function getReportBalance($reportId, $conexionHandler) { $totalReported = getReportTotal($reportId, $conexionHandler); $totalPaid = getReportPaid($reportId, $conexionHandler); return decimalPad($totalReported - $totalPaid); }
<table align="center" class="report" width="100%" cellspacing="0" > <?php $tableHolder = ""; $ticketTotaled = 0; $reportedTotaled = 0; $paidTotaled = 0; $totalDebt = 0; $brokersArr = array(); $reportsArr = array(); $reportsQuery = "\r\n\tSELECT\r\n\t\t*\r\n\tFROM\r\n\t\treport\r\n\t\tJOIN broker using (brokerId)\r\n\t\tLEFT JOIN driver ON (driver.driverId = report.reportType)\r\n\tWHERE\r\n\t\treportDate BETWEEN '{$fromDate}' AND '{$toDate}'\r\n\tORDER BY\r\n\t\treportEndDate desc\r\n"; //echo $brokersQuery; $reports = mysql_query($reportsQuery, $conexion); while ($report = mysql_fetch_assoc($reports)) { //$reportBalance = getReportBalance($report['reportId'], $conexion); $reportTotal = getReportTotal($report['reportId'], $conexion); $paidTotal = getReportPaid($report['reportId'], $conexion); //echo $reportTotal." -- ".$paidTotal; $reportBalance = decimalPad($reportTotal - $paidTotal); if ($reportBalance > 0) { $tableHolder .= "<tr>"; $tableHolder .= "<td>" . to_MDY($report['reportStartDate']) . "</td>"; $tableHolder .= "<td>" . to_MDY($report['reportEndDate']) . "</td>"; $tableHolder .= "<td>" . ($report['brokerId'] == 64 ? "<strong>MFI</strong> " . $report['driverLastName'] . ", " . $report['driverFirstName'] : $report['brokerName']) . "</td>"; $tableHolder .= "<td>" . $report['reportId'] . "</td>"; $tableHolder .= "<td align='right'>" . decimalPad($reportTotal) . "</td>"; $tableHolder .= "<td align='right'>" . decimalPad($reportBalance) . "</td>"; $tableHolder .= "</tr>\n"; /*if(isset($brokersArr[$broker['brokerId']])){ $brokersArr[$broker['brokerId']]['counter'] = $brokersArr[$broker['brokerId']]['counter'] +1; }else{ $brokerInfo = mysql_fetch_assoc(mysql_query("select * from broker where brokerId = ".$broker['brokerId'],$conexion));
$tbody = "<table class='listing form' cellpadding='0' cellspacing='0' ><tr> <th>ID</th> <th>Broker</th> <th>Driver</th> <th>Report Date</th> <th>Start Date</th> <th>End Date</th> <th>Due Date</th> <th>Total</th> <th>Paid</th> <th>Balance</th> <th colspan='2'></th> </tr>"; while($invoice = mysql_fetch_assoc($reports)) { $reportTotal = getReportTotal($invoice['reportId'], $conexion); $paidTotal = getReportPaid($invoice['reportId'], $conexion); if($paidTotal == null || $paidTotal <= 0 ){ $paid = 'Unpaid';if($paidR)continue;} if($paidTotal != null && $paidTotal >= $reportTotal && $paidTotal != 0){ $paid = 'Paid'; if($unpaidR)continue;} if($paidTotal != null && $paidTotal > 0 && $paidTotal < $reportTotal){ $paid = 'Warning';if($paidR)continue;} if($paidTotal != null && $paidTotal > $reportTotal){ $paid = 'Overpaid'; if($unpaid)continue;} if($colorFlag){$tbody.= "<tr class='even".$paid." printable' id='report".$invoice['reportId']."' invoice='".$invoice['reportId']."'>";} else{$tbody.= "<tr class='odd".$paid." printable' id='report".$invoice['reportId']."' invoice='".$invoice['reportId']."'>";} $colorFlag=!$colorFlag; $tbody.= "<td>".$invoice['reportId']."</td>"; $tbody.= "<td>".$invoice['brokerPid']."</td>"; $tbody.= "<td>".($invoice['driverFirstName']==null?'----':$invoice['driverLastName'].", ".$invoice['driverFirstName'])."</td>"; $tbody.= "<td>".to_MDY($invoice['reportDate'])."</td>"; $tbody.= "<td>".to_MDY($invoice['reportStartDate'])."</td>";
return data; } </script> <div id='formDiv' class='table'> <img src="/mfi/img/bg-th-left.gif" width="8" height="7" alt="" class="left" /> <img src="/mfi/img/bg-th-right.gif" width="7" height="7" alt="" class="right" /> <table class="listing form" cellpadding="0" cellspacing="0"> <tr> <th colspan='2'>New Pay Cheque for Broker Invoice [<?php echo $reportId; ?> ]</th> </tr> <?php $reportTotal = getReportTotal($reportId, $conexion); $paidTotal = getReportPaid($reportId, $conexion); $reportInfo = getBasicReportInfo($conexion, $reportId); $balance = decimalPad($reportTotal - $paidTotal); $nextCheck = getNextAutoIncrement($conexion, 'paidcheques'); //Truck $flag = true; echo createFormRowTextField('Check Id', 'newBrokerChequeId', $flag ? 'class="bg"' : '', true, " disabled='disabled' size='10px' value='" . $nextCheck . "'"); $flag = !$flag; echo createFormRowTextField('Check Number', 'newBrokerCheckNumber', $flag ? 'class="bg"' : '', false, "size='10px' "); $flag = !$flag; echo createFormRowTextField('Check Date', 'newBrokerCheckDate', $flag ? 'class="bg"' : '', false, "size='10px' value='" . to_MDY($reportInfo['reportDate']) . "'"); $flag = !$flag; echo createFormRowTextField('Amount', 'newBrokerCheckAmount', $flag ? 'class="bg"' : '', false, "size='10px' value='" . $balance . "'"); $flag = !$flag; ?> </table>