From: <rc...@us...> - 2016-11-03 20:33:10
|
Revision: 7661 http://sourceforge.net/p/web-erp/reponame/7661 Author: rchacon Date: 2016-11-03 20:33:07 +0000 (Thu, 03 Nov 2016) Log Message: ----------- On Dashboard.php, fix creditors payment to point to allocation instead to payment, replace printf() with plain list echo, regroup code, and complete column styles. Modified Paths: -------------- trunk/Dashboard.php trunk/doc/Change.log Modified: trunk/Dashboard.php =================================================================== --- trunk/Dashboard.php 2016-11-01 18:42:38 UTC (rev 7660) +++ trunk/Dashboard.php 2016-11-03 20:33:07 UTC (rev 7661) @@ -1,80 +1,93 @@ <?php /* $Id: Dashboard.php 6843 2014-08-20 06:04:47Z daintree $*/ +/* Display outstanding debtors, creditors, etc */ include('includes/session.inc'); - $Title = _('Dashboard'); - +$ViewTopic = 'GeneralLedger';// RChacon: You should be in this topic ? +$BookMark = 'Dashboard'; include('includes/header.inc'); -echo '<p class="page_title_text"><img src="'.$RootPath.'/css/'.$Theme.'/images/gl.png" title="' . _('Dashboard') . '" alt="" />' . _('Dashboard') . '</p>'; +echo '<p class="page_title_text"><img alt="" src="', $RootPath, '/css/', $Theme, + '/images/gl.png" title="',// Icon image. + $Title, '" /> ',// Icon title. + $Title, '</p>';// Page title. -$sql = "SELECT pagesecurity +$Sql = "SELECT pagesecurity FROM scripts WHERE scripts.script = 'AgedDebtors.php'"; $ErrMsg = _('The security for Aging Debtors cannot be retrieved because'); $DbgMsg = _('The SQL that was used and failed was'); -$Security1Result = DB_query($sql, $ErrMsg, $DbgMsg); +$Security1Result = DB_query($Sql, $ErrMsg, $DbgMsg); $MyUserRow = DB_fetch_array($Security1Result); $DebtorSecurity = $MyUserRow['pagesecurity']; -$sql = "SELECT pagesecurity +$Sql = "SELECT pagesecurity FROM scripts WHERE scripts.script = 'SuppPaymentRun.php'"; $ErrMsg = _('The security for upcoming payments cannot be retrieved because'); $DbgMsg = _('The SQL that was used and failed was'); -$Security2Result = DB_query($sql, $ErrMsg, $DbgMsg); +$Security2Result = DB_query($Sql, $ErrMsg, $DbgMsg); $MyUserRow = DB_fetch_array($Security2Result); $PayeeSecurity = $MyUserRow['pagesecurity']; -$sql = "SELECT pagesecurity +$Sql = "SELECT pagesecurity FROM scripts WHERE scripts.script = 'GLAccountInquiry.php'"; $ErrMsg = _('The security for G/L Accounts cannot be retrieved because'); $DbgMsg = _('The SQL that was used and failed was'); -$Security2Result = DB_query($sql, $ErrMsg, $DbgMsg); +$Security2Result = DB_query($Sql, $ErrMsg, $DbgMsg); $MyUserRow = DB_fetch_array($Security2Result); $CashSecurity = $MyUserRow['pagesecurity']; -$sql = "SELECT pagesecurity +$Sql = "SELECT pagesecurity FROM scripts WHERE scripts.script = 'SelectSalesOrder.php'"; $ErrMsg = _('The security for Aging Debtors cannot be retrieved because'); $DbgMsg = _('The SQL that was used and failed was'); -$Security1Result = DB_query($sql, $ErrMsg, $DbgMsg); +$Security1Result = DB_query($Sql, $ErrMsg, $DbgMsg); $MyUserRow = DB_fetch_array($Security1Result); $OrderSecurity = $MyUserRow['pagesecurity']; -if (in_array($DebtorSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($DebtorSecurity)) { - echo '<br /><b>' . _('Overdue Customer Balances') . '</b> - <table class="selection"><tbody>'; +if(in_array($DebtorSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($DebtorSecurity)) { + echo '<br /> + <h2>', _('Overdue Customer Balances'), '</h2> + <table class="selection"> + <thead> + <tr> + <th>', _('Customer'), '</th> + <th>', _('Reference'), '</th> + <th>', _('Trans Date'), '</th> + <th>', _('Due Date'), '</th> + <th>', _('Balance'), '</th> + <th>', _('Current'), '</th> + <th>', _('Due Now'), '</th> + <th>', '> ', $_SESSION['PastDueDays1'], ' ', _('Days Over'), '</th> + <th>', '> ', $_SESSION['PastDueDays2'], ' ', _('Days Over'), '</th> + </tr> + </thead><tbody>'; + $j = 1; + $k = 0;// Row colour counter. + $TotBal = 0; + $TotCurr = 0; + $TotDue = 0; + $TotOD1 = 0; + $TotOD2 = 0; + $ListCount = DB_num_rows($CustomerResult); + $CurrDecimalPlaces = 2;//By default. - $TableHeader = '<tr> - <th>' . _('Customer') . '</th> - <th>' . _('Reference') . '</th> - <th>' . _('Trans Date') . '</th> - <th>' . _('Due Date') . '</th> - <th>' . _('Balance') . '</th> - <th>' . _('Current') . '</th> - <th>' . _('Due Now') . '</th> - <th>' . '> ' . $_SESSION['PastDueDays1'] . ' ' . _('Days Over') . '</th> - <th>' . '> ' . $_SESSION['PastDueDays2'] . ' ' . _('Days Over') . '</th> - </tr>'; - echo $TableHeader; - $j = 1; - $k=0; //row colour counter - if (!isset($_POST['Salesman'])){ - $_POST['Salesman']=''; + if(!isset($_POST['Salesman'])) { + $_POST['Salesman'] = ''; } - if ($_SESSION['SalesmanLogin'] != '') { + if($_SESSION['SalesmanLogin'] != '') { $_POST['Salesman'] = $_SESSION['SalesmanLogin']; } - if (trim($_POST['Salesman'])!=''){ + if(trim($_POST['Salesman']) != '') { $SalesLimit = " AND debtorsmaster.debtorno IN (SELECT DISTINCT debtorno FROM custbranch WHERE salesman = '".$_POST['Salesman']."') "; } else { $SalesLimit = ''; } - $SQL = "SELECT debtorsmaster.debtorno, + $Sql = "SELECT debtorsmaster.debtorno, debtorsmaster.name, currencies.currency, currencies.decimalplaces, @@ -139,35 +152,25 @@ holdreasons.reasondescription HAVING ROUND(ABS(SUM(debtortrans.ovamount + debtortrans.ovgst + debtortrans.ovfreight + debtortrans.ovdiscount - debtortrans.alloc)),currencies.decimalplaces) > 0"; - $CustomerResult = DB_query($SQL,'','',False,False); /*dont trap errors handled below*/ + $CustomerResult = DB_query($Sql, '', '', False, False); /*dont trap errors handled below*/ - if (DB_error_no() !=0) { + if(DB_error_no() != 0) { prnMsg(_('The customer details could not be retrieved by the SQL because') . ' ' . DB_error_msg(),'error'); echo '<br /><a href="' . $RootPath . '/index.php">' . _('Back to the menu') . '</a>'; - if ($debug==1){ - echo '<br />' . $SQL; + if($debug==1) { + echo '<br />', $Sql; } include('includes/footer.inc'); exit; } - - $TotBal=0; - $TotCurr=0; - $TotDue=0; - $TotOD1=0; - $TotOD2=0; - - $ListCount = DB_num_rows($CustomerResult); - $CurrDecimalPlaces =2; //by default - - while ($AgedAnalysis = DB_fetch_array($CustomerResult,$db)){ - if ($k==1){ + while($AgedAnalysis = DB_fetch_array($CustomerResult,$db)) { + if($k == 1) { echo '<tr class="EvenTableRows">'; - $k=0; + $k = 0; } else { echo '<tr class="OddTableRows">'; - $k=1; + $k = 1; } $CurrDecimalPlaces = $AgedAnalysis['decimalplaces']; $DisplayDue = locale_number_format($AgedAnalysis['due']-$AgedAnalysis['overdue1'],$CurrDecimalPlaces); @@ -175,35 +178,21 @@ $DisplayBalance = locale_number_format($AgedAnalysis['balance'],$CurrDecimalPlaces); $DisplayOverdue1 = locale_number_format($AgedAnalysis['overdue1']-$AgedAnalysis['overdue2'],$CurrDecimalPlaces); $DisplayOverdue2 = locale_number_format($AgedAnalysis['overdue2'],$CurrDecimalPlaces); - if ($DisplayDue <> 0 OR $DisplayOverdue1 <> 0 OR $DisplayOverdue2 <> 0) { + if($DisplayDue <> 0 OR $DisplayOverdue1 <> 0 OR $DisplayOverdue2 <> 0) { $TotBal += $AgedAnalysis['balance']; + $TotCurr += ($AgedAnalysis['balance']-$AgedAnalysis['due']); $TotDue += ($AgedAnalysis['due']-$AgedAnalysis['overdue1']); - $TotCurr += ($AgedAnalysis['balance']-$AgedAnalysis['due']); $TotOD1 += ($AgedAnalysis['overdue1']-$AgedAnalysis['overdue2']); $TotOD2 += $AgedAnalysis['overdue2']; + echo '<td class="text" colspan="4"><b>', $AgedAnalysis['debtorno'], ' - ', $AgedAnalysis['name'], '</b></td> + <td class="number"><b>', $DisplayBalance, '</b></td> + <td class="number"><b>', $DisplayCurrent, '</b></td> + <td class="number" style="color:orange;"><b>', $DisplayDue, '</b></td> + <td class="number" style="color:red;"><b>', $DisplayOverdue1, '</b></td> + <td class="number" style="color:red;"><b>', $DisplayOverdue2, '</b></td> + </tr>'; - - printf('<td><b>%s</b></td> - <td><b>%s</b></td> - <td><b>%s</b></td> - <td><b>%s</b></td> - <td class="number"><b>%s</b></td> - <td class="number"><b>%s</b></td> - <td class="number" style="color:orange;"><b>%s</b></td> - <td class="number" style="color:red;"><b>%s</b></td> - <td class="number" style="color:red;"><b>%s</b></td> - </tr>', - $AgedAnalysis['debtorno'] . ' - ' . $AgedAnalysis['name'], - '', - '', - '', - $DisplayBalance, - $DisplayCurrent, - $DisplayDue, - $DisplayOverdue1, - $DisplayOverdue2 ); - - $sql = "SELECT systypes.typename, + $Sql = "SELECT systypes.typename, debtortrans.transno, debtortrans.trandate, daysbeforedue, @@ -247,33 +236,32 @@ AND debtortrans.debtorno = '" . $AgedAnalysis['debtorno'] . "' AND ABS(debtortrans.ovamount + debtortrans.ovgst + debtortrans.ovfreight + debtortrans.ovdiscount - debtortrans.alloc)>0.004"; - if ($_SESSION['SalesmanLogin'] != '') { - $sql .= " AND debtortrans.salesperson='" . $_SESSION['SalesmanLogin'] . "'"; + if($_SESSION['SalesmanLogin'] != '') { + $Sql .= " AND debtortrans.salesperson='" . $_SESSION['SalesmanLogin'] . "'"; } - $DetailResult = DB_query($sql,'','',False,False); - if (DB_error_no() !=0) { + $DetailResult = DB_query($Sql,'','',False,False); + if(DB_error_no() !=0) { prnMsg(_('The details of outstanding transactions for customer') . ' - ' . $AgedAnalysis['debtorno'] . ' ' . _('could not be retrieved because') . ' - ' . DB_error_msg(),'error'); echo '<br /><a href="' . $RootPath . '/index.php">' . _('Back to the menu') . '</a>'; - if ($debug==1){ - echo '<br />' . _('The SQL that failed was') . '<br />' . $sql; + if($debug==1) { + echo '<br />' . _('The SQL that failed was') . '<br />' . $Sql; } include('includes/footer.inc'); exit; } - while ($DetailTrans = DB_fetch_array($DetailResult)){ - + while($DetailTrans = DB_fetch_array($DetailResult)) { $DisplayTranDate = ConvertSQLDate($DetailTrans['trandate']); - $DisplayDue = locale_number_format($DetailTrans['due']-$DetailTrans['overdue1'],$CurrDecimalPlaces); - $DisplayCurrent = locale_number_format($DetailTrans['balance']-$DetailTrans['due'],$CurrDecimalPlaces); - $DisplayBalance = locale_number_format($DetailTrans['balance'],$CurrDecimalPlaces); - $DisplayOverdue1 = locale_number_format($DetailTrans['overdue1']-$DetailTrans['overdue2'],$CurrDecimalPlaces); - $DisplayOverdue2 = locale_number_format($DetailTrans['overdue2'],$CurrDecimalPlaces); + $DisplayBalance = locale_number_format($DetailTrans['balance'], $CurrDecimalPlaces); + $DisplayCurrent = locale_number_format($DetailTrans['balance']-$DetailTrans['due'], $CurrDecimalPlaces); + $DisplayDue = locale_number_format($DetailTrans['due']-$DetailTrans['overdue1'], $CurrDecimalPlaces); + $DisplayOverdue1 = locale_number_format($DetailTrans['overdue1']-$DetailTrans['overdue2'], $CurrDecimalPlaces); + $DisplayOverdue2 = locale_number_format($DetailTrans['overdue2'], $CurrDecimalPlaces); - if ($DetailTrans['daysbeforedue'] > 0) { + if($DetailTrans['daysbeforedue'] > 0) { $AddDays=$DetailTrans['daysbeforedue'] . ' days'; - if (function_exists(date_add)) { + if(function_exists(date_add)) { $DisplayDueDate = date_add(date_create($DetailTrans['trandate']), date_interval_create_from_date_string($AddDays)); } else { $DisplayDueDate = strtotime($AddDays,strtotime($DetailTrans['trandate'])); @@ -281,7 +269,7 @@ } else { $AddDays=(intval($DetailTrans['dayinfollowingmonth']) - 1) . ' days'; - if (function_exists(date_add)){ + if(function_exists(date_add)) { $DisplayDueDate = date_create($DetailTrans['trandate']); $DisplayDueDate->modify('first day of next month'); $DisplayDueDate = date_add($DisplayDueDate, date_interval_create_from_date_string($AddDays)); @@ -291,91 +279,72 @@ } } - if (function_exists(date_add)) { + if(function_exists(date_add)) { $DisplayDueDate=date_format($DisplayDueDate,$_SESSION['DefaultDateFormat']); } else { $DisplayDueDate = Date($_SESSION['DefaultDateFormat'],$DisplayDueDate); } - if ($k==1){ + if($k == 1) { echo '<tr class="EvenTableRows">'; - $k=0; + $k = 0; } else { echo '<tr class="OddTableRows">'; - $k=1; + $k = 1; } - printf('<td style="text-align:center">%s</td> - <td style="text-align:right">%s</td> - <td>%s</td> - <td>%s</td> - <td class="number">%s</td> - <td class="number">%s</td> - <td class="number" style="color:orange;">%s</td> - <td class="number" style="color:red;">%s</td> - <td class="number" style="color:red;">%s</td>', - _($DetailTrans['typename']), - $DetailTrans['transno'], - $DisplayTranDate, - $DisplayDueDate, - $DisplayBalance, - $DisplayCurrent, - $DisplayDue, - $DisplayOverdue1, - $DisplayOverdue2); - echo '</tr>'; + echo '<td style="text-align:center">', _($DetailTrans['typename']), '</td>',// Should it be left (text field) ? + '<td class="number">', $DetailTrans['transno'], '</td> + <td class="centre">', $DisplayTranDate, '</td> + <td class="centre">', $DisplayDueDate, '</td> + <td class="number">', $DisplayBalance, '</td> + <td class="number">', $DisplayCurrent, '</td> + <td class="number" style="color:orange;">', $DisplayDue, '</td> + <td class="number" style="color:red;">', $DisplayOverdue1, '</td> + <td class="number" style="color:red;">', $DisplayOverdue2, '</td> + </tr>'; } //end while there are detail transactions to show } //has Due now or overdue } //end customer aged analysis while loop - $DisplayTotBalance = locale_number_format($TotBal,$CurrDecimalPlaces); - $DisplayTotDue = locale_number_format($TotDue,$CurrDecimalPlaces); - $DisplayTotCurrent = locale_number_format($TotCurr,$CurrDecimalPlaces); - $DisplayTotOverdue1 = locale_number_format($TotOD1,$CurrDecimalPlaces); - $DisplayTotOverdue2 = locale_number_format($TotOD2,$CurrDecimalPlaces); - if ($k==1){ + // Print totals of 'Overdue Customer Balances': + if($k == 1) { echo '<tr class="EvenTableRows">'; - $k=0; + $k = 0; } else { echo '<tr class="OddTableRows">'; - $k=1; + $k = 1; } - printf('<td style="text-align:left"><b>%s</b></td> - <td><b>%s</b></td> - <td><b>%s</b></td> - <td><b>%s</b></td> - <td class="number"><b>%s</b></td> - <td class="number"><b>%s</b></td> - <td class="number"><b>%s</b></td> - <td class="number" style="color:red;"><b>%s</b></td> - <td class="number" style="color:red;"><b>%s</b></td>', - _('Totals'), - '', - '', - '', - $DisplayTotBalance, - $DisplayTotCurrent, - $DisplayTotDue, - $DisplayTotOverdue1, - $DisplayTotOverdue2); - - echo '</tr>'; - echo '</tbody> - </table>'; + echo '<td class="text"><b>', _('Totals'), '</b></td> + <td> </td> + <td> </td> + <td> </td> + <td class="number"><b>', locale_number_format($TotBal, $CurrDecimalPlaces), '</b></td> + <td class="number"><b>', locale_number_format($TotCurr, $CurrDecimalPlaces), '</b></td> + <td class="number"><b>', locale_number_format($TotDue, $CurrDecimalPlaces), '</b></td> + <td class="number" style="color:red;"><b>', locale_number_format($TotOD1, $CurrDecimalPlaces), '</b></td> + <td class="number" style="color:red;"><b>', locale_number_format($TotOD2, $CurrDecimalPlaces), '</b></td> + </tr> + </tbody></table>'; } //DebtorSecurity -if (in_array($PayeeSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($PayeeSecurity)) { +if(in_array($PayeeSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($PayeeSecurity)) { + echo '<br /> + <h2>', _('Supplier Invoices Due within 1 Month'), '</h2> + <table class="selection"> + <thead> + <tr> + <th>', _('Supplier'), '</th> + <th>', _('Invoice Date'), '</th> + <th>', _('Invoice'), '</th> + <th>', _('Amount Due'), '</th> + <th>', _('Due Date'), '</th> + </tr> + </thead><tbody>'; + $SupplierID = ''; + $TotalPayments = 0; + $TotalAccumDiffOnExch = 0; + $AccumBalance = 0; - echo '<br /><b>' . _('Supplier Invoices Due within 1 Month') . '</b> - <table class="selection"> - <tbody> - <tr> - <th>' . _('Supplier') . '</th> - <th>' . _('Invoice Date') . '</th> - <th>' . _('Invoice') . '</th> - <th>' . _('Amount Due') . '</th> - <th>' . _('Due Date') . '</th> - </tr>'; - - $sql = "SELECT suppliers.supplierid, + $Sql = "SELECT suppliers.supplierid, currencies.decimalplaces AS currdecimalplaces, SUM(supptrans.ovamount + supptrans.ovgst - supptrans.alloc) AS balance FROM suppliers INNER JOIN paymentterms @@ -392,19 +361,13 @@ currencies.decimalplaces HAVING SUM(supptrans.ovamount + supptrans.ovgst - supptrans.alloc) <> 0 ORDER BY suppliers.supplierid"; + $SuppliersResult = DB_query($Sql); - $SuppliersResult = DB_query($sql); + while($SuppliersToPay = DB_fetch_array($SuppliersResult)) { - $SupplierID =''; - $TotalPayments = 0; - $TotalAccumDiffOnExch = 0; - $AccumBalance =0; - - while ($SuppliersToPay = DB_fetch_array($SuppliersResult)){ - $CurrDecimalPlaces = $SuppliersToPay['currdecimalplaces']; - $sql = "SELECT suppliers.supplierid, + $Sql = "SELECT suppliers.supplierid, suppliers.suppname, systypes.typename, paymentterms.terms, @@ -418,26 +381,24 @@ (supptrans.ovamount + supptrans.ovgst ) AS trantotal, supptrans.diffonexch, supptrans.id - FROM suppliers INNER JOIN paymentterms - ON suppliers.paymentterms = paymentterms.termsindicator - INNER JOIN supptrans - ON suppliers.supplierid = supptrans.supplierno - INNER JOIN systypes - ON systypes.typeid = supptrans.type + FROM suppliers + INNER JOIN paymentterms ON suppliers.paymentterms = paymentterms.termsindicator + INNER JOIN supptrans ON suppliers.supplierid = supptrans.supplierno + INNER JOIN systypes ON systypes.typeid = supptrans.type WHERE supptrans.supplierno = '" . $SuppliersToPay['supplierid'] . "' - AND supptrans.ovamount + supptrans.ovgst - supptrans.alloc !=0 - AND supptrans.duedate <='" . Date('Y-m-d', mktime(0,0,0, Date('n'),Date('j')+30,date('Y'))) . "' - AND supptrans.hold = 0 + AND supptrans.ovamount + supptrans.ovgst - supptrans.alloc !=0 + AND supptrans.duedate <='" . Date('Y-m-d', mktime(0,0,0, Date('n'),Date('j')+30,date('Y'))) . "' + AND supptrans.hold = 0 ORDER BY supptrans.supplierno, supptrans.type, supptrans.transno"; - $TransResult = DB_query($sql,'','',false,false); - if (DB_error_no() !=0) { + $TransResult = DB_query($Sql,'','',false,false); + if(DB_error_no() !=0) { prnMsg(_('The details of supplier invoices due could not be retrieved because') . ' - ' . DB_error_msg(),'error'); echo '<br /><a href="' . $RootPath . '/index.php">' . _('Back to the menu') . '</a>'; - if ($debug==1){ - echo '<br />' . _('The SQL that failed was') . ' ' . $sql; + if($debug==1) { + echo '<br />' . _('The SQL that failed was') . ' ' . $Sql; } include('includes/footer.inc'); exit; @@ -446,95 +407,90 @@ unset($Allocs); $Allocs = array(); $AllocCounter =0; - $k=0; //row colour counter + $k = 0; //row colour counter - while ($DetailTrans = DB_fetch_array($TransResult)){ - - if ($DetailTrans['supplierid'] != $SupplierID){ /*Need to head up for a new suppliers details */ - if ($k==1){ + while($DetailTrans = DB_fetch_array($TransResult)) { + if($DetailTrans['supplierid'] != $SupplierID) { /*Need to head up for a new suppliers details */ + if($k == 1) { echo '<tr class="EvenTableRows">'; - $k=0; + $k = 0; } else { echo '<tr class="OddTableRows">'; - $k=1; + $k = 1; } $SupplierID = $DetailTrans['supplierid']; $SupplierName = $DetailTrans['suppname']; - //$AccumBalance = 0; $AccumDiffOnExch = 0; + echo '<td class="text" colspan="5"><b>', $DetailTrans['supplierid'], ' - ', $DetailTrans['suppname'], ' - ', $DetailTrans['terms'], '</b></td> + </tr>'; + } - printf('<td style="text-align:left"><b>%s</b></td> - <td>%s</td> - <td>%s</td> - <td class="number">%s</td> - <td>%s</td>', - $DetailTrans['supplierid'] . ' - ' . $DetailTrans['suppname'] . ' - ' . $DetailTrans['terms'], - '', - '', - '', - ''); - echo '</tr>'; - } - if ($k==1){ + if($k == 1) { echo '<tr class="EvenTableRows">'; - $k=0; + $k = 0; } else { echo '<tr class="OddTableRows">'; - $k=1; + $k = 1; } $DisplayFormat = ''; - - if ((time()-(60*60*24)) > strtotime($DetailTrans['duedate'])) { - $DisplayFormat=' style="color:red;" '; + if((time()-(60*60*24)) > strtotime($DetailTrans['duedate'])) { + $DisplayFormat = ' style="color:red;"'; } $DislayTranDate = ConvertSQLDate($DetailTrans['trandate']); $AccumBalance += $DetailTrans['balance']; - $PayNow='<a href="' . $RootPath . '/Payments.php?&SupplierID=' . $SupplierID. '&Amount=' . $DetailTrans['balance'] . '&BankTransRef=' .$DetailTrans['suppreference'] . '">' .$DetailTrans['suppreference'] . '</a>'; - printf('<td style="text-align:center">%s</td> - <td>%s</td> - <td>%s</td> - <td class="number"' . $DisplayFormat . '>%s</td> - <td' . $DisplayFormat . '>%s</td>', - _($DetailTrans['typename']), - $DislayTranDate, - $PayNow, - locale_number_format($DetailTrans['balance'],$CurrDecimalPlaces), - ConvertSQLDate($DetailTrans['duedate'])); - echo '</tr>'; + if(_($DetailTrans['type']) == 20) {// If Purchase Invoice: + echo '<td style="text-align:center">', _($DetailTrans['typename']), '</td> + <td class="centre">', $DislayTranDate, '</td> + <td class="text"><a href="', $RootPath, '/Payments.php?&SupplierID=', $SupplierID, '&Amount=', $DetailTrans['balance'], '&BankTransRef=', $DetailTrans['suppreference'], '">', $DetailTrans['suppreference'], '</a></td> + <td class="number"', $DisplayFormat, '>', locale_number_format($DetailTrans['balance'], $CurrDecimalPlaces), '</td> + <td class="centre"', $DisplayFormat, '>', ConvertSQLDate($DetailTrans['duedate']), '</td> + </tr>'; + } else {// If NOT Purchase Invoice (Creditors Payment): + echo '<td style="text-align:center">', _($DetailTrans['typename']), '</td> + <td class="centre">', $DislayTranDate, '</td> + <td class="text"><a href="', $RootPath, '/SupplierAllocations.php?AllocTrans=', $DetailTrans['id'], '">', $DetailTrans['suppreference'], '</a></td> + <td class="number"', $DisplayFormat, '>', locale_number_format($DetailTrans['balance'], $CurrDecimalPlaces), '</td> + <td class="centre"', $DisplayFormat, '>', ConvertSQLDate($DetailTrans['duedate']), '</td> + </tr>'; + } } /*end while there are detail transactions to show */ } /* end while there are suppliers to retrieve transactions for */ - if ($k==1){ + if($k == 1) { echo '<tr class="EvenTableRows">'; - $k=0; + $k = 0; } else { echo '<tr class="OddTableRows">'; - $k=1; + $k = 1; } - echo '<td style="text-align:left">' . _('Grand Total Payments Due') . '</td> - <td></td> - <td></td> - <td class="number"><b>' . locale_number_format($AccumBalance,$CurrDecimalPlaces) . '</b></td> - <td></td> + echo '<td class="number">', _('Grand Total Payments Due'), '</td> + <td> </td> + <td> </td> + <td class="number"><b>', locale_number_format($AccumBalance, $CurrDecimalPlaces), '</b></td> + <td> </td> </tr> </tbody> </table>'; } //PayeeSecurity -if (in_array($CashSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($CashSecurity)) { + +if(in_array($CashSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($CashSecurity)) { include('includes/GLPostings.inc'); - echo '<br /><b>' . _('Bank and Credit Card Balances') . '</b> - <table class="selection"><tbody>'; + echo '<br /> + <h2>', _('Bank and Credit Card Balances'), '</h2> + <table class="selection">', +/* '<thead>',*/ // Need to update the sorting javascript. + '<tr> + <th class="ascending">', _('GL Account'), '</th> + <th class="ascending">', _('Account Name'), '</th> + <th class="ascending">', _('Balance'), '</th> + </tr>' +/*, '</thead><tbody>'*/;// Need to update the sorting javascript. $FirstPeriodSelected = GetPeriod(date($_SESSION['DefaultDateFormat']), $db); $LastPeriodSelected = GetPeriod(date($_SESSION['DefaultDateFormat']), $db); $SelectedPeriod=$LastPeriodSelected; - echo '<tr> - <th class="ascending">' . _('GL Account') . '</th> - <th class="ascending">' . _('Account Name') . '</th> - <th class="ascending">' . _('Balance') . '</th> - </tr>'; - $sql = "SELECT bankaccounts.accountcode, + $Sql = "SELECT bankaccounts.accountcode, bankaccounts.bankaccountcode, chartmaster.accountname, bankaccountname @@ -542,18 +498,18 @@ ON bankaccounts.accountcode = chartmaster.accountcode"; $ErrMsg = _('The bank accounts set up could not be retrieved because'); - $DbgMsg = _('The SQL used to retrieve the bank account details was') . '<br />' . $sql; - $result1 = DB_query($sql,$ErrMsg,$DbgMsg); + $DbgMsg = _('The SQL used to retrieve the bank account details was') . '<br />' . $Sql; + $result1 = DB_query($Sql,$ErrMsg,$DbgMsg); - $k=0; //row colour counter + $k = 0; //row colour counter - while ($myrow = DB_fetch_array($result1)) { - if ($k==1){ + while($myrow = DB_fetch_array($result1)) { + if($k == 1) { echo '<tr class="EvenTableRows">'; - $k=0; + $k = 0; } else { echo '<tr class="OddTableRows">'; - $k++; + $k = 1; } /*Is the account a balance sheet or a profit and loss account */ $result = DB_query("SELECT pandl @@ -561,13 +517,13 @@ INNER JOIN chartmaster ON accountgroups.groupname=chartmaster.group_ WHERE chartmaster.accountcode='" . $myrow['accountcode'] ."'"); $PandLRow = DB_fetch_row($result); - if ($PandLRow[0]==1){ + if($PandLRow[0]==1) { $PandLAccount = True; - }else{ + } else { $PandLAccount = False; /*its a balance sheet account */ } - $sql= "SELECT counterindex, + $Sql= "SELECT counterindex, type, typename, gltrans.typeno, @@ -586,12 +542,11 @@ AND periodno>='" . $FirstPeriodSelected . "' AND periodno<='" . $LastPeriodSelected . "' ORDER BY periodno, gltrans.trandate, counterindex"; - $TransResult = DB_query($sql,$ErrMsg); - if ($PandLAccount==True) { + $TransResult = DB_query($Sql,$ErrMsg); + if($PandLAccount==True) { $RunningTotal = 0; - } else { - // added to fix bug with Brought Forward Balance always being zero - $sql = "SELECT bfwd, + } else {// added to fix bug with Brought Forward Balance always being zero + $Sql = "SELECT bfwd, actual, period FROM chartdetails @@ -599,33 +554,32 @@ AND chartdetails.period='" . $FirstPeriodSelected . "'"; $ErrMsg = _('The chart details for account') . ' ' . $myrow['accountcode'] . ' ' . _('could not be retrieved'); - $ChartDetailsResult = DB_query($sql,$ErrMsg); + $ChartDetailsResult = DB_query($Sql,$ErrMsg); $ChartDetailRow = DB_fetch_array($ChartDetailsResult); - $RunningTotal =$ChartDetailRow['bfwd']; + $RunningTotal = $ChartDetailRow['bfwd']; } $PeriodTotal = 0; $PeriodNo = -9999; - while ($myrow2=DB_fetch_array($TransResult)) { - if ($myrow2['periodno']!=$PeriodNo){ - if ($PeriodNo!=-9999){ //ie its not the first time around + while($myrow2=DB_fetch_array($TransResult)) { + if($myrow2['periodno']!=$PeriodNo) { + if($PeriodNo!=-9999) { //ie its not the first time around /*Get the ChartDetails balance b/fwd and the actual movement in the account for the period as recorded in the chart details - need to ensure integrity of transactions to the chart detail movements. Also, for a balance sheet account it is the balance carried forward that is important, not just the transactions*/ - $sql = "SELECT bfwd, + $Sql = "SELECT bfwd, actual, period FROM chartdetails WHERE chartdetails.accountcode='" . $myrow['accountcode'] . "' AND chartdetails.period='" . $PeriodNo . "'"; - $ErrMsg = _('The chart details for account') . ' ' . $myrow['accountcode'] . ' ' . _('could not be retrieved'); - $ChartDetailsResult = DB_query($sql,$ErrMsg); + $ChartDetailsResult = DB_query($Sql,$ErrMsg); $ChartDetailRow = DB_fetch_array($ChartDetailsResult); - if ($PeriodTotal < 0 ){ //its a credit balance b/fwd - if ($PandLAccount==True) { + if($PeriodTotal < 0 ) { //its a credit balance b/fwd + if($PandLAccount==True) { $RunningTotal = 0; } } else { //its a debit balance b/fwd - if ($PandLAccount==True) { + if($PandLAccount==True) { $RunningTotal = 0; } } @@ -637,33 +591,33 @@ $PeriodTotal += $myrow2['amount']; } $DisplayBalance=locale_number_format(($RunningTotal),$_SESSION['CompanyRecord']['decimalplaces']); - printf('<td>%s</td> - <td>%s</td> - <td class="number">%s</td> - </tr>', - $myrow['accountcode'] . ' - ' . $myrow['accountname'], - $myrow['bankaccountname'], - $DisplayBalance); + echo '<td class="text">', $myrow['accountcode'], ' - ', $myrow['accountname'], '</td> + <td class="text">', $myrow['bankaccountname'], '</td> + <td class="number">', $DisplayBalance, '</td> + </tr>'; } //each bank account - echo '</tbody> - </table>'; + echo /*'</tbody>',*/// Need to update the sorting javascript. + '</table>'; } //CashSecurity -if (in_array($OrderSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($OrderSecurity)) { - echo '<br /><b>' . _('Outstanding Orders') . '</b> - <table cellpadding="2" width="95%" class="selection"> - <tr> - <th>' . _('View Order') . '</th> - <th>' . _('Customer') . '</th> - <th>' . _('Branch') . '</th> - <th>' . _('Cust Order') . ' #</th> - <th>' . _('Order Date') . '</th> - <th>' . _('Req Del Date') . '</th> - <th>' . _('Delivery To') . '</th> - <th>' . _('Order Total') . ' ' . _('in') . ' ' . $_SESSION['CompanyRecord']['currencydefault'] . '</th> - </tr>'; +if(in_array($OrderSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($OrderSecurity)) { + echo '<br /> + <h2>', _('Outstanding Orders'), '</h2> + <table class="selection"> + <thead>', + '<tr> + <th>', _('View Order'), '</th> + <th>', _('Customer'), '</th> + <th>', _('Branch'), '</th> + <th>', _('Cust Order'), ' #</th> + <th>', _('Order Date'), '</th> + <th>', _('Req Del Date'), '</th> + <th>', _('Delivery To'), '</th> + <th>', _('Order Total'), ' ', _('in'), ' ', $_SESSION['CompanyRecord']['currencydefault'], '</th> + </tr> + </thead><tbody>'; - $SQL = "SELECT salesorders.orderno, + $Sql = "SELECT salesorders.orderno, debtorsmaster.name, custbranch.brname, salesorders.customerref, @@ -694,59 +648,47 @@ salesorders.printedpackingslip ORDER BY salesorders.orddate DESC, salesorders.orderno"; $ErrMsg = _('No orders or quotations were returned by the SQL because'); - $SalesOrdersResult = DB_query($SQL,$ErrMsg); + $SalesOrdersResult = DB_query($Sql,$ErrMsg); /*show a table of the orders returned by the SQL */ - if (DB_num_rows($SalesOrdersResult)>0) { - $k=0; //row colour counter - $OrdersTotal =0; - $FontColor=''; + if(DB_num_rows($SalesOrdersResult)>0) { + $k = 0; //row colour counter + $OrdersTotal = 0; + $FontColor = ''; - while ($myrow=DB_fetch_array($SalesOrdersResult)) { - - $OrderDate = ConvertSQLDate($myrow['orddate']); - $FormatedDelDate = ConvertSQLDate($myrow['deliverydate']); - $FormatedOrderValue = locale_number_format($myrow['ordervalue'],$_SESSION['CompanyRecord']['decimalplaces']); - - if (DateDiff(Date($_SESSION['DefaultDateFormat']),$OrderDate,'d')>5) { - $FontColor=' style="color:green; font-weight:bold"'; + while($MyRow=DB_fetch_array($SalesOrdersResult)) { + $OrderDate = ConvertSQLDate($MyRow['orddate']); + $FormatedDelDate = ConvertSQLDate($MyRow['deliverydate']); + $FormatedOrderValue = locale_number_format($MyRow['ordervalue'],$_SESSION['CompanyRecord']['decimalplaces']); + if(DateDiff(Date($_SESSION['DefaultDateFormat']), $OrderDate, 'd') > 5) { + $FontColor = ' style="color:green; font-weight:bold"'; } - if ($k==1){ + if($k == 1) { echo '<tr class="EvenTableRows">'; - $k=0; + $k = 0; } else { echo '<tr class="OddTableRows">'; - $k++; + $k = 1; } + echo '<td class="number"><a href="', $RootPath, '/OrderDetails.php?OrderNumber=', $MyRow['orderno'], '" target="_blank">', $MyRow['orderno'], '</a></td> + <td class="text"', $FontColor, '>', $MyRow['name'], '</td> + <td class="text"', $FontColor, '>', $MyRow['brname'], '</td> + <td class="number"', $FontColor, '>', $MyRow['customerref'], '</td> + <td class="centre"', $FontColor, '>', $OrderDate, '</td> + <td class="centre"', $FontColor, '>', $FormatedDelDate, '</td> + <td class="text"', $FontColor, '>', html_entity_decode($MyRow['deliverto'], ENT_QUOTES, 'UTF-8'), '</td> + <td class="number"', $FontColor , '>', $FormatedOrderValue, '</td> + </tr>'; + $OrdersTotal += $MyRow['ordervalue']; + }// END while($MyRow=DB_fetch_array($SalesOrdersResult)) - printf( '<td><a href="%s" target="_blank">' . $myrow['orderno'] . '</a></td> - <td' . $FontColor . '>%s</td> - <td' . $FontColor . '>%s</td> - <td' . $FontColor . '>%s</td> - <td' . $FontColor . '>%s</td> - <td' . $FontColor . '>%s</td> - <td' . $FontColor . '>%s</td> - <td' . $FontColor . ' class="number">%s</td> - </tr>', - $RootPath . '/OrderDetails.php?OrderNumber=' . $myrow['orderno'], - $myrow['name'], - $myrow['brname'], - $myrow['customerref'], - $OrderDate, - $FormatedDelDate, - html_entity_decode($myrow['deliverto'],ENT_QUOTES,'UTF-8'), - $FormatedOrderValue); - $OrdersTotal += $myrow['ordervalue']; - } //while + echo '<tr> + <td class="number" colspan="7"><b>', _('Total Order(s) Value in'), ' ', $_SESSION['CompanyRecord']['currencydefault'], ' :</b></td> + <td class="number"><b>', locale_number_format($OrdersTotal,$_SESSION['CompanyRecord']['decimalplaces']), '</b></td> + </tr> + </tbody></table>'; - echo '<tfoot> - <tr> - <td colspan="7" class="number"><b>' . _('Total Order(s) Value in') . ' ' . $_SESSION['CompanyRecord']['currencydefault'] . ' :</b></td> - <td class="number"><b>' . locale_number_format($OrdersTotal,$_SESSION['CompanyRecord']['decimalplaces']) . '</b></td> - </tr> - </tfoot> - </table>'; } //rows > 0 } //OrderSecurity include('includes/footer.inc'); -?> +?> \ No newline at end of file Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2016-11-01 18:42:38 UTC (rev 7660) +++ trunk/doc/Change.log 2016-11-03 20:33:07 UTC (rev 7661) @@ -1,5 +1,6 @@ webERP Change Log +03/11/16 RChacon: On Dashboard.php, fix creditors payment to point to allocation instead to payment, replace printf() with plain list echo, regroup code, and complete column styles. 01/11/16 RChacon: On SupplierInquiry.php, replace the printf() statements with echo statements to fix bug caused by a supplier invoice with a comment that includes a % character (reported by R2-G, solution by Tim). 30/10/16 RChacon: In SecurityTokens.php: Fix Description's input maxlength, fix table head in data table, move form-tables after data table, add cancel button in edit form table, add return button, add style to print data table, add title in form tables, regroup code, change from if/elseif to switch/case to improve code readability, and add code documentation. 30/10/16 RChacon: On SupplierPriceList.php, add ViewTopic and BookMark, and complete html table. Add info to manual. |