From: <dai...@us...> - 2010-07-18 09:39:14
|
Revision: 3637 http://web-erp.svn.sourceforge.net/web-erp/?rev=3637&view=rev Author: daintree Date: 2010-07-18 09:39:07 +0000 (Sun, 18 Jul 2010) Log Message: ----------- 18/07/10 Phil: CounterSales.php - was not retrieving ReceiptNumber if the debtor integration was disabled - also the correct period was not retrieved because the date format was not in the correct DateFormat because of a typo in SESSION[DefaultDateFormat] <p>18/07/10 Phil: New script ContractBOM.php to allow defining the bill of materials for a contract Further work on Contracts.php Modified Paths: -------------- trunk/Contracts.php trunk/CounterSales.php trunk/doc/Change.log.html trunk/includes/DefineContractClass.php trunk/includes/DefinePOClass.php Added Paths: ----------- trunk/ContractBOM.php Added: trunk/ContractBOM.php =================================================================== --- trunk/ContractBOM.php (rev 0) +++ trunk/ContractBOM.php 2010-07-18 09:39:07 UTC (rev 3637) @@ -0,0 +1,397 @@ +<?php + +/* $Id: $ */ + +$PageSecurity = 4; + +include('includes/DefineContractClass.php'); + +include('includes/session.inc'); +$title = _('Contract Bill of Materials'); + +$identifier=$_GET['identifier']; + +/* If a contract header doesn't exist, then go to + * Contracts.php to create one + */ + +if (!isset($_SESSION['Contract'.$identifier])){ + header('Location:' . $rootpath . '/Contracts.php?' . SID); + exit; +} +include('includes/header.inc'); + +$Maximum_Number_Of_Parts_To_Show=50; + +if (isset($_POST['UpdateLines']) OR isset($_POST['BackToHeader'])) { + if($_SESSION['Contract'.$identifier]->Status!=2){ //dont do anything if the customer has committed to the contract + foreach ($_SESSION['Contract'.$identifier]->ContractBOM as $ContractComponent) { + if ($_POST['Qty'.$ContractComponent->ComponentID]==0){ + //this is the same as deleting the line - so delete it + $_SESSION['Contract'.$identifier]->remove_ContractComponent($ContractComponent->ComponentID); + } else { + $_SESSION['Contract'.$identifier]->ContractBOM[$ContractComponent->ComponentID]->Quantity=$_POST['Qty'.$ContractComponent->ComponentID]; + } + } // end loop around the items on the contract BOM + } // end if the contract is not currently committed to by the customer +}// end if the user has hit the update lines or back to header buttons + + +if (isset($_POST['BackToHeader'])){ + echo '<meta http-equiv="Refresh" content="0; url=' . $rootpath . '/Contracts.php?' . SID . 'identifier='.$identifier. '">'; + echo '<p>'; + prnMsg(_('You should automatically be forwarded to the Contract page. If this does not happen perhaps the browser does not support META Refresh') . '<a href="' . $rootpath . '/Contracts.php?' . SID. 'identifier='.$identifier . '">' . _('click here') . '</a> ' . _('to continue'),'info'); + include('includes/footer.inc'); + exit; +} + +if (isset($_POST['Search'])){ /*ie seach for stock items */ + + If ($_POST['Keywords'] AND $_POST['StockCode']) { + $msg=_('Stock description keywords have been used in preference to the Stock code extract entered'); + } + If ($_POST['Keywords']) { + //insert wildcard characters in spaces + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; + + if ($_POST['StockCat']=='All'){ + $sql = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE stockmaster.mbflag!='D' + AND stockmaster.mbflag!='A' + AND stockmaster.mbflag!='K' + and stockmaster.discontinued!=1 + AND stockmaster.description " . LIKE . " '$SearchString' + ORDER BY stockmaster.stockid"; + } else { + $sql = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE stockmaster.mbflag!='D' + AND stockmaster.mbflag!='A' + AND stockmaster.mbflag!='K' + and stockmaster.discontinued!=1 + AND stockmaster.description " . LIKE . " '$SearchString' + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + ORDER BY stockmaster.stockid"; + } + + } elseif ($_POST['StockCode']){ + + $_POST['StockCode'] = '%' . $_POST['StockCode'] . '%'; + + if ($_POST['StockCat']=='All'){ + $sql = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE stockmaster.mbflag!='D' + AND stockmaster.mbflag!='A' + AND stockmaster.mbflag!='K' + and stockmaster.discontinued!=1 + AND stockmaster.stockid " . LIKE . " '" . $_POST['StockCode'] . "' + ORDER BY stockmaster.stockid"; + } else { + $sql = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE stockmaster.mbflag!='D' + AND stockmaster.mbflag!='A' + AND stockmaster.mbflag!='K' + and stockmaster.discontinued!=1 + AND stockmaster.stockid " . LIKE . " '" . $_POST['StockCode'] . "' + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + ORDER BY stockmaster.stockid"; + } + + } else { + if ($_POST['StockCat']=='All'){ + $sql = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE stockmaster.mbflag!='D' + AND stockmaster.mbflag!='A' + AND stockmaster.mbflag!='K' + and stockmaster.discontinued!=1 + ORDER BY stockmaster.stockid"; + } else { + $sql = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE stockmaster.mbflag!='D' + AND stockmaster.mbflag!='A' + AND stockmaster.mbflag!='K' + and stockmaster.discontinued!=1 + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + ORDER BY stockmaster.stockid"; + } + } + + $ErrMsg = _('There is a problem selecting the part records to display because'); + $DbgMsg = _('The SQL statement that failed was'); + $SearchResult = DB_query($sql,$db,$ErrMsg,$DbgMsg); + + if (DB_num_rows($SearchResult)==0 && $debug==1){ + prnMsg( _('There are no products to display matching the criteria provided'),'warn'); + } + if (DB_num_rows($SearchResult)==1){ + $myrow=DB_fetch_array($SearchResult); + $_GET['NewItem'] = $myrow['stockid']; + DB_data_seek($SearchResult,0); + } + +} //end of if search + + +if(isset($_GET['Delete'])){ + if($_SESSION['Contract'.$identifier]->Status!=2){ + $_SESSION['Contract'.$identifier]->remove_ContractComponent($_GET['Delete']); + } else { + prnMsg( _('The contract BOM cannot be alterned because the customer has already placed the order'),'warn'); + } +} + + + +if (isset($_POST['NewItem'])){ /* NewItem is set from the part selection list as the part code selected */ +/* take the form entries and enter the data from the form into the PurchOrder class variable */ + foreach ($_POST as $key => $value) { + if (substr($key, 0, 3)=='qty') { + $ItemCode=substr($key, 3, strlen($key)-3); + $Quantity=$value; + $AlreadyOnThisBOM = 0; + + if (count($_SESSION['Contract'.$identifier]->ContractBOM)!=0){ + + foreach ($_SESSION['Contract'.$identifier]->ContractBOM AS $Component) { + + /* do a loop round the items on the order to see that the item + is not already on this order */ + if ($Component->StockID == $ItemCode) { + $AlreadyOnThisBOM = 1; + prnMsg( _('The item') . ' ' . $ItemCode . ' ' . _('is already in the bill of material for this contract. The system will not allow the same item on the contract more than once. However you can change the quantity required for the item.'),'error'); + } + } /* end of the foreach loop to look for preexisting items of the same code */ + } + + if ($AlreadyOnThisBOM!=1 and $Quantity>0){ + + $sql = "SELECT stockmaster.description, + stockmaster.stockid, + stockmaster.units, + stockmaster.decimalplaces, + stockmaster.materialcost+labourcost+overheadcost AS unitcost + FROM stockmaster + WHERE stockmaster.stockid = '". $ItemCode . "'"; + + $ErrMsg = _('The item details could not be retrieved'); + $DbgMsg = _('The SQL used to retrieve the item details but failed was'); + $result1 = DB_query($sql,$db,$ErrMsg,$DbgMsg); + + if ($myrow = DB_fetch_array($result1)){ + + $_SESSION['Contract'.$identifier]->Add_To_ContractBOM ($ItemCode, + $myrow['description'], + $DefaultWorkCentre, + $Quantity, /* Qty */ + $myrow['unitcost'], + $myrow['units']); + } else { + prnMsg (_('The item code') . ' ' . $ItemCode . ' ' . _('does not exist in the database and therefore cannot be added to the contract BOM'),'error'); + if ($debug==1){ + echo "<br>".$sql; + } + include('includes/footer.inc'); + exit; + } + } /* end of if not already on the contract BOM */ + } + } +} /* end of if its a new item */ + +/* This is where the order as selected should be displayed reflecting any deletions or insertions*/ + +echo '<form name="ContractBOMForm" action="' . $_SERVER['PHP_SELF'] . '?' . SID . 'identifier='.$identifier. '" method="post">'; + +if (count($_SESSION['Contract'.$identifier]->ContractBOM)>0){ + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . + _('Contract Bill of Material') . '" alt=""> '.$_SESSION['Contract'.$identifier]->CustomerName; + + if (isset($_SESSION['Contract'.$identifier]->ContractRef)) { + echo ' ' . _('Contract Reference:') .' '. $_SESSION['Contract'.$identifier]->ContractRef; + } + + echo '<table cellpadding=2 colspan=7 border=1>'; + echo '<tr> + <th>' . _('Item Code') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Quantity') . '</th> + <th>' . _('UOM') .'</th> + <th>' . _('Unit Cost') . '</th> + <th>' . _('Sub-total') . '</th> + </tr>'; + + $_SESSION['Contract'.$identifier]->total = 0; + $k = 0; //row colour counter + $TotalCost =0; + foreach ($_SESSION['Contract'.$identifier]->ContractBOM as $ContractComponent) { + + $LineTotal = $ContractComponent->Quantity * $ContractComponent->ItemCost; + + $DisplayLineTotal = number_format($LineTotal,2); + + if ($k==1){ + echo '<tr class="EvenTableRows">'; + $k=0; + } else { + echo '<tr class="OddTableRows">'; + $k=1; + } + + echo '<td>' . $ContractComponent->StockID . '</td> + <td>' . $ContractComponent->ItemDescription . '</td> + <td><input type=text class="number" name="Qty' . $ContractComponent->ComponentID . '" size="11" value="' . $ContractComponent->Quantity . '"></td> + <td>' . $ContractComponent->UOM . '</td> + <td class="number">' . $ContractComponent->ItemCost . '</td> + <td class="number">' . $DisplayLineTotal . '</td> + <td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . 'identifier='.$identifier. '&Delete=' . $ContractComponent->ComponentID . '">' . _('Delete') . '</a></td></tr>'; + $TotalCost += $LineTotal; + } + + $DisplayTotal = number_format($TotalCost,2); + echo '<tr><td colspan=6 class="number">' . _('Total Cost') . '</td><td class="number"><b>' . $DisplayTotal . '</b></td></tr></table>'; + echo '<br><div class="centre"><input type="submit" name="UpdateLines" value="' . _('Update Order Lines') . '">'; + echo ' <input type="submit" name="BackToHeader" value="' . _('Back To Contract Header') . '">'; + +} /*Only display the contract BOM lines if there are any !! */ + +if (!isset($_GET['Edit'])) { + $sql="SELECT categoryid, + categorydescription + FROM stockcategory + WHERE stocktype<>'L' + AND stocktype<>'D' + ORDER BY categorydescription"; + $ErrMsg = _('The supplier category details could not be retrieved because'); + $DbgMsg = _('The SQL used to retrieve the category details but failed was'); + $result1 = DB_query($sql,$db,$ErrMsg,$DbgMsg); + + echo '<table class=selection><tr><p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/magnifier.png" title="' . + _('Print') . '" alt="">' . ' ' . _('Search For Stock Items') . ''; + + echo ":</font></tr><tr><td><select name='StockCat'>"; + + echo "<option selected value='All'>" . _('All'); + while ($myrow1 = DB_fetch_array($result1)) { + if (isset($_POST['StockCat']) and $_POST['StockCat']==$myrow1['categoryid']){ + echo "<option selected value=". $myrow1['categoryid'] . '>' . $myrow1['categorydescription']; + } else { + echo "<option value=". $myrow1['categoryid'] . '>' . $myrow1['categorydescription']; + } + } + + unset($_POST['Keywords']); + unset($_POST['StockCode']); + + if (!isset($_POST['Keywords'])) { + $_POST['Keywords']=''; + } + + if (!isset($_POST['StockCode'])) { + $_POST['StockCode']=''; + } + + echo '</select></td> + <td><font size=2>' . _('Enter text extracts in the description') . ":</font></td> + <td><input type='text' name='Keywords' size=20 maxlength=25 value='" . $_POST['Keywords'] . "'></td></tr> + <tr><td></td> + <td><font size=3><b>" . _('OR') . ' </b></font><font size=2>' . _('Enter extract of the Stock Code') . + ":</font></td> + <td><input type='text' name='StockCode' size=15 maxlength=18 value='" . $_POST['StockCode'] . "'></td> + </tr> + <tr><td></td> + <td><font size=3><b>" . _('OR') . ' </b></font><font size=2><a target="_blank" href="'.$rootpath.'/Stocks.php?"' . SID . + '">' . _('Create a New Stock Item') . "</a></font></td></tr> + </table><br> + <div class='centre'><input type=submit name='Search' value='" . _('Search Now') . "'> + </div><br>"; + + + $PartsDisplayed =0; +} + +if (isset($SearchResult)) { + + echo '<table cellpadding=1 colspan=7>'; + + $tableheader = '<tr> + <th>' . _('Code') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Units') . '</th> + <th>' . _('Image') . '</th> + <th>' . _('Quantity') . '</th + </tr>'; + echo $tableheader; + + $j = 1; + $k=0; //row colour counter + + while ($myrow=DB_fetch_array($SearchResult)) { + + if ($k==1){ + echo '<tr class="EvenTableRows">'; + $k=0; + } else { + echo '<tr class="OddTableRows">'; + $k=1; + } + + $filename = $myrow['stockid'] . '.jpg'; + if (file_exists( $_SESSION['part_pics_dir'] . '/' . $filename) ) { + $ImageSource = '<img src="'.$rootpath . '/' . $_SESSION['part_pics_dir'] . '/' . $filename . '" width="50" height="50">'; + } else { + $ImageSource = '<i>'._('No Image').'</i>'; + } + + echo '<td>'.$myrow['stockid'].'</td> + <td>'.$myrow['description'].'</td> + <td>'.$myrow['units'] . '</td> + <td>'.$ImageSource.'</td> + <td><input class="number" type="text" size="6" value="0" name="qty'.$myrow['stockid'].'"></td> + </tr>'; + + $PartsDisplayed++; + if ($PartsDisplayed == $Maximum_Number_Of_Parts_To_Show){ + break; + } +#end of page full new headings if + } +#end of while loop + echo '</table>'; + if ($PartsDisplayed == $Maximum_Number_Of_Parts_To_Show){ + + /*$Maximum_Number_Of_Parts_To_Show defined in config.php */ + + prnMsg( _('Only the first') . ' ' . $Maximum_Number_Of_Parts_To_Show . ' ' . _('can be displayed') . '. ' . + _('Please restrict your search to only the parts required'),'info'); + } + echo '<br><div class="centre"><input type="submit" name="NewItem" value="' . _('Add to Contract Bill Of Material') .'"></div>'; +}#end if SearchResults to show + +echo '<hr>'; + +echo '</form>'; +include('includes/footer.inc'); +?> \ No newline at end of file Modified: trunk/Contracts.php =================================================================== --- trunk/Contracts.php 2010-07-18 08:11:03 UTC (rev 3636) +++ trunk/Contracts.php 2010-07-18 09:39:07 UTC (rev 3637) @@ -33,11 +33,8 @@ $identifier=$_GET['identifier']; } -/*Page is called with NewContract=Yes when a new order is to be entered - * the session variable that holds all the Contract data $_SESSION['Contract'][$identifier] - * is unset to allow all new details to be created */ -if (isset($_GET['NewContract']) and isset($_SESSION['Contract'.$identifier])){ +if (isset($_GET['NewContract']) AND isset($_SESSION['Contract'.$identifier])){ unset($_SESSION['Contract'.$identifier]); $_SESSION['ExistingContract'] = 0; } @@ -53,21 +50,21 @@ /* initialize new class object */ $_SESSION['Contract'.$identifier] = new Contract; - $_SESSION['RequireCustomerSelection'] = 0; $_POST['SelectedCustomer'] = $_GET['SelectedCustomer']; + + $_SESSION['Contract'.$identifier]->Status =0; /*The customer is checked for credit and the Contract Object populated * using the usual logic of when a customer is selected * */ } -if (isset($_POST['EnterContractBOM']) OR isset($_POST['EnterContractRequirements'])){ -/*User hit the button to enter line items - - * ensure session variables updated then meta refresh to Contract_Items.php*/ - +if(isset($_SESSION['Contract'.$identifier]) AND + (isset($_POST['EnterContractBOM']) + OR isset($_POST['EnterContractRequirements']))){ + /** Ensure session variables updated */ + $_SESSION['Contract'.$identifier]->ContractRef=$_POST['ContractRef']; $_SESSION['Contract'.$identifier]->ContractDescription=$_POST['ContractDescription']; - $_SESSION['Contract'.$identifier]->DebtorNo = $_POST['DebtorNo']; - $_SESSION['Contract'.$identifier]->BranchCode = $_POST['BranchCode']; $_SESSION['Contract'.$identifier]->CategoryID = $_POST['CategoryID']; $_SESSION['Contract'.$identifier]->RequiredDate = $_POST['RequiredDate']; $_SESSION['Contract'.$identifier]->Margin = $_POST['Margin']; @@ -75,8 +72,18 @@ $_SESSION['Contract'.$identifier]->QuantityReqd = $_POST['QuantityReqd']; $_SESSION['Contract'.$identifier]->Units = $_POST['Units']; $_SESSION['Contract'.$identifier]->ExRate = $_POST['ExRate']; - if (isset($_POST['EnterContractBOM'])){ - echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . '/Contract_Items.php?' . SID . 'identifier='.$identifier. "'>"; + + +/*User hit the button to enter line items - + then meta refresh to Contract_Items.php*/ + $InputError = false; + if(strlen($_SESSION['Contract'.$identifier]->ContractRef)<2){ + prnMsg(_('The contract reference must be entered (and be longer than 2 characters) before the requirements of the contract can be setup'),'warn'); + $InputError = true; + } + + if (isset($_POST['EnterContractBOM']) AND !$InputError){ + echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . '/ContractBOM.php?' . SID . 'identifier='.$identifier. "'>"; echo '<p>'; prnMsg(_('You should automatically be forwarded to the entry of the Contract line items page') . '. ' . _('If this does not happen') . ' (' . _('if the browser does not support META Refresh') . ') ' . @@ -84,7 +91,7 @@ include('includes/footer.inc'); exit; } - if (isset($_POST['EnterContractRequirements'])){ + if (isset($_POST['EnterContractRequirements']) AND !$InputError){ echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . '/ContractRequirements.php?' . SID . 'identifier='.$identifier. "'>"; echo '<p>'; prnMsg(_('You should automatically be forwarded to the entry of the Contract requirements page') . '. ' . @@ -95,7 +102,7 @@ } } /* end of if going to contract BOM or contract requriements */ -echo '<a href="'. $rootpath . '/ContractSelect.php?' . SID . "identifier=".$identifier.'">'. _('Back to Contracts'). '</a><br>'; +echo '<a href="'. $rootpath . '/ContractSelect.php?' . SID . 'identifier='.$identifier.'">'. _('Back to Contracts'). '</a><br>'; //attempting to upload the drawing image file if (isset($_FILES['Drawing']) AND $_FILES['Drawing']['name'] !='' AND $_SESSION['Contract'.$identifier]->ContractRef!='') { @@ -256,21 +263,18 @@ $ErrMsg = _('The contract bill of materials could not be deleted because'); $DelResult=DB_query($sql,$db,$ErrMsg); $sql = "DELETE FROM contractreqts WHERE contractref='" . $_SESSION['Contract'.$identifier]->ContractRef . "'"; - $ErrMsg = _('The contract requirments could not be deleted because'); + $ErrMsg = _('The contract requirements could not be deleted because'); $DelResult=DB_query($sql,$db,$ErrMsg); $sql= "DELETE FROM contracts WHERE contractref='" . $_SESSION['Contract'.$identifier]->ContractRef . "'"; $ErrMsg = _('The contract could not be deleted because'); $DelResult=DB_query($sql,$db,$ErrMsg); prnMsg( _('Contract').' '.$_SESSION['Contract'.$identifier]->ContractRef.' '._('has been cancelled'), 'success'); - unset($_SESSION['Contract'.$identifier]); unset($_SESSION['ExistingContract']); } unset($_SESSION['Contract'.$identifier]->ContractBOM); unset($_SESSION['Contract'.$identifier]->ContractReqts); unset($_SESSION['Contract'.$identifier]); - $_SESSION['Contract'.$identifier] = new Contract; - $_SESSION['RequireCustomerSelection'] = 1; } } @@ -284,6 +288,8 @@ $_SESSION['ExistingContract']= 0; $_SESSION['Contract'.$identifier] = new Contract; + $_SESSION['Contract'.$identifier]->Status = 0; //new contracts are just quotes ... + if ($_SESSION['Contract'.$identifier]->DebtorNo=='' OR !isset($_SESSION['Contract'.$identifier]->DebtorNo)){ /* a session variable will have to maintain if a supplier @@ -428,8 +434,7 @@ " . $Requirement->Quantity . ")"; $result = DB_query($sql,$db,$ErrMsg); } - - + prnMsg(_('The changes to the contract have been committed to the database'),'success'); } if ($ExistingContract['status']==1 AND ! $InputError){ @@ -638,8 +643,7 @@ } //end if a customer has just been selected -if ($_SESSION['RequireCustomerSelection'] == 1 - OR !isset($_SESSION['Contract'.$identifier]->DebtorNo) +if (!isset($_SESSION['Contract'.$identifier]->DebtorNo) OR $_SESSION['Contract'.$identifier]->DebtorNo=='' ) { echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/customer.png" title="' . @@ -724,9 +728,6 @@ } echo '</p>'; - //echo '<meta http-equiv="refresh" content="0; url=' . $rootpath . '/Contract_Items.php?' . SID . '&identifier='.$identifier. '">'; - - /*Set up form for entry of contract header stuff */ echo '<table>'; @@ -799,7 +800,7 @@ echo '<tr><td>' . _('Contract Status') . ':</td><td><select name="Status">'; $StatusText = array(); - $StatusText[0] = _('Costing'); + $StatusText[0] = _('Setup'); $StatusText[1] = _('Quote'); $StatusText[2] = _('Completed'); for ($Status=0;$Status<3;$Status++) { @@ -868,7 +869,7 @@ echo'<p></p>'; echo '<div class="centre"><input type="submit" name="EnterContractBOM" value="' . _('Enter Items Required') . '"> - <input type=submit name="EnterContractReqts" value="' . _('Enter Other Requirements') .'"> + <input type=submit name="EnterContractRequirements" value="' . _('Enter Other Requirements') .'"> <input type=submit name="CommitContract" value="' . _('Commit Changes') .'"></div>'; if ($_SESSION['Contract'.$identifier]->Status!=2) { echo '<p><div class="centre"><input type="submit" name="CancelContract" value="' . _('Cancel and Delete Contract') . '"></div></p>'; Modified: trunk/CounterSales.php =================================================================== --- trunk/CounterSales.php 2010-07-18 08:11:03 UTC (rev 3636) +++ trunk/CounterSales.php 2010-07-18 09:39:07 UTC (rev 3637) @@ -1148,7 +1148,7 @@ * GetPeriod() in includes/DateFunctions.inc */ $InvoiceNo = GetNextTransNo(10, $db); - $PeriodNo = GetPeriod(Date($SESSION['DefaultDateFormat']), $db); + $PeriodNo = GetPeriod(Date($_SESSION['DefaultDateFormat']), $db); /*Start an SQL transaction */ @@ -1774,106 +1774,111 @@ $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); }//amount paid we not zero } /*end of if Sales and GL integrated */ - //Now need to add the receipt banktrans record - //First get the account currency that it has been banked into - $result = DB_query("SELECT rate FROM currencies - INNER JOIN bankaccounts ON currencies.currabrev=bankaccounts.currcode - WHERE bankaccounts.accountcode='" . $_POST['BankAccount'] . "'",$db); - $myrow = DB_fetch_row($result); - $BankAccountExRate = $myrow[0]; + if ($_POST['AmountPaid']!=0){ + if (!isset($ReceiptNumber)){ + $ReceiptNumber = GetNextTransNo(12,$db); + } + //Now need to add the receipt banktrans record + //First get the account currency that it has been banked into + $result = DB_query("SELECT rate FROM currencies + INNER JOIN bankaccounts ON currencies.currabrev=bankaccounts.currcode + WHERE bankaccounts.accountcode='" . $_POST['BankAccount'] . "'",$db); + $myrow = DB_fetch_row($result); + $BankAccountExRate = $myrow[0]; + + /* + * Some interesting exchange rate conversion going on here + * Say : + * The business's functional currency is NZD + * Customer location counter sales are in AUD - 1 NZD = 0.80 AUD + * Banking money into a USD account - 1 NZD = 0.68 USD + * + * Customer sale is for $100 AUD + * GL entries conver the AUD 100 to NZD - 100 AUD / 0.80 = $125 NZD + * Banktrans entries convert the AUD 100 to USD using 100/0.8 * 0.68 + */ + + //insert the banktrans record in the currency of the bank account + + $SQL='INSERT INTO banktrans (type, + transno, + bankact, + ref, + exrate, + functionalexrate, + transdate, + banktranstype, + amount, + currcode) + VALUES (12, + ' . $ReceiptNumber . ', + ' . $_POST['BankAccount'] . ", + '" . $_SESSION['Items'.$identifier]->LocationName . ' ' . _('Counter Sale') . ' ' . $InvoiceNo . "', + " . $ExRate . ", + " . $BankAccountExRate . ", + '" . $DefaultDispatchDate . "', + '" . $_POST['PaymentMethod'] . "', + " . ($_POST['AmountPaid'] * $BankAccountExRate) . ", + '" . $_SESSION['Items'.$identifier]->DefaultCurrency . "')"; + + $DbgMsg = _('The SQL that failed to insert the bank account transaction was'); + $ErrMsg = _('Cannot insert a bank transaction'); + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - /* - * Some interesting exchange rate conversion going on here - * Say : - * The business's functional currency is NZD - * Customer location counter sales are in AUD - 1 NZD = 0.80 AUD - * Banking money into a USD account - 1 NZD = 0.68 USD - * - * Customer sale is for $100 AUD - * GL entries conver the AUD 100 to NZD - 100 AUD / 0.80 = $125 NZD - * Banktrans entries convert the AUD 100 to USD using 100/0.8 * 0.68 - */ - - //insert the banktrans record in the currency of the bank account - - $SQL='INSERT INTO banktrans (type, - transno, - bankact, - ref, - exrate, - functionalexrate, - transdate, - banktranstype, - amount, - currcode) - VALUES (12, - ' . $ReceiptNumber . ', - ' . $_POST['BankAccount'] . ", - '" . $_SESSION['Items'.$identifier]->LocationName . ' ' . _('Counter Sale') . ' ' . $InvoiceNo . "', - " . $ExRate . ", - " . $BankAccountExRate . ", - '" . $DefaultDispatchDate . "', - '" . $_POST['PaymentMethod'] . "', - " . ($_POST['AmountPaid'] * $BankAccountExRate) . ", - '" . $_SESSION['Items'.$identifier]->DefaultCurrency . "')"; - - $DbgMsg = _('The SQL that failed to insert the bank account transaction was'); - $ErrMsg = _('Cannot insert a bank transaction'); - $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + //insert a new debtortrans for the receipt + + $SQL = 'INSERT INTO debtortrans (transno, + type, + debtorno, + trandate, + inputdate, + prd, + reference, + rate, + ovamount, + alloc, + invtext) + VALUES (' . $ReceiptNumber . ", + 12, + '" . $_SESSION['Items'.$identifier]->DebtorNo . "', + '" . $DefaultDispatchDate . "', + '" . date('Y-m-d H-i-s') . "', + " . $PeriodNo . ", + " . $InvoiceNo . ", + " . $ExRate . ", + " . -$_POST['AmountPaid'] . ", + " . -$_POST['AmountPaid'] . ", + '" . $_SESSION['Items'.$identifier]->LocationName . ' ' . _('Counter Sale') ."')"; + + $DbgMsg = _('The SQL that failed to insert the customer receipt transaction was'); + $ErrMsg = _('Cannot insert a receipt transaction against the customer because') ; + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - //insert a new debtortrans for the receipt + $ReceiptDebtorTransID = DB_Last_Insert_ID($db,'debtortrans','id'); + + $SQL = "UPDATE debtorsmaster SET lastpaiddate = '" . $DefaultDispatchDate . "', + lastpaid=" . $_POST['AmountPaid'] ." + WHERE debtorsmaster.debtorno='" . $_SESSION['Items'.$identifier]->DebtorNo . "'"; + + $DbgMsg = _('The SQL that failed to update the date of the last payment received was'); + $ErrMsg = _('Cannot update the customer record for the date of the last payment received because'); + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + + //and finally add the allocation record between receipt and invoice + + $SQL = 'INSERT INTO custallocns ( amt, + datealloc, + transid_allocfrom, + transid_allocto ) + VALUES (' . $_POST['AmountPaid'] . ", + '" . $DefaultDispatchDate . "', + " . $ReceiptDebtorTransID . ", + " . $DebtorTransID . ')'; + $DbgMsg = _('The SQL that failed to insert the allocation of the receipt to the invoice was'); + $ErrMsg = _('Cannot insert the customer allocation of the receipt to the invoice because'); + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + } //end if $_POST['AmountPaid']!= 0 - $SQL = 'INSERT INTO debtortrans (transno, - type, - debtorno, - trandate, - inputdate, - prd, - reference, - rate, - ovamount, - alloc, - invtext) - VALUES (' . $ReceiptNumber . ", - 12, - '" . $_SESSION['Items'.$identifier]->DebtorNo . "', - '" . $DefaultDispatchDate . "', - '" . date('Y-m-d H-i-s') . "', - " . $PeriodNo . ", - " . $InvoiceNo . ", - " . $ExRate . ", - " . -$_POST['AmountPaid'] . ", - " . -$_POST['AmountPaid'] . ", - '" . $_SESSION['Items'.$identifier]->LocationName . ' ' . _('Counter Sale') ."')"; - - $DbgMsg = _('The SQL that failed to insert the customer receipt transaction was'); - $ErrMsg = _('Cannot insert a receipt transaction against the customer because') ; - $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - - $ReceiptDebtorTransID = DB_Last_Insert_ID($db,'debtortrans','id'); - - $SQL = "UPDATE debtorsmaster SET lastpaiddate = '" . $DefaultDispatchDate . "', - lastpaid=" . $_POST['AmountPaid'] ." - WHERE debtorsmaster.debtorno='" . $_SESSION['Items'.$identifier]->DebtorNo . "'"; - - $DbgMsg = _('The SQL that failed to update the date of the last payment received was'); - $ErrMsg = _('Cannot update the customer record for the date of the last payment received because'); - $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - - //and finally add the allocation record between receipt and invoice - - $SQL = 'INSERT INTO custallocns ( amt, - datealloc, - transid_allocfrom, - transid_allocto ) - VALUES (' . $_POST['AmountPaid'] . ", - '" . $DefaultDispatchDate . "', - " . $ReceiptDebtorTransID . ", - " . $DebtorTransID . ')'; - $DbgMsg = _('The SQL that failed to insert the allocation of the receipt to the invoice was'); - $ErrMsg = _('Cannot insert the customer allocation of the receipt to the invoice because'); - $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - DB_Txn_Commit($db); // ************************************************************************* // 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 Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-18 08:11:03 UTC (rev 3636) +++ trunk/doc/Change.log.html 2010-07-18 09:39:07 UTC (rev 3637) @@ -1,5 +1,8 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>18/07/10 Phil: CounterSales.php - was not retrieving ReceiptNumber if the debtor integration was disabled - also the correct period was not retrieved because the date format was not in the correct DateFormat because of a typo in SESSION['DefaultDateFormat'] +<p>18/07/10 Phil: New script ContractBOM.php to allow defining the bill of materials for a contract +<p>18/07/10 Phil: Further work on Contracts.php <p>17/07/10 Tim: PaymentTerms.php - Bug fixes, SQL quoting and layout changes</p> <p>17/07/10 Tim: Payments.php - Bug fixes, SQL quoting and layout changes</p> <p>17/07/10 Tim: PaymentMethods.php - SQL quoting and layout changes</p> Modified: trunk/includes/DefineContractClass.php =================================================================== --- trunk/includes/DefineContractClass.php 2010-07-18 08:11:03 UTC (rev 3636) +++ trunk/includes/DefineContractClass.php 2010-07-18 09:39:07 UTC (rev 3637) @@ -41,7 +41,8 @@ function Add_To_ContractBOM($StockID, $ItemDescription, $WorkCentre, $Quantity, $ItemCost, $UOM){ if (isset($StockID) AND $Quantity!=0){ - $this->ContractBOM[$this->BOMComponentCounter] = new ContractComponent($StockID, + $this->ContractBOM[$this->BOMComponentCounter] = new ContractComponent($this->BOMComponentCounter, + $StockID, $ItemDescription, $WorkCentre, $Quantity, @@ -76,7 +77,7 @@ } /* end of class defintion */ Class ContractComponent { - + var $ComponentID; var $StockID; var $ItemDescription; var $WorkCentre; @@ -84,9 +85,10 @@ var $ItemCost; var $UOM; - function ContractComponent ($StockID, $ItemDescription, $WorkCentre, $Quantity, $ItemCost, $UOM){ + function ContractComponent ($ComponentID, $StockID, $ItemDescription, $WorkCentre, $Quantity, $ItemCost, $UOM){ /* Constructor function to add a new Contract Component object with passed params */ + $this->ComponentID = $ComponentID; $this->StockID = $StockID; $this->ItemDescription = $ItemDescription; $this->WorkCentre = $WorkCentre; Modified: trunk/includes/DefinePOClass.php =================================================================== --- trunk/includes/DefinePOClass.php 2010-07-18 08:11:03 UTC (rev 3636) +++ trunk/includes/DefinePOClass.php 2010-07-18 09:39:07 UTC (rev 3637) @@ -96,17 +96,17 @@ $DecimalPlaces=2, $itemno, $uom, - $ConversionFactor, - $leadtime, - $suppliers_partno, - $subtotal_amount, - $package, - $pcunit, - $nw, - $gw, - $cuft, - $total_quantity, - $total_amount){ + $ConversionFactor=1, + $leadtime=1, + $suppliers_partno='', + $subtotal_amount=0, + $package=0, + $pcunit=0, + $nw=0, + $gw=0, + $cuft=0, + $total_quantity=0, + $total_amount=0){ if ($Qty!=0 && isset($Qty)){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |