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/settlement_due/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">Settlement Due 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">
						<div class="row">
							<div class="table-responsive custom_table_area export_table_area">
								<table width="100%" id="settlement_due_table" class="table table-striped table-bordered export_btn_dt c_table_style">
									<thead>
                                		<tr>
											<th width="5%">Sl No.</th>
											<!-- <th width="10%">Car No</th> -->
											<th width="10%">Driver Name </th>
											<th width="5%">Car No</th>
											<th width="10%">Mobile No</th>
											<th width="15%">Last Week<br><span id="week_1"></span></th>
											<th width="15%">Second Last Week<br><span id="week_2"></span></th>
											<th width="15%">Third Last Week<br><span id="week_3"></span></th>
											<th width="15%">Older Due <br><span id="week_4"></span></th>
                                		</tr>
                            		</thead>
									
									<tbody id="tbody_settlement_due_table">
                            		</tbody>
                        		</table>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</section>
<!-- // Basic form layout section end -->
            </div>
          </div>
        </div>
<script>
	$(document).ready(function() {
		settlement_due_list();
	});

	function settlement_due_list() {
		
		var resulthtml = '';
		$.ajax({
				url: "<?php echo base_url('admin/report/get_settlement_due_report'); ?>",
				type: "POST",
				data: {},
				dataType: "json",
				encode: true,
				//async: false
			})
			.done(function(data) {

				if (data.status) {

					if (data.settlement_due_list) {
						var i = 0;
						$.each(data.settlement_due_list, function(key, value) {
							i++;
							
							resulthtml += '<tr>';
							resulthtml += '<td width="5%">' + i + '</td>';
							// resulthtml += '<td width="10%">' + value.registration_no + '</td>';
							resulthtml += '<td width="10%">' + value.full_name + '</td>';
							resulthtml += '<td width="5%">' + value.registration_no + '</td>';
							resulthtml += '<td width="10%">' + value.mobile + '</td>';
							var weekly_settlement_status =[];
							var weekly_settlement_status_str;
							//console.log(value.weekly_settlement_status);
							if(value.weekly_settlement_status){

								weekly_settlement_status = value.weekly_settlement_status.split('|#|');
								//console.log(weekly_settlement_status_str);
								

							}
							$.each(weekly_settlement_status,function(key1,value1){
								
								//console.log(key1);
								var week_id = Number(key1) + Number(1);
								//console.log(week_id);
								var weekly_settlement_status_array = value1.split('|$|');
								$("#week_"+week_id).html('('+weekly_settlement_status_array[1]+' <br><span style="text-align:center;">To</span><br> '+weekly_settlement_status_array[2]+')');
								
								if(weekly_settlement_status_array[0] != ''){
									resulthtml += '<td width="15%"><span class="week_color week_color_red">Due</span><br>'+weekly_settlement_status_array[0].split(",").join("<br>");+'</td>';
								}
								else{
									resulthtml += '<td width="15%"><span class="week_color week_color_green">Settled</span></td>';
								}
							})
									 
							resulthtml += '</tr>';
						})
					}
				
						//console.log(resulthtml);
						var now = new Date();
						var date = now.getFullYear() + ":" + now.getMonth() + ":" + now.getDate();
						$("#settlement_due_table").dataTable().fnDestroy();
						$("#tbody_settlement_due_table").html(resulthtml);
						$('#settlement_due_table').DataTable({
							pageLength: 100,
							dom: 'Bfrtip',
							buttons: [{
									extend: 'excel',
									text: 'Download Excel',
									className: 'btn btn-outline-primary mr-1',
									filename: 'settlement_due_report' + date
								}
								//'copy', 'csv', 'excel', 'pdf', 'print'
							]
						});


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