From: <rc...@us...> - 2016-08-21 03:11:46
|
Revision: 7599 http://sourceforge.net/p/web-erp/reponame/7599 Author: rchacon Date: 2016-08-21 03:11:43 +0000 (Sun, 21 Aug 2016) Log Message: ----------- Fix table html code. Modified Paths: -------------- trunk/ConfirmDispatch_Invoice.php trunk/doc/Change.log Modified: trunk/ConfirmDispatch_Invoice.php =================================================================== --- trunk/ConfirmDispatch_Invoice.php 2016-08-20 04:00:54 UTC (rev 7598) +++ trunk/ConfirmDispatch_Invoice.php 2016-08-21 03:11:43 UTC (rev 7599) @@ -1,30 +1,30 @@ <?php - /* $Id$*/ +/* Creates sales invoices from entered sales orders based on the quantities dispatched that can be modified */ /* Session started in session.inc for password checking and authorisation level check */ include('includes/DefineCartClass.php'); include('includes/DefineSerialItems.php'); + include('includes/session.inc'); $Title = _('Confirm Dispatches and Invoice An Order'); - $ViewTopic= 'ARTransactions'; $BookMark = 'ConfirmInvoice'; +include('includes/header.inc'); -include('includes/header.inc'); include('includes/SQL_CommonFunctions.inc'); include('includes/FreightCalculation.inc'); include('includes/GetSalesTransGLCodes.inc'); -if (empty($_GET['identifier'])) { +if(empty($_GET['identifier'])) { /*unique session identifier to ensure that there is no conflict with other order entry sessions on the same machine */ $identifier=date('U'); } else { $identifier=$_GET['identifier']; } -if (!isset($_GET['OrderNumber']) AND !isset($_SESSION['ProcessingOrder'])) { +if(!isset($_GET['OrderNumber']) AND !isset($_SESSION['ProcessingOrder'])) { /* This page can only be called with an order number for invoicing*/ echo '<div class="centre"> <a href="' . $RootPath . '/SelectSalesOrder.php">' . _('Select a sales order to invoice'). '</a> @@ -34,7 +34,7 @@ prnMsg( _('This page can only be opened if an order has been selected Please select an order first from the delivery details screen click on Confirm for invoicing'), 'error' ); include ('includes/footer.inc'); exit; -} elseif (isset($_GET['OrderNumber']) and $_GET['OrderNumber']>0) { +} elseif(isset($_GET['OrderNumber']) and $_GET['OrderNumber']>0) { unset($_SESSION['Items'.$identifier]->LineItems); unset ($_SESSION['Items'.$identifier]); @@ -43,7 +43,7 @@ $_GET['OrderNumber']=(int)$_GET['OrderNumber']; $_SESSION['Items'.$identifier] = new cart; -/*read in all the guff from the selected order into the Items cart */ +/*read in all the guff from the selected order into the Items cart */ $OrderHeaderSQL = "SELECT salesorders.orderno, salesorders.debtorno, @@ -83,10 +83,10 @@ ON debtorsmaster.currcode = currencies.currabrev INNER JOIN locations ON locations.loccode=salesorders.fromstkloc - INNER JOIN locationusers ON locationusers.loccode=salesorders.fromstkloc AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canupd=1 + INNER JOIN locationusers ON locationusers.loccode=salesorders.fromstkloc AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canupd=1 WHERE salesorders.orderno = '" . $_GET['OrderNumber']."'"; - if ($_SESSION['SalesmanLogin'] != '') { + if($_SESSION['SalesmanLogin'] != '') { $OrderHeaderSQL .= " AND salesorders.salesperson='" . $_SESSION['SalesmanLogin'] . "'"; } @@ -94,7 +94,7 @@ $DbgMsg = _('The SQL to get the order header was'); $GetOrdHdrResult = DB_query($OrderHeaderSQL,$ErrMsg,$DbgMsg); - if (DB_num_rows($GetOrdHdrResult)==1) { + if(DB_num_rows($GetOrdHdrResult)==1) { $myrow = DB_fetch_array($GetOrdHdrResult); @@ -110,8 +110,8 @@ $BestShipper = $myrow['shipvia']; $_SESSION['Items'.$identifier]->ShipVia = $myrow['shipvia']; - if (is_null($BestShipper)){ - $BestShipper=0; + if(is_null($BestShipper)) { + $BestShipper=0; } $_SESSION['Items'.$identifier]->DeliverTo = $myrow['deliverto']; $_SESSION['Items'.$identifier]->DeliveryDate = ConvertSQLDate($myrow['deliverydate']); @@ -172,7 +172,7 @@ $DbgMsg = _('The SQL that failed was'); $LineItemsResult = DB_query($LineItemsSQL,$ErrMsg,$DbgMsg); - if (DB_num_rows($LineItemsResult)>0) { + if(DB_num_rows($LineItemsResult)>0) { while ($myrow=DB_fetch_array($LineItemsResult)) { @@ -216,7 +216,7 @@ } //end of checks on returned data set DB_free_result($LineItemsResult); - } else { /*end if the order was returned sucessfully */ + } else {// End if the order was returned successfully. echo '<br />' . prnMsg( _('This order item could not be retrieved. Please select another order'), 'warn'); @@ -226,44 +226,44 @@ } else { /* if processing, a dispatch page has been called and ${$StkItm->LineNumber} would have been set from the post -set all the necessary session variables changed by the POST */ - if (isset($_POST['ShipVia'])){ +set all the necessary session variables changed by the POST */ + if(isset($_POST['ShipVia'])) { $_SESSION['Items'.$identifier]->ShipVia = $_POST['ShipVia']; } - if (isset($_POST['ChargeFreightCost'])){ + if(isset($_POST['ChargeFreightCost'])) { $_SESSION['Items'.$identifier]->FreightCost = filter_number_format($_POST['ChargeFreightCost']); } $i=1; foreach ($_SESSION['Items'.$identifier]->FreightTaxes as $FreightTaxLine) { - if (isset($_POST['FreightTaxRate' . $i])){ - $_SESSION['Items'.$identifier]->FreightTaxes[$i]->TaxRate = filter_number_format($_POST['FreightTaxRate' . $i])/100; + if(isset($_POST['FreightTaxRate' . $i])) { + $_SESSION['Items'.$identifier]->FreightTaxes[$i]->TaxRate = filter_number_format($_POST['FreightTaxRate' . $i])/100; } $i++; } foreach ($_SESSION['Items'.$identifier]->LineItems as $Itm) { - if (sizeOf($Itm->SerialItems) > 0) { + if(sizeOf($Itm->SerialItems) > 0) { $_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyDispatched = 0; //initialise QtyDispatched foreach ($Itm->SerialItems as $SerialItem) { //calculate QtyDispatched from bundle quantities $_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyDispatched += $SerialItem->BundleQty; } //Preventing from dispatched more than ordered. Since it's controlled items, users must select the batch/lot again. - if($_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyDispatched > ($_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->Quantity - $_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyInv)){ + if($_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyDispatched > ($_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->Quantity - $_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyInv)) { prnMsg(_('Dispathed Quantity should not be more than order balanced quantity').'. '._('To dispatch quantity is').' '.$_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyDispatched.' '._('And the order balance is ').' '.($_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->Quantity - $_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyInv),'error'); include('includes/footer.inc'); exit; } - } else if (isset($_POST[$Itm->LineNumber . '_QtyDispatched' ])){ - if (is_numeric(filter_number_format($_POST[$Itm->LineNumber . '_QtyDispatched' ])) - AND filter_number_format($_POST[$Itm->LineNumber . '_QtyDispatched']) <= ($_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->Quantity - $_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyInv)){ + } else if(isset($_POST[$Itm->LineNumber . '_QtyDispatched' ])) { + if(is_numeric(filter_number_format($_POST[$Itm->LineNumber . '_QtyDispatched' ])) + AND filter_number_format($_POST[$Itm->LineNumber . '_QtyDispatched']) <= ($_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->Quantity - $_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyInv)) { - $_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyDispatched = round(filter_number_format($_POST[$Itm->LineNumber . '_QtyDispatched']),$Itm->DecimalPlaces); + $_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->QtyDispatched = round(filter_number_format($_POST[$Itm->LineNumber . '_QtyDispatched']),$Itm->DecimalPlaces); } } $i=1; foreach ($Itm->Taxes as $TaxLine) { - if (isset($_POST[$Itm->LineNumber . $i . '_TaxRate'])){ - $_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->Taxes[$i]->TaxRate = filter_number_format($_POST[$Itm->LineNumber . $i . '_TaxRate'])/100; + if(isset($_POST[$Itm->LineNumber . $i . '_TaxRate'])) { + $_SESSION['Items'.$identifier]->LineItems[$Itm->LineNumber]->Taxes[$i]->TaxRate = filter_number_format($_POST[$Itm->LineNumber . $i . '_TaxRate'])/100; } $i++; } @@ -273,8 +273,8 @@ /* Always display dispatch quantities and recalc freight for items being dispatched */ -if ($_SESSION['Items'.$identifier]->SpecialInstructions) { - prnMsg($_SESSION['Items'.$identifier]->SpecialInstructions,'warn'); +if($_SESSION['Items'.$identifier]->SpecialInstructions) { + prnMsg($_SESSION['Items'.$identifier]->SpecialInstructions,'warn'); } echo '<p class="page_title_text"><img src="'.$RootPath.'/css/'.$Theme.'/images/inventory.png" title="' . _('Confirm Invoice') . '" alt="" />' . ' ' . _('Confirm Dispatch and Invoice'). '</p>'; @@ -296,10 +296,11 @@ /*************************************************************** Line Item Display ***************************************************************/ -echo '<table width="90%" cellpadding="2" class="selection"> +echo '<table class="selection"> + <thead> <tr> <th>' . _('Item Code') . '</th> - <th>' . _('Item Description' ) . '</th> + <th>' . _('Item Description') . '</th> <th>' . _('Ordered') . '</th> <th>' . _('Units') . '</th> <th>' . _('Already') . '<br />' . _('Sent') . '</th> @@ -309,9 +310,10 @@ <th>' . _('Total') . '<br />' . _('Excl Tax') . '</th> <th>' . _('Tax Authority') . '</th> <th>' . _('Tax %') . '</th> - <th>' . _('Tax') . '<br />' . _('Amount') . '</th> + <th>' . _('Tax Amount') . '</th> <th>' . _('Total') . '<br />' . _('Incl Tax') . '</th> - </tr>'; + </tr> + </thead><tbody>'; $_SESSION['Items'.$identifier]->total = 0; $_SESSION['Items'.$identifier]->totalVolume = 0; @@ -326,37 +328,35 @@ $j=0; foreach ($_SESSION['Items'.$identifier]->LineItems as $LnItm) { $j++; - if ($k==1){ - $RowStarter = '<tr class="EvenTableRows">'; - $k=0; - } else { - $RowStarter = '<tr class="OddTableRows">'; - $k=1; - } - $LineTotal = $LnItm->QtyDispatched * $LnItm->Price * (1 - $LnItm->DiscountPercent); - $_SESSION['Items'.$identifier]->total += $LineTotal; $_SESSION['Items'.$identifier]->totalVolume += ($LnItm->QtyDispatched * $LnItm->Volume); $_SESSION['Items'.$identifier]->totalWeight += ($LnItm->QtyDispatched * $LnItm->Weight); - echo $RowStarter; - echo '<td>' . $LnItm->StockID . '</td> - <td title="'. $LnItm->LongDescription . '">' .$LnItm->ItemDescription . '</td> - <td class="number">' . locale_number_format($LnItm->Quantity,$LnItm->DecimalPlaces) . '</td> - <td>' . $LnItm->Units . '</td> - <td class="number">' . locale_number_format($LnItm->QtyInv,$LnItm->DecimalPlaces) . '</td>'; + if($k==1) { + $RowStarter = '<tr class="EvenTableRows">'; + $k = 0; + } else { + $RowStarter = '<tr class="OddTableRows">'; + $k = 1; + } + echo $RowStarter, ' + <td>', $LnItm->StockID, '</td> + <td class="text" title="', $LnItm->LongDescription, '">', $LnItm->ItemDescription, '</td> + <td class="number">', locale_number_format($LnItm->Quantity, $LnItm->DecimalPlaces), '</td> + <td class="text">', $LnItm->Units, '</td> + <td class="number">', locale_number_format($LnItm->QtyInv, $LnItm->DecimalPlaces), '</td>'; - if ($LnItm->Controlled==1){ + if($LnItm->Controlled==1) { - if (isset($_POST['ProcessInvoice'])) { + if(isset($_POST['ProcessInvoice'])) { echo '<td class="number">' . locale_number_format($LnItm->QtyDispatched,$LnItm->DecimalPlaces) . '</td>'; } else { - echo '<td class="number"><input type="hidden" name="' . $LnItm->LineNumber . '_QtyDispatched" value="' . $LnItm->QtyDispatched . '" /><a href="' . $RootPath .'/ConfirmDispatchControlled_Invoice.php?identifier=' . $identifier . '&LineNo='. $LnItm->LineNumber.'">' .locale_number_format($LnItm->QtyDispatched,$LnItm->DecimalPlaces) . '</a></td>'; + echo '<td class="number"><input type="hidden" name="' . $LnItm->LineNumber . '_QtyDispatched" value="' . $LnItm->QtyDispatched . '" /><a href="' . $RootPath .'/ConfirmDispatchControlled_Invoice.php?identifier=' . $identifier . '&LineNo='. $LnItm->LineNumber.'">' .locale_number_format($LnItm->QtyDispatched,$LnItm->DecimalPlaces) . '</a></td>'; } } else { - if (isset($_POST['ProcessInvoice'])) { - echo '<td class="number">' . locale_number_format($LnItm->QtyDispatched,$LnItm->DecimalPlaces) . '</td>'; + if(isset($_POST['ProcessInvoice'])) { + echo '<td class="number">' . locale_number_format($LnItm->QtyDispatched,$LnItm->DecimalPlaces) . '</td>'; } else { echo '<td class="number"><input tabindex="'.$j.'" type="text" ' . ($j==1 ? 'autofocus="autofocus" ':'') . ' class="number" required="required" title="' . _('Enter the quantity to charge the customer for, that has been dispatched') . '" name="' . $LnItm->LineNumber . '_QtyDispatched" maxlength="12" size="12" value="' . locale_number_format($LnItm->QtyDispatched,$LnItm->DecimalPlaces) . '" /></td>'; } @@ -372,33 +372,33 @@ echo '<td>'; $i=0; foreach ($_SESSION['Items'.$identifier]->LineItems[$LnItm->LineNumber]->Taxes AS $Tax) { - if ($i>0){ + if($i>0) { echo '<br />'; } echo $Tax->TaxAuthDescription; $i++; } - echo '</td>'; - echo '<td class="number">'; + echo '</td> + <td class="number">'; $i=1; // initialise the number of taxes iterated through $TaxLineTotal =0; //initialise tax total for the line foreach ($LnItm->Taxes AS $Tax) { - if (empty($TaxTotals[$Tax->TaxAuthID])) { + if(empty($TaxTotals[$Tax->TaxAuthID])) { $TaxTotals[$Tax->TaxAuthID]=0; } - if ($i>1){ + if($i>1) { echo '<br />'; } - if (isset($_POST['ProcessInvoice'])) { - echo $Tax->TaxRate*100; + if(isset($_POST['ProcessInvoice'])) { + echo $Tax->TaxRate*100; } else { echo '<input type="text" class="number" required="required" title="' . _('Enter the tax rate applicable as a number') . '" name="' . $LnItm->LineNumber . $i . '_TaxRate" maxlength="4" size="4" value="' . $Tax->TaxRate*100 . '" />'; } $i++; - if ($Tax->TaxOnTax ==1){ + if($Tax->TaxOnTax ==1) { $TaxTotals[$Tax->TaxAuthID] += ($Tax->TaxRate * ($LineTotal + $TaxLineTotal)); $TaxLineTotal += ($Tax->TaxRate * ($LineTotal + $TaxLineTotal)); } else { @@ -418,10 +418,10 @@ echo '<td class="number">' . $DisplayTaxAmount . '</td> <td class="number">' . $DisplayGrossLineTotal . '</td>'; - if ($LnItm->Controlled==1){ - if (!isset($_POST['ProcessInvoice'])) { + if($LnItm->Controlled==1) { + if(!isset($_POST['ProcessInvoice'])) { echo '<td><a href="' . $RootPath . '/ConfirmDispatchControlled_Invoice.php?identifier=' . $identifier . '&LineNo='. $LnItm->LineNumber.'">'; - if ($LnItm->Serialised==1){ + if($LnItm->Serialised==1) { echo _('Enter Serial Numbers'); } else { /*Just batch/roll/lot control */ echo _('Enter Batch/Roll/Lot #'); @@ -430,7 +430,7 @@ } } echo '</tr>'; - if (mb_strlen($LnItm->Narrative)>1){ + if(mb_strlen($LnItm->Narrative)>1) { $Narrative=str_replace('\r\n','<br />', $LnItm->Narrative); echo $RowStarter . '<td colspan="12">' . stripslashes($Narrative) . '</td></tr>'; } @@ -442,7 +442,7 @@ was not fully delivered the first time ?? */ if(!isset($_SESSION['Items'.$identifier]->FreightCost)) { - if ($_SESSION['DoFreightCalc']==True){ + if($_SESSION['DoFreightCalc']==True) { list ($FreightCost, $BestShipper) = CalcFreightCost($_SESSION['Items'.$identifier]->total, $_SESSION['Items'.$identifier]->BrAdd2, $_SESSION['Items'.$identifier]->BrAdd3, @@ -456,77 +456,76 @@ $db); $_SESSION['Items'.$identifier]->ShipVia = $BestShipper; } - if (is_numeric($FreightCost)){ + if(is_numeric($FreightCost)) { $FreightCost = $FreightCost / $_SESSION['CurrencyRate']; - } else { + } else { $FreightCost =0; - } - if (!is_numeric($BestShipper)){ - $SQL = "SELECT shipper_id FROM shippers WHERE shipper_id='" . $_SESSION['Default_Shipper'] . "'"; + } + if(!is_numeric($BestShipper)) { + $SQL = "SELECT shipper_id FROM shippers WHERE shipper_id='" . $_SESSION['Default_Shipper'] . "'"; $ErrMsg = _('There was a problem testing for a default shipper because'); $TestShipperExists = DB_query($SQL, $ErrMsg); - if (DB_num_rows($TestShipperExists)==1){ + if(DB_num_rows($TestShipperExists)==1) { $BestShipper = $_SESSION['Default_Shipper']; } else { - $SQL = "SELECT shipper_id FROM shippers"; + $SQL = "SELECT shipper_id FROM shippers"; $ErrMsg = _('There was a problem testing for a default shipper'); $TestShipperExists = DB_query($SQL, $ErrMsg); - if (DB_num_rows($TestShipperExists)>=1){ + if(DB_num_rows($TestShipperExists)>=1) { $ShipperReturned = DB_fetch_row($TestShipperExists); $BestShipper = $ShipperReturned[0]; } else { prnMsg( _('There are no shippers defined') . '. ' . _('Please use the link below to set up shipping freight companies, the system expects the shipping company to be selected or a default freight company to be used'),'error'); - echo '<a href="' . $RootPath . 'Shippers.php">' . _('Enter') . '/' . _('Amend Freight Companies'). '</a>'; + echo '<a href="' . $RootPath . 'Shippers.php">' . _('Enter') . '/' . _('Amend Freight Companies'). '</a>'; } } } } -if (isset($_POST['ChargeFreightCost']) AND !is_numeric(filter_number_format($_POST['ChargeFreightCost']))){ +if(isset($_POST['ChargeFreightCost']) AND !is_numeric(filter_number_format($_POST['ChargeFreightCost']))) { $_POST['ChargeFreightCost'] = 0; } echo '<tr> - <td colspan="5" class="number">' . _('Order Freight Cost'). '</td> - <td class="number">' . locale_number_format($_SESSION['Old_FreightCost'],$_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '</td>'; + <td class="number" colspan="2">', _('Order Freight Cost'), '</td> + <td class="number">', locale_number_format($_SESSION['Old_FreightCost'], $_SESSION['Items'.$identifier]->CurrDecimalPlaces), '</td>'; -if ($_SESSION['DoFreightCalc']==True){ - echo '<td colspan="2" class="number">' ._('Recalculated Freight Cost'). '</td> - <td class="number">' . locale_number_format($FreightCost,$_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '</td>'; +if($_SESSION['DoFreightCalc']==True) { + echo '<td class="number" colspan="2">', _('Recalculated Freight Cost'), '</td> + <td class="number">', locale_number_format($FreightCost, $_SESSION['Items'.$identifier]->CurrDecimalPlaces), '</td>'; } else { -// echo '<td colspan="1"></td>'; +// echo '<td colspan="1"></td>';// Should be?: echo '<td colspan="3"> </td>'; } $j++; -if (!isset($_POST['ChargeFreightCost'])) { +if(!isset($_POST['ChargeFreightCost'])) { $_POST['ChargeFreightCost']=0; } -if ($_SESSION['Items'.$identifier]->Any_Already_Delivered()==1 +echo '<td class="number" colspan="2">', _('Charge Freight Cost ex Tax'), '</td>'; +if($_SESSION['Items'.$identifier]->Any_Already_Delivered()==1 AND (!isset($_SESSION['Items'.$identifier]->FreightCost) OR $_POST['ChargeFreightCost']==0)) { - echo '<td colspan="2" class="number">' . _('Charge Freight Cost ex Tax') . '</td> - <td><input tabindex="'.$j.'" type="text" required="required" class="number" size="10" maxlength="12" name="ChargeFreightCost" value="0" /></td>'; - $_SESSION['Items'.$identifier]->FreightCost=0; + echo '<td><input class="number" maxlength="12" name="ChargeFreightCost" required="required" size="10" tabindex="', $j, '" type="text" value="0" /></td>'; + $_SESSION['Items'.$identifier]->FreightCost = 0; } else { - echo '<td colspan="2" class="number">' . _('Charge Freight Cost ex Tax') . '</td>'; - if (isset($_POST['ProcessInvoice'])) { + if(isset($_POST['ProcessInvoice'])) { echo '<td class="number">' . locale_number_format($_SESSION['Items'.$identifier]->FreightCost,$_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '</td>'; } else { - echo '<td class="number"><input tabindex="'.$j.'" type="text" class="number" size="10" maxlength="12" name="ChargeFreightCost" value="' . locale_number_format($_SESSION['Items'.$identifier]->FreightCost,$_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '" /></td>'; + echo '<td class="number"><input class="number" maxlength="12" name="ChargeFreightCost" size="10" tabindex="'. $j. '" type="text" value="'. locale_number_format($_SESSION['Items'.$identifier]->FreightCost,$_SESSION['Items'.$identifier]->CurrDecimalPlaces). '" /></td>'; } $_POST['ChargeFreightCost'] = locale_number_format($_SESSION['Items'.$identifier]->FreightCost,$_SESSION['Items'.$identifier]->CurrDecimalPlaces); } -$FreightTaxTotal =0; //initialise tax total +$FreightTaxTotal = 0;// initialise tax total echo '<td>'; $i=0; // initialise the number of taxes iterated through foreach ($_SESSION['Items'.$identifier]->FreightTaxes as $FreightTaxLine) { - if ($i>0){ + if($i>0) { echo '<br />'; } - echo $FreightTaxLine->TaxAuthDescription; + echo $FreightTaxLine->TaxAuthDescription; $i++; } @@ -534,18 +533,17 @@ $i=0; foreach ($_SESSION['Items'.$identifier]->FreightTaxes as $FreightTaxLine) { - if ($i>0){ + if($i>0) { echo '<br />'; } - if (isset($_POST['ProcessInvoice'])) { - echo $FreightTaxLine->TaxRate * 100 ; + if(isset($_POST['ProcessInvoice'])) { + echo $FreightTaxLine->TaxRate * 100 ; } else { - echo '<input type="text" class="number" name="FreightTaxRate' . $FreightTaxLine->TaxCalculationOrder . - '" maxlength="4" size="4" value="' . locale_number_format($FreightTaxLine->TaxRate * 100,$_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '" />'; + echo '<input class="number" maxlength="4" name="FreightTaxRate'. $FreightTaxLine->TaxCalculationOrder. '" size="4" type="text" value="'. locale_number_format($FreightTaxLine->TaxRate * 100, $_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '" />'; } - if ($FreightTaxLine->TaxOnTax ==1){ + if($FreightTaxLine->TaxOnTax ==1) { $TaxTotals[$FreightTaxLine->TaxAuthID] += ($FreightTaxLine->TaxRate * ($_SESSION['Items'.$identifier]->FreightCost + $FreightTaxTotal)); $FreightTaxTotal += ($FreightTaxLine->TaxRate * ($_SESSION['Items'.$identifier]->FreightCost + $FreightTaxTotal)); } else { @@ -574,15 +572,15 @@ </tr>'; -if (! isset($_POST['DispatchDate']) OR ! Is_Date($_POST['DispatchDate'])){ +if(! isset($_POST['DispatchDate']) OR ! Is_Date($_POST['DispatchDate'])) { $DefaultDispatchDate = Date($_SESSION['DefaultDateFormat'],CalcEarliestDispatchDate()); } else { $DefaultDispatchDate = $_POST['DispatchDate']; } -echo '</table><br />'; +echo '<tbody></table><br />'; -if (isset($_POST['ProcessInvoice']) AND $_POST['ProcessInvoice'] != ''){ +if(isset($_POST['ProcessInvoice']) AND $_POST['ProcessInvoice'] != '') { /* SQL to process the postings for sales invoices... @@ -592,23 +590,23 @@ $QuantityInvoicedIsPositive = false; foreach ($_SESSION['Items'.$identifier]->LineItems as $OrderLine) { - if ($OrderLine->QtyDispatched > 0){ + if($OrderLine->QtyDispatched > 0) { $QuantityInvoicedIsPositive =true; } } - if (! $QuantityInvoicedIsPositive){ + if(! $QuantityInvoicedIsPositive) { prnMsg( _('There are no lines on this order with a quantity to invoice') . '. ' . _('No further processing has been done'),'error'); include('includes/footer.inc'); exit; } - if ($_SESSION['ProhibitNegativeStock']==1){ // checks for negative stock after processing invoice + if($_SESSION['ProhibitNegativeStock']==1) { // checks for negative stock after processing invoice //sadly this check does not combine quantities occuring twice on and order and each line is considered individually :-( $NegativesFound = false; foreach ($_SESSION['Items'.$identifier]->LineItems as $OrderLine) { $SQL = "SELECT stockmaster.description, - locstock.quantity, - stockmaster.mbflag + locstock.quantity, + stockmaster.mbflag FROM locstock INNER JOIN stockmaster ON stockmaster.stockid=locstock.stockid @@ -618,17 +616,17 @@ $ErrMsg = _('Could not retrieve the quantity left at the location once this order is invoiced (for the purposes of checking that stock will not go negative because)'); $Result = DB_query($SQL,$ErrMsg); $CheckNegRow = DB_fetch_array($Result); - if (($CheckNegRow['mbflag']=='B' OR $CheckNegRow['mbflag']=='M') AND mb_substr($OrderLine->StockID,0,4)!='ASSET'){ - if ($CheckNegRow['quantity'] < $OrderLine->QtyDispatched){ + if(($CheckNegRow['mbflag']=='B' OR $CheckNegRow['mbflag']=='M') AND mb_substr($OrderLine->StockID,0,4)!='ASSET') { + if($CheckNegRow['quantity'] < $OrderLine->QtyDispatched) { prnMsg( _('Invoicing the selected order would result in negative stock. The system parameters are set to prohibit negative stocks from occurring. This invoice cannot be created until the stock on hand is corrected.'),'error',$OrderLine->StockID . ' ' . $CheckNegRow['description'] . ' - ' . _('Negative Stock Prohibited')); $NegativesFound = true; } - } elseif ($CheckNegRow['mbflag']=='A') { + } elseif($CheckNegRow['mbflag']=='A') { /*Now look for assembly components that would go negative */ $SQL = "SELECT bom.component, - stockmaster.description, - locstock.quantity-(" . $OrderLine->QtyDispatched . "*bom.quantity) AS qtyleft + stockmaster.description, + locstock.quantity-(" . $OrderLine->QtyDispatched . "*bom.quantity) AS qtyleft FROM bom INNER JOIN locstock ON bom.component=locstock.stockid @@ -636,13 +634,13 @@ ON stockmaster.stockid=bom.component WHERE bom.parent='" . $OrderLine->StockID . "' AND locstock.loccode='" . $_SESSION['Items'.$identifier]->Location . "' - AND bom.effectiveafter <= '" . date('Y-m-d') . "' - AND bom.effectiveto > '" . date('Y-m-d') . "'"; + AND bom.effectiveafter <= '" . date('Y-m-d') . "' + AND bom.effectiveto > '" . date('Y-m-d') . "'"; $ErrMsg = _('Could not retrieve the component quantity left at the location once the assembly item on this order is invoiced (for the purposes of checking that stock will not go negative because)'); $Result = DB_query($SQL,$ErrMsg); - while ($NegRow = DB_fetch_array($Result)){ - if ($NegRow['qtyleft']<0){ + while ($NegRow = DB_fetch_array($Result)) { + if($NegRow['qtyleft']<0) { prnMsg(_('Invoicing the selected order would result in negative stock for a component of an assembly item on the order. The system parameters are set to prohibit negative stocks from occurring. This invoice cannot be created until the stock on hand is corrected.'),'error',$NegRow['component'] . ' ' . $NegRow['description'] . ' - ' . _('Negative Stock Prohibited')); $NegativesFound = true; } // end if negative would result @@ -651,10 +649,10 @@ } //end of loop around items on the order for negative check - if ($NegativesFound){ - echo '</div>'; - echo '</form>'; - echo '<div class="centre"> + if($NegativesFound) { + echo '</div>'; + echo '</form>'; + echo '<div class="centre"> <input type="submit" name="Update" value="' . _('Update'). '" /></div>'; include('includes/footer.inc'); exit; @@ -680,7 +678,7 @@ /*company record read in on login with info on GL Links and debtors GL account*/ - if ($_SESSION['CompanyRecord']==0){ + if($_SESSION['CompanyRecord']==0) { /*The company data and preferences could not be retrieved for some reason */ prnMsg( _('The company information and preferences could not be retrieved') . ' - ' . _('see your system administrator'), 'error'); include('includes/footer.inc'); @@ -699,11 +697,11 @@ $Result = DB_query($SQL); - if (DB_num_rows($Result) != count($_SESSION['Items'.$identifier]->LineItems)){ + if(DB_num_rows($Result) != count($_SESSION['Items'.$identifier]->LineItems)) { - /*there should be the same number of items returned from this query as there are lines on the invoice - if not then someone has already invoiced or credited some lines */ + /*there should be the same number of items returned from this query as there are lines on the invoice - if not then someone has already invoiced or credited some lines */ - if ($debug==1){ + if($debug==1) { echo '<br />' . $SQL; echo '<br />' . _('Number of rows returned by SQL') . ':' . DB_num_rows($Result); echo '<br />' . _('Count of items in the session') . ' ' . count($_SESSION['Items'.$identifier]->LineItems); @@ -722,16 +720,16 @@ while ($myrow = DB_fetch_array($Result)) { - if ($_SESSION['Items'.$identifier]->LineItems[$myrow['orderlineno']]->Quantity != $myrow['quantity'] + if($_SESSION['Items'.$identifier]->LineItems[$myrow['orderlineno']]->Quantity != $myrow['quantity'] OR $_SESSION['Items'.$identifier]->LineItems[$myrow['orderlineno']]->QtyInv != $myrow['qtyinvoiced']) { - echo '<br />' . _('Orig order for'). ' ' . $myrow['orderlineno'] . ' '. _('has a quantity of'). ' ' . $myrow['quantity'] . ' '. _('and an invoiced qty of'). ' ' . $myrow['qtyinvoiced'] . ' '. _('the session shows quantity of'). ' ' . $_SESSION['Items'.$identifier]->LineItems[$myrow['orderlineno']]->Quantity . ' ' . _('and quantity invoice of'). ' ' . $_SESSION['Items'.$identifier]->LineItems[$myrow['orderlineno']]->QtyInv; + echo '<br />' . _('Orig order for'). ' ' . $myrow['orderlineno'] . ' '. _('has a quantity of'). ' ' . $myrow['quantity'] . ' '. _('and an invoiced qty of'). ' ' . $myrow['qtyinvoiced'] . ' '. _('the session shows quantity of'). ' ' . $_SESSION['Items'.$identifier]->LineItems[$myrow['orderlineno']]->Quantity . ' ' . _('and quantity invoice of'). ' ' . $_SESSION['Items'.$identifier]->LineItems[$myrow['orderlineno']]->QtyInv; prnMsg( _('This order has been changed or invoiced since this delivery was started to be confirmed') . ' ' . _('Processing halted.') . ' ' . _('To enter and confirm this dispatch, it must be re-selected and re-read again to update the changes made by the other user'), 'error'); echo '<br />'; - echo '<div class="centre"><a href="'. $RootPath . '/SelectSalesOrder.php">' . _('Select a sales order for confirming deliveries and invoicing'). '</a></div>'; + echo '<div class="centre"><a href="'. $RootPath . '/SelectSalesOrder.php">' . _('Select a sales order for confirming deliveries and invoicing'). '</a></div>'; unset($_SESSION['Items'.$identifier]->LineItems); unset($_SESSION['Items'.$identifier]); @@ -756,7 +754,7 @@ DB_Txn_Begin(); - if ($DefaultShipVia != $_SESSION['Items'.$identifier]->ShipVia){ + if($DefaultShipVia != $_SESSION['Items'.$identifier]->ShipVia) { $SQL = "UPDATE custbranch SET defaultshipvia ='" . $_SESSION['Items'.$identifier]->ShipVia . "' WHERE debtorno='" . $_SESSION['Items'.$identifier]->DebtorNo . "' @@ -846,13 +844,13 @@ foreach ($_SESSION['Items'.$identifier]->LineItems as $OrderLine) { /*Test to see if the item being sold is an asset */ - if (mb_substr($OrderLine->StockID,0,6)=='ASSET-'){ + if(mb_substr($OrderLine->StockID,0,6)=='ASSET-') { $IsAsset = true; $HyphenOccursAt = mb_strpos($OrderLine->StockID,'-',6); - if ($HyphenOccursAt == false){ - $AssetNumber = intval(mb_substr($OrderLine->StockID,6)); + if($HyphenOccursAt == false) { + $AssetNumber = intval(mb_substr($OrderLine->StockID,6)); } else { - $AssetNumber = intval(mb_substr($OrderLine->StockID,6,mb_strlen($OrderLine->StockID)-$HyphenOccursAt-1)); + $AssetNumber = intval(mb_substr($OrderLine->StockID,6,mb_strlen($OrderLine->StockID)-$HyphenOccursAt-1)); } prnMsg (_('The asset number being disposed of is:') . ' ' . $AssetNumber, 'info'); } else { @@ -860,7 +858,7 @@ $AssetNumber = 0; } - if ($_POST['BOPolicy']=='CAN'){ + if($_POST['BOPolicy']=='CAN') { $SQL = "UPDATE salesorderdetails SET quantity = quantity - " . ($OrderLine->Quantity - $OrderLine->QtyDispatched - $OrderLine->QtyInv) . " @@ -872,7 +870,7 @@ $Result = DB_query($SQL,$ErrMsg,$DbgMsg,true); - if (($OrderLine->Quantity - $OrderLine->QtyDispatched)>0){ + if(($OrderLine->Quantity - $OrderLine->QtyDispatched)>0) { $SQL = "INSERT INTO orderdeliverydifferenceslog (orderno, invoiceno, @@ -885,7 +883,7 @@ '" . $_SESSION['ProcessingOrder'] . "', '" . $InvoiceNo . "', '" . $OrderLine->StockID . "', - '" . ($OrderLine->Quantity - $OrderLine->QtyDispatched - $OrderLine->QtyInv) . "', + '" . ($OrderLine->Quantity - $OrderLine->QtyDispatched - $OrderLine->QtyInv) . "', '" . $_SESSION['Items'.$identifier]->DebtorNo . "', '" . $_SESSION['Items'.$identifier]->Branch . "', 'CAN')"; @@ -895,7 +893,7 @@ $Result = DB_query($SQL,$ErrMsg,$DbgMsg,true); } - } elseif (($OrderLine->Quantity - $OrderLine->QtyDispatched)>0 + } elseif(($OrderLine->Quantity - $OrderLine->QtyDispatched)>0 AND DateDiff(ConvertSQLDate($DefaultDispatchDate),$_SESSION['Items'.$identifier]->DeliveryDate,'d')>0) { /*The order is being short delivered after the due date - need to insert a delivery differnce log */ @@ -912,33 +910,33 @@ '" . $_SESSION['ProcessingOrder'] . "', '" . $InvoiceNo . "', '" . $OrderLine->StockID . "', - '" . ($OrderLine->Quantity - $OrderLine->QtyDispatched - $OrderLine->QtyInv) . "', + '" . ($OrderLine->Quantity - $OrderLine->QtyDispatched - $OrderLine->QtyInv) . "', '" . $_SESSION['Items'.$identifier]->DebtorNo . "', '" . $_SESSION['Items'.$identifier]->Branch . "', 'BO' )"; - $ErrMsg = '<br />' . _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The order delivery differences log record could not be inserted because'); + $ErrMsg = '<br />' . _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The order delivery differences log record could not be inserted because'); $DbgMsg = _('The following SQL to insert the order delivery differences record was used'); $Result = DB_query($SQL,$ErrMsg,$DbgMsg,true); } /*end of order delivery differences log entries */ /*Now update SalesOrderDetails for the quantity invoiced and the actual dispatch dates. */ - if ($OrderLine->QtyDispatched !=0 AND $OrderLine->QtyDispatched!='' AND $OrderLine->QtyDispatched) { + if($OrderLine->QtyDispatched !=0 AND $OrderLine->QtyDispatched!='' AND $OrderLine->QtyDispatched) { // Test above to see if the line is completed or not - if ($OrderLine->QtyDispatched>=($OrderLine->Quantity - $OrderLine->QtyInv) OR $_POST['BOPolicy']=='CAN'){ + if($OrderLine->QtyDispatched>=($OrderLine->Quantity - $OrderLine->QtyInv) OR $_POST['BOPolicy']=='CAN') { $SQL = "UPDATE salesorderdetails SET qtyinvoiced = qtyinvoiced + " . $OrderLine->QtyDispatched . ", - actualdispatchdate = '" . $DefaultDispatchDate . "', + actualdispatchdate = '" . $DefaultDispatchDate . "', completed=1 WHERE orderno = '" . $_SESSION['ProcessingOrder'] . "' AND orderlineno = '" . $OrderLine->LineNumber . "'"; } else { $SQL = "UPDATE salesorderdetails SET qtyinvoiced = qtyinvoiced + " . $OrderLine->QtyDispatched . ", - actualdispatchdate = '" . $DefaultDispatchDate . "' + actualdispatchdate = '" . $DefaultDispatchDate . "' WHERE orderno = '" . $_SESSION['ProcessingOrder'] . "' AND orderlineno = '" . $OrderLine->LineNumber . "'"; @@ -958,21 +956,21 @@ $myrow = DB_fetch_row($Result); $MBFlag = $myrow[0]; - if ($MBFlag=='B' OR $MBFlag=='M') { + if($MBFlag=='B' OR $MBFlag=='M') { $Assembly = False; /* Need to get the current location quantity will need it later for the stock movement */ - $SQL="SELECT locstock.quantity + $SQL="SELECT locstock.quantity FROM locstock WHERE locstock.stockid='" . $OrderLine->StockID . "' AND loccode= '" . $_SESSION['Items'.$identifier]->Location . "'"; $ErrMsg = _('WARNING') . ': ' . _('Could not retrieve current location stock'); $Result = DB_query($SQL, $ErrMsg); - if (DB_num_rows($Result)==1){ - $LocQtyRow = DB_fetch_row($Result); - $QtyOnHandPrior = $LocQtyRow[0]; + if(DB_num_rows($Result)==1) { + $LocQtyRow = DB_fetch_row($Result); + $QtyOnHandPrior = $LocQtyRow[0]; } else { /* There must be some error this should never happen */ $QtyOnHandPrior = 0; @@ -987,7 +985,7 @@ $DbgMsg = _('The following SQL to update the location stock record was used'); $Result = DB_query($SQL,$ErrMsg,$DbgMsg,true); - } else if ($MBFlag=='A'){ /* its an assembly */ + } else if($MBFlag=='A') { /* its an assembly */ /*Need to get the BOM for this part and make stock moves for the components then update the Location stock balances */ $Assembly=True; @@ -998,19 +996,19 @@ FROM bom INNER JOIN stockmaster ON bom.component=stockmaster.stockid WHERE bom.parent='" . $OrderLine->StockID . "' - AND bom.effectiveafter <= '" . date('Y-m-d') . "' - AND bom.effectiveto > '" . date('Y-m-d') . "'"; + AND bom.effectiveafter <= '" . date('Y-m-d') . "' + AND bom.effectiveto > '" . date('Y-m-d') . "'"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Could not retrieve assembly components from the database for'). ' '. $OrderLine->StockID . _('because').' '; $DbgMsg = _('The SQL that failed was'); $AssResult = DB_query($SQL,$ErrMsg,$DbgMsg,true); - while ($AssParts = DB_fetch_array($AssResult)){ + while ($AssParts = DB_fetch_array($AssResult)) { $StandardCost += ($AssParts['standard'] * $AssParts['quantity']) ; /* Need to get the current location quantity will need it later for the stock movement */ - $SQL="SELECT locstock.quantity + $SQL="SELECT locstock.quantity FROM locstock WHERE locstock.stockid='" . $AssParts['component'] . "' AND loccode= '" . $_SESSION['Items'.$identifier]->Location . "'"; @@ -1018,14 +1016,14 @@ $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Can not retrieve assembly components location stock quantities because '); $DbgMsg = _('The SQL that failed was'); $Result = DB_query($SQL,$ErrMsg,$DbgMsg,true); - if (DB_num_rows($Result)==1){ - $LocQtyRow = DB_fetch_row($Result); - $QtyOnHandPrior = $LocQtyRow[0]; + if(DB_num_rows($Result)==1) { + $LocQtyRow = DB_fetch_row($Result); + $QtyOnHandPrior = $LocQtyRow[0]; } else { /*There must be some error this should never happen */ $QtyOnHandPrior = 0; } - if (empty($AssParts['standard'])) { + if(empty($AssParts['standard'])) { $AssParts['standard']=0; } $SQL = "INSERT INTO stockmoves (stockid, @@ -1081,11 +1079,11 @@ //$LocalCurrencyPrice = round(($OrderLine->Price / $_SESSION['CurrencyRate']),$_SESSION['CompanyRecord']['decimalplaces']); change decimalplaces to 5 to avoid price or lines total variance on invoice. And the decimal places should not be over 5 since the stockmoves table defined it as decimal(21,5) now. $LocalCurrencyPrice = round(($OrderLine->Price / $_SESSION['CurrencyRate']),5); - if (empty($OrderLine->StandardCost)) { + if(empty($OrderLine->StandardCost)) { $OrderLine->StandardCost=0; } - if ($MBFlag=='B' OR $MBFlag=='M'){ - $SQL = "INSERT INTO stockmoves (stockid, + if($MBFlag=='B' OR $MBFlag=='M') { + $SQL = "INSERT INTO stockmoves (stockid, type, transno, loccode, @@ -1118,8 +1116,8 @@ '" . ($QtyOnHandPrior - $OrderLine->QtyDispatched) . "', '" . DB_escape_string($OrderLine->Narrative) . "' )"; } else { - // its an assembly or dummy and assemblies/dummies always have nil stock (by definition they are made up at the time of dispatch so new qty on hand will be nil - if (empty($OrderLine->StandardCost)) { + // its an assembly or dummy and assemblies/dummies always have nil stock (by definition they are made up at the time of dispatch so new qty on hand will be nil + if(empty($OrderLine->StandardCost)) { $OrderLine->StandardCost=0; } $SQL = "INSERT INTO stockmoves (stockid, @@ -1182,11 +1180,11 @@ } -/*Insert the StockSerialMovements and update the StockSerialItems for controlled items*/ +/* Insert the StockSerialMovements and update the StockSerialItems for controlled items*/ - if ($OrderLine->Controlled ==1){ - foreach($OrderLine->SerialItems as $Item){ - /*We need to add the StockSerialItem record and the StockSerialMoves as well */ + if($OrderLine->Controlled ==1) { + foreach($OrderLine->SerialItems as $Item) { + /*We need to add the StockSerialItem record and the StockSerialMoves as well */ $SQL = "UPDATE stockserialitems SET quantity= quantity - " . $Item->BundleQty . " WHERE stockid='" . $OrderLine->StockID . "' @@ -1217,7 +1215,7 @@ /*Insert Sales Analysis records */ $SalesValue = 0; - if ($_SESSION['CurrencyRate']>0){ + if($_SESSION['CurrencyRate']>0) { $SalesValue = $OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']; } @@ -1254,12 +1252,12 @@ salesanalysis.budgetoractual"; $ErrMsg = _('The count of existing Sales analysis records could not run because'); - $DbgMsg = '<br />' . _('SQL to count the no of sales analysis records'); + $DbgMsg = '<br />' . _('SQL to count the no of sales analysis records'); $Result = DB_query($SQL,$ErrMsg,$DbgMsg,true); $myrow = DB_fetch_row($Result); - if ($myrow[0]>0){ /*Update the existing record that already exists */ + if($myrow[0]>0) { /*Update the existing record that already exists */ $SQL = "UPDATE salesanalysis SET amt=amt+" . round(($SalesValue),$_SESSION['CompanyRecord']['decimalplaces']) . ", cost=cost+" . round(($OrderLine->StandardCost * $OrderLine->QtyDispatched),$_SESSION['CompanyRecord']['decimalplaces']) . ", @@ -1315,9 +1313,9 @@ /* If GLLink_Stock then insert GLTrans to credit stock and debit cost of sales at standard cost*/ - if ($_SESSION['CompanyRecord']['gllink_stock']==1 AND $OrderLine->StandardCost !=0 AND ! $IsAsset){ + if($_SESSION['CompanyRecord']['gllink_stock']==1 AND $OrderLine->StandardCost !=0 AND ! $IsAsset) { -/*first the cost of sales entry - GL accounts are retrieved using the function GetCOGSGLAccount from includes/GetSalesTransGLCodes.inc */ +/*first the cost of sales entry - GL accounts are retrieved using the function GetCOGSGLAccount from includes/GetSalesTransGLCodes.inc */ $SQL = "INSERT INTO gltrans (type, typeno, @@ -1361,11 +1359,11 @@ $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The stock side of the cost of sales GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the GLTrans record was used'); $Result = DB_query($SQL,$ErrMsg,$DbgMsg,true); - } /* end of if GL and stock integrated and standard cost !=0 and not an asset */ + } /* end of if GL and stock integrated and standard cost !=0 and not an asset */ - if ($_SESSION['CompanyRecord']['gllink_debtors']==1 AND $OrderLine->Price !=0){ + if($_SESSION['CompanyRecord']['gllink_debtors']==1 AND $OrderLine->Price !=0) { - if (!$IsAsset){ // its a normal stock item + if(!$IsAsset) { // its a normal stock item //Post sales transaction to GL credit sales $SalesGLAccounts = GetSalesGLAccount($Area, $OrderLine->StockID, $_SESSION['Items'.$identifier]->DefaultSalesType, $db); @@ -1389,7 +1387,7 @@ $DbgMsg = '<br />' ._('The following SQL to insert the GLTrans record was used'); $Result = DB_query($SQL,$ErrMsg,$DbgMsg,true); - if ($OrderLine->DiscountPercent !=0){ + if($OrderLine->DiscountPercent !=0) { $SQL = "INSERT INTO gltrans (type, typeno, @@ -1429,14 +1427,14 @@ $DisposalResult = DB_query( $SQL,$ErrMsg,$DbgMsg); $DisposalRow = DB_fetch_array($DisposalResult); - /*Need to : - * 1.) debit accum depn account with whole amount of accum depn - * 2.) credit cost account with the whole amount of the cost - * 3.) debit the disposal account with the NBV - * 4.) credit the disposal account with the sale proceeds net of discounts */ + /*Need to : + * 1.) debit accum depn account with whole amount of accum depn + * 2.) credit cost account with the whole amount of the cost + * 3.) debit the disposal account with the NBV + * 4.) credit the disposal account with the sale proceeds net of discounts */ /* 1 debit accum depn */ - if ($DisposalRow['accumdepn']!=0){ + if($DisposalRow['accumdepn']!=0) { $SQL = "INSERT INTO gltrans (type, typeno, trandate, @@ -1457,8 +1455,8 @@ $DbgMsg = _('The following SQL to insert the GLTrans record was used'); $Result = DB_query($SQL,$ErrMsg,$DbgMsg,true); } - /* 2 credit cost */ - if($DisposalRow['cost']!=0){ + /* 2 credit cost */ + if($DisposalRow['cost']!=0) { $SQL = "INSERT INTO gltrans (type, typeno, trandate, @@ -1480,7 +1478,7 @@ $Result = DB_query($SQL,$ErrMsg,$DbgMsg,true); } //3. Debit disposal account with NBV - if($DisposalRow['cost']-$DisposalRow['accumdepn']!=0){ + if($DisposalRow['cost']-$DisposalRow['accumdepn']!=0) { $SQL = "INSERT INTO gltrans (type, typeno, trandate, @@ -1494,7 +1492,7 @@ '" . $DefaultDispatchDate . "', '" . $PeriodNo . "', '" . $DisposalRow['disposalact'] . "', - '" . $_SESSION['Items'.$identifier]->DebtorNo . " - " . $OrderLine->StockID . ' ' . _('net book value disposal') . "', + '" . $_SESSION['Items'.$identifier]->DebtorNo . " - " . $OrderLine->StockID . ' ' . _('net book value disposal') . "', '" . ($DisposalRow['cost']-$DisposalRow['accumdepn']) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The disposal net book value GL posting could not be inserted because'); @@ -1516,7 +1514,7 @@ '" . $DefaultDispatchDate . "', '" . $PeriodNo . "', '" . $DisposalRow['disposalact'] . "', - '" . $_SESSION['Items'.$identifier]->DebtorNo . " - " . $OrderLine->StockID . ' ' . _('asset disposal proceeds') . "', + '" . $_SESSION['Items'.$identifier]->DebtorNo . " - " . $OrderLine->StockID . ' ' . _('asset disposal proceeds') . "', '" . (-$OrderLine->Price * $OrderLine->QtyDispatched* (1 - $OrderLine->DiscountPercent)/$_SESSION['CurrencyRate']) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The disposal proceeds GL posting could not be inserted because'); @@ -1526,7 +1524,7 @@ } // end if the item being sold was an asset } /*end of if sales integrated with debtors */ - if ($IsAsset) { + if($IsAsset) { /* then the item being sold is an asset disposal * need to create fixedassettrans * set disposal date and proceeds @@ -1565,10 +1563,10 @@ } /*end of OrderLine loop */ - if ($_SESSION['CompanyRecord']['gllink_debtors']==1){ + if($_SESSION['CompanyRecord']['gllink_debtors']==1) { /*Post debtors transaction to GL debit debtors, credit freight re-charged and credit sales */ - if (($_SESSION['Items'.$identifier]->total + $_SESSION['Items'.$identifier]->FreightCost + $TaxTotal) !=0) { + if(($_SESSION['Items'.$identifier]->total + $_SESSION['Items'.$identifier]->FreightCost + $TaxTotal) !=0) { $SQL = "INSERT INTO gltrans (type, typeno, trandate, @@ -1592,7 +1590,7 @@ /*Could do with setting up a more flexible freight posting schema that looks at the sales type and area of the customer branch to determine where to post the freight recovery */ - if ($_SESSION['Items'.$identifier]->FreightCost !=0) { + if($_SESSION['Items'.$identifier]->FreightCost !=0) { $SQL = "INSERT INTO gltrans ( type, typeno, @@ -1614,8 +1612,8 @@ $DbgMsg = _('The following SQL to insert the GLTrans record was used'); $Result = DB_query($SQL,$ErrMsg,$DbgMsg,true); } - foreach ( $TaxTotals as $TaxAuthID => $TaxAmount){ - if ($TaxAmount !=0 ){ + foreach ( $TaxTotals as $TaxAuthID => $TaxAmount) { + if($TaxAmount !=0 ) { $SQL = "INSERT INTO gltrans (type, typeno, trandate, @@ -1639,8 +1637,8 @@ } } /*end of if Sales and GL integrated */ EnsureGLEntriesBalance(10,$InvoiceNo,$db); - + DB_Txn_Commit(); // ************************************************************************* // E N D O F I N V O I C E S Q L P R O C E S S I N G @@ -1654,25 +1652,25 @@ echo '<br /><div class="centre">'; - if ($_SESSION['InvoicePortraitFormat']==0){ - echo '<img src="'.$RootPath.'/css/'.$Theme.'/images/printer.png" title="' . _('Print') . '" alt="" />' . ' ' . '<a target="_blank" href="'.$RootPath.'/PrintCustTrans.php?FromTransNo='.$InvoiceNo.'&InvOrCredit=Invoice&PrintPDF=True">' . _('Print this invoice'). ' (' . _('Landscape') . ')</a><br /><br />'; + if($_SESSION['InvoicePortraitFormat']==0) { + echo '<img src="'.$RootPath.'/css/'.$Theme.'/images/printer.png" title="' . _('Print') . '" alt="" />' . ' ' . '<a target="_blank" href="'.$RootPath.'/PrintCustTrans.php?FromTransNo='.$InvoiceNo.'&InvOrCredit=Invoice&PrintPDF=True">' . _('Print this invoice'). ' (' . _('Landscape') . ')</a><br /><br />'; } else { - echo '<img src="'.$RootPath.'/css/'.$Theme.'/images/printer.png" title="' . _('Print') . '" alt="" />' . ' ' . '<a target="_blank" href="'.$RootPath.'/PrintCustTransPortrait.php?FromTransNo='.$InvoiceNo.'&InvOrCredit=Invoice&PrintPDF=True">' . _('Print this invoice'). ' (' . _('Portrait') . ')</a><br /><br />'; + echo '<img src="'.$RootPath.'/css/'.$Theme.'/images/printer.png" title="' . _('Print') . '" alt="" />' . ' ' . '<a target="_blank" href="'.$RootPath.'/PrintCustTransPortrait.php?FromTransNo='.$InvoiceNo.'&InvOrCredit=Invoice&PrintPDF=True">' . _('Print this invoice'). ' (' . _('Portrait') . ')</a><br /><br />'; } - echo '<a href="'.$RootPath.'/SelectSalesOrder.php">' . _('Select another order for invoicing'). '</a><br /><br />'; + echo '<a href="'.$RootPath.'/SelectSalesOrder.php">' . _('Select another order for invoicing'). '</a><br /><br />'; echo '<a href="'.$RootPath.'/SelectOrderItems.php?NewOrder=Yes">' . _('Sales Order Entry') . '</a></div><br />'; /*end of process invoice */ } else { /*Process Invoice not set so allow input of invoice data */ - if (!isset($_POST['Consignment'])) { + if(!isset($_POST['Consignment'])) { $_POST['Consignment']=''; } - if (!isset($_POST['Packages'])) { + if(!isset($_POST['Packages'])) { $_POST['Packages']='1'; } - if (!isset($_POST['InvoiceText'])) { + if(!isset($_POST['InvoiceText'])) { $_POST['InvoiceText']=''; } $j++; Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2016-08-20 04:00:54 UTC (rev 7598) +++ trunk/doc/Change.log 2016-08-21 03:11:43 UTC (rev 7599) @@ -1,5 +1,6 @@ webERP Change Log +20/08/16 RChacon: In ConfirmDispatch_Invoice.php, fix table html code. 18/08/16 RChacon: In PDFStatementPageHeader.inc, replace addJpegFromFile() and RoundRectangle() functions from class.pdf.php with Image() and RoundedRect() functions from tcpdf.php. 18/08/16 Exson: Add a Cancel button on SupplierAllocations.php to make user can return to previous page easily. 18/08/16 Exson: Add date format validation in PcClaimExpensesFromTab.php. |