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/application/views/admin/report/levy/list_new.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>Full Name</th>
																					<th>Shift No</th>
																					<th>DC No.</th>
																					<th>ABN No.</th>
																					<th>Hail Job</th>
																					<th>Booking Job</th>
																					<th>Levy</th>
																					<th>GST</th>
																					<th>Total (Levy Inc GST)</th>
																				
																				</tr>
																			</thead>
																			<tbody id="tbody_unsettle">


																				

																			</tbody>

																			<tfoot id="tfoot_unsettle">
																				
																			</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>Full Name</th>
																					<th>Shift No</th>
																					<th>DC No.</th>
																					<th>ABN No.</th>
																					<th>Hail Job</th>
																					<th>Booking Job</th>
																					<th>Levy</th>
																					<th>GST</th>
																					<th>Total (Levy Inc GST)</th>
																				</tr>
																			</thead>
																			<tbody id="tbody_settle">

																			
																			</tbody>
																			<tfoot id="tfoot_settle">
																				
																				</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();
		
// 		if(driver_id=='' && company_id==''){
// 		    	$.alert({
// 						type: 'red',
// 						title: 'Alert!',
// 						content: 'Please select Company or Driver',
// 					});
// 					return false;
// 		}

		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_new'); ?>",
				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_without_gst = 0 * 1;
						var total_hail_job_cnt =0 * 1;
						var total_booking_job_cnt =0 * 1;
						$.each(data.levy_list, function(key, value) {
							i++;
							var levy_without_gst = 0;
							var levy_gst_amt = 0;
							var hail_job_cnt =0;
							var booking_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)));

							booking_job_cnt = parseFloat(Number(value.no_of_hiring_end) - Number(value.no_of_hiring_start) - Math.abs(hail_job_cnt)) ;
							
							if (value.levy && value.levy_gst) {
								levy_without_gst = parseFloat(Number(value.levy * 100) / (100 + Number(value.levy_gst))).toFixed(2);
								levy_gst_amt = value.levy - levy_without_gst;
							}
							resulthtml += '<tr>';
							resulthtml += '<td>' + i + '</td>';
							resulthtml += '<td>' + value.first_name +' '+ value.middle_name +' '+ value.last_name + '</td>';
							resulthtml += '<td>' + value.shift_no + '</td>';
							resulthtml += '<td>' + value.dc_no + '</td>';
							resulthtml += '<td>' + value.abn + '</td>';
							resulthtml += '<td>' + Math.abs(hail_job_cnt) + '</td>';
							resulthtml += '<td>' + Math.abs(booking_job_cnt) + '</td>';
							
							resulthtml += '<td>' + levy_without_gst + '</td>';
							resulthtml += '<td>' + parseFloat(levy_gst_amt).toFixed(2) + '</td>';
							resulthtml += '<td>' + value.levy + '</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_hail_job_cnt +=Number(Math.abs(hail_job_cnt));
							total_booking_job_cnt +=Number(Math.abs(booking_job_cnt));
							total_levy_amt +=Number(value.levy);
							total_levy_gst_amt +=Number(levy_gst_amt);
							total_levy_without_gst +=Number(levy_without_gst);
						})

						footerhtml +=`<tr style="background: #1db5bd;color: #fff;">
										<td colspan="5"><strong>TOTAL</strong></td>
										<td><strong>`+parseFloat(total_hail_job_cnt).toFixed(2)+`</strong></td>
										<td><strong>`+parseFloat(total_booking_job_cnt).toFixed(2)+`</strong></td>
										<td><strong>`+parseFloat(total_levy_without_gst).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><strong>`+parseFloat(total_levy_amt).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*$/, "");
		if(checked_unsettle_string){
			$.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 Message',
							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...',
					});
				})
		} else{
			$.alert({
				type: 'red',
				title: 'Alert!',
				content: 'Select atleast one before submit',
			});

		}
	})

	$(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>