File: /var/www/html/taxicamera/applicationold/views/admin/roster/roster_bckup.php
<style>
/* Roster CSS */
/* .set_roster_frm select {
display: none;
width: 100%;
padding: 3px;
} */
.unselectable{
background-color: #ddd;
pointer-events: none;
cursor: not-allowed;
}
.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;
}
.brek2 {}
.brek2.chk_custom_box {
font-size: 13px !important;
padding-left: 0 !important;
}
.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">Roster Setup</h4>
<?php echo $this->session->flashdata('msg') ?>
<div class="search_by_date">
<form class="roster_form_s" method="post" action="<?= base_url(); ?>admin/roster/search_date">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<!--<label>From Date</label>-->
<div class="input-group">
<input type="date" class="form-control" name="day_date" placeholder="" />
<div class="input-group-append">
<span class="input-group-text">
<span class="fa fa-calendar-o"></span>
</span>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<input type="submit" name="" class="btn btn-success">
</div>
</div>
</div>
</form>
</div>
<?php
$ddate = date('Y-m-d');
$date = new DateTime($ddate);
if(!empty($week_no)){
$week = $week_no;
}
else{
$week = $date->format("W");
}
$year = date('Y');
$week_array = getStartAndEndDate($week, $year);
//print_r($week_array);
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">
<h4 class="form-section2">Import Roster</h4>
<form action="<?= base_url(); ?>admin/import_roster" method="post" id="search_roster_by_wk">
<div class="row">
<div class="col-md-3">
<div class="form-group">
<!--<label>Select Taxi</label>-->
<select class="js-select2" data-show-subtext="true" data-live-search="true" name="get_week_no" id="get_week_no" required>
<option value="">Select Week</option>
<?php foreach ($weeks as $wk) : ?>
<option value="<?= $wk['week_name']; ?>"><?= $wk['week_name']; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<button type="button" class="btn btn-success" id="prevwk">Import Roster</button>
</div>
</div>
</div>
</form>
</div>
<div class="select_edit_form">
<h4 class="form-section2">Add / View / Edit Roster (Current Week Number : <?= $week ?>)</h4>
<form action="<?= base_url(); ?>admin/roster" method="post" id="edit_roster_by_wk">
<div class="row">
<div class="col-md-3">
<div class="form-group">
<select name="get_week_no_edit" id="get_week_no_edit" class="js-select2" data-show-subtext="true" data-live-search="true">
<option value="">Select Week</option>
<?php foreach ($weeks as $wk) : ?>
<option value="<?= $wk['week_name']; ?>" <?= ($week_no == $wk['week_name']) ? 'selected' : '' ?>><?= $wk['week_name']; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
</form>
</div>
<!-- ------------------------------------------------------------------------------------------------------- -->
<?php if (!empty($get_car_by_wk)) { $unselectable_cls='';?>
<form method="post" class="set_roster_frm edt_import_form" id="roster_edit_form" action="<?= base_url('admin/roster/add_roster'); ?>">
<input type="hidden" name="week_no" value="<?= $week_no; ?>">
<?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']; ?>">
<div class="days_of_week table-responsive custom_table_area">
<div class="table-responsive roster_table">
<table class="table-responsive custom_table_area table">
<thead>
<?php foreach ($car as $ax) :
if($ax['roster']['day_date'] <= date('Y-m-d')){
$unselectable_cls='unselectable';
} else {
$unselectable_cls='';
}
?>
<td class="<?=$unselectable_cls?>"><?= $ax['roster']['dayname']; ?><span><?= $ax['roster']['day_date']; ?> </span></td>
<?php endforeach; ?>
</thead>
<tbody>
<?php $d = 0;$disabled_shift='';
foreach ($car as $ax) :
if($ax['roster']['day_date'] <= date('Y-m-d')){
$unselectable_cls='unselectable';
} else {
$unselectable_cls='';
}
?>
<td class="<?=$unselectable_cls?>">
<input type="hidden" name="dayname[<?= $i; ?>][]" value="<?= $ax['roster']['dayname'] ?>">
<input type="hidden" name="day_date[<?= $i; ?>][]" value="<?= $ax['roster']['day_date']; ?>">
<input type="hidden" name="roster_id_hidden[<?= $i; ?>][]" value="<?= $ax['roster']['roster_id']; ?>">
<?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 Breakdown/Accident</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 Breakdown/Accident</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="<?= $roster_shift_id ?>">
<input type="hidden" name="roster_driver_id_hidden[<?= $i; ?>][<?= $d; ?>][<?= $sts; ?>]" value="<?= $roster_driver_id; ?>">
<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['full_name']; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<?php $sts++;
endforeach; ?>
</td>
<?php $d++;
endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php $i++;
endforeach; ?>
<div class="col md-12" style="text-align:center;">
<button type="submit" id="roster_submit" name="roster_submit" class="btn btn-info submit_cls">Submit</button>
</div>
</form>
<?php } else { ?>
<form method="post" class="set_roster_frm" action="<?= base_url('admin/roster/add_roster'); ?>">
<input type="hidden" name="week_no" value="<?= $week_no; ?>">
<?php $i = 0;$unselectable_cls='';
foreach ($cars as $car) : ?>
<h1><?= $car['registration_no']; ?></h1>
<?php if ($car['accident_status'] == 0) : ?>
<input type="hidden" name="car_id[]" value="<?= $car['car_id']; ?>">
<div class="days_of_week table-responsive custom_table_area">
<div class="table-responsive roster_table">
<table class="table table-striped custom_table_area">
<thead>
<?php foreach ($day_array as $day) :
if(date('Y-m-d',strtotime($day['date'])) <= date('Y-m-d')){
$unselectable_cls='unselectable';
} else {
$unselectable_cls='';
}
?>
<td class="<?=$unselectable_cls?>"><?= $day['day'] ?><span><?= $day['date']; ?> </span></td>
<?php endforeach; ?>
</thead>
<tbody>
<?php $d = 0;
foreach ($day_array as $day) :
if(date('Y-m-d',strtotime($day['date'])) <= date('Y-m-d')){
$unselectable_cls='unselectable';
} else {
$unselectable_cls='';
}
?>
<td class="<?=$unselectable_cls?>">
<input type="hidden" name="dayname[<?= $i; ?>][]" value="<?= $day['day'] ?>">
<input type="hidden" name="day_date[<?= $i; ?>][]" value="<?= $day['date']; ?>">
<input type="hidden" name="roster_id_hidden[<?= $i; ?>][]" value="">
<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 Breakdown/Accident</option>
<option value="Breakdown">BreakDown</option>
<option value="Accident">Accident</option>
</select>
</div>
<?php $sts = 0;
foreach ($shift_array as $single_shift) : ?>
<div class="driver_shift_div">
<label class="brek2 chk_custom_box">
<input type="checkbox" name="shift_name[<?= $i; ?>][<?= $d; ?>][<?= $sts; ?>]" value="<?= $single_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="display:none;">
<select class="js-select2" name="driver_id[<?= $i; ?>][<?= $d; ?>][<?= $sts; ?>]">
<option value="">Select Driver</option>
<?php foreach ($driver_list as $driver) : ?>
<option value="<?= $driver['user_id']; ?>"><?= $driver['full_name']; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<?php $sts++;
endforeach; ?>
</td>
<?php $d++;
endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php elseif ($car['accident_status'] == 1) : ?>
<div class="alert alert-danger" role="alert">
<?= $car['accident_review']; ?>
</div>
<?php endif; ?>
<?php $i++;
endforeach; ?>
<button type="submit" class="btn btn-info">Submit</button>
</form>
<?php } ?>
<!------------------------------------------------------------------------------------------------------------ -->
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
</div>
<script type="text/javascript">
// $('#get_week_no').change(function() {
// $('#search_roster_by_wk').submit();
// });
$('#get_week_no_edit').change(function() {
$('#edit_roster_by_wk').submit();
});
// $(document).on("change", ".custom_select", function(e) {
// e.preventDefault('.custom_checkbox');
// e.stopPropagation('.custom_checkbox');
// alert("select");
// })
// $(document).on("click", ".custom_checkbox", function(e) {
// e.preventDefault('.custom_select');
// e.stopPropagation('.custom_select');
// alert("checkbox");
// })
$('.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');
}
});
// $('.edt_import_form label').each(function() {
// var did = $(this).children('input[type="checkbox"]').attr('set-dv');
// alert(did);
// //$(this).children('select').find('option[value="'+did+'"]').css('color','green');
// $(this).children('select').find('option[value="' + did + '"]').attr('selected', 'selected');
// //$(this).append(did);
// });
$('#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',
});
}
});
$(".submit_cls").click(function(){
if(this.id=='roster_submit'){
$("#roster_edit_form").submit();
}
else{
var get_week_no=$("#get_week_no").val();
if(get_week_no){
$("#roster_edit_form").submit();
}
else{
$.alert({
type: 'red',
title: 'Import Week Not Selected',
content: 'Please Select week to import roster',
});
}
}
})
</script>