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/old/applicationold/views/admin/report/levy/list.php
<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-sm-12">
			<h2 class="content-header">Driver Master</h2>
		</div>
	</div>-->
				<div class="row">
					<div class="col-md-12">
						<div class="card">
							<div class="card-header">
								<div class="page-title-wrap">
									<h4 class="card-title">Levy Report</h4>

								</div>


								<!--<p class="mb-0">This is the most basic and cost estimation form is the default position.</p>-->
							</div>
							<div class="card-body">
								<div class="px-3">
									<form id="unsettled_settled_levy_form" name="unsettled_settled_levy_form" method="POST">
										<div class="form-body">
											<!----->
											<div class="row">
												<div class="col-md-12">
													<div class="staff_tab_area">
														<ul class="nav nav-tabs" role="tablist">
															<li class="nav-item">
																<a class="nav-link active" data-toggle="tab" href="#active_user">Un Settled</a>
															</li>
															<li class="nav-item">
																<a class="nav-link" data-toggle="tab" href="#inactive_user">Settled</a>
															</li>
														</ul>
														<!-- Tab panes -->
														<div class="tab-content">

															<div id="active_user" class="tab-pane active">
																<div class="user_permission_top">
																	<div class="row">
																		<div class="col-md-3">
																			<div class="form-group">
																				<label>Company Name</label>
																				<select name="company_id_unsettle" id="company_id_unsettle" class="js-select2 company_cls" data-show-subtext="true" data-live-search="true" data-settle_unsettle="unsettle">
																					<option value="">Select Company</option>
																					<?php foreach ($company_list as $company) { ?>
																						<option value="<?= $company['company_id'] ?>"><?= $company['company_name'] ?></option>
																					<?php } ?>
																				</select>
																			</div>
																		</div>
																		<div class="col-md-3">
																			<div class="form-group">
																				<label>Driver</label>
																				<select class="js-select2" name="driver_id_unsettle" id="driver_id_unsettle" data-show-subtext="true" data-live-search="true">
																					<option value="">Select Driver</option>
																					<?php foreach ($driver_list as $driver) { ?>
																						<option value="<?= $driver['user_id'] ?>"><?= $driver['first_name'] . ' - ' . $driver['dc_no'] ?></option>
																					<?php } ?>
																				</select>
																			</div>
																		</div>

																		<div class="col-md-2">
																			<div class="form-group">
																				<label>From Date</label>
																				<div class="input-group">
																					<input type="text" name="from_date_unsettle" id="from_date_unsettle" class="form-control pickadate" 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-2">
																			<div class="form-group">
																				<label>To Date</label>
																				<div class="input-group">
																					<input type="text" class="form-control pickadate" placeholder="" name="to_date_unsettle" id="to_date_unsettle" />
																					<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-2">
																			<div class="form-group">
																				<label class="blank_lbl">&nbsp;</label>
																				<button type="button" class="btn btn-success settle_unsettle_btn" data-levy_settled_flag="0" data-settle_unsettle="unsettle">
																					<i class="fa fa-search" aria-hidden="true"></i> Search
																				</button>
																			</div>
																		</div>
																	</div>

																</div>
																<!-- <div class="show_data">
																	<div class="row clearfix">
																		<div class="col-sm-12">
																			<ul class="list_show_data">
																				<li><strong>Total Levy: </strong> 900</li>
																				<li><strong>Total GST: </strong> 90</li>
																			</ul>
																		</div>
																	</div>
																</div> -->

																<div class="row">

																	<div class="table-responsive custom_table_area export_table_area">
																		<table id="levy_table_unsettle" class="table table-striped table-bordered export_btn_dt file-export c_table_style">
																			<thead>
																				<tr>
																					<th>SL No.</th>
																					<th>First Name</th>
																					<th>Middle Name</th>
																					<th>Last Name</th>
																					<th>DC No.</th>
																					<th>ABN No.</th>
																					<th>Hail Job</th>
																					<th>Levy</th>
																					<th>GST</th>
																					<th>Total (Levy Inc GST)</th>
																					<th>Action</th>
																				</tr>
																			</thead>
																			<tbody id="tbody_unsettle">


																				<?php 
																				$total_levy_amt = $total_levy_gst_amt = $total_levy_without_gst = 0;
																				if (!empty($unsettled_levy_list)) {
																					foreach ($unsettled_levy_list as $key => $unsettled_levy) { ?>
																						<tr>
																							<td><?= $key + 1 ?></td>
																							<td><?= $unsettled_levy['first_name'] ?></td>
																							<td><?= $unsettled_levy['middle_name'] ?></td>
																							<td><?= $unsettled_levy['last_name'] ?></td>
																							<td><?= $unsettled_levy['dc_no'] ?></td>
																							<td><?= $unsettled_levy['abn'] ?></td>
																							
																							<?php
																								$levy_gst_amt = $levy_without_gst = $hail_job_cnt= 0;
																								if ((isset($unsettled_levy['levy']) && isset($unsettled_levy['levy_gst']))) {
																									$levy_gst_amt = $unsettled_levy['levy'] * $unsettled_levy['levy_gst'] / 100;
																									$levy_without_gst = $unsettled_levy['levy'] - $levy_gst_amt;
																								}  
																								$total_levy_gst_amt +=$levy_gst_amt;
																								$total_levy_without_gst +=$levy_without_gst;
																								$total_levy_amt +=$unsettled_levy['levy'];
																								
																								$hail_job_cnt = number_format(abs((($unsettled_levy['extra_end'] - $unsettled_levy['extra_start'])/2)  - ($unsettled_levy['no_of_hiring_end'] - $unsettled_levy['no_of_hiring_start'])),0); 
																							
																							?>

																							<td><?= $hail_job_cnt ?></td>
																							<td><?= number_format($levy_without_gst,2) ?></td>
																							<td><?= number_format($levy_gst_amt,2) ?></td>
																							<td><?= number_format($unsettled_levy['levy'],2) ?></td>
																							<td>
																								<label class="chk_custom_box">
																									<input type="checkbox" class="settle_unsettle_chkbox" value="<?= $unsettled_levy['payin_id'] ?>"><span class="checkmark"></span>
																								</label>
																								<a href="<?=base_url('admin/report/download_pdf/0/'.$unsettled_levy['driver_id'])?>"><i class="fa fa-file-text fa-lg" aria-hidden="true"></i></a>
																							</td>
																						</tr>
																				<?php } ?>

																				
																				<?php } ?>

																			</tbody>

																			<tfoot id="tfoot_unsettle">
																				<tr style="background: #1db5bd;color: #fff;">
																					<td colspan="7"><strong>TOTAL</strong></td>
																					<td><strong><?=number_format($total_levy_without_gst,2)?></strong></td>
																					<td><strong><?=number_format($total_levy_gst_amt,2)?></strong></td>
																					<td colspan="2"><strong><?=number_format($total_levy_amt,2)?></strong></td>
																				</tr>
																			</tfoot>
																			
																				

																			
																		</table>

																	</div>
																	<div class="col-md-12" style="text-align:center;">
																		<div class="form-group">
																			<label class="blank_lbl">&nbsp;</label>
																			<button type="button" id="settle_submit_btn" class="btn btn-success">
																				<i class="fa fa-submit" aria-hidden="true"></i> Submit
																			</button>
																		</div>
																	</div>

																</div>
															</div>

															<div id="inactive_user" class="tab-pane fade">
																<div class="user_permission_top">
																	<div class="row">
																		<div class="col-md-3">
																			<div class="form-group">
																				<label>Company Name</label>
																				<select class="js-select2 company_cls" name="company_id_settle" id="company_id_settle" data-show-subtext="true" data-live-search="true" data-settle_unsettle="settle">
																					<option value="">Select Company</option>
																					<?php foreach ($company_list as $company) { ?>
																						<option value="<?= $company['company_id'] ?>"><?= $company['company_name'] ?></option>
																					<?php } ?>
																				</select>
																			</div>
																		</div>
																		<div class="col-md-3">
																			<div class="form-group">
																				<label>Driver</label>
																				<select class="js-select2" name="driver_id_settle" id="driver_id_settle" data-show-subtext="true" data-live-search="true">
																					<option value="">Select Driver</option>
																					<?php foreach ($driver_list as $driver) { ?>
																						<option value="<?= $driver['user_id'] ?>"><?= $driver['first_name'] . '-' . $driver['dc_no'] ?></option>
																					<?php } ?>
																				</select>
																			</div>
																		</div>

																		<div class="col-md-2">
																			<div class="form-group">
																				<label>From Date</label>
																				<div class="input-group">
																					<input type="text" name="from_date_settle" id="from_date_settle" class="form-control pickadate" 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-2">
																			<div class="form-group">
																				<label>To Date</label>
																				<div class="input-group">
																					<input type="text" name="to_date_settle" id="to_date_settle" class="form-control pickadate" 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-2">
																			<div class="form-group">
																				<label class="blank_lbl">&nbsp;</label>
																				<button type="button" class="btn btn-success settle_unsettle_btn" data-levy_settled_flag="1" data-settle_unsettle="settle">
																					<i class="fa fa-search" aria-hidden="true"></i> Search
																				</button>
																			</div>
																		</div>
																	</div>

																</div>
																<!-- <div class="show_data">
																	<div class="row clearfix">
																		<div class="col-sm-12">
																			<ul class="list_show_data">
																				<li><strong>Total Levy: </strong> 900</li>
																				<li><strong>Total GST: </strong> 90</li>
																			</ul>
																		</div>
																	</div>
																</div> -->

																<div class="row clearfix">
																	<div class="table-responsive custom_table_area export_table_area">
																		<table id="levy_table_settle" class="table table-striped table-bordered export_btn_dt file-export c_table_style">
																			<thead>
																				<tr>
																					<th>SL No.</th>
																					<th>First Name</th>
																					<th>Middle Name</th>
																					<th>Last Name</th>
																					<th>DC No.</th>
																					<th>ABN No.</th>
																					<th>Hail Job</th>
																					<th>Levy</th>
																					<th>GST</th>
																					<th>Total (Levy Inc GST)</th>
																					<th>Action</th>
																				</tr>
																			</thead>
																			<tbody id="tbody_settle">

																			<?php 
																				$total_levy_amt = $total_levy_gst_amt = $total_levy_without_gst = 0;
																				if (!empty($settled_levy_list)) {
																					foreach ($settled_levy_list as $key => $settled_levy) { ?>
																						<tr>
																							<td><?= $key + 1 ?></td>
																							<td><?= $settled_levy['first_name'] ?></td>
																							<td><?= $settled_levy['middle_name'] ?></td>
																							<td><?= $settled_levy['last_name'] ?></td>
																							<td><?= $settled_levy['dc_no'] ?></td>
																							<td><?= $settled_levy['abn'] ?></td>
																							
																							<?php
																								$levy_gst_amt = $levy_without_gst = $hail_job_cnt = 0;
																								if ((isset($settled_levy['levy']) && isset($settled_levy['levy_gst']))) {
																									$levy_gst_amt = $settled_levy['levy'] * $settled_levy['levy_gst'] / 100;
																									$levy_without_gst = $settled_levy['levy'] - $levy_gst_amt;
																								}  
																								$total_levy_gst_amt +=$levy_gst_amt;
																								$total_levy_without_gst +=$levy_without_gst;
																								$total_levy_amt +=$settled_levy['levy'];

																								$hail_job_cnt = number_format(abs((($settled_levy['extra_end'] - $settled_levy['extra_start'])/2)  - ($settled_levy['no_of_hiring_end'] - $settled_levy['no_of_hiring_start'])),0); 
																							
																							?>
																							
																							<td><?= $hail_job_cnt ?></td>
																							<td><?= $total_levy_without_gst ?></td>	
																							<td><?= number_format($levy_gst_amt,2) ?></td>
																							<td><?= number_format($settled_levy['levy'],2) ?></td>
																							<td><a href="<?=base_url('admin/report/download_pdf/1/'.$settled_levy['driver_id'])?>"><i class="fa fa-file-text fa-lg" aria-hidden="true"></i></a></td>
																						</tr>
																				<?php } ?>
																				
																				<?php } ?>
																			</tbody>
																			<tfoot id="tfoot_settle">
																				<tr style="background: #1db5bd;color: #fff;">
																					<td colspan="7"><strong>TOTAL</strong></td>
																					<td><strong><?=number_format($total_levy_without_gst,2)?></strong></td>
																					<td><strong><?=number_format($total_levy_gst_amt,2)?></strong></td>
																					<td colspan="2"><strong><?=number_format($total_levy_amt,2)?></strong></td>
																				</tr>
																				</tfoot>
																			
																		</table>
																	</div>
																</div>
															</div>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>

		</div>
	</div>
</div>
</div>
</div>
</section>
<!-- // Basic form layout section end -->
</div>
</div>
</div>
<script>


	$(document).on('click', '.settle_unsettle_btn', function() {

		var settle_unsettle = $(this).data('settle_unsettle');
		var levy_settled_flag = $(this).data('levy_settled_flag');
		var start_date = $("#from_date_" + settle_unsettle).val();
		var end_date = $("#to_date_" + settle_unsettle).val();
		var driver_id = $("#driver_id_" + settle_unsettle).val();
		var company_id = $("#company_id_" + settle_unsettle).val();

		var format_start_date=start_date.split("/").reverse().join("-");
		var format_end_date=end_date.split("/").reverse().join("-");
		var resulthtml = footerhtml ='';
		$.ajax({
				url: "<?php echo base_url('admin/report/levy_report_search'); ?>",
				type: "POST",
				data: {
					'company_id': company_id,
					'driver_id': driver_id,
					'start_date': start_date,
					'end_date': end_date,
					'levy_settled_flag': levy_settled_flag
				},
				dataType: "json",
				encode: true,
				//async: false
			})
			.done(function(data) {

				if (data.status) {

					if (data.levy_list) {
						var i = total_levy_amt = total_levy_gst_amt = total_levy_with_gst = 0 * 1;
						$.each(data.levy_list, function(key, value) {
							i++;
							var levy_with_gst = 0;
							var levy_gst_amt = 0;
							var hail_job_cnt =0;
							
							hail_job_cnt = parseFloat(((Number(value.extra_end) - Number(value.extra_start))/2)  - (Number(value.no_of_hiring_end) - Number(value.no_of_hiring_start)));
							
							if (value.levy && value.levy_gst) {
								levy_gst_amt = parseFloat(Number((value.levy * value.levy_gst / 100))).toFixed(2);
								levy_with_gst = parseFloat(Number(value.levy) + Number((value.levy * value.levy_gst / 100))).toFixed(2);
							}
							resulthtml += '<tr>';
							resulthtml += '<td>' + i + '</td>';
							resulthtml += '<td>' + value.first_name + '</td>';
							resulthtml += '<td>' + value.middle_name + '</td>';
							resulthtml += '<td>' + value.last_name + '</td>';
							resulthtml += '<td>' + value.dc_no + '</td>';
							resulthtml += '<td>' + value.abn + '</td>';
							resulthtml += '<td>' + Math.abs(hail_job_cnt) + '</td>';
							
							resulthtml += '<td>' + value.levy + '</td>';
							resulthtml += '<td>' + levy_gst_amt + '</td>';
							resulthtml += '<td>' + levy_with_gst + '</td>';
							if (levy_settled_flag == 0) {
								resulthtml += '<td><label class="chk_custom_box"><input type="checkbox" class="settle_unsettle_chkbox" value="' + value.payin_id + '"><span class="checkmark"></span></label><a href="<?=base_url()?>admin/report/download_pdf/'+levy_settled_flag+'/'+value.driver_id+'/'+format_start_date+'/'+format_end_date+'"><i class="fa fa-file-text fa-lg" aria-hidden="true"></i></a></td>';
							}
							else{
								resulthtml += '<td><a href="<?=base_url()?>admin/report/download_pdf/'+levy_settled_flag+'/'+value.driver_id+'/'+format_start_date+'/'+format_end_date+'"><i class="fa fa-file-text fa-lg" aria-hidden="true"></i></a></td>';
							}
							resulthtml += '</tr>';

							total_levy_amt +=Number(value.levy);
							total_levy_gst_amt +=Number(levy_gst_amt);
							total_levy_with_gst +=Number(levy_with_gst);
						})

						footerhtml +=`<tr style="background: #1db5bd;color: #fff;">
										<td colspan="7"><strong>TOTAL</strong></td>
										<td><strong>`+parseFloat(total_levy_amt).toFixed(2)+`</strong></td>
										<td><strong>`+parseFloat(total_levy_gst_amt).toFixed(2)+`</strong></td>`;
										// if(settle_unsettle == 'settle'){
										// 	footerhtml +=`<td><strong>`+parseFloat(total_levy_gst_amt).toFixed(2)+`</strong></td>`;
										// }
										// else{
											footerhtml +=`<td colspan="2"><strong>`+parseFloat(total_levy_with_gst).toFixed(2)+`</strong></td>`;
										//}
										
										footerhtml +=`</tr>`;
						//console.log(resulthtml);
						



						var now = new Date();
						var date = now.getFullYear() + ":" + now.getMonth() + ":" + now.getDate();
						$("#levy_table_" + settle_unsettle).dataTable().fnDestroy();
						$("#tbody_" + settle_unsettle).html(resulthtml);
						$("#tfoot_" + settle_unsettle).html(footerhtml);
						$('#levy_table_' + settle_unsettle).DataTable({
							pageLength: 100,
							dom: 'lBfrtip',
							buttons: [{
									extend: 'excel',
									text: 'Download Excel',
									className: 'btn btn-outline-primary mr-1',
									filename: 'levy_report_' + date
								}
								//'copy', 'csv', 'excel', 'pdf', 'print'
							],
							"lengthMenu": [[5, 25, 50, 100, -1], [5, 25, 50, 100, "All"]]
						});



					}

				} else {
					$.alert({
						type: 'red',
						title: 'Alert!',
						content: 'Oops!Something went wrong...',
					});
				}
			})
			.fail(function(result) {
				$.alert({
					type: 'red',
					title: 'Alert!',
					content: 'Oops!Something went wrong...',
				});
			})
	})

	// $(document).on('change', '.settle_unsettle_chkbox', function() {



	// 	settle_submit_btn


	// })

	$(document).on('click', '#settle_submit_btn', function() {
		var checked_unsettle_string = '';
		$('.settle_unsettle_chkbox').each(function() {
			if (this.checked) {

				checked_unsettle_string += $(this).val() + ',';
			}

		})
		checked_unsettle_string.replace(/,\s*$/, "");
		$.ajax({
				url: "<?php echo base_url('admin/report/settle_checked_levy'); ?>",
				type: "POST",
				data: {
					'checked_unsettle_string': checked_unsettle_string,
				},
				dataType: "json",
				encode: true
			})
			.done(function(data) {

				if (data.status) {
					$.alert({
						type: 'green',
						title: 'Success Msg',
						content: data.msg,
						buttons: {
							Done: {
								btnClass: 'btn-success',
								action: function() {
									window.location.reload(true);
								}
							},

						}
					});



				} else {
					$.alert({
						type: 'red',
						title: 'Alert!',
						content: 'data.msg',
					});
				}
			})
			.fail(function(result) {
				$.alert({
					type: 'red',
					title: 'Alert!',
					content: 'Oops!Something went wrong...',
				});
			})

	})

	$(document).on('change','.company_cls',function(){
		var settle_unsettle=$(this).data('settle_unsettle');
		var company_id = $(this).val();
		$.ajax({
				url: "<?php echo base_url('admin/report/get_driver_against_company'); ?>",
				type: "POST",
				data: {
					'company_id': company_id,
				},
				dataType: "json",
				encode: true
			})
			.done(function(data) {

				if (data.status) {
					var optionHTML='<option value="">Select Driver</option>';
					$.each(data.driver_list,function(key,value){
						optionHTML +=`<option value="`+value.user_id+`">`+value.first_name +'-'+value.dc_no+`</option>`;	
					})
					$("#driver_id_"+settle_unsettle).html(optionHTML);

				} 
			})
			.fail(function(result) {
				$.alert({
					type: 'red',
					title: 'Alert!',
					content: 'Oops!Something went wrong...',
				});
			})

	})
</script>