From: <dai...@us...> - 2010-08-14 09:55:46
|
Revision: 3690 http://web-erp.svn.sourceforge.net/web-erp/?rev=3690&view=rev Author: daintree Date: 2010-08-14 09:55:38 +0000 (Sat, 14 Aug 2010) Log Message: ----------- New contracts work to charge purchase invocies against contracts Modified Paths: -------------- trunk/CreditStatus.php trunk/DeliveryDetails.php trunk/GLTransInquiry.php trunk/SuppShiptChgs.php trunk/SuppTransGLAnalysis.php trunk/SupplierCredit.php trunk/SupplierInvoice.php trunk/doc/Change.log.html trunk/doc/Manual/ManualContents.php trunk/includes/DefineSuppTransClass.php trunk/index.php trunk/sql/mysql/upgrade3.11.1-3.12.sql Removed Paths: ------------- trunk/SuppInvGLAnalysis.php Modified: trunk/CreditStatus.php =================================================================== --- trunk/CreditStatus.php 2010-08-10 08:27:14 UTC (rev 3689) +++ trunk/CreditStatus.php 2010-08-14 09:55:38 UTC (rev 3690) @@ -66,14 +66,14 @@ if (isset($_POST['DisallowInvoices']) and $_POST['DisallowInvoices']=='on'){ $sql = "UPDATE holdreasons SET - reasondescription='" . $_POST['ReasonDescription'] . "', - dissallowinvoices=1 - WHERE reasoncode = '".$SelectedReason."'"; + reasondescription='" . $_POST['ReasonDescription'] . "', + dissallowinvoices=1 + WHERE reasoncode = '".$SelectedReason."'"; } else { $sql = "UPDATE holdreasons SET - reasondescription='" . $_POST['ReasonDescription'] . "', - dissallowinvoices=0 - WHERE reasoncode = '".$SelectedReason."'"; + reasondescription='" . $_POST['ReasonDescription'] . "', + dissallowinvoices=0 + WHERE reasoncode = '".$SelectedReason."'"; } $msg = _('The credit status record has been updated'); @@ -193,7 +193,7 @@ if (!isset($_GET['delete'])) { - echo "<form method='post' action=" . $_SERVER['PHP_SELF'] . '>'; + echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; if (isset($SelectedReason) and ($InputError!=1)) { //editing an existing status code @@ -232,17 +232,17 @@ $_POST['ReasonDescription'] = ''; } echo '<tr> - <td>'. _('Description') .":</td> - <td><input " . (in_array('ReasonDescription',$Errors) ? 'class="inputerror"' : '' ) . - " tabindex=2 type='text' name='ReasonDescription' VALUE='". $_POST['ReasonDescription'] ."' size=28 maxlength=30> - </td></tr> - <tr><td>". _('Disallow Invoices') . "</td>"; + <td>'. _('Description') .':</td> + <td><input ' . (in_array('ReasonDescription',$Errors) ? 'class="inputerror"' : '' ) . + ' tabindex=2 type="text" name="ReasonDescription" VALUE="'. $_POST['ReasonDescription'] .'" size="28" maxlength="30"> + </td></tr> + <tr><td>'. _('Disallow Invoices') . '</td>'; if (isset($_POST['DisallowInvoices']) and $_POST['DisallowInvoices']==1) { - echo "<td><input tabindex=3 type='checkbox' checked name='DisallowInvoices'></td></tr>"; + echo '<td><input tabindex=3 type="checkbox" checked name="DisallowInvoices"></td></tr>'; } else { - echo "<td><input tabindex=3 type='checkbox' name='DisallowInvoices'></td></tr>"; + echo '<td><input tabindex=3 type="checkbox" name="DisallowInvoices"></td></tr>'; } - echo "</table><br><div class='centre'><input tabindex=4 type='Submit' name='submit' value='" . _('Enter Information') . "'></div></form>"; + echo '</table><br><div class="centre"><input tabindex=4 type="submit" name="submit" value="' . _('Enter Information') . '"></div></form>'; } //end if record deleted no point displaying form to add record include('includes/footer.inc'); ?> \ No newline at end of file Modified: trunk/DeliveryDetails.php =================================================================== --- trunk/DeliveryDetails.php 2010-08-10 08:27:14 UTC (rev 3689) +++ trunk/DeliveryDetails.php 2010-08-14 09:55:38 UTC (rev 3690) @@ -620,35 +620,35 @@ WHERE orderno='" .$_SESSION['ExistingOrder'] . "'", $db,$ErrMsg,$DbgMsg,true); $ErrMsg = _('Could not insert the contract bill of materials'); $InsContractBOM = DB_query("INSERT INTO bom (parent, - component, - workcentreadded, - location, - effectiveafter, - effectiveto) - SELECT contractref, - stockid, - workcentreadded, - '" . $_SESSION['Items'.$identifier]->Location ."', - '" . Date('Y-m-d') . "', - '2037-12-31' - FROM contractbom - WHERE contractref='" . $ContractRow['contractref'] . "'",$db,$ErrMsg,$DbgMsg); + component, + workcentreadded, + loccode, + effectiveafter, + effectiveto) + SELECT contractref, + stockid, + workcentreadded, + '" . $_SESSION['Items'.$identifier]->Location ."', + '" . Date('Y-m-d') . "', + '2037-12-31' + FROM contractbom + WHERE contractref='" . $ContractRow['contractref'] . "'",$db,$ErrMsg,$DbgMsg); $ErrMsg = _('Unable to insert a new work order for the sales order item'); $InsWOResult = DB_query("INSERT INTO workorders (wo, - loccode, - requiredby, - startdate) - VALUES ('" . $WONo . "', - '" . $_SESSION['Items'.$identifier]->Location ."', - '" . $ContractRow['requireddate'] . "', - '" . Date('Y-m-d'). "')", - $db,$ErrMsg,$DbgMsg); + loccode, + requiredby, + startdate) + VALUES ('" . $WONo . "', + '" . $_SESSION['Items'.$identifier]->Location ."', + '" . $ContractRow['requireddate'] . "', + '" . Date('Y-m-d'). "')", + $db,$ErrMsg,$DbgMsg); //Need to get the latest BOM to roll up cost but also add the contract other requirements - $CostResult = DB_query("SELECT SUM((materialcost+labourcost+overheadcost)*bom.quantity) AS cost - FROM stockmaster INNER JOIN contractbom - ON stockmaster.stockid=contractbom.stockid - WHERE contractbom.contractref='" . $ContractRow['contractref'] . "'", + $CostResult = DB_query("SELECT SUM((materialcost+labourcost+overheadcost)*contractbom.quantity) AS cost + FROM stockmaster INNER JOIN contractbom + ON stockmaster.stockid=contractbom.stockid + WHERE contractbom.contractref='" . $ContractRow['contractref'] . "'", $db); $CostRow = DB_fetch_row($CostResult); if (is_null($CostRow[0]) OR $CostRow[0]==0){ Modified: trunk/GLTransInquiry.php =================================================================== --- trunk/GLTransInquiry.php 2010-08-10 08:27:14 UTC (rev 3689) +++ trunk/GLTransInquiry.php 2010-08-14 09:55:38 UTC (rev 3690) @@ -52,22 +52,22 @@ </tr>'; $SQL = "SELECT gltrans.type, - gltrans.trandate, - gltrans.periodno, - gltrans.account, - gltrans.narrative, - gltrans.amount, - gltrans.posted, - chartmaster.accountname, - periods.lastdate_in_period - FROM gltrans, - chartmaster, - periods - WHERE gltrans.account = chartmaster.accountcode - AND periods.periodno=gltrans.periodno - AND gltrans.type= '" . $_GET['TypeID'] . "' - AND gltrans.typeno = '" . $_GET['TransNo'] . "' - ORDER BY gltrans.counterindex"; + gltrans.trandate, + gltrans.periodno, + gltrans.account, + gltrans.narrative, + gltrans.amount, + gltrans.posted, + chartmaster.accountname, + periods.lastdate_in_period + FROM gltrans, + chartmaster, + periods + WHERE gltrans.account = chartmaster.accountcode + AND periods.periodno=gltrans.periodno + AND gltrans.type= '" . $_GET['TypeID'] . "' + AND gltrans.typeno = '" . $_GET['TransNo'] . "' + ORDER BY gltrans.counterindex"; $TransResult = DB_query($SQL,$db); $Posted = _('Yes'); @@ -135,23 +135,33 @@ $j++; } echo '<td>' . $TranDate . '</td> - <td class=number>' . MonthAndYearFromSQLDate($TransRow['lastdate_in_period']) . '</td> - <td><a href="' . $URL . '">' . $TransRow['accountname'] . '</a></td> - <td class=number>' . $DebitAmount . '</td> - <td class=number>' . $CreditAmount . '</td> - <td>' . $TransRow['narrative'] . '</td> - <td>' . $Posted . '</td> - </tr>'; + <td>' . MonthAndYearFromSQLDate($TransRow['lastdate_in_period']) . '</td> + <td><a href="' . $URL . '">' . $TransRow['accountname'] . '</a></td> + <td class=number>' . $DebitAmount . '</td> + <td class=number>' . $CreditAmount . '</td> + <td>' . $TransRow['narrative'] . '</td> + <td>' . $Posted . '</td> + </tr>'; } if ($DetailResult) { while ( $DetailRow = DB_fetch_row($DetailResult) ) { if ( $TransRow['amount'] > 0){ - $Debit = number_format(($DetailRow[1] + $DetailRow[2]) / $DetailRow[3],2); - $Credit = ' '; + if ($TransRow['account'] == $_SESSION['CompanyRecord']['debtorsact']) { + $Debit = number_format(($DetailRow[1] + $DetailRow[2]) / $DetailRow[3],2); + $Credit = ' '; + } else { + $Debit = number_format((-$DetailRow[1] - $DetailRow[2]) / $DetailRow[3],2); + $Credit = ' '; + } } else { - $Credit = number_format(-($DetailRow[1] + $DetailRow[2]) / $DetailRow[3],2); - $Debit = ' '; + if ($TransRow['account'] == $_SESSION['CompanyRecord']['debtorsact']) { + $Credit = number_format(-($DetailRow[1] + $DetailRow[2]) / $DetailRow[3],2); + $Debit = ' '; + } else { + $Credit = number_format(($DetailRow[1] + $DetailRow[2]) / $DetailRow[3],2); + $Debit = ' '; + } } if ($j==1) { @@ -162,13 +172,13 @@ $j++; } echo '<td>' . $TranDate . '</td> - <td class=number>' . $TransRow['periodno'] . '</td> - <td><a href="' . $URL . $DetailRow[0] . $date . '">' . $TransRow['accountname'] . ' - ' . $DetailRow[4] . '</a></td> - <td class=number>' . $Debit . '</td> - <td class=number>' . $Credit . '</td> - <td>' . $TransRow['narrative'] . '</td> - <td>' . $Posted . '</td> - </tr>'; + <td>' . MonthAndYearFromSQLDate($TransRow['lastdate_in_period']) . '</td> + <td><a href="' . $URL . $DetailRow[0] . $date . '">' . $TransRow['accountname'] . ' - ' . $DetailRow[4] . '</a></td> + <td class=number>' . $Debit . '</td> + <td class=number>' . $Credit . '</td> + <td>' . $TransRow['narrative'] . '</td> + <td>' . $Posted . '</td> + </tr>'; } DB_free_result($DetailResult); } Deleted: trunk/SuppInvGLAnalysis.php =================================================================== --- trunk/SuppInvGLAnalysis.php 2010-08-10 08:27:14 UTC (rev 3689) +++ trunk/SuppInvGLAnalysis.php 2010-08-14 09:55:38 UTC (rev 3690) @@ -1,90 +0,0 @@ -<?php -/* $Id$*/ -/*The supplier transaction uses the SuppTrans class to hold the information about the invoice -the SuppTrans class contains an array of GRNs objects - containing details of GRNs for invoicing and also -an array of GLCodes objects - only used if the AP - GL link is effective */ -$PageSecurity=5; -include('includes/DefineSuppTransClass.php'); -/* Session started in header.inc for password checking and authorisation level check */ -include('includes/session.inc'); - -$title = _('Supplier Invoice General Ledger Analysis'); - -include('includes/header.inc'); - - -if (!isset($_SESSION['SuppInv'])){ - prnMsg( _('To enter a supplier invoice the supplier must first be selected from the supplier selection screen') . ', ' . _('then the link to enter a supplier invoice must be clicked on'),'info'); - echo '<br><a href="' . $rootpath . '/SelectSupplier.php?' . SID . '">' . _('Select A Supplier to Enter an Invoice For') . '</a>'; - include('includes/footer.inc'); - exit; - /*It all stops here if there aint no supplier selected and invoice initiated ie $_SESSION['SuppInv'] started off*/ -} - -/*If the user hit the Add to Invoice button then process this first before showing all GL codes on the invoice otherwise it wouldnt show the latest addition*/ - -if (isset($_POST['AddGLCodeToInvoice']) ){ - - $InputError=False; - - if ($InputError==False){ - $_SESSION['SuppInv']->Add_GLCodes_To_Trans($GLCode, - $Amount, - $ShiptRef, - $JobRef, - $Narrative); - } -} - -if (isset($_GET['Delete'])){ - - $_SESSION['SuppInv']->Remove_GLCodes_From_Trans($_GET['Delete']); - -} - - -/*Show all the selected GLCodes so far from the SESSION['SuppInv']->GLCodes array */ -echo '<div class="centre"><font size=4 color=blue>' . _('General Ledger Analysis of Invoice From') . ' ' . $_SESSION['SuppInv']->SupplierName.'</div>'; -echo '<table cellpadding=2><tr><th>' . _('Account') . '</th> - <th>' . _('Name') . '</th> - <th>' . _('Amount') . '<br>' . _('in') . ' ' . $_SESSION['SuppInv']->CurrCode . '</th> - <th>' . _('Shipment') . '</th> - <th>' . _('Job') . '</th> - <th>' . _('Narrative') . '</th></tr>'; - -$TotalGLValue=0; - -foreach ($_SESSION['SuppInv']->GLCodes as $EnteredGLCode){ - - echo '<tr><td>' . $EnteredGLCode->GLCode . '</td> - <td>' . $EnteredGLCode->GLActName . '</td> - <td class=number>' . number_format($EnteredGLCode->Amount,2) . '</td> - <td>' . $EnteredGLCode->ShiptRef . '</td> - <td>' .$EnteredGLCode->JobRef . '</td> - <td>' . $EnteredGLCode->Narrative . '</td> - <td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&Delete=' . $EnteredGLCode->Counter . '">' . _('Delete') . '</a></td></tr>'; - - $TotalGLValue = $TotalGLValue + ($EnteredGLCode->ChgPrice * $EnteredGLCode->This_QuantityInv); - - $i++; - if ($i>15){ - $i=0; - echo '<tr><td bgcolor=#800000><font color=#ffffff><b>' . _('Account') . '</b></td> - <td bgcolor=#800000><font color=#ffffff><b>' . _('Name') . '</b></td> - <td bgcolor=#800000><font color=#ffffff><b>' . _('Amount') . '<br>' . _('in') . ' ' . $_SESSION['SuppInv']->CurrCode . '</b></td> - <td bgcolor=#800000><font color=#ffffff><b>' . _('Shipment') . '</b></td> - <td bgcolor=#800000><font color=#ffffff><b>' . _('Job') . '</b></td> - <td bgcolor=#800000><font color=#ffffff><b>' . _('Narrative') . '</b></td></tr>'; - } -} - -echo '<tr><td colspan=2 class=number><font size=4 color=BLUE>' . _('Total') . ':</font></td> - <td class=number><font size=4 color=BLUE><U>' . number_format($TotalGLValue,2) . '</U></font></td></tr>'; -echo '</table><br><a href="' . $rootpath . '/SupplierInvoice.php?' . SID . '">' . _('Back to Invoice Entry') . '</a><hr>'; - -/*Set up a form to allow input of new GL entries */ -echo '<form action="' . $_SERVER['PHP_SELF'] . '?' . SID . '" method=post>'; - -echo '</form>'; -include('includes/footer.inc'); -?> Modified: trunk/SuppShiptChgs.php =================================================================== --- trunk/SuppShiptChgs.php 2010-08-10 08:27:14 UTC (rev 3689) +++ trunk/SuppShiptChgs.php 2010-08-14 09:55:38 UTC (rev 3690) @@ -58,16 +58,15 @@ /*Show all the selected ShiptRefs so far from the SESSION['SuppInv']->Shipts array */ if ($_SESSION['SuppTrans']->InvoiceOrCredit=='Invoice'){ - echo '<div class="centre"><font size=4 color=BLUE>' . _('Shipment charges on Invoice') . ' '; + echo '<div class="centre"><p class="page_title_text">'. _('Shipment charges on Invoice') . ' '; } else { - echo '<div class="centre"><font size=4 color=BLUE>' . _('Shipment credits on Credit Note') . ' '; + echo '<div class="centre"><p class="page_title_text">' . _('Shipment credits on Credit Note') . ' '; } -echo '</div>'; echo $_SESSION['SuppTrans']->SuppReference . ' ' ._('From') . ' ' . $_SESSION['SuppTrans']->SupplierName; - -echo "<table cellpadding=2>"; -$TableHeader = "<tr><th>" . _('Shipment') . "</th> - <th>" . _('Amount') . '</th></tr>'; +echo '</div>'; +echo '<table cellpadding=2>'; +$TableHeader = '<tr><th>' . _('Shipment') . '</th> + <th>' . _('Amount') . '</th></tr>'; echo $TableHeader; $TotalShiptValue = 0; @@ -75,8 +74,8 @@ foreach ($_SESSION['SuppTrans']->Shipts as $EnteredShiptRef){ echo '<tr><td>' . $EnteredShiptRef->ShiptRef . '</td> - <td class=number>' . number_format($EnteredShiptRef->Amount,2) . "</td> - <td><a href='" . $_SERVER['PHP_SELF'] . "?" . SID . "&Delete=" . $EnteredShiptRef->Counter . "'>" . _('Delete') . '</a></td></tr>'; + <td class=number>' . number_format($EnteredShiptRef->Amount,2) . '</td> + <td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&Delete=' . $EnteredShiptRef->Counter . '">' . _('Delete') . '</a></td></tr>'; $TotalShiptValue = $TotalShiptValue + $EnteredShiptRef->Amount; @@ -89,29 +88,29 @@ </table>'; if ($_SESSION['SuppTrans']->InvoiceOrCredit == 'Invoice'){ - echo "<br><a href='$rootpath/SupplierInvoice.php?" . SID . "'>" . _('Back to Invoice Entry') . '</a><hr>'; + echo '<br><a href="' . $rootpath . '/SupplierInvoice.php?' . SID . '">' . _('Back to Invoice Entry') . '</a><hr>'; } else { - echo "<br><a href='$rootpath/SupplierCredit.php?" . SID . "'>" . _('Back to Credit Note Entry') . '</a><hr>'; + echo '<br><a href="' . $rootpath . '/SupplierCredit.php?' . SID . '">' . _('Back to Credit Note Entry') . '</a><hr>'; } /*Set up a form to allow input of new Shipment charges */ -echo "<form action='" . $_SERVER['PHP_SELF'] . "?" . SID . "' method=post>"; +echo '<form action="' . $_SERVER['PHP_SELF'] . '?' . SID . '" method="post">'; if (!isset($_POST['ShiptRef'])) { $_POST['ShiptRef']=''; } echo '<table>'; -echo '<tr><td>' . _('Shipment Reference') . ":</td> - <td><input type='Text' name='ShiptRef' size=12 maxlength=11 VALUE=" . $_POST['ShiptRef'] . '></td></tr>'; -echo '<tr><td>' . _('Shipment Selection') . ':<br><font size=1>' . _('If you know the code enter it above') . '<br>' . _('otherwise select the shipment from the list') . "</font></td><td><select name='ShiptSelection'>"; +echo '<tr><td>' . _('Shipment Reference') . ':</td> + <td><input type="text" name="ShiptRef" size="12" maxlength="11" VALUE="' . $_POST['ShiptRef'] . '"></td></tr>'; +echo '<tr><td>' . _('Shipment Selection') . ':<br> ' . _('If you know the code enter it above') . '<br>' . _('otherwise select the shipment from the list') . '</td><td><select name="ShiptSelection">'; -$sql = "SELECT shiptref, - vessel, - eta, - suppname - FROM shipments INNER JOIN suppliers - ON shipments.supplierid=suppliers.supplierid - WHERE closed=0"; +$sql = 'SELECT shiptref, + vessel, + eta, + suppname + FROM shipments INNER JOIN suppliers + ON shipments.supplierid=suppliers.supplierid + WHERE closed=0'; $result = DB_query($sql, $db); @@ -121,7 +120,7 @@ } else { echo '<option VALUE='; } - echo $myrow['shiptref'] . '>' . $myrow['shiptref'] . ' - ' . $myrow['vessel'] . ' ' . _('ETA') . ' ' . ConvertSQLDate($myrow['eta']) . ' ' . _('from') . ' ' . $myrow['suppname']; + echo $myrow['shiptref'] . '>' . $myrow['shiptref'] . ' - ' . $myrow['vessel'] . ' ' . _('ETA') . ' ' . ConvertSQLDate($myrow['eta']) . ' ' . _('from') . ' ' . $myrow['suppname'] . '</option>'; } echo '</select></td></tr>'; @@ -129,12 +128,12 @@ if (!isset($_POST['Amount'])) { $_POST['Amount']=0; } -echo '<tr><td>' . _('Amount') . ":</td> - <td><input type='Text' name='Amount' size=12 maxlength=11 VALUE=" . $_POST['Amount'] . '></td></tr>'; +echo '<tr><td>' . _('Amount') . ':</td> + <td><input type="text" name="Amount" size="12" maxlength="11" VALUE="' . $_POST['Amount'] . '"></td></tr>'; echo '</table>'; -echo "<input type='Submit' name='AddShiptChgToInvoice' VALUE='" . _('Enter Shipment Charge') . "'>"; +echo '<input type="submit" name="AddShiptChgToInvoice" VALUE="' . _('Enter Shipment Charge') . '">'; echo '</form>'; include('includes/footer.inc'); -?> +?> \ No newline at end of file Modified: trunk/SuppTransGLAnalysis.php =================================================================== --- trunk/SuppTransGLAnalysis.php 2010-08-10 08:27:14 UTC (rev 3689) +++ trunk/SuppTransGLAnalysis.php 2010-08-14 09:55:38 UTC (rev 3690) @@ -86,13 +86,12 @@ } echo '</p><table cellpadding=2>'; -$TableHeader = "<tr> - <th>" . _('Account') . "</th> - <th>" . _('Name') . "</th> - <th>" . _('Amount') . '<br>' . _('in') . ' ' . $_SESSION['SuppTrans']->CurrCode . "</th> - <th>" . _('Job') . "</th> - <th>" . _('Narrative') . '</th> - </tr>'; +$TableHeader = '<tr> + <th>' . _('Account') . '</th> + <th>' . _('Name') . '</th> + <th>' . _('Amount') . '<br>' . _('in') . ' ' . $_SESSION['SuppTrans']->CurrCode . '</th> + <th>' . _('Narrative') . '</th> + </tr>'; echo $TableHeader; $TotalGLValue=0; @@ -102,12 +101,11 @@ <td>' . $EnteredGLCode->GLCode . '</td> <td>' . $EnteredGLCode->GLActName . '</td> <td class=number>' . number_format($EnteredGLCode->Amount,2) . '</td> - <td>' .$EnteredGLCode->JobRef . '</td> <td>' . $EnteredGLCode->Narrative . "</td> <td><a href='" . $_SERVER['PHP_SELF'] . "?" . SID . "Delete=" . $EnteredGLCode->Counter . "'>" . _('Delete') . '</a></td> </tr>'; - $TotalGLValue = $TotalGLValue + $EnteredGLCode->Amount; + $TotalGLValue += $EnteredGLCode->Amount; $i++; if ($i>15){ @@ -124,27 +122,27 @@ if ($_SESSION['SuppTrans']->InvoiceOrCredit == 'Invoice'){ - echo "<br><a href='$rootpath/SupplierInvoice.php?" . SID . "'>" . _('Back to Invoice Entry') . '</a><hr>'; + echo '<br><a href="' . $rootpath . '/SupplierInvoice.php?' . SID . '">' . _('Back to Invoice Entry') . '</a><hr>'; } else { - echo "<br><a href='$rootpath/SupplierCredit.php?" . SID . "'>" . _('Back to Credit Note Entry') . '</a><hr>'; + echo '<br><a href="' . $rootpath . '/SupplierCredit.php?' . SID . '">' . _('Back to Credit Note Entry') . '</a><hr>'; } /*Set up a form to allow input of new GL entries */ -echo "<form action='" . $_SERVER['PHP_SELF'] . "?" . SID . "' method=post>"; +echo '<form action="' . $_SERVER['PHP_SELF'] . '?' . SID . '" method="post">'; echo '<table>'; if (!isset($_POST['GLCode'])) { $_POST['GLCode']=''; } echo '<tr> - <td>' . _('Account Code') . ":</td> - <td><input type='Text' name='GLCode' size=12 maxlength=11 VALUE=" . $_POST['GLCode'] . '></td> + <td>' . _('Account Code') . ':</td> + <td><input type="text" name="GLCode" size=12 maxlength=11 VALUE="' . $_POST['GLCode'] . '"></td> </tr>'; echo '<tr> - <td>' . _('Account Selection') . ':<br><font size=1>' . _('If you know the code enter it above') . '<br>' . _('otherwise select the account from the list') . "</font></td> - <td><select name='AcctSelection'>"; + <td>' . _('Account Selection') . ':<br>(' . _('If you know the code enter it above') . '<br>' . _('otherwise select the account from the list') . ')</td> + <td><select name="AcctSelection">'; -$sql = "SELECT accountcode, accountname FROM chartmaster ORDER BY accountcode"; +$sql = 'SELECT accountcode, accountname FROM chartmaster ORDER BY accountcode'; $result = DB_query($sql, $db); @@ -165,32 +163,21 @@ $_POST['Amount']=0; } echo '<tr> - <td>' . _('Amount') . ":</td> - <td><input type='Text' class='number' name='Amount' size=12 maxlength=11 VALUE=" . $_POST['Amount'] . '></td> + <td>' . _('Amount') . ':</td> + <td><input type="text" class="number" name="Amount" size="12" maxlength="11" VALUE="' . $_POST['Amount'] . '"></td> </tr>'; - if (!isset($_POST['JobRef'])) { - $_POST['JobRef']=''; - } -echo '<tr> - <td>' . _('Contract Ref') . ":</td> - <td><input type='Text' name='JobRef' size=21 maxlength=20 VALUE=" . $_POST['JobRef'] . ">"; - /* Once the contract stuff is written then it would be appropriate to have: - <a TARGET='_blank' href='$rootpath/ContractsList.php?" . SID . "'>" . _('View Open Contracts/Jobs') . '</a> */ - -echo ' </td> - </tr>'; - if (!isset($_POST['Narrative'])) { - $_POST['Narrative']=''; - } +if (!isset($_POST['Narrative'])) { + $_POST['Narrative']=''; +} echo '<tr> - <td>' . _('Narrative') . ":</td> - <td><TEXTAREA name='Narrative' COLS=40 ROWS=2>" . $_POST['Narrative'] . '</TEXTAREa></td> + <td>' . _('Narrative') . ':</td> + <td><TEXTAREA name="Narrative" cols=40 rows=2>' . $_POST['Narrative'] . '</textarea></td> </tr> </table>'; -echo "<input type='Submit' name='AddGLCodeToTrans' VALUE='" . _('Enter GL Line') . "'>"; +echo '<input type="submit" name="AddGLCodeToTrans" VALUE="' . _('Enter GL Line') . '">'; echo '</form>'; include('includes/footer.inc'); -?> +?> \ No newline at end of file Modified: trunk/SupplierCredit.php =================================================================== --- trunk/SupplierCredit.php 2010-08-10 08:27:14 UTC (rev 3689) +++ trunk/SupplierCredit.php 2010-08-14 09:55:38 UTC (rev 3690) @@ -68,23 +68,23 @@ /*Now retrieve supplier information - name, currency, default ex rate, terms, tax rate etc */ $sql = "SELECT suppliers.suppname, - suppliers.supplierid, - paymentterms.terms, - paymentterms.daysbeforedue, - paymentterms.dayinfollowingmonth, - suppliers.currcode, - currencies.rate AS exrate, - suppliers.taxgroupid, - taxgroups.taxgroupdescription - FROM suppliers, - taxgroups, - currencies, - paymentterms, - taxauthorities - WHERE suppliers.taxgroupid=taxgroups.taxgroupid - AND suppliers.currcode=currencies.currabrev - AND suppliers.paymentterms=paymentterms.termsindicator - AND suppliers.supplierid = '" . $_GET['SupplierID'] . "'"; + suppliers.supplierid, + paymentterms.terms, + paymentterms.daysbeforedue, + paymentterms.dayinfollowingmonth, + suppliers.currcode, + currencies.rate AS exrate, + suppliers.taxgroupid, + taxgroups.taxgroupdescription + FROM suppliers, + taxgroups, + currencies, + paymentterms, + taxauthorities + WHERE suppliers.taxgroupid=taxgroups.taxgroupid + AND suppliers.currcode=currencies.currabrev + AND suppliers.paymentterms=paymentterms.termsindicator + AND suppliers.supplierid = '" . $_GET['SupplierID'] . "'"; $ErrMsg = _('The supplier record selected') . ': ' . $_GET['SupplierID'] . ' ' ._('cannot be retrieved because'); $DbgMsg = _('The SQL used to retrieve the supplier details and failed was'); @@ -110,8 +110,8 @@ $_SESSION['SuppTrans']->SupplierID = $_GET['SupplierID']; $LocalTaxProvinceResult = DB_query("SELECT taxprovinceid - FROM locations - WHERE loccode = '" . $_SESSION['UserStockLocation'] . "'", $db); + FROM locations + WHERE loccode = '" . $_SESSION['UserStockLocation'] . "'", $db); if(DB_num_rows($LocalTaxProvinceResult)==0){ prnMsg(_('The tax province associated with your user account has not been set up in this database. Tax calculations are based on the tax group of the supplier and the tax province of the user entering the invoice. The system administrator should redefine your account with a valid default stocking location and this location should refer to a valid tax province'),'error'); @@ -134,7 +134,7 @@ } elseif (!isset($_SESSION['SuppTrans'])){ prnMsg(_('To enter a supplier credit note the supplier must first be selected from the supplier selection screen'),'warn'); - echo "<br><a href='$rootpath/SelectSupplier.php?" . SID ."'>" . _('Select A Supplier to Enter an Credit Note For') . '</a>'; + echo '<br><a href="' . $rootpath . '/SelectSupplier.php?' . SID .'">' . _('Select A Supplier to Enter an Credit Note For') . '</a>'; include('includes/footer.inc'); exit; @@ -173,12 +173,17 @@ } if (count($_SESSION['SuppTrans']->GLCodes) > 0){ foreach ( $_SESSION['SuppTrans']->GLCodes as $GLLine){ - $_SESSION['SuppTrans']->OvAmount = $_SESSION['SuppTrans']->OvAmount + $GLLine->Amount; + $_SESSION['SuppTrans']->OvAmount += $GLLine->Amount; } } + if (count($_SESSION['SuppTrans']->Contracts) > 0){ + foreach ( $_SESSION['SuppTrans']->Contracts as $Contract){ + $_SESSION['SuppTrans']->OvAmount += $Contract->Amount; + } + } if (count($_SESSION['SuppTrans']->Shipts) > 0){ foreach ( $_SESSION['SuppTrans']->Shipts as $ShiptLine){ - $_SESSION['SuppTrans']->OvAmount = $_SESSION['SuppTrans']->OvAmount + $ShiptLine->Amount; + $_SESSION['SuppTrans']->OvAmount += $ShiptLine->Amount; } } /*OvAmount must be entered manually */ @@ -194,10 +199,10 @@ /*This ensures that any changes in the page are stored in the session before calling the grn page */ - echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . "/SuppCreditGRNs.php?" . SID . "'>"; + echo '<meta http-equiv="Refresh" content="0; url=' . $rootpath . '/SuppCreditGRNs.php?' . SID . '">'; echo '<p>' . _('You should automatically be forwarded to the entry of credit notes against goods received page') . '. ' . _('If this does not happen') . ' (' . _('if the browser does not support META Refresh') . ') ' . - "<a href='" . $rootpath . "/SuppCreditGRNs.php?" . SID . "'>" . + '<a href="' . $rootpath . '/SuppCreditGRNs.php?' . SID . '">' . _('click here') . '</a> ' . _('to continue') . '.<br>'; include('includes/footer.inc'); exit; @@ -206,10 +211,10 @@ /*This ensures that any changes in the page are stored in the session before calling the shipments page */ - echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . "/SuppShiptChgs.php?" . SID . "'>"; + echo '<meta http-equiv="Refresh" content="0; url=' . $rootpath . '/SuppShiptChgs.php?' . SID . '">'; echo '<p>' . _('You should automatically be forwarded to the entry of credit notes against shipments page') . '. ' . _('If this does not happen') . ' (' . _('if the browser does not support META Refresh') . ') ' . - "<a href='" . $rootpath . "/SuppShiptChgs.php?" . SID . "'>" . + '<a href="' . $rootpath . '/SuppShiptChgs.php?' . SID . '">' . _('click here') . '</a> ' . _('to continue') . '.<br>'; include('includes/footer.inc'); exit; @@ -218,14 +223,22 @@ /*This ensures that any changes in the page are stored in the session before calling the shipments page */ - echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . "/SuppTransGLAnalysis.php?" . SID . "'>"; + echo '<meta http-equiv="Refresh" content="0; url=' . $rootpath . '/SuppTransGLAnalysis.php?' . SID . '">'; echo '<p>' . _('You should automatically be forwarded to the entry of credit notes against the general ledger page') . '. ' . _('If this does not happen') . ' (' . _('if the browser does not support META Refresh') . ') ' . - "<a href='" . $rootpath . "/SuppTransGLAnalysis.php?" . SID . "'>" . + '<a href="' . $rootpath . '/SuppTransGLAnalysis.php?' . SID . '">' . _('click here') . '</a> ' . _('to continue') . '.<br>'; include('includes/footer.inc'); exit; } +if (isset($_POST['Contracts']) and $_POST['Contracts'] == _('Enter Against Contracts')){ + /*This ensures that any changes in the page are stored in the session before calling the shipments page */ + echo '<meta http-equiv="refresh" content="0; url=' . $rootpath . '/SuppContractChgs.php?' . SID . '">'; + echo '<DIV class="centre">' . _('You should automatically be forwarded to the entry of invoices against contracts page') . + '. ' . _('If this does not happen') . ' (' . _('if the browser does not support META Refresh'). ') ' . + '<a href="' . $rootpath . '/SuppContractChgs.php?' . SID . '">' . _('click here') . '</a> ' . _('to continue') . '.</DIV><br>'; + exit; + } /* everything below here only do if a Supplier is selected fisrt add a header to show who we are making an credit note for */ @@ -257,14 +270,17 @@ <td><input type=TEXT class='number' size=11 maxlength=10 name='ExRate' VALUE=" . $_SESSION['SuppTrans']->ExRate . '></td></tr>'; echo '</table>'; -echo "<br><div class='centre'><input type=submit name='GRNS' VALUE='" . _('Enter Credit Against Goods Recd') . "'> "; -echo "<input type=submit name='Shipts' VALUE='" . _('Enter Credit Against Shipment') . "'> "; +echo '<br><div class="centre"><input type="submit" name="GRNS" VALUE="' . _('Enter Credit Against Goods Recd') . '"> '; +echo '<input type="submit" name="Shipts" value="' . _('Enter Credit Against Shipment') . '"> '; +echo '<input type="submit" name="Contracts" VALUE="' . _('Enter Against Contracts') . '"> '; if ( $_SESSION['SuppTrans']->GLLink_Creditors ==1){ - echo "<input type=submit name='GL' VALUE='" . _('Enter General Ledger Analysis') . "'></div>"; + echo '<input type="submit" name="GL" value="' . _('Enter General Ledger Analysis') . '"></div>'; } else { echo '</div>'; } + + if (count($_SESSION['SuppTrans']->GRNs)>0){ /*if there are some GRNs selected for crediting then */ /*Show all the selected GRNs so far from the SESSION['SuppInv']->GRNs array @@ -312,10 +328,12 @@ foreach ($_SESSION['SuppTrans']->Shipts as $EnteredShiptRef){ - echo '<tr><td>' . $EnteredShiptRef->ShiptRef . '</td><td class=number>' . - number_format($EnteredShiptRef->Amount,2) . '</td></tr>'; + echo '<tr> + <td>' . $EnteredShiptRef->ShiptRef . '</td> + <td class=number>' . number_format($EnteredShiptRef->Amount,2) . '</td> + </tr>'; - $TotalShiptValue = $TotalShiptValue + $EnteredShiptRef->Amount; + $TotalShiptValue += $EnteredShiptRef->Amount; } @@ -323,16 +341,47 @@ <td class=number><font size=4 color=red><U>' . number_format($TotalShiptValue,2) . '</U></font></td></tr>'; } +if (count( $_SESSION['SuppTrans']->Contracts) > 0){ /*if there are any contract charges on the invoice*/ + + echo '<table cellpadding="2">'; + $TableHeader = '<tr><th>' . _('Contract') . '</th> + <th>' . _('Amount') . '</th> + <th>' . _('Narrative') . '</th></tr>'; + echo $TableHeader; + + $TotalContractsValue = 0; + $i=0; + foreach ($_SESSION['SuppTrans']->Contracts as $Contract){ + + echo '<tr><td>' . $Contract->ContractRef . '</td> + <td class=number>' . number_format($Contract->Amount,2) . '</td> + <td>' . $Contract->Narrative . '</td> + </tr>'; + + $TotalContractsValue += $Contract->Amount; + + $i++; + if ($i == 15){ + $i = 0; + echo $TableHeader; + } + } + + echo '<tr><td class="number">' . _('Total') . ':</font></td> + <td class="number">' . number_format($TotalContractsValue,2) . '</td> + </tr></table>'; +} + + if ($_SESSION['SuppTrans']->GLLink_Creditors ==1){ if (count($_SESSION['SuppTrans']->GLCodes)>0){ echo '<table cellpadding=2>'; - $TableHeader = "<tr><th>" . _('Account') . "</th> - <th>" . _('Name') . "</th> - <th>" . _('Amount') . '<br>' . _('in') . ' ' . $_SESSION['SuppTrans']->CurrCode . "</th> - <th>" . _('Shipment') . "</th> - <th>" . _('Job') . "</th> - <th>" . _('Narrative') . '</th></tr>'; + $TableHeader = '<tr><th>' . _('Account') . '</th> + <th>' . _('Name') . '</th> + <th>' . _('Amount') . '<br>' . _('in') . ' ' . $_SESSION['SuppTrans']->CurrCode . '</th> + <th>' . _('Shipment') . '</th> + <th>' . _('Narrative') . '</th></tr>'; echo $TableHeader; $TotalGLValue=0; @@ -343,7 +392,6 @@ <td>' . $EnteredGLCode->GLActName . '</td> <td class=number>' . number_format($EnteredGLCode->Amount,2) . '</td> <td>' . $EnteredGLCode->ShiptRef . '</td> - <td>' . $EnteredGLCode->JobRef . '</td> <td>' . $EnteredGLCode->Narrative . '</td></tr>'; $TotalGLValue = $TotalGLValue + $EnteredGLCode->Amount; @@ -369,14 +417,18 @@ if (!isset($TotalShiptValue)) { $TotalShiptValue=0; } - - $_SESSION['SuppTrans']->OvAmount = round($TotalGRNValue + $TotalGLValue + $TotalShiptValue,2); + if (!isset($TotalContractsValue)){ + $TotalContractsValue = 0; + } + + $_SESSION['SuppTrans']->OvAmount = round($TotalGRNValue + $TotalGLValue + $TotalShiptValue + $TotalContractsValue,2); + echo '<table><tr><td><font color=red>' . _('Credit Amount in Supplier Currency') . ':</font></td> <td colspan=2 class=number>' . number_format($_SESSION['SuppTrans']->OvAmount,2) . '</td></tr>'; } else { - echo '<table><tr><td><font color=red>' . _("Credit Amount in Supplier Currency") . + echo '<table><tr><td><font color=red>' . _('Credit Amount in Supplier Currency') . ':</font></td> - <td colspan=2 class=number><input type=TEXT size=12 maxlength=10 name=OvAmount VALUE=' . number_format($_SESSION['SuppTrans']->OvAmount,2) . '></td></tr>'; + <td colspan=2 class=number><input type=TEXT size="12" maxlength="10" name="OvAmount" VALUE=' . number_format($_SESSION['SuppTrans']->OvAmount,2) . '></td></tr>'; } echo "<tr><td colspan=2><input type=Submit name='ToggleTaxMethod'VALUE='" . _('Change Tax Calculation Method') . @@ -456,7 +508,6 @@ foreach ($_SESSION['SuppTrans']->Taxes as $Tax) { - /*Set the tax rate to what was entered */ if (isset($_POST['TaxRate' . $Tax->TaxCalculationOrder])){ $_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxRate = $_POST['TaxRate' . $Tax->TaxCalculationOrder]/100; @@ -517,13 +568,8 @@ /*Start an SQL transaction */ - $SQL = 'BEGIN'; + DB_Txn_Begin($db); - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The database does not support transactions'); - $DbgMsg = _('The following SQL to start an SQL transaction was used'); - - $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg); - /*Get the next transaction number for internal purposes and the period to post GL transactions in based on the credit note date*/ $CreditNoteNo = GetNextTransNo(21, $db); @@ -619,7 +665,44 @@ $LocalTotal += round($ShiptChg->Amount/$_SESSION['SuppTrans']->ExRate,2); } + + foreach ($_SESSION['SuppTrans']->Contracts as $Contract){ + /*contract postings need to get the WIP from the contract item's stock category record + * debit postings to this WIP account + * the WIP account is tidied up when the contract is closed*/ + $result = DB_query("SELECT wipact FROM stockcategory + INNER JOIN stockmaster ON + stockcategory.categoryid=stockmaster.categoryid + WHERE stockmaster.stockid='" . $Contract->ContractRef . "'",$db); + $WIPRow = DB_fetch_row($result); + $WIPAccount = $WIPRow[0]; + + $SQL = 'INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (21, ' . + $CreditNoteNo . ", + '" . SQLCreditNoteDate. "', + '" . $PeriodNo . "', + '". $WIPAccount . "', + '" . $_SESSION['SuppTrans']->SupplierID . ' ' . _('Contract charge against') . ' ' . $Contract->ContractRef . "', + '" . (-$Contract->Amount/ $_SESSION['SuppTrans']->ExRate) . "')"; + + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The general ledger transaction for the contract') . ' ' . $Contract->ContractRef . ' ' . _('could not be added because'); + + $DbgMsg = _('The following SQL to insert the GL transaction was used'); + + $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, True); + + $LocalTotal += ($Contract->Amount/ $_SESSION['SuppTrans']->ExRate); + + } + foreach ($_SESSION['SuppTrans']->GRNs as $EnteredGRN){ if (strlen($EnteredGRN->ShiptRef)==0 OR $EnteredGRN->ShiptRef=="" OR $EnteredGRN->ShiptRef==0){ /*so its not a shipment item */ @@ -852,31 +935,31 @@ foreach ($_SESSION['SuppTrans']->Taxes as $Tax){ /* Now the TAX account */ + if ($Tax->TaxOvAmount/ $_SESSION['SuppTrans']->ExRate !=0){ + $SQL = 'INSERT INTO gltrans (type, + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (21, ' . + $CreditNoteNo . ", + '" . $SQLCreditNoteDate . "', + " . $PeriodNo . ', + ' . $Tax->TaxGLCode . ", + '" . $_SESSION['SuppTrans']->SupplierID . ' - ' . _('Credit note') . ' ' . + $_SESSION['SuppTrans']->SuppReference . ' ' . $_SESSION['SuppTrans']->CurrCode . + $Tax->TaxOvAmount . ' @ ' . _('a rate of') . ' ' . $_SESSION['SuppTrans']->ExRate . + "', + " . round(-$Tax->TaxOvAmount/ $_SESSION['SuppTrans']->ExRate,2) . ')'; - $SQL = 'INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES (21, ' . - $CreditNoteNo . ", - '" . $SQLCreditNoteDate . "', - " . $PeriodNo . ', - ' . $Tax->TaxGLCode . ", - '" . $_SESSION['SuppTrans']->SupplierID . ' - ' . _('Credit note') . ' ' . - $_SESSION['SuppTrans']->SuppReference . ' ' . $_SESSION['SuppTrans']->CurrCode . - $Tax->TaxOvAmount . ' @ ' . _('a rate of') . ' ' . $_SESSION['SuppTrans']->ExRate . - "', - " . round(-$Tax->TaxOvAmount/ $_SESSION['SuppTrans']->ExRate,2) . ')'; + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The general ledger transaction for the tax could not be added because'); - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The general ledger transaction for the tax could not be added because'); - - $DbgMsg = _('The following SQL to insert the GL transaction was used'); - - $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, True); - + $DbgMsg = _('The following SQL to insert the GL transaction was used'); + + $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, True); + }/* if the tax is not 0 */ } /*end of loop to post the tax */ /* Now the control account */ @@ -1011,12 +1094,35 @@ $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, True); } - $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The COMMIT SQL command failed'); - $DbgMsg = _('The COMMIT SQL failed'); + /*Add contract charges records as necessary */ - $SQL='COMMIT'; - $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg); + foreach ($_SESSION['SuppTrans']->Contracts as $Contract){ + + if($Contract->AnticipatedCost ==true){ + $Anticipated =1; + } else { + $Anticipated =0; + } + $SQL = "INSERT INTO contractcharges (contractref, + transtype, + transno, + amount, + narrative, + anticipated) + VALUES ('" . $Contract->ContractRef . "', + '21', + '" . $CreditNoteNo . "', + '" . -$Contract->Amount/ $_SESSION['SuppTrans']->ExRate . "', + '" . $Contract->Narrative . "', + '" . $Anticipated . "')"; + $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The contract charge record for contract') . ' ' . $Contract->ContractRef . ' ' . _('could not be added because'); + $DbgMsg = _('The following SQL to insert the contract charge record was used'); + $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, True); + } + + DB_Txn_Commit($db); + prnMsg(_('Supplier credit note number') . ' ' . $CreditNoteNo . ' ' . _('has been processed'),'success'); echo '<br><div class="centre"><a href="' . $rootpath . '/SupplierCredit.php?&SupplierID=' .$_SESSION['SuppTrans']->SupplierID . '">' . _('Enter another Credit Note for this Supplier') . '</a></div>'; unset($_SESSION['SuppTrans']->GRNs); Modified: trunk/SupplierInvoice.php =================================================================== --- trunk/SupplierInvoice.php 2010-08-10 08:27:14 UTC (rev 3689) +++ trunk/SupplierInvoice.php 2010-08-14 09:55:38 UTC (rev 3690) @@ -52,23 +52,23 @@ /*Now retrieve supplier information - name, currency, default ex rate, terms, tax rate etc */ $sql = "SELECT suppliers.suppname, - suppliers.supplierid, - paymentterms.terms, - paymentterms.daysbeforedue, - paymentterms.dayinfollowingmonth, - suppliers.currcode, - currencies.rate AS exrate, - suppliers.taxgroupid, - taxgroups.taxgroupdescription - FROM suppliers, - taxgroups, - currencies, - paymentterms, - taxauthorities - WHERE suppliers.taxgroupid=taxgroups.taxgroupid - AND suppliers.currcode=currencies.currabrev - AND suppliers.paymentterms=paymentterms.termsindicator - AND suppliers.supplierid = '" . $_GET['SupplierID'] . "'"; + suppliers.supplierid, + paymentterms.terms, + paymentterms.daysbeforedue, + paymentterms.dayinfollowingmonth, + suppliers.currcode, + currencies.rate AS exrate, + suppliers.taxgroupid, + taxgroups.taxgroupdescription + FROM suppliers, + taxgroups, + currencies, + paymentterms, + taxauthorities + WHERE suppliers.taxgroupid=taxgroups.taxgroupid + AND suppliers.currcode=currencies.currabrev + AND suppliers.paymentterms=paymentterms.termsindicator + AND suppliers.supplierid = '" . $_GET['SupplierID'] . "'"; $ErrMsg = _('The supplier record selected') . ': ' . $_GET['SupplierID'] . ' ' ._('cannot be retrieved because'); $DbgMsg = _('The SQL used to retrieve the supplier details and failed was'); @@ -147,19 +147,24 @@ $_SESSION['SuppTrans']->OvAmount = 0; /* for starters */ if (count($_SESSION['SuppTrans']->GRNs) > 0){ foreach ( $_SESSION['SuppTrans']->GRNs as $GRN){ - $_SESSION['SuppTrans']->OvAmount = $_SESSION['SuppTrans']->OvAmount + ($GRN->This_QuantityInv * $GRN->ChgPrice); + $_SESSION['SuppTrans']->OvAmount += ($GRN->This_QuantityInv * $GRN->ChgPrice); } } if (count($_SESSION['SuppTrans']->GLCodes) > 0){ foreach ( $_SESSION['SuppTrans']->GLCodes as $GLLine){ - $_SESSION['SuppTrans']->OvAmount = $_SESSION['SuppTrans']->OvAmount + $GLLine->Amount; + $_SESSION['SuppTrans']->OvAmount += $GLLine->Amount; } } if (count($_SESSION['SuppTrans']->Shipts) > 0){ foreach ( $_SESSION['SuppTrans']->Shipts as $ShiptLine){ - $_SESSION['SuppTrans']->OvAmount = $_SESSION['SuppTrans']->OvAmount + $ShiptLine->Amount; + $_SESSION['SuppTrans']->OvAmount += $ShiptLine->Amount; } } + if (count($_SESSION['SuppTrans']->Contracts) > 0){ + foreach ( $_SESSION['SuppTrans']->Contracts as $Contract){ + $_SESSION['SuppTrans']->OvAmount += $Contract->Amount; + } + } $_SESSION['SuppTrans']->OvAmount = round($_SESSION['SuppTrans']->OvAmount,2); }else { /*OvAmount must be entered manually */ @@ -178,7 +183,7 @@ "<a href='" . $rootpath . "/SuppInvGRNs.php?" . SID . "'>" . _('click here') . '</a> ' . _('to continue') . '.</DIV><br>'; exit; } - if (isset($_POST['Shipts']) and $_POST['Shipts'] == _('Enter Against Shipment')){ + if (isset($_POST['Shipts']) and $_POST['Shipts'] == _('Enter Against Shipments')){ /*This ensures that any changes in the page are stored in the session before calling the shipments page */ echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . "/SuppShiptChgs.php?" . SID . "'>"; echo '<DIV class="centre">' . _('You should automatically be forwarded to the entry of invoices against shipments page') . @@ -194,14 +199,22 @@ "<a href='" . $rootpath . "/SuppTransGLAnalysis.php?" . SID . "'>" . _('click here') . '</a> ' . _('to continue') . '.</DIV><br>'; exit; } + if (isset($_POST['Contracts']) and $_POST['Contracts'] == _('Enter Against Contracts')){ + /*This ensures that any changes in the page are stored in the session before calling the shipments page */ + echo '<meta http-equiv="refresh" content="0; url=' . $rootpath . '/SuppContractChgs.php?' . SID . '">'; + echo '<DIV class="centre">' . _('You should automatically be forwarded to the entry of invoices against contracts page') . + '. ' . _('If this does not happen') . ' (' . _('if the browser does not support META Refresh'). ') ' . + '<a href="' . $rootpath . '/SuppContractChgs.php?' . SID . '">' . _('click here') . '</a> ' . _('to continue') . '.</DIV><br>'; + exit; + } /* everything below here only do if a Supplier is selected fisrt add a header to show who we are making an invoice for */ - echo "<table BORDER=2 colspan=4><tr><th>" . _('Supplier') . - "</th><th>" . _('Currency') . - "</th><th>" . _('Terms'). - "</th><th>" . _('Tax Authority') . '</th></tr>'; + echo '<table border=2 colspan=4><tr><th>' . _('Supplier') . '</th> + <th>' . _('Currency') . '</th> + <th>' . _('Terms') . '</th> + <th>' . _('Tax Authority') . '</th></tr>'; echo '<tr><td><font color=blue><b>' . $_SESSION['SuppTrans']->SupplierID . ' - ' . $_SESSION['SuppTrans']->SupplierName . '</b></font></td> @@ -211,13 +224,13 @@ </tr> </table>'; - echo "<br><form action='" . $_SERVER['PHP_SELF'] . "?" . SID . "' method=post name=form1>"; + echo '<br><form action="' . $_SERVER['PHP_SELF'] . '?' . SID . '" method="post" name="form1">'; echo '<table>'; - echo '<tr><td>' . _('Supplier Invoice Reference') . ":</td> - <td><font size=2><input type=TEXT size=20 maxlength=20 name=SuppReference VALUE='" . - $_SESSION['SuppTrans']->SuppReference . "'></td>"; + echo '<tr><td>' . _('Supplier Invoice Reference') . ':</td> + <td><input type="text" size="20" maxlength="20" name="SuppReference" VALUE="' . + $_SESSION['SuppTrans']->SuppReference . '"></td>'; if (!isset($_SESSION['SuppTrans']->TranDate)){ $_SESSION['SuppTrans']->TranDate= Date($_SESSION['DefaultDateFormat'], Mktime(0,0,0,Date('m'),Date('d')-1,Date('y'))); @@ -225,16 +238,17 @@ echo '<td>' . _('Invoice Date') . ' (' . _('in format') . ' ' . $_SESSION['DefaultDateFormat'] . ') :</td> <td><input type="TEXT" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" size="11" maxlength="10" name="TranDate" VALUE="' . $_SESSION['SuppTrans']->TranDate . '"></td>'; - echo '<td>' . _('Exchange Rate') . ":</td> - <td><input type=TEXT class='number' size=11 maxlength=10 name='ExRate' VALUE=" . $_SESSION['SuppTrans']->ExRate . '></td></tr>'; + echo '<td>' . _('Exchange Rate') . ':</td> + <td><input type="text" class="number" size="11" maxlength="10" name="ExRate" VALUE="' . $_SESSION['SuppTrans']->ExRate . '"></td></tr>'; echo '</table>'; - echo "<br><div class='centre'><input type=submit name='GRNS' VALUE='" . _('Enter Against Goods Received') . "'> "; + echo '<br><div class="centre"><input type="submit" name="GRNS" value="' . _('Enter Against Goods Received') . '"> '; - echo "<input type=submit name='Shipts' VALUE='" . _('Enter Against Shipment') . "'> "; + echo '<input type="submit" name="Shipts" VALUE="' . _('Enter Against Shipments') . '"> '; + echo '<input type="submit" name="Contracts" VALUE="' . _('Enter Against Contracts') . '"> '; if ( $_SESSION['SuppTrans']->GLLink_Creditors == 1){ - echo "<input type=submit name='GL' VALUE='" . _('Enter General Ledger Analysis') . "'></div>"; + echo '<input type="submit" name="GL" VALUE="' . _('Enter General Ledger Analysis') . '"></div>'; } else { echo '</div>'; } @@ -244,12 +258,12 @@ /*Show all the selected GRNs so far from the SESSION['SuppInv']->GRNs array */ echo '<table cellpadding=2>'; - $tableheader = "<tr bgcolor=#800000><th>" . _('Seq') . " #</th> - <th>" . _('Item Code') . "</th> - <th>" . _('Description') . "</th> - <th>" . _('Quantity Charged') . "</th> - <th>" . _('Price in') . ' ' . $_SESSION['SuppTrans']->CurrCode . "</th> - <th>" . _('Line Total') . ' ' . $_SESSION['SuppTrans']->CurrCode . '</th></tr>'; + $tableheader = '<tr bgcolor=#800000><th>' . _('Seq') . ' #</th> + <th>' . _('Item Code') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Quantity Charged') . '</th> + <th>' . _('Price in') . ' ' . $_SESSION['SuppTrans']->CurrCode . '</th> + <th>' . _('Line Total') . ' ' . $_SESSION['SuppTrans']->CurrCode . '</th></tr>'; echo $tableheader; $TotalGRNValue = 0; @@ -298,36 +312,67 @@ echo '<tr><td colspan=2 class=number><font size=4 color=blue>' . _('Total') . ':</font></td> <td class=number><font size=4 color=BLUE><U>' . number_format($TotalShiptValue,2) . '</U></font></td></tr></table>'; } + + if (count( $_SESSION['SuppTrans']->Contracts) > 0){ /*if there are any contract charges on the invoice*/ + echo '<table cellpadding="2">'; + $TableHeader = '<tr><th>' . _('Contract') . '</th> + <th>' . _('Amount') . '</th> + <th>' . _('Narrative') . '</th></tr>'; + echo $TableHeader; + $TotalContractsValue = 0; + $i=0; + foreach ($_SESSION['SuppTrans']->Contracts as $Contract){ + + echo '<tr><td>' . $Contract->ContractRef . '</td> + <td class=number>' . number_format($Contract->Amount,2) . '</td> + <td>' . $Contract->Narrative . '</td> + </tr>'; + + $TotalContractsValue += $Contract->Amount; + + $i++; + if ($i == 15){ + $i = 0; + echo $TableHeader; + } + } + + echo '<tr><td class="number">' . _('Total') . ':</font></td> + <td class="number">' . number_format($TotalContractsValue,2) . '</td> + </tr></table>'; + } + + if ( $_SESSION['SuppTrans']->GLLink_Creditors == 1){ if (count($_SESSION['SuppTrans']->GLCodes) > 0){ echo '<br><table cellpadding=2>'; - $TableHeader = "<tr><th>" . _('Account') . - "</th><th>" . _('Name') . - "</th><th>" . _('Amount') . '<br>' . _('in') . ' ' . $_SESSION['SuppTrans']->CurrCode . "</th> - <th>" . _('Shipment') ."</th> - <th>" . _('Job') . "</th> - <th>" . _('Narrative') . '</th></tr>'; + $TableHeader = '<tr><th>' . _('Account') . '</th> + <th>' . _('Name') . '</th> + <th>' . _('Amount') . '<br>' . _('in') . ' ' . $_SESSION['SuppTrans']->CurrCode . '</th> + <th>' . _('Shipment') . '</th> + <th>' . _('Narrative') . '</th></tr>'; echo $TableHeader; $TotalGLValue = 0; foreach ($_SESSION['SuppTrans']->GLCodes as $EnteredGLCode){ - echo '<tr><td>' . $EnteredGLCode->GLCode . '</td><td>' . $EnteredGLCode->GLActName . - '</td><td class=number>' . number_format($EnteredGLCode->Amount,2) . - '</td><td>' . $EnteredGLCode->ShiptRef . '</td><td>' .$EnteredGLCode->JobRef . - '</td><td>' . $EnteredGLCode->Narrative . '</td></tr>'; + echo '<tr><td>' . $EnteredGLCode->GLCode . '</td> + <td>' . $EnteredGLCode->GLActName . '</td> + <td class=number>' . number_format($EnteredGLCode->Amount,2) . '</td> + <td>' . $EnteredGLCode->ShiptRef . '</td> + <td>' . $EnteredGLCode->Narrative . '</td></tr>'; - $TotalGLValue = $TotalGLValue + $EnteredGLCode->Amount; + $TotalGLValue += $EnteredGLCode->Amount; } - echo '<tr><td colspan=2 class=number><font size=4 color=blue>' . _('Total') . ':</font></td> - <td class=number><font size=4 color=blue><U>' . number_format($TotalGLValue,2) . '</U></font></td> - </tr></table>'; + echo '<tr><td colspan=2 class="number">' . _('Total') . ':</td> + <td class=number>' . number_format($TotalGLValue,2) . '</td> + </tr></table>'; } if (!isset($TotalGRNValue)){ @@ -339,24 +384,28 @@ if (!isset($TotalShiptValue)){ $TotalShiptValue = 0; } + if (!isset($TotalContractsValue)){ + $TotalContractsValue = 0; + } + $_SESSION['SuppTrans']->OvAmount = ($TotalGRNValue + $TotalGLValue + $TotalShiptValue + $TotalContractsValue); - $_SESSION['SuppTrans']->OvAmount = $TotalGRNValue + $TotalGLValue + $TotalShiptValue; - echo '<br><table><tr><td>' . _('Amount in supplier currency') . ':</td><td colspan=2 class=number>' . number_format( $_SESSION['SuppTrans']->OvAmount,2) . '</td></tr>'; } else { echo '<table><tr><td>' . _('Amount in supplier currency') . - ':</td><td colspan=2 class=number><input type=TEXT size=12 maxlength=10 name=OvAmount VALUE=' . + ':</td><td colspan=2 class=number><input type="text" size="12" maxlength="10" name="OvAmount" VALUE=' . number_format( $_SESSION['SuppTrans']->OvAmount,2) . '></td></tr>'; } - echo "<tr><td colspan=2><input type=Submit name='ToggleTaxMethod' VALUE='" . _('Update Tax Calculation') . - "'></td><td><select name='OverRideTax' onChange='ReloadForm(form1.ToggleTaxMethod)'>"; + echo '<tr><td colspan="2"><input type="submit" name="ToggleTaxMethod" VALUE="' . _('Update Tax Calculation') . + '"></td><td><select name="OverRideTax" onChange="ReloadForm(form1.ToggleTaxMethod)">'; if ($_POST['OverRideTax']=='Man'){ - echo "<option VALUE='Auto'>" . _('Automatic') . "<option selected VALUE='Man'>" . _('Manual'); + echo '<option value="Auto">' . _('Automatic') . '</option> + <option selected VALUE="Man">' . _('Manual') . '</option>'; } else { - echo "<option selected VALUE='Auto'>" . _('Automatic') . "<option VALUE='Man'>" . _('Manual'); + echo '<option selected value="Auto">' . _('Automatic') . '</option> + <option VALUE="Man">' . _('Manual') . '</option>'; } echo '</select></td></tr>'; @@ -375,7 +424,7 @@ if (!isset($_POST['OverRideTax']) or $_POST['OverRideTax']=='Auto'){ - echo ' <input type=TEXT class="number" name=TaxRate' . $Tax->TaxCalculationOrder . ' maxlength=4 size=4 VALUE=' . $_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxRate * 100 . '>%'; + echo ' <input type="text" class="number" name=TaxRate' . $Tax->TaxCalculationOrder . ' maxlength=4 size=4 VALUE=' . $_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxRate * 100 . '>%'; /*Now recaluclate the tax depending on the method */ if ($Tax->TaxOnTax ==1){ @@ -399,9 +448,9 @@ // } $_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxOvAmount = $_POST['TaxAmount' . $Tax->TaxCalculationOrder]; - echo ' <input type=hidden name=TaxRate' . $Tax->TaxCalculationOrder . ' VALUE=' . $_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxRate * 100 . '>'; + echo ' <input type="hidden" name="TaxRate"' . $Tax->TaxCalculationOrder . ' value="' . $_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxRate * 100 . '">'; - echo '</td><td><input type=TEXT class="number" size=12 maxlength=12 name="TaxAmount' . $Tax->TaxCalculationOrder . '" VALUE=' . round($_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxOvAmount,2) . '>'; + echo '</td><td><input type="text" class="number" size="12" maxlength="12" name="TaxAmount' . $Tax->TaxCalculationOrder . '" VALUE=' . round($_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxOvAmount,2) . '>'; } $TaxTotal += $_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxOvAmount; @@ -412,12 +461,15 @@ $DisplayTotal = number_format(( $_SESSION['SuppTrans']->OvAmount + $TaxTotal), 2); - echo '<tr><td>' . _('Invoice Total') . ':</td><td colspan=2 class=number><b>' . $DisplayTotal . '</b></td></tr></table>'; + echo '<tr><td>' . _('Invoice Total') . ':</td> + <td colspan=2 class="number"><b>' . $DisplayTotal . '</b></td> + </tr></table>'; - echo '<table><tr><td>' . _('Comments') . '</td><td><textarea name=Comments COLS=40 ROWS=2>' . - $_SESSION['SuppTrans']->Comments . '</textarea></td></tr></table>'; + echo '<table><tr><td>' . _('Comments') . '</td> + <td><textarea name="Comments" cols="40" rows="2">' . $_SESSION['SuppTrans']->Comments . '</textarea></td> + </tr></table>'; - echo "<p><div class='centre'><input type=submit name='PostInvoice' VALUE='" . _('Enter Invoice') . "'></div>"; + echo '<p><div class="centre"><input type="submit" name="PostInvoice" value="' . _('Enter Invoice') . '"></div>'; } else { //do the postings -and dont show the button to process @@ -426,13 +478,11 @@ foreach ($_SESSION['SuppTrans']->Taxes as $Tax) { - /*Set the tax rate to what was entered */ if (isset($_POST['TaxRate' . $Tax->TaxCalculationOrder])){ $_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxRate = $_POST['TaxRate' . $Tax->T... [truncated message content] |