HEX
Server: Apache/2.4.41 (Amazon) OpenSSL/1.0.2k-fips PHP/5.6.40
System: Linux ip-172-31-40-18 4.14.146-93.123.amzn1.x86_64 #1 SMP Tue Sep 24 00:45:23 UTC 2019 x86_64
User: apache (48)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: /var/www/html/taxicamera/applicationold/views/admin/roster/roster.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: #FF4500 !important;
		color: #fff;
	} */

	label.brek2.chk_custom_box.hara_bhara {
		background: #2bab11 !important;
		color: #fff;
		margin-bottom: 0;
	}

	label.brek2.chk_custom_box.light_orange {
		background: #FF4500 !important;
		color: #fff;
		margin-bottom: 0;
	}

	

	.brek2 {}

span.select2.select2-container {
    font-size: 11px;
    font-weight: 700;
}
span.select2-results {
    font-size: 12px;
}

	.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;
	}

	.page-title-wrap form label {
     float: none; 
    
}


</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') ?>

									
										<!-- accordian_area -->
										<div id="accordionWrap1" class="accordion roster_accordian">
											<div class="card collapse-icon accordion-icon-rotate">
											<div id="heading11"  class="card-header">
												<a data-toggle="collapse" href data-target="#accordion11" aria-expanded="false" aria-controls="accordion11" class="card-title lead collapsed">Import Roster Daily / Weekly</a>
											</div>
											<div id="accordion11" data-parent="#accordionWrap1" aria-labelledby="heading11" class="collapse">
												<div class="card-body">
												<div class="card-block">
													<!-- tab-->
													<div class="staff_tab_area">
														<ul class="nav nav-tabs" role="tablist">
															<li class="nav-item">
																<a class="nav-link active show" data-toggle="tab" href="#active_user">Daily</a>
															</li>
															<li class="nav-item">
																<a class="nav-link" data-toggle="tab" href="#inactive_user">Weekly</a>
															</li>
														<!-- 	<li class="nav-item">
																<a class="nav-link" data-toggle="tab" href="#trash_user">Trash Driver</a>
															</li> -->
														</ul>

														<div class="tab-content">
															<div id="active_user" class="tab-pane active"><br>
															<div class="search_by_date">
																<form id="roster_import_day" 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>Select Import From Date</label>
																				<div class="input-group">
																					<input type="text" class="form-control" id="day_date_from" name="day_date_from" value="" placeholder="" required/>
																					<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-4">
																			<div class="form-group">
																			<label>Select Import To Date</label>
																				<div class="input-group">
																					<input type="text" class="form-control" id="day_date_to" name="day_date_to" placeholder="" value="" required/>
																					<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">
																				<button type="button" name="daily_roster_import" id="daily_roster_import" class="btn btn-success" style="margin-top:30px;">Import Daily</button>
																				

																			</div>
																		</div>
																	</div>
																</form>

															</div>
															</div>
															<div id="inactive_user" class="tab-pane"><br>
															<?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/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']; ?>" <?=($week==$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 
																$current_week = $date->format("W");
																foreach ($weeks as $wk) : 
																	if($wk['week_name'] > $current_week):
															?>
																<option value="<?= $wk['week_name']; ?>"><?= $wk['week_name']; ?></option>
															<?php endif; endforeach; ?>
														</select>

													</div>
												</div>
												<div class="col-md-3">
												<div class="form-group">
													<button type="submit" class="btn btn-success" id="roster_import" name="roster_import"  style="margin-top:30px;">Import roster</button>
												</div>
											</div>

											</div>


										</form>
									</div>
															</div>
														</div>




													</div>
													<!-- tab end -->
													
												</div>
												</div>
											</div>
											<div id="heading12"  class="card-header">
												<a data-toggle="collapse" href data-target="#accordion12" aria-expanded="true" aria-controls="accordion12" class="card-title lead">Add / View / Edit Roster (Current Week Number : <?=  $date->format("W"); ?>)</a>
											</div>
											<div id="accordion12" data-parent="#accordionWrap1" aria-labelledby="heading12" class="collapse show">
												<div class="card-body">
												<div class="card-block">
												<div class="select_edit_form">
										
										<form action="<?= base_url(); ?>admin/roster" method="post" id="edit_roster_by_wk">
											<div class="row">
												<div class="col-md-6">
													<div class="form-group">
														<label>Select Week No</label>
														<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 class="col-md-6">
													<div class="form-group">
														<label>Select Car </label>
														<div class="search-tag">
														<select name="get_car_no_view" id="get_car_no_view" class="js-select2" data-show-subtext="true" data-live-search="true">
														<option value="">Select All</option> 
														<?php foreach ($cars as $car) : ?>
															<option value="<?= $car['car_id']; ?>" <?=($car_no==$car['car_id'])?'selected':''?>><?= $car['registration_no']; ?></option>
														<?php endforeach; ?>
														</select>
														
													</div>
													</div>
												</div>


											</div>
										</form>
									</div>


									<!-- -------------------------------------------------------------------------------------------------------  -->
									<?php if (!empty($get_car_by_wk)) { $count =0; $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; ?>">

											
											<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 ($get_car_by_wk as $car1) {$count++; 
																if($count == 1){ 
																foreach ($car1  as $ax1) { ?>
																	<td class=""><?= $ax1['roster']['dayname']; ?> <span><?= date('d/m/Y',strtotime($ax1['roster']['day_date']))?> </span></td>
													<?php 	}	}	} ?>
															
															
																
															</thead>

															<tbody>
											
											<?php
												$i = 0;
												foreach ($get_car_by_wk as $car) :?>
												
												<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 $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" class="day_date_roster" 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 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 light_orange">
																				<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="<?= $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; ?>]" <?=$disabled_shift?>>
																							<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'] ."-".$driver['first_name']  ?></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_submit_edit" name="roster_submit_edit"   class="btn btn-info">Submit</button>
											</div> -->

										</form>

									<?php } else { ?>


										<form method="post" class="set_roster_frm"  id="roster_form_add" action="<?= base_url('admin/roster/add_roster'); ?>">


											<input type="hidden" name="week_no" value="<?= $week_no; ?>">

											<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>
															<td class="">Car No.</td>
															<?php foreach ($day_array  as $key_cnt => $day) {?>
																	<td class=""><?= $day['day'] ?><br><span><?= date('d/m/Y',strtotime($day['date'])) ?> </span></td>
															<?php 	} ?>
															
														</thead>
														<tbody>
														
											<?php $i = 0;$unselectable_cls='';
											//pr($cars);
											
												foreach ($cars as $car) : ?>
												<tr>
												<!-- <h1><?= $car['registration_no']; ?></h1> -->

												<?php if ($car['accident_status'] == 0) : ?>
													<input type="hidden" name="car_id[]" value="<?= $car['car_id']; ?>">
													
																
																<td><?= $car['registration_no']; ?></td>
																	<?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" class="day_date_roster" 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 Br/Ac</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" class="custom_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 custom_select" name="driver_id[<?= $i; ?>][<?= $d; ?>][<?= $sts; ?>]">
																							<option value="">Select Driver</option>
																							<?php foreach ($driver_list as $driver) : ?>
																								<option value="<?= $driver['user_id']; ?>"><?= $driver['dc_no'] ."-".$driver['first_name'] ?></option>
																							<?php endforeach; ?>
																						</select>
																					</div>
																				</div>

																			<?php $sts++;
																							endforeach; ?>

																		</td>
																		

																	<?php $d++;
																				endforeach; ?>


																</tr>


												
												<?php endif; ?>
											<?php $i++;
												endforeach;	?>
												</tbody>

</table>
</div>
</div>
											
											
										</form>
									<?php } ?>
										</div>
									</div>
								</div>
							</div>
						</div>
										<!-- accordian_area end-->
										
										
									

									


									

									<!------------------------------------------------------------------------------------------------------------  -->
								</div>
							</div>
						</div>
					</div>
				</div>
			</section>
		</div>
	</div>
</div>
<script type="text/javascript">
	$(document).ready(function(){

		populate_datepicker();

			$(".wrapper").addClass("menu-collapsed nav-collapsed");
			$(".toggle-icon").removeClass("ft-disc");
			$(".toggle-icon").addClass("ft-circle");
			$(".toggle-icon").attr("data-toggle",'collapsed');
	})

	$('#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);
		}

	})
	
	$('#get_week_no_edit').change(function() {
		$('#edit_roster_by_wk').submit();
	});

	// function populate_datepicker(){
		
	// 	$('#day_date_from').pickadate({
	// 		format: 'dd/mm/yyyy',
	// 		autoclose: true,
	// 	}),
			
	// 	$('#day_date_to').pickadate({
	// 		format: 'dd/mm/yyyy',
	// 		autoclose: true,
	// 		min:'0'
	// 	})
	
	// }

	function populate_datepicker(){

var from_$input = $('#day_date_from').pickadate({
  format: 'dd/mm/yyyy',
  autoclose: true
 }),
 from_picker = from_$input.pickadate('picker')

var to_$input = $('#day_date_to').pickadate({
  format: 'dd/mm/yyyy',
  autoclose: true
 }),
 to_picker = to_$input.pickadate('picker')

// Check if there’s a “from” or “to” date to start with.
if (from_picker.get('value')) {
 to_picker.set('min', from_picker.get('select'))
}
if (to_picker.get('value')) {
 from_picker.set('max', to_picker.get('select'))
}

// When something is selected, update the “from” and “to” limits.
from_picker.on('set', function(event) {

 if (event.select) {
  to_picker.set('min', from_picker.get('select'));
 } else if ('clear' in event) {
  to_picker.set('min', false);
 }
})

to_picker.on('set', function(event) {

 if (event.select) {
  from_picker.set('max', to_picker.get('select'));
  $("#day_date").val(to_picker.get('select'));
 } else if ('clear' in event) {
  from_picker.set('max', false);
  $("#day_date").val('');
 }
})

}

	$('.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') {
				$(this).parent('label').addClass('light_orange');
				//------------------------------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).parent('label').removeClass('light_orange');
			$(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();
			$(this).parents('.driver_shift_div').find('.driver_select_div select').select2().val(null).trigger("change");
			
			
			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',
				});
			}
		}
		
	})

	$(document).on('select2:select','.custom_select',function(){
		
		var selected_flag =true;
		var selected_driver_for_day = $(this).val();
		var selected_day = $(this).parents('td').find('.day_date_roster').val();
		
		$('.day_date_roster').not($(this).parents('td').find('.day_date_roster')).each(function(){
			
			if($(this).val() === selected_day){
				
				$(this).parents('td').find('.driver_shift_div select:not(:disabled)').each(function(){
					//&& ($(this).parents('.breakdown_select_div').find('select').val() == '')
					if(($(this).val() !='') && ($(this).val() === selected_driver_for_day)){
					
						$.alert({
							type: 'red',
							title: 'Driver Already Assigned For Another Car',
							content: 'Please Select Another Driver',
						});
						selected_flag=false;
					}

				})
			}
		})
		if(!selected_flag){
			$(this).select2().val(null).trigger("change");
		}
	})



	$("#daily_roster_import").click(function(e){
		e.preventDefault();
		var day_date_from =$("#day_date_from").val();
		var day_date_to =$("#day_date_to").val();
		if(!day_date_from || !day_date_to){

			$.alert({
				type: 'red',
				title: 'Import Date From  & To  Mandatory',
				content: 'Please select import from date and import to date',
			});
			return false;
			
		}
		else{
			$("#roster_import_day").submit();
		}
	})

	$(document).on("click","#roster_submit_edit",function(e){
		e.preventDefault();
		if($("#roster_edit_form").valid()){
			$("#roster_edit_form").submit();
		}

	})

	$(document).on("click","#roster_submit_add",function(e){
		e.preventDefault();
		if($("#roster_form_add").valid()){
			$("#roster_form_add").submit();
		}

	})

	
</script>