
						<div class="card-body">
							<div class="table-responsive">
								<table class="table table-bordered table-hover table-sm" id="dataTable" width="70%" cellspacing="0" style="font-size: 12px">
									<tr><th colspan="15"> NOT PAID LIST - DEPOSIT</th></tr>
									<tr >
										<td valign="middle" align="center" rowspan="4"><b>#</b></td>
										<td valign="middle" align="center" rowspan="4"><b>Tenant Name</b></td>
										<td valign="middle" align="center" rowspan="4"><b>Unit No</b></td>
										<td align="center" rowspan="4"><b>Invoice No</b></td>
										<td align="center" rowspan="4"><b>Date Created</b></td>
										<td  align="center" rowspan="4"><b>Payment Status</b></td>
										<td align = "center" colspan="9"><b>Deposit Invoice Details</b></td>
										
									</tr>
									<tr>
										<td align="center" colspan="3"><b>Two Month Rental</b></td>
										<td align="center" colspan="3"><b>Utilities</b></td>
										<td  align="center" colspan="3"><b>Total</b></td>
									</tr>
									<tr>
										<td align="center" ><b>Billing</b></td>
										<td align="center" ><b>Payment</b></td>
										<td  align="center" ><b>Due</b></td>
										<td align="center" ><b>Billing</b></td>
										<td align="center" ><b>Payment</b></td>
										<td  align="center" ><b>Due</b></td>
										<td align="center" ><b>Billing</b></td>
										<td align="center" ><b>Payment</b></td>
										<td  align="center" ><b>Due</b></td>
									</tr>
									<tr>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
									</tr>
									<?PHP
									$no = 1;
									$total2monthRental_due = 0;
									$total2monthRental_bill = 0;
									$totalUtilities_due = 0;
									$totalUtilities_bill = 0;
									$total_2monthRental_utilities_due = 0;
									$total_2monthRental_utilities_bills = 0;
									$totalAllDeposit_newRecord = 0;
									
									if($countStatementDeposit_newRecord > 0){
										while($resultDeposit_newRecord = mysqli_fetch_array($runStatementDeposit_newRecord)){
											$tenant_id = $resultDeposit_newRecord["tenant_id"];
											$tenant_name = $resultDeposit_newRecord["tenant_name"];
											$unit_no = $resultDeposit_newRecord["unit_no"];
											$invoice_no = $resultDeposit_newRecord["invoice_no"];
											$two_month_rental_due = $resultDeposit_newRecord["two_month_rental_due"];
											$two_month_rental_amount_bill = $resultDeposit_newRecord["two_month_rental_amount_bill"];
											$utility_due  = $resultDeposit_newRecord["utility_due"];
											$utility_amount_bill  = $resultDeposit_newRecord["utility_amount_bill"];
											$created_at  = $resultDeposit_newRecord["created_at"];
											$deposit_bill_id  = $resultDeposit_newRecord["deposit_bill_id"];
											$payment_status  = $resultDeposit_newRecord["payment_status"];
											
											//find deposit payment from deposit_bill_id
											echo $sqlDeposit_payments = "select sum(two_months_amount_paid) as total2monthrental_paid, sum(utility_amount_paid) as totalutility_paid from deposit_payments where deposit_bill_id = $deposit_bill_id";
											$runDeposit_payments = mysqli_query($link, $sqlDeposit_payments);
											if($runDeposit_payments === FALSE){
												die(mysqli_error($link));
											}
											$resultDeposit_payments = mysqli_fetch_assoc($runDeposit_payments);
											$total2monthrental_paid = $resultDeposit_payments["total2monthrental_paid"];
											$totalutility_paid = $resultDeposit_payments["totalutility_paid"];
											
											$two_month_rental_due = $two_month_rental_amount_bill - $total2monthrental_paid;
											$utility_due = $utility_amount_bill - $totalutility_paid;
											
											$totalBilling = $two_month_rental_amount_bill + $utility_amount_bill;
											$totalPayment = $total2monthrental_paid + $totalutility_paid;
											$totalDue = $totalBilling - $totalPayment;
											
											$report_type = "Rental" ;
									?>
									<tr>
										<td align="center"><?php echo $no; ?></td>
										<td align="center"><a href="viewTenantDashboard.php?tenant_id=<?php echo $tenant_id?>"><?php echo strtoupper($tenant_name); ?></a></td>
										<td align="center"><?php echo $unit_no; ?></td>
										<td align="center"><a href="invoice/print.php?report_type=<?php echo $report_type?>&tenant_id=<?php echo $tenant_id?>&id=<?php echo $deposit_bill_id?>"><?php echo $invoice_no; ?></a></td>
										<td align="center"><?php echo date("d/m/Y",strtotime($created_at)); ?></td>
										<td align="center"><?php echo $payment_status; ?></td>
										<td align="right"><?php echo number_format($two_month_rental_amount_bill,2,".",","); ?></td>
										<td align="right"><?php echo number_format($total2monthrental_paid,2,".",","); ?></td>
										<td align="right"><?php echo number_format($two_month_rental_due,2,".",","); ?></td>
										<td align="right"><?php echo number_format($utility_amount_bill,2,".",","); ?></td>
										<td align="right"><?php echo number_format($totalutility_paid,2,".",","); ?></td>
										<td align="right"><?php echo number_format($utility_due,2,".",","); ?></td>
										<td align="right"><?php echo number_format($totalBilling,2,".",","); ?></td>
										<td align="right"><?php echo number_format($totalPayment,2,".",","); ?></td>
										<td align="right"><?php echo number_format($totalDue,2,".",","); ?></td>
									<?php 
									$total2monthRental += $two_month_rental;
									$totalUtilities += $utilities;
									$totalMgtFree += $management_fee;
									
									$all_two_month_rental_amount_bill += $two_month_rental_amount_bill;
									$all_total2monthrental_paid += $total2monthrental_paid;
									$all_two_month_rental_due += $two_month_rental_due;
									$all_utility_amount_bill += $utility_amount_bill;
									$all_totalutility_paid += $totalutility_paid;
									$all_utility_due += $utility_due;
									$all_totalBilling += $totalBilling;
									$all_totalPayment += $totalPayment;
									$all_totalDue += $totalDue;
									
									
									$totalAllDeposit += $total_deposit;
									$no++;
									} 
									?>
									</tr>
									<tr>
										<td colspan="6" align="center"><b><?php echo "TOTAL (RM)"?></b></td>
										<td align="right" ><b><?php echo number_format($all_two_month_rental_amount_bill,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_total2monthrental_paid,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_two_month_rental_due,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_utility_amount_bill,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_totalutility_paid,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_utility_due,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_totalBilling,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_totalPayment,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_totalDue,2,".",",")?></b></td>
									</tr>
						<?php } ?>
								</table>
								
								<BR/>
								<table class="table table-bordered table-hover table-sm" id="dataTable" width="70%" cellspacing="0" style="font-size: 12px">
									<tr><th colspan="18"> NOT PAID LIST - OTHERS</th></tr>
									<tr >
										<td valign="middle" align="center" rowspan="4"><b>#</b></td>
										<td valign="middle" align="center" rowspan="4"><b>Tenant Name</b></td>
										<td valign="middle" align="center" rowspan="4"><b>Unit No</b></td>
										<td align="center" rowspan="4"><b>Invoice No</b></td>
										<td align="center" rowspan="4"><b>Date Created</b></td>
										<td  align="center" rowspan="4"><b>Payment Status</b></td>
										<td align = "center" colspan="12"><b>Others Invoice Details</b></td>
										
									</tr>
									<tr>
										<td align="center" colspan="3"><b>Yuran Pelbagai</b></td>
										<td align="center" colspan="3"><b>SST from Yuran Pelbagai</b></td>
										<td  align="center" colspan="3"><b>Stamping Charges</b></td>
										<td  align="center" colspan="3"><b>Total</b></td>
									</tr>
									<tr>
										<td align="center" ><b>Billing</b></td>
										<td align="center" ><b>Payment</b></td>
										<td  align="center" ><b>Due</b></td>
										<td align="center" ><b>Billing</b></td>
										<td align="center" ><b>Payment</b></td>
										<td  align="center" ><b>Due</b></td>
										<td align="center" ><b>Billing</b></td>
										<td align="center" ><b>Payment</b></td>
										<td  align="center" ><b>Due</b></td>
										<td align="center" ><b>Billing</b></td>
										<td align="center" ><b>Payment</b></td>
										<td  align="center" ><b>Due</b></td>
									</tr>
									<tr>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
										<td align="center"><b>RM</b></td>
									</tr>
									<?PHP
									$no = 1;
									$totalYP_due = 0;
									$totalYP_bill = 0;
									$totalSST_due = 0;
									$totalSST_bill = 0;
									$totalStamping_due = 0;
									$totalStamping_bill = 0;
									$total_YP_SST_Stamping_due = 0;
									$total_YP_SST_Stamping_bills = 0;
									$totalAllOthers_newRecord = 0;
									
									if($countRowPaymentOthers > 0){
										while($resultDepositPaymentOthers = mysqli_fetch_array($runDepositPaymentOthers)){
											$tenant_id = $resultDepositPaymentOthers["tenant_id"];
											$tenant_name = $resultDepositPaymentOthers["tenant_name"];
											$unit_no = $resultDepositPaymentOthers["unit_no"];
											$invoice_no = $resultDepositPaymentOthers["invoice_no"];
											$yp_due = $resultDepositPaymentOthers["yp_due"];
											$yp_charges_amount = $resultDepositPaymentOthers["yp_charges_amount"];
											$sst_due  = $resultDepositPaymentOthers["sst_due"];
											$sst_charges_amount  = $resultDepositPaymentOthers["sst_charges_amount"];
											$stamping_due  = $resultDepositPaymentOthers["stamping_due"];
											$stamping_charges_amount  = $resultDepositPaymentOthers["stamping_charges_amount"];
											$created_at  = $resultDepositPaymentOthers["created_at"];
											$deposit_bill_other_id  = $resultDepositPaymentOthers["deposit_bill_other_id"];
											$payment_status  = $resultDepositPaymentOthers["payment_status"];
											
											//find deposit payment from deposit_bill_other_id
											echo $sqlDeposit_payments = "select sum(yp_paid) as totalyp_paid, sum(sst_paid) as totalsst_paid, sum(stamping_paid) as totalstamping_paid from deposit_payment_other_receipts where deposit_bill_other_id = $deposit_bill_other_id";
											$runDeposit_payments = mysqli_query($link, $sqlDeposit_payments);
											if($runDeposit_payments === FALSE){
												die(mysqli_error($link));
											}
											$resultDeposit_payments = mysqli_fetch_assoc($runDeposit_payments);
											$totalyp_paid = $resultDeposit_payments["totalyp_paid"];
											$totalsst_paid = $resultDeposit_payments["totalsst_paid"];
											$totalstamping_paid = $resultDeposit_payments["totalstamping_paid"];
											
											$yp_due = $yp_charges_amount - $totalyp_paid;
											$sst_due = $sst_charges_amount - $totalsst_paid;
											$stamping_due = $stamping_charges_amount - $totalstamping_paid;
											
											$totalBilling = $yp_charges_amount + $sst_charges_amount + $stamping_charges_amount ;
											$totalPayment = $totalyp_paid + $totalsst_paid + $totalstamping_paid;
											$totalDue = $totalBilling - $totalPayment;
											
											$report_type = "Rental" ;
									?>
									<tr>
										<td align="center"><?php echo $no; ?></td>
										<td align="center"><a href="viewTenantDashboard.php?tenant_id=<?php echo $tenant_id?>"><?php echo strtoupper($tenant_name); ?></a></td>
										<td align="center"><?php echo $unit_no; ?></td>
										<td align="center"><a href="invoice/print.php?report_type=<?php echo $report_type?>&tenant_id=<?php echo $tenant_id?>&id=<?php echo $deposit_bill_id?>"><?php echo $invoice_no; ?></a></td>
										<td align="center"><?php echo date("d/m/Y",strtotime($created_at)); ?></td>
										<td align="center"><?php echo $payment_status; ?></td>
										<td align="right"><?php echo number_format($yp_charges_amount,2,".",","); ?></td>
										<td align="right"><?php echo number_format($totalyp_paid,2,".",","); ?></td>
										<td align="right"><?php echo number_format($yp_due,2,".",","); ?></td>
										<td align="right"><?php echo number_format($sst_charges_amount,2,".",","); ?></td>
										<td align="right"><?php echo number_format($totalsst_paid,2,".",","); ?></td>
										<td align="right"><?php echo number_format($sst_due,2,".",","); ?></td>
										<td align="right"><?php echo number_format($stamping_charges_amount,2,".",","); ?></td>
										<td align="right"><?php echo number_format($totalstamping_paid,2,".",","); ?></td>
										<td align="right"><?php echo number_format($stamping_due,2,".",","); ?></td>
										<td align="right"><?php echo number_format($totalBilling,2,".",","); ?></td>
										<td align="right"><?php echo number_format($totalPayment,2,".",","); ?></td>
										<td align="right"><?php echo number_format($totalDue,2,".",","); ?></td>
									<?php 
									
									
									$all_yp_charges_amount += $yp_charges_amount;
									$all_totalyp_paid += $totalyp_paid;
									$all_yp_due += $yp_due;
									
									$all_sst_charges_amount += $sst_charges_amount;
									$all_totalsst_paid += $totalsst_paid;
									$all_sst_due += $sst_due;
									
									$all_stamping_charges_amount += $stamping_charges_amount;
									$all_totalstamping_paid += $totalstamping_paid;
									$all_stamping_due += $stamping_due;
									
									$all_totalBilling += $totalBilling;
									$all_totalPayment += $totalPayment;
									$all_totalDue += $totalDue;
									
									
									$totalAllDeposit += $total_deposit;
									$no++;
									} 
									?>
									</tr>
									<tr>
										<td colspan="6"><b><?php echo "TOTAL (RM)"?></b></td>
										<td align="right" ><b><?php echo number_format($all_yp_charges_amount,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_totalyp_paid,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_yp_due,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_sst_charges_amount,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_totalsst_paid,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_sst_due,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_stamping_charges_amount,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_totalstamping_paid,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_stamping_due,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_totalBilling,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_totalPayment,2,".",",")?></b></td>
										<td  align="right"><b><?php echo number_format($all_totalDue,2,".",",")?></b></td>
									</tr>
						<?php } ?>
								</table>
							</div>
						</div>
					