File: /var/www/html/taxicamera/old/applicationold/views/admin/roster/roster_import.php
<style>
/* Roster CSS */
/* .set_roster_frm select {
display: none;
width: 100%;
padding: 3px;
} */
.roster_table .table th, .table td {
padding: 7px;
vertical-align: top;
border-top: 3px solid #1db5bd;
}
.brek2.chk_custom_box {
font-size: 11px !important;
padding-left: 0 !important;
letter-spacing: initial;
color: #000;
}
.unselectable{
background-color: #ddd;
cursor: not-allowed;
pointer-events: none;
}
.get_dvr_detail {
pointer-events: all;
}
.set_roster_frm label {
width: 100%;
background: #ccc;
cursor: pointer;
}
.set_roster_frm .select2.select2-container .select2-selection {
margin-bottom: 0 !important;
}
edit_roster_by_wk .select2.select2-container .select2-selection {
margin-bottom: 0 !important;
}
#edit_roster_by_wk .form-group,
#search_roster_by_wk .form-group,
.roster_form_s .form-group,
{
margin-bottom: 0 !important;
}
.form-section2 {
color: #343A40;
line-height: 3rem;
font-size: 1.2rem;
letter-spacing: 0.5px;
font-weight: 400;
margin-bottom: 15px;
border-bottom: 1px solid #b7b5b5;
}
.roster_table .table thead tr td {
background: #1db5bd;
color: #fff;
font-size: 13px;
}
.roster_table.table-striped tbody tr:nth-of-type(odd) {
background-color: #edfaff !important;
}
.breakdown.hara_bhara {
background: #2bab11 !important;
color: #fff;
}
label.brek2.chk_custom_box.hara_bhara {
background: #2bab11 !important;
color: #fff;
margin-bottom: 0;
}
.brek2.chk_custom_box:hover input~.checkmark,
.brek2.chk_custom_box .checkmark {
background-color: #5d6061 !important;
}
/*===========================================================
RESPONSIVE CSS
=============================================================*/
@media only screen and (min-width:220px) and (max-width:767px) {}
@media only screen and (min-width:320px) and (max-width:479px) {
.card-header .title_btn {
float: none;
display: block;
width: 101px;
margin-top: 10px;
}
}
.btn-save-all {
background: #239c91;
padding: 5px 10px;
display: inline-block;
color: #fff;
border-radius: 3px;
font-size: 15px;
}
</style>
<div class="main-content">
<div class="content-wrapper">
<div class="container-fluid">
<!-- Basic form layout section start -->
<section id="basic-form-layouts">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<div class="page-title-wrap">
<h4 class="card-title">Import Roster</h4>
<?php echo $this->session->flashdata('msg') ?>
<?php
if(!empty($set_week_no_roster)){
$week = $set_week_no_roster;
}
else{
$ddate = date('Y-m-d');
$date = new DateTime($ddate);
$week = $date->format("W");
}
$year = date('Y');
$week_array = getStartAndEndDate($week, $year);
//echo '<pre>'; print_r($week_array);die;
function getStartAndEndDate($week, $year){
$dto = new DateTime();
$dto->setISODate($year, $week);
$ret['monday'] = $dto->format('Y-m-d');
$dto->modify('+1 days');
$ret['tuesday'] = $dto->format('Y-m-d');
$dto->modify('+1 days');
$ret['wednesday'] = $dto->format('Y-m-d');
$dto->modify('+1 days');
$ret['thursday'] = $dto->format('Y-m-d');
$dto->modify('+1 days');
$ret['friday'] = $dto->format('Y-m-d');
$dto->modify('+1 days');
$ret['saturday'] = $dto->format('Y-m-d');
$dto->modify('+1 days');
$ret['sunday'] = $dto->format('Y-m-d');
return $ret;
}
$day_array = array(
0 => array(
'day' => 'Monday',
'date' => $week_array['monday'],
),
1 => array(
'day' => 'Tuesday',
'date' => $week_array['tuesday'],
),
2 => array(
'day' => 'Wednesday',
'date' => $week_array['wednesday'],
),
3 => array(
'day' => 'Thursday',
'date' => $week_array['thursday'],
),
4 => array(
'day' => 'Friday',
'date' => $week_array['friday'],
),
5 => array(
'day' => 'Saturday',
'date' => $week_array['saturday'],
),
6 => array(
'day' => 'Sunday',
'date' => $week_array['sunday'],
),
);
$shift_array = array('H', 'D', 'N');
?>
<div class="select_form">
<form action="<?= base_url(); ?>admin/roster/import_roster" method="post" id="search_roster_by_wk">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>Select Import From Week No</label>
<select class="js-select2" data-show-subtext="true" data-live-search="true" name="get_week_no_roster" id="get_week_no_roster" required>
<option value="">Select Week</option>
<?php foreach ($weeks as $wk) : ?>
<option value="<?= $wk['week_name']; ?>" <?=($get_week_no_roster==$wk['week_name'])?'selected':''?>><?= $wk['week_name']; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Select Import To Week No</label>
<select class="js-select2" data-show-subtext="true" data-live-search="true" name="set_week_no_roster" id="set_week_no_roster" required>
<option value="">Select Week</option>
<?php foreach ($weeks as $wk) : ?>
<option value="<?= $wk['week_name']; ?>" <?=($set_week_no_roster==$wk['week_name'])?'selected':''?>><?= $wk['week_name']; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<button type="button" onclick="window.location.href='<?=base_url('admin/roster')?>'" class="btn btn-success" style="margin-top:30px;">Back To Roster</button>
</div>
</div>
</div>
</form>
</div>
<!-- ------------------------------------------------------------------------------------------------------- -->
<?php if (!empty($get_car_by_wk)) {?>
<form method="post" class="set_roster_frm edt_import_form" id="roster_import_form" action="<?= base_url('admin/roster/import_roster_submit'); ?>">
<input type="hidden" name="week_no" value="<?= $set_week_no_roster; ?>">
<div class="days_of_week table-responsive custom_table_area">
<div class="table-responsive roster_table">
<table class=" custom_table_area table">
<thead>
<td class="">Car No.</td>
<?php foreach ($day_array as $day) : ?>
<td><?= $day['day'] ?><br><span><?= date('d/m/Y',strtotime($day['date'])) ?> </span></td>
<?php endforeach; ?>
</thead>
<tbody>
<?php
$i = 0;
foreach ($get_car_by_wk as $car) :?>
<!-- <h1><?= $car[0]['roster']['registration_no']; ?></h1> -->
<input type="hidden" name="car_id[]" value="<?= $car[0]['roster']['car_id']; ?>">
<tr>
<td><?= $car[0]['roster']['registration_no']; ?></td>
<?php $d = 0;$disabled_shift='';
foreach ($car as $key => $ax) : ?>
<td>
<input type="hidden" name="roster_id_hidden[<?= $i; ?>][]" value="">
<input type="hidden" name="dayname[<?= $i; ?>][]" value="<?= $day_array[$key]['day'] ?>">
<input type="hidden" name="day_date[<?= $i; ?>][]" value="<?= $day_array[$key]['date']; ?>">
<?php if ($ax['roster']['breakdown'] != 1) { $disabled_shift='';?>
<label class="breakdown brek2 chk_custom_box">
<input type="checkbox" name="breakdown[<?= $i; ?>][<?= $d; ?>]" class="breakdown" value="1" data-checkbox_type="B"> Breakdown / Accident
</label>
<div class="breakdown_select_div" style="display:none;">
<select class="js-select2" name="breakdown_reason[<?= $i; ?>][<?= $d; ?>]">
<option value="">Select Br/Ac</option>
<option value="Breakdown">BreakDown</option>
<option value="Accident">Accident</option>
</select>
</div>
<?php } else { $disabled_shift='disabled'; ?>
<!-- <div class='alert alert-danger'><?=$ax['roster']['breakdown_reason']?></div> -->
<label class="breakdown brek2 chk_custom_box hara_bhara">
<input type="checkbox" name="breakdown[<?= $i; ?>][<?= $d; ?>]" class="breakdown" value="1" checked data-checkbox_type="B"> Breakdown / Accident
</label>
<div class="breakdown_select_div">
<select class="js-select2" name="breakdown_reason[<?= $i; ?>][<?= $d; ?>]">
<option value="">Select Br/Ac</option>
<option value="Breakdown" <?= ($ax['roster']['breakdown_reason'] == 'Breakdown') ? 'selected' : '' ?>>BreakDown</option>
<option value="Accident" <?= ($ax['roster']['breakdown_reason'] == 'Accident') ? 'selected' : '' ?>>Accident</option>
</select>
</div>
<?php } ?>
<?php $sts = 0;$disabled_day_night='';
foreach ($shift_array as $single_shift) :
$checked = $checked_class = $set_dv = $roster_shift_id = $roster_driver_id = $set_driver_id= '';
$style_class = 'display:none';
foreach ($car[$d]['roster']['shift'] as $shift) {
if ($shift['shift_name'] == $single_shift) {
$checked = "checked";
if($single_shift == 'H'){
$disabled_day_night='disabled';
}
$set_driver_id =$shift['driver']['driver_id'];
$set_dv = " set-dv=".$shift['driver']['driver_id'];
$roster_shift_id = $shift['roster_shift_id'];
$roster_driver_id = $shift['driver']['roster_driver_id'];
$checked_class = 'hara_bhara';
$style_class = "display:block;";
}
}
?>
<div class="driver_shift_div">
<label class="brek2 chk_custom_box <?= $checked_class ?>">
<a href="javascript:void(0)" class="get_dvr_detail"><i class="fa fa-eye" aria-hidden="true"></i></a>
<span class="shw_drvr_details"></span>
<input type="checkbox" class="custom_checkbox" name="shift_name[<?= $i; ?>][<?= $d; ?>][<?= $sts; ?>]" value="<?= $single_shift; ?>" <?= $checked ?> <?= $set_dv ?> <?=($single_shift =='D' || $single_shift =='N')?$disabled_day_night:''?> <?=$disabled_shift?>/><?= $single_shift; ?>
</label>
<input type="hidden" name="roster_shift_id_hidden[<?= $i; ?>][<?= $d; ?>][<?= $sts; ?>]" value="">
<input type="hidden" name="roster_driver_id_hidden[<?= $i; ?>][<?= $d; ?>][<?= $sts; ?>]" value="">
<div class="driver_select_div" style="<?= $style_class ?>">
<select class="js-select2 custom_select" name="driver_id[<?= $i; ?>][<?= $d; ?>][<?= $sts; ?>]">
<option value="">Select Driver</option>
<?php foreach ($driver_list as $driver) : ?>
<option value="<?= $driver['user_id']; ?>" <?=($set_driver_id == $driver['user_id'])?'selected':''?>><?= $driver['dc_no']; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<?php $sts++;
endforeach; ?>
</td>
<?php $d++;
endforeach; ?>
</tr>
<?php $i++;
endforeach; ?>
</tbody>
</table>
</div>
</div>
<div class="col md-12" style="text-align:center;">
<button type="submit" id="roster_import_submit" name="roster_import_submit" class="btn btn-info">Submit</button>
</div>
</form>
<?php } else { ?>
<div class="alert alert-success alert-dismissible"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>No Roster Data Available for the selected week</div>
<?php } ?>
<!------------------------------------------------------------------------------------------------------------ -->
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$(".wrapper").addClass("menu-collapsed nav-collapsed");
$(".toggle-icon").removeClass("ft-disc");
$(".toggle-icon").addClass("ft-circle");
$(".toggle-icon").attr("data-toggle",'collapsed');
})
$('#get_week_no_roster').change(function() {
$('#search_roster_by_wk').submit();
});
$('#set_week_no_roster').change(function(){
var set_week_no_roster =$(this).val();
var get_week_no_roster =$("#get_week_no_roster").val();
if(get_week_no_roster >= set_week_no_roster){
$.alert({
type: 'red',
title: 'Import From week Should Not Greater Than To Week',
content: 'Please select import to week which greater than import from week',
});
$("#set_week_no_roster").val('');
$("#week_no").val('');
}
else{
$("#week_no").val(set_week_no_roster);
}
})
$("#roster_import_submit").submit(function(e){
e.preventDefault();
var set_week_no_roster =$("#set_week_no_roster").val();
var get_week_no_roster =$("#get_week_no_roster").val();
if(!get_week_no_roster || !set_week_no_roster){
$.alert({
type: 'red',
title: 'Import From week & To Week Mandatory',
content: 'Please select import from week and import to week',
});
$("#set_week_no_roster").val('');
$("#week_no").val('');
}
else{
$("#week_no").val(set_week_no_roster);
$("#roster_import_form").submit();
}
})
$('.chk_custom_box input[type="checkbox"]').click(function() {
if ($(this).is(':checked')) {
//------------------------------For showing green color as active-----------------------------------------//
$(this).parent('label').addClass('hara_bhara');
//-------------------------------Set all select & checkbox disabled false---------------------------------//
$(this).parents('td').find('input[type="checkbox"]').attr('disabled', false);
$(this).parents('td').find('select').attr('disabled', false);
if ($(this).data('checkbox_type') == 'B') {
//------------------------------For showing breakdown dropdown and set required field-----------------------------------------//
$(this).parents('td').children('.breakdown_select_div').show();
$(this).parents('td').find('.breakdown_select_div select').slideDown();
$(this).parents('td').find('.breakdown_select_div select').attr('required',true);
//------------------------------For blocking all checkbox & dropdown-----------------------------------------//
$(this).parents('td').find('input:checkbox').not(this).attr('disabled', true);
$(this).parents('td').find('.driver_select_div select').attr('disabled', true);
$(this).parents('td').find('.chk_custom_box').not($(this).parent('label')).removeClass('hara_bhara');
$(this).parents('td').find('.driver_select_div').hide();
} else {
$(this).parents('.driver_shift_div').children('.driver_select_div').show();
$(this).parents('.driver_shift_div').find('.driver_select_div select').slideDown();
$(this).parents('.driver_shift_div').find('.driver_select_div select').attr('required', true);
var val = $(this).val();
if (val == 'H') {
$(this).parents('td').find('.driver_shift_div input:checkbox').not(this).attr('disabled', true);
$(this).parents('td').find('.driver_select_div select').not($(this).parents('.driver_shift_div').find('.driver_select_div select')).attr('disabled', true);
$(this).parents('td').find('.chk_custom_box').not($(this).parent('label')).removeClass('hara_bhara');
$(this).parents('td').find('.driver_select_div').not($(this).parents('.driver_shift_div').find('.driver_select_div')).hide();
}
}
} else {
$(this).parent('label').removeClass('hara_bhara');
$(this).parents('td').children('.breakdown_select_div').hide();
$(this).parents('.driver_shift_div').children('.driver_select_div').hide();
$(this).parents('.driver_shift_div').find('.driver_select_div select').slideUp();
if($(this).data('checkbox_type') == 'B'){
$(this).parents('td').find('.breakdown_select_div select').attr('required',false);
} else{
$(this).parents('.driver_shift_div').find('.driver_select_div select').attr('required', false);
}
$(this).parents('td').find('input[type="checkbox"]').removeAttr('disabled');
}
});
$('#prevwk').click(function() {
var val = $(this).val();
//alert(val);
$(this).siblings('select').val(val);
$('#search_roster_by_wk').submit();
});
$('a.get_dvr_detail').click(function() {
var details = $(this).siblings('.shw_drvr_details');
var user_id = $(this).siblings("input[type='checkbox']").attr('set-dv');
//alert(user_id);
if (user_id !== undefined) {
$.ajax({
type: "POST",
url: '<?= base_url(); ?>admin/roster/get_driver_details/' + user_id,
success: function(response) {
$.alert({
type: 'green',
title: 'Driver Details',
content: response,
});
//details.html(response);
}
});
} else {
$.alert({
type: 'red',
title: 'No Driver Set',
content: 'No driver is set here',
});
}
});
</script>