From: <tim...@us...> - 2010-05-12 05:23:48
|
Revision: 3458 http://web-erp.svn.sourceforge.net/web-erp/?rev=3458&view=rev Author: tim_schofield Date: 2010-05-12 05:23:41 +0000 (Wed, 12 May 2010) Log Message: ----------- Tim: Exit MRP scripts gracefully if no MRP calculation has been done. Modified Paths: -------------- trunk/MRPPlannedPurchaseOrders.php trunk/MRPPlannedWorkOrders.php trunk/MRPReschedules.php trunk/MRPShortages.php trunk/doc/Change.log.html Modified: trunk/MRPPlannedPurchaseOrders.php =================================================================== --- trunk/MRPPlannedPurchaseOrders.php 2010-05-08 11:29:25 UTC (rev 3457) +++ trunk/MRPPlannedPurchaseOrders.php 2010-05-12 05:23:41 UTC (rev 3458) @@ -5,7 +5,18 @@ // purchase orders created for them $PageSecurity = 2; include('includes/session.inc'); -If (isset($_POST['PrintPDF'])) { +$sql='show tables where Tables_in_'.$_SESSION['DatabaseName'].'="mrprequirements"'; +$result=DB_query($sql,$db); +if (DB_num_rows($result)==0) { + $title='MRP error'; + include('includes/header.inc'); + echo '<br>'; + prnMsg( _('The MRP calculation must be run before you can run this report').'<br>'. + _('To run the MRP calculation click').' '.'<a href='.$rootpath .'/MRP.php?' . SID .'>'._('here').'</a>', 'error'); + include('includes/footer.inc'); + exit; +} +if (isset($_POST['PrintPDF'])) { include('includes/PDFStarter.php'); $pdf->addInfo('Title',_('MRP Planned Purchase Orders Report')); Modified: trunk/MRPPlannedWorkOrders.php =================================================================== --- trunk/MRPPlannedWorkOrders.php 2010-05-08 11:29:25 UTC (rev 3457) +++ trunk/MRPPlannedWorkOrders.php 2010-05-12 05:23:41 UTC (rev 3458) @@ -5,7 +5,18 @@ // work orders created for them $PageSecurity = 2; include('includes/session.inc'); -If (isset($_POST['PrintPDF'])) { +$sql='show tables where Tables_in_'.$_SESSION['DatabaseName'].'="mrprequirements"'; +$result=DB_query($sql,$db); +if (DB_num_rows($result)==0) { + $title='MRP error'; + include('includes/header.inc'); + echo '<br>'; + prnMsg( _('The MRP calculation must be run before you can run this report').'<br>'. + _('To run the MRP calculation click').' '.'<a href='.$rootpath .'/MRP.php?' . SID .'>'._('here').'</a>', 'error'); + include('includes/footer.inc'); + exit; +} +if (isset($_POST['PrintPDF'])) { include('includes/PDFStarter.php'); Modified: trunk/MRPReschedules.php =================================================================== --- trunk/MRPReschedules.php 2010-05-08 11:29:25 UTC (rev 3457) +++ trunk/MRPReschedules.php 2010-05-12 05:23:41 UTC (rev 3458) @@ -8,7 +8,18 @@ $PageSecurity = 2; include('includes/session.inc'); -If (isset($_POST['PrintPDF'])) { +$sql='show tables where Tables_in_'.$_SESSION['DatabaseName'].'="mrprequirements"'; +$result=DB_query($sql,$db); +if (DB_num_rows($result)==0) { + $title='MRP error'; + include('includes/header.inc'); + echo '<br>'; + prnMsg( _('The MRP calculation must be run before you can run this report').'<br>'. + _('To run the MRP calculation click').' '.'<a href='.$rootpath .'/MRP.php?' . SID .'>'._('here').'</a>', 'error'); + include('includes/footer.inc'); + exit; +} +if (isset($_POST['PrintPDF'])) { include('includes/PDFStarter.php'); $pdf->addInfo('Title',_('MRP Reschedule Report')); @@ -64,29 +75,29 @@ $YPos -=$line_height; $FontSize=8; - + $FormatedDueDate = ConvertSQLDate($myrow['duedate']); $FormatedMRPDate = ConvertSQLDate($myrow['mrpdate']); if ($myrow['mrpdate'] == '2050-12-31') { $FormatedMRPDate = 'Cancel'; } - + // Use to alternate between lines with transparent and painted background if ($_POST['Fill'] == 'yes'){ $fill=!$fill; } - + // Parameters for addTextWrap are defined in /includes/class.pdf.php // 1) X position 2) Y position 3) Width // 4) Height 5) Text 6) Alignment 7) Border 8) Fill - True to use SetFillColor // and False to set to transparent - $pdf->addTextWrap($Left_Margin,$YPos,90,$FontSize,$myrow['part'],'',0,$fill); + $pdf->addTextWrap($Left_Margin,$YPos,90,$FontSize,$myrow['part'],'',0,$fill); $pdf->addTextWrap(130,$YPos,200,$FontSize,$myrow['description'],'',0,$fill); $pdf->addTextWrap(330,$YPos,50,$FontSize,$myrow['orderno'],'right',0,$fill); $pdf->addTextWrap(380,$YPos,30,$FontSize,$myrow['ordertype'],'right',0,$fill); $pdf->addTextWrap(410,$YPos,50,$FontSize,number_format($myrow['supplyquantity'], $myrow['decimalplaces']),'right',0,$fill); - $pdf->addTextWrap(460,$YPos,55,$FontSize,$FormatedDueDate,'right',0,$fill); + $pdf->addTextWrap(460,$YPos,55,$FontSize,$FormatedDueDate,'right',0,$fill); $pdf->addTextWrap(515,$YPos,50,$FontSize,$FormatedMRPDate,'right',0,$fill); if ($YPos < $Bottom_Margin + $line_height){ @@ -125,13 +136,13 @@ header('Expires: 0'); header('Cache-Control: private, post-check=0, pre-check=0'); header('Pragma: public'); - + $pdf->Output('MRPRescedules.pdf', 'I'); } */ $pdf->OutputD($_SESSION['DatabaseName'] . '_MRPReschedules_' . date('Y-m-d').'.pdf');//UldisN $pdf->__destruct(); //UldisN - + } else { /*The option to print PDF was not hit so display form */ $title=_('MRP Reschedule Reporting'); @@ -171,7 +182,7 @@ $YPos -=$line_height; $pdf->addTextWrap($Left_Margin,$YPos,300,$FontSize,_('MRP Reschedule Report')); -$pdf->addTextWrap($Page_Width-$Right_Margin-115,$YPos,160,$FontSize,_('Printed') . ': ' . +$pdf->addTextWrap($Page_Width-$Right_Margin-115,$YPos,160,$FontSize,_('Printed') . ': ' . Date($_SESSION['DefaultDateFormat']) . ' ' . _('Page') . ' ' . $PageNumber); $YPos -=$line_height; $pdf->addTextWrap($Left_Margin,$YPos,70,$FontSize,_('Selection:')); Modified: trunk/MRPShortages.php =================================================================== --- trunk/MRPShortages.php 2010-05-08 11:29:25 UTC (rev 3457) +++ trunk/MRPShortages.php 2010-05-12 05:23:41 UTC (rev 3458) @@ -7,6 +7,18 @@ $PageSecurity = 2; include('includes/session.inc'); +$sql='show tables where Tables_in_'.$_SESSION['DatabaseName'].'="mrprequirements"'; +$result=DB_query($sql,$db); +if (DB_num_rows($result)==0) { + $title='MRP error'; + include('includes/header.inc'); + echo '<br>'; + prnMsg( _('The MRP calculation must be run before you can run this report').'<br>'. + _('To run the MRP calculation click').' '.'<a href='.$rootpath .'/MRP.php?' . SID .'>'._('here').'</a>', 'error'); + include('includes/footer.inc'); + exit; +} + If (isset($_POST['PrintPDF'])) { include('includes/PDFStarter.php'); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-08 11:29:25 UTC (rev 3457) +++ trunk/doc/Change.log.html 2010-05-12 05:23:41 UTC (rev 3458) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>11/05/10 Tim: Exit MRP scripts gracefully if no MRP calculation has been done.</p> <p>08/05/10 Lindsay: API was broken after adding a test for global variable $DatabaseName in ConnectDB_mysql* for this variable being set and using it as DB name if so. The variable of that name in the api_php.php has been changed to $api_DatabaseName.</p> <p>08/05/10 Phil: GetPrices.inc now uses the new price startdate and enddate to return the price which falls within the date range base on the current date. Changes to Prices.php and Prices_Customer.php to allow entry of effective from and effective to dates and updating/deleting of prices with appropriate error trapping and rescheduling of enddates where start and end dates would otherwise overlap.</p> <p>08/05/10 Phil: Found a bug in Date1GreaterThanDate2 function (in includes/DateFunction.inc) with SESSION['DefaultDateFormat'] = 'd/m/Y' this function had been broken </p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-05-15 10:37:03
|
Revision: 3459 http://web-erp.svn.sourceforge.net/web-erp/?rev=3459&view=rev Author: daintree Date: 2010-05-15 10:36:56 +0000 (Sat, 15 May 2010) Log Message: ----------- GetPrices.inc Prices.php and Prices_Customer.php - modified to allow default prices - with no end dates - reducing requirement to administer - also updated Prices section of the manual Modified Paths: -------------- trunk/Prices.php trunk/Prices_Customer.php trunk/doc/Change.log.html trunk/doc/Manual/ManualPrices.html trunk/includes/ConnectDB_mysqli.inc trunk/includes/GetPrice.inc trunk/includes/UserLogin.php trunk/includes/session.inc trunk/sql/mysql/upgrade3.11.1-3.12.sql Modified: trunk/Prices.php =================================================================== --- trunk/Prices.php 2010-05-12 05:23:41 UTC (rev 3458) +++ trunk/Prices.php 2010-05-15 10:36:56 UTC (rev 3459) @@ -33,7 +33,10 @@ echo "<a href='" . $rootpath . '/SelectProduct.php?' . SID . "'>" . _('Back to Items') . '</a><br>'; -$result = DB_query("SELECT stockmaster.description, stockmaster.mbflag FROM stockmaster WHERE stockmaster.stockid='$Item'",$db); +$result = DB_query("SELECT stockmaster.description, + stockmaster.mbflag + FROM stockmaster + WHERE stockmaster.stockid='$Item'",$db); $myrow = DB_fetch_row($result); if (DB_num_rows($result)==0){ @@ -66,7 +69,8 @@ ie the page has called itself with some user input */ //first off validate inputs sensible - + $ZeroDate = Date($_SESSION['DefaultDateFormat'],Mktime(0,0,0,0,0,0)); + if (!is_double((double) trim($_POST['Price'])) OR $_POST['Price']=="") { $InputError = 1; prnMsg( _('The price entered must be numeric'),'error'); @@ -75,36 +79,44 @@ $InputError =1; prnMsg (_('The date this price is to take effect from must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat'],'error'); } - if (! Is_Date($_POST['EndDate'])){ + if (! Is_Date($_POST['EndDate']) AND $_POST['EndDate']!=''){ $InputError =1; prnMsg (_('The date this price is be in effect to must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat'],'error'); } - if (Date1GreaterThanDate2($_POST['StartDate'],$_POST['EndDate'])){ + if (Date1GreaterThanDate2($_POST['StartDate'],$_POST['EndDate']) AND $_POST['EndDate']!='' AND $_POST['EndDate']!=$ZeroDate){ $InputError =1; + + echo 'Debug - start date ' . $_POST['StartDate'] . ' end date: ' . $_POST['EndDate']; + prnMsg (_('The end date is expected to be after the start date, enter an end date after the start date for this price'),'error'); } - if (Date1GreaterThanDate2(Date($_SESSION['DefaultDateFormat']),$_POST['EndDate'])){ + if (Date1GreaterThanDate2(Date($_SESSION['DefaultDateFormat']),$_POST['EndDate']) AND $_POST['EndDate']!='' AND $_POST['EndDate']!=$ZeroDate){ $InputError =1; prnMsg(_('The end date is expected to be after today. There is no point entering a new price where the effective date is before today!'),'error'); } - + if (Is_Date($_POST['EndDate'])){ + $SQLEndDate = FormatDateForSQL($_POST['EndDate']); + } else { + $SQLEndDate = '0000-00-00'; + } if (isset($_POST['OldTypeAbbrev']) AND isset($_POST['OldCurrAbrev']) AND strlen($Item)>1 AND $InputError !=1) { /* Need to see if there is also a price entered that has an end date after the start date of this price and if so we will need to update it so there is no ambiguity as to which price will be used*/ + //editing an existing price $sql = "UPDATE prices SET - typeabbrev='" . $_POST['TypeAbbrev'] . "', - currabrev='" . $_POST['CurrAbrev'] . "', - price=" . $_POST['Price'] . ", - startdate='" . FormatDateForSQL($_POST['StartDate']) . "', - enddate='" . FormatDateForSQL($_POST['EndDate']) . "' - WHERE prices.stockid='$Item' - AND startdate='" .$_POST['OldStartDate'] . "' - AND enddate ='" . $_POST['OldEndDate'] . "' - AND prices.typeabbrev='" . $_POST['OldTypeAbbrev'] . "' - AND prices.currabrev='" . $_POST['OldCurrAbrev'] . "' - AND prices.debtorno=''"; + typeabbrev='" . $_POST['TypeAbbrev'] . "', + currabrev='" . $_POST['CurrAbrev'] . "', + price=" . $_POST['Price'] . ", + startdate='" . FormatDateForSQL($_POST['StartDate']) . "', + enddate='" . $SQLEndDate . "' + WHERE prices.stockid='$Item' + AND startdate='" .$_POST['OldStartDate'] . "' + AND enddate ='" . $_POST['OldEndDate'] . "' + AND prices.typeabbrev='" . $_POST['OldTypeAbbrev'] . "' + AND prices.currabrev='" . $_POST['OldCurrAbrev'] . "' + AND prices.debtorno=''"; $ErrMsg = _('Could not be update the existing prices'); $result = DB_query($sql,$db,$ErrMsg); @@ -118,22 +130,22 @@ /*Selected price is null cos no item selected on first time round so must be adding a record must be submitting new entries in the new price form */ $sql = "INSERT INTO prices (stockid, - typeabbrev, - currabrev, - startdate, - enddate, - price) - VALUES ('$Item', - '" . $_POST['TypeAbbrev'] . "', - '" . $_POST['CurrAbrev'] . "', - '" . FormatDateForSQL($_POST['StartDate']) . "', - '" . FormatDateForSQL($_POST['EndDate']). "', - " . $_POST['Price'] . ")"; - $ErrMsg = _('The new price could not be added'); - $result = DB_query($sql,$db,$ErrMsg); - - ReSequenceEffectiveDates ($Item, $_POST['TypeAbbrev'], $_POST['CurrAbrev'], $db) ; - prnMsg(_('The new price has been inserted'),'success'); + typeabbrev, + currabrev, + startdate, + enddate, + price) + VALUES ('$Item', + '" . $_POST['TypeAbbrev'] . "', + '" . $_POST['CurrAbrev'] . "', + '" . FormatDateForSQL($_POST['StartDate']) . "', + '" . $SQLEndDate. "', + " . $_POST['Price'] . ")"; + $ErrMsg = _('The new price could not be added'); + $result = DB_query($sql,$db,$ErrMsg); + + ReSequenceEffectiveDates ($Item, $_POST['TypeAbbrev'], $_POST['CurrAbrev'], $db) ; + prnMsg(_('The new price has been inserted'),'success'); } unset($_POST['Price']); unset($_POST['StartDate']); @@ -195,7 +207,11 @@ echo '<tr class="OddTableRows">'; $k=1; } - + if ($myrow['enddate']=='0000-00-00'){ + $EndDateDisplay = _('No End Date'); + } else { + $EndDateDisplay = ConvertSQLDate($myrow['enddate']); + } /*Only allow access to modify prices if securiy token 5 is allowed */ if (in_array(5,$_SESSION['AllowedPageSecurityTokens'])) { @@ -210,7 +226,7 @@ $myrow['sales_type'], $myrow['price'], ConvertSQLDate($myrow['startdate']), - ConvertSQLDate($myrow['enddate']), + $EndDateDisplay, $_SERVER['PHP_SELF'], SID, $myrow['stockid'], @@ -237,7 +253,7 @@ $myrow['sales_type'], $myrow['price'], ConvertSQLDate($myrow['startdate']), - ConvertSQLDate($myrow['enddate'])); + $EndDateDisplay; } } @@ -257,7 +273,11 @@ $_POST['TypeAbbrev'] = $_GET['TypeAbbrev']; $_POST['Price'] = $_GET['Price']; $_POST['StartDate'] = ConvertSQLDate($_GET['StartDate']); - $_POST['EndDate'] = ConvertSQLDate($_GET['EndDate']); + if ($_GET['EndDate']==''){ + $_POST['EndDate'] =''; + } else { + $_POST['EndDate'] = ConvertSQLDate($_GET['EndDate']); + } } $SQL = "SELECT currabrev, currency FROM currencies"; @@ -297,7 +317,7 @@ } if (!isset($_POST['EndDate'])){ - $_POST['EndDate'] = Date($_SESSION['DefaultDateFormat'],Mktime(0,0,0,12,31,(Date('y')+20))); + $_POST['EndDate'] = ''; } echo '<tr><td>' . _('Price Effective From Date') . ':</td> <td><input type=text name="StartDate" value="' . $_POST['StartDate'] . '"></td></tr>'; @@ -330,25 +350,30 @@ function ReSequenceEffectiveDates ($Item, $PriceList, $CurrAbbrev, $db) { + /*This is quite complicated - the idea is that prices set up should be unique and there is no way two prices could be returned as valid - when getting a price in includes/GetPrice.inc the logic is to first look for a price of the salestype/currency within the effective start and end dates - then if not get the price with a start date prior but a blank end date (the default price). We would not want two prices where one price falls inside another effective date range except in the case of a blank end date - ie no end date - the default price for the currency/salestype. + I first thought that we would need to update the previous default price (blank end date), when a new default price is entered, to have an end date of the startdate of this new default price less 1 day - but this is converting a default price into a special price which could result in having two special prices over the same date range - best to leave it unchanged and use logic in the GetPrice.inc to ensure the correct default price is returned + */ + //this is just the case where debtorno='' - see the Prices_Customer.php script for customer special prices $SQL = "SELECT price, - startdate, - enddate + startdate, + enddate FROM prices WHERE debtorno='' AND stockid='" . $Item . "' AND currabrev='" . $CurrAbbrev . "' AND typeabbrev='" . $PriceList . "' + AND enddate <>'0000-00-00' ORDER BY startdate, enddate"; $result = DB_query($SQL,$db); $NextStartDate = Date($_SESSION['DefaultDateFormat']); unset($EndDate); unset($NextStartDate); - while ($myrow = DB_fetch_array($result)){ - + while ($myrow = DB_fetch_array($result)){ if (isset($NextStartDate)){ if (Date1GreaterThanDate2(ConvertSQLDate($myrow['startdate']),$NextStartDate)){ $NextStartDate = ConvertSQLDate($myrow['startdate']); - if (isset($EndDate)) { + //Only if the previous enddate is after the new start date do we need to look at updates + if (Date1GreaterThanDate2(ConvertSQLDate($EndDate),ConvertSQLDate($myrow['startdate']))) { /*Need to make the end date the new start date less 1 day */ $SQL = "UPDATE prices SET enddate = '" . FormatDateForSQL(DateAdd($NextStartDate,'d',-1)) . "' WHERE stockid ='" .$Item . "' @@ -367,7 +392,7 @@ $StartDate = $myrow['startdate']; $EndDate = $myrow['enddate']; $Price = $myrow['price']; - } -} + } // end of loop around all prices +} // end function ReSequenceEffectiveDates ?> \ No newline at end of file Modified: trunk/Prices_Customer.php =================================================================== --- trunk/Prices_Customer.php 2010-05-12 05:23:41 UTC (rev 3458) +++ trunk/Prices_Customer.php 2010-05-15 10:36:56 UTC (rev 3459) @@ -25,23 +25,32 @@ } $result = DB_query("SELECT debtorsmaster.name, - debtorsmaster.currcode, - debtorsmaster.salestype - FROM - debtorsmaster - WHERE - debtorsmaster.debtorno='" . $_SESSION['CustomerID'] . "'",$db); + debtorsmaster.currcode, + debtorsmaster.salestype + FROM + debtorsmaster + WHERE + debtorsmaster.debtorno='" . $_SESSION['CustomerID'] . "'",$db); $myrow = DB_fetch_row($result); echo '<font color=BLUE><b>' . $myrow[0] . ' ' . _('in') . ' ' . $myrow[1] . '<br>' . ' ' . _('for') . ' '; $CurrCode = $myrow[1]; $SalesType = $myrow[2]; -$result = DB_query("SELECT stockmaster.description - FROM stockmaster - WHERE stockmaster.stockid='" . $Item . "'",$db); +$result = DB_query("SELECT stockmaster.description, + stockmaster.mbflag + FROM stockmaster + WHERE stockmaster.stockid='" . $Item . "'",$db); $myrow = DB_fetch_row($result); +if (DB_num_rows($result)==0){ + prnMsg( _('The part code entered does not exist in the database') . '. ' . _('Only valid parts can have prices entered against them'),'error'); + $InputError=1; +} +if ($myrow[1]=='K'){ + prnMsg(_('The part selected is a kit set item') .', ' . _('these items explode into their components when selected on an order') . ', ' . _('prices must be set up for the components and no price can be set for the whole kit'),'error'); + exit; +} echo $Item . ' - ' . $myrow[0] . '</b></font><hr>'; @@ -77,15 +86,15 @@ $InputError =1; $msg = _('The date this price is to take effect from must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat']; } - if (! Is_Date($_POST['EndDate'])){ + if (! Is_Date($_POST['EndDate']) AND $_POST['EndDate']!=''){ //EndDate can also be blank for default prices $InputError =1; $msg = _('The date this price is be in effect to must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat']; } - if (Date1GreaterThanDate2($_POST['StartDate'],$_POST['EndDate'])){ + if (Date1GreaterThanDate2($_POST['StartDate'],$_POST['EndDate']) AND $_POST['EndDate']!=''){ $InputError =1; $msg = _('The end date is expected to be after the start date, enter an end date after the start date for this price'); } - if (Date1GreaterThanDate2(Date($_SESSION['DefaultDateFormat']),$_POST['EndDate'])){ + if (Date1GreaterThanDate2(Date($_SESSION['DefaultDateFormat']),$_POST['EndDate']) AND $_POST['EndDate']!=''){ $InputError =1; $msg = _('The end date is expected to be after today. There is no point entering a new price where the effective date is before today!'); } @@ -195,13 +204,18 @@ } else { echo '<tr><th>' . _('Normal Price') . '</th></tr>'; while ($myrow = DB_fetch_array($result)) { + if ($myrow['enddate']=='0000-00-00'){ + $EndDateDisplay = _('No End Date'); + } else { + $EndDateDisplay = ConvertSQLDate($myrow['enddate']); + } printf('<tr class="EvenTableRows"> <td class=number>%0.2f</td> <td class=date>%s</td> <td class=date>%s</td></tr>', $myrow['price'], ConvertSQLDate($myrow['startdate']), - ConvertSQLDate($myrow['enddate'])); + $EndDateDisplay); } } @@ -244,7 +258,11 @@ } else { $Branch = $myrow['brname']; } - + if ($myrow['enddate']=='0000-00-00'){ + $EndDateDisplay = _('No End Date'); + } else { + $EndDateDisplay = ConvertSQLDate($myrow['enddate']); + } printf("<tr bgcolor='#CCCCCC'> <td class=number>%0.2f</td> <td>%s</td> @@ -255,7 +273,7 @@ $myrow['price'], $Branch, ConvertSQLDate($myrow['startdate']), - ConvertSQLDate($myrow['enddate']), + $EndDateDisplay, $_SERVER['PHP_SELF'], $Item, $myrow['price'], @@ -288,7 +306,11 @@ $_POST['Price']=$_GET['Price']; $_POST['Branch']=$_GET['Branch']; $_POST['StartDate'] = ConvertSQLDate($_GET['StartDate']); - $_POST['EndDate'] = ConvertSQLDate($_GET['EndDate']); + if (Is_Date($_GET['EndDate'])){ + $_POST['EndDate'] = ConvertSQLDate($_GET['EndDate']); + } else { + $_POST['EndDate']=''; + } } if (!isset($_POST['Branch'])) { @@ -303,15 +325,15 @@ } if (!isset($_POST['EndDate'])){ - $_POST['EndDate'] = Date($_SESSION['DefaultDateFormat'],Mktime(0,0,0,12,31,(Date('y')+20))); + $_POST['EndDate'] = ''; } echo '<table><tr><td>' . _('Branch') . ':</td> <td><input type="Text" name="Branch" size=11 maxlength=10 value=' . $_POST['Branch'] . '></td></tr>'; - echo '<table><tr><td>' . _('Start Date') . ':</td> + echo '<tr><td>' . _('Start Date') . ':</td> <td><input type="Text" name="StartDate" size=11 maxlength=10 value=' . $_POST['StartDate'] . '></td></tr>'; - echo '<table><tr><td>' . _('End Date') . ':</td> + echo '<tr><td>' . _('End Date') . ':</td> <td><input type="Text" name="EndDate" size=11 maxlength=10 value=' . $_POST['EndDate'] . '></td></tr>'; echo '<tr><td>' . _('Price') . ':</td> @@ -326,32 +348,40 @@ function ReSequenceEffectiveDates ($Item, $PriceList, $CurrAbbrev, $CustomerID, $db) { + /*This is quite complicated - the idea is that prices set up should be unique and there is no way two prices could be returned as valid - when getting a price in includes/GetPrice.inc the logic is to first look for a price of the salestype/currency within the effective start and end dates - then if not get the price with a start date prior but a blank end date (the default price). We would not want two prices where the effective dates fall between an existing price so it is necessary to update enddates of prices - with me - I am just hanging on here myself + + Prices with no end date are default prices and need to be ignored in this resquence*/ + $SQL = "SELECT branchcode, - startdate, - enddate + startdate, + enddate FROM prices WHERE debtorno='" . $CustomerID . "' AND stockid='" . $Item . "' AND currabrev='" . $CurrAbbrev . "' AND typeabbrev='" . $PriceList . "' - ORDER BY branchcode, - startdate, - enddate"; + AND enddate<>'' + ORDER BY + branchcode, + startdate, + enddate"; + $result = DB_query($SQL,$db); unset($BranchCode); while ($myrow = DB_fetch_array($result)){ if ($BranchCode != $myrow['branchcode']){ + unset($NextDefaultStartDate); //a price with a blank end date unset($NextStartDate); unset($EndDate); unset($StartDate); $BranchCode = $myrow['branchcode']; } - if (isset($NextStartDate)){ + if (isset($NextStartDate)){ if (Date1GreaterThanDate2(ConvertSQLDate($myrow['startdate']),$NextStartDate)){ $NextStartDate = ConvertSQLDate($myrow['startdate']); - if (isset($EndDate)) { + if (Date1GreaterThanDate2(ConvertSQLDate($EndDate),ConvertSQLDate($myrow['startdate']))) { /*Need to make the end date the new start date less 1 day */ $SQL = "UPDATE prices SET enddate = '" . FormatDateForSQL(DateAdd($NextStartDate,'d',-1)) . "' WHERE stockid ='" .$Item . "' Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-12 05:23:41 UTC (rev 3458) +++ trunk/doc/Change.log.html 2010-05-15 10:36:56 UTC (rev 3459) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>15/5/10 Phil: GetPrices.inc Prices.php and Prices_Customer.php - modified to allow default prices - with no end dates - reducing requirement to administer - also updated Prices section of the manual <p>11/05/10 Tim: Exit MRP scripts gracefully if no MRP calculation has been done.</p> <p>08/05/10 Lindsay: API was broken after adding a test for global variable $DatabaseName in ConnectDB_mysql* for this variable being set and using it as DB name if so. The variable of that name in the api_php.php has been changed to $api_DatabaseName.</p> <p>08/05/10 Phil: GetPrices.inc now uses the new price startdate and enddate to return the price which falls within the date range base on the current date. Changes to Prices.php and Prices_Customer.php to allow entry of effective from and effective to dates and updating/deleting of prices with appropriate error trapping and rescheduling of enddates where start and end dates would otherwise overlap.</p> Modified: trunk/doc/Manual/ManualPrices.html =================================================================== --- trunk/doc/Manual/ManualPrices.html 2010-05-12 05:23:41 UTC (rev 3458) +++ trunk/doc/Manual/ManualPrices.html 2010-05-15 10:36:56 UTC (rev 3459) @@ -8,13 +8,19 @@ <br><br> Prices are held by Sales Type and Currency. When setting up a customer account the sales type applicable to the customer is defined as is the currency applicable to invoices to the customer. There is no limit to the number of sales types that can be defined and therefore no limit to the number of different price lists that can be maintained. Further flexibility is available in that where necessary prices specific to a customer can also be defined, normally pricing will be specific to a customer but the system also has the capability of making prices specific to a particular branch of a customer. If a price is flagged as specific to a branch it will not be used for all other sales of the item to the customer, the default price of the item will be used. Further flexibility in discounting is available through the discount matrix (see below). If an item has an additional discount this can be entered at the time of order. The user also has the ability to change the price manually at the time of order. Sales analysis records allow reporting on sales types, so the analysis will report the volume of business done under each set of special pricing arrangements. <br><br> +<font size="+1"><b>Prices Effectivity Dates</b></font> +<br><br> +In many businesses a change in price has to come into effect at some later date and be published to customers in advance of the price being effective. This functionality was introduced in 2010. The date that a price is to be effective from must be specified at the time of entry. If the price is expected to continue indefinitely then it is not necessary to specify an end date. Any subsequent prices entered without an end date will superseed previous entries with starting dates prior. +<br><br> +If a price is entered with an end date then this takes precidence over prices with no end date - where the date of entry of an order falls within the date range for the price. It is the current server date that is used to compare against the date range in determining the price to use. +<br><br> <font size="+1"><b>Maintaining Prices</b></font> <br><br> -To maintain pricing, first an item must be selected. This can be done from the link "Select an Item " on any page or from the inventory tab of the menu the link "Modify Or Delete An Inventory Item Or Item Pricing" allows for a part to be selected. Once selected the options available to work with the item are shown, there is a link to "Maintain Pricing". The pricing page displays, the sales type and the currency of all prices defined for the item. The existing prices can be deleted or modified from this screen and new prices can be entered. It is not possible to enter two prices for the same sales type and currency. +To maintain pricing, first an item must be selected. This can be done from the link "Select an Item " on any page or from the inventory tab of the menu the link "Modify Or Delete An Inventory Item Or Item Pricing" allows for a part to be selected. Once selected the options available to work with the item are shown, there is a link to "Maintain Pricing". The pricing page displays, the sales type and the currency of all prices defined for the item. The existing prices can be deleted or modified from this screen and new prices can be entered. It is possible to enter many prices for a given sales type and currency with different effective from and to dates. Normally the date that the price should be effective to can be left blank. Subsequent entries of prices with no end date can be entered and these will be used after the start date of these prices. When entering prices for a fixed date range - this price will take precidence over the default price with no end date. The system automatically adjusts the end date of prices where a new price with a fixed date range is entered with an overlapping period to a previously entered price. The end date of the previous price is adjusted to be the day prior to the start date of the new price. This ensures that there can only be one price returned in a given date range. <br><br> To enter prices for a specific customer and branch, the customer must first be selected. (See selecting customers). Going to the select an item page after having selected an item now shows an additional link to maintain the special pricing "Special Prices for customer - customer code". Clicking this link shows, the normal price for the sales type and currency of the customer selected and any special prices defined for this item/customer combination. If no special pricing is defined then the page shows only the normal price with a note that no special pricing is defined for this item and allows entry of the new special price. If a special price exists then it can be deleted or changed. A customer with many branches can have a special price for each branch or just a single branch having a special price beyond the special customer price. A special price applicable to only one branch will not apply to any of the other branches. Also, a special price set up for the customer account but with a blank branch field will apply to all branches unless there is a specific price set up for the branch. <br><br> -Prices can be amended at any time. However, changes to a price do not automatically cascade into sales orders for the item that are yet to be delivered, these would have to be changed manually as necessary. +Prices can be amended at any time. However, changes to a price do not automatically cascade into sales orders for the item that are yet to be delivered, these orders would have to be changed manually as necessary. <br><br> There is a utility page that has some options for making bulk changes to pricing avoiding extensive re-keying exercises. Great care should be taken with this facility. System administrator permission is required to access this page accordingly. <br><br> Modified: trunk/includes/ConnectDB_mysqli.inc =================================================================== --- trunk/includes/ConnectDB_mysqli.inc 2010-05-12 05:23:41 UTC (rev 3458) +++ trunk/includes/ConnectDB_mysqli.inc 2010-05-15 10:36:56 UTC (rev 3459) @@ -45,11 +45,11 @@ //DB wrapper functions to change only once for whole application function DB_query ($SQL, - &$Conn, - $ErrorMessage='', - $DebugMessage= '', - $Transaction=false, - $TrapErrors=true){ + &$Conn, + $ErrorMessage='', + $DebugMessage= '', + $Transaction=false, + $TrapErrors=true){ global $debug; global $PathPrefix; Modified: trunk/includes/GetPrice.inc =================================================================== --- trunk/includes/GetPrice.inc 2010-05-12 05:23:41 UTC (rev 3458) +++ trunk/includes/GetPrice.inc 2010-05-15 10:36:56 UTC (rev 3459) @@ -3,31 +3,8 @@ function GetPrice ($StockID, $DebtorNo, $BranchCode, $db){ $Price = 0; - - $sql="SELECT prices.price, - prices.debtorno, - prices.branchcode - FROM prices, - debtorsmaster - WHERE debtorsmaster.salestype=prices.typeabbrev - AND debtorsmaster.debtorno='" . $DebtorNo . "' - AND prices.stockid = '" . $StockID . "' - AND prices.currabrev = debtorsmaster.currcode - AND prices.debtorno=debtorsmaster.debtorno - AND prices.branchcode='" . $BranchCode . "' - AND prices.startdate <='" . Date('Y-m-d') . "' - AND prices.enddate >='" . Date('Y-m-d') . "'"; - - $ErrMsg = _('There is a problem in retrieving the pricing information for part') . ' ' . $StockID . ' ' . _('and for Customer') . ' ' . $DebtorNo . ' ' . _('the error message returned by the SQL server was'); - $result = DB_query($sql, $db,$ErrMsg); - - - if (DB_num_rows($result)==0){ - - /* No result returned for customer and branch search try for just a customer match */ - $sql = "SELECT prices.price, - prices.debtorno, - prices.branchcode + /*Search by branch and customer for a date specified price */ + $sql="SELECT prices.price FROM prices, debtorsmaster WHERE debtorsmaster.salestype=prices.typeabbrev @@ -35,54 +12,141 @@ AND prices.stockid = '" . $StockID . "' AND prices.currabrev = debtorsmaster.currcode AND prices.debtorno=debtorsmaster.debtorno - AND prices.branchcode='' + AND prices.branchcode='" . $BranchCode . "' AND prices.startdate <='" . Date('Y-m-d') . "' - AND prices.enddate >='" . Date('Y-m-d') . "'";; - - - $result = DB_query($sql,$db,$ErrMsg); - - if (DB_num_rows($result)==0){ - - /*No special pricing use the customers normal price list */ - $sql = "SELECT prices.price, - prices.debtorno, - prices.branchcode + AND prices.enddate >='" . Date('Y-m-d') . "'"; + + $ErrMsg = _('There is a problem in retrieving the pricing information for part') . ' ' . $StockID . ' ' . _('and for Customer') . ' ' . $DebtorNo . ' ' . _('the error message returned by the SQL server was'); + $result = DB_query($sql, $db,$ErrMsg); + if (DB_num_rows($result)==0){ + /*Need to try same specific search but for a default price with a zero end date */ + $sql="SELECT prices.price, + prices.startdate FROM prices, debtorsmaster WHERE debtorsmaster.salestype=prices.typeabbrev AND debtorsmaster.debtorno='" . $DebtorNo . "' AND prices.stockid = '" . $StockID . "' - AND prices.debtorno='' AND prices.currabrev = debtorsmaster.currcode + AND prices.debtorno=debtorsmaster.debtorno + AND prices.branchcode='" . $BranchCode . "' AND prices.startdate <='" . Date('Y-m-d') . "' - AND prices.enddate >='" . Date('Y-m-d') . "'"; - - $result = DB_query($sql,$db,$ErrMsg); - - if (DB_num_rows($result)==0){ - - /* Now use the default salestype/price list cos all else has failed */ - $sql="SELECT prices.price + AND prices.enddate ='0000-00-00' + ORDER BY prices.startdate DESC"; + + $result = DB_query($sql, $db,$ErrMsg); + + if (DB_num_rows($result)==0){ + + /* No result returned for customer and branch search try for just a customer match */ + $sql = "SELECT prices.price FROM prices, - debtorsmaster - WHERE prices.stockid = '" . $StockID . "' + debtorsmaster + WHERE debtorsmaster.salestype=prices.typeabbrev + AND debtorsmaster.debtorno='" . $DebtorNo . "' + AND prices.stockid = '" . $StockID . "' AND prices.currabrev = debtorsmaster.currcode - AND debtorsmaster.debtorno='" . $DebtorNo . "' - AND prices.typeabbrev='" . $_SESSION['DefaultPriceList'] . "' - AND prices.debtorno='' + AND prices.debtorno=debtorsmaster.debtorno + AND prices.branchcode='' AND prices.startdate <='" . Date('Y-m-d') . "' - AND prices.enddate >='" . Date('Y-m-d') . "'";; + AND prices.enddate >='" . Date('Y-m-d') . "'"; + + + $result = DB_query($sql,$db,$ErrMsg); + if (DB_num_rows($result)==0){ + //if no specific price between the dates maybe there is a default price with no end date specified + $sql = "SELECT prices.price, + prices.startdate + FROM prices, + debtorsmaster + WHERE debtorsmaster.salestype=prices.typeabbrev + AND debtorsmaster.debtorno='" . $DebtorNo . "' + AND prices.stockid = '" . $StockID . "' + AND prices.currabrev = debtorsmaster.currcode + AND prices.debtorno=debtorsmaster.debtorno + AND prices.branchcode='' + AND prices.startdate <='" . Date('Y-m-d') . "' + AND prices.enddate >='0000-00-00' + ORDER BY prices.startdate DESC"; + + $result = DB_query($sql,$db,$ErrMsg); - $result = DB_query($sql, $db,$ErrMsg); - - if (DB_num_rows($result)==0){ - /*Not even a price set up in the default price list so return 0 */ - prnMsg(_('There are no prices set up for') . ' ' . $StockID,'warn'); - Return 0; + + /*No special customer specific pricing use the customers normal price list but look for special limited time prices with specific end date*/ + $sql = "SELECT prices.price + FROM prices, + debtorsmaster + WHERE debtorsmaster.salestype=prices.typeabbrev + AND debtorsmaster.debtorno='" . $DebtorNo . "' + AND prices.stockid = '" . $StockID . "' + AND prices.debtorno='' + AND prices.currabrev = debtorsmaster.currcode + AND prices.startdate <='" . Date('Y-m-d') . "' + AND prices.enddate >='" . Date('Y-m-d') . "'"; + + $result = DB_query($sql,$db,$ErrMsg); + + if (DB_num_rows($result)==0){ + /*No special customer specific pricing use the customers normal price list but look for default price with 0000-00-00 end date*/ + $sql = "SELECT prices.price, + prices.startdate + FROM prices, + debtorsmaster + WHERE debtorsmaster.salestype=prices.typeabbrev + AND debtorsmaster.debtorno='" . $DebtorNo . "' + AND prices.stockid = '" . $StockID . "' + AND prices.debtorno='' + AND prices.currabrev = debtorsmaster.currcode + AND prices.startdate <='" . Date('Y-m-d') . "' + AND prices.enddate ='0000-00-00' + ORDER BY prices.startdate DESC"; + + $result = DB_query($sql,$db,$ErrMsg); + + if (DB_num_rows($result)==0){ + + /* Now use the default salestype/price list cos all else has failed */ + $sql="SELECT prices.price + FROM prices, + debtorsmaster + WHERE prices.stockid = '" . $StockID . "' + AND prices.currabrev = debtorsmaster.currcode + AND debtorsmaster.debtorno='" . $DebtorNo . "' + AND prices.typeabbrev='" . $_SESSION['DefaultPriceList'] . "' + AND prices.debtorno='' + AND prices.startdate <='" . Date('Y-m-d') . "' + AND prices.enddate >='" . Date('Y-m-d') . "'";; + + $result = DB_query($sql, $db,$ErrMsg); + + if (DB_num_rows($result)==0){ + + /* Now use the default salestype/price list cos all else has failed */ + $sql="SELECT prices.price + prices.startdate + FROM prices, + debtorsmaster + WHERE prices.stockid = '" . $StockID . "' + AND prices.currabrev = debtorsmaster.currcode + AND debtorsmaster.debtorno='" . $DebtorNo . "' + AND prices.typeabbrev='" . $_SESSION['DefaultPriceList'] . "' + AND prices.debtorno='' + AND prices.startdate <='" . Date('Y-m-d') . "' + AND prices.enddate ='0000-00-00' + ORDER BY prices.startdate DESC"; + + $result = DB_query($sql, $db,$ErrMsg); + + if (DB_num_rows($result)==0){ + /*Not even a price set up in the default price list so return 0 */ + prnMsg(_('There are no prices set up for') . ' ' . $StockID,'warn'); + Return 0; + } + } + } + } } - } } } Modified: trunk/includes/UserLogin.php =================================================================== --- trunk/includes/UserLogin.php 2010-05-12 05:23:41 UTC (rev 3458) +++ trunk/includes/UserLogin.php 2010-05-15 10:36:56 UTC (rev 3459) @@ -19,6 +19,7 @@ */ function userLogin($Name, $Password, $db) { + if (!isset($_SESSION['AccessLevel']) OR $_SESSION['AccessLevel'] == '' OR (isset($Name) AND $Name != '')) { /* if not logged in */ @@ -113,11 +114,7 @@ } } // End of userid/password check // Run with debugging messages for the system administrator(s) but not anyone else - if (in_array(15, $_SESSION['AllowedPageSecurityTokens'])) { - $debug = 1; - } else { - $debug = 0; - } + return UL_OK; /* All is well */ } Modified: trunk/includes/session.inc =================================================================== --- trunk/includes/session.inc 2010-05-12 05:23:41 UTC (rev 3458) +++ trunk/includes/session.inc 2010-05-15 10:36:56 UTC (rev 3459) @@ -248,10 +248,13 @@ include($PathPrefix . 'includes/footer.inc'); exit; } - - } +if (in_array(15, $_SESSION['AllowedPageSecurityTokens'])) { + $debug = 1; +} else { + $debug = 0; +} function CryptPass( $Password ) { global $CryptFunction; if ( $CryptFunction == 'sha1' ) { Modified: trunk/sql/mysql/upgrade3.11.1-3.12.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-05-12 05:23:41 UTC (rev 3458) +++ trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-05-15 10:36:56 UTC (rev 3459) @@ -153,7 +153,7 @@ ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `systypes` VALUES(19, 'Picking List', 0); -ALTER TABLE `prices` ADD `startdate` DATE NOT NULL , ADD `enddate` DATE NOT NULL DEFAULT '9999-12-31'; +ALTER TABLE `prices` ADD `startdate` DATE NOT NULL , ADD `enddate` DATE NOT NULL; ALTER TABLE prices DROP PRIMARY KEY , ADD PRIMARY KEY ( `stockid` , `typeabbrev` , `currabrev` , `debtorno` , `startdate` , `enddate` ) ; -UPDATE prices SET startdate='1999-01-01', enddate='9999-12-31'; +UPDATE prices SET startdate='1999-01-01'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-05-15 10:53:11
|
Revision: 3461 http://web-erp.svn.sourceforge.net/web-erp/?rev=3461&view=rev Author: daintree Date: 2010-05-15 10:53:04 +0000 (Sat, 15 May 2010) Log Message: ----------- Combined the common address checking function from Save.php and MiscFunctions.php into a single function Modified Paths: -------------- trunk/doc/Change.log.html trunk/includes/MiscFunctions.php trunk/install/save.php Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-15 10:39:42 UTC (rev 3460) +++ trunk/doc/Change.log.html 2010-05-15 10:53:04 UTC (rev 3461) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>15/5/10 Phil: Used Lindsay/Ngaraj's nice email address checking function to replace the existing function in MiscFunctions.php and includes MiscFunctions.php in install/save.php to avoid duplication of the function</p> <p>15/5/10 Phil: $debug variable in UserLogin.php was only set on first login - not subsequent page calls (its not a session variable) - moved it back into session.inc so that full info about bugs is available to sysadmins <p>15/5/10 Phil: GetPrices.inc Prices.php and Prices_Customer.php - modified to allow default prices - with no end dates - reducing requirement to administer - also updated Prices section of the manual <p>11/05/10 Tim: Exit MRP scripts gracefully if no MRP calculation has been done.</p> Modified: trunk/includes/MiscFunctions.php =================================================================== --- trunk/includes/MiscFunctions.php 2010-05-15 10:39:42 UTC (rev 3460) +++ trunk/includes/MiscFunctions.php 2010-05-15 10:53:04 UTC (rev 3461) @@ -50,26 +50,67 @@ return '<DIV class="'.$Class.'"><B>' . $Prefix . '</B> : ' .$Msg . '</DIV>'; }//getMsg -function IsEmailAddress($TestEmailAddress){ +function IsEmailAddress($email){ -/*thanks to Gavin Sharp for this regular expression to test validity of email addresses */ + $atIndex = strrpos ($email, "@"); + if ($atIndex === false) + { + return false; // No @ sign is not acceptable. + } - if (function_exists('preg_match')){ - if(preg_match("/^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$/", $TestEmailAddress)){ - return true; - } else { - return false; - } - } else { - if (strlen($TestEmailAddress)>5 AND strstr($TestEmailAddress,'@')>2 AND (strstr($TestEmailAddress,'.co')>3 OR strstr($TestEmailAddress,'.org')>3 OR strstr($TestEmailAddress,'.net')>3 OR strstr($TestEmailAddress,'.edu')>3 OR strstr($TestEmailAddress,'.biz')>3)){ - return true; - } else { - return false; - } + if (preg_match('/\\.\\./', $email)) + return false; // > 1 consecutive dot is not allowed. + + // Check component length limits + $domain = substr ($email, $atIndex+1); + $local = substr ($email, 0, $atIndex); + $localLen = strlen ($local); + $domainLen = strlen ($domain); + if ($localLen < 1 || $localLen > 64) + { + // local part length exceeded + return false; } + if ($domainLen < 1 || $domainLen > 255) + { + // domain part length exceeded + return false; + } + + if ($local[0] == '.' || $local[$localLen-1] == '.') + { + // local part starts or ends with '.' + return false; + } + if (!preg_match ('/^[A-Za-z0-9\\-\\.]+$/', $domain )) + { + // character not valid in domain part + return false; + } + if (!preg_match ('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', + str_replace ("\\\\", "" ,$local ) )) + { + // character not valid in local part unless local part is quoted + if (!preg_match ('/^"(\\\\"|[^"])+"$/', + str_replace("\\\\", "", $local) )) + { + return false; + } + } + + // Check for a DNS 'MX' or 'A' record. + // Windows supported from PHP 5.3.0 on - so check. + $ret = true; + if (version_compare(PHP_VERSION, '5.3.0') >= 0 + || strtoupper(substr(PHP_OS, 0, 3) !== 'WIN')) { + $ret = checkdnsrr( $domain, "MX" ) || checkdnsrr( $domain, "A" ); + } + + return $ret; } + Function ContainsIllegalCharacters ($CheckVariable) { if (strstr($CheckVariable,"'") Modified: trunk/install/save.php =================================================================== --- trunk/install/save.php 2010-05-15 10:39:42 UTC (rev 3460) +++ trunk/install/save.php 2010-05-15 10:53:04 UTC (rev 3461) @@ -4,6 +4,7 @@ ini_set('display_errors', "On"); ini_set('max_execution_time', "180"); +require_once('../includes/MiscFunctions.php'); // Start a session if(!defined('SESSION_STARTED')){ session_name('ba_session_id'); @@ -108,64 +109,8 @@ return $default_dir_mode; } -function is_valid_email($email) { - $atIndex = strrpos ($email, "@"); - if ($atIndex === false) - { - return false; // No @ sign is not acceptable. - } - if (preg_match('/\\.\\./', $email)) - return false; // > 1 consecutive dot is not allowed. - // Check component length limits - $domain = substr ($email, $atIndex+1); - $local = substr ($email, 0, $atIndex); - $localLen = strlen ($local); - $domainLen = strlen ($domain); - if ($localLen < 1 || $localLen > 64) - { - // local part length exceeded - return false; - } - if ($domainLen < 1 || $domainLen > 255) - { - // domain part length exceeded - return false; - } - - if ($local[0] == '.' || $local[$localLen-1] == '.') - { - // local part starts or ends with '.' - return false; - } - if (!preg_match ('/^[A-Za-z0-9\\-\\.]+$/', $domain )) - { - // character not valid in domain part - return false; - } - if (!preg_match ('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', - str_replace ("\\\\", "" ,$local ) )) - { - // character not valid in local part unless local part is quoted - if (!preg_match ('/^"(\\\\"|[^"])+"$/', - str_replace("\\\\", "", $local) )) - { - return false; - } - } - - // Check for a DNS 'MX' or 'A' record. - // Windows supported from PHP 5.3.0 on - so check. - $ret = true; - if (version_compare(PHP_VERSION, '5.3.0') >= 0 - || strtoupper(substr(PHP_OS, 0, 3) !== 'WIN')) { - $ret = checkdnsrr( $domain, "MX" ) || checkdnsrr( $domain, "A" ); - } - - return $ret; -} - if (isset($_POST['path_to_root'])) { $path_to_root = $_POST['path_to_root']; } else { @@ -258,7 +203,7 @@ if (!isset($_POST['admin_email']) || $_POST['admin_email'] == ''){ set_error('Please enter an email for the Administrator account'); } else { - if (is_valid_email($_POST['admin_email'])==false) { + if (IsEmailAddress($_POST['admin_email'])==false) { set_error('Please enter a valid email address for the Administrator account'); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-05-16 06:11:46
|
Revision: 3462 http://web-erp.svn.sourceforge.net/web-erp/?rev=3462&view=rev Author: daintree Date: 2010-05-16 06:11:39 +0000 (Sun, 16 May 2010) Log Message: ----------- <p>16/5/10 Phil: reworked PDFPriceList to use the new effective dates fields and print out effective prices as at a specified date - showing effective dates on the report - also ditched includes/PDFPriceListPageHeader.php in favour of a PageHeader() function inside PDFPriceList.php. Also made the script work with tcpdf - not sure how it was missed before?</p> <p>16/5/10 Phil: reworked PricesBasedOnMarkUp.php to insert new prices with effectivity dates and update the prices where effectivity dates specified.</p> <p>16/5/10 Phil: reworked PricesByCost.php this was bit of a dodgy script - well I found it hard to follow - in the words of Frank Sinatra - I did it my way! Also built in effectivity dates to display and ensure correct prices updated now the primary key of prices is changed.</p> <p>16/5/10 Phil: Wrote up the manual so that the logic of pricing with effective dates is explained</p> Modified Paths: -------------- trunk/PDFDIFOT.php trunk/PDFPriceList.php trunk/PDFStockNegatives.php trunk/Prices.php trunk/PricesBasedOnMarkUp.php trunk/PricesByCost.php trunk/Z_PriceChanges.php trunk/doc/Change.log.html trunk/doc/Manual/ManualPrices.html trunk/javascripts/MiscFunctions.js Removed Paths: ------------- trunk/includes/PDFPriceListPageHeader.inc Modified: trunk/PDFDIFOT.php =================================================================== --- trunk/PDFDIFOT.php 2010-05-15 10:53:04 UTC (rev 3461) +++ trunk/PDFDIFOT.php 2010-05-16 06:11:39 UTC (rev 3462) @@ -265,18 +265,7 @@ $YPos-=$line_height; $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,200,$FontSize,_('DIFOT') . ' ' . number_format((1-($TotalDiffs/$myrow[0])) * 100,2) . '%', 'left'); -/* UldisN -$pdfcode = $pdf->output(); -$len = strlen($pdfcode); -header('Content-type: application/pdf'); -header('Content-Length: ' . $len); -header('Content-Disposition: inline; filename=DIFOT.pdf'); -header('Expires: 0'); -header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); -header('Pragma: public'); -$pdf->stream(); -*/ $ReportFileName = $_SESSION['DatabaseName'] . '_DIFOT_' . date('Y-m-d').'.pdf'; $pdf->OutputD($ReportFileName);//UldisN $pdf->__destruct(); //UldisN Modified: trunk/PDFPriceList.php =================================================================== --- trunk/PDFPriceList.php 2010-05-15 10:53:04 UTC (rev 3461) +++ trunk/PDFPriceList.php 2010-05-16 06:11:39 UTC (rev 3462) @@ -16,7 +16,6 @@ $pdf->addinfo('Title', _('Price Listing Report') ); $pdf->addinfo('Subject', _('Price List') ); - $PageNumber=1; $line_height=12; @@ -28,49 +27,62 @@ include('includes/header.inc'); echo '<br>'; prnMsg( _('The customer must first be selected from the select customer link') . '. ' . _('Re-run the price list once the customer has been selected') ); + echo '<br><br><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '">' . _('Back') . '</a>'; include('includes/footer.inc'); exit; } + if (!Is_Date($_POST['EffectiveDate'])){ + $title = _('Special price List - No Customer Selected'); + include('includes/header.inc'); + prnMsg(_('The effective date must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat'],'error'); + echo '<br><br><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '">' . _('Back') . '</a>'; + include('includes/footer.inc'); + exit; + } $SQL = "SELECT debtorsmaster.name, debtorsmaster.salestype - FROM debtorsmaster - WHERE debtorno = '" . $_SESSION['CustomerID'] . "'"; + FROM debtorsmaster + WHERE debtorno = '" . $_SESSION['CustomerID'] . "'"; $CustNameResult = DB_query($SQL,$db); $CustNameRow = DB_fetch_row($CustNameResult); $CustomerName = $CustNameRow[0]; $SalesType = $CustNameRow[1]; $SQL = "SELECT prices.typeabbrev, - prices.stockid, - stockmaster.description, - stockmaster.longdescription, - prices.currabrev, - prices.price, - stockmaster.materialcost+stockmaster.labourcost+stockmaster.overheadcost AS standardcost, - stockmaster.categoryid, - stockcategory.categorydescription, - prices.debtorno, - prices.branchcode, - custbranch.brname - FROM stockmaster, - stockcategory, - prices LEFT JOIN custbranch - ON prices.debtorno=custbranch.debtorno - AND prices.branchcode=custbranch.branchcode - WHERE stockmaster.stockid=prices.stockid - AND stockmaster.categoryid=stockcategory.categoryid - AND prices.typeabbrev = '" . $SalesType . "' - AND stockmaster.categoryid >= '" . $_POST['FromCriteria'] . "' - AND stockmaster.categoryid <= '" . $_POST['ToCriteria'] . "' - AND prices.debtorno='" . $_SESSION['CustomerID'] . "' - ORDER BY prices.currabrev, - stockmaster.categoryid, - stockmaster.stockid"; + prices.stockid, + stockmaster.description, + stockmaster.longdescription, + prices.currabrev, + prices.startdate, + prices.enddate, + prices.price, + stockmaster.materialcost+stockmaster.labourcost+stockmaster.overheadcost AS standardcost, + stockmaster.categoryid, + stockcategory.categorydescription, + prices.debtorno, + prices.branchcode, + custbranch.brname + FROM stockmaster, + stockcategory, + prices LEFT JOIN custbranch + ON prices.debtorno=custbranch.debtorno + AND prices.branchcode=custbranch.branchcode + WHERE stockmaster.stockid=prices.stockid + AND stockmaster.categoryid=stockcategory.categoryid + AND prices.typeabbrev = '" . $SalesType . "' + AND stockmaster.categoryid >= '" . $_POST['FromCriteria'] . "' + AND stockmaster.categoryid <= '" . $_POST['ToCriteria'] . "' + AND prices.debtorno='" . $_SESSION['CustomerID'] . "' + AND prices.startdate<='" . FormatDateForSQL($_POST['EffectiveDate']) . "' + AND (prices.enddate='0000-00-00' OR prices.enddate>'" . FormatDateForSQL($_POST['EffectiveDate']) . "') + ORDER BY prices.currabrev, + stockmaster.categoryid, + stockmaster.stockid, + prices.startdate"; } else { /* the sales type list only */ - $SQL = "SELECT sales_type FROM salestypes WHERE typeabbrev='" . $_POST['SalesType'] . "'"; $SalesTypeResult = DB_query($SQL,$db); $SalesTypeRow = DB_fetch_row($SalesTypeResult); @@ -78,6 +90,8 @@ $SQL = "SELECT prices.typeabbrev, prices.stockid, + prices.startdate, + prices.enddate, stockmaster.description, stockmaster.longdescription, prices.currabrev, @@ -93,10 +107,13 @@ AND stockmaster.categoryid >= '" . $_POST['FromCriteria'] . "' AND stockmaster.categoryid <= '" . $_POST['ToCriteria'] . "' AND prices.typeabbrev='" . $_POST['SalesType'] . "' + AND prices.startdate<='" . FormatDateForSQL($_POST['EffectiveDate']) . "' + AND (prices.enddate='0000-00-00' OR prices.enddate>'" . FormatDateForSQL($_POST['EffectiveDate']) . "') AND prices.debtorno='' ORDER BY prices.currabrev, stockmaster.categoryid, - stockmaster.stockid"; + stockmaster.stockid, + prices.startdate"; } $PricesResult = DB_query($SQL,$db,'','',false,false); @@ -106,13 +123,22 @@ prnMsg( _('The Price List could not be retrieved by the SQL because'). ' - ' . DB_error_msg($db), 'error'); echo '<br><a href="' .$rootpath .'/index.php?' . SID . '">'. _('Back to the menu'). '</a>'; if ($debug==1){ - echo '<br>'. $SQL; + prnMsg(_('For debugging purposes the SQL used was:') . $SQL,'error'); } include('includes/footer.inc'); exit; } - - include('includes/PDFPriceListPageHeader.inc'); + if (DB_num_rows($PricesResult)==0){ + $title = _('Print Price List Error'); + include('includes/header.inc'); + prnMsg(_('There were no price details to print out for the customer or category specified'),'warn'); + echo '<br><a href="'.$_SERVER['PHP_SELF'] .'?' . SID . '">'. _('Back').'</a>'; + include('includes/footer.inc'); + exit; + } + + PageHeader(); + $CurrCode =''; $Category = ''; $CatTot_Val=0; @@ -122,28 +148,33 @@ if ($CurrCode != $PriceList['currabrev']){ $FontSize=10; - $YPos -= $line_height; + $YPos -= 2*$line_height; $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,300-$Left_Margin,$FontSize, $PriceList['currabrev'] . ' ' . _('Prices')); $CurrCode = $PriceList['currabrev']; $FontSize = 8; - $YPos -= $line_height; } if ($Category!=$PriceList['categoryid']){ $FontSize=10; - $YPos -= $line_height; + $YPos -= 2*$line_height; $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,300-$Left_Margin,$FontSize,$PriceList['categoryid'] . ' - ' . $PriceList['categorydescription']); $Category = $PriceList['categoryid']; $CategoryName = $PriceList['categorydescription']; $FontSize=8; - $YPos -=$line_height; } $YPos -=$line_height; - $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,60,$FontSize,$PriceList['stockid']); - $LeftOvers = $pdf->addTextWrap(190,$YPos,260,$FontSize,$PriceList['description']); + $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,80,$FontSize,$PriceList['stockid']); + $LeftOvers = $pdf->addTextWrap($Left_Margin+80,$YPos,47,$FontSize,ConvertSQLDate($PriceList['startdate'])); + if ($PriceList['enddate']!='0000-00-00'){ + $DisplayEndDate = ConvertSQLDate($PriceList['enddate']); + } else { + $DisplayEndDate = _('No End Date'); + } + $LeftOvers = $pdf->addTextWrap($Left_Margin+80+47,$YPos,47,$FontSize,$DisplayEndDate); + $LeftOvers = $pdf->addTextWrap($Left_Margin+80+47+47,$YPos,130,$FontSize,$PriceList['description']); $DisplayUnitPrice = number_format($PriceList['price'],2); - $LeftOvers = $pdf->addTextWrap(440,$YPos,60,$FontSize,$DisplayUnitPrice, 'right'); + $LeftOvers = $pdf->addTextWrap($Left_Margin+80+47+47+130,$YPos,60,$FontSize,$DisplayUnitPrice, 'right'); if ($PriceList['price']!=0){ $DisplayGPPercent = (int)(($PriceList['price']-$PriceList['standardcost'])*100/$PriceList['price']) . '%'; @@ -152,58 +183,53 @@ } if ($_POST['ShowGPPercentages']=='Yes'){ - $LeftOvers = $pdf->addTextWrap(530,$YPos,20,$FontSize,$DisplayGPPercent, 'right'); + $LeftOvers = $pdf->addTextWrap($Left_Margin+80+47+47+130+65,$YPos,20,$FontSize,$DisplayGPPercent, 'right'); } if ($_POST['CustomerSpecials']=='Customer Special Prices Only'){ /*Need to show to which branch the price relates */ if ($PriceList['branchcode']!=''){ - $LeftOvers = $pdf->addTextWrap(320,$YPos,130,$FontSize,$PriceList['brname'],'left'); + $LeftOvers = $pdf->addTextWrap($Left_Margin+80+47+47+130+65+25,$YPos,60,$FontSize,$PriceList['brname'],'left'); } else { - $LeftOvers = $pdf->addTextWrap(320,$YPos,130,$FontSize,_('All'),'left'); + $LeftOvers = $pdf->addTextWrap($Left_Margin+80+47+47+130+65+25,$YPos,60,$FontSize,_('All'),'left'); } - }else If ($_POST['CustomerSpecials']=='Full Description'){ + } else If ($_POST['CustomerSpecials']=='Full Description'){ - if(file_exists($_SESSION['part_pics_dir'] . '/' .$PriceList['stockid'].'.jpg') ) { - $img = imagecreatefromjpeg($_SESSION['part_pics_dir'] . '/' .$PriceList['stockid'].'.jpg'); - $width = imagesx( $img ); - $height = imagesy( $img ); + if(file_exists($_SESSION['part_pics_dir'] . '/' .$PriceList['stockid'].'.jpg') ) { + $img = imagecreatefromjpeg($_SESSION['part_pics_dir'] . '/' .$PriceList['stockid'].'.jpg'); + $width = imagesx( $img ); + $height = imagesy( $img ); if($width>$height){ $LeftOvers = $pdf->Image($_SESSION['part_pics_dir'] . '/'.$PriceList['stockid'].'.jpg',120,$Page_Height-$Top_Margin-$YPos+20,50,0); }else{ $LeftOvers = $pdf->Image($_SESSION['part_pics_dir'] . '/'.$PriceList['stockid'].'.jpg',120,$Page_Height-$Top_Margin-$YPos+20,0,40); } - }/*end checked file exist*/ + }/*end checked file exist*/ + + $Split = explode("\r\n", $PriceList['longdescription']); + $FontSize2=6; + if ($YPos < ($Bottom_Margin + (count($Split)*$line_height))){ + PageHeader(); + } + for ($i=0; $i<=count($Split); $i++) { + if(count($Split)==1){ + $YPos -=(1*$line_height); + $LeftOvers = $pdf->addTextWrap(140,$YPos,300,$FontSize2,$Split[$i]); + $YPos -=(1*$line_height); + $LeftOvers = $pdf->addTextWrap(140,$YPos,300,$FontSize2,''); + }elseif(count($Split)==2){ + $YPos -=(1*$line_height); + $LeftOvers = $pdf->addTextWrap(140,$YPos,300,$FontSize2,$Split[$i]); + }elseif(count($Split)>=3){ + $YPos -=(1*$line_height); + $LeftOvers = $pdf->addTextWrap(140,$YPos,300,$FontSize2,$Split[$i]); + } + }/*end for*/ + }/*end if full descriptions*/ - $Split = explode("\r\n", $PriceList['longdescription']); - $FontSize2=6; - - for ($i=0; $i<=count($Split); $i++) - { - if(count($Split)==1){ - $YPos -=(1*$line_height); - $LeftOvers = $pdf->addTextWrap(190,$YPos,260,$FontSize2,$Split[$i]); - $YPos -=(1*$line_height); - $LeftOvers = $pdf->addTextWrap(190,$YPos,260,$FontSize2,''); - }elseif(count($Split)==2){ - $YPos -=(1*$line_height); - $LeftOvers = $pdf->addTextWrap(190,$YPos,260,$FontSize2,$Split[$i]); - }elseif(count($Split)>=3){ - $YPos -=(1*$line_height); - $LeftOvers = $pdf->addTextWrap(190,$YPos,260,$FontSize2,$Split[$i]); - } - - - }/*end for*/ - - }/*end if*/ - - - if ($YPos < $Bottom_Margin + $line_height){ - include('includes/PDFPriceListPageHeader.inc'); - + PageHeader(); } } /*end inventory valn while loop */ @@ -211,26 +237,10 @@ $FontSize =10; /*Print out the category totals */ - $pdfcode = $pdf->output(); - $len = strlen($pdfcode); + $FileName=$_SESSION['DatabaseName']. '_' . _('Price_List') . '_' . date('Y-m-d').'.pdf'; + $pdf->OutputD($FileName); + $pdf->__destruct(); - if ($len<=20){ - $title = _('Print Price List Error'); - include('includes/header.inc'); - prnMsg(_('There were no price details to print out for the customer or category specified'),'warn'); - echo '<br><a href="'.$rootpath.'/index.php?' . SID . '">'. _('Back to the menu').'</a>'; - include('includes/footer.inc'); - exit; - } else { - header('Content-type: application/pdf'); - header('Content-Length: ' . $len); - header('Content-Disposition: inline; filename=PriceList.pdf'); - header('Expires: 0'); - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - header('Pragma: public'); - $FileName=$_SESSION['DatabaseName'].'_'.date('Y-m-d').'.pdf'; - $pdf->Output($FileName,'I'); - } } else { /*The option to print PDF was not hit */ $title= _('Price Listing'); @@ -280,10 +290,77 @@ echo '<option Value="Customer Special Prices Only">'. _('Customer Special Prices Only'); echo '<option Value="Full Description">'. _('Full Description'); echo '</select></td></tr>'; + + echo '<tr><td>' . _('Effective As At') . ':</td><td><input type="text" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" name="EffectiveDate" value="' . Date($_SESSION['DefaultDateFormat']) . '">'; echo '</table><div class="centre"><input type=Submit Name="PrintPDF" Value="'. _('Print PDF'). '"></div>'; } include('includes/footer.inc'); } /*end of else not PrintPDF */ + +function PageHeader () { + global $pdf; + global $PageNumber; + global $YPos; + global $Xpos; + global $line_height; + global $Page_Height; + global $Top_Margin; + global $Page_Width; + global $Right_Margin; + global $Left_Margin; + global $Bottom_Margin; + global $FontSize; + global $SalesTypeName; + global $CustomerName; + + if ($PageNumber>1){ + $pdf->newPage(); + } + + $FontSize=10; + $YPos= $Page_Height-$Top_Margin; + + $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,300,$FontSize,$_SESSION['CompanyRecord']['coyname']); + $LeftOvers = $pdf->addTextWrap($Page_Width-$Right_Margin-140,$YPos,140,$FontSize, _('Printed').': ' . Date($_SESSION['DefaultDateFormat']) . ' '. _('Page'). ' ' . $PageNumber); + + $YPos -=$line_height; + //Note, this is ok for multilang as this is the value of a Select, text in option is different + if ($_POST['CustomerSpecials']==_('Customer Special Prices Only')){ + $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,550,$FontSize, $CustomerName . ' ' . _('Prices for Categories').' ' . $_POST['FromCriteria'] . ' - ' . $_POST['ToCriteria'] . ' ' . _('Effective As At') . ' ' . $_POST['EffectiveDate']); + } else { + $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,550,$FontSize, $SalesTypeName . ' ' ._('Prices For Categories') . ' ' . $_POST['FromCriteria'] . ' - ' . $_POST['ToCriteria'] . ' ' . _('Effective As At') . ' ' . $_POST['EffectiveDate'] ); + } + + $YPos -=(2*$line_height); + /*Draw a rectangle to put the headings in */ + + $pdf->line($Left_Margin, $YPos+$line_height,$Page_Width-$Right_Margin, $YPos+$line_height); + $pdf->line($Left_Margin, $YPos+$line_height,$Left_Margin, $YPos- $line_height); + $pdf->line($Left_Margin, $YPos- $line_height,$Page_Width-$Right_Margin, $YPos- $line_height); + $pdf->line($Page_Width-$Right_Margin, $YPos+$line_height,$Page_Width-$Right_Margin, $YPos- $line_height); + + /*set up the headings */ + $Xpos = $Left_Margin+1; + + $LeftOvers = $pdf->addTextWrap($Xpos,$YPos,60,$FontSize, _('Category') . '/' . _('Item'), 'left'); + $LeftOvers = $pdf->addTextWrap($Xpos+70,$YPos,60,$FontSize, _('Effective Date Range'), 'left'); + + if ($_POST['CustomerSpecials']==_('Customer Special Prices Only')){ + $LeftOvers = $pdf->addTextWrap($Left_Margin+80+47+47+130+65+25,$YPos,60,$FontSize, _('Branch'), 'centre'); + } + + $LeftOvers = $pdf->addTextWrap($Left_Margin+80+47+47+130+20,$YPos,60,$FontSize, _('Price') , 'centre'); + + if ($_POST['ShowGPPercentages']=='Yes'){ + $LeftOvers = $pdf->addTextWrap($Left_Margin+80+47+47+130+65,$YPos,20,$FontSize, _('GP') .'%', 'centre'); + } + + $FontSize=8; + $YPos -= (1.5 * $line_height); + + $PageNumber++; +} + ?> \ No newline at end of file Modified: trunk/PDFStockNegatives.php =================================================================== --- trunk/PDFStockNegatives.php 2010-05-15 10:53:04 UTC (rev 3461) +++ trunk/PDFStockNegatives.php 2010-05-16 06:11:39 UTC (rev 3462) @@ -60,29 +60,7 @@ } } while ($NegativesRow = DB_fetch_array($result)); -/* -$pdfcode = $pdf->output(); -$len = strlen($pdfcode); - -if ($len<=10){ - include('includes/header.inc'); - echo '<p>'; - prnMsg( _('There was no negative stocks to print out'), 'warn'); - echo '<br><a href="' . $rootpath. '/index.php?' . SID . '">'. _('Back to the menu'). '</a>'; - include('includes/footer.inc'); - exit; -} else { - header('Content-type: application/pdf'); - header('Content-Length: ' . $len); - header('Content-Disposition: inline; filename=NegativeStocks.pdf'); - header('Expires: 0'); - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - header('Pragma: public'); - - $pdf->Output('PDFStockNegatives.pdf', 'I'); -} -*/ $pdf->OutputD($_SESSION['DatabaseName'] . '_NegativeStocks_' . date('Y-m-d') . '.pdf');//UldisN $pdf->__destruct(); //UldisN ?> Modified: trunk/Prices.php =================================================================== --- trunk/Prices.php 2010-05-15 10:53:04 UTC (rev 3461) +++ trunk/Prices.php 2010-05-16 06:11:39 UTC (rev 3462) @@ -69,7 +69,7 @@ ie the page has called itself with some user input */ //first off validate inputs sensible - $ZeroDate = Date($_SESSION['DefaultDateFormat'],Mktime(0,0,0,0,0,0)); + // This gives some date in 1999?? $ZeroDate = Date($_SESSION['DefaultDateFormat'],Mktime(0,0,0,0,0,0)); if (!is_double((double) trim($_POST['Price'])) OR $_POST['Price']=="") { $InputError = 1; @@ -83,14 +83,11 @@ $InputError =1; prnMsg (_('The date this price is be in effect to must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat'],'error'); } - if (Date1GreaterThanDate2($_POST['StartDate'],$_POST['EndDate']) AND $_POST['EndDate']!='' AND $_POST['EndDate']!=$ZeroDate){ + if (Date1GreaterThanDate2($_POST['StartDate'],$_POST['EndDate']) AND $_POST['EndDate']!=''){ $InputError =1; - - echo 'Debug - start date ' . $_POST['StartDate'] . ' end date: ' . $_POST['EndDate']; - prnMsg (_('The end date is expected to be after the start date, enter an end date after the start date for this price'),'error'); } - if (Date1GreaterThanDate2(Date($_SESSION['DefaultDateFormat']),$_POST['EndDate']) AND $_POST['EndDate']!='' AND $_POST['EndDate']!=$ZeroDate){ + if (Date1GreaterThanDate2(Date($_SESSION['DefaultDateFormat']),$_POST['EndDate']) AND $_POST['EndDate']!=''){ $InputError =1; prnMsg(_('The end date is expected to be after today. There is no point entering a new price where the effective date is before today!'),'error'); } @@ -253,7 +250,7 @@ $myrow['sales_type'], $myrow['price'], ConvertSQLDate($myrow['startdate']), - $EndDateDisplay; + $EndDateDisplay); } } Modified: trunk/PricesBasedOnMarkUp.php =================================================================== --- trunk/PricesBasedOnMarkUp.php 2010-05-15 10:53:04 UTC (rev 3461) +++ trunk/PricesBasedOnMarkUp.php 2010-05-16 06:11:39 UTC (rev 3462) @@ -1,14 +1,14 @@ <?php /* $Revision: 1.9 $ */ /* $Id$*/ -$PageSecurity=2; +$PageSecurity=11; include('includes/session.inc'); $title=_('Update Pricing From Costs'); include('includes/header.inc'); -echo '<br><div class="page_help_text">' . _('This page adds new prices or updates already existing prices for a specified sales type (price list) and currency for the stock category selected - based on a percentage mark up from cost prices or from preferred supplier cost data. This script does not care about the dates when prices are effective from and to - it will update all prices for the selections made irrespective of effectivity dates.') . '</div><br><div class="centre">'; +echo '<br><div class="page_help_text">' . _('This page adds new prices or updates already existing prices for a specified sales type (price list) and currency for the stock category selected - based on a percentage mark up from cost prices or from preferred supplier cost data.') . '</div><br><div class="centre">'; echo "<form method='POST' action='" . $_SERVER['PHP_SELF'] . '?' . SID . "'>"; @@ -17,9 +17,9 @@ $PricesResult = DB_query($SQL,$db); echo '<p><table> - <tr> - <td>' . _('Select the Price List to update') .':</td> - <td><select name="PriceList">'; + <tr> + <td>' . _('Select the Price List to update') .':</td> + <td><select name="PriceList">'; if (!isset($_POST['PriceList']) OR $_POST['PriceList']=='0'){ echo '<option selected VALUE="0">' . _('No Price List Selected'); @@ -69,7 +69,7 @@ echo ' <option selected value="PreferredSupplier">' . _('Preferred Supplier Cost Data') . '</option> <option value="StandardCost">' . $CostingBasis . '</option> <option value="OtherPriceList">' . _('Another Price List') . '</option>'; -}elseif ($_POST['CostType']=='StandardCost'){ +} elseif ($_POST['CostType']=='StandardCost'){ echo ' <option value="PreferredSupplier">' . _('Preferred Supplier Cost Data') . '</option> <option selected value="StandardCost">' . $CostingBasis . '</option> <option value="OtherPriceList">' . _('Another Price List') . '</option>'; @@ -138,6 +138,12 @@ echo '<tr><td>' . _('Rounding Factor') . ':</td> <td><input type=text class=number name="RoundingFactor" size="6" maxlength="6" value=' . $_POST['RoundingFactor'] . '></td></tr>'; +echo '<tr><td>' . _('New Price To Be Effective From') . ':</td> + <td><input type=text class=date alt="' . $_SESSION['DefaultDateFormat'] . '" name="PriceStartDate" size="10" maxlength="10" value="' . $_POST['PriceStartDate'] . '"></td></tr>'; + +echo '<tr><td>' . _('New Price To Be Effective To (Blank = No End Date)') . ':</td> + <td><input type=text class=date alt="' . $_SESSION['DefaultDateFormat'] . '" name="PriceEndDate" size="10" maxlength="10" value="' . $_POST['PriceEndDate'] . '"></td></tr>'; + if (!isset($_POST['IncreasePercent'])){ $_POST['IncreasePercent']=0; } @@ -146,158 +152,194 @@ <td><input type=text name='IncreasePercent' class=number size=4 maxlength=4 VALUE=" . $_POST['IncreasePercent'] . "></td></tr></table>"; -echo "<p><div class='centre'><input type=submit name='UpdatePrices' VALUE='" . _('Update Prices') . '\' onclick="return confirm(\'' . _('Are you sure you wish to update all the prices according to the criteria selected?') . '\');"></div>'; +echo "<p><div class='centre'><input type=submit name='UpdatePrices' VALUE='" . _('Update Prices') . '\' onclick="return confirm(\'' . _('Are you sure you wish to update or add all the prices according to the criteria selected?') . '\');"></div>'; echo '</form>'; -$InputError =0; //assume the best -if (isset($_POST['UpdatePrices']) AND $_POST['PriceList']=='0'){ - prnMsg(_('No price list is selected to update. No updates will take place'),'error'); - $InputError =1; -} -if (isset($_POST['UpdatePrices']) AND $_POST['CurrCode']=='0'){ - prnMsg(_('No price list currency is selected to update. No updates will take place'),'error'); - $InputError =1; -} - -if (isset($_POST['UpdatePrices']) AND $_POST['StkCatTo']<$_POST['StkCatFrom']){ - prnMsg(_('The stock category from must be before the stock category to - there would be not items in the range to update'),'error'); - $InputError =1; -} -if (isset($_POST['UpdatePrices']) AND $_POST['CostType']=='OtherPriceList' AND $_POST['BasePriceList']=='0'){ - echo '<br>Base price list selected: ' .$_POST['BasePriceList']; - prnMsg(_('When you are updating prices based on another price list - the other price list must also be selected. No updates will take place until the other price list is selected'),'error'); - $InputError =1; -} -if (isset($_POST['UpdatePrices']) AND $_POST['CostType']=='OtherPriceList' AND $_POST['BasePriceList']==$_POST['PriceList']){ - prnMsg(_('When you are updating prices based on another price list - the other price list cannot be the same as the price list being used for the calculation. No updates will take place until the other price list selected is different from the price list to be updated' ),'error'); - $InputError =1; -} - -if (isset($_POST['UpdatePrices']) AND $InputError==0) { - echo '<br>' . _('So we are using a price list/sales type of') .' : ' . $_POST['PriceList']; - echo '<br>' . _('updating only prices in') . ' : ' . $_POST['CurrCode']; - echo '<br>' . _('and the stock category range from') . ' : ' . $_POST['StkCatFrom'] . ' ' . _('to') . ' ' . $_POST['StkCatTo']; - echo '<br>' . _('and we are applying a markup percent of') . ' : ' . $_POST['IncreasePercent']; - echo '<br>' . _('against') . ' '; - - if ($_POST['CostType']=='PreferredSupplier'){ - echo _('Preferred Supplier Cost Data'); - } elseif ($_POST['CostType']=='OtherPriceList') { - echo _('Price List') . ' ' . $_POST['BasePriceList']; - } else { - echo $CostingBasis; - } - +if (isset($_POST['UpdatePrices'])){ + $InputError =0; //assume the best if ($_POST['PriceList']=='0'){ - echo '<br>' . _('The price list/sales type to be updated must be selected first'); - include ('includes/footer.inc'); - exit; + prnMsg(_('No price list is selected to update. No updates will take place'),'error'); + $InputError =1; } if ($_POST['CurrCode']=='0'){ - echo '<br>' . _('The currency of prices to be updated must be selected first'); - include ('includes/footer.inc'); - exit; + prnMsg(_('No price list currency is selected to update. No updates will take place'),'error'); + $InputError =1; } - - $sql = "SELECT stockid, - materialcost+labourcost+overheadcost AS cost - FROM stockmaster - WHERE categoryid>='" . $_POST['StkCatFrom'] . "' - AND categoryid <='" . $_POST['StkCatTo'] . "'"; - $PartsResult = DB_query($sql,$db); - - $IncrementPercentage = $_POST['IncreasePercent']/100; - - $CurrenciesResult = DB_query("SELECT rate FROM currencies WHERE currabrev='" . $_POST['CurrCode'] . "'",$db); - $CurrencyRow = DB_fetch_row($CurrenciesResult); - $CurrencyRate = $CurrencyRow[0]; - - while ($myrow=DB_fetch_array($PartsResult)){ - -//Figure out the cost to use + + if (! Is_Date($_POST['PriceEndDate']) AND $_POST['PriceEndDate']!=''){ + $InputError =1; + prnMsg (_('The date the new price is to be in effect to must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat'],'error'); + } + if (! Is_Date($_POST['PriceStartDate'])){ + $InputError =1; + prnMsg (_('The date this price is to take effect from must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat'],'error'); + } + if (Date1GreaterThanDate2($_POST['PriceStartDate'],$_POST['PriceEndDate']) AND $_POST['PriceEndDate']!=''){ + $InputError =1; + prnMsg (_('The end date is expected to be after the start date, enter an end date after the start date for this price'),'error'); + } + if (Date1GreaterThanDate2(Date($_SESSION['DefaultDateFormat']),$_POST['PriceStartDate'])){ + $InputError =1; + prnMsg(_('The date this new price is to start from is expected to be after today'),'error'); + } + if ($_POST['StkCatTo']<$_POST['StkCatFrom']){ + prnMsg(_('The stock category from must be before the stock category to - there would be not items in the range to update'),'error'); + $InputError =1; + } + if ($_POST['CostType']=='OtherPriceList' AND $_POST['BasePriceList']=='0'){ + echo '<br>Base price list selected: ' .$_POST['BasePriceList']; + prnMsg(_('When you are updating prices based on another price list - the other price list must also be selected. No updates will take place until the other price list is selected'),'error'); + $InputError =1; + } + if ($_POST['CostType']=='OtherPriceList' AND $_POST['BasePriceList']==$_POST['PriceList']){ + prnMsg(_('When you are updating prices based on another price list - the other price list cannot be the same as the price list being used for the calculation. No updates will take place until the other price list selected is different from the price list to be updated' ),'error'); + $InputError =1; + } + + if ($InputError==0) { + prnMsg(_('For a log of all the prices changed this page should be printed with CTRL+P'),'info'); + echo '<br>' . _('So we are using a price list/sales type of') .' : ' . $_POST['PriceList']; + echo '<br>' . _('updating only prices in') . ' : ' . $_POST['CurrCode']; + echo '<br>' . _('and the stock category range from') . ' : ' . $_POST['StkCatFrom'] . ' ' . _('to') . ' ' . $_POST['StkCatTo']; + echo '<br>' . _('and we are applying a markup percent of') . ' : ' . $_POST['IncreasePercent']; + echo '<br>' . _('against') . ' '; + if ($_POST['CostType']=='PreferredSupplier'){ - $sql = "SELECT purchdata.price/purchdata.conversionfactor/currencies.rate AS cost - FROM purchdata INNER JOIN suppliers - ON purchdata.supplierno=suppliers.supplierid - INNER JOIN currencies - ON suppliers.currcode=currencies.currabrev - WHERE purchdata.preferred=1 AND purchdata.stockid='" . $myrow['stockid'] ."'"; - $ErrMsg = _('Could not get the supplier purchasing information for a preferred supplier for the item') . ' ' . $myrow['stockid']; - $PrefSuppResult = DB_query($sql,$db,$ErrMsg); - if (DB_num_rows($PrefSuppResult)==0){ - prnMsg(_('There is no preferred supplier data for the item') . ' ' . $myrow['stockid'] . ' ' . _('prices will not be updated for this item'),'warn'); - $Cost = 0; - } elseif(DB_num_rows($PrefSuppResult)>1) { - prnMsg(_('There is more than a single preferred supplier data for the item') . ' ' . $myrow['stockid'] . ' ' . _('prices will not be updated for this item'),'warn'); - $Cost = 0; + echo _('Preferred Supplier Cost Data'); + } elseif ($_POST['CostType']=='OtherPriceList') { + echo _('Price List') . ' ' . $_POST['BasePriceList']; + } else { + echo $CostingBasis; + } + + if ($_POST['PriceList']=='0'){ + echo '<br>' . _('The price list/sales type to be updated must be selected first'); + include ('includes/footer.inc'); + exit; + } + if ($_POST['CurrCode']=='0'){ + echo '<br>' . _('The currency of prices to be updated must be selected first'); + include ('includes/footer.inc'); + exit; + } + if (Is_Date($_POST['PriceEndDate'])){ + $SQLEndDate = FormatDateForSQL($_POST['PriceEndDate']); + } else { + $SQLEndDate = '0000-00-00'; + } + $sql = "SELECT stockid, + materialcost+labourcost+overheadcost AS cost + FROM stockmaster + WHERE categoryid>='" . $_POST['StkCatFrom'] . "' + AND categoryid <='" . $_POST['StkCatTo'] . "'"; + $PartsResult = DB_query($sql,$db); + + $IncrementPercentage = $_POST['IncreasePercent']/100; + + $CurrenciesResult = DB_query("SELECT rate FROM currencies WHERE currabrev='" . $_POST['CurrCode'] . "'",$db); + $CurrencyRow = DB_fetch_row($CurrenciesResult); + $CurrencyRate = $CurrencyRow[0]; + + while ($myrow=DB_fetch_array($PartsResult)){ + + //Figure out the cost to use + if ($_POST['CostType']=='PreferredSupplier'){ + $sql = "SELECT purchdata.price/purchdata.conversionfactor/currencies.rate AS cost + FROM purchdata INNER JOIN suppliers + ON purchdata.supplierno=suppliers.supplierid + INNER JOIN currencies + ON suppliers.currcode=currencies.currabrev + WHERE purchdata.preferred=1 AND purchdata.stockid='" . $myrow['stockid'] ."'"; + $ErrMsg = _('Could not get the supplier purchasing information for a preferred supplier for the item') . ' ' . $myrow['stockid']; + $PrefSuppResult = DB_query($sql,$db,$ErrMsg); + if (DB_num_rows($PrefSuppResult)==0){ + prnMsg(_('There is no preferred supplier data for the item') . ' ' . $myrow['stockid'] . ' ' . _('prices will not be updated for this item'),'warn'); + $Cost = 0; + } elseif(DB_num_rows($PrefSuppResult)>1) { + prnMsg(_('There is more than a single preferred supplier data for the item') . ' ' . $myrow['stockid'] . ' ' . _('prices will not be updated for this item'),'warn'); + $Cost = 0; + } else { + $PrefSuppRow = DB_fetch_row($PrefSuppResult); + $Cost = $PrefSuppRow[0]; + } + } elseif ($_POST['CostType']=='OtherPriceList'){ + $sql = "SELECT price FROM + prices + WHERE typeabbrev= '" . $_POST['BasePriceList'] . "' + AND currabrev='" . $_POST['CurrCode'] . "' + AND debtorno='' + AND enddate='0000-00-00' + AND stockid='" . $myrow['stockid'] . "' + ORDER BY startdate DESC"; + $ErrMsg = _('Could not get the base price for the item') . ' ' . $myrow['stockid'] . _('from the price list') . ' ' . $_POST['BasePriceList']; + $BasePriceResult = DB_query($sql,$db,$ErrMsg); + if (DB_num_rows($BasePriceResult)==0){ + prnMsg(_('There is no default price defined in the base price list for the item') . ' ' . $myrow['stockid'] . ' ' . _('prices will not be updated for this item'),'warn'); + $Cost = 0; + } else { + $BasePriceRow = DB_fetch_row($BasePriceResult); + $Cost = $BasePriceRow[0]; + } + } else { //Must be using standard/weighted average costs + $Cost = $myrow['cost']; + if ($Cost<=0){ + prnMsg(_('The cost for this item is not set up or is set up as less than or equal to zero - no price changes will be made based on zero cost items. The item concerned is:') . ' ' . $myrow['stockid'],'warn'); + } + } + + if ($_POST['CostType']!='OtherPriceList'){ + $RoundedPrice = round(($Cost * (1+ $IncrementPercentage) * $CurrencyRate+($_POST['RoundingFactor']/2))/$_POST['RoundingFactor']) * $_POST['RoundingFactor']; + if ($RoundedPrice <=0){ + $RoundedPrice = $_POST['RoundingFactor']; + } } else { - $PrefSuppRow = DB_fetch_row($PrefSuppResult); - $Cost = $PrefSuppRow[0]; + $RoundedPrice = round(($Cost * (1+ $IncrementPercentage)+($_POST['RoundingFactor']/2))/$_POST['RoundingFactor']) * $_POST['RoundingFactor']; + if ($RoundedPrice <=0){ + $RoundedPrice = $_POST['RoundingFactor']; + } } - } elseif ($_POST['CostType']=='OtherPriceList'){ - $sql = "SELECT price FROM - prices - WHERE typeabbrev= '" . $_POST['BasePriceList'] . "' + + if ($Cost > 0) { + $CurrentPriceResult = DB_query("SELECT price FROM + prices + WHERE typeabbrev= '" . $_POST['PriceList'] . "' + AND debtorno ='' + AND currabrev='" . $_POST['CurrCode'] . "' + AND enddate='" . $SQLEndDate . "' + AND startdate='" . FormatDateForSQL($_POST['PriceStartDate']) . "' + AND stockid='" . $myrow['stockid'] . "'",$db); + if (DB_num_rows($CurrentPriceResult)==1){ + $sql = 'UPDATE prices SET price=' . $RoundedPrice . " + WHERE typeabbrev='" . $_POST['PriceList'] . "' AND currabrev='" . $_POST['CurrCode'] . "' + AND debtorno='' + AND startdate ='" . FormatDateForSQL($_POST['PriceStartDate']) . "' + AND enddate ='" . $SQLEndDate . "' AND stockid='" . $myrow['stockid'] . "'"; - $ErrMsg = _('Could not get the base price for the item') . ' ' . $myrow['stockid'] . _('from the price list') . ' ' . $_POST['BasePriceList']; - $BasePriceResult = DB_query($sql,$db,$ErrMsg); - if (DB_num_rows($BasePriceResult)==0){ - prnMsg(_('There is no price defined in the base price list for the item') . ' ' . $myrow['stockid'] . ' ' . _('prices will not be updated for this item'),'warn'); - $Cost = 0; - } else { - $BasePriceRow = DB_fetch_row($BasePriceResult); - $Cost = $BasePriceRow[0]; - } - } else { //Must be using standard/weighted average costs - $Cost = $myrow['cost']; - if ($Cost<=0){ - prnMsg(_('The cost for this item is not set up or is set up as less than or equal to zero - no price changes will be made based on zero cost items. The item concerned is:') . ' ' . $myrow['stockid'],'warn'); - } - } - - if ($_POST['CostType']!='OtherPriceList'){ - $RoundedPrice = round(($Cost * (1+ $IncrementPercentage) * $CurrencyRate+($_POST['RoundingFactor']/2))/$_POST['RoundingFactor']) * $_POST['RoundingFactor']; - if ($RoundedPrice <=0){ - $RoundedPrice = $_POST['RoundingFactor']; - } - } else { - $RoundedPrice = round(($Cost * (1+ $IncrementPercentage)+($_POST['RoundingFactor']/2))/$_POST['RoundingFactor']) * $_POST['RoundingFactor']; - if ($RoundedPrice <=0){ - $RoundedPrice = $_POST['RoundingFactor']; - } - } - - if ($Cost > 0) { - $CurrentPriceResult = DB_query("SELECT price FROM - prices - WHERE typeabbrev= '" . $_POST['PriceList'] . "' - AND currabrev='" . $_POST['CurrCode'] . "' - AND stockid='" . $myrow['stockid'] . "'",$db); - if (DB_num_rows($CurrentPriceResult)==1){ - $sql = 'UPDATE prices SET price=' . $RoundedPrice . " - WHERE typeabbrev='" . $_POST['PriceList'] . "' - AND currabrev='" . $_POST['CurrCode'] . "' - AND stockid='" . $myrow['stockid'] . "'"; - $ErrMsg =_('Error updating prices for') . ' ' . $myrow['stockid'] . ' ' . _('because'); - $result = DB_query($sql,$db,$ErrMsg); - prnMsg(_('Updating prices for') . ' ' . $myrow['stockid'] . ' ' . _('to') . ' ' . $RoundedPrice,'info'); - } else { - $sql = "INSERT INTO prices (stockid, - typeabbrev, - currabrev, - price) - VALUES ('" . $myrow['stockid'] . "', - '" . $_POST['PriceList'] . "', - '" . $_POST['CurrCode'] . "', - " . $RoundedPrice . ")"; - $ErrMsg =_('Error inserting prices for') . ' ' . $myrow['stockid'] . ' ' . _('because'); - $result = DB_query($sql,$db,$ErrMsg); - prnMsg(_('Inserting new price for') . ' ' . $myrow['stockid'] . ' ' . _('to') . ' ' . $RoundedPrice,'info'); - } //end if update or insert - }// end if cost > 0 - }//end while loop around items in the category + $ErrMsg =_('Error updating prices for') . ' ' . $myrow['stockid'] . ' ' . _('because'); + $result = DB_query($sql,$db,$ErrMsg); + prnMsg(_('Updating price for') . ' ' . $myrow['stockid'] . ' ' . _('to') . ' ' . $RoundedPrice,'info'); + } else { + $sql = "INSERT INTO prices (stockid, + typeabbrev, + currabrev, + startdate, + enddate, + price) + VALUES ('" . $myrow['stockid'] . "', + '" . $_POST['PriceList'] . "', + '" . $_POST['CurrCode'] . "', + '" . FormatDateForSQL($_POST['PriceStartDate']) . "', + '" . $SQLEndDate . "', + " . $RoundedPrice . ")"; + $ErrMsg =_('Error inserting prices for') . ' ' . $myrow['stockid'] . ' ' . _('because'); + $result = DB_query($sql,$db,$ErrMsg); + prnMsg(_('Inserting new price for') . ' ' . $myrow['stockid'] . ' ' . _('to') . ' ' . $RoundedPrice,'info'); + } //end if update or insert + }// end if cost > 0 + }//end while loop around items in the category + } } include('includes/footer.inc'); ?> \ No newline at end of file Modified: trunk/PricesByCost.php =================================================================== --- trunk/PricesByCost.php 2010-05-15 10:53:04 UTC (rev 3461) +++ trunk/PricesByCost.php 2010-05-16 06:11:39 UTC (rev 3462) @@ -1,11 +1,13 @@ <?php /* $Id$ */ // PricesByCost.php - -$PageSecurity = 2; +$PageSecurity = 11; include ('includes/session.inc'); $title = _('Update of Prices By Cost'); include ('includes/header.inc'); + echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/inventory.png" title="' . _('Inventory') . '" alt="">' . ' ' . _('Update Price By Cost') . ''; + if (isset($_POST['submit']) or isset($_POST['update'])) { if ($_POST['Margin'] == "") { header('Location: PricesByCost.php'); @@ -15,64 +17,95 @@ } else { $Comparator = ">="; } /*end of else Comparator */ - if ($_POST['StockCat'] == 'all') { - $Category = 'stockmaster.stockid = prices.stockid'; + if ($_POST['StockCat'] != 'all') { + $Category = " AND stockmaster.categoryid = '" . $_POST['StockCat'] . "'"; } else { - $Category = "stockmaster.stockid = prices.stockid AND stockmaster.categoryid = '" . $_POST['StockCat'] . "'"; - } /*end of else StockCat */ + $Category =''; + }/*end of else StockCat */ + $sql = 'SELECT stockmaster.stockid, stockmaster.description, + prices.debtorno, + prices.branchcode, (stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost) as cost, - prices.price as price, prices.debtorno as customer, prices.branchcode as branch - FROM stockmaster, prices - WHERE ' . $Category . ' - AND prices.price' . $Comparator . '(stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost) * ' . $_POST['Margin'] . " - AND prices.typeabbrev ='" . $_POST['SalesType'] . "' - AND prices.currabrev ='" . $_POST['CurrCode'] . "'"; + prices.price as price, prices.debtorno as customer, prices.branchcode as branch, + prices.startdate, + prices.enddate + FROM stockmaster, prices + WHERE stockmaster.stockid=prices.stockid' . $Category . ' + AND prices.price' . $Comparator . '(stockmaster.materialcost + stockmaster.labourcost + stockmaster.overheadcost) * ' . $_POST['Margin'] . " + AND prices.typeabbrev ='" . $_POST['SalesType'] . "' + AND prices.currabrev ='" . $_POST['CurrCode'] . "' + AND (prices.enddate>='" . Date('Y-m-d') . "' OR prices.enddate='0000-00-00')"; $result = DB_query($sql, $db); $numrow = DB_num_rows($result); + + if ($_POST['submit'] == 'Update') { + //Update Prices + $PriceCounter =0; + while ($myrow = DB_fetch_array($result)) { + //update database if update pressed + $SQLUpdate = "UPDATE prices + SET price = '" . $_POST['Price_' . $PriceCounter] . "' + WHERE `prices`.`stockid` = '" . $_POST['StockID_' . $PriceCounter] . "' + AND prices.typeabbrev ='" . $_POST['SalesType'] . "' + AND prices.currabrev ='" . $_POST['CurrCode'] . "' + AND prices.debtorno ='" . $_POST['DebtorNo_' . $PriceCounter] . "' + AND prices.branchcode ='" . $_POST['BranchCode_' . $PriceCounter] . "' + AND prices.startdate ='" . $_POST['StartDate_' . $PriceCounter] . "' + AND prices.enddate ='" . $_POST['EndDate_' . $PriceCounter] . "'"; + $ResultUpdate = DB_query($SQLUpdate, $db); + $PriceCounter++; + } + DB_free_result($result); //clear the old result + $result = DB_query($sql, $db); //re-run the query with the updated prices + $numrow = DB_num_rows($result); // get the new number - should be the same!! + } + $sqlcat = "SELECT categorydescription FROM stockcategory WHERE categoryid='" . $_POST['StockCat'] . "'"; $ResultCat = DB_query($sqlcat, $db); - $Category = DB_fetch_array($ResultCat); + $CategoryRow = DB_fetch_array($ResultCat); + $sqltype = "SELECT sales_type FROM salestypes WHERE typeabbrev='" . $_POST['SalesType'] . "'"; $ResultType = DB_query($sqltype, $db); - $Type = DB_fetch_array($ResultType); - if (isset($Category[0])) { - $Cat = $Category[0]; + $SalesTypeRow = DB_fetch_array($ResultType); + + if (isset($CategoryRow['categorgdescription'])) { + $CategoryText = _('the') . ' ' . $CategoryRow['categorgdescription'] . ' ' . _('category'); } else { - $Cat = 'All Category'; + $CategoryText = _('all Categories'); } /*end of else Category */ - echo '<div class="page_help_text">' . _('Items in category ') . '' . $Cat . '' . _(' With Price ') . '' . $Comparator . '' . $_POST['Margin'] . '' . _(' times ') . '' . _('Cost in Price List ') . '' . $Type['0'] . '</div><br><br>'; - if ($numrow != 0) { + + echo '<div class="page_help_text">' . _('Items in') . ' ' . $CategoryText . ' ' . _('With Prices') . ' ' . $Comparator . '' . $_POST['Margin'] . ' ' . _('times') . ' ' . _('Cost in Price List') . ' ' . $SalesTypeRow['sales_type'] . '</div><br><br>'; + + if ($numrow > 0) { //the number of prices returned from the main prices query is echo '<table>'; echo '<tr><th>' . _('Code') . '</th> <th>' . _('Description') . '</th> <th>' . _('Customer') . '</th> <th>' . _('Branch') . '</th> + <th>' . _('Start Date') . '</th> + <th>' . _('End Date') . '</th> <th>' . _('Cost') . '</th> <th>' . _('Current Margin') . '</th> <th>' . _('Price Proposed') . '</th> <th>' . _('Price in pricelist') . '</th> <tr>'; $k = 0; //row colour counter - echo '<form action="PricesByCost.php" method="POST" name="' . _('update') . '">'; + echo '<form action="' .$_SERVER['PHP_SELF'] .'" method="POST" name="update">'; + echo'<input type="hidden" value=' . $_POST['StockCat'] . ' name="StockCat"> + <input type="hidden" value=' . $_POST['Margin'] . ' name="Margin"> + <input type="hidden" value=' . $_POST['CurrCode'] . ' name="CurrCode"> + <input type="hidden" value=' . $_POST['Comparator'] . ' name="Comparator"> + <input type="hidden" value=' . $_POST['SalesType'] . ' name="SalesType">'; + + $PriceCounter =0; while ($myrow = DB_fetch_array($result)) { - //update database if update pressed - if ($_POST['submit'] == 'Update') { - //Update Prices - $SQLUpdate = "UPDATE prices - SET price = '" . $_POST[$myrow['0']] . "' - WHERE `prices`.`stockid` = '" . $myrow['0'] . "' - AND prices.typeabbrev ='" . $_POST['SalesType'] . "' - AND prices.currabrev ='" . $_POST['CurrCode'] . "' - AND prices.debtorno ='" . $myrow['customer'] . "' - AND prices.branchcode ='" . $myrow['branch'] . "'"; - $Resultup = DB_query($SQLUpdate, $db); - } + if ($k == 1) { echo '<tr class="EvenTableRows">'; $k = 0; @@ -81,54 +114,59 @@ $k = 1; } //get cost - if ($myrow['cost'] == "") { - $Cost = "0"; + if ($myrow['cost'] == '') { + $Cost = 0; } else { $Cost = $myrow['cost']; } /*end of else Cost */ - //get qty price - if (isset($_POST[$myrow['0']])) { - $price = $_POST[$myrow['0']]; + + //variables for update + echo '<input type="hidden" value=' . $myrow['stockid'] . ' name="StockID_' . $PriceCounter .'"> + <input type="hidden" value=' . $myrow['debtorno'] . ' name="DebtorNo_' . $PriceCounter .'"> + <input type="hidden" value=' . $myrow['branchcode'] . ' name="BranchCode_' . $PriceCounter .'"> + <input type="hidden" value=' . $myrow['startdate'] . ' name="StartDate_' . $PriceCounter .'"> + <input type="hidden" value=' . $myrow['enddate'] . ' name="EndDate_' . $PriceCounter .'">'; + //variable for current margin + if ($Cost != 0){ + $CurrentMargin = $Price / $Cost; } else { - $price = $myrow['price']; - } /*end of else price */ - //variable for update data - echo ' - <input type="hidden" value=' . $_POST['StockCat'] . ' name=' . _('StockCat') . ' /> - <input type="hidden" value=' . $_POST['Margin'] . ' name=' . _('Margin') . ' /> - <input type="hidden" value=' . $_POST['CurrCode'] . ' name=' . _('CurrCode') . ' /> - <input type="hidden" value=' . $_POST['Comparator'] . ' name=' . _('Comparator') . ' /> - <input type="hidden" value=' . $_POST['SalesType'] . ' name=' . _('SalesType') . ' /> - <input type="hidden" value=' . $myrow['0'] . ' name=' . _('Id') . ' /> - <input type="hidden" value=' . $_POST['Price'] . ' name=' . _('Price') . ' /> - '; - //variable for current margin - $currentmargin = $price / $Cost; + $CurrentMargin = 0; + } //variable for proposed - $proposed = $Cost * $_POST['Margin']; - echo ' <td>' . $myrow['0'] . '</td> - <td>' . $myrow['1'] . '</td> + $Proposed = $Cost * $_POST['Margin']; + if ($myrow['enddate']=='0000-00-00'){ + $EndDateDisplay = _('No End Date'); + } else { + $EndDateDisplay = ConvertSQLDate($myrow['enddate']); + } + echo ' <td>' . $myrow['stockid'] . '</td> + <td>' . $myrow['description'] . '</td> <td>' . $myrow['customer'] . '</td> <td>' . $myrow['branch'] . '</td> + <td>' . ConvertSQLDate($myrow['startdate']) . '</td> + <td>' . $EndDateDisplay . '</td> <td class="number">' . number_format($Cost, 2) . '</td> - <td class="number">' . number_format($currentmargin, 2) . '</td> - <td class="number">' . number_format($proposed, 2) . '</td> - <td><input type="text" class="number" name="' . $myrow['0'] . '" MAXLENGTH =14 size=15 value="' . $price . '"></td> + <td class="number">' . number_format($CurrentMargin, 2) . '</td> + <td class="number">' . number_format($Proposed, 2) . '</td> + <td><input type="text" class="number" name="Price_' . $PriceCounter . '" MAXLENGTH =14 size=15 value="' . $myrow['price'] . '"></td> </tr> '; + $PriceCounter++; } //end of looping echo '<tr> - <td style="text-align:right" colspan=4><input type=submit name=submit value=' . _("Update") . '></td> - <td style="text-align:left" colspan=3><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '"><input type=submit value=' . _("Back") . '><a/></td> + <td style="text-align:right" colspan=4><input type=submit name=submit value=' . _('Update') . '></td> + <td style="text-align:left" colspan=3><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '"><input type=submit value=' . _('Back') . '><a/></td> </tr></form>'; } else { + prnMsg(_('There were no prices meeting the criteria specified to review'),'info'); echo '<p><div class="centre"><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '">' . _('Back') . '<a/></div><p>'; } } else { /*The option to submit was not hit so display form */ echo '<div class="page_help_text">' . _('Use this report to display price list with the cost.') . '</div><br>'; - echo '</br></br><form action=' . $_SERVER['PHP_SELF'] . " method='post'><table>"; + echo '</br></br><form action="' . $_SERVER['PHP_SELF'] . '" method="post"><table>'; + $SQL = 'SELECT categoryid, categorydescription - FROM stockcategory - ORDER BY categorydescription'; + FROM stockcategory + ORDER BY categorydescription'; $result1 = DB_query($SQL, $db); echo '<tr> <td>' . _('Category') . ':</td> @@ -147,8 +185,11 @@ } else { echo '</select>'.' '. _('Standard Cost') . ' x </td>'; } + if (!isset($_POST['Margin'])){ + $_POST['Margin']=1; + } echo '<td> - <input type="text" class="number" name="Margin" MAXLENGTH =10 size=11 value=0></td></tr>'; + <input type="text" class="number" name="Margin" MAXLENGTH =2 size=2 value=' .$_POST['Margin'] . '></td></tr>'; $result = DB_query('SELECT typeabbrev, sales_type FROM salestypes ', $db); echo '<tr><td>' . _('Sales Type') . '/' . _('Price List') . ":</td> <td><select name='SalesType'>"; Modified: trunk/Z_PriceChanges.php =================================================================== --- trunk/Z_PriceChanges.php 2010-05-15 10:53:04 UTC (rev 3461) +++ trunk/Z_PriceChanges.php 2010-05-16 06:11:39 UTC (rev 3462) @@ -10,6 +10,8 @@ echo '<br>' . _('This page updates already existing prices for a specified sales type (price list)') . '. ' . _('Choose between updating only customer special prices where the customer is set up under the price list selected, or all prices under the sales type or just specific prices for a customer for the stock category selected'); +prnMsg (_('This script takes no account of start and end dates of prices and updates all historical prices as well as current prices - better to use new scripts under Inventory -> Maintenance'),'warn'); + echo "<form method='POST' action='" . $_SERVER['PHP_SELF'] . '?' . SID . "'>"; $SQL = 'SELECT sales_type, typeabbrev FROM salestypes'; @@ -131,7 +133,7 @@ } $result = DB_query($sql,$db); - $ErrMsg =_('Error updating prices for') . ' ' . $myrow['stockid'] . ' ' . _('because'); + $ErrMsg =_('Error updating prices for') . ' ' . $myrow['stockid'] . ' ' . _('because'); prnMsg(_('Updating prices for') . ' ' . $myrow['stockid'],'info'); } Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-15 10:53:04 UTC (rev 3461) +++ trunk/doc/Change.log.html 2010-05-16 06:11:39 UTC (rev 3462) @@ -1,5 +1,9 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>16/5/10 Phil: reworked PDFPriceList to use the new effective dates fields and print out effective prices as at a specified date - showing effective dates on the report - also ditched includes/PDFPriceListPageHeader.php in favour of a PageHeader() function inside PDFPriceList.php. Also made the script work with tcpdf - not sure how it was missed before?</p> +<p>16/5/10 Phil: reworked PricesBasedOnMarkUp.php to insert new prices with effectivity dates and update the prices where effectivity dates specified.</p> +<p>16/5/10 Phil: reworked PricesByCost.php this was bit of a dodgy script - well I found it hard to follow - in the words of Frank Sinatra - I did it my way! Also built in effectivity dates to display and ensure correct prices updated now the primary key of prices is changed.</p> +<p>16/5/10 Phil: Wrote up the manual so that the logic of pricing with effective dates is explained</p> <p>15/5/10 Phil: Used Lindsay/Ngaraj's nice email address checking function to replace the existing function in MiscFunctions.php and includes MiscFunctions.php in install/save.php to avoid duplication of the function</p> <p>15/5/10 Phil: $debug variable in UserLogin.php was only set on first login - not subsequent page calls (its not a session variable) - moved it back into session.inc so that full info about bugs is available to sysadmins <p>15/5/10 Phil: GetPrices.inc Prices.php and Prices_Customer.php - modified to allow default prices - with no end dates - reducing requirement to administer - also updated Prices section of the manual Modified: trunk/doc/Manual/ManualPrices.html =================================================================== --- trunk/doc/Manual/ManualPrices.html 2010-05-15 10:53:04 UTC (rev 3461) +++ trunk/doc/Manual/ManualPrices.html 2010-05-16 06:11:39 UTC (rev 3462) @@ -22,19 +22,30 @@ <br><br> Prices can be amended at any time. However, changes to a price do not automatically cascade into sales orders for the item that are yet to be delivered, these orders would have to be changed manually as necessary. <br><br> -There is a utility page that has some options for making bulk changes to pricing avoiding extensive re-keying exercises. Great care should be taken with this facility. System administrator permission is required to access this page accordingly. +<font size="+1"><b>Price Maintenance Utilities</b></font> <br><br> -The script is called: Z_PriceChanges.php and is accessed from the Utilities index Z_index.php -<br><br> -This script allows bulk increase/decreases by percentage for specific or a range of stock categories and for specific sales types. There is the opportunity to update the pricing: -<br><br> +There is a utility script that has some options for making bulk changes to pricing avoiding extensive re-keying. This script is accessed from the main menu under "Inventory->Add Or Update Prices Based On Cost". Great care should be taken with this facilities since bulk updates and inserts of new prices are performed as a result. System administrator permission is required to access this page accordingly. The script named PricesBasedOnMarkUp.php is quite flexible and can update/insert new default prices for a particular price list/currency based on any of: <ul> -<li>For all prices for the sales type within the stock categories selected or -<li>For only the default prices for the sales type within the stock categories selected or -<li>For the selected customer special prices - provided the customer selected belongs to the sales type selected in the bulk change screen. +<li>another price list plus a markup</li> +<li>the supplier purchasing cost data plus a markup</li> +<li>the system cost plus a markup</li> </ul> -Equally flexible options exist for printing price lists from the main menu under the orders tab under inquiries and reports. +If using another price list the price used as the base for the new price will be the latest default price i.e. no customer speicifc prices will be used - nor updated - and the price with the most recent start date will be chosen as the basis for the calculation of the new price. <br><br> +The script allows you to specifiy when the new prices will be effective from and to - if the field for effective to is left blank then the new price is assumed to be effective until a later price is entered. If you have run this script once and wish to change the parameters to use say a different markup - the prices previously entered by the script can be updated rather than creating a lot of new prices, provided that the same start and end dates are specified. You can only specify price effective from dates for days after the current day. +<br><br> +<font size="+1"><b>Printing Price Lists</b></font> +<br><br> +Flexible options exist for printing price lists from the main menu under the sales tab under inquiries and reports ->Print Price Lists. Price lists for a particular price list and specific category or range of categories can be printed to pdf. It is also possible to print the price list with the current gross profitability of those prices displayed for internal use. Prices specific to particular customers can also be printed having selected the customer first. +<br><br> + +<br><br> +<font size="+1"><b>Reviewing Prices Based on Cost</b></font> +<br><br> +It is possible to review prices based on the proportion of cost that they represent - e.g. you may wish to review costs that are less than 100% of cost (or 1 times the cost) - i.e. prices that would result in a gross loss - a wise idea indeed! The prices meeting the criteria are displayed and available to be modified. You can specify any number of times the cost for the critiera - to look at the prices where the margin is less than 50% on cost the multiple would be 1.5 times cost. You can also look at prices where the price is more than a multiple of the cost. The prices returned can then be updated all in place without having to select them individually this is much more convenient than identifying the errant prices manually and then going in and selecting them individually in the normal price maintenace screen. +<br><br> +From the main menu Inventory -> View Or Update Prices Based On Costs. You can select the Inventory category you wish to review or leave the default - to view all categories. Initially it is assumed you wish ... [truncated message content] |
From: <dai...@us...> - 2010-05-16 06:18:40
|
Revision: 3463 http://web-erp.svn.sourceforge.net/web-erp/?rev=3463&view=rev Author: daintree Date: 2010-05-16 06:18:34 +0000 (Sun, 16 May 2010) Log Message: ----------- 6/5/10 Phil: reworked PDFRemittanceAdvices.php - somehow missed from tcpdf work to print utf-8 pdfs Modified Paths: -------------- trunk/PDFRemittanceAdvice.php trunk/doc/Change.log.html Modified: trunk/PDFRemittanceAdvice.php =================================================================== --- trunk/PDFRemittanceAdvice.php 2010-05-16 06:11:39 UTC (rev 3462) +++ trunk/PDFRemittanceAdvice.php 2010-05-16 06:18:34 UTC (rev 3463) @@ -10,17 +10,8 @@ AND strlen($_POST['FromCriteria'])>=1 AND isset($_POST['ToCriteria']) AND strlen($_POST['ToCriteria'])>=1) { - -/*then print the report */ + /*Now figure out the invoice less credits due for the Supplier range under review */ - include('includes/PDFStarter.php'); - $pdf->addInfo('Title',_('Remmitance Advice')); - $pdf->addInfo('Subject',_('Remittance Advice') . ' - ' . _('suppliers from') . ' ' . $_POST['FromCriteria'] . ' to ' . $_POST['ToCriteria'] . ' ' . _('and Paid On') . ' ' . $_POST['PaymentDate']); - - $line_height=12; - - /*Now figure out the invoice less credits due for the Supplier range under review */ - $sql = "SELECT suppliers.supplierid, suppliers.suppname, suppliers.address1, @@ -41,7 +32,24 @@ ORDER BY supplierno"; $SuppliersResult = DB_query($sql,$db); + if (DB_num_rows($SuppliersResult)==0){ + //then there aint awt to print + $title = _('Print Remittance Advices Error'); + include('includes/header.inc'); + prnMsg(_('There were no remittance advices to print out for the supplier range and payment date specified'),'warn'); + echo '<br><a href="'.$_SERVER['PHP_SELF'] .'?' . SID . '">'. _('Back').'</a>'; + include('includes/footer.inc'); + exit; + } +/*then print the report */ + include('includes/PDFStarter.php'); + $pdf->addInfo('Title',_('Remmitance Advice')); + $pdf->addInfo('Subject',_('Remittance Advice') . ' - ' . _('suppliers from') . ' ' . $_POST['FromCriteria'] . ' to ' . $_POST['ToCriteria'] . ' ' . _('and Paid On') . ' ' . $_POST['PaymentDate']); + + $line_height=12; + + $SupplierID =''; $RemittanceAdviceCounter =0; while ($SuppliersPaid = DB_fetch_array($SuppliersResult)){ @@ -102,21 +110,11 @@ PaymentFooter(); } /* end while there are supplier payments to retrieve allocations for */ - $pdfcode = $pdf->output(); - $len = strlen($pdfcode); - header('Content-type: application/pdf'); - header('Content-Length: ' . $len); - header('Content-Disposition: inline; filename=RemittanceAdvice.pdf'); - header('Expires: 0'); - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - header('Pragma: public'); + + $FileName=$_SESSION['DatabaseName']. '_' . _('Remittance_Advices') . '_' . date('Y-m-d').'.pdf'; + $pdf->OutputD($FileName); + $pdf->__destruct(); - $pdf->stream(); - - header('Expires: 0'); - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); - header('Pragma: public'); - } else { /*The option to print PDF was not hit */ $title=_('Remittance Advices'); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-16 06:11:39 UTC (rev 3462) +++ trunk/doc/Change.log.html 2010-05-16 06:18:34 UTC (rev 3463) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<P>16/5/10 Phil: reworked PDFRemittanceAdvices.php - somehow missed from tcpdf work to print utf-8 pdfs</p> <p>16/5/10 Phil: reworked PDFPriceList to use the new effective dates fields and print out effective prices as at a specified date - showing effective dates on the report - also ditched includes/PDFPriceListPageHeader.php in favour of a PageHeader() function inside PDFPriceList.php. Also made the script work with tcpdf - not sure how it was missed before?</p> <p>16/5/10 Phil: reworked PricesBasedOnMarkUp.php to insert new prices with effectivity dates and update the prices where effectivity dates specified.</p> <p>16/5/10 Phil: reworked PricesByCost.php this was bit of a dodgy script - well I found it hard to follow - in the words of Frank Sinatra - I did it my way! Also built in effectivity dates to display and ensure correct prices updated now the primary key of prices is changed.</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-05-17 17:14:47
|
Revision: 3465 http://web-erp.svn.sourceforge.net/web-erp/?rev=3465&view=rev Author: tim_schofield Date: 2010-05-17 17:14:40 +0000 (Mon, 17 May 2010) Log Message: ----------- Matt Taylor - Changes to MRPPlannedWorkOrders.php Modified Paths: -------------- trunk/MRPPlannedWorkOrders.php trunk/WorkOrderEntry.php trunk/doc/Change.log.html trunk/sql/mysql/upgrade3.11.1-3.12.sql trunk/sql/mysql/weberp-demo.sql trunk/sql/mysql/weberp-new.sql Modified: trunk/MRPPlannedWorkOrders.php =================================================================== --- trunk/MRPPlannedWorkOrders.php 2010-05-16 06:21:10 UTC (rev 3464) +++ trunk/MRPPlannedWorkOrders.php 2010-05-17 17:14:40 UTC (rev 3465) @@ -16,23 +16,14 @@ include('includes/footer.inc'); exit; } -if (isset($_POST['PrintPDF'])) { +if ( isset($_POST['PrintPDF']) OR isset($_POST['Review']) ) { - include('includes/PDFStarter.php'); - - $pdf->addInfo('Title',_('MRP Planned Work Orders Report')); - $pdf->addInfo('Subject',_('MRP Planned Work Orders')); - - $FontSize=9; - $PageNumber=1; - $line_height=12; - $Xpos = $Left_Margin+1; $wheredate = " "; $reportdate = " "; if (is_Date($_POST['cutoffdate'])) { $formatdate = FormatDateForSQL($_POST['cutoffdate']); $wheredate = ' AND duedate <= "' . $formatdate . '" '; - $reportdate = _(' Through ') . Format_Date($_POST['cutoffdate']); + $reportdate = _(' Through ') . $_POST['cutoffdate']; } if ($_POST['Consolidation'] == 'None') { @@ -122,7 +113,7 @@ exit; } if (DB_num_rows($result)==0){ //then there's nothing to print - $title = _('Print MRP Planned Work Orders'); + $title = _('MRP Planned Work Orders'); include('includes/header.inc'); prnMsg(_('There were no items with demand greater than supply'),'info'); echo "<br><a href='$rootpath/index.php?" . SID . "'>" . _('Back to the menu') . '</a>'; @@ -130,109 +121,201 @@ exit; } - PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin, - $Page_Width,$Right_Margin,$_POST['Consolidation'],$reportdate); - $Total_EXTcost=0; - $Partctr = 0; - $fill = false; - $pdf->SetFillColor(224,235,255); // Defines color to make alternating lines highlighted - $FontSize=8; - $holdpart = " "; - $holddescription = " "; - $holdmbflag = " "; - $holdcost = " "; - $holddecimalplaces = 0; - $totalpartqty = 0; - $totalpartcost = 0; - While ($myrow = DB_fetch_array($result,$db)){ - $YPos -=$line_height; + If (isset($_POST['PrintPDF'])) { // Print planned work orders - // Use to alternate between lines with transparent and painted background - if ($_POST['Fill'] == 'yes'){ - $fill=!$fill; - } + include('includes/PDFStarter.php'); - // Print information on part break - if ($Partctr > 0 & $holdpart != $myrow['part']) { - $pdf->addTextWrap(50,$YPos,130,$FontSize,$holddescription,'',0,$fill); - $pdf->addTextWrap(180,$YPos,40,$FontSize,_('Unit Cost: '),'center',0,$fill); - $pdf->addTextWrap(220,$YPos,40,$FontSize,number_format($holdcost,2),'right',0,$fill); - $pdf->addTextWrap(260,$YPos,50,$FontSize,number_format($totalpartqty, - $holddecimalplaces),'right',0,$fill); - $pdf->addTextWrap(310,$YPos,60,$FontSize,number_format($totalpartcost,2),'right',0,$fill); - $pdf->addTextWrap(370,$YPos,30,$FontSize,_('M/B: '),'right',0,$fill); - $pdf->addTextWrap(400,$YPos,15,$FontSize,$holdmbflag,'right',0,$fill); - $totalpartcost = 0; - $totalpartqty = 0; - $YPos -= (2*$line_height); - } + $pdf->addInfo('Title',_('MRP Planned Work Orders Report')); + $pdf->addInfo('Subject',_('MRP Planned Work Orders')); - // Parameters for addTextWrap are defined in /includes/class.pdf.php - // 1) X position 2) Y position 3) Width - // 4) Height 5) Text 6) Alignment 7) Border 8) Fill - True to use SetFillColor - // and False to set to transparent - $FormatedSupDueDate = ConvertSQLDate($myrow['duedate']); - $FormatedSupMRPDate = ConvertSQLDate($myrow['mrpdate']); - $extcost = $myrow['supplyquantity'] * $myrow['computedcost']; - $pdf->addTextWrap($Left_Margin,$YPos,110,$FontSize,$myrow['part'],'',0,$fill); - $pdf->addTextWrap(150,$YPos,50,$FontSize,$FormatedSupDueDate,'right',0,$fill); - $pdf->addTextWrap(200,$YPos,60,$FontSize,$FormatedSupMRPDate,'right',0,$fill); - $pdf->addTextWrap(260,$YPos,50,$FontSize,number_format($myrow['supplyquantity'], - $myrow['decimalplaces']),'right',0,$fill); - $pdf->addTextWrap(310,$YPos,60,$FontSize,number_format($extcost,2),'right',0,$fill); - if ($_POST['Consolidation'] == 'None'){ - $pdf->addTextWrap(370,$YPos,80,$FontSize,$myrow['ordertype'],'right',0,$fill); - $pdf->addTextWrap(450,$YPos,80,$FontSize,$myrow['orderno'],'right',0,$fill); - } else { - $pdf->addTextWrap(370,$YPos,100,$FontSize,$myrow['consolidatedcount'],'right',0,$fill); - }; - $holddescription = $myrow['description']; - $holdpart = $myrow['part']; - $holdmbflag = $myrow['mbflag']; - $holdcost = $myrow['computedcost']; - $holddecimalplaces = $myrow['decimalplaces']; - $totalpartcost += $extcost; - $totalpartqty += $myrow['supplyquantity']; + $FontSize=9; + $PageNumber=1; + $line_height=12; + $Xpos = $Left_Margin+1; - $Total_Extcost += $extcost; - $Partctr++; + PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin, + $Page_Width,$Right_Margin,$_POST['Consolidation'],$reportdate); - if ($YPos < $Bottom_Margin + $line_height){ + $Total_EXTcost=0; + $Partctr = 0; + $fill = false; + $pdf->SetFillColor(224,235,255); // Defines color to make alternating lines highlighted + $FontSize=8; + $holdpart = " "; + $holddescription = " "; + $holdmbflag = " "; + $holdcost = " "; + $holddecimalplaces = 0; + $totalpartqty = 0; + $totalpartcost = 0; + + While ($myrow = DB_fetch_array($result,$db)){ + $YPos -=$line_height; + + // Use to alternate between lines with transparent and painted background + if ($_POST['Fill'] == 'yes'){ + $fill=!$fill; + } + + // Print information on part break + if ($Partctr > 0 & $holdpart != $myrow['part']) { + $pdf->addTextWrap(50,$YPos,130,$FontSize,$holddescription,'',0,$fill); + $pdf->addTextWrap(180,$YPos,40,$FontSize,_('Unit Cost: '),'center',0,$fill); + $pdf->addTextWrap(220,$YPos,40,$FontSize,number_format($holdcost,2),'right',0,$fill); + $pdf->addTextWrap(260,$YPos,50,$FontSize,number_format($totalpartqty, + $holddecimalplaces),'right',0,$fill); + $pdf->addTextWrap(310,$YPos,60,$FontSize,number_format($totalpartcost,2),'right',0,$fill); + $pdf->addTextWrap(370,$YPos,30,$FontSize,_('M/B: '),'right',0,$fill); + $pdf->addTextWrap(400,$YPos,15,$FontSize,$holdmbflag,'right',0,$fill); + $totalpartcost = 0; + $totalpartqty = 0; + $YPos -= (2*$line_height); + } + + // Parameters for addTextWrap are defined in /includes/class.pdf.php + // 1) X position 2) Y position 3) Width + // 4) Height 5) Text 6) Alignment 7) Border 8) Fill - True to use SetFillColor + // and False to set to transparent + $FormatedSupDueDate = ConvertSQLDate($myrow['duedate']); + $FormatedSupMRPDate = ConvertSQLDate($myrow['mrpdate']); + $extcost = $myrow['supplyquantity'] * $myrow['computedcost']; + $pdf->addTextWrap($Left_Margin,$YPos,110,$FontSize,$myrow['part'],'',0,$fill); + $pdf->addTextWrap(150,$YPos,50,$FontSize,$FormatedSupDueDate,'right',0,$fill); + $pdf->addTextWrap(200,$YPos,60,$FontSize,$FormatedSupMRPDate,'right',0,$fill); + $pdf->addTextWrap(260,$YPos,50,$FontSize,number_format($myrow['supplyquantity'], + $myrow['decimalplaces']),'right',0,$fill); + $pdf->addTextWrap(310,$YPos,60,$FontSize,number_format($extcost,2),'right',0,$fill); + if ($_POST['Consolidation'] == 'None'){ + $pdf->addTextWrap(370,$YPos,80,$FontSize,$myrow['ordertype'],'right',0,$fill); + $pdf->addTextWrap(450,$YPos,80,$FontSize,$myrow['orderno'],'right',0,$fill); + } else { + $pdf->addTextWrap(370,$YPos,100,$FontSize,$myrow['consolidatedcount'],'right',0,$fill); + }; + $holddescription = $myrow['description']; + $holdpart = $myrow['part']; + $holdmbflag = $myrow['mbflag']; + $holdcost = $myrow['computedcost']; + $holddecimalplaces = $myrow['decimalplaces']; + $totalpartcost += $extcost; + $totalpartqty += $myrow['supplyquantity']; + + $Total_Extcost += $extcost; + $Partctr++; + + if ($YPos < $Bottom_Margin + $line_height){ + PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin,$Page_Width, + $Right_Margin,$_POST['Consolidation'],$reportdate); + // include('includes/MRPPlannedWorkOrdersPageHeader.inc'); + } + + } /*end while loop */ + // Print summary information for last part + $YPos -=$line_height; + $pdf->addTextWrap(40,$YPos,130,$FontSize,$holddescription,'',0,$fill); + $pdf->addTextWrap(170,$YPos,50,$FontSize,_('Unit Cost: '),'center',0,$fill); + $pdf->addTextWrap(220,$YPos,40,$FontSize,number_format($holdcost,2),'right',0,$fill); + $pdf->addTextWrap(260,$YPos,50,$FontSize,number_format($totalpartqty,$holddecimalplaces),'right',0,$fill); + $pdf->addTextWrap(310,$YPos,60,$FontSize,number_format($totalpartcost,2),'right',0,$fill); + $pdf->addTextWrap(370,$YPos,30,$FontSize,_('M/B: '),'right',0,$fill); + $pdf->addTextWrap(400,$YPos,15,$FontSize,$holdmbflag,'right',0,$fill); + $FontSize =8; + $YPos -= (2*$line_height); + + if ($YPos < $Bottom_Margin + $line_height){ PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin,$Page_Width, - $Right_Margin,$_POST['Consolidation'],$reportdate); + $Right_Margin,$_POST['Consolidation'],$reportdate); // include('includes/MRPPlannedWorkOrdersPageHeader.inc'); + } + /*Print out the grand totals */ + $pdf->addTextWrap($Left_Margin,$YPos,120,$FontSize,_('Number of Work Orders: '), 'left'); + $pdf->addTextWrap(150,$YPos,30,$FontSize,$Partctr, 'left'); + $pdf->addTextWrap(200,$YPos,100,$FontSize,_('Total Extended Cost:'), 'right'); + $DisplayTotalVal = number_format($Total_Extcost,2); + $pdf->addTextWrap(310,$YPos,60,$FontSize,$DisplayTotalVal, 'right'); + + $pdf->OutputD($_SESSION['DatabaseName'] . '_MRP_Planned_Work_Orders_' . Date('Y-m-d') . '.pdf'); + $pdf->__destruct(); + + + + } else { // Review planned work orders + + $title = _('Review/Convert MRP Planned Work Orders'); + include('includes/header.inc'); + + echo " + <br /><br /><form action='MRPConvertWorkOrders.php' method='post'>"; + echo "<div class='centre'><h3>Conolidation: " . $_POST['Consolidation'] . "</h3></div>"; + echo "<div class='centre'><h3>Cutoff Date: " . $_POST['cutoffdate'] . "</h3></div>"; + echo "<table><tr> + <th></th> + <th>" . _('Code') . "</th> + <th>" . _('Description') . "</th> + <th>" . _('MRP Date') . "</th> + <th>" . _('Due Date') . "</th> + <th>" . _('Quantity') . "</th> + <th>" . _('Unit Cost') . "</th> + <th>" . _('Ext. Cost') . "</th> + <th>" . _('Consolidations') . "</th> + </tr>"; + + $totalpartqty = 0; + $totalpartcost = 0; + $j=1; //row ID + $k=0; //row colour counter + While ($myrow = DB_fetch_array($result,$db)){ + + // Alternate row color + if ($k==1){ + echo '<tr class="EvenTableRows">'; + $k=0; + } else { + echo '<tr class="OddTableRows">'; + $k++; } - } /*end while loop */ - // Print summary information for last part - $YPos -=$line_height; - $pdf->addTextWrap(40,$YPos,130,$FontSize,$holddescription,'',0,$fill); - $pdf->addTextWrap(170,$YPos,50,$FontSize,_('Unit Cost: '),'center',0,$fill); - $pdf->addTextWrap(220,$YPos,40,$FontSize,number_format($holdcost,2),'right',0,$fill); - $pdf->addTextWrap(260,$YPos,50,$FontSize,number_format($totalpartqty,$holddecimalplaces),'right',0,$fill); - $pdf->addTextWrap(310,$YPos,60,$FontSize,number_format($totalpartcost,2),'right',0,$fill); - $pdf->addTextWrap(370,$YPos,30,$FontSize,_('M/B: '),'right',0,$fill); - $pdf->addTextWrap(400,$YPos,15,$FontSize,$holdmbflag,'right',0,$fill); - $FontSize =8; - $YPos -= (2*$line_height); + printf("\n <td><a href='%s/WorkOrderEntry.php?NewItem=%s&ReqQty=%s&ReqDate=%s'>%s</a></td>", + $rootpath, + $myrow['part'], + $myrow['supplyquantity'], + ConvertSQLDate($myrow['duedate']), + _('Convert') + ); + printf("\n <td>%s <input type='hidden' name='%s_part' value='%s' /></td>", $myrow['part'], $j, $myrow['part']); + printf("\n <td>%s</td>", $myrow['description']); + printf("\n <td>%s</td>", ConvertSQLDate($myrow['mrpdate'])); + printf("\n <td>%s</td>", ConvertSQLDate($myrow['duedate'])); + printf("\n <td class=number>%s</td>", number_format($myrow['supplyquantity'],$myrow['decimalplaces'])); + printf("\n <td class=number>%.2f</td>", number_format($myrow['computedcost'],2)); + printf("\n <td class=number>%.2f</td>", number_format($myrow['supplyquantity'] * $myrow['computedcost'],2)); + printf("\n <td class=number>%s</td>", $myrow['consolidatedcount']); + echo "</tr>"; - if ($YPos < $Bottom_Margin + $line_height){ - PrintHeader($pdf,$YPos,$PageNumber,$Page_Height,$Top_Margin,$Left_Margin,$Page_Width, - $Right_Margin,$_POST['Consolidation'],$reportdate); - // include('includes/MRPPlannedWorkOrdersPageHeader.inc'); + $j++; + $Total_Extcost += ( $myrow['supplyquantity'] * $myrow['computedcost'] ); + + } // end while loop + + // Print out the grand totals + printf(" + <tr><td colspan='4' class='number'>%s %s</td> + <td colspan='4' class='number'>%s %s</td></tr></table> + ", + _('Number of Work Orders: '), + $j-1, + _('Total Extended Cost: '), + number_format($Total_Extcost,2) + ); + + echo "<br /><a href='$rootpath/index.php?" . SID . "'>" . _('Back to the menu') . '</a>'; + include('includes/footer.inc'); + } -/*Print out the grand totals */ - $pdf->addTextWrap($Left_Margin,$YPos,120,$FontSize,_('Number of Work Orders: '), 'left'); - $pdf->addTextWrap(150,$YPos,30,$FontSize,$Partctr, 'left'); - $pdf->addTextWrap(200,$YPos,100,$FontSize,_('Total Extended Cost:'), 'right'); - $DisplayTotalVal = number_format($Total_Extcost,2); - $pdf->addTextWrap(310,$YPos,60,$FontSize,$DisplayTotalVal, 'right'); - $pdf->OutputD($_SESSION['DatabaseName'] . '_MRP_Planned_Work_Orders_' . Date('Y-m-d') . '.pdf'); - $pdf->__destruct(); + } else { /*The option to print PDF was not hit so display form */ $title=_('MRP Planned Work Orders Reporting'); @@ -249,7 +332,7 @@ echo "<option value='no'>" . _('Plain Print'); echo '</select></td></tr>'; echo '<tr><td>' . _('Cut Off Date') . ":</td><td><input type ='text' class=date alt='".$_SESSION['DefaultDateFormat'] ."' name='cutoffdate' size='10' value='".date($_SESSION['DefaultDateFormat'])."'></tr>"; - echo "</table></br><div class='centre'><input type=submit name='PrintPDF' value='" . _('Print PDF') . "'></div>"; + echo "</table></br><div class='centre'><input type=submit name='Review' value='" . _('Review') . "'> <input type=submit name='PrintPDF' value='" . _('Print PDF') . "'></div>"; include('includes/footer.inc'); Modified: trunk/WorkOrderEntry.php =================================================================== --- trunk/WorkOrderEntry.php 2010-05-16 06:21:10 UTC (rev 3464) +++ trunk/WorkOrderEntry.php 2010-05-17 17:14:40 UTC (rev 3465) @@ -8,33 +8,52 @@ $title = _('Work Order Entry'); include('includes/header.inc'); include('includes/SQL_CommonFunctions.inc'); - echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/transactions.png" title="' . _('Search') . '" alt="">' . ' ' . $title; + + +echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/transactions.png" title="' . _('Search') . '" alt="">' . ' ' . $title; + +if (isset($_GET['ReqDate'])){ + $ReqDate = $_GET['ReqDate']; +} +if (isset($_GET['loccode'])){ + $LocCode = $_GET['loccode']; +} + +// check for new or modify condition if (isset($_REQUEST['WO']) and $_REQUEST['WO']!=''){ + // modify $_POST['WO'] = $_REQUEST['WO']; $EditingExisting = true; } else { + // new $_POST['WO'] = GetNextTransNo(40,$db); - $InsWOResult = DB_query("INSERT INTO workorders (wo, - loccode, - requiredby, - startdate) - VALUES (" . $_POST['WO'] . ", - '" . $_SESSION['UserStockLocation'] . "', - '" . Date('Y-m-d') . "', - '" . Date('Y-m-d'). "')", - $db); + $sql = "INSERT INTO workorders (wo, + loccode, + requiredby, + startdate) + VALUES (" . $_POST['WO'] . ", + '" . (($LocCode) ? $LocCode : $_SESSION['UserStockLocation']) . "', + '" . (($ReqDate) ? $ReqDate : Date('Y-m-d')) . "', + '" . Date('Y-m-d'). "')"; + $InsWOResult = DB_query($sql,$db); } + if (isset($_GET['NewItem'])){ $NewItem = $_GET['NewItem']; } - +if (isset($_GET['ReqQty'])){ + $ReqQty = $_GET['ReqQty']; +} if (!isset($_POST['StockLocation'])){ - if (isset($_SESSION['UserStockLocation'])){ + if (isset($LocCode)){ + $_POST['StockLocation']=$LocCode; + } elseif (isset($_SESSION['UserStockLocation'])){ $_POST['StockLocation']=$_SESSION['UserStockLocation']; } } + if (isset($_POST['Search'])){ If ($_POST['Keywords'] AND $_POST['StockCode']) { @@ -159,7 +178,7 @@ if ($CheckItemRow['controlled']==1 AND $_SESSION['DefineControlledOnWOEntry']==1){ //need to add serial nos or batches to determine quantity $EOQ = 0; } else { - $EOQ = $CheckItemRow['eoq']; + $EOQ = ($ReqQty) ? $ReqQty : $CheckItemRow['eoq']; } if ($CheckItemRow['mbflag']!='M'){ prnMsg(_('The item selected cannot be added to a work order because it is not a manufactured item'),'warn'); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-16 06:21:10 UTC (rev 3464) +++ trunk/doc/Change.log.html 2010-05-17 17:14:40 UTC (rev 3465) @@ -1,19 +1,24 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> -<P>16/5/10 Phil: javascripts/MiscFunctions.js - not my field ... but could not resist adding some indentation - I struggle at the best of times with javascript but this was a shocker to read!! Hope I didnt mess up anything</p> -<P>16/5/10 Phil: reworked PDFRemittanceAdvices.php - somehow missed from tcpdf work to print utf-8 pdfs</p> -<p>16/5/10 Phil: reworked PDFPriceList to use the new effective dates fields and print out effective prices as at a specified date - showing effective dates on the report - also ditched includes/PDFPriceListPageHeader.php in favour of a PageHeader() function inside PDFPriceList.php. Also made the script work with tcpdf - not sure how it was missed before?</p> -<p>16/5/10 Phil: reworked PricesBasedOnMarkUp.php to insert new prices with effectivity dates and update the prices where effectivity dates specified.</p> -<p>16/5/10 Phil: reworked PricesByCost.php this was bit of a dodgy script - well I found it hard to follow - in the words of Frank Sinatra - I did it my way! Also built in effectivity dates to display and ensure correct prices updated now the primary key of prices is changed.</p> -<p>16/5/10 Phil: Wrote up the manual so that the logic of pricing with effective dates is explained</p> -<p>15/5/10 Phil: Used Lindsay/Ngaraj's nice email address checking function to replace the existing function in MiscFunctions.php and includes MiscFunctions.php in install/save.php to avoid duplication of the function</p> -<p>15/5/10 Phil: $debug variable in UserLogin.php was only set on first login - not subsequent page calls (its not a session variable) - moved it back into session.inc so that full info about bugs is available to sysadmins -<p>15/5/10 Phil: GetPrices.inc Prices.php and Prices_Customer.php - modified to allow default prices - with no end dates - reducing requirement to administer - also updated Prices section of the manual +<P>16/05/10 Phil: javascripts/MiscFunctions.js - not my field ... but could not resist adding some indentation - I struggle at the best of times with javascript but this was a shocker to read!! Hope I didnt mess up anything</p> +<P>16/05/10 Phil: reworked PDFRemittanceAdvices.php - somehow missed from tcpdf work to print utf-8 pdfs</p> +<p>16/05/10 Phil: reworked PDFPriceList to use the new effective dates fields and print out effective prices as at a specified date - showing effective dates on the report - also ditched includes/PDFPriceListPageHeader.php in favour of a PageHeader() function inside PDFPriceList.php. Also made the script work with tcpdf - not sure how it was missed before?</p> +<p>16/05/10 Phil: reworked PricesBasedOnMarkUp.php to insert new prices with effectivity dates and update the prices where effectivity dates specified.</p> +<p>16/05/10 Phil: reworked PricesByCost.php this was bit of a dodgy script - well I found it hard to follow - in the words of Frank Sinatra - I did it my way! Also built in effectivity dates to display and ensure correct prices updated now the primary key of prices is changed.</p> +<p>16/05/10 Phil: Wrote up the manual so that the logic of pricing with effective dates is explained</p> +<p>15/05/10 Phil: Used Lindsay/Ngaraj's nice email address checking function to replace the existing function in MiscFunctions.php and includes MiscFunctions.php in install/save.php to avoid duplication of the function</p> +<p>15/05/10 Phil: $debug variable in UserLogin.php was only set on first login - not subsequent page calls (its not a session variable) - moved it back into session.inc so that full info about bugs is available to sysadmins +<p>15/05/10 Phil: GetPrices.inc Prices.php and Prices_Customer.php - modified to allow default prices - with no end dates - reducing requirement to administer - also updated Prices section of the manual <p>11/05/10 Tim: Exit MRP scripts gracefully if no MRP calculation has been done.</p> <p>08/05/10 Lindsay: API was broken after adding a test for global variable $DatabaseName in ConnectDB_mysql* for this variable being set and using it as DB name if so. The variable of that name in the api_php.php has been changed to $api_DatabaseName.</p> <p>08/05/10 Phil: GetPrices.inc now uses the new price startdate and enddate to return the price which falls within the date range base on the current date. Changes to Prices.php and Prices_Customer.php to allow entry of effective from and effective to dates and updating/deleting of prices with appropriate error trapping and rescheduling of enddates where start and end dates would otherwise overlap.</p> <p>08/05/10 Phil: Found a bug in Date1GreaterThanDate2 function (in includes/DateFunction.inc) with SESSION['DefaultDateFormat'] = 'd/m/Y' this function had been broken </p> <p>06/05/10 Lindsay: Tracker 2929564: dates mangled via QuicK Entry format</p> +<p>06/05/10 Matt Taylor: upgrade3.11.1-3.12.sql : Added default startdate to prices table.</p> +<p>06/05/10 Matt Taylor: weberp-demo.sql : Added startdate and enddate columns to prices table.</p> +<p>06/05/10 Matt Taylor: weberp-new.sql : Added startdate and enddate columns to prices table.</p> +<p>06/05/10 Matt Taylor: WorkOrderEntry.php : Added feature to convert planned work orders.</p> +<p>06/05/10 Matt Taylor: MRPPlannedWorkOrders.php : Added feature to convert planned work orders.</p> <p>05/05/10 Tim: Fix javascript errors in date picker</p> <p>05/05/10 SiteMe: Update to allow RecurringSalesOrdersProcess.php to run via cron</p> <p>05/05/10 SiteMe: Correct statements layout problems caused by the newer version of tcpdf</p> Modified: trunk/sql/mysql/upgrade3.11.1-3.12.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-05-16 06:21:10 UTC (rev 3464) +++ trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-05-17 17:14:40 UTC (rev 3465) @@ -153,7 +153,11 @@ ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `systypes` VALUES(19, 'Picking List', 0); -ALTER TABLE `prices` ADD `startdate` DATE NOT NULL , ADD `enddate` DATE NOT NULL; +ALTER TABLE `prices` ADD `startdate` DATE NOT NULL DEFAULT '0000-00-00' , ADD `enddate` DATE NOT NULL DEFAULT '9999-12-31'; ALTER TABLE prices DROP PRIMARY KEY , ADD PRIMARY KEY ( `stockid` , `typeabbrev` , `currabrev` , `debtorno` , `startdate` , `enddate` ) ; + +UPDATE prices SET startdate='1999-01-01', enddate='9999-12-31'; + +ALTER TABLE stockcheckfreeze ADD COLUMN stockcheckdate date NOT NULL; UPDATE prices SET startdate='1999-01-01'; Modified: trunk/sql/mysql/weberp-demo.sql =================================================================== --- trunk/sql/mysql/weberp-demo.sql 2010-05-16 06:21:10 UTC (rev 3464) +++ trunk/sql/mysql/weberp-demo.sql 2010-05-17 17:14:40 UTC (rev 3465) @@ -1057,6 +1057,8 @@ `debtorno` varchar(10) NOT NULL DEFAULT '', `price` decimal(20,4) NOT NULL DEFAULT '0.0000', `branchcode` varchar(10) NOT NULL DEFAULT '', + `startdate` DATE NOT NULL DEFAULT '0000-00-00', + `enddate` DATE NOT NULL DEFAULT '9999-12-31', PRIMARY KEY (`stockid`,`typeabbrev`,`currabrev`,`debtorno`), KEY `CurrAbrev` (`currabrev`), KEY `DebtorNo` (`debtorno`), Modified: trunk/sql/mysql/weberp-new.sql =================================================================== --- trunk/sql/mysql/weberp-new.sql 2010-05-16 06:21:10 UTC (rev 3464) +++ trunk/sql/mysql/weberp-new.sql 2010-05-17 17:14:40 UTC (rev 3465) @@ -1058,6 +1058,8 @@ `debtorno` varchar(10) NOT NULL DEFAULT '', `price` decimal(20,4) NOT NULL DEFAULT '0.0000', `branchcode` varchar(10) NOT NULL DEFAULT '', + `startdate` DATE NOT NULL DEFAULT '0000-00-00', + `enddate` DATE NOT NULL DEFAULT '9999-12-31', PRIMARY KEY (`stockid`,`typeabbrev`,`currabrev`,`debtorno`), KEY `CurrAbrev` (`currabrev`), KEY `DebtorNo` (`debtorno`), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-05-24 17:48:26
|
Revision: 3466 http://web-erp.svn.sourceforge.net/web-erp/?rev=3466&view=rev Author: tim_schofield Date: 2010-05-24 17:48:19 +0000 (Mon, 24 May 2010) Log Message: ----------- Added telephone, email and fax fields to Suppliers and Customers Pages. Ability to add/edit the records. Modified Paths: -------------- trunk/CustomerBranches.php trunk/Customers.php trunk/Suppliers.php trunk/doc/Change.log.html Modified: trunk/CustomerBranches.php =================================================================== --- trunk/CustomerBranches.php 2010-05-17 17:14:40 UTC (rev 3465) +++ trunk/CustomerBranches.php 2010-05-24 17:48:19 UTC (rev 3466) @@ -348,7 +348,7 @@ contactname, phoneno, faxno, - email, + custbranch.email, taxgroups.taxgroupdescription, custbranch.branchcode, custbranch.disabletrans Modified: trunk/Customers.php =================================================================== --- trunk/Customers.php 2010-05-17 17:14:40 UTC (rev 3465) +++ trunk/Customers.php 2010-05-24 17:48:19 UTC (rev 3466) @@ -88,8 +88,33 @@ prnMsg( _('The Line 6 of the address must be fifteen characters or less long'),'error'); $Errors[$i] = 'Address6'; $i++; - } elseif (!is_numeric($_POST['CreditLimit'])) { + } + elseif (strlen($_POST['Phone']) >25) { $InputError = 1; + prnMsg(_('The telephone number must be 25 characters or less long'),'error'); + $Errors[$i] = 'Telephone'; + $i++; + } + elseif (strlen($_POST['Fax']) >25) { + $InputError = 1; + prnMsg(_('The fax number must be 25 characters or less long'),'error'); + $Errors[$i] = 'Fax'; + $i++; + } + elseif (strlen($_POST['Email']) >55) { + $InputError = 1; + prnMsg(_('The email address must be 55 characters or less long'),'error'); + $Errors[$i] = 'Email'; + $i++; + } + elseif (strlen($_POST['Email'])>0 and !IsEmailAddress($_POST['Email'])) { + $InputError = 1; + prnMsg(_('The email address is not correctly formed'),'error'); + $Errors[$i] = 'Email'; + $i++; + } + elseif (!is_numeric($_POST['CreditLimit'])) { + $InputError = 1; prnMsg( _('The credit limit must be numeric'),'error'); $Errors[$i] = 'CreditLimit'; $i++; @@ -146,6 +171,9 @@ address4='" . $_POST['Address4'] . "', address5='" . $_POST['Address5'] . "', address6='" . $_POST['Address6'] . "', + telephone='".$_POST['Phone']."', + fax = '".$_POST['Fax']."', + email = '".$_POST['Email']."', currcode='" . $_POST['CurrCode'] . "', clientsince='$SQL_ClientSince', holdreason='" . $_POST['HoldReason'] . "', @@ -177,6 +205,9 @@ address4='" . $_POST['Address4'] . "', address5='" . $_POST['Address5'] . "', address6='" . $_POST['Address6'] . "', + telephone='".$_POST['Phone']."', + fax = '".$_POST['Fax']."', + email = '".$_POST['Email']."', clientsince='$SQL_ClientSince', holdreason='" . $_POST['HoldReason'] . "', paymentterms='" . $_POST['PaymentTerms'] . "', @@ -220,6 +251,9 @@ address4, address5, address6, + telephone, + fax, + email, currcode, clientsince, holdreason, @@ -241,6 +275,9 @@ '" . $_POST['Address4'] . "', '" . $_POST['Address5'] . "', '" . $_POST['Address6'] . "', + '".$_POST['Phone']."', + '".$_POST['Fax']."', + '".$_POST['Email']."', '" . $_POST['CurrCode'] . "', '" . $SQL_ClientSince . "', " . $_POST['HoldReason'] . ", @@ -338,6 +375,9 @@ unset($_POST['Address4']); unset($_POST['Address5']); unset($_POST['Address6']); + unset($_POST['Phone']); + unset($_POST['Fax']); + unset($_POST['Email']); unset($_POST['HoldReason']); unset($_POST['PaymentTerms']); unset($_POST['Discount']); @@ -403,7 +443,7 @@ $myrow=DB_fetch_row($result); if ($myrow[0]==0) { prnMsg( _('In order to create a new customer you must first set up at least one sales type/price list').'<br />'. - _('Click').' '.'<a target="_blank" href="' . $rootpath . '/SalesTypes.php">' . _('here').' ' . '</a>'._('to set up your price lists'),'warning').'<br />'; + _('Click').' '.'<a target="_blank" href="' . $rootpath . '/SalesTypes.php">' . _('here').' ' . '</a>'._('to set up your price lists'),'warning').'<br />'; $SetupErrors += 1; } $sql='SELECT COUNT(typeid) @@ -415,13 +455,13 @@ _('Click').' '.'<a target="_blank" href="' . $rootpath . '/CustomerTypes.php">' . _('here').' ' . '</a>'._('to set up your customer types'),'warning'); $SetupErrors += 1; } - + if ($SetupErrors>0) { echo '<br /><div class=centre><a href="'.$_SERVER['PHP_SELF'] .'" >'._('Click here to continue').'</a></div>'; include('includes/footer.inc'); exit; } - + echo "<form method='post' action=" . $_SERVER['PHP_SELF'] . '>'; echo "<input type='Hidden' name='New' value='Yes'>"; @@ -438,6 +478,12 @@ echo '<tr><td>' . _('Customer Name') . ':</td> <td><input tabindex=2 type="Text" name="CustName" size=42 maxlength=40></td></tr>'; + echo '<tr><td>' . _('Telephone') . ':</td> + <td><input tabindex=2 type="Text" name="Phone" size=30 maxlength=40></td></tr>'; + echo '<tr><td>' . _('Facsimile') . ':</td> + <td><input tabindex=2 type="Text" name="Fax" size=30 maxlength=40></td></tr>'; + echo '<tr><td>' . _('Email Address') . ':</td> + <td><input tabindex=2 type="Text" name="Email" size=30 maxlength=40></td></tr>'; echo '<tr><td>' . _('Address Line 1 (Street)') . ':</td> <td><input tabindex=3 type="Text" name="Address1" size=42 maxlength=40></td></tr>'; echo '<tr><td>' . _('Address Line 2 (Suburb/City)') . ':</td> @@ -465,7 +511,7 @@ while ($myrow = DB_fetch_array($result)) { echo '<option value="'. $myrow['typeabbrev'] . '">' . $myrow['sales_type'] . '</option>'; - } //end while loop + } //end while loopre DB_data_seek($result,0); echo '</select></td></tr>'; } @@ -590,6 +636,9 @@ address4, address5, address6, + telephone, + fax, + email, currcode, salestype, clientsince, @@ -609,14 +658,12 @@ $ErrMsg = _('The customer details could not be retrieved because'); $result = DB_query($sql,$db,$ErrMsg); - $myrow = DB_fetch_array($result); - /* if $AutoDebtorNo in config.php has not been set or if it has been set to a number less than one, then display the DebtorNo */ if ($_SESSION['AutoDebtorNo']== 0 ) { echo '<tr><td>' . _('Customer Code') . ":</td> - <td>" . $DebtorNo . "</td></tr>"; + <td>" . $DebtorNo. "</td></tr>"; } $_POST['CustName'] = $myrow['name']; $_POST['Address1'] = $myrow['address1']; @@ -625,6 +672,9 @@ $_POST['Address4'] = $myrow['address4']; $_POST['Address5'] = $myrow['address5']; $_POST['Address6'] = $myrow['address6']; + $_POST['Phone'] = $myrow['telephone']; + $_POST['Fax'] = $myrow['fax']; + $_POST['Email'] = $myrow['email']; $_POST['SalesType'] = $myrow['salestype']; $_POST['CurrCode'] = $myrow['currcode']; $_POST['ClientSince'] = ConvertSQLDate($myrow['clientsince']); @@ -654,6 +704,9 @@ } if (isset($_GET['Modify'])) { echo '<tr><td>' . _('Customer Name') . ':</td><td>' . $_POST['CustName'] . '</td></tr>'; + echo '<tr><td>' . _('Telephone') . ':</td><td>' . $_POST['Phone'] . '</td></tr>'; + echo '<tr><td>' . _('Facsimile') . ':</td><td>' . $_POST['Fax'] . '</td></tr>'; + echo '<tr><td>' . _('Email Address') . ':</td><td>' . $_POST['Email'] . '</td></tr>'; echo '<tr><td>' . _('Address Line 1 (Street)') . ':</td><td>' . $_POST['Address1'] . '</td></tr>'; echo '<tr><td>' . _('Address Line 2 (Suburb/City)') . ':</td><td>' . $_POST['Address2'] . '</td></tr>'; echo '<tr><td>' . _('Address Line 3 (State/Province)') . ':</td><td>' . $_POST['Address3'] . '</td></tr>'; @@ -664,6 +717,12 @@ } else { echo '<tr><td>' . _('Customer Name') . ':</td> <td><input ' . (in_array('CustName',$Errors) ? 'class="inputerror"' : '' ) .' type="Text" name="CustName" value="' . $_POST['CustName'] . '" size=42 maxlength=40></td></tr>'; + echo '<tr><td>' . _('Telephone') . ':</td> + <td><input ' . (in_array('Phone',$Errors) ? 'class="inputerror"' : '' ) .' type="Text" name="Phone" value="' . $_POST['Phone'] . '" size=42 maxlength=40></td></tr>'; + echo '<tr><td>' . _('Facsimile') . ':</td> + <td><input ' . (in_array('Fax',$Errors) ? 'class="inputerror"' : '' ) .' type="Text" name="Fax" value="' . $_POST['Fax'] . '" size=42 maxlength=40></td></tr>'; + echo '<tr><td>' . _('Email Address') . ':</td> + <td><input ' . (in_array('Email',$Errors) ? 'class="inputerror"' : '' ) .' type="Text" name="Email" value="' . $_POST['Email'] . '" size=42 maxlength=40></td></tr>'; echo '<tr><td>' . _('Address Line 1 (Street)') . ':</td> <td><input ' . (in_array('Address1',$Errors) ? 'class="inputerror"' : '' ) .' type="Text" name="Address1" size=42 maxlength=40 value="' . $_POST['Address1'] . '"></td></tr>'; echo '<tr><td>' . _('Address Line 2 (Suburb/City)') . ':</td> @@ -739,7 +798,7 @@ echo '<tr><td>' . _('Tax Reference') . ':</td> <td><input type="Text" name="TaxRef" size=22 maxlength=20 value="' . $_POST['TaxRef'] . '"></td></tr>'; } - + if (isset($_GET['Modify'])) { $result=DB_query('SELECT terms FROM paymentterms WHERE termsindicator='.$_POST['PaymentTerms'],$db); $myrow=DB_fetch_array($result); @@ -815,7 +874,7 @@ } echo '</select></td></tr>'; } - + if (isset($_GET['Modify'])) { if ($_POST['CustomerPOLine']==0){ echo '<tr><td>' . _('Invoice Addressing') . ":</td><td>"._('Address to HO')."</td></tr>"; Modified: trunk/Suppliers.php =================================================================== --- trunk/Suppliers.php 2010-05-17 17:14:40 UTC (rev 3465) +++ trunk/Suppliers.php 2010-05-24 17:48:19 UTC (rev 3466) @@ -346,6 +346,30 @@ $Errors[$i]='ID'; $i++; } + if (strlen($_POST['Phone']) >25) { + $InputError = 1; + prnMsg(_('The telephone number must be 25 characters or less long'),'error'); + $Errors[$i] = 'Telephone'; + $i++; + } + if (strlen($_POST['Fax']) >25) { + $InputError = 1; + prnMsg(_('The fax number must be 25 characters or less long'),'error'); + $Errors[$i] = 'Fax'; + $i++; + } + if (strlen($_POST['Email']) >55) { + $InputError = 1; + prnMsg(_('The email address must be 55 characters or less long'),'error'); + $Errors[$i] = 'Email'; + $i++; + } + if (strlen($_POST['Email'])>0 and !IsEmailAddress($_POST['Email'])) { + $InputError = 1; + prnMsg(_('The email address is not correctly formed'),'error'); + $Errors[$i] = 'Email'; + $i++; + } if (strlen($_POST['BankRef']) > 12) { $InputError = 1; prnMsg(_('The bank reference text must be less than 12 characters long'),'error'); @@ -438,6 +462,9 @@ address2='" . $_POST['Address2'] . "', address3='" . $_POST['Address3'] . "', address4='" . $_POST['Address4'] . "', + telephone='".$_POST['Phone']."', + fax = '".$_POST['Fax']."', + email = '".$_POST['Email']."', currcode='" . $_POST['CurrCode'] . "', suppliersince='$SQL_SupplierSince', paymentterms='" . $_POST['PaymentTerms'] . "', @@ -460,6 +487,9 @@ address2='" . $_POST['Address2'] . "', address3='" . $_POST['Address3'] . "', address4='" . $_POST['Address4'] . "', + telephone='".$_POST['Phone']."', + fax = '".$_POST['Fax']."', + email = '".$_POST['Email']."', suppliersince='$SQL_SupplierSince', paymentterms='" . $_POST['PaymentTerms'] . "', bankpartics='" . $_POST['BankPartics'] . "', @@ -476,7 +506,7 @@ $ErrMsg = _('The supplier could not be updated because'); $DbgMsg = _('The SQL that was used to update the supplier but failed was'); - + // echo $sql; $result = DB_query($sql, $db, $ErrMsg, $DbgMsg); prnMsg(_('The supplier master record for') . ' ' . $SupplierID . ' ' . _('has been updated'),'success'); @@ -489,6 +519,9 @@ address2, address3, address4, + telephone, + fax, + email, currcode, suppliersince, paymentterms, @@ -507,6 +540,9 @@ '" . $_POST['Address2'] . "', '" . $_POST['Address3'] . "', '" . $_POST['Address4'] . "', + '".$_POST['Phone']."', + '".$_POST['Fax']."', + '".$_POST['Email']."', '" . $_POST['CurrCode'] . "', '" . $SQL_SupplierSince . "', '" . $_POST['PaymentTerms'] . "', @@ -533,6 +569,9 @@ unset($_POST['Address2']); unset($_POST['Address3']); unset($_POST['Address4']); + unset($_POST['Phone']); + unset($_POST['Fax']); + unset($_POST['Email']); unset($_POST['CurrCode']); unset($SQL_SupplierSince); unset($_POST['PaymentTerms']); @@ -610,6 +649,9 @@ echo '<table>'; echo '<tr><td>' . _('Supplier Code') . ":</td><td><input type='text' name='SupplierID' size=11 maxlength=10></td></tr>"; echo '<tr><td>' . _('Supplier Name') . ":</td><td><input type='text' name='SuppName' size=42 maxlength=40></td></tr>"; + echo '<tr><td>' . _('Telephone') . ":</td><td><input type='text' name='Phone' size=30 maxlength=40></td></tr>"; + echo '<tr><td>' . _('Facsimile') . ":</td><td><input type='text' name='Fax' size=30 maxlength=40></td></tr>"; + echo '<tr><td>' . _('Email Address') . ":</td><td><input type='text' name='Email' size=30 maxlength=40></td></tr>"; echo '<tr><td>' . _('Address Line 1 (Street)') . ":</td><td><input type='text' name='Address1' size=42 maxlength=40></td></tr>"; echo '<tr><td>' . _('Address Line 2 (Suburb/City)') . ":</td><td><input type='text' name='Address2' size=42 maxlength=40></td></tr>"; echo '<tr><td>' . _('Address Line 3 (State/Province)') . ":</td><td><input type='text' name='Address3' size=42 maxlength=40></td></tr>"; @@ -701,6 +743,9 @@ address2, address3, address4, + telephone, + fax, + email, currcode, suppliersince, paymentterms, @@ -723,6 +768,9 @@ $_POST['Address3'] = stripcslashes($myrow['address3']); $_POST['Address4'] = stripcslashes($myrow['address4']); $_POST['CurrCode'] = stripcslashes($myrow['currcode']); + $_POST['Phone'] = $myrow['telephone']; + $_POST['Fax'] = $myrow['fax']; + $_POST['Email'] = $myrow['email']; $_POST['SupplierSince'] = ConvertSQLDate($myrow['suppliersince']); $_POST['PaymentTerms'] = $myrow['paymentterms']; $_POST['BankPartics'] = stripcslashes($myrow['bankpartics']); @@ -742,6 +790,9 @@ } echo '<tr><td>' . _('Supplier Name') . ':</td><td><input '.(in_array('Name',$Errors) ? 'class="inputerror"' : '').' type="text" name="SuppName" VALUE="' . $_POST['SuppName'] . '" size=42 maxlength=40></td></tr>'; + echo '<tr><td>' . _('Telephone') . ':</td><td><input '.(in_array('Name',$Errors) ? 'class="inputerror"' : '').' type="text" name="Phone" VALUE="' . $_POST['Phone'] . '" size=42 maxlength=40></td></tr>'; + echo '<tr><td>' . _('Facsimile') . ':</td><td><input '.(in_array('Name',$Errors) ? 'class="inputerror"' : '').' type="text" name="Fax" VALUE="' . $_POST['Fax'] . '" size=42 maxlength=40></td></tr>'; + echo '<tr><td>' . _('Email Address') . ':</td><td><input '.(in_array('Name',$Errors) ? 'class="inputerror"' : '').' type="text" name="Email" VALUE="' . $_POST['Email'] . '" size=42 maxlength=40></td></tr>'; echo '<tr><td>' . _('Address Line 1 (Street)') . ':</td><td><input type="text" name="Address1" VALUE="' . $_POST['Address1'] . '" size=42 maxlength=40></td></tr>'; echo '<tr><td>' . _('Address Line 2 (Suburb/City)') . ':</td><td><input type="text" name="Address2" VALUE="' . $_POST['Address2'] . '" size=42 maxlength=40></td></tr>'; echo '<tr><td>' . _('Address Line 3 (State/Province)') . ':</td><td><input type="text" name="Address3" VALUE="' . $_POST['Address3'] . '" size=42 maxlength=40></td></tr>'; @@ -837,3 +888,4 @@ include('includes/footer.inc'); ?> + Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-17 17:14:40 UTC (rev 3465) +++ trunk/doc/Change.log.html 2010-05-24 17:48:19 UTC (rev 3466) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<P>24/05/10 Simon Peter Otandeka: Added telephone, email and fax fields to Suppliers and Customers Pages. Ability to add/edit the records.</p> <P>16/05/10 Phil: javascripts/MiscFunctions.js - not my field ... but could not resist adding some indentation - I struggle at the best of times with javascript but this was a shocker to read!! Hope I didnt mess up anything</p> <P>16/05/10 Phil: reworked PDFRemittanceAdvices.php - somehow missed from tcpdf work to print utf-8 pdfs</p> <p>16/05/10 Phil: reworked PDFPriceList to use the new effective dates fields and print out effective prices as at a specified date - showing effective dates on the report - also ditched includes/PDFPriceListPageHeader.php in favour of a PageHeader() function inside PDFPriceList.php. Also made the script work with tcpdf - not sure how it was missed before?</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-05-24 18:11:20
|
Revision: 3467 http://web-erp.svn.sourceforge.net/web-erp/?rev=3467&view=rev Author: tim_schofield Date: 2010-05-24 18:11:14 +0000 (Mon, 24 May 2010) Log Message: ----------- Correct SQL error on Currency updater Modified Paths: -------------- trunk/doc/Change.log.html trunk/includes/session.inc Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-24 17:48:19 UTC (rev 3466) +++ trunk/doc/Change.log.html 2010-05-24 18:11:14 UTC (rev 3467) @@ -14,6 +14,7 @@ <p>08/05/10 Lindsay: API was broken after adding a test for global variable $DatabaseName in ConnectDB_mysql* for this variable being set and using it as DB name if so. The variable of that name in the api_php.php has been changed to $api_DatabaseName.</p> <p>08/05/10 Phil: GetPrices.inc now uses the new price startdate and enddate to return the price which falls within the date range base on the current date. Changes to Prices.php and Prices_Customer.php to allow entry of effective from and effective to dates and updating/deleting of prices with appropriate error trapping and rescheduling of enddates where start and end dates would otherwise overlap.</p> <p>08/05/10 Phil: Found a bug in Date1GreaterThanDate2 function (in includes/DateFunction.inc) with SESSION['DefaultDateFormat'] = 'd/m/Y' this function had been broken </p> +<p>06/05/10 Keith: session.inc : Correct SQL error on Currency updater</p> <p>06/05/10 Lindsay: Tracker 2929564: dates mangled via QuicK Entry format</p> <p>06/05/10 Matt Taylor: upgrade3.11.1-3.12.sql : Added default startdate to prices table.</p> <p>06/05/10 Matt Taylor: weberp-demo.sql : Added startdate and enddate columns to prices table.</p> Modified: trunk/includes/session.inc =================================================================== --- trunk/includes/session.inc 2010-05-24 17:48:19 UTC (rev 3466) +++ trunk/includes/session.inc 2010-05-24 18:11:14 UTC (rev 3467) @@ -139,7 +139,9 @@ while ($CurrencyRow = DB_fetch_row($CurrenciesResult)){ if ($CurrencyRow[0]!=$_SESSION['CompanyRecord']['currencydefault']){ - $UpdateCurrRateResult = DB_query('UPDATE currencies SET rate=' . GetCurrencyRate ($CurrencyRow[0],$CurrencyRates) . " WHERE currabrev='" . $CurrencyRow[0] . "'",$db); + $UpdateCurrRateResult = DB_query('UPDATE currencies SET + rate=' . GetCurrencyRate ($CurrencyRow[0],$CurrencyRates) . " ' + WHERE currabrev='" . $CurrencyRow[0] . "'",$db); } } $_SESSION['UpdateCurrencyRatesDaily'] = Date('Y-m-d'); @@ -265,4 +267,4 @@ return $Password; } } -?> \ No newline at end of file +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-05-26 07:23:59
|
Revision: 3468 http://web-erp.svn.sourceforge.net/web-erp/?rev=3468&view=rev Author: tim_schofield Date: 2010-05-26 07:23:52 +0000 (Wed, 26 May 2010) Log Message: ----------- Tim: Corrections to SelectCustomer.php and Customers.php Modified Paths: -------------- trunk/Customers.php trunk/SelectCustomer.php trunk/doc/Change.log.html Modified: trunk/Customers.php =================================================================== --- trunk/Customers.php 2010-05-24 18:11:14 UTC (rev 3467) +++ trunk/Customers.php 2010-05-26 07:23:52 UTC (rev 3468) @@ -628,7 +628,7 @@ echo '<table border=2 cellspacing=4><tr><td><table>'; if (!isset($_POST['New'])) { - $sql = "SELECT debtorno, + $sql = "SELECT debtorsmaster.debtorno, name, address1, address2, @@ -636,9 +636,9 @@ address4, address5, address6, - telephone, - fax, - email, + custbranch.phoneno, + custbranch.faxno, + custbranch.email, currcode, salestype, clientsince, @@ -653,7 +653,9 @@ customerpoline, typeid FROM debtorsmaster - WHERE debtorno = '" . $DebtorNo . "'"; + LEFT JOIN custbranch + ON debtorsmaster.debtorno=custbranch.debtorno + WHERE debtorsmaster.debtorno = '" . $DebtorNo . "'"; $ErrMsg = _('The customer details could not be retrieved because'); $result = DB_query($sql,$db,$ErrMsg); Modified: trunk/SelectCustomer.php =================================================================== --- trunk/SelectCustomer.php 2010-05-24 18:11:14 UTC (rev 3467) +++ trunk/SelectCustomer.php 2010-05-26 07:23:52 UTC (rev 3468) @@ -23,6 +23,7 @@ $myrow = DB_fetch_array($result); $sql = "SELECT debtorsmaster.debtorno, debtorsmaster.name, + custbranch.branchcode, custbranch.brname, custbranch.lat, custbranch.lng @@ -102,6 +103,7 @@ debtorsmaster.address2, debtorsmaster.address3, debtorsmaster.address4, + custbranch.branchcode, custbranch.brname, custbranch.contactname, debtortype.typename, @@ -121,6 +123,7 @@ debtorsmaster.address2, debtorsmaster.address3, debtorsmaster.address4, + custbranch.branchcode, custbranch.brname, custbranch.contactname, debtortype.typename, @@ -138,6 +141,7 @@ debtorsmaster.address2, debtorsmaster.address3, debtorsmaster.address4, + custbranch.branchcode, custbranch.brname, custbranch.contactname, debtortype.typename, @@ -154,6 +158,7 @@ debtorsmaster.address2, debtorsmaster.address3, debtorsmaster.address4, + custbranch.branchcode, custbranch.brname, custbranch.contactname, debtortype.typename, @@ -172,6 +177,7 @@ debtorsmaster.address2, debtorsmaster.address3, debtorsmaster.address4, + custbranch.branchcode, custbranch.brname, custbranch.contactname, debtortype.typename, @@ -190,6 +196,7 @@ debtorsmaster.address2, debtorsmaster.address3, debtorsmaster.address4, + custbranch.branchcode, custbranch.brname, custbranch.contactname, debtortype.typename, @@ -219,10 +226,11 @@ if (!isset($_POST['Select'])) { $_POST['Select'] = ""; } +$Debtor=explode('-', $_POST['Select']); if ($_POST['Select'] != "" or ($_SESSION['CustomerID'] != "" and !isset($_POST['Keywords']) and !isset($_POST['CustCode']) and !isset($_POST['CustType']) and !isset($_POST['CustPhone']))) { if ($_POST['Select'] != "") { - $SQL = "SELECT brname, phoneno FROM custbranch WHERE debtorno='" . $_POST['Select'] . "'"; - $_SESSION['CustomerID'] = $_POST['Select']; + $SQL = "SELECT brname, phoneno FROM custbranch WHERE debtorno='" . $Debtor[0] . "'"; + $_SESSION['CustomerID'] = $Debtor[0]; } else { $SQL = "SELECT debtorsmaster.name, custbranch.phoneno FROM debtorsmaster, custbranch WHERE @@ -425,7 +433,7 @@ echo '<tr class="OddTableRows">'; $k = 1; } - echo "<td><font size=1><input type=submit name='Select' value='" . $myrow['debtorno'] . "'</font></td> + echo "<td><font size=1><input type=submit name='Select' value='" . $myrow['debtorno'].'-'.$myrow['branchcode'] . "'></font></td> <td><font size=1>" . $myrow['name'] . "</font></td> <td><font size=1>" . $myrow['brname'] . "</font></td> <td><font size=1>" . $myrow['contactname'] . "</font></td> Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-24 18:11:14 UTC (rev 3467) +++ trunk/doc/Change.log.html 2010-05-26 07:23:52 UTC (rev 3468) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<P>26/05/10 Tim: Corrections to SelectCustomer.php and Customers.php</p> <P>24/05/10 Simon Peter Otandeka: Added telephone, email and fax fields to Suppliers and Customers Pages. Ability to add/edit the records.</p> <P>16/05/10 Phil: javascripts/MiscFunctions.js - not my field ... but could not resist adding some indentation - I struggle at the best of times with javascript but this was a shocker to read!! Hope I didnt mess up anything</p> <P>16/05/10 Phil: reworked PDFRemittanceAdvices.php - somehow missed from tcpdf work to print utf-8 pdfs</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-05-26 07:37:38
|
Revision: 3469 http://web-erp.svn.sourceforge.net/web-erp/?rev=3469&view=rev Author: tim_schofield Date: 2010-05-26 07:37:32 +0000 (Wed, 26 May 2010) Log Message: ----------- Tim: Corrections to Suppliers.php and new fields for suppliers table Modified Paths: -------------- trunk/Suppliers.php trunk/doc/Change.log.html trunk/sql/mysql/upgrade3.11.1-3.12.sql Modified: trunk/Suppliers.php =================================================================== --- trunk/Suppliers.php 2010-05-26 07:23:52 UTC (rev 3468) +++ trunk/Suppliers.php 2010-05-26 07:37:32 UTC (rev 3469) @@ -649,13 +649,13 @@ echo '<table>'; echo '<tr><td>' . _('Supplier Code') . ":</td><td><input type='text' name='SupplierID' size=11 maxlength=10></td></tr>"; echo '<tr><td>' . _('Supplier Name') . ":</td><td><input type='text' name='SuppName' size=42 maxlength=40></td></tr>"; - echo '<tr><td>' . _('Telephone') . ":</td><td><input type='text' name='Phone' size=30 maxlength=40></td></tr>"; - echo '<tr><td>' . _('Facsimile') . ":</td><td><input type='text' name='Fax' size=30 maxlength=40></td></tr>"; - echo '<tr><td>' . _('Email Address') . ":</td><td><input type='text' name='Email' size=30 maxlength=40></td></tr>"; echo '<tr><td>' . _('Address Line 1 (Street)') . ":</td><td><input type='text' name='Address1' size=42 maxlength=40></td></tr>"; echo '<tr><td>' . _('Address Line 2 (Suburb/City)') . ":</td><td><input type='text' name='Address2' size=42 maxlength=40></td></tr>"; echo '<tr><td>' . _('Address Line 3 (State/Province)') . ":</td><td><input type='text' name='Address3' size=42 maxlength=40></td></tr>"; echo '<tr><td>' . _('Address Line 4 (Postal Code)') . ":</td><td><input type='text' name='Address4' size=42 maxlength=40></td></tr>"; + echo '<tr><td>' . _('Telephone') . ":</td><td><input type='text' name='Phone' size=30 maxlength=40></td></tr>"; + echo '<tr><td>' . _('Facsimile') . ":</td><td><input type='text' name='Fax' size=30 maxlength=40></td></tr>"; + echo '<tr><td>' . _('Email Address') . ":</td><td><input type='text' name='Email' size=30 maxlength=40></td></tr>"; $DateString = Date($_SESSION['DefaultDateFormat']); echo '<tr><td>' . _('Supplier Since') . ' (' . $_SESSION['DefaultDateFormat'] . "):</td><td><input type='text' class='date' alt='".$_SESSION['DefaultDateFormat']."' name='SupplierSince' VALUE=$DateString size=12 maxlength=10></td></tr>"; @@ -790,13 +790,13 @@ } echo '<tr><td>' . _('Supplier Name') . ':</td><td><input '.(in_array('Name',$Errors) ? 'class="inputerror"' : '').' type="text" name="SuppName" VALUE="' . $_POST['SuppName'] . '" size=42 maxlength=40></td></tr>'; - echo '<tr><td>' . _('Telephone') . ':</td><td><input '.(in_array('Name',$Errors) ? 'class="inputerror"' : '').' type="text" name="Phone" VALUE="' . $_POST['Phone'] . '" size=42 maxlength=40></td></tr>'; - echo '<tr><td>' . _('Facsimile') . ':</td><td><input '.(in_array('Name',$Errors) ? 'class="inputerror"' : '').' type="text" name="Fax" VALUE="' . $_POST['Fax'] . '" size=42 maxlength=40></td></tr>'; - echo '<tr><td>' . _('Email Address') . ':</td><td><input '.(in_array('Name',$Errors) ? 'class="inputerror"' : '').' type="text" name="Email" VALUE="' . $_POST['Email'] . '" size=42 maxlength=40></td></tr>'; echo '<tr><td>' . _('Address Line 1 (Street)') . ':</td><td><input type="text" name="Address1" VALUE="' . $_POST['Address1'] . '" size=42 maxlength=40></td></tr>'; echo '<tr><td>' . _('Address Line 2 (Suburb/City)') . ':</td><td><input type="text" name="Address2" VALUE="' . $_POST['Address2'] . '" size=42 maxlength=40></td></tr>'; echo '<tr><td>' . _('Address Line 3 (State/Province)') . ':</td><td><input type="text" name="Address3" VALUE="' . $_POST['Address3'] . '" size=42 maxlength=40></td></tr>'; echo '<tr><td>' . _('Address Line 4 (Postal Code)') . ':</td><td><input type="text" name="Address4" VALUE="' . $_POST['Address4'] . '" size=42 maxlength=40></td></tr>'; + echo '<tr><td>' . _('Telephone') . ':</td><td><input '.(in_array('Name',$Errors) ? 'class="inputerror"' : '').' type="text" name="Phone" VALUE="' . $_POST['Phone'] . '" size=42 maxlength=40></td></tr>'; + echo '<tr><td>' . _('Facsimile') . ':</td><td><input '.(in_array('Name',$Errors) ? 'class="inputerror"' : '').' type="text" name="Fax" VALUE="' . $_POST['Fax'] . '" size=42 maxlength=40></td></tr>'; + echo '<tr><td>' . _('Email Address') . ':</td><td><input '.(in_array('Name',$Errors) ? 'class="inputerror"' : '').' type="text" name="Email" VALUE="' . $_POST['Email'] . '" size=42 maxlength=40></td></tr>'; echo '<tr><td>' . _('Supplier Since') . ' (' . $_SESSION['DefaultDateFormat'] .'):</td><td><input '.(in_array('SupplierSince',$Errors) ? 'class="inputerror"' : '').' size=12 maxlength=10 type="text" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" name="SupplierSince" VALUE=' . $_POST['SupplierSince'] . '></td></tr>'; echo '<tr><td>' . _('Bank Particulars') . ":</td><td><input type='text' name='BankPartics' size=13 maxlength=12 VALUE='" . $_POST['BankPartics'] . "'></td></tr>"; Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-26 07:23:52 UTC (rev 3468) +++ trunk/doc/Change.log.html 2010-05-26 07:37:32 UTC (rev 3469) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<P>26/05/10 Tim: Corrections to Suppliers.php and new fields for suppliers table</p> <P>26/05/10 Tim: Corrections to SelectCustomer.php and Customers.php</p> <P>24/05/10 Simon Peter Otandeka: Added telephone, email and fax fields to Suppliers and Customers Pages. Ability to add/edit the records.</p> <P>16/05/10 Phil: javascripts/MiscFunctions.js - not my field ... but could not resist adding some indentation - I struggle at the best of times with javascript but this was a shocker to read!! Hope I didnt mess up anything</p> Modified: trunk/sql/mysql/upgrade3.11.1-3.12.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-05-26 07:23:52 UTC (rev 3468) +++ trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-05-26 07:37:32 UTC (rev 3469) @@ -161,3 +161,5 @@ ALTER TABLE stockcheckfreeze ADD COLUMN stockcheckdate date NOT NULL; UPDATE prices SET startdate='1999-01-01'; + +ALTER TABLE suppliers add (email varchar(55),fax varchar(25), telephone varchar(25)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-05-28 11:38:47
|
Revision: 3470 http://web-erp.svn.sourceforge.net/web-erp/?rev=3470&view=rev Author: tim_schofield Date: 2010-05-28 11:38:41 +0000 (Fri, 28 May 2010) Log Message: ----------- GLProfit_Loss.php - Correction to show profit and loss reports for other languages Modified Paths: -------------- trunk/GLProfit_Loss.php trunk/doc/Change.log.html Modified: trunk/GLProfit_Loss.php =================================================================== --- trunk/GLProfit_Loss.php 2010-05-26 07:37:32 UTC (rev 3469) +++ trunk/GLProfit_Loss.php 2010-05-28 11:38:41 UTC (rev 3470) @@ -364,7 +364,7 @@ $SectionPrdActual +=$AccountPeriodActual; $SectionPrdBudget +=$AccountPeriodBudget; - if ($_POST['Detail'] == _('Detailed')) { + if ($_POST['Detail'] == 'Detailed') { $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,60,$FontSize,$myrow['accountcode']); $LeftOvers = $pdf->addTextWrap($Left_Margin+60,$YPos,190,$FontSize,$myrow['accountname']); if ($Section == 1) { /*Income*/ @@ -869,7 +869,7 @@ $SectionPrdActual +=$AccountPeriodActual; $SectionPrdBudget +=$AccountPeriodBudget; - if ($_POST['Detail']==_('Detailed')){ + if ($_POST['Detail']=='Detailed'){ if ($k==1){ echo '<tr class="EvenTableRows">'; Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-26 07:37:32 UTC (rev 3469) +++ trunk/doc/Change.log.html 2010-05-28 11:38:41 UTC (rev 3470) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<P>27/05/10 Tim: GLProfit_Loss.php - Correction to show profit and loss reports for other languages</p> <P>26/05/10 Tim: Corrections to Suppliers.php and new fields for suppliers table</p> <P>26/05/10 Tim: Corrections to SelectCustomer.php and Customers.php</p> <P>24/05/10 Simon Peter Otandeka: Added telephone, email and fax fields to Suppliers and Customers Pages. Ability to add/edit the records.</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-05-28 12:34:29
|
Revision: 3471 http://web-erp.svn.sourceforge.net/web-erp/?rev=3471&view=rev Author: tim_schofield Date: 2010-05-28 12:34:22 +0000 (Fri, 28 May 2010) Log Message: ----------- Tim: PO_ReadInOrder.inc - Only show one line when item has more than one price set up Modified Paths: -------------- trunk/doc/Change.log.html trunk/includes/PO_ReadInOrder.inc Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-28 11:38:41 UTC (rev 3470) +++ trunk/doc/Change.log.html 2010-05-28 12:34:22 UTC (rev 3471) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<P>27/05/10 Tim: PO_ReadInOrder.inc - Only show one line when item has more than one price set up</p> <P>27/05/10 Tim: GLProfit_Loss.php - Correction to show profit and loss reports for other languages</p> <P>26/05/10 Tim: Corrections to Suppliers.php and new fields for suppliers table</p> <P>26/05/10 Tim: Corrections to SelectCustomer.php and Customers.php</p> Modified: trunk/includes/PO_ReadInOrder.inc =================================================================== --- trunk/includes/PO_ReadInOrder.inc 2010-05-28 11:38:41 UTC (rev 3470) +++ trunk/includes/PO_ReadInOrder.inc 2010-05-28 12:34:22 UTC (rev 3471) @@ -154,7 +154,8 @@ gw, cuft, total_quantity, - total_amount + total_amount, + MAX(purchdata.effectivefrom) FROM purchorderdetails LEFT JOIN stockmaster ON purchorderdetails.itemcode=stockmaster.stockid @@ -162,30 +163,12 @@ ON purchorders.orderno=purchorderdetails.orderno LEFT JOIN chartmaster ON purchorderdetails.glcode=chartmaster.accountcode - LEFT JOIN (SELECT purchdata.supplierno, - purchdata.stockid, - purchdata.price, - purchdata.suppliersuom, - purchdata.conversionfactor, - purchdata.supplierdescription, - purchdata.leadtime, - purchdata.preferred, - purchdata.suppliers_partno, - MAX(purchdata.effectivefrom) - FROM purchdata - GROUP BY purchdata.supplierno, - purchdata.stockid, - purchdata.suppliersuom, - purchdata.conversionfactor, - purchdata.supplierdescription, - purchdata.leadtime, - purchdata.preferred, - purchdata.suppliers_partno) purchdata + LEFT JOIN purchdata ON purchdata.stockid=purchorderdetails.itemcode AND purchdata.supplierno=purchorders.supplierno WHERE purchorderdetails.completed=0 - AND purchorderdetails.orderno =' . $_GET['ModifyOrderNumber'] . ' + AND purchorderdetails.orderno =" . $_GET['ModifyOrderNumber'] . ' ORDER BY podetailitem'; - + $ErrMsg = _('The lines on the purchase order cannot be retrieved because'); $DbgMsg = _('The SQL statement that was used to retrieve the purchase order lines was'); $LineItemsResult = db_query($LineItemsSQL,$db,$ErrMsg,$DbgMsg); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-05-28 15:24:17
|
Revision: 3472 http://web-erp.svn.sourceforge.net/web-erp/?rev=3472&view=rev Author: tim_schofield Date: 2010-05-28 15:24:11 +0000 (Fri, 28 May 2010) Log Message: ----------- GoodsReceived.php - Correctly show the suppliers Units of measure Modified Paths: -------------- trunk/GoodsReceived.php trunk/doc/Change.log.html Modified: trunk/GoodsReceived.php =================================================================== --- trunk/GoodsReceived.php 2010-05-28 12:34:22 UTC (rev 3471) +++ trunk/GoodsReceived.php 2010-05-28 15:24:11 UTC (rev 3472) @@ -111,16 +111,21 @@ $DisplayLineTotal = number_format($LineTotal,2); $DisplayPrice = number_format($LnItm->Price,2); - $uomsql='SELECT conversionfactor, suppliersuom + $uomsql='SELECT unitsofmeasure.unitname, + conversionfactor, + suppliersuom, + max(effectivefrom) FROM purchdata + LEFT JOIN unitsofmeasure + ON purchdata.suppliersuom=unitsofmeasure.unitid WHERE supplierno="'.$_SESSION['PO']->SupplierID.'" AND stockid="'.$LnItm->StockID.'"'; $uomresult=DB_query($uomsql, $db); if (DB_num_rows($uomresult)>0) { $uomrow=DB_fetch_array($uomresult); - if (strlen($uomrow['suppliersuom'])>0) { - $uom=$uomrow['suppliersuom']; + if (strlen($uomrow['unitname'])>0) { + $uom=$uomrow['unitname']; } else { $uom=$LnItm->Units; } Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-28 12:34:22 UTC (rev 3471) +++ trunk/doc/Change.log.html 2010-05-28 15:24:11 UTC (rev 3472) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<P>27/05/10 Tim: GoodsReceived.php - Correctly show the suppliers Units of measure</p> <P>27/05/10 Tim: PO_ReadInOrder.inc - Only show one line when item has more than one price set up</p> <P>27/05/10 Tim: GLProfit_Loss.php - Correction to show profit and loss reports for other languages</p> <P>26/05/10 Tim: Corrections to Suppliers.php and new fields for suppliers table</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-05-28 17:22:37
|
Revision: 3473 http://web-erp.svn.sourceforge.net/web-erp/?rev=3473&view=rev Author: tim_schofield Date: 2010-05-28 17:22:31 +0000 (Fri, 28 May 2010) Log Message: ----------- CustomerAllocations.php - Show the right balance, and the allocate link where needed Modified Paths: -------------- trunk/CustomerAllocations.php trunk/doc/Change.log.html Modified: trunk/CustomerAllocations.php =================================================================== --- trunk/CustomerAllocations.php 2010-05-28 15:24:11 UTC (rev 3472) +++ trunk/CustomerAllocations.php 2010-05-28 17:22:31 UTC (rev 3473) @@ -544,9 +544,9 @@ $balance = 0; $curDebtor = $myrow['debtorno']; - $balSQL= "SELECT ovamount+ovgst+ovfreight+ovdiscount as total + $balSQL= "SELECT ovamount+ovgst+ovfreight+ovdiscount-alloc as total FROM debtortrans - WHERE debtortrans.settled=0 AND + WHERE type=12 AND debtorno='" . $myrow['debtorno'] . "' ORDER BY ovamount"; $balResult = DB_query($balSQL,$db); @@ -559,7 +559,7 @@ } $curTrans ++; - if ( isset($balance) and $balance < -0.01 ) + if ( isset($balance) and abs($balance) < -0.01 ) { $allocate = ' '; } Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-28 15:24:11 UTC (rev 3472) +++ trunk/doc/Change.log.html 2010-05-28 17:22:31 UTC (rev 3473) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<P>27/05/10 Tim: CustomerAllocations.php - Show the right balance, and the allocate link where needed</p> <P>27/05/10 Tim: GoodsReceived.php - Correctly show the suppliers Units of measure</p> <P>27/05/10 Tim: PO_ReadInOrder.inc - Only show one line when item has more than one price set up</p> <P>27/05/10 Tim: GLProfit_Loss.php - Correction to show profit and loss reports for other languages</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-05-28 18:22:22
|
Revision: 3474 http://web-erp.svn.sourceforge.net/web-erp/?rev=3474&view=rev Author: tim_schofield Date: 2010-05-28 18:22:16 +0000 (Fri, 28 May 2010) Log Message: ----------- PurchData.php - Show the uom name, not the number Modified Paths: -------------- trunk/PurchData.php trunk/doc/Change.log.html Modified: trunk/PurchData.php =================================================================== --- trunk/PurchData.php 2010-05-28 17:22:31 UTC (rev 3473) +++ trunk/PurchData.php 2010-05-28 18:22:16 UTC (rev 3474) @@ -136,13 +136,15 @@ purchdata.price, suppliers.currcode, purchdata.effectivefrom, - purchdata.suppliersuom, + unitsofmeasure.unitname, purchdata.supplierdescription, purchdata.leadtime, purchdata.suppliers_partno, purchdata.preferred FROM purchdata INNER JOIN suppliers ON purchdata.supplierno=suppliers.supplierid + LEFT JOIN unitsofmeasure + ON purchdata.suppliersuom=unitsofmeasure.unitid WHERE purchdata.stockid = '" . $StockID . "' ORDER BY purchdata.effectivefrom DESC"; $ErrMsg = _('The supplier purchasing details for the selected part could not be retrieved because'); @@ -188,7 +190,7 @@ <td>%s</td> <td><a href='%s?%s&StockID=%s&SupplierID=%s&Edit=1&EffectiveFrom=%s'>" . _('Edit') . "</a></td> <td><a href='%s?%s&StockID=%s&SupplierID=%s&Delete=1&EffectiveFrom=%s' onclick=\"return confirm('" . _('Are you sure you wish to delete this suppliers price?') . "');\">" . _('Delete') . "</a></td> - </tr>", $myrow['suppname'], number_format($myrow['price'], 3), $myrow['currcode'], ConvertSQLDate($myrow['effectivefrom']), $myrow['suppliersuom'], $myrow['leadtime'], $DisplayPreferred, $_SERVER['PHP_SELF'], SID, $StockID, $myrow['supplierno'], $myrow['effectivefrom'], $_SERVER['PHP_SELF'], SID, $StockID, $myrow['supplierno'], $myrow['effectivefrom']); + </tr>", $myrow['suppname'], number_format($myrow['price'], 3), $myrow['currcode'], ConvertSQLDate($myrow['effectivefrom']), $myrow['unitname'], $myrow['leadtime'], $DisplayPreferred, $_SERVER['PHP_SELF'], SID, $StockID, $myrow['supplierno'], $myrow['effectivefrom'], $_SERVER['PHP_SELF'], SID, $StockID, $myrow['supplierno'], $myrow['effectivefrom']); } //end of while loop echo '</table><br/>'; if ($CountPreferreds > 1) { Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-28 17:22:31 UTC (rev 3473) +++ trunk/doc/Change.log.html 2010-05-28 18:22:16 UTC (rev 3474) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<P>27/05/10 Tim: PurchData.php - Show the uom name, not the number</p> <P>27/05/10 Tim: CustomerAllocations.php - Show the right balance, and the allocate link where needed</p> <P>27/05/10 Tim: GoodsReceived.php - Correctly show the suppliers Units of measure</p> <P>27/05/10 Tim: PO_ReadInOrder.inc - Only show one line when item has more than one price set up</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-05-29 00:00:48
|
Revision: 3475 http://web-erp.svn.sourceforge.net/web-erp/?rev=3475&view=rev Author: daintree Date: 2010-05-29 00:00:42 +0000 (Sat, 29 May 2010) Log Message: ----------- New field in locations table to allow a default cash sales account to be setup by location -modifications to Locations.php to allow it to be entered and error-trapping for debtor - branch format required for specification. This will be used in a new CounterSales.php script I am working on Modified Paths: -------------- trunk/Locations.php trunk/PricesByCost.php trunk/SelectOrderItems.php trunk/doc/Change.log.html trunk/sql/mysql/upgrade3.11.1-3.12.sql Modified: trunk/Locations.php =================================================================== --- trunk/Locations.php 2010-05-28 18:22:16 UTC (rev 3474) +++ trunk/Locations.php 2010-05-29 00:00:42 UTC (rev 3475) @@ -30,6 +30,24 @@ $InputError = 1; prnMsg( _('The location code may not be empty'), 'error'); } + if ($_POST['CashSaleCustomer']!=''){ + if (!strstr($_POST['CashSaleCustomer'],' - ')){ + $InputError =1; + prnMsg(_('The cash sale customer account must be a valid customer account separated by " - " then the branch code of the customer entered'), 'error'); + } else { + $Branch = substr($_POST['CashSaleCustomer'],strpos($_POST['CashSaleCustomer'],' - ')+3); + $DebtorNo = substr($_POST['CashSaleCustomer'],0,strpos($_POST['CashSaleCustomer'],' - ')); + $sql = "SELECT * FROM custbranch WHERE debtorno='" . $DebtorNo . "' + AND branchcode='" . $Branch . "'"; + + $result = DB_query($sql,$db); + if (DB_num_rows($result)==0){ + $InputError = 1; + prnMsg(_('The cash sale customer for this location must be a valid customer code separated by " - " then a valid branch code for this customer'),'error'); + } + } + } //end of checking the customer - branch code entered + if (isset($SelectedLocation) AND $InputError !=1) { @@ -54,6 +72,7 @@ email='" . $_POST['Email'] . "', contact='" . $_POST['Contact'] . "', taxprovinceid = " . $_POST['TaxProvince'] . ", + cashsalecustomer ='" . $_POST['CashSaleCustomer'] . "', managed = " . $_POST['Managed'] . " WHERE loccode = '$SelectedLocation'"; @@ -76,6 +95,7 @@ unset($_POST['Email']); unset($_POST['TaxProvince']); unset($_POST['Managed']); + unset($_POST['CashSaleCustomer']); unset($SelectedLocation); unset($_POST['Contact']); @@ -105,6 +125,7 @@ email, contact, taxprovinceid, + cashsalecustomer, managed ) VALUES ( @@ -121,6 +142,7 @@ '" . $_POST['Email'] . "', '" . $_POST['Contact'] . "', " . $_POST['TaxProvince'] . ", + '" . $_POST['CashSaleCustomer'] . "', " . $_POST['Managed'] . " )"; @@ -160,6 +182,7 @@ unset($_POST['Fax']); unset($_POST['Email']); unset($_POST['TaxProvince']); + unset($_POST['CashSaleCustomer']); unset($_POST['Managed']); unset($SelectedLocation); unset($_POST['Contact']); @@ -402,6 +425,7 @@ tel, email, taxprovinceid, + cashsalecustomer, managed FROM locations WHERE loccode='$SelectedLocation'"; @@ -422,6 +446,7 @@ $_POST['Fax'] = $myrow['fax']; $_POST['Email'] = $myrow['email']; $_POST['TaxProvince'] = $myrow['taxprovinceid']; + $_POST['CashSaleCustomer'] = $myrow['cashsalecustomer']; $_POST['Managed'] = $myrow['managed']; @@ -468,6 +493,9 @@ if (!isset($_POST['Email'])) { $_POST['Email'] = ''; } + if (!isset($_POST['CashSaleCustomer'])) { + $_POST['CashSaleCustomer'] = ''; + } if (!isset($_POST['Managed'])) { $_POST['Managed'] = 0; } @@ -510,8 +538,15 @@ ?> </select></td></tr> + <tr><td><?php echo _('Default Counter Sales Customer') . ':'; ?></td> + <td><input type="Text" name="CashSaleCustomer" value="<?php echo $_POST['CashSaleCustomer']; ?>" size=25 maxlength=23></td></tr> + <?php + /* + This functionality is not written yet ... <tr><td><?php echo _('Enable Warehouse Management') . ':'; ?></td> <td><input type='checkbox' name='Managed'<?php if($_POST['Managed'] == 1) echo ' checked';?>></td></tr> + */ + ?> </table> <div class="centre"><input type="Submit" name="submit" value="<?php echo _('Enter Information'); ?>"></div> Modified: trunk/PricesByCost.php =================================================================== --- trunk/PricesByCost.php 2010-05-28 18:22:16 UTC (rev 3474) +++ trunk/PricesByCost.php 2010-05-29 00:00:42 UTC (rev 3475) @@ -91,9 +91,9 @@ <th>' . _('Start Date') . '</th> <th>' . _('End Date') . '</th> <th>' . _('Cost') . '</th> - <th>' . _('Current Margin') . '</th> + <th>' . _('GP %') . '</th> <th>' . _('Price Proposed') . '</th> - <th>' . _('Price in pricelist') . '</th> + <th>' . _('List Price') . '</th> <tr>'; $k = 0; //row colour counter echo '<form action="' .$_SERVER['PHP_SELF'] .'" method="POST" name="update">'; @@ -127,10 +127,10 @@ <input type="hidden" value=' . $myrow['startdate'] . ' name="StartDate_' . $PriceCounter .'"> <input type="hidden" value=' . $myrow['enddate'] . ' name="EndDate_' . $PriceCounter .'">'; //variable for current margin - if ($Cost != 0){ - $CurrentMargin = $Price / $Cost; + if ($myrow['price'] != 0){ + $CurrentGP = ($myrow['price']-$Cost)*100 / $myrow['price']; } else { - $CurrentMargin = 0; + $CurrentGP = 0; } //variable for proposed $Proposed = $Cost * $_POST['Margin']; @@ -146,9 +146,9 @@ <td>' . ConvertSQLDate($myrow['startdate']) . '</td> <td>' . $EndDateDisplay . '</td> <td class="number">' . number_format($Cost, 2) . '</td> - <td class="number">' . number_format($CurrentMargin, 2) . '</td> + <td class="number">' . number_format($CurrentGP, 1) . '%</td> <td class="number">' . number_format($Proposed, 2) . '</td> - <td><input type="text" class="number" name="Price_' . $PriceCounter . '" MAXLENGTH =14 size=15 value="' . $myrow['price'] . '"></td> + <td><input type="text" class="number" name="Price_' . $PriceCounter . '" maxlength=14 size=10 value="' . $myrow['price'] . '"></td> </tr> '; $PriceCounter++; } //end of looping Modified: trunk/SelectOrderItems.php =================================================================== --- trunk/SelectOrderItems.php 2010-05-28 18:22:16 UTC (rev 3474) +++ trunk/SelectOrderItems.php 2010-05-29 00:00:42 UTC (rev 3475) @@ -62,9 +62,6 @@ } -// removed to improve UI layout -//echo '<a href="'. $rootpath . '/SelectSalesOrder.php?' . SID . '">'. _('Back to Sales Orders'). '</a><br>'; - if (isset($_GET['ModifyOrderNumber']) AND $_GET['ModifyOrderNumber']!=''){ Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-28 18:22:16 UTC (rev 3474) +++ trunk/doc/Change.log.html 2010-05-29 00:00:42 UTC (rev 3475) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>28/5/10 Phil: New field in locations table to allow a default cash sales account to be setup by location -modifications to Locations.php to allow it to be entered and error-trapping for debtor - branch format required for specification. This will be used in a new CounterSales.php script I am working on <P>27/05/10 Tim: PurchData.php - Show the uom name, not the number</p> <P>27/05/10 Tim: CustomerAllocations.php - Show the right balance, and the allocate link where needed</p> <P>27/05/10 Tim: GoodsReceived.php - Correctly show the suppliers Units of measure</p> @@ -8,7 +9,7 @@ <P>26/05/10 Tim: Corrections to Suppliers.php and new fields for suppliers table</p> <P>26/05/10 Tim: Corrections to SelectCustomer.php and Customers.php</p> <P>24/05/10 Simon Peter Otandeka: Added telephone, email and fax fields to Suppliers and Customers Pages. Ability to add/edit the records.</p> -<P>16/05/10 Phil: javascripts/MiscFunctions.js - not my field ... but could not resist adding some indentation - I struggle at the best of times with javascript but this was a shocker to read!! Hope I didnt mess up anything</p> +<P>16/05/10 Phil: javascripts/MiscFunctions.js - not my field ... but could not resist adding some indentation - I struggle at the best of times with javascript but this was a shocker to read!! Hope I didn't mess up anything</p> <P>16/05/10 Phil: reworked PDFRemittanceAdvices.php - somehow missed from tcpdf work to print utf-8 pdfs</p> <p>16/05/10 Phil: reworked PDFPriceList to use the new effective dates fields and print out effective prices as at a specified date - showing effective dates on the report - also ditched includes/PDFPriceListPageHeader.php in favour of a PageHeader() function inside PDFPriceList.php. Also made the script work with tcpdf - not sure how it was missed before?</p> <p>16/05/10 Phil: reworked PricesBasedOnMarkUp.php to insert new prices with effectivity dates and update the prices where effectivity dates specified.</p> Modified: trunk/sql/mysql/upgrade3.11.1-3.12.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-05-28 18:22:16 UTC (rev 3474) +++ trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-05-29 00:00:42 UTC (rev 3475) @@ -157,9 +157,9 @@ ALTER TABLE prices DROP PRIMARY KEY , ADD PRIMARY KEY ( `stockid` , `typeabbrev` , `currabrev` , `debtorno` , `startdate` , `enddate` ) ; -UPDATE prices SET startdate='1999-01-01', enddate='9999-12-31'; +UPDATE prices SET startdate='1999-01-01', enddate=''; ALTER TABLE stockcheckfreeze ADD COLUMN stockcheckdate date NOT NULL; -UPDATE prices SET startdate='1999-01-01'; ALTER TABLE suppliers add (email varchar(55),fax varchar(25), telephone varchar(25)); +ALTER TABLE locations add cashsalecustomer VARCHAR(21) NOT NULL DEFAULT ''; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-05-29 21:41:43
|
Revision: 3476 http://web-erp.svn.sourceforge.net/web-erp/?rev=3476&view=rev Author: daintree Date: 2010-05-29 21:41:37 +0000 (Sat, 29 May 2010) Log Message: ----------- GL trans were set to posted at the time of creation so integrated GL was broken, reverted to creating gltrans with posted=0 Modified Paths: -------------- trunk/ConfirmDispatch_Invoice.php trunk/sql/mysql/upgrade3.11.1-3.12.sql Modified: trunk/ConfirmDispatch_Invoice.php =================================================================== --- trunk/ConfirmDispatch_Invoice.php 2010-05-29 00:00:42 UTC (rev 3475) +++ trunk/ConfirmDispatch_Invoice.php 2010-05-29 21:41:37 UTC (rev 3476) @@ -1241,9 +1241,7 @@ periodno, account, narrative, - amount, - posted - ) + amount ) VALUES ( 10, " . $InvoiceNo . ", @@ -1251,9 +1249,7 @@ " . $PeriodNo . ", " . GetCOGSGLAccount($Area, $OrderLine->StockID, $_SESSION['Items']->DefaultSalesType, $db) . ", '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->StandardCost . "', - " . $OrderLine->StandardCost * $OrderLine->QtyDispatched . ", - 1 - )"; + " . $OrderLine->StandardCost * $OrderLine->QtyDispatched . " )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The cost of sales GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the GLTrans record was used'); @@ -1269,9 +1265,7 @@ periodno, account, narrative, - amount, - posted - ) + amount ) VALUES ( 10, " . $InvoiceNo . ", @@ -1279,9 +1273,7 @@ " . $PeriodNo . ", " . $StockGLCode['stockact'] . ", '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->StandardCost . "', - " . (-$OrderLine->StandardCost * $OrderLine->QtyDispatched) . ", - 1 - )"; + " . (-$OrderLine->StandardCost * $OrderLine->QtyDispatched) . " )"; $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'); @@ -1300,9 +1292,7 @@ periodno, account, narrative, - amount, - posted - ) + amount ) VALUES ( 10, " . $InvoiceNo . ", @@ -1310,9 +1300,7 @@ " . $PeriodNo . ", " . $SalesGLAccounts['salesglcode'] . ", '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->Price . "', - " . (-$OrderLine->Price * $OrderLine->QtyDispatched/$_SESSION['CurrencyRate']) . ", - 1 - )"; + " . (-$OrderLine->Price * $OrderLine->QtyDispatched/$_SESSION['CurrencyRate']) . " )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales GL posting could not be inserted because'); $DbgMsg = '<br>' ._('The following SQL to insert the GLTrans record was used'); @@ -1327,9 +1315,7 @@ periodno, account, narrative, - amount, - posted - ) + amount ) VALUES ( 10, " . $InvoiceNo . ", @@ -1337,9 +1323,7 @@ " . $PeriodNo . ", " . $SalesGLAccounts['discountglcode'] . ", '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " @ " . ($OrderLine->DiscountPercent * 100) . "%', - " . ($OrderLine->Price * $OrderLine->QtyDispatched * $OrderLine->DiscountPercent/$_SESSION['CurrencyRate']) . ", - 1 - )"; + " . ($OrderLine->Price * $OrderLine->QtyDispatched * $OrderLine->DiscountPercent/$_SESSION['CurrencyRate']) . " )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales discount GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the GLTrans record was used'); @@ -1362,9 +1346,7 @@ periodno, account, narrative, - amount, - posted - ) + amount ) VALUES ( 10, " . $InvoiceNo . ", @@ -1372,9 +1354,7 @@ " . $PeriodNo . ", " . $_SESSION['CompanyRecord']['debtorsact'] . ", '" . $_SESSION['Items']->DebtorNo . "', - " . (($_SESSION['Items']->total + $_SESSION['Items']->FreightCost + $TaxTotal)/$_SESSION['CurrencyRate']) . ", - 1 - )"; + " . (($_SESSION['Items']->total + $_SESSION['Items']->FreightCost + $TaxTotal)/$_SESSION['CurrencyRate']) . " )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The total debtor GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the total debtors control GLTrans record was used'); @@ -1391,9 +1371,7 @@ periodno, account, narrative, - amount, - posted - ) + amount ) VALUES ( 10, " . $InvoiceNo . ", @@ -1401,9 +1379,7 @@ " . $PeriodNo . ", " . $_SESSION['CompanyRecord']['freightact'] . ", '" . $_SESSION['Items']->DebtorNo . "', - " . (-($_SESSION['Items']->FreightCost)/$_SESSION['CurrencyRate']) . ", - 1 - )"; + " . (-($_SESSION['Items']->FreightCost)/$_SESSION['CurrencyRate']) . " )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The freight GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the GLTrans record was used'); @@ -1418,9 +1394,7 @@ periodno, account, narrative, - amount, - posted - ) + amount ) VALUES ( 10, " . $InvoiceNo . ", @@ -1428,9 +1402,7 @@ " . $PeriodNo . ", " . $TaxGLCodes[$TaxAuthID] . ", '" . $_SESSION['Items']->DebtorNo . "', - " . (-$TaxAmount/$_SESSION['CurrencyRate']) . ", - 1 - )"; + " . (-$TaxAmount/$_SESSION['CurrencyRate']) . " )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The tax GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the GLTrans record was used'); Modified: trunk/sql/mysql/upgrade3.11.1-3.12.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-05-29 00:00:42 UTC (rev 3475) +++ trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-05-29 21:41:37 UTC (rev 3476) @@ -19,7 +19,7 @@ UPDATE `www_users` SET `modulesallowed`=(SELECT insert(`modulesallowed`, 15,0,"1,")); INSERT INTO `config` (`confname`, `confvalue`) VALUES ('FrequentlyOrderedItems',0); -ALTER TABLE `www_users` CHANGE COLUMN `language` `language` varchar(10) NOT NULL DEFAULT 'en_GB'; +ALTER TABLE `www_users` CHANGE COLUMN `language` `language` varchar(10) NOT NULL DEFAULT 'en_GB.utf8'; ALTER TABLE `assetmanager` ADD COLUMN `disposalvalue` int(11) NOT NULL DEFAULT 0; ALTER TABLE `currencies` ADD COLUMN `decimalplaces` tinyint(3) NOT NULL DEFAULT 2 AFTER `hundredsname`; ALTER TABLE `fixedassetlocations` ADD COLUMN `parentlocationid` char(6) DEFAULT ''; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-05-30 05:53:47
|
Revision: 3477 http://web-erp.svn.sourceforge.net/web-erp/?rev=3477&view=rev Author: daintree Date: 2010-05-30 05:53:40 +0000 (Sun, 30 May 2010) Log Message: ----------- New script to allow sales to be entered from a single script. The customer is defaulted from the logged in users default stock location. Locations need to be defined with a customer account that is their default cash/counter sales account. The new script allows payments to be entered. Behind the scenes all the logic is the same as a normal order -> ConfirmDispatch_Invoice.php. It is not possible to invoice controlled/serial items using this script Modified Paths: -------------- trunk/BankMatching.php trunk/CustomerReceipt.php trunk/DeliveryDetails.php trunk/doc/Change.log.html trunk/includes/GetPrice.inc trunk/includes/MiscFunctions.php trunk/includes/SelectOrderItems_IntoCart.inc trunk/index.php Added Paths: ----------- trunk/CounterSales.php Modified: trunk/BankMatching.php =================================================================== --- trunk/BankMatching.php 2010-05-29 21:41:37 UTC (rev 3476) +++ trunk/BankMatching.php 2010-05-30 05:53:40 UTC (rev 3477) @@ -8,15 +8,22 @@ $title = _('Bank Account Matching'); include('includes/header.inc'); -if ((isset($_GET["Type"]) and $_GET["Type"]=='Receipts') OR (isset($_POST["Type"]) and $_POST["Type"]=='Receipts')){ +if ((isset($_GET['Type']) AND $_GET['Type']=='Receipts') OR + (isset($_POST['Type']) and $_POST['Type']=='Receipts')){ + $Type = 'Receipts'; $TypeName =_('Receipts'); -echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_add.png" title="' . _('Bank Matching') . '" alt="">' . ' ' . _('Bank Account Matching - Receipts') . '</p>'; -} elseif ((isset($_GET["Type"]) and $_GET["Type"]=='Payments') OR (isset($_POST["Type"]) and $_POST["Type"]=='Payments')) { + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_add.png" title="' . _('Bank Matching') . '" alt="">' . ' ' . _('Bank Account Matching - Receipts') . '</p>'; + +} elseif ((isset($_GET['Type']) AND $_GET['Type']=='Payments') OR + (isset($_POST['Type']) and $_POST['Type']=='Payments')) { + $Type = 'Payments'; $TypeName =_('Payments'); -echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_delete.png" title="' . _('Bank Matching') . '" alt="">' . ' ' . _('Bank Account Matching - Payments') . '</p>'; + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_delete.png" title="' . _('Bank Matching') . '" alt="">' . ' ' . _('Bank Account Matching - Payments') . '</p>'; + } else { + prnMsg(_('This page must be called with a bank transaction type') . '. ' . _('It should not be called directly'),'error'); include ('includes/footer.inc'); exit; @@ -26,54 +33,55 @@ for ($Counter=1;$Counter <= $_POST['RowCounter']; $Counter++){ if (isset($_POST["Clear_" . $Counter]) and $_POST["Clear_" . $Counter]==True){ /*Get amount to be cleared */ - $sql = "SELECT amount, + $sql = 'SELECT amount, exrate FROM banktrans - WHERE banktransid=" . $_POST["BankTrans_" . $Counter]; + WHERE banktransid=' . $_POST['BankTrans_' . $Counter]; $ErrMsg = _('Could not retrieve transaction information'); $result = DB_query($sql,$db,$ErrMsg); $myrow=DB_fetch_array($result); $AmountCleared = round($myrow[0] / $myrow[1],2); /*Update the banktrans recoord to match it off */ - $sql = "UPDATE banktrans SET amountcleared= ". $AmountCleared . - " WHERE banktransid=" . $_POST["BankTrans_" . $Counter]; + $sql = 'UPDATE banktrans SET amountcleared= '. $AmountCleared . + ' WHERE banktransid=' . $_POST['BankTrans_' . $Counter]; $ErrMsg = _('Could not match off this payment because'); $result = DB_query($sql,$db,$ErrMsg); - } elseif (isset($_POST["AmtClear_" . $Counter]) and is_numeric((float) $_POST["AmtClear_" . $Counter]) AND - ((isset($_POST["AmtClear_" . $Counter]) and $_POST["AmtClear_" . $Counter]<0 AND $Type=='Payments') OR - ($Type=='Receipts' AND (isset($_POST["AmtClear_" . $Counter]) and $_POST["AmtClear_" . $Counter]>0)))){ + } elseif (isset($_POST['AmtClear_' . $Counter]) AND + is_numeric((float) $_POST["AmtClear_" . $Counter]) AND + ((isset($_POST['AmtClear_' . $Counter]) AND $_POST['AmtClear_' . $Counter]<0 AND $Type=='Payments') OR + ($Type=='Receipts' AND (isset($_POST['AmtClear_' . $Counter]) and $_POST['AmtClear_' . $Counter]>0)))){ /*if the amount entered was numeric and negative for a payment or positive for a receipt */ - $sql = "UPDATE banktrans SET amountcleared=" . $_POST["AmtClear_" . $Counter] . " - WHERE banktransid=" . $_POST["BankTrans_" . $Counter]; + $sql = 'UPDATE banktrans SET amountcleared=' . $_POST['AmtClear_' . $Counter] . ' + WHERE banktransid=' . $_POST['BankTrans_' . $Counter]; $ErrMsg = _('Could not update the amount matched off this bank transaction because'); $result = DB_query($sql,$db,$ErrMsg); - } elseif (isset($_POST["Unclear_" . $Counter]) and $_POST["Unclear_" . $Counter]==True){ - $sql = "UPDATE banktrans SET amountcleared = 0 - WHERE banktransid=" . $_POST["BankTrans_" . $Counter]; + } elseif (isset($_POST['Unclear_' . $Counter]) and $_POST['Unclear_' . $Counter]==True){ + $sql = 'UPDATE banktrans SET amountcleared = 0 + WHERE banktransid=' . $_POST['BankTrans_' . $Counter]; $ErrMsg = _('Could not unclear this bank transaction because'); $result = DB_query($sql,$db,$ErrMsg); } } /*Show the updated position with the same criteria as previously entered*/ - $_POST["ShowTransactions"] = True; + $_POST['ShowTransactions'] = True; } echo '<div class="page_help_text">' . _('Use this screen to match webERP Receipts and Payments to your Bank Statement. Check your bank statement and click the check-box when you find the matching transaction.') . '</div><br>'; -echo "<form action='". $_SERVER['PHP_SELF'] . "?" . SID . "' method=post>"; +echo '<form action="'. $_SERVER['PHP_SELF'] . '?' . SID . '" method=post>'; -echo "<input type=hidden Name=Type Value=$Type>"; +echo '<input type="hidden" name="Type" Value="' . $Type . '">'; echo '<table><tr>'; echo '<td align=left>' . _('Bank Account') . ':</td><td colspan=3><select tabindex="1" name="BankAccount">'; -$sql = "SELECT accountcode, bankaccountname FROM bankaccounts"; +$sql = 'SELECT accountcode, bankaccountname FROM bankaccounts'; $resultBankActs = DB_query($sql,$db); while ($myrow=DB_fetch_array($resultBankActs)){ - if (isset($_POST['BankAccount']) and $myrow["accountcode"]==$_POST['BankAccount']){ + if (isset($_POST['BankAccount']) and $myrow['accountcode']==$_POST['BankAccount']){ echo "<option selected Value='" . $myrow['accountcode'] . "'>" . $myrow['bankaccountname']; } else { echo "<option Value='" . $myrow['accountcode'] . "'>" . $myrow['bankaccountname']; @@ -98,7 +106,7 @@ echo '<tr><td colspan=3>' . _('Choose outstanding') . ' ' . $TypeName . ' ' . _('only or all') . ' ' . $TypeName . ' ' . _('in the date range') . ':</td> <td><select tabindex="4" name="Ostg_or_All">'; -if ($_POST["Ostg_or_All"]=='All'){ +if ($_POST['Ostg_or_All']=='All'){ echo '<option selected Value="All">' . _('Show all') . ' ' . $TypeName . ' ' . _('in the date range'); echo '<option Value="Ostdg">' . _('Show unmatched') . ' ' . $TypeName . ' ' . _('only'); } else { @@ -109,7 +117,7 @@ echo '<tr><td colspan=3>' . _('Choose to display only the first 20 matching') . ' ' . $TypeName . ' ' . _('or all') . ' ' . $TypeName . ' ' . _('meeting the criteria') . ':</td><td><select tabindex="5" name="First20_or_All">'; -if ($_POST["First20_or_All"]=='All'){ +if ($_POST['First20_or_All']=='All'){ echo '<option selected Value="All">' . _('Show all') . ' ' . $TypeName . ' ' . _('in the date range'); echo '<option Value="First20">' . _('Show only the first 20') . ' ' . $TypeName; } else { @@ -137,7 +145,7 @@ $_SESSION['DefaultDateFormat'],'error'); } -if ($InputError !=1 AND isset($_POST["BankAccount"]) AND $_POST["BankAccount"]!="" AND isset($_POST["ShowTransactions"])){ +if ($InputError !=1 AND isset($_POST['BankAccount']) AND $_POST['BankAccount']!='' AND isset($_POST['ShowTransactions'])){ $SQLBeforeDate = FormatDateForSQL($_POST['BeforeDate']); $SQLAfterDate = FormatDateForSQL($_POST['AfterDate']); @@ -145,61 +153,61 @@ if ($_POST["Ostg_or_All"]=='All'){ if ($Type=='Payments'){ $sql = "SELECT banktransid, - ref, - amountcleared, - transdate, - amount/exrate as amt, - banktranstype - FROM banktrans - WHERE amount <0 - AND transdate >= '". $SQLAfterDate . "' - AND transdate <= '" . $SQLBeforeDate . "' - AND bankact=" .$_POST["BankAccount"] . " - ORDER BY transdate"; + ref, + amountcleared, + transdate, + amount/exrate as amt, + banktranstype + FROM banktrans + WHERE amount <0 + AND transdate >= '". $SQLAfterDate . "' + AND transdate <= '" . $SQLBeforeDate . "' + AND bankact=" .$_POST["BankAccount"] . " + ORDER BY transdate"; } else { /* Type must == Receipts */ $sql = "SELECT banktransid, - ref, - amountcleared, - transdate, - amount/exrate as amt, - banktranstype - FROM banktrans - WHERE amount >0 - AND transdate >= '". $SQLAfterDate . "' - AND transdate <= '" . $SQLBeforeDate . "' - AND bankact=" .$_POST['BankAccount'] . " - ORDER BY transdate"; + ref, + amountcleared, + transdate, + amount/exrate as amt, + banktranstype + FROM banktrans + WHERE amount >0 + AND transdate >= '". $SQLAfterDate . "' + AND transdate <= '" . $SQLBeforeDate . "' + AND bankact=" .$_POST['BankAccount'] . " + ORDER BY transdate"; } } else { /*it must be only the outstanding bank trans required */ if ($Type=='Payments'){ $sql = "SELECT banktransid, - ref, - amountcleared, - transdate, - amount/exrate as amt, - banktranstype - FROM banktrans - WHERE amount <0 - AND transdate >= '". $SQLAfterDate . "' - AND transdate <= '" . $SQLBeforeDate . "' - AND bankact=" .$_POST["BankAccount"] . " - AND ABS(amountcleared - (amount / exrate)) > 0.009 - ORDER BY transdate"; + ref, + amountcleared, + transdate, + amount/exrate as amt, + banktranstype + FROM banktrans + WHERE amount <0 + AND transdate >= '". $SQLAfterDate . "' + AND transdate <= '" . $SQLBeforeDate . "' + AND bankact=" .$_POST["BankAccount"] . " + AND ABS(amountcleared - (amount / exrate)) > 0.009 + ORDER BY transdate"; } else { /* Type must == Receipts */ $sql = "SELECT banktransid, - ref, - amountcleared, - transdate, - amount/exrate as amt, - banktranstype - FROM banktrans - WHERE amount >0 - AND transdate >= '". $SQLAfterDate . "' - AND transdate <= '" . $SQLBeforeDate . "' - AND bankact=" .$_POST["BankAccount"] . " - AND ABS(amountcleared - (amount / exrate)) > 0.009 - ORDER BY transdate"; + ref, + amountcleared, + transdate, + amount/exrate as amt, + banktranstype + FROM banktrans + WHERE amount >0 + AND transdate >= '". $SQLAfterDate . "' + AND transdate <= '" . $SQLBeforeDate . "' + AND bankact=" .$_POST["BankAccount"] . " + AND ABS(amountcleared - (amount / exrate)) > 0.009 + ORDER BY transdate"; } } if ($_POST["First20_or_All"]!='All'){ Added: trunk/CounterSales.php =================================================================== --- trunk/CounterSales.php (rev 0) +++ trunk/CounterSales.php 2010-05-30 05:53:40 UTC (rev 3477) @@ -0,0 +1,2269 @@ +<?php +/* $Id: SelectOrderItems.php 3453 2010-05-06 06:39:52Z lindsayh $*/ + +include('includes/DefineCartClass.php'); +$PageSecurity = 1; +/* Session started in session.inc for password checking and authorisation level check +config.php is in turn included in session.inc*/ + +include('includes/session.inc'); + +$title = _('Counter Sales'); + +include('includes/header.inc'); +include('includes/GetPrice.inc'); +include('includes/SQL_CommonFunctions.inc'); +include('includes/GetSalesTransGLCodes.inc'); + +if (empty($_GET['identifier'])) { + $identifier=date('U'); +} else { + $identifier=$_GET['identifier']; +} +if (isset($_SESSION['Items'.$identifier])){ + //update the Items object variable with the data posted from the form + $_SESSION['Items'.$identifier]->CustRef = $_POST['CustRef']; + $_SESSION['Items'.$identifier]->Comments = $_POST['Comments']; + $_SESSION['Items'.$identifier]->DeliverTo = $_POST['DeliverTo']; + $_SESSION['Items'.$identifier]->PhoneNo = $_POST['PhoneNo']; + $_SESSION['Items'.$identifier]->Email = $_POST['Email']; +} + +if (isset($_POST['QuickEntry'])){ + unset($_POST['PartSearch']); +} + +if (isset($_POST['order_items'])){ + foreach ($_POST as $key => $value) { + if (strstr($key,'itm')) { + $NewItem_array[substr($key,3)] = trim($value); + } + } +} + +if (isset($_GET['NewItem'])){ + $NewItem = trim($_GET['NewItem']); +} + +if (isset($_GET['NewOrder'])){ + /*New order entry - clear any existing order details from the Items object and initiate a newy*/ + if (isset($_SESSION['Items'.$identifier])){ + unset ($_SESSION['Items'.$identifier]->LineItems); + $_SESSION['Items'.$identifier]->ItemsOrdered=0; + unset ($_SESSION['Items'.$identifier]); + } +} + + +if (!isset($_SESSION['Items'.$identifier])){ + /* It must be a new order being created $_SESSION['Items'.$identifier] would be set up from the order + modification code above if a modification to an existing order. Also $ExistingOrder would be + set to 1. The delivery check screen is where the details of the order are either updated or + inserted depending on the value of ExistingOrder */ + + $_SESSION['ExistingOrder'] = 0; + $_SESSION['Items'.$identifier] = new cart; + $_SESSION['PrintedPackingSlip'] = 0; /*Of course 'cos the order ain't even started !!*/ + /*Get the default customer-branch combo from the user's default location record */ + $result = DB_query("SELECT cashsalecustomer, + locationname, + taxprovinceid + FROM locations + WHERE loccode='" . $_SESSION['UserStockLocation'] . "'",$db); + if (DB_num_rows($result)==0) { + prnMsg(_('Your user account does not have a valid default inventory location set up. Please see the system administrator to modify your user account.'),'error'); + include('includes/footer.inc'); + exit; + } else { + $myrow = DB_fetch_array($result); //get the only row returned + $_SESSION['Items'.$identifier]->Branch = substr($myrow['cashsalecustomer'],strpos($myrow['cashsalecustomer'],' - ')+3); + + $_SESSION['Items'.$identifier]->DebtorNo = substr($myrow['cashsalecustomer'],0,strpos($myrow['cashsalecustomer'],' - ')); + $_SESSION['Items'.$identifier]->LocationName = $myrow['locationname']; + $_SESSION['Items'.$identifier]->Location = $_SESSION['UserStockLocation']; + $_SESSION['Items'.$identifier]->DispatchTaxProvince = $myrow['taxprovinceid']; + + // Now check to ensure this account exists and set defaults */ + $sql = "SELECT debtorsmaster.name, + holdreasons.dissallowinvoices, + debtorsmaster.salestype, + salestypes.sales_type, + debtorsmaster.currcode, + debtorsmaster.customerpoline, + paymentterms.terms + FROM debtorsmaster, + holdreasons, + salestypes, + paymentterms + WHERE debtorsmaster.salestype=salestypes.typeabbrev + AND debtorsmaster.holdreason=holdreasons.reasoncode + AND debtorsmaster.paymentterms=paymentterms.termsindicator + AND debtorsmaster.debtorno = '" . $_SESSION['Items'.$identifier]->DebtorNo . "'"; + + $ErrMsg = _('The details of the customer selected') . ': ' . $_SESSION['Items'.$identifier]->DebtorNo . ' ' . _('cannot be retrieved because'); + $DbgMsg = _('The SQL used to retrieve the customer details and failed was') . ':'; + $result =DB_query($sql,$db,$ErrMsg,$DbgMsg); + + $myrow = DB_fetch_row($result); + if ($myrow[1] != 1){ + if ($myrow[1]==2){ + prnMsg($myrow[0] . ' ' . _('Although this account is defined as the cash sale account for the location. The account is currently flagged as an account that needs to be watched. Please contact the credit control personnel to discuss'),'warn'); + } + + $_SESSION['RequireCustomerSelection']=0; + $_SESSION['Items'.$identifier]->CustomerName = $myrow[0]; + // the sales type is the price list to be used for this sale + $_SESSION['Items'.$identifier]->DefaultSalesType = $myrow[2]; + $_SESSION['Items'.$identifier]->SalesTypeName = $myrow[3]; + $_SESSION['Items'.$identifier]->DefaultCurrency = $myrow[4]; + $_SESSION['Items'.$identifier]->DefaultPOLine = $myrow[5]; + $_SESSION['Items'.$identifier]->PaymentTerms = $myrow[6]; + + /* now get the branch defaults from the customer branches table CustBranch. */ + + $sql = "SELECT custbranch.brname, + custbranch.defaultshipvia, + custbranch.deliverblind, + custbranch.specialinstructions, + custbranch.estdeliverydays, + custbranch.salesman, + custbranch.taxgroupid, + custbranch.defaultshipvia + FROM custbranch + WHERE custbranch.branchcode='" . $_SESSION['Items'.$identifier]->Branch . "' + AND custbranch.debtorno = '" . $_SESSION['Items'.$identifier]->DebtorNo . "'"; + + $ErrMsg = _('The customer branch record of the customer selected') . ': ' . $_SESSION['Items'.$identifier]->Branch . ' ' . _('cannot be retrieved because'); + $DbgMsg = _('SQL used to retrieve the branch details was') . ':'; + $result =DB_query($sql,$db,$ErrMsg,$DbgMsg); + + if (DB_num_rows($result)==0){ + + prnMsg(_('The branch details for branch code') . ': ' . $_SESSION['Items'.$identifier]->Branch . ' ' . _('against customer code') . ': ' . $_POST['Select'] . ' ' . _('could not be retrieved') . '. ' . _('Check the set up of the customer and branch'),'error'); + + if ($debug==1){ + echo '<br>' . _('The SQL that failed to get the branch details was') . ':<br>' . $sql; + } + include('includes/footer.inc'); + exit; + } + // add echo + echo '<br>'; + $myrow = DB_fetch_array($result); + + $_SESSION['Items'.$identifier]->DeliverTo = ''; + $_SESSION['Items'.$identifier]->DelAdd1 = $myrow['braddress1']; + $_SESSION['Items'.$identifier]->ShipVia = $myrow['defaultshipvia']; + $_SESSION['Items'.$identifier]->DeliverBlind = $myrow['deliverblind']; + $_SESSION['Items'.$identifier]->SpecialInstructions = $myrow['specialinstructions']; + $_SESSION['Items'.$identifier]->DeliveryDays = $myrow['estdeliverydays']; + $_SESSION['Items'.$identifier]->TaxGroup = $myrow['taxgroupid']; + + if ($_SESSION['Items'.$identifier]->SpecialInstructions) + prnMsg($_SESSION['Items'.$identifier]->SpecialInstructions,'warn'); + + if ($_SESSION['CheckCreditLimits'] > 0){ /*Check credit limits is 1 for warn and 2 for prohibit sales */ + $_SESSION['Items'.$identifier]->CreditAvailable = GetCreditAvailable($_SESSION['Items'.$identifier]->DebtorNo,$db); + + if ($_SESSION['CheckCreditLimits']==1 AND $_SESSION['Items'.$identifier]->CreditAvailable <=0){ + prnMsg(_('The') . ' ' . $myrow[0] . ' ' . _('account is currently at or over their credit limit'),'warn'); + } elseif ($_SESSION['CheckCreditLimits']==2 AND $_SESSION['Items'.$identifier]->CreditAvailable <=0){ + prnMsg(_('No more orders can be placed by') . ' ' . $myrow[0] . ' ' . _(' their account is currently at or over their credit limit'),'warn'); + include('includes/footer.inc'); + exit; + } + } + + } else { + prnMsg($myrow[0] . ' ' . _('Although the account is defined as the cash sale account for the location the account is currently on hold. Please contact the credit control personnel to discuss'),'warn'); + } + + } +} // end if its a new sale to be set up ... + +if (isset($_POST['CancelOrder'])) { + + + unset($_SESSION['Items'.$identifier]->LineItems); + $_SESSION['Items'.$identifier]->ItemsOrdered = 0; + unset($_SESSION['Items'.$identifier]); + $_SESSION['Items'.$identifier] = new cart; + + echo '<br><br>'; + prnMsg(_('This sale has been cancelled as requested'),'success'); + echo '<br><br><a href="' .$_SERVER['PHP_SELF'] . '">' . _('Start a new Counter Sale') . '</a>'; + include('includes/footer.inc'); + exit; + +} else { /*Not cancelling the order */ + + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/inventory.png" title="' . _('Counter Sales') . '" alt="">' . ' '; + + echo _('Counter Sale') . ' - ' . $_SESSION['Items'.$identifier]->LocationName . ' (' . _('all amounts in') . ' ' . $_SESSION['Items'.$identifier]->DefaultCurrency . ')'; + echo '</b></div>'; +} + +if (isset($_POST['Search']) or isset($_POST['Next']) or isset($_POST['Prev'])){ + + if ($_POST['Keywords']!=='' AND $_POST['StockCode']=='') { + $msg='</b><div class="page_help_text">' . _('Item description has been used in search') . '.</div>'; + } elseif ($_POST['StockCode']!=='' AND $_POST['Keywords']=='') { + $msg='</b><div class="page_help_text">' . _('Item Code has been used in search') . '.</div>'; + } elseif ($_POST['Keywords']=='' AND $_POST['StockCode']=='') { + $msg='</b><div class="page_help_text">' . _('Stock Category has been used in search') . '.</div>'; + } + if (isset($_POST['Keywords']) AND strlen($_POST['Keywords'])>0) { + //insert wildcard characters in spaces + $_POST['Keywords'] = strtoupper($_POST['Keywords']); + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; + + if ($_POST['StockCat']=='All'){ + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster, + stockcategory + WHERE stockmaster.categoryid=stockcategory.categoryid + AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.mbflag <>'G' + AND stockmaster.controlled <> 1 + AND stockmaster.description " . LIKE . " '$SearchString' + AND stockmaster.discontinued=0 + ORDER BY stockmaster.stockid"; + } else { + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster, stockcategory + WHERE stockmaster.categoryid=stockcategory.categoryid + AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.mbflag <>'G' + AND stockmaster.controlled <> 1 + AND stockmaster.discontinued=0 + AND stockmaster.description " . LIKE . " '" . $SearchString . "' + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + ORDER BY stockmaster.stockid"; + } + + } elseif (strlen($_POST['StockCode'])>0){ + + $_POST['StockCode'] = strtoupper($_POST['StockCode']); + $SearchString = '%' . $_POST['StockCode'] . '%'; + + if ($_POST['StockCat']=='All'){ + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster, stockcategory + WHERE stockmaster.categoryid=stockcategory.categoryid + AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.stockid " . LIKE . " '" . $SearchString . "' + AND stockmaster.mbflag <>'G' + AND stockmaster.controlled <> 1 + AND stockmaster.discontinued=0 + ORDER BY stockmaster.stockid"; + } else { + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster, stockcategory + WHERE stockmaster.categoryid=stockcategory.categoryid + AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.stockid " . LIKE . " '" . $SearchString . "' + AND stockmaster.mbflag <>'G' + AND stockmaster.controlled <> 1 + AND stockmaster.discontinued=0 + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + ORDER BY stockmaster.stockid"; + } + + } else { + if ($_POST['StockCat']=='All'){ + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster, stockcategory + WHERE stockmaster.categoryid=stockcategory.categoryid + AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.mbflag <>'G' + AND stockmaster.controlled <> 1 + AND stockmaster.discontinued=0 + ORDER BY stockmaster.stockid"; + } else { + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units + FROM stockmaster, stockcategory + WHERE stockmaster.categoryid=stockcategory.categoryid + AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.mbflag <>'G' + AND stockmaster.controlled <> 1 + AND stockmaster.discontinued=0 + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + ORDER BY stockmaster.stockid"; + } + } + + if (isset($_POST['Next'])) { + $Offset = $_POST['nextlist']; + } + if (isset($_POST['Prev'])) { + $Offset = $_POST['previous']; + } + if (!isset($Offset) or $Offset<0) { + $Offset=0; + } + $SQL = $SQL . ' LIMIT ' . $_SESSION['DefaultDisplayRecordsMax'].' OFFSET '.number_format($_SESSION['DefaultDisplayRecordsMax']*$Offset); + + $ErrMsg = _('There is a problem selecting the part records to display because'); + $DbgMsg = _('The SQL used to get the part selection was'); + $SearchResult = DB_query($SQL,$db,$ErrMsg, $DbgMsg); + + if (DB_num_rows($SearchResult)==0 ){ + prnMsg (_('There are no products available meeting the criteria specified'),'info'); + } + if (DB_num_rows($SearchResult)==1){ + $myrow=DB_fetch_array($SearchResult); + $NewItem = $myrow['stockid']; + DB_data_seek($SearchResult,0); + } + if (DB_num_rows($SearchResult)< $_SESSION['DisplayRecordsMax']){ + $Offset=0; + } + +} //end of if search + + +/* Always do the stuff below */ + +echo '<form action="' . $_SERVER['PHP_SELF'] . '?' . SID .'identifier='.$identifier . '"& name="SelectParts" method=post>'; + +//Get The exchange rate used for GPPercent calculations on adding or amending items +if ($_SESSION['Items'.$identifier]->DefaultCurrency != $_SESSION['CompanyRecord']['currencydefault']){ + $ExRateResult = DB_query("SELECT rate FROM currencies WHERE currabrev='" . $_SESSION['Items'.$identifier]->DefaultCurrency . "'",$db); + if (DB_num_rows($ExRateResult)>0){ + $ExRateRow = DB_fetch_row($ExRateResult); + $ExRate = $ExRateRow[0]; + } else { + $ExRate =1; + } +} else { + $ExRate = 1; +} + +/*Process Quick Entry */ +/* If enter is pressed on the quick entry screen, the default button may be Recalculate */ + if (isset($_POST['order_items']) + OR isset($_POST['QuickEntry']) + OR isset($_POST['Recalculate'])){ + + /* get the item details from the database and hold them in the cart object */ + + /*Discount can only be set later on -- after quick entry -- so default discount to 0 in the first place */ + $Discount = 0; + + $i=1; + while ($i<=$_SESSION['QuickEntries'] and isset($_POST['part_' . $i]) and $_POST['part_' . $i]!='') { + $QuickEntryCode = 'part_' . $i; + $QuickEntryQty = 'qty_' . $i; + $QuickEntryPOLine = 'poline_' . $i; + $QuickEntryItemDue = 'itemdue_' . $i; + + $i++; + + if (isset($_POST[$QuickEntryCode])) { + $NewItem = strtoupper($_POST[$QuickEntryCode]); + } + if (isset($_POST[$QuickEntryQty])) { + $NewItemQty = $_POST[$QuickEntryQty]; + } + if (isset($_POST[$QuickEntryItemDue])) { + $NewItemDue = $_POST[$QuickEntryItemDue]; + } else { + $NewItemDue = DateAdd (Date($_SESSION['DefaultDateFormat']),'d', $_SESSION['Items'.$identifier]->DeliveryDays); + } + if (isset($_POST[$QuickEntryPOLine])) { + $NewPOLine = $_POST[$QuickEntryPOLine]; + } else { + $NewPOLine = 0; + } + + if (!isset($NewItem)){ + unset($NewItem); + break; /* break out of the loop if nothing in the quick entry fields*/ + } + + if(!Is_Date($NewItemDue)) { + prnMsg(_('An invalid date entry was made for ') . ' ' . $NewItem . ' ' . _('The date entry') . ' ' . $NewItemDue . ' ' . _('must be in the format') . ' ' . $_SESSION['DefaultDateFormat'],'warn'); + //Attempt to default the due date to something sensible? + $NewItemDue = DateAdd (Date($_SESSION['DefaultDateFormat']),'d', $_SESSION['Items'.$identifier]->DeliveryDays); + } + /*Now figure out if the item is a kit set - the field MBFlag='K'*/ + $sql = "SELECT stockmaster.mbflag, stockmaster.controlled + FROM stockmaster + WHERE stockmaster.stockid='". $NewItem ."'"; + + $ErrMsg = _('Could not determine if the part being ordered was a kitset or not because'); + $DbgMsg = _('The sql that was used to determine if the part being ordered was a kitset or not was '); + $KitResult = DB_query($sql, $db,$ErrMsg,$DbgMsg); + + + if (DB_num_rows($KitResult)==0){ + prnMsg( _('The item code') . ' ' . $NewItem . ' ' . _('could not be retrieved from the database and has not been added to the order'),'warn'); + } elseif ($myrow=DB_fetch_array($KitResult)){ + if ($myrow['mbflag']=='K'){ /*It is a kit set item */ + $sql = "SELECT bom.component, + bom.quantity + FROM bom + WHERE bom.parent='" . $NewItem . "' + AND bom.effectiveto > '" . Date('Y-m-d') . "' + AND bom.effectiveafter < '" . Date('Y-m-d') . "'"; + + $ErrMsg = _('Could not retrieve kitset components from the database because') . ' '; + $KitResult = DB_query($sql,$db,$ErrMsg,$DbgMsg); + + $ParentQty = $NewItemQty; + while ($KitParts = DB_fetch_array($KitResult,$db)){ + $NewItem = $KitParts['component']; + $NewItemQty = $KitParts['quantity'] * $ParentQty; + $NewPOLine = 0; + include('includes/SelectOrderItems_IntoCart.inc'); + } + + } elseif ($myrow['mbflag']=='G'){ + prnMsg(_('Phantom assemblies cannot be sold, these items exist only as bills of materials used in other manufactured items. The following item has not been added to the order:') . ' ' . $NewItem, 'warn'); + } elseif ($myrow['controlled']==1){ + prnMsg(_('The system does not currently cater for counter sales of lot controlled or serialised items'),'warn'); + } else { /*Its not a kit set item*/ + include('includes/SelectOrderItems_IntoCart.inc'); + } + } + } + unset($NewItem); + } /* end of if quick entry */ + + + /*Now do non-quick entry delete/edits/adds */ + +if ((isset($_SESSION['Items'.$identifier])) OR isset($NewItem)){ + + if(isset($_GET['Delete'])){ + $_SESSION['Items'.$identifier]->remove_from_cart($_GET['Delete']); /*Don't do any DB updates*/ + } + + foreach ($_SESSION['Items'.$identifier]->LineItems as $OrderLine) { + + if (isset($_POST['Quantity_' . $OrderLine->LineNumber])){ + + $Quantity = $_POST['Quantity_' . $OrderLine->LineNumber]; + + if (ABS($OrderLine->Price - $_POST['Price_' . $OrderLine->LineNumber])>0.01){ + $Price = $_POST['Price_' . $OrderLine->LineNumber]; + $_POST['GPPercent_' . $OrderLine->LineNumber] = (($Price*(1-($_POST['Discount_' . $OrderLine->LineNumber]/100))) - $OrderLine->StandardCost*$ExRate)/($Price *(1-$_POST['Discount_' . $OrderLine->LineNumber])/100); + } elseif (ABS($OrderLine->GPPercent - $_POST['GPPercent_' . $OrderLine->LineNumber])>=0.001) { + //then do a recalculation of the price at this new GP Percentage + $Price = ($OrderLine->StandardCost*$ExRate)/(1 -(($_POST['GPPercent_' . $OrderLine->LineNumber] + $_POST['Discount_' . $OrderLine->LineNumber])/100)); + } else { + $Price = $_POST['Price_' . $OrderLine->LineNumber]; + } + $DiscountPercentage = $_POST['Discount_' . $OrderLine->LineNumber]; + if ($_SESSION['AllowOrderLineItemNarrative'] == 1) { + $Narrative = $_POST['Narrative_' . $OrderLine->LineNumber]; + } else { + $Narrative = ''; + } + + if (!isset($OrderLine->DiscountPercent)) { + $OrderLine->DiscountPercent = 0; + } + + if ($Quantity<0 OR $Price <0 OR $DiscountPercentage >100 OR $DiscountPercentage <0){ + prnMsg(_('The item could not be updated because you are attempting to set the quantity ordered to less than 0 or the price less than 0 or the discount more than 100% or less than 0%'),'warn'); + } elseif ($OrderLine->Quantity !=$Quantity + OR $OrderLine->Price != $Price + OR ABS($OrderLine->DiscountPercent -$DiscountPercentage/100) >0.001 + OR $OrderLine->Narrative != $Narrative + OR $OrderLine->ItemDue != $_POST['ItemDue_' . $OrderLine->LineNumber] + OR $OrderLine->POLine != $_POST['POLine_' . $OrderLine->LineNumber]) { + + $_SESSION['Items'.$identifier]->update_cart_item($OrderLine->LineNumber, + $Quantity, + $Price, + ($DiscountPercentage/100), + $Narrative, + 'Yes', /*Update DB */ + $_POST['ItemDue_' . $OrderLine->LineNumber], + $_POST['POLine_' . $OrderLine->LineNumber], + $_POST['GPPercent_' . $OrderLine->LineNumber]); + } + } //page not called from itself - POST variables not set + } +} + + +if (isset($NewItem)){ +/* get the item details from the database and hold them in the cart object make the quantity 1 by default then add it to the cart +Now figure out if the item is a kit set - the field MBFlag='K' +* controlled items and ghost/phantom items cannot be selected because the SQL to show items to select doesn't show 'em +* */ + $sql = "SELECT stockmaster.mbflag, + stockmaster.taxcatid + FROM stockmaster + WHERE stockmaster.stockid='". $NewItem ."'"; + + $ErrMsg = _('Could not determine if the part being ordered was a kitset or not because'); + + $KitResult = DB_query($sql, $db,$ErrMsg); + + $NewItemQty = 1; /*By Default */ + $Discount = 0; /*By default - can change later or discount category override */ + + if ($myrow=DB_fetch_array($KitResult)){ + if ($myrow['mbflag']=='K'){ /*It is a kit set item */ + $sql = "SELECT bom.component, + bom.quantity + FROM bom + WHERE bom.parent='" . $NewItem . "' + AND bom.effectiveto > '" . Date('Y-m-d') . "' + AND bom.effectiveafter < '" . Date('Y-m-d') . "'"; + + $ErrMsg = _('Could not retrieve kitset components from the database because'); + $KitResult = DB_query($sql,$db,$ErrMsg); + + $ParentQty = $NewItemQty; + while ($KitParts = DB_fetch_array($KitResult,$db)){ + $NewItem = $KitParts['component']; + $NewItemQty = $KitParts['quantity'] * $ParentQty; + $NewPOLine = 0; + $NewItemDue = date($_SESSION['DefaultDateFormat']); + include('includes/SelectOrderItems_IntoCart.inc'); + $_SESSION['Items'.$identifier]->GetTaxes(($_SESSION['Items'.$identifier]->LineCounter - 1)); + } + + } else { /*Its not a kit set item*/ + $NewItemDue = date($_SESSION['DefaultDateFormat']); + $NewPOLine = 0; + + include('includes/SelectOrderItems_IntoCart.inc'); + $_SESSION['Items'.$identifier]->GetTaxes(($_SESSION['Items'.$identifier]->LineCounter - 1)); + } + + } /* end of if its a new item */ + +} /*end of if its a new item */ + +if (isset($NewItem_array) && isset($_POST['order_items'])){ +/* get the item details from the database and hold them in the cart object make the quantity 1 by default then add it to the cart */ +/*Now figure out if the item is a kit set - the field MBFlag='K'*/ + foreach($NewItem_array as $NewItem => $NewItemQty) { + if($NewItemQty > 0) { + $sql = "SELECT stockmaster.mbflag + FROM stockmaster + WHERE stockmaster.stockid='". $NewItem ."'"; + + $ErrMsg = _('Could not determine if the part being ordered was a kitset or not because'); + + $KitResult = DB_query($sql, $db,$ErrMsg); + + //$NewItemQty = 1; /*By Default */ + $Discount = 0; /*By default - can change later or discount category override */ + + if ($myrow=DB_fetch_array($KitResult)){ + if ($myrow['mbflag']=='K'){ /*It is a kit set item */ + $sql = "SELECT bom.component, + bom.quantity + FROM bom + WHERE bom.parent='" . $NewItem . "' + AND bom.effectiveto > '" . Date('Y-m-d') . "' + AND bom.effectiveafter < '" . Date('Y-m-d') . "'"; + + $ErrMsg = _('Could not retrieve kitset components from the database because'); + $KitResult = DB_query($sql,$db,$ErrMsg); + + $ParentQty = $NewItemQty; + while ($KitParts = DB_fetch_array($KitResult,$db)){ + $NewItem = $KitParts['component']; + $NewItemQty = $KitParts['quantity'] * $ParentQty; + $NewItemDue = date($_SESSION['DefaultDateFormat']); + $NewPOLine = 0; + include('includes/SelectOrderItems_IntoCart.inc'); + $_SESSION['Items'.$identifier]->GetTaxes(($_SESSION['Items'.$identifier]->LineCounter - 1)); + } + + } else { /*Its not a kit set item*/ + $NewItemDue = date($_SESSION['DefaultDateFormat']); + $NewPOLine = 0; + include('includes/SelectOrderItems_IntoCart.inc'); + $_SESSION['Items'.$identifier]->GetTaxes(($_SESSION['Items'.$identifier]->LineCounter - 1)); + } + } /* end of if its a new item */ + } /*end of if its a new item */ + } +} + + +/* Run through each line of the order and work out the appropriate discount from the discount matrix */ +$DiscCatsDone = array(); +$counter =0; +foreach ($_SESSION['Items'.$identifier]->LineItems as $OrderLine) { + + if ($OrderLine->DiscCat !="" AND ! in_array($OrderLine->DiscCat,$DiscCatsDone)){ + $DiscCatsDone[$counter]=$OrderLine->DiscCat; + $QuantityOfDiscCat =0; + + foreach ($_SESSION['Items'.$identifier]->LineItems as $StkItems_2) { + /* add up total quantity of all lines of this DiscCat */ + if ($StkItems_2->DiscCat==$OrderLine->DiscCat){ + $QuantityOfDiscCat += $StkItems_2->Quantity; + } + } + $result = DB_query("SELECT MAX(discountrate) AS discount + FROM discountmatrix + WHERE salestype='" . $_SESSION['Items'.$identifier]->DefaultSalesType . "' + AND discountcategory ='" . $OrderLine->DiscCat . "' + AND quantitybreak <" . $QuantityOfDiscCat,$db); + $myrow = DB_fetch_row($result); + if ($myrow[0]!=0){ /* need to update the lines affected */ + foreach ($_SESSION['Items'.$identifier]->LineItems as $StkItems_2) { + /* add up total quantity of all lines of this DiscCat */ + if ($StkItems_2->DiscCat==$OrderLine->DiscCat AND $StkItems_2->DiscountPercent == 0){ + $_SESSION['Items'.$identifier]->LineItems[$StkItems_2->LineNumber]->DiscountPercent = $myrow[0]; + } + } + } + } +} /* end of discount matrix lookup code */ + +if (count($_SESSION['Items'.$identifier]->LineItems)>0){ /*only show order lines if there are any */ +/* +// ************************************************************************* +// T H I S W H E R E T H E S A L E I S D I S P L A Y E D +// ************************************************************************* +*/ + + echo '<br> + <table width="90%" cellpadding="2" colspan="7"> + <tr bgcolor=#800000>'; + echo '<th>' . _('Item Code') . '</th> + <th>' . _('Item Description') . '</th> + <th>' . _('Quantity') . '</th> + <th>' . _('QOH') . '</th> + <th>' . _('Unit') . '</th> + <th>' . _('Price') . '</th> + <th>' . _('Discount') . '</th> + <th>' . _('GP %') . '</th> + <th>' . _('Net') . '</th> + <th>' . _('Tax') . '</th> + <th>' . _('Total') . '<br>' . _('Incl Tax') . '</th> + </tr>'; + + $_SESSION['Items'.$identifier]->total = 0; + $_SESSION['Items'.$identifier]->totalVolume = 0; + $_SESSION['Items'.$identifier]->totalWeight = 0; + $TaxTotals = array(); + $TaxGLCodes = array(); + $TaxTotal =0; + $k =0; //row colour counter + foreach ($_SESSION['Items'.$identifier]->LineItems as $OrderLine) { + + $SubTotal = $OrderLine->Quantity * $OrderLine->Price * (1 - $OrderLine->DiscountPercent); + $DisplayDiscount = number_format(($OrderLine->DiscountPercent * 100),2); + $QtyOrdered = $OrderLine->Quantity; + $QtyRemain = $QtyOrdered - $OrderLine->QtyInv; + + if ($OrderLine->QOHatLoc < $OrderLine->Quantity AND ($OrderLine->MBflag=='B' OR $OrderLine->MBflag=='M')) { + /*There is a stock deficiency in the stock location selected */ + $RowStarter = '<tr bgcolor="#EEAABB">'; + } elseif ($k==1){ + $RowStarter = '<tr class="OddTableRows">'; + $k=0; + } else { + $RowStarter = '<tr class="EvenTableRows">'; + $k=1; + } + + echo $RowStarter; + echo '<input type="hidden" name="POLine_' . $OrderLine->LineNumber . '" value="">'; + + echo '<td><a target="_blank" href="' . $rootpath . '/StockStatus.php?' . SID .'identifier='.$identifier . '&StockID=' . $OrderLine->StockID . '&DebtorNo=' . $_SESSION['Items'.$identifier]->DebtorNo . '">' . $OrderLine->StockID . '</a></td> + <td>' . $OrderLine->ItemDescription . '</td>'; + + echo '<td><input class="number" tabindex=2 type=tect name="Quantity_' . $OrderLine->LineNumber . '" size=6 maxlength=6 value=' . $OrderLine->Quantity . '>'; + + echo '</td> + <td class="number">' . $OrderLine->QOHatLoc . '</td> + <td>' . $OrderLine->Units . '</td>'; + + echo '<td><input class="number" type=text name="Price_' . $OrderLine->LineNumber . '" size=16 maxlength=16 value=' . $OrderLine->Price . '></td> + <td><input class="number" type=text name="Discount_' . $OrderLine->LineNumber . '" size=5 maxlength=4 value=' . ($OrderLine->DiscountPercent * 100) . '></td> + <td><input class="number" type=text name="GPPercent_' . $OrderLine->LineNumber . '" size=3 maxlength=40 value=' . $OrderLine->GPPercent . '></td>'; + echo '</td><td class=number>' . number_format($SubTotal,2) . '</td>'; + $LineDueDate = $OrderLine->ItemDue; + if (!Is_Date($OrderLine->ItemDue)){ + $LineDueDate = DateAdd (Date($_SESSION['DefaultDateFormat']),'d', $_SESSION['Items'.$identifier]->DeliveryDays); + $_SESSION['Items'.$identifier]->LineItems[$OrderLine->LineNumber]->ItemDue= $LineDueDate; + } + $i=0; // initialise the number of taxes iterated through + $TaxLineTotal =0; //initialise tax total for the line + + foreach ($OrderLine->Taxes AS $Tax) { + if (empty($TaxTotals[$Tax->TaxAuthID])) { + $TaxTotals[$Tax->TaxAuthID]=0; + } + if ($Tax->TaxOnTax ==1){ + $TaxTotals[$Tax->TaxAuthID] += ($Tax->TaxRate * ($SubTotal + $TaxLineTotal)); + $TaxLineTotal += ($Tax->TaxRate * ($SubTotal + $TaxLineTotal)); + } else { + $TaxTotals[$Tax->TaxAuthID] += ($Tax->TaxRate * $SubTotal); + $TaxLineTotal += ($Tax->TaxRate * $SubTotal); + } + $TaxGLCodes[$Tax->TaxAuthID] = $Tax->TaxGLCode; + } + + $TaxTotal += $TaxLineTotal; + + echo '<td class="number">' . number_format($TaxLineTotal ,2) . '</td>'; + echo '<td class="number">' . number_format($SubTotal + $TaxLineTotal ,2) . '</td>'; + echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID .'&identifier='.$identifier . '&Delete=' . $OrderLine->LineNumber . '" onclick="return confirm(\'' . _('Are You Sure?') . '\');">' . _('Delete') . '</a></td></tr>'; + + if ($_SESSION['AllowOrderLineItemNarrative'] == 1){ + echo $RowStarter; + echo '<td valign="top" colspan="11">' . _('Narrative') . ':<textarea name="Narrative_' . $OrderLine->LineNumber . '" cols="100" rows="1">' . stripslashes(AddCarriageReturns($OrderLine->Narrative)) . '</textarea><br></td></tr>'; + } else { + echo '<input type=hidden name="Narrative" value="">'; + } + + $_SESSION['Items'.$identifier]->total = $_SESSION['Items'.$identifier]->total + $SubTotal; + $_SESSION['Items'.$identifier]->totalVolume = $_SESSION['Items'.$identifier]->totalVolume + $OrderLine->Quantity * $OrderLine->Volume; + $_SESSION['Items'.$identifier]->totalWeight = $_SESSION['Items'.$identifier]->totalWeight + $OrderLine->Quantity * $OrderLine->Weight; + + } /* end of loop around items */ + + echo '<tr class="EvenTableRows"><td colspan="8" class="number"><b>' . _('Total') . '</b></td> + <td class=number>' . number_format(($_SESSION['Items'.$identifier]->total),2) . '</td> + <td class=number>' . number_format($TaxTotal,2) . '</td> + <td class=number>' . number_format(($_SESSION['Items'.$identifier]->total+$TaxTotal),2) . '</td> + </tr> + </table>'; + echo '<table><tr><td>'; + //nested table + echo '<table><tr> + <td>'. _('Picked Up By') .':</td> + <td><input type=text size=25 maxlength=25 name="DeliverTo" value="' . $_SESSION['Items'.$identifier]->DeliverTo . '"></td> + </tr>'; + echo '<tr> + <td>'. _('Contact Phone Number') .':</td> + <td><input type=text size=25 maxlength=25 name="PhoneNo" value="' . $_SESSION['Items'.$identifier]->PhoneNo . '"></td> + </tr>'; + + echo '<tr><td>' . _('Contact Email') . ':</td><td><input type=text size=25 maxlength=30 name="Email" value="' . $_SESSION['Items'.$identifier]->Email . '"></td></tr>'; + + echo '<tr><td>'. _('Customer Reference') .':</td> + <td><input type=text size=25 maxlength=25 name="CustRef" value="' . $_SESSION['Items'.$identifier]->CustRef . '"></td> + </tr>'; + + echo '<tr> + <td>'. _('Comments') .':</td> + <td><textarea name=Comments cols=23 rows=5>' . $_SESSION['Items'.$identifier]->Comments .'</textarea></td> + </tr>'; + echo '</table>'; //end the sub table in the first column of master table + echo '</td><th valign="bottom">'; //for the master table + echo '<table class="selection">'; // a new nested table in the second column of master table + //now the payment stuff in this column + $PaymentMethodsResult = DB_query('SELECT paymentid, paymentname FROM paymentmethods',$db); + + echo '<tr><td>' . _('Payment Type') . ':</td><td><select name="PaymentMethod">'; + while ($PaymentMethodRow = DB_fetch_array($PaymentMethodsResult)){ + if ($_POST['PaymentMethod'] == $PaymentMethodRow['paymentid']){ + echo '<option selected value=' . $PaymentMethodRow['paymentid'] . '>' . $PaymentMethodRow['paymentname'] . '</option>'; + } else { + echo '<option value=' . $PaymentMethodRow['paymentid'] . '>' . $PaymentMethodRow['paymentname'] . '</option>'; + } + } + echo '</select></td></tr>'; + + $BankAccountsResult = DB_query('SELECT bankaccountname, accountcode FROM bankaccounts',$db); + + echo '<tr><td>' . _('Banked to') . ':</td><td><select name="BankAccount">'; + while ($BankAccountsRow = DB_fetch_array($BankAccountsResult)){ + if ($_POST['BankAccount'] == $BankAccountsRow['accountcode']){ + echo '<option selected value=' . $BankAccountsRow['accountcode'] . '>' . $BankAccountsRow['bankaccountname'] . '</option>'; + } else { + echo '<option value=' . $BankAccountsRow['accountcode'] . '>' . $BankAccountsRow['bankaccountname'] . '</option>'; + } + } + echo '</select></td></tr>'; + + if (!isset($_POST['AmountPaid'])){ + $_POST['AmountPaid'] =0; + } + echo '<tr><td>' . _('Amount Paid') . ':</td><td><input type="text" class="number" name="AmountPaid" maxlength="12" size="12" value=' . $_POST['AmountPaid'] . '></td></tr>'; + + echo '</table>'; //end the sub table in the second column of master table + echo '</td></tr></table>'; //end of column/row/master table + echo '<br><div class="centre"><input type=submit name="Recalculate" Value="' . _('Re-Calculate') . '"> + <input type=submit name="ProcessSale" value="' . _('Process The Sale') . '"></div><hr>'; +} # end of if lines + +/* ********************************** + * Invoice Processing Here + * ********************************** + * */ +if (isset($_POST['ProcessSale']) && $_POST['ProcessSale'] != ""){ + + $InputError = false; //always assume the best + //but check for the worst + if ($_SESSION['Items'.$identifier]->LineCounter == 0){ + prnMsg(_('There are no lines on this sale. Please enter lines to invoice first'),'error'); + $InputError = true; + } + if (ABS($_POST['AmountPaid'] -($_SESSION['Items'.$identifier]->total+$TaxTotal))>=0.01) { + prnMsg(_('The amount entered as payment does not equal the amount of the invoice. Please ensure the customer has paid the correct amount and re-enter'),'error'); + $InputError = true; + } + + 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 + FROM locstock + INNER JOIN stockmaster + ON stockmaster.stockid=locstock.stockid + WHERE stockmaster.stockid='" . $OrderLine->StockID . "' + AND locstock.loccode='" . $_SESSION['Items'.$identifier]->Location . "'"; + + $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,$db,$ErrMsg); + $CheckNegRow = DB_fetch_array($Result); + if ($CheckNegRow['mbflag']=='B' OR $CheckNegRow['mbflag']=='M'){ + if ($CheckNegRow['quantity'] < $OrderLine->Quantity){ + 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') { + + /*Now look for assembly components that would go negative */ + $SQL = "SELECT bom.component, + stockmaster.description, + locstock.quantity-(" . $OrderLine->Quantity . "*bom.quantity) AS qtyleft + FROM bom + INNER JOIN locstock + ON bom.component=locstock.stockid + INNER JOIN stockmaster + ON stockmaster.stockid=bom.component + WHERE bom.parent='" . $OrderLine->StockID . "' + AND locstock.loccode='" . $_SESSION['Items'.$identifier]->Location . "' + AND effectiveafter <'" . Date('Y-m-d') . "' + AND 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,$db,$ErrMsg); + 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 + } //loop around the components of an assembly item + }//end if its an assembly item - check component stock + + } //end of loop around items on the order for negative check + + if ($NegativesFound){ + prnMsg(_('The parameter to prohibit negative stock is set and invoicing this sale would result in negative stock. No futher processing can be performed. Alter the sale first changing quantities or deleting lines which do not have sufficient stock.'),'error'); + $InputError = true; + } + + }//end of testing for negative stocks + + + if ($InputError == false) { //all good so let's get on with the processing + + /* Now Get the area where the sale is to from the branches table */ + + $SQL = "SELECT area, + defaultshipvia + FROM custbranch + WHERE custbranch.debtorno ='". $_SESSION['Items'.$identifier]->DebtorNo . "' + AND custbranch.branchcode = '" . $_SESSION['Items'.$identifier]->Branch . "'"; + + $ErrMsg = _('We were unable to load the area where the sale is to from the custbranch table'); + $Result = DB_query($SQL,$db, $ErrMsg); + $myrow = DB_fetch_row($Result); + $Area = $myrow[0]; + $DefaultShipVia = $myrow[1]; + DB_free_result($Result); + + /*company record read in on login with info on GL Links and debtors GL account*/ + + 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'); + exit; + } + + // ************************************************************************* + // S T A R T O F I N V O I C E S Q L P R O C E S S I N G + // ************************************************************************* + + /*First add the order to the database - it only exists in the session currently! */ + $OrderNo = GetNextTransNo(30, $db); + + $HeaderSQL = "INSERT INTO salesorders ( orderno, + debtorno, + branchcode, + customerref, + comments, + orddate, + ordertype, + shipvia, + deliverto, + deladd1, + contactphone, + contactemail, + fromstkloc, + deliverydate, + confirmeddate, + deliverblind) + VALUES ( + " . $OrderNo . ", + '" . $_SESSION['Items'.$identifier]->DebtorNo . "', + '" . $_SESSION['Items'.$identifier]->Branch . "', + '". DB_escape_string($_SESSION['Items'.$identifier]->CustRef) ."', + '". DB_escape_string($_SESSION['Items'.$identifier]->Comments) ."', + '" . Date("Y-m-d H:i") . "', + '" . $_SESSION['Items'.$identifier]->DefaultSalesType . "', + " . $_SESSION['Items'.$identifier]->ShipVia . ", + '". DB_escape_string($_SESSION['Items'.$identifier]->DeliverTo) . "', + '" . _('Counter Sale') . "', + '" . $_SESSION['Items'.$identifier]->PhoneNo . "', + '" . $_SESSION['Items'.$identifier]->Email . "', + '" . $_SESSION['Items'.$identifier]->Location ."', + '" . Date('Y-m-d') . "', + '" . Date('Y-m-d') . "', + 0)"; + + $ErrMsg = _('The order cannot be added because'); + $InsertQryResult = DB_query($HeaderSQL,$db,$ErrMsg); + + $StartOf_LineItemsSQL = 'INSERT INTO salesorderdetails (orderlineno, + orderno, + stkcode, + unitprice, + quantity, + discountpercent, + narrative, + itemdue, + actualdispatchdate, + qtyinvoiced, + completed) + VALUES ('; + + $DbgMsg = _('Trouble inserting a line of a sales order. The SQL that failed was'); + foreach ($_SESSION['Items'.$identifier]->LineItems as $StockItem) { + + $LineItemsSQL = $StartOf_LineItemsSQL . + $StockItem->LineNumber . ', + ' . $OrderNo . ", + '" . $StockItem->StockID . "', + ". $StockItem->Price . ', + ' . $StockItem->Quantity . ', + ' . floatval($StockItem->DiscountPercent) . ", + '" . DB_escape_string($StockItem->Narrative) . "', + '" . Date('Y-m-d') . "', + '" . Date('Y-m-d') . "', + " . $StockItem->Quantity . ', + 1)'; + + $ErrMsg = _('Unable to add the sales order line'); + $Ins_LineItemResult = DB_query($LineItemsSQL,$db,$ErrMsg,$DbgMsg,true); + + /*Now check to see if the item is manufactured + * and AutoCreateWOs is on + * and it is a real order (not just a quotation)*/ + + if ($StockItem->MBflag=='M' + AND $_SESSION['AutoCreateWOs']==1){ //oh yeah its all on! + + //now get the data required to test to see if we need to make a new WO + $QOHResult = DB_query("SELECT SUM(quantity) FROM locstock WHERE stockid='" . $StockItem->StockID . "'",$db); + $QOHRow = DB_fetch_row($QOHResult); + $QOH = $QOHRow[0]; + + $SQL = "SELECT SUM(salesorderdetails.quantity - salesorderdetails.qtyinvoiced) AS qtydemand + FROM salesorderdetails + WHERE salesorderdetails.stkcode = '" . $StockItem->StockID . "' + AND salesorderdetails.completed = 0"; + $DemandResult = DB_query($SQL,$db); + $DemandRow = DB_fetch_row($DemandResult); + $QuantityDemand = $DemandRow[0]; + + $SQL = "SELECT SUM((salesorderdetails.quantity-salesorderdetails.qtyinvoiced)*bom.quantity) AS dem + FROM salesorderdetails, + bom, + stockmaster + WHERE salesorderdetails.stkcode=bom.parent + AND salesorderdetails.quantity-salesorderdetails.qtyinvoiced > 0 + AND bom.component='" . $StockItem->StockID . "' + AND stockmaster.stockid=bom.parent + AND stockmaster.mbflag='A' + AND salesorderdetails.completed=0"; + $AssemblyDemandResult = DB_query($SQL,$db); + $AssemblyDemandRow = DB_fetch_row($AssemblyDemandResult); + $QuantityAssemblyDemand = $AssemblyDemandRow[0]; + + $SQL = "SELECT SUM(purchorderdetails.quantityord - purchorderdetails.quantityrecd) as qtyonorder + FROM purchorderdetails, + purchorders + WHERE purchorderdetails.orderno = purchorders.orderno + AND purchorderdetails.itemcode = '" . $StockItem->StockID . "' + AND purchorderdetails.completed = 0"; + $PurchOrdersResult = DB_query($SQL,$db); + $PurchOrdersRow = DB_fetch_row($PurchOrdersResult); + $QuantityPurchOrders = $PurchOrdersRow[0]; + + $SQL = "SELECT SUM(woitems.qtyreqd - woitems.qtyrecd) as qtyonorder + FROM woitems INNER JOIN workorders + ON woitems.wo=workorders.wo + WHERE woitems.stockid = '" . $StockItem->StockID . "' + AND woitems.qtyreqd > woitems.qtyrecd + AND workorders.closed = 0"; + $WorkOrdersResult = DB_query($SQL,$db); + $WorkOrdersRow = DB_fetch_row($WorkOrdersResult); + $QuantityWorkOrders = $WorkOrdersRow[0]; + + //Now we have the data - do we need to make any more? + $ShortfallQuantity = $QOH-$QuantityDemand-$QuantityAssemblyDemand+$QuantityPurchOrders+$QuantityWorkOrders; + + if ($ShortfallQuantity < 0) { //then we need to make a work order + //How many should the work order be for?? + if ($ShortfallQuantity + $StockItem->EOQ < 0){ + $WOQuantity = -$ShortfallQuantity; + } else { + $WOQuantity = $StockItem->EOQ; + } + + $WONo = GetNextTransNo(40,$db); + $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['DefaultFactoryLocation'] . "', + '" . Date('Y-m-d') . "', + '" . Date('Y-m-d'). "')", + $db,$ErrMsg,$DbgMsg,true); + //Need to get the latest BOM to roll up cost + $CostResult = DB_query("SELECT SUM((materialcost+labourcost+overheadcost)*bom.quantity) AS cost + FROM stockmaster INNER JOIN bom + ON stockmaster.stockid=bom.component + WHERE bom.parent='" . $StockItem->StockID . "' + AND bom.loccode='" . $_SESSION['DefaultFactoryLocation'] . "'", + $db); + $CostRow = DB_fetch_row($CostResult); + if (is_null($CostRow[0]) OR $CostRow[0]==0){ + $Cost =0; + prnMsg(_('In automatically creating a work order for') . ' ' . $StockItem->StockID . ' ' . _('an item on this sales order, the cost of this item as accumulated from the sum of the component costs is nil. This could be because there is no bill of material set up ... you may wish to double check this'),'warn'); + } else { + $Cost = $CostRow[0]; + } + + // insert parent item info + $sql = "INSERT INTO woitems (wo, + stockid, + qtyreqd, + stdcost) + VALUES ( " . $WONo . ", + '" . $StockItem->StockID . "', + " . $WOQuantity . ", + " . $Cost . ")"; + $ErrMsg = _('The work order item could not be added'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); + + //Recursively insert real component requirements - see includes/SQL_CommonFunctions.in for function WoRealRequirements + WoRealRequirements($db, $WONo, $_SESSION['DefaultFactoryLocation'], $StockItem->StockID); + + $FactoryManagerEmail = _('A new work order has been created for') . + ":\n" . $StockItem->StockID . ' - ' . $StockItem->Descr . ' x ' . $WOQuantity . ' ' . $StockItem->UOM . + "\n" . _('These are for') . ' ' . $_SESSION['Items'.$identifier]->CustomerName . ' ' . _('there order ref') . ': ' . $_SESSION['Items'.$identifier]->CustRef . ' ' ._('our order number') . ': ' . $OrderNo; + + if ($StockItem->Serialised AND $StockItem->NextSerialNo>0){ + //then we must create the serial numbers for the new WO also + $FactoryManagerEmail .= "\n" . _('The following serial numbers ... [truncated message content] |
From: <dai...@us...> - 2010-06-04 11:10:59
|
Revision: 3478 http://web-erp.svn.sourceforge.net/web-erp/?rev=3478&view=rev Author: daintree Date: 2010-06-04 11:10:53 +0000 (Fri, 04 Jun 2010) Log Message: ----------- Otandeka changes to CounterSales.php and Locations.php to use explode to parse the debtorno-branchcode from the new field in locations. Also changed to remove spaces requirements in the format of entry of this field. Phil: added error checking to CounterSales.php and more useful message if defaultcashsales not entered for the users location Modified Paths: -------------- trunk/CounterSales.php trunk/Locations.php trunk/doc/Change.log.html trunk/sql/mysql/weberp-demo.sql Modified: trunk/CounterSales.php =================================================================== --- trunk/CounterSales.php 2010-05-30 05:53:40 UTC (rev 3477) +++ trunk/CounterSales.php 2010-06-04 11:10:53 UTC (rev 3478) @@ -65,21 +65,30 @@ $_SESSION['Items'.$identifier] = new cart; $_SESSION['PrintedPackingSlip'] = 0; /*Of course 'cos the order ain't even started !!*/ /*Get the default customer-branch combo from the user's default location record */ - $result = DB_query("SELECT cashsalecustomer, + $sql = "SELECT cashsalecustomer, locationname, taxprovinceid FROM locations - WHERE loccode='" . $_SESSION['UserStockLocation'] . "'",$db); + WHERE loccode='" . $_SESSION['UserStockLocation'] ."'"; + $result = DB_query($sql,$db); if (DB_num_rows($result)==0) { prnMsg(_('Your user account does not have a valid default inventory location set up. Please see the system administrator to modify your user account.'),'error'); include('includes/footer.inc'); exit; } else { $myrow = DB_fetch_array($result); //get the only row returned - $_SESSION['Items'.$identifier]->Branch = substr($myrow['cashsalecustomer'],strpos($myrow['cashsalecustomer'],' - ')+3); - - $_SESSION['Items'.$identifier]->DebtorNo = substr($myrow['cashsalecustomer'],0,strpos($myrow['cashsalecustomer'],' - ')); - $_SESSION['Items'.$identifier]->LocationName = $myrow['locationname']; + + if ($myrow['cashsalecustomer']==''){ + prnMsg(_('To use this script it is first necessary to define a cash sales customer for the location that is your default location. The default cash sale customer is defined under set up ->Inventory Locations Maintenance. The customer should be entered using the customer code a hypen then the branch code of the customer to use.'),'error'); + include('includes/footer.inc'); + exit; + } + + $CashSaleCustomer = explode('-',$myrow['cashsalecustomer']); + + $_SESSION['Items'.$identifier]->Branch = $CashSaleCustomer[0]; + $_SESSION['Items'.$identifier]->DebtorNo = $CashSaleCustomer[1]; + $_SESSION['Items'.$identifier]->LocationName = $myrow['locationname']; $_SESSION['Items'.$identifier]->Location = $_SESSION['UserStockLocation']; $_SESSION['Items'.$identifier]->DispatchTaxProvince = $myrow['taxprovinceid']; @@ -102,6 +111,7 @@ $ErrMsg = _('The details of the customer selected') . ': ' . $_SESSION['Items'.$identifier]->DebtorNo . ' ' . _('cannot be retrieved because'); $DbgMsg = _('The SQL used to retrieve the customer details and failed was') . ':'; + // echo $sql; $result =DB_query($sql,$db,$ErrMsg,$DbgMsg); $myrow = DB_fetch_row($result); @@ -2251,8 +2261,8 @@ /* Do not display colum unless customer requires po line number by sales order line*/ echo '<td><input type="text" name="part_' . $i . '" size=21 maxlength=20></td> <td><input type="text" name="qty_' . $i . '" size=6 maxlength=6></td> - <td><input type="hidden" class="date" name="itemdue_' . $i . '" - value="' . $DefaultDeliveryDate . '"></td></tr>'; + <input type="hidden" class="date" name="itemdue_' . $i . '" + value="' . $DefaultDeliveryDate . '"></tr>'; } echo '<script type="text/javascript">if (document.SelectParts) {defaultControl(document.SelectParts.part_1);}</script>'; @@ -2266,4 +2276,4 @@ } echo '</form>'; include('includes/footer.inc'); -?> \ No newline at end of file +?> Modified: trunk/Locations.php =================================================================== --- trunk/Locations.php 2010-05-30 05:53:40 UTC (rev 3477) +++ trunk/Locations.php 2010-06-04 11:10:53 UTC (rev 3478) @@ -31,15 +31,20 @@ prnMsg( _('The location code may not be empty'), 'error'); } if ($_POST['CashSaleCustomer']!=''){ - if (!strstr($_POST['CashSaleCustomer'],' - ')){ + if (!strstr($_POST['CashSaleCustomer'],'-')){ $InputError =1; - prnMsg(_('The cash sale customer account must be a valid customer account separated by " - " then the branch code of the customer entered'), 'error'); + prnMsg(_('The cash sale customers '.$_POST['CashSaleCustomer'].' account must be a valid customer account separated by " - " then the branch code of the customer entered'), 'error'); } else { - $Branch = substr($_POST['CashSaleCustomer'],strpos($_POST['CashSaleCustomer'],' - ')+3); - $DebtorNo = substr($_POST['CashSaleCustomer'],0,strpos($_POST['CashSaleCustomer'],' - ')); + // $Branch = substr($_POST['CashSaleCustomer'],strpos($_POST['CashSaleCustomer'],' - ')+3); + // $DebtorNo = substr($_POST['CashSaleCustomer'],0,strpos($_POST['CashSaleCustomer'],' - ')); + $arr = explode('-',$_POST['CashSaleCustomer']); + $DebtorNo = $arr[0]; + $Branch = $arr[1]; + $sql = "SELECT * FROM custbranch WHERE debtorno='" . $DebtorNo . "' - AND branchcode='" . $Branch . "'"; - + AND branchcode='" . $Branch . "'"; + + // echo $sql; $result = DB_query($sql,$db); if (DB_num_rows($result)==0){ $InputError = 1; @@ -556,4 +561,4 @@ <?php } //end if record deleted no point displaying form to add record include('includes/footer.inc'); -?> \ No newline at end of file +?> Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-05-30 05:53:40 UTC (rev 3477) +++ trunk/doc/Change.log.html 2010-06-04 11:10:53 UTC (rev 3478) @@ -1,5 +1,8 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>03/06/10 Phil: Added a bit of error trapping to ensure customer/branch set up when going into CounterSales.php +<p>03/06/10 Otandeka: Locations.php used explode function rather than substr function to split the cashsalecustomer to get Branch and Debtorno codes - also changed format to just a hypen between debtorno and branchcode</p> +<p>03/06/10 Otandeka: CounterSales php changed to use explode to get branch and debtorno from cashsalecustomer - and changed format to debtorno-branchcode and rather than debtorno - branchcode (spaces removed)</p> <p>31/5/10 Phil: BankMatching script took out double quotes reformated indenting - a hard one to read - my bad!</p> <p>31/5/10 Phil: New script CounterSales.php to allow entry of sale and payment over the counter as a half way step to POS - the customer account is defaulted based on the users default stock location. The locations table now has a default cash sales account - see below</p> <p>28/5/10 Phil: New field in locations table to allow a default cash sales account to be setup by location -modifications to Locations.php to allow it to be entered and error-trapping for debtor - branch format required for specification. This will be used in a new CounterSales.php script I am working on</p> Modified: trunk/sql/mysql/weberp-demo.sql =================================================================== --- trunk/sql/mysql/weberp-demo.sql 2010-05-30 05:53:40 UTC (rev 3477) +++ trunk/sql/mysql/weberp-demo.sql 2010-06-04 11:10:53 UTC (rev 3478) @@ -1,5 +1,5 @@ -CREATE DATABASE IF NOT EXISTS weberpdemo DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; -USE weberpdemo; +CREATE DATABASE IF NOT EXISTS weberp DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; +USE weberp; SET FOREIGN_KEY_CHECKS=0; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-06-05 12:55:01
|
Revision: 3480 http://web-erp.svn.sourceforge.net/web-erp/?rev=3480&view=rev Author: tim_schofield Date: 2010-06-05 12:54:55 +0000 (Sat, 05 Jun 2010) Log Message: ----------- ChenJohn: SalesTypes.php - upgrade3.11.1-3.12.sql - to allow sales type description up to 40 char length Modified Paths: -------------- trunk/SalesTypes.php trunk/doc/Change.log.html trunk/sql/mysql/upgrade3.11.1-3.12.sql Modified: trunk/SalesTypes.php =================================================================== --- trunk/SalesTypes.php 2010-06-04 11:13:08 UTC (rev 3479) +++ trunk/SalesTypes.php 2010-06-05 12:54:55 UTC (rev 3480) @@ -40,9 +40,9 @@ prnMsg('<br>' . _('The sales type (price list) code cannot be an empty string or spaces'),'error'); $Errors[$i] = 'SalesType'; $i++; - } elseif (strlen($_POST['Sales_Type']) >20) { + } elseif (strlen($_POST['Sales_Type']) >40) { $InputError = 1; - echo prnMsg(_('The sales type (price list) description must be twenty characters or less long'),'error'); + echo prnMsg(_('The sales type (price list) description must be forty characters or less long'),'error'); $Errors[$i] = 'SalesType'; $i++; } elseif ($_POST['TypeAbbrev']=='AN'){ Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-06-04 11:13:08 UTC (rev 3479) +++ trunk/doc/Change.log.html 2010-06-05 12:54:55 UTC (rev 3480) @@ -1,10 +1,11 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> -<p>03/06/10 Phil: Added a bit of error trapping to ensure customer/branch set up when going into CounterSales.php +<p>03/06/10 Phil: Added a bit of error trapping to ensure customer/branch set up when going into CounterSales.php</p> <p>03/06/10 Otandeka: Locations.php used explode function rather than substr function to split the cashsalecustomer to get Branch and Debtorno codes - also changed format to just a hypen between debtorno and branchcode</p> -<p>03/06/10 Otandeka: CounterSales php changed to use explode to get branch and debtorno from cashsalecustomer - and changed format to debtorno-branchcode and rather than debtorno - branchcode (spaces removed)</p> +<p>03/06/10 Otandeka: CounterSales php changed to use explode to get branch and debtorno from cashsalecustomer - and changed format to debtorno-branchcode and rather than debtorno - branchcode (spaces removed)</p> <p>31/5/10 Phil: BankMatching script took out double quotes reformated indenting - a hard one to read - my bad!</p> <p>31/5/10 Phil: New script CounterSales.php to allow entry of sale and payment over the counter as a half way step to POS - the customer account is defaulted based on the users default stock location. The locations table now has a default cash sales account - see below</p> +<P>29/05/10 ChenJohn: SalesTypes.php - upgrade3.11.1-3.12.sql - to allow sales type description up to 40 char length</p> <p>28/5/10 Phil: New field in locations table to allow a default cash sales account to be setup by location -modifications to Locations.php to allow it to be entered and error-trapping for debtor - branch format required for specification. This will be used in a new CounterSales.php script I am working on</p> <P>27/05/10 Tim: PurchData.php - Show the uom name, not the number</p> <P>27/05/10 Tim: CustomerAllocations.php - Show the right balance, and the allocate link where needed</p> @@ -21,8 +22,8 @@ <p>16/05/10 Phil: reworked PricesByCost.php this was bit of a dodgy script - well I found it hard to follow - in the words of Frank Sinatra - I did it my way! Also built in effectivity dates to display and ensure correct prices updated now the primary key of prices is changed.</p> <p>16/05/10 Phil: Wrote up the manual so that the logic of pricing with effective dates is explained</p> <p>15/05/10 Phil: Used Lindsay/Ngaraj's nice email address checking function to replace the existing function in MiscFunctions.php and includes MiscFunctions.php in install/save.php to avoid duplication of the function</p> -<p>15/05/10 Phil: $debug variable in UserLogin.php was only set on first login - not subsequent page calls (its not a session variable) - moved it back into session.inc so that full info about bugs is available to sysadmins -<p>15/05/10 Phil: GetPrices.inc Prices.php and Prices_Customer.php - modified to allow default prices - with no end dates - reducing requirement to administer - also updated Prices section of the manual +<p>15/05/10 Phil: $debug variable in UserLogin.php was only set on first login - not subsequent page calls (its not a session variable) - moved it back into session.inc so that full info about bugs is available to sysadmins</p> +<p>15/05/10 Phil: GetPrices.inc Prices.php and Prices_Customer.php - modified to allow default prices - with no end dates - reducing requirement to administer - also updated Prices section of the manual</p> <p>11/05/10 Tim: Exit MRP scripts gracefully if no MRP calculation has been done.</p> <p>08/05/10 Lindsay: API was broken after adding a test for global variable $DatabaseName in ConnectDB_mysql* for this variable being set and using it as DB name if so. The variable of that name in the api_php.php has been changed to $api_DatabaseName.</p> <p>08/05/10 Phil: GetPrices.inc now uses the new price startdate and enddate to return the price which falls within the date range base on the current date. Changes to Prices.php and Prices_Customer.php to allow entry of effective from and effective to dates and updating/deleting of prices with appropriate error trapping and rescheduling of enddates where start and end dates would otherwise overlap.</p> Modified: trunk/sql/mysql/upgrade3.11.1-3.12.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-06-04 11:13:08 UTC (rev 3479) +++ trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-06-05 12:54:55 UTC (rev 3480) @@ -162,4 +162,10 @@ ALTER TABLE stockcheckfreeze ADD COLUMN stockcheckdate date NOT NULL; ALTER TABLE suppliers add (email varchar(55),fax varchar(25), telephone varchar(25)); + +ALTER TABLE `www_users` add `supplierid` varchar(10) NOT NULL DEFAULT '' AFTER `customerid`; +INSERT INTO `securityroles` VALUES (9,'Supplier Log On Only'); + ALTER TABLE locations add cashsalecustomer VARCHAR(21) NOT NULL DEFAULT ''; + +ALTER TABLE `salestypes` CHANGE COLUMN `sales_type` `sales_type` VARCHAR(40) NOT NULL DEFAULT ''; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-06-06 08:33:38
|
Revision: 3481 http://web-erp.svn.sourceforge.net/web-erp/?rev=3481&view=rev Author: tim_schofield Date: 2010-06-06 08:33:32 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Zhiguo Yuan: WorkOrderReceive.php - Change to make rollup costs change when more labour or overheadcosts change Modified Paths: -------------- trunk/WorkOrderReceive.php trunk/doc/Change.log.html Modified: trunk/WorkOrderReceive.php =================================================================== --- trunk/WorkOrderReceive.php 2010-06-05 12:54:55 UTC (rev 3480) +++ trunk/WorkOrderReceive.php 2010-06-06 08:33:32 UTC (rev 3481) @@ -191,7 +191,9 @@ //Need to check this against the current standard cost and do a cost update if necessary $sql = "SELECT materialcost+labourcost+overheadcost AS cost, - sum(quantity) AS totalqoh + sum(quantity) AS totalqoh, + labourcost, + overheadcost FROM stockmaster INNER JOIN locstock ON stockmaster.stockid=locstock.stockid WHERE stockmaster.stockid='" . $_POST['StockID'] . "' @@ -202,14 +204,14 @@ $ItemResult = DB_query($sql,$db); $ItemCostRow = DB_fetch_array($ItemResult); - if ($Cost != $ItemCostRow['cost']){ //the cost roll-up cost <> standard cost + if (($Cost + $ItemCostRow['labourcost'] + $ItemCostRow['overheadcost']) != $ItemCostRow['cost']){ //the cost roll-up cost <> standard cost if ($_SESSION['CompanyRecord']['gllink_stock']==1 AND $ItemCostRow['totalqoh']!=0){ $CostUpdateNo = GetNextTransNo(35, $db); $PeriodNo = GetPeriod(Date($_SESSION['DefaultDateFormat']), $db); - $ValueOfChange = $ItemCostRow['totalqoh'] * ($Cost - $ItemCostRow['cost']); + $ValueOfChange = $ItemCostRow['totalqoh'] * (($Cost + $ItemCostRow['labourcost'] + $ItemCostRow['overheadcost']) - $ItemCostRow['cost']); $SQL = "INSERT INTO gltrans (type, typeno, @@ -252,8 +254,8 @@ $SQL = "UPDATE stockmaster SET materialcost=" . $Cost . ", - labourcost=0, - overheadcost=0, + labourcost=" . $ItemCostRow['labourcost'] . ", + overheadcost=" . $ItemCostRow['overheadcost'] . ", lastcost=" . $ItemCostRow['cost'] . " WHERE stockid='" . $_POST['StockID'] . "'"; Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-06-05 12:54:55 UTC (rev 3480) +++ trunk/doc/Change.log.html 2010-06-06 08:33:32 UTC (rev 3481) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>06/06/10 Zhiguo Yuan: WorkOrderReceive.php - Change to make rollup costs change when more labour or overheadcosts change</p> <p>03/06/10 Phil: Added a bit of error trapping to ensure customer/branch set up when going into CounterSales.php</p> <p>03/06/10 Otandeka: Locations.php used explode function rather than substr function to split the cashsalecustomer to get Branch and Debtorno codes - also changed format to just a hypen between debtorno and branchcode</p> <p>03/06/10 Otandeka: CounterSales php changed to use explode to get branch and debtorno from cashsalecustomer - and changed format to debtorno-branchcode and rather than debtorno - branchcode (spaces removed)</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-06-07 01:06:20
|
Revision: 3483 http://web-erp.svn.sourceforge.net/web-erp/?rev=3483&view=rev Author: daintree Date: 2010-06-07 01:06:13 +0000 (Mon, 07 Jun 2010) Log Message: ----------- Start of work on contracts costing Modified Paths: -------------- trunk/PO_Header.php trunk/sql/mysql/upgrade3.11.1-3.12.sql trunk/sql/mysql/weberp-demo.sql trunk/sql/mysql/weberp-new.sql Added Paths: ----------- trunk/Contracts.php trunk/includes/DefineContractClass.php Added: trunk/Contracts.php =================================================================== --- trunk/Contracts.php (rev 0) +++ trunk/Contracts.php 2010-06-07 01:06:13 UTC (rev 3483) @@ -0,0 +1,1092 @@ +<?php + +/* $Id: Contract_Header.php 3325 2010-01-25 16:50:32Z tim_schofield $ */ + +$PageSecurity = 4; +include('includes/DefineContractClass.php'); +include('includes/session.inc'); + +if (isset($_GET['ModifyContractNo'])) { + $title = _('Modify Contract') . ' ' . $_GET['ModifyContractNo']; +} else { + $title = _('Contract Entry'); +} + +if (isset($_GET['CustomerID'])) { + $_ContractST['Select']=$_GET['CustomerID']; +} + +include('includes/header.inc'); +include('includes/SQL_CommonFunctions.inc'); + +/*If the page is called is called without an identifier being set then + * it must be either a new contract, or the start of a modification of an + * existing contract, and so we must create a new identifier. + * + * The identifier only needs to be unique for this php session, so a + * unix timestamp will be sufficient. + */ + +if (empty($_GET['identifier'])) { + $identifier=date('U'); +} else { + $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])){ + unset($_SESSION['Contract'.$identifier]); + $_SESSION['ExistingContract']=0; +} + +if (isset($_ContractST['Select']) and empty($_ContractST['SupplierContact'])) { + $sql = "SELECT contact + FROM suppliercontacts + WHERE CustomerID='". $_ContractST['Select'] ."'"; + + $SuppCoResult = DB_query($sql,$db); + if (DB_num_rows($SuppCoResult)>0) { + $myrow = DB_fetch_row($SuppCoResult); + $_ContractST['SupplierContact'] = $myrow[0]; + } else { + $_ContractST['SupplierContact']=''; + } +} + + +if (isset($_GET['NewContract']) AND isset($_GET['SelectedCustomer'])) { + /* + * initialize a new contract + */ + $_SESSION['ExistingContract']=0; + unset($_SESSION['Contract'.$identifier]); + /* initialize new class object */ + $_SESSION['Contract'.$identifier] = new Contract; + /** + * and fill it with essential data + */ + $_SESSION['Contract'.$identifier]->AllowPrintContract = 1; /* Of course cos the + * order aint even started !!*/ + $_SESSION['Contract'.$identifier]->GLLink = $_SESSION['CompanyRecord']['gllink_stock']; + /* set the CustomerID we got */ + $_SESSION['Contract'.$identifier]->CustomerID = $_GET['SelectedCustomer']; + /**/ + $_SESSION['RequireSupplierSelection'] = 0; + /**/ + $_ContractST['Select'] = $_GET['SelectedCustomer']; + + /** + * the item (its item code) that should be purchased + */ + $purch_item = $_GET['StockID']; + +} + +if (isset($_ContractST['EnterLines'])){ +/*User hit the button to enter line items - + * ensure session variables updated then meta refresh to Contract_Items.php*/ + + $_SESSION['Contract'.$identifier]->Location=$_ContractST['StkLocation']; + $_SESSION['Contract'.$identifier]->SupplierContact=$_ContractST['SupplierContact']; + $_SESSION['Contract'.$identifier]->DelAdd1 = $_ContractST['DelAdd1']; + $_SESSION['Contract'.$identifier]->DelAdd2 = $_ContractST['DelAdd2']; + $_SESSION['Contract'.$identifier]->DelAdd3 = $_ContractST['DelAdd3']; + $_SESSION['Contract'.$identifier]->DelAdd4 = $_ContractST['DelAdd4']; + $_SESSION['Contract'.$identifier]->DelAdd5 = $_ContractST['DelAdd5']; + $_SESSION['Contract'.$identifier]->DelAdd6 = $_ContractST['DelAdd6']; + $_SESSION['Contract'.$identifier]->suppDelAdd1 = $_ContractST['suppDelAdd1']; + $_SESSION['Contract'.$identifier]->suppDelAdd2 = $_ContractST['suppDelAdd2']; + $_SESSION['Contract'.$identifier]->suppDelAdd3 = $_ContractST['suppDelAdd3']; + $_SESSION['Contract'.$identifier]->suppDelAdd4 = $_ContractST['suppDelAdd4']; + $_SESSION['Contract'.$identifier]->suppDelAdd5 = $_ContractST['suppDelAdd5']; + $_SESSION['Contract'.$identifier]->supptel= $_ContractST['supptel']; + $_SESSION['Contract'.$identifier]->Initiator = $_ContractST['Initiator']; + $_SESSION['Contract'.$identifier]->RequisitionNo = $_ContractST['Requisition']; + $_SESSION['Contract'.$identifier]->version = $_ContractST['version']; + $_SESSION['Contract'.$identifier]->deliverydate = $_ContractST['deliverydate']; + $_SESSION['Contract'.$identifier]->revised = $_ContractST['revised']; + $_SESSION['Contract'.$identifier]->ExRate = $_ContractST['ExRate']; + $_SESSION['Contract'.$identifier]->Comments = $_ContractST['Comments']; + $_SESSION['Contract'.$identifier]->deliveryby = $_ContractST['deliveryby']; + $_SESSION['Contract'.$identifier]->StatusMessage = $_ContractST['StatComments']; + $_SESSION['Contract'.$identifier]->paymentterms = $_ContractST['paymentterms']; + $_SESSION['Contract'.$identifier]->contact = $_ContractST['Contact']; + $_SESSION['Contract'.$identifier]->tel = $_ContractST['tel']; + $_SESSION['Contract'.$identifier]->Contractrt = $_ContractST['Contractrt']; + + if (isset($_ContractST['RePrint']) and $_ContractST['RePrint']==1){ + + $_SESSION['Contract'.$identifier]->AllowPrintContract=1; + + $sql = 'UPDATE purchorders + SET purchorders.allowprint=1 + WHERE purchorders.orderno=' . $_SESSION['Contract'.$identifier]->OrderNo; + + $ErrMsg = _('An error occurred updating the Contract to allow reprints') . '. ' . _('The error says'); + $updateResult = DB_query($sql,$db,$ErrMsg); + + } else { + $_ContractST['RePrint'] = 0; + } + + echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . '/Contract_Items.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 supContractrt META Refresh') . ') ' . + "<a href='$rootpath/Contract_Items.php?" . SID. 'identifier='.$identifier . "'>" . _('click here') . '</a> ' . _('to continue'),'info'); + include('includes/footer.inc'); + exit; +} /* end of if isset _ContractST'EnterLines' */ + +echo '<a href="'. $rootpath . '/Contract_SelectOSPurchOrder.php?' . SID . "identifier=".$identifier.'">'. _('Back to Contracts'). '</a><br>'; + +/*The page can be called with ModifyContractNo=x where x is a purchase + * order number. The page then looks up the details of order x and allows + * these details to be modified */ + +if (isset($_GET['ModifyContractNo'])){ + include ('includes/Contract_ReadInOrder.inc'); +} + +if (isset($_ContractST['CancelOrder']) AND $_ContractST['CancelOrder']!='') { +/*The cancel button on the header screen - to delete order */ + $OK_to_delete = 1; //assume this in the first instance + + if(!isset($_SESSION['ExistingContract']) OR $_SESSION['ExistingContract']!=0) { + /* need to check that not already dispatched or invoiced + * by the supplier */ + + if($_SESSION['Contract'.$identifier]->Any_Already_Received()==1){ + $OK_to_delete =0; + prnMsg( _('This order cannot be cancelled because some of it has already been received') . '. ' . + _('The line item quantities may be modified to quantities more than already received') . '. ' . + _('Prices cannot be altered for lines that have already been received') .' '. + _('and quantities cannot be reduced below the quantity already received'),'warn'); + } + + } + + if ($OK_to_delete==1){ + $emailsql='SELECT email FROM www_users WHERE userid="'.$_SESSION['Contract'.$identifier]->Initiator.'"'; + $emailresult=DB_query($emailsql, $db); + $emailrow=DB_fetch_array($emailresult); + $StatusComment=date($_SESSION['DefaultDateFormat']). + ' - Order Cancelled by <a href="mailto:'.$emailrow['email'].'">'.$_SESSION['UserID'].'</a><br>'.$_ContractST['statcommentscomplete']; + unset($_SESSION['Contract'.$identifier]->LineItems); + unset($_SESSION['Contract'.$identifier]); + $_SESSION['Contract'.$identifier] = new PurchOrder; + $_SESSION['RequireSupplierSelection'] = 1; + + if($_SESSION['ExistingContract']!=0){ + + $sql = 'UPDATE purchorderdetails + SET completed=1 + WHERE purchorderdetails.orderno =' . $_SESSION['ExistingContract']; + $ErrMsg = _('The order detail lines could not be deleted because'); + $DelResult=DB_query($sql,$db,$ErrMsg); + + $sql="UPDATE purchorders + SET status='".PurchOrder::STATUS_CANCELLED."', + stat_comment='".$StatusComment."' + WHERE orderno=".$_SESSION['ExistingContract']; + + $ErrMsg = _('The order header could not be deleted because'); + $DelResult=DB_query($sql,$db,$ErrMsg); + prnMsg( _('Order number').' '.$_SESSION['ExistingContract'].' '._('has been cancelled'), 'success'); + unset($_SESSION['Contract'.$identifier]); + unset($_SESSION['ExistingContract']); + } else { + // Re-Direct to right place + unset($_SESSION['Contract'.$identifier]); + prnMsg( _('The creation of the new order has been cancelled'), 'success'); + } + } +} + +if (!isset($_SESSION['Contract'.$identifier])){ + /* It must be a new order being created + * $_SESSION['Contract'.$identifier] would be set up from the order modification + * code above if a modification to an existing order. Also + * $ExistingContract would be set to 1. The delivery check screen + * is where the details of the order are either updated or + * inserted depending on the value of ExistingContract */ + + $_SESSION['ExistingContract']=0; + $_SESSION['Contract'.$identifier] = new PurchOrder; + $_SESSION['Contract'.$identifier]->AllowPrintContract = 1; /*Of course cos the order aint even started !!*/ + $_SESSION['Contract'.$identifier]->GLLink = $_SESSION['CompanyRecord']['gllink_stock']; + + if ($_SESSION['Contract'.$identifier]->CustomerID=='' OR !isset($_SESSION['Contract'.$identifier]->CustomerID)){ + +/* a session variable will have to maintain if a supplier + * has been selected for the order or not the session + * variable CustomerID holds the supplier code already + * as determined from user id /password entry */ + $_SESSION['RequireSupplierSelection'] = 1; + } else { + $_SESSION['RequireSupplierSelection'] = 0; + } + +} + +if (isset($_ContractST['ChangeSupplier'])) { + +/* change supplier only allowed with appropriate permissions - + * button only displayed to modify is AccessLevel >10 + * (see below)*/ + if ($_SESSION['Contract'.$identifier]->Stat == PurchOrder::STATUS_PENDING and $_SESSION['UserID']==$_SESSION['Contract'.$identifier]->Initiator) { + if ($_SESSION['Contract'.$identifier]->Any_Already_Received()==0){ + $emailsql='SELECT email FROM www_users WHERE userid="'.$_SESSION['Contract'.$identifier]->Initiator.'"'; + $emailresult=DB_query($emailsql, $db); + $emailrow=DB_fetch_array($emailresult); + $date = date($_SESSION['DefaultDateFormat']); + $_SESSION['RequireSupplierSelection']=1; + $_SESSION['Contract'.$identifier]->Stat = PurchOrder::STATUS_PENDING; + $StatusComment=$date.' - Supplier changed by <a href="mailto:'.$emailrow['email'].'">'.$_SESSION['UserID']. + '</a> - '.$_ContractST['StatComments'].'<br>'.$_ContractST['statcommentscomplete']; + $_SESSION['Contract'.$identifier]->StatComments=$StatusComment; + } else { + echo '<br><br>'; + prnMsg(_('Cannot modify the supplier of the order once some of the order has been received'),'warn'); + } + } +} + +$msg=''; +if (isset($_ContractST['SearchSuppliers'])){ + + if (strlen($_ContractST['Keywords'])>0 AND strlen($_SESSION['Contract'.$identifier]->CustomerID)>0) { + $msg=_('Supplier name keywords have been used in preference to the supplier code extract entered'); + } + if ($_ContractST['Keywords']=='' AND $_ContractST['SuppCode']=='') { + $msg=_('At least one Supplier Name keyword OR an extract of a Supplier Code must be entered for the search'); + } else { + if (strlen($_ContractST['Keywords'])>0) { + //insert wildcard characters in spaces + $SearchString = '%' . str_replace(' ', '%', $_ContractST['Keywords']) . '%'; + + $SQL = "SELECT suppliers.CustomerID, + suppliers.suppname, + suppliers.address1, + suppliers.address2, + suppliers.address3, + suppliers.address4, + suppliers.address5, + suppliers.address6, + suppliers.currcode + FROM suppliers + WHERE suppliers.suppname " . LIKE . " '$SearchString' + ORDER BY suppliers.suppname"; + + } elseif (strlen($_ContractST['SuppCode'])>0){ + $SQL = "SELECT suppliers.CustomerID, + suppliers.suppname, + suppliers.address1, + suppliers.address2, + suppliers.address3, + suppliers.address4, + suppliers.address5, + suppliers.address6, + suppliers.currcode + FROM suppliers + WHERE suppliers.CustomerID " . LIKE . " '%" . $_ContractST['SuppCode'] . "%' + ORDER BY suppliers.CustomerID"; + } + + $ErrMsg = _('The searched supplier records requested cannot be retrieved because'); + $result_SuppSelect = DB_query($SQL,$db,$ErrMsg); + + if (DB_num_rows($result_SuppSelect)==1){ + $myrow=DB_fetch_array($result_SuppSelect); + $_ContractST['Select'] = $myrow['CustomerID']; + } elseif (DB_num_rows($result_SuppSelect)==0){ + prnMsg( _('No supplier records contain the selected text') . ' - ' . + _('please alter your search criteria and try again'),'info'); + } + } /*one of keywords or SuppCode was more than a zero length string */ +} /*end of if search for supplier codes/names */ + + +// added by Hudson +if((!isset($_ContractST['SearchSuppliers']) or $_ContractST['SearchSuppliers']=='' ) AND + (isset($_SESSION['Contract'.$identifier]->CustomerID) AND $_SESSION['Contract'.$identifier]->CustomerID!='')){ + + /*The session variables are set but the form variables have been lost + * need to restore the form variables from the session */ + $_ContractST['CustomerID']=$_SESSION['Contract'.$identifier]->CustomerID; + $_ContractST['SupplierName']=$_SESSION['Contract'.$identifier]->SupplierName; + $_ContractST['CurrCode'] = $_SESSION['Contract'.$identifier]->CurrCode; + $_ContractST['ExRate'] = $_SESSION['Contract'.$identifier]->ExRate; + $_ContractST['paymentterms'] = $_SESSION['Contract'.$identifier]->paymentterms; + $_ContractST['DelAdd1']=$_SESSION['Contract'.$identifier]->DelAdd1; + $_ContractST['DelAdd2']=$_SESSION['Contract'.$identifier]->DelAdd2; + $_ContractST['DelAdd3']=$_SESSION['Contract'.$identifier]->DelAdd3; + $_ContractST['DelAdd4']=$_SESSION['Contract'.$identifier]->DelAdd4; + $_ContractST['DelAdd5']=$_SESSION['Contract'.$identifier]->DelAdd5; + $_ContractST['DelAdd6']=$_SESSION['Contract'.$identifier]->DelAdd6; + $_ContractST['suppDelAdd1']=$_SESSION['Contract'.$identifier]->suppDelAdd1; + $_ContractST['suppDelAdd2']=$_SESSION['Contract'.$identifier]->suppDelAdd2; + $_ContractST['suppDelAdd3']=$_SESSION['Contract'.$identifier]->suppDelAdd3; + $_ContractST['suppDelAdd4']=$_SESSION['Contract'.$identifier]->suppDelAdd4; + $_ContractST['suppDelAdd5']=$_SESSION['Contract'.$identifier]->suppDelAdd5; + $_ContractST['suppDelAdd6']=$_SESSION['Contract'.$identifier]->suppDelAdd6; + +} + +if (isset($_ContractST['Select'])) { + +/* will only be true if page called from supplier selection form + * or set because only one supplier record returned from a search + * so parse the $Select string into supplier code and branch code */ + $sql='SELECT currcode FROM suppliers where CustomerID="'.$_ContractST['Select'].'"'; + $result=DB_query($sql,$db); + $myrow=DB_fetch_array($result); + $SupplierCurrCode=$myrow['currcode']; + + $authsql='SELECT cancreate + FROM purchorderauth + WHERE userid="'.$_SESSION['UserID'].'" + AND currabrev="'.$SupplierCurrCode.'"'; + + $authresult=DB_query($authsql,$db); + + $sql = "SELECT suppliers.suppname, + suppliers.currcode, + currencies.rate, + suppliers.paymentterms, + suppliers.address1, + suppliers.address2, + suppliers.address3, + suppliers.address4, + suppliers.address5, + suppliers.address6, + suppliers.phn, + suppliers.Contractrt + FROM suppliers INNER JOIN currencies + ON suppliers.currcode=currencies.currabrev + WHERE CustomerID='" . $_ContractST['Select'] . "'"; + + $ErrMsg = _('The supplier record of the supplier selected') . ': ' . $_ContractST['Select'] . ' ' . + _('cannot be retrieved because'); + $DbgMsg = _('The SQL used to retrieve the supplier details and failed was'); + $result =DB_query($sql,$db,$ErrMsg,$DbgMsg); + $myrow = DB_fetch_row($result); + $SupplierName = $myrow[0]; + // added for suppliers lookup fields + + if (($authmyrow=DB_fetch_array($authresult) and $authmyrow[0]==0 ) ) { + $_ContractST['SupplierName'] = $myrow[0]; + $_ContractST['CurrCode'] = $myrow[1]; + $_ContractST['ExRate'] = $myrow[2]; + $_ContractST['paymentterms']= $myrow[3]; + $_ContractST['suppDelAdd1'] = $myrow[4]; + $_ContractST['suppDelAdd2'] = $myrow[5]; + $_ContractST['suppDelAdd3'] = $myrow[6]; + $_ContractST['suppDelAdd4'] = $myrow[7]; + $_ContractST['suppDelAdd5'] = $myrow[8]; + $_ContractST['suppDelAdd6'] = $myrow[9]; + $_ContractST['supptel'] = $myrow[10]; + $_ContractST['Contractrt'] = $myrow[11]; + + $_SESSION['Contract'.$identifier]->CustomerID = $_ContractST['Select']; + $_SESSION['RequireSupplierSelection'] = 0; + $_SESSION['Contract'.$identifier]->SupplierName = $_ContractST['SupplierName']; + $_SESSION['Contract'.$identifier]->CurrCode = $_ContractST['CurrCode']; + $_SESSION['Contract'.$identifier]->ExRate = $_ContractST['ExRate']; + $_SESSION['Contract'.$identifier]->paymentterms = $_ContractST['paymentterms']; + $_SESSION['Contract'.$identifier]->suppDelAdd1 = $_ContractST['suppDelAdd1']; + $_SESSION['Contract'.$identifier]->suppDelAdd2 = $_ContractST['suppDelAdd2']; + $_SESSION['Contract'.$identifier]->suppDelAdd3 = $_ContractST['suppDelAdd3']; + $_SESSION['Contract'.$identifier]->suppDelAdd4 = $_ContractST['suppDelAdd4']; + $_SESSION['Contract'.$identifier]->suppDelAdd5 = $_ContractST['suppDelAdd5']; + $_SESSION['Contract'.$identifier]->suppDelAdd6 = $_ContractST['suppDelAdd6']; + $_SESSION['Contract'.$identifier]->supptel = $_ContractST['supptel']; + $_SESSION['Contract'.$identifier]->Contractrt = $_ContractST['Contractrt']; + } else { + prnMsg( _('You do not have the authority to raise Contracts for '). + $SupplierName.'. '._('Please Consult your system administrator for more information').'. ' + ._('You can setup authorisations ').'<a href=Contract_AuthorisationLevels.php>'._('here').'.</a>', 'warn'); + include('includes/footer.inc'); + exit; + } + + // end of added for suppliers lookup fields + +} else { + $_ContractST['Select'] = $_SESSION['Contract'.$identifier]->CustomerID; + $sql = "SELECT suppliers.suppname, + suppliers.currcode, + suppliers.paymentterms, + suppliers.address1, + suppliers.address2, + suppliers.address3, + suppliers.address4, + suppliers.address5, + suppliers.address6, + suppliers.phn, + suppliers.Contractrt + FROM suppliers INNER JOIN currencies + ON suppliers.currcode=currencies.currabrev + WHERE CustomerID='" . $_ContractST['Select'] . "'"; + + $ErrMsg = _('The supplier record of the supplier selected') . ': ' . $_ContractST['Select'] . ' ' . + _('cannot be retrieved because'); + $DbgMsg = _('The SQL used to retrieve the supplier details and failed was'); + $result =DB_query($sql,$db,$ErrMsg,$DbgMsg); + + + $myrow = DB_fetch_row($result); + + + // added for suppliers lookup fields + if (!isset($_SESSION['Contract'.$identifier])) { + $_ContractST['SupplierName'] = $myrow[0]; + $_ContractST['CurrCode'] = $myrow[1]; + $_ContractST['paymentterms']= $myrow[2]; + $_ContractST['suppDelAdd1'] = $myrow[3]; + $_ContractST['suppDelAdd2'] = $myrow[4]; + $_ContractST['suppDelAdd3'] = $myrow[5]; + $_ContractST['suppDelAdd4'] = $myrow[6]; + $_ContractST['suppDelAdd5'] = $myrow[7]; + $_ContractST['suppDelAdd6'] = $myrow[8]; + $_ContractST['supptel'] = $myrow[9]; + $_ContractST['Contractrt'] = $myrow[10]; + + $_SESSION['Contract'.$identifier]->CustomerID = $_ContractST['Select']; + $_SESSION['RequireSupplierSelection'] = 0; + $_SESSION['Contract'.$identifier]->SupplierName = $_ContractST['SupplierName']; + $_SESSION['Contract'.$identifier]->CurrCode = $_ContractST['CurrCode']; + $_SESSION['Contract'.$identifier]->ExRate = $_ContractST['ExRate']; + $_SESSION['Contract'.$identifier]->paymentterms = $_ContractST['paymentterms']; + $_SESSION['Contract'.$identifier]->suppDelAdd1 = $_ContractST['suppDelAdd1']; + $_SESSION['Contract'.$identifier]->suppDelAdd2 = $_ContractST['suppDelAdd2']; + $_SESSION['Contract'.$identifier]->suppDelAdd3 = $_ContractST['suppDelAdd3']; + $_SESSION['Contract'.$identifier]->suppDelAdd4 = $_ContractST['suppDelAdd4']; + $_SESSION['Contract'.$identifier]->suppDelAdd5 = $_ContractST['suppDelAdd5']; + $_SESSION['Contract'.$identifier]->suppDelAdd6 = $_ContractST['suppDelAdd6']; + $_SESSION['Contract'.$identifier]->supptel = $_ContractST['supptel']; + $_SESSION['Contract'.$identifier]->Contractrt = $_ContractST['Contractrt']; + // end of added for suppliers lookup fields + } +} + +// MADE THE SUPPILERS BECOME SELECT MENU NOT BY SEARCHING By Hudson @2008/6/30 + +// part of step 1 +if ($_SESSION['RequireSupplierSelection'] ==1 OR !isset($_SESSION['Contract'.$identifier]->CustomerID) OR + $_SESSION['Contract'.$identifier]->CustomerID=='' ) { +//if (true) { + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . + _('Contract') . '" alt="">' . ' ' . _('Contract: Select Supplier') . ''; + echo "<form action='" . $_SERVER['PHP_SELF'] . '?' . SID . "identifier=".$identifier."' method=Contractst name='choosesupplier'>"; + if (strlen($msg)>1){ + prnMsg($msg,'warn'); + } + + echo '<table cellpadding=3 colspan=4> + <tr> + <td><font size=1>' . _('Enter text in the supplier name') . ":</font></td> + <td><input type='Text' name='Keywords' size=20 maxlength=25></td> + <td><font size=3><b>" . _('OR') . '</b></font></td> + <td><font size=1>' . _('Enter text extract in the supplier code') . ":</font></td> + <td><input type='text' name='SuppCode' size=15 maxlength=18></td> + </tr> + </table><br><div class='centre'> + <input type=submit name='SearchSuppliers' value=" . _('Search Now') . "> + <input type=submit action=reset value='" . _('Reset') . "'></div>"; + + echo '<script type="text/javascript">defaultControl(document.forms[0].Keywords);</script>'; + +// UPDATED BY HUDSON 30/6/2008 + + if (isset($result_SuppSelect)) { + + echo '<br><table cellpadding=3 colspan=7 border=1>'; + + $tableheader = "<tr> + <th>" . _('Code') . "</th> + <th>" . _('Supplier Name') . "</th> + <th>" . _('Address') . "</th> + <th>" . _('Currency') . '</th> + </tr>'; + + echo $tableheader; + + $j = 1; + $k = 0; /*row counter to determine background colour */ + + while ($myrow=DB_fetch_array($result_SuppSelect)) { + + if ($k==1){ + echo '<tr class="EvenTableRows">'; + $k=0; + } else { + echo '<tr class="OddTableRows">'; + $k++; + } + + echo "<td><input type='submit' style='width:100%' name='Select' value='".$myrow['CustomerID']."' ></td> + <td>".$myrow['suppname']."</td><td>"; + + for ($i=1; $i<=6; $i++) { + if ($myrow['address'.$i] != '') { + echo $myrow['address'.$i].'<br>'; + } + } + echo "</td><td>".$myrow['currcode']."</td></tr>"; + + //end of page full new headings if + } +//end of while loop + + echo '</table>'; + + } +//end if results to show + +//end if RequireSupplierSelection +} else { +/* everything below here only do if a supplier is selected */ + + echo "<form name='form1' action='" . $_SERVER['PHP_SELF'] . '?' . SID . "identifier=".$identifier. "' method=Contractst>"; + +// Be careful not made confused by orderno and realorderno +// $orderno = previous_id("purchorders","orderno"); +// $_SESSION['Contract'.$identifier]->OrderNo2 = $orderno; + echo '<p class="page_title_text"> + <img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . _('Contract') . '" alt=""> + ' . $_SESSION['Contract'.$identifier]->SupplierName . ' - ' . _('All amounts stated in') . ' + ' . $_SESSION['Contract'.$identifier]->CurrCode . '<br />'; + if ($_SESSION['ExistingContract']) { + echo _(' Modify Contract Number') . ' ' . $_SESSION['Contract'.$identifier]->OrderNo; + + echo '</p>'; + + } + +/* 2008-08-19 ToPu -- debugging purContractse */ + if (isset($purch_item)) { + prnMsg(_('Purchase Item(s) with this code') . ': ' . $purch_item,'info'); + + /** + * 2008-08-21 ToPu + * Now go ahead to Contract_Items.php + * with NewItem=$purch_item + */ + /* a somewhat nice outfit for that link */ + echo "<div class='centre'>"; + echo '<br><table class="table_index"><tr><td class="menu_group_item">'; + + /* the link */ + echo '<li><a href="'.$rootpath.'/Contract_Items.php?' . SID . 'NewItem=' . $purch_item . "&identifier=".$identifier. '">' . + _('Enter Line Item to this Contract') . '</a></li>'; + /**/ + echo "</td></tr></table></div><br>"; + + if (isset($_GET['Quantity'])) { + $Qty=$_GET['Quantity']; + } else { + $Qty=1; + } + + $sql='SELECT + controlled, + serialised, + description, + units , + decimalplaces + FROM stockmaster + WHERE stockid="'.$purch_item.'" '; + $result=DB_query($sql, $db); + $stockmasterrow=DB_fetch_array($result); + + $sql='SELECT + price, + suppliersuom, + suppliers_partno + FROM purchdata + WHERE supplierno="'.$_GET['SelectedCustomer'] .'" + AND stockid="'.$purch_item.'" '; + $result=DB_query($sql, $db); + $purchdatarow=DB_fetch_array($result); + + $sql='SELECT + stockact + FROM stockcategory + LEFT JOIN stockmaster ON stockmaster.categoryid=stockcategory.categoryid + WHERE stockid="'.$purch_item.'" '; + $result=DB_query($sql, $db); + $categoryrow=DB_fetch_array($result); + + $_SESSION['Contract'.$identifier]->add_to_order( + 1, + $purch_item, + $stockmasterrow['serialised'], + $stockmasterrow['controlled'], + $Qty, + $stockmasterrow['description'], + $purchdatarow['price'], + $stockmasterrow['units'], + $categoryrow['stockact'], + date($_SESSION['DefaultDateFormat']), + 0, + 0, + '', + 0, + 0, + '', + $stockmasterrow['decimalplaces'], + $purch_item, + $purchdatarow['suppliersuom'], + $purchdatarow['suppliers_partno'], + $Qty*$purchdatarow['price'], + '', + 0, + 0, + 0, + 0, + $Qty, + $Qty*$purchdatarow['price']); + echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . '/Contract_Items.php?' . SID . 'identifier='.$identifier. "'>"; + } + + /*Set up form for entry of order header stuff */ + + if (!isset($_ContractST['LookupDeliveryAddress']) and (!isset($_ContractST['StkLocation']) or $_ContractST['StkLocation']) + AND (isset($_SESSION['Contract'.$identifier]->Location) AND $_SESSION['Contract'.$identifier]->Location != '')) { + /* The session variables are set but the form variables have + * been lost -- + * need to restore the form variables from the session */ + $_ContractST['StkLocation']=$_SESSION['Contract'.$identifier]->Location; + $_ContractST['SupplierContact']=$_SESSION['Contract'.$identifier]->SupplierContact; + $_ContractST['DelAdd1']=$_SESSION['Contract'.$identifier]->DelAdd1; + $_ContractST['DelAdd2']=$_SESSION['Contract'.$identifier]->DelAdd2; + $_ContractST['DelAdd3']=$_SESSION['Contract'.$identifier]->DelAdd3; + $_ContractST['DelAdd4']=$_SESSION['Contract'.$identifier]->DelAdd4; + $_ContractST['DelAdd5']=$_SESSION['Contract'.$identifier]->DelAdd5; + $_ContractST['DelAdd6']=$_SESSION['Contract'.$identifier]->DelAdd6; + $_ContractST['Initiator']=$_SESSION['Contract'.$identifier]->Initiator; + $_ContractST['Requisition']=$_SESSION['Contract'.$identifier]->RequisitionNo; + $_ContractST['version']=$_SESSION['Contract'.$identifier]->version; + $_ContractST['deliverydate']=$_SESSION['Contract'.$identifier]->deliverydate; + $_ContractST['revised']=$_SESSION['Contract'.$identifier]->revised; + $_ContractST['ExRate']=$_SESSION['Contract'.$identifier]->ExRate; + $_ContractST['Comments']=$_SESSION['Contract'.$identifier]->Comments; + $_ContractST['deliveryby']=$_SESSION['Contract'.$identifier]->deliveryby; + $_ContractST['paymentterms']=$_SESSION['Contract'.$identifier]->paymentterms; + } + +// move apart by Hudson + echo '<br><table border=1 colspan=1 width=80%> + <tr> + <td><font color=blue size=4><b>' . _('Order Initiation Details') . '</b></font></td> + + <td><font color=blue size=4><b>' . _('Order Status') . '</b></font></td> + </tr> <tr><td style="width:50%">'; + + echo '<table>'; + echo '<tr><td>' . _('Contract Date') . ':</td><td>'; + if ($_SESSION['ExistingContract']!=0){ + echo ConvertSQLDate($_SESSION['Contract'.$identifier]->Orig_OrderDate); + } else { + /* DefaultDateFormat defined in config.php */ + echo Date($_SESSION['DefaultDateFormat']); + } + echo '</td></tr>'; + + $date = date($_SESSION['DefaultDateFormat']); + + if (isset($_GET['ModifyContractNo']) && $_GET['ModifyContractNo'] != '') { + $_SESSION['Contract'.$identifier]->version += 1; + $_ContractST['version'] = $_SESSION['Contract'.$identifier]->version; + } elseif (isset($_SESSION['Contract'.$identifier]->version) and $_SESSION['Contract'.$identifier]->version != '') { + $_ContractST['version'] = $_SESSION['Contract'.$identifier]->version; + } else { + $_ContractST['version']='1'; + } + + if (!isset($_ContractST['deliverydate'])) { + $_ContractST['deliverydate']= date($_SESSION['DefaultDateFormat']); + } + + echo '<tr><td>' . _('Version'). ' #' . ":</td><td><input type='hidden' name='version' size=16 maxlength=15 + value='" . $_ContractST['version'] . "'>".$_ContractST['version']."</td></tr>"; + echo '<tr><td>' . _('Revised') . ":</td><td><input type='hidden' name='revised' size=11 maxlength=15 value=" . + $date . '>'.$date.'</td></tr>'; + + echo '<tr><td>' . _('Delivery Date') . ":</td><td><input type='text' class=date alt='".$_SESSION['DefaultDateFormat']. + "' name='deliverydate' size=11 value=" . $_ContractST['deliverydate'] . '>'."</td></tr>"; + + if (!isset($_ContractST['Initiator'])) { + $_ContractST['Initiator'] = $_SESSION['UserID']; + $_ContractST['Requisition'] = ''; + } + + echo '<tr><td>' . _('Initiated By') . ":</td> + <td><input type='hidden' name='Initiator' size=11 maxlength=10 value=" . + $_ContractST['Initiator'] . ">".$_ContractST['Initiator']."</td></tr>"; + echo '<tr><td>' . _('Requisition Ref') . ":</td><td><input type='text' name='Requisition' size=16 + maxlength=15 value=" . $_ContractST['Requisition'] . '></td></tr>'; + +// echo '<tr><td>' . _('Exchange Rate') . ":</td> +// <td><input type=TEXT name='ExRate' size=16 maxlength=15 VALUE=" . $_ContractST['ExRate'] . '></td> +// echo "<input type='hidden' name='ExRate' size=16 maxlength=15 value=" . $_ContractST['ExRate'] . "></td>"; +// </tr>'; + echo '<tr><td>' . _('Date Printed') . ':</td><td>'; + + if (isset($_SESSION['Contract'.$identifier]->DatePurchaseOrderPrinted) AND strlen($_SESSION['Contract'.$identifier]->DatePurchaseOrderPrinted)>6){ + echo ConvertSQLDate($_SESSION['Contract'.$identifier]->DatePurchaseOrderPrinted); + $Printed = True; + } else { + $Printed = False; + echo _('Not yet printed'); + } + + if (isset($_ContractST['AllowRePrint'])) { + $sql='UPDATE purchorders SET allowprint=1 WHERE orderno='.$_SESSION['Contract'.$identifier]->OrderNo; + $result=DB_query($sql, $db); + } + + if ($_SESSION['Contract'.$identifier]->AllowPrintContract==0 AND empty($_ContractST['RePrint'])){ + echo '<tr><td>' . _('Allow Reprint') . ":</td><td><select name='RePrint' onChange='ReloadForm(form1.AllowRePrint)'><option selected value=0>" . + _('No') . "<option value=1>" . _('Yes') . '</select></td>'; + echo '<td><input type=submit name="AllowRePrint" value="Update"></td></tr>'; + } elseif ($Printed) { + echo "<tr><td colspan=2><a target='_blank' href='$rootpath/Contract_PDFPurchOrder.php?" . + SID . "OrderNo=" . $_SESSION['ExistingContract'] . "&identifier=".$identifier. "'>" . _('Reprint Now') . '</a></td></tr>'; + } + + echo '</table>'; + + echo '<td style="width:50%"><table>'; + if($_SESSION['ExistingContract'] != 0 and $_SESSION['Contract'.$identifier]->Stat == PurchOrder::STATUS_PRINTED){ + echo '<tr><td><a href="' .$rootpath . "/GoodsReceived.php?" . SID . "&ContractNumber=" . + $_SESSION['Contract'.$identifier]->OrderNo . "&identifier=".$identifier.'">'._('Receive this order').'</a></td></tr>'; + } + echo '<td>' . _('Status') . ' : </td><td><select name=Stat onChange="ReloadForm(form1.UpdateStat)">'; + + switch ($_SESSION['Contract'.$identifier]->Stat) { + case '': + $StatusList = array(PurchOrder::STATUS_NEW_ORDER); + break; + case PurchOrder::STATUS_PENDING: + $StatusList = array(PurchOrder::STATUS_PENDING, PurchOrder::STATUS_AUTHORISED, + PurchOrder::STATUS_REJECTED, PurchOrder::STATUS_CANCELLED); + break; + case PurchOrder::STATUS_AUTHORISED: + $StatusList = array(PurchOrder::STATUS_PENDING, PurchOrder::STATUS_AUTHORISED, + PurchOrder::STATUS_CANCELLED); + break; + case PurchOrder::STATUS_REJECTED: + $StatusList = array(PurchOrder::STATUS_PENDING, PurchOrder::STATUS_AUTHORISED, + PurchOrder::STATUS_REJECTED, PurchOrder::STATUS_CANCELLED); + break; + case PurchOrder::STATUS_CANCELLED: + $StatusList = array(PurchOrder::STATUS_PENDING, PurchOrder::STATUS_CANCELLED); + break; + case PurchOrder::STATUS_PRINTED: + $StatusList = array(PurchOrder::STATUS_PENDING, PurchOrder::STATUS_PRINTED, + PurchOrder::STATUS_CANCELLED); + break; + case PurchOrder::STATUS_COMPLITED: + $StatusList = array(PurchOrder::STATUS_COMPLITED); + break; + default: + $StatusList = array(PurchOrder::STATUS_NEW_ORDER, PurchOrder::STATUS_PENDING, + PurchOrder::STATUS_AUTHORISED, PurchOrder::STATUS_REJECTED, + PurchOrder::STATUS_CANCELLED); + break; + } + + foreach ($StatusList as $Status) { + if ($_SESSION['Contract'.$identifier]->Stat == $Status){ + echo '<option selected value="' . $Status . '">' . _($Status) . '</option>'; + } else { + echo '<option value="'.$Status.'">' . _($Status) . '</option>'; + } + } + echo '</select></td></tr>'; + + echo '<tr><td>' . _('Status Comment'); + echo ":</td><td><input type=text name='StatComments' size=50></td></tr><tr><td colspan=2><b>" . html_entity_decode($_SESSION['Contract'.$identifier]->StatComments) .'</b></td></tr>'; + echo "<input type=hidden name='statcommentscomplete' value='".$_SESSION['Contract'.$identifier]->StatComments."'>"; + echo '<tr><td><input type="submit" name=UpdateStat value="' . _("Status Update") .'"></td>'; + + echo "<td><input type='submit' name='CancelOrder' value='" . _("Cancel and Delete Order") . "'></td></tr>"; + echo '</table></td>'; + +// end of move by Hudson + + echo '<table border=1 width=80%> + <tr> + <td><font color=blue size=4><b>' . _('Warehouse Info') . '</b></font></td> + <!-- <td><font color=blue size=4><b>' . _('Delivery To') . '</b></font></td> --> + <td><font color=blue size=4><b>' . _('Supplier Info') . '</b></font></td> + </tr> + <tr><td valign=top>'; + /*nested table level1 */ + + echo '<table><tr><td>' . _('Warehouse') . ':</td> + <td><select name=StkLocation onChange="ReloadForm(form1.LookupDeliveryAddress)">'; + + $sql = 'SELECT loccode, + locationname + FROM locations'; + $LocnResult = DB_query($sql,$db); + + while ($LocnRow=DB_fetch_array($LocnResult)){ + if (isset($_ContractST['StkLocation']) and ($_ContractST['StkLocation'] == $LocnRow['loccode'] OR + ($_ContractST['StkLocation']=='' AND $LocnRow['loccode']==$_SESSION['UserStockLocation']))){ + echo "<option selected value='" . $LocnRow['loccode'] . "'>" . $LocnRow['locationname']; + } else { + echo "<option value='" . $LocnRow['loccode'] . "'>" . $LocnRow['locationname']; + } + } + + echo '</select> + <input type="submit" name="LookupDeliveryAddress" value="' ._('Select') . '"></td> + </tr>'; + +/* If this is the first time + * the form loaded set up defaults */ + + if (!isset($_ContractST['StkLocation']) OR $_ContractST['StkLocation']==''){ + + $_ContractST['StkLocation'] = $_SESSION['UserStockLocation']; + + $sql = "SELECT deladd1, + deladd2, + deladd3, + deladd4, + deladd5, + deladd6, + tel, + contact + FROM locations + WHERE loccode='" . $_ContractST['StkLocation'] . "'"; + + $LocnAddrResult = DB_query($sql,$db); + if (DB_num_rows($LocnAddrResult)==1){ + $LocnRow = DB_fetch_row($LocnAddrResult); + $_ContractST['DelAdd1'] = $LocnRow[0]; + $_ContractST['DelAdd2'] = $LocnRow[1]; + $_ContractST['DelAdd3'] = $LocnRow[2]; + $_ContractST['DelAdd4'] = $LocnRow[3]; + $_ContractST['DelAdd5'] = $LocnRow[4]; + $_ContractST['DelAdd6'] = $LocnRow[5]; + $_ContractST['tel'] = $LocnRow[6]; + $_ContractST['Contact'] = $LocnRow[7]; + + $_SESSION['Contract'.$identifier]->Location= $_ContractST['StkLocation']; +// $_SESSION['Contract'.$identifier]->SupplierContact= $_ContractST['SupplierContact']; + $_SESSION['Contract'.$identifier]->DelAdd1 = $_ContractST['DelAdd1']; + $_SESSION['Contract'.$identifier]->DelAdd2 = $_ContractST['DelAdd2']; + $_SESSION['Contract'.$identifier]->DelAdd3 = $_ContractST['DelAdd3']; + $_SESSION['Contract'.$identifier]->DelAdd4 = $_ContractST['DelAdd4']; + $_SESSION['Contract'.$identifier]->DelAdd5 = $_ContractST['DelAdd5']; + $_SESSION['Contract'.$identifier]->DelAdd6 = $_ContractST['DelAdd6']; + $_SESSION['Contract'.$identifier]->tel = $_ContractST['tel']; + $_SESSION['Contract'.$identifier]->contact = $_ContractST['Contact']; + + } else { + /*The default location of the user is crook */ + prnMsg(_('The default stock location set up for this user is not a currently defined stock location') . + '. ' . _('Your system administrator needs to amend your user record'),'error'); + } + + + } elseif (isset($_ContractST['LookupDeliveryAddress'])){ + + $sql = "SELECT deladd1, + deladd2, + deladd3, + deladd4, + deladd5, + deladd6, + tel, + contact + FROM locations + WHERE loccode='" . $_ContractST['StkLocation'] . "'"; + + $LocnAddrResult = DB_query($sql,$db); + if (DB_num_rows($LocnAddrResult)==1){ + $LocnRow = DB_fetch_row($LocnAddrResult); + $_ContractST['DelAdd1'] = $LocnRow[0]; + $_ContractST['DelAdd2'] = $LocnRow[1]; + $_ContractST['DelAdd3'] = $LocnRow[2]; + $_ContractST['DelAdd4'] = $LocnRow[3]; + $_ContractST['DelAdd5'] = $LocnRow[4]; + $_ContractST['DelAdd6'] = $LocnRow[5]; + $_ContractST['tel'] = $LocnRow[6]; + $_ContractST['Contact'] = $LocnRow[7]; + + $_SESSION['Contract'.$identifier]->Location= $_ContractST['StkLocation']; + $_SESSION['Contract'.$identifier]->DelAdd1 = $_ContractST['DelAdd1']; + $_SESSION['Contract'.$identifier]->DelAdd2 = $_ContractST['DelAdd2']; + $_SESSION['Contract'.$identifier]->DelAdd3 = $_ContractST['DelAdd3']; + $_SESSION['Contract'.$identifier]->DelAdd4 = $_ContractST['DelAdd4']; + $_SESSION['Contract'.$identifier]->DelAdd5 = $_ContractST['DelAdd5']; + $_SESSION['Contract'.$identifier]->DelAdd6 = $_ContractST['DelAdd6']; + $_SESSION['Contract'.$identifier]->tel = $_ContractST['tel']; + $_SESSION['Contract'.$identifier]->contact = $_ContractST['Contact']; + } + } + + + echo '<tr><td>' . _('Delivery Contact') . ":</td> + <td><input type='text' name=Contact size=41 value='" . $_SESSION['Contract'.$identifier]->contact . "'></td> + </tr>"; + echo '<tr><td>' . _('Address') . " 1 :</td> + <td><input type='text' name=DelAdd1 size=41 maxlength=40 value='" . $_ContractST['DelAdd1'] . "'></td> + </tr>"; + echo '<tr><td>' . _('Address') . " 2 :</td> + <td><input type='text' name=DelAdd2 size=41 maxlength=40 value='" . $_ContractST['DelAdd2'] . "'></td> + </tr>"; + echo '<tr><td>' . _('Address') . " 3 :</td> + <td><input type='text' name=DelAdd3 size=41 maxlength=40 value='" . $_ContractST['DelAdd3'] . "'></td> + </tr>"; + echo '<tr><td>' . _('Address') . " 4 :</td> + <td><input type='text' name=DelAdd4 size=21 maxlength=20 value='" . $_ContractST['DelAdd4'] . "'></td> + </tr>"; + echo '<tr><td>' . _('Address') . " 5 :</td> + <td><input type='text' name=DelAdd5 size=16 maxlength=15 value='" . $_ContractST['DelAdd5'] . "'></td> + </tr>"; + echo '<tr><td>' . _('Address') . " 6 :</td> + <td><input type='text' name=DelAdd6 size=16 maxlength=15 value='" . $_ContractST['DelAdd6'] . "'></td> + </tr>"; + echo '<tr><td>' . _('Phone') . ":</td> + <td><input type='text' name=tel size=31 maxlength=30 value='" . $_SESSION['Contract'.$identifier]->tel . "'></td> + </tr>"; + + echo '<tr><td>' . _('Delivery By') . ':</td><td><select name=deliveryby>'; + + $sql = 'SELECT shipper_id, shippername FROM shippers'; + $shipperResult = DB_query($sql,$db); + + while ($shipperRow=DB_fetch_array($shipperResult)){ + if (isset($_ContractST['deliveryby']) and ($_ContractST['deliveryby'] == $shipperRow['shipper_id'])) { + echo "<option selected value='" . $shipperRow['shipper_id'] . "'>" . $shipperRow['shippername']; + } else { + echo "<option value='" . $shipperRow['shipper_id'] . "'>" . $shipperRow['shippername']; + } + } + + echo '</select></tr></table>'; + /* end of sub table */ + + echo '</td><td>'; /*sub table nested */ + echo '<table><tr><td>' . _('Supplier Selection') . ':</td><td> + <select name=Keywords onChange="ReloadForm(form1.SearchSuppliers)">'; + + $sql = "SELECT CustomerID,suppname FROM suppliers ORDER BY suppname"; + $SuppCoResult = DB_query($sql,$db); + + while ( $SuppCoRow=DB_fetch_array($SuppCoResult)){ + if ($SuppCoRow['suppname'] == $_SESSION['Contract'.$identifier]->SupplierName) { + echo "<option selected value='" . $SuppCoRow['suppname'] . "'>" . $SuppCoRow['suppname']; + } else { + echo "<option value='" . $SuppCoRow['suppname'] . "'>" . $SuppCoRow['suppname']; + } + } + + echo '</select> '; + echo '<input type="submit" name="SearchSuppliers" value=' . _('Select Now') . '"></td></tr>'; + +// END of added <input type=submit action=RESET VALUE="' . _('Reset') + + echo '</td></tr><tr><td>' . _('Supplier Contact') . ':</td><td> + <select name=SupplierContact>'; + + $sql = "SELECT contact FROM suppliercontacts WHERE CustomerID='". $_ContractST['Select'] ."'"; + + $SuppCoResult = DB_query($sql,$db); + + while ( $SuppCoRow=DB_fetch_array($SuppCoResult)){ + if ($_ContractST['SupplierContact'] == $SuppCoRow['contact'] OR ($_ContractST['SupplierContact']=='' + AND $SuppCoRow['contact']==$_SESSION['Contract'.$identifier]->SupplierContact)){ + //if (1) { + echo "<option selected value='" . $SuppCoRow['contact'] . "'>" . $SuppCoRow['contact']; + } else { + echo "<option value='" . $SuppCoRow['contact'] . "'>" . $SuppCoRow['contact']; + } + } + + echo '</select> '; + echo '</td></tr>'; + + echo '<tr><td>' . _('Address') . " 1 :</td> + </td><td><input type='text' name=suppDelAdd1 size=41 maxlength=40 value='" . $_ContractST['suppDelAdd1'] . "'></td> + </tr>"; + echo '<tr><td>' . _('Address') . " 2 :</td> + </td><td><input type='text' name=suppDelAdd2 size=41 maxlength=40 value='" . $_ContractST['suppDelAdd2'] . "'></td> + </tr>"; + echo '<tr><td>' . _('Address') . " 3 :</td> + </td><td><input type='text' name=suppDelAdd3 size=41 maxlength=40 value='" . $_ContractST['suppDelAdd3'] . "'></td> + </tr>"; + echo '<tr><td>' . _('Address') . " 4 :</td> + </td><td><input type='text' name=suppDelAdd5 size=21 maxlength=20 value='" . $_ContractST['suppDelAdd5'] . "'></td> + </tr>"; + echo '<tr><td>' . _('Address') . " 5 :</td> + </td><td><input type='text' name=suppDelAdd4 size=41 maxlength=40 value='" . $_ContractST['suppDelAdd4'] . "'></td> + </tr>"; + echo '<tr><td>' . _('Phone') . ": + </td><td><input type='text' name=supptel size=31 maxlength=30 value='" . $_SESSION['Contract'.$identifier]->supptel . "'></td> + </tr>"; + + $result=DB_query('SELECT terms, termsindicator FROM paymentterms', $db); + + echo '<tr><td>' . _('Payment Terms') . ":</td><td><select name='paymentterms'>"; + + while ($myrow = DB_fetch_array($result)) { + if ($myrow['termsindicator']==$_SESSION['Contract'.$identifier]->paymentterms) { + echo "<option selected value='". $myrow['termsindicator'] . "'>" . $myrow['terms']; + } else { + echo "<option value='". $myrow['termsindicator'] . "'>" . $myrow['terms']; + } //end while loop + } + DB_data_seek($result, 0); + echo '</select></td></tr>'; + + $result=DB_query("SELECT loccode, locationname FROM locations WHERE loccode='" . $_SESSION['Contract'.$identifier]->Contractrt."'", $db); + $myrow = DB_fetch_array($result); + $_ContractST['Contractrt'] = $myrow['locationname']; + + echo '<tr><td>' . _('Delivery To') . ": + </td><td><input type='text' name=Contractrt size=31 value='" . $_ContractST['Contractrt'] . "'></td> + </tr>"; + + if ($_SESSION['Contract'.$identifier]->CurrCode != $_SESSION['CompanyRecord']['currencydefault']) { + echo '<tr><td>'. _('Exchange Rate').':'.'</td><td><input type=text name="ExRate" + value='.$_ContractST['ExRate'].' class=number size=11></td></tr>'; + } else { + echo '<input type=hidden name="ExRate" value="1">'; + } + echo '</td></tr></table>'; /*end of sub table */ + + echo '</td></tr><tr><th colspan=4>' . _('Comments'); + + $Default_Comments = ''; + + if (!isset($_ContractST['Comments'])) { + $_ContractST['Comments']=$Default_Comments; + } + + echo ":</th></tr><tr><td colspan=4><textarea name='Comments' style='width:100%' rows=5>" . $_ContractST['Comments'] . '</textarea>'; + + echo '</table>'; + + echo '</td></tr></table><br>'; /* end of main table */ + // discard change supplier submit buttom + // kept enter line item but remove Delete button by Hudson 11/16,and added status field + echo "<div class='centre'> + <input type=submit name='EnterLines' value='" . _('Enter Line Items') . "'></div>"; + // Delete Contract when necessrary + +} /*end of if supplier selected */ + +echo '</form>'; +include('includes/footer.inc'); +?> Modified: trunk/PO_Header.php =================================================================== --- trunk/PO_Header.php 2010-06-06 08:37:57 UTC (rev 3482) +++ trunk/PO_Header.php 2010-06-07 01:06:13 UTC (rev 3483) @@ -2,36 +2,6 @@ /* $Id$ */ -/* -* PO_Header.php -* -* webERP Linux-Apache-MySQL-PHP based accounting system -* Copyright Logic Works Ltd - 2007 - Contact: in...@we... -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -* MA 02110-1301, USA. -* -* -* modifications and add-ons started from: -* Revision: 1.18 -* by Thomas Pulina -* <hol...@no...>|<tho...@wa...> -* 2008 -* -*/ - $PageSecurity = 4; include('includes/DefinePOClass.php'); include('includes/session.inc'); Added: trunk/includes/DefineContractClass.php =================================================================== --- trunk/includes/DefineContractClass.php (rev 0) +++ trunk/includes/DefineContractClass.php 2010-06-07 01:06:13 UTC (rev 3483) @@ -0,0 +1,107 @@ +<?php +/* $Id: $*/ +/* definition of the Contract class */ + +Class Contract { + + var contractno; /*auto generated contract no - but there for existing contracts */ + var contractref; /*the contract short description used for stockid when contract submitted for quotation */ + var contractdescription; /*the description of the contract */ + var debtorno; /*the customer that the contract is for */ + var branchcode; + var status; /* 0 = initiated - 1=quoted - 2=completed */ + var categoryid; /* the category where the contract will be when converted to an item for quotation*/ + var orderno; /* the order number created when the contract is quoted */ + var margin; /*the margin used in quoting for the contract */ + var wo; /*the wo created when the quotation is converted to an order */ + var requireddate; + var quantityreqd; + var units; /*the unit of measure of the contract item*/ + var drawing; /*a link to the contract drawing*/ + var rate; /*the rate of exchange between customer currency and company functional currency used when quoting */ + var BOMComponentCounter; + var RequirementsCounter; + + var $ContractBOM; /*array of stockid components required for the contract */ + var $ContractReqts; /*array of other items required for the contract */ + + function Contract(){ + /*Constructor function initialises a new Payment batch */ + $this->ContractBOM = array(); + $this->ContractReqts = array(); + $this->BOMComponentCounter=0; + $this->RequirementsCounter=0; + } + + function Add_To_ContractBOM($StockID, $WorkCentre, $Quantity, $ItemCost, $UOM){ + if (isset($StockID) AND $Quantity!=0){ + $this->ContractBOM[$this->BOMComponentCounter] = new ContractComponent($StockID, $WorkCentre, $Quantity,$ItemCost, $UOM); + $this->BOMComponentCounter++; + Return 1; + } + Return 0; + } + + function remove_ContractComponent($ContractComponent_ID){ + unset($this->ContractBOM[$ContractComponent_ID]); + } + + +/*Requirments Methods */ + +function Add_To_ContractRequirements($Requirment, $Quantity, $CostPerUnit,$ContractReqID){){ + if (isset($Requirment) AND $Quantity!=0 AND $CostPerUnit!=0){ + $this->ContractReqts[$this->RequirementsCounter] = new ContractRequirement($Requirment, $Quantity, $CostPerUnit,$ContractReqID); + $this->RequirementsCounter++; + Return 1; + } + Return 0; + } + + function remove_ContractRequirement($ContractRequirmentID){ + unset($this->ContractReqts[$ContractRequirmentID]); + } + +} /* end of class defintion */ + +Class ContractComponent { + + var $StockID; + var $WorkCentre; + var $Quantity; + var $ItemCost; + var $UOM; + + function ContractComponent ($StockID, $WorkCentre, $Quantity, $ItemCost, $UOM){ + +/* Constructor function to add a new Contract Component object with passed params */ + $this->StockID =$StockID; + $this->WorkCentre = $WorkCentre; + $this->Quantity = $Quantity; + $this->ItemCost= $ItemCost; + $this->UOM = $UOM; + } +} + +Class ContractRequirement { + + var $ContractReqID; /*Used to hold the database ID of the contractreqtID - if an existing contract*/ + var $Requirement; /*The description of the requirement for the contract */ + var $Quantity; + var $CostPerUnit; + + function ContractRequirement ($Requirment, $Quantity, $CostPerUnit,$ContractReqID=0){ + +/* Constructor function to add a new Contract Component object with passed params */ + $this->Requirement =$Requirement; + $this->Quantity = $Quantity; + $this->CostPerUnit = $CostPerUnit; + $this->ItemCost= $ItemCost; + $this->ContractReqID = $ContractReqID; + } +} + + + + +?> \ No newline at end of file Modified: trunk/sql/mysql/upgrade3.11.1-3.12.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-06-06 08:37:57 UTC (rev 3482) +++ trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-06-07 01:06:13 UTC (rev 3483) @@ -168,4 +168,62 @@ ALTER TABLE locations add cashsalecustomer VARCHAR(21) NOT NULL DEFAULT ''; -ALTER TABLE `salestypes` CHANGE COLUMN `sales_type` `sales_type` VARCHAR(40) NOT NULL DEFAULT ''; \ No newline at end of file +SET FOREIGN_KEY_CHECKS=0; +DROP TABLE contracts; +DROP TABLE contractreqts; +DROP TABLE contractbom; +CREATE TABLE `contractbom` ( + contractno int(11) NOT NULL DEFAULT '0', + `stockid` char(20) NOT NULL DEFAULT '', + `workcentreadded` char(5) NOT NULL DEFAULT '', + `quantity` double NOT NULL DEFAULT '1', + PRIMARY KEY (`contractno`,`stockid`,`workcentreadded`), + KEY `Stockid` (`stockid`), + KEY `ContractNo` (`contractno`), + KEY `WorkCentreAdded` (`workcentreadded`), + CONSTRAINT `contractbom_ibfk_1` FOREIGN KEY (`workcentreadded`) REFERENCES `workcentres` (`code`), + CONSTRAINT `contractbom_ibfk_3` FOREIGN KEY (`stockid`) REFERENCES `stockmaster` (`stockid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `contractreqts` ( + `contractreqid` int(11) NOT NULL AUTO_INCREMENT, + `contractno` int(11) NOT NULL DEFAULT '0', + `requirement` varchar(40) NOT NULL DEFAULT '', + `quantity` double NOT NULL DEFAULT '1', + `costperunit` double NOT NULL DEFAULT '0.0000', + PRIMARY KEY (`contractreqid`), + KEY `Contract` (`contractno`), + CONSTRAINT `contractreqts_ibfk_1` FOREIGN KEY (`contractno`) REFERENCES `contracts` (`contractno`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `contracts` ( + `contractno` int(11) NOT NULL DEFAULT '0', + `contractref` varchar(20) NOT NULL DEFAULT '', + `contractdescription` text NOT NULL DEFAULT '', + `debtorno` varchar(10) NOT NULL DEFAULT '', + `branchcode` varchar(10) NOT NULL DEFAULT '', + `status` tinyint NOT NULL DEFAULT 0, + `categoryid` varchar(6) NOT NULL DEFAULT '', + `orderno` int(11) NOT NULL DEFAULT '0', + `margin` double NOT NULL DEFAULT '1', + `wo` int(11) NOT NULL DEFAULT '0', + `requireddate` date NOT NULL DEFAULT '0000-00-00', + `quantityreqd` double NOT NULL DEFAULT '1', + `units` varchar(15) NOT NULL DEFAULT 'Each', + `drawing` varchar(50) NOT NULL DEFAULT '', + `rate` double NOT NULL DEFAULT '1', + PRIMARY KEY (`contractno`), + KEY `ContractRef` (`contractref`), + KEY `OrderNo` (`orderno`), + KEY `CategoryID` (`categoryid`), + KEY `Status` (`status`), + KEY `WO` (`wo`), + KEY `DebtorNo` (`debtorno`,`branchcode`), + CONSTRAINT `contracts_ibfk_1` FOREIGN KEY (`debtorno`, `branchcode`) REFERENCES `custbranch` (`debtorno`, `branchcode`), + CONSTRAINT `contracts_ibfk_2` FOREIGN KEY (`categoryid`) REFERENCES `stockcategory` (`categoryid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +ALTER TABLE `salestypes` CHANGE COLUMN `sales_type` `sales_type` VARCHAR(40) NOT NULL DEFAULT '';>>>>>>> .r3482 Modified: trunk/sql/mysql/weberp-demo.sql =================================================================== --- trunk/sql/mysql/weberp-demo.sql 2010-06-06 08:37:57 UTC (rev 3482) +++ trunk/sql/mysql/weberp-demo.sql 2010-06-07 01:06:13 UTC (rev 3483) @@ -6168,9 +6168,6 @@ INSERT INTO `periods` VALUES (22,'2009-03-31'); -INSERT INTO `prices` VALUES ('HIT3043-5','DE','USD','','2300.0000',''); - - INSERT INTO `purchdata` VALUES ('BINGO','HIT3043-5','1235.0000','',1,'',5,1,'2009-09-18',''); INSERT INTO `purchdata` VALUES ('CRUISE','DVD-UNSG2','200.0000','10 Pack',10,'',5,1,'2009-09-18',''); Modified: trunk/sql/mysql/weberp-new.sql =================================================================== --- trunk/sql/mysql/weberp-new.sql 2010-06-06 08:37:57 UTC (rev 3482) +++ trunk/sql/mysql/weberp-new.sql 2010-06-07 01:06:13 UTC (rev 3483) @@ -1,4 +1,4 @@ -CREATE DATABASE IF NOT EXISTS MyCompanyName DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci; +cCREATE DATABASE IF NOT EXISTS MyCompanyName DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci; USE MyCompanyName; SET FOREIGN_KEY_CHECKS=0; @@ -259,20 +259,16 @@ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `contractbom` ( - `contractref` char(20) NOT NULL DEFAULT '', - `component` char(20) NOT NULL DEFAULT '', + contractno int(11) NOT NULL DEFAULT '0', + `stockid` char(20) NOT NULL DEFAULT '', `workcentreadded` char(5) NOT NULL DEFAULT '', - `loccode` char(5) NOT NULL DEFAULT '', `quantity` double NOT NULL DEFAULT '1', - PRIMARY KEY (`contractref`,`component`,`workcentreadded`,`loccode`), - KEY `Component` (`component`), - KEY `LocCode` (`loccode`), - KEY `ContractRef` (`contractref`), + PRIMARY KEY (`contractno`,`stockid`,`workcentreadded`), + KEY `Stockid` (`stockid`), + KEY `ContractNo` (`contractno`), KEY `WorkCentreAdded` (`workcentreadded`), - KEY `WorkCentreAdded_2` (`workcentreadded`), CONSTRAINT `contractbom_ibfk_1` FOREIGN KEY (`workcentreadded`) REFERENCES `workcentres` (`code`), - CONSTRAINT `contractbom_ibfk_2` FOREIGN KEY (`loccode`) REFERENCES `locations` (`loccode`), - CONSTRAINT `contractbom_ibfk_3` FOREIGN KEY (`component`) REFERENCES `stockmaster` (`stockid`) + CONSTRAINT `contractbom_ibfk_3` FOREIGN KEY (`stockid`) REFERENCES `stockmaster` (`stockid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -281,13 +277,13 @@ /*!40101 SET character_set_client = utf8 */; CREATE TABLE `contractreqts` ( `contractreqid` int(11) NOT NULL AUTO_INCREMENT, - `contract` char(20) NOT NULL DEFAULT '', - `component` char(40) NOT NULL DEFAULT '', + `contractno` int(11) NOT NULL DEFAULT '0', + `requirement` varchar(40) NOT NULL DEFAULT '', `quantity` double NOT NULL DEFAULT '1', - `priceperunit` decimal(20,4) NOT NULL DEFAULT '0.0000', + `costperunit` double NOT NULL DEFAULT '0.0000', PRIMARY KEY (`contractreqid`), - KEY `Contract` (`contract`), - CONSTRAINT `contractreqts_ibfk_1` FOREIGN KEY (`contract`) REFERENCES `contracts` (`contractref`) + KEY `Contract` (`contractno`), + CONSTRAINT `contractreqts_ibfk_1` FOREIGN KEY (`contractno`) REFERENCES `contracts` (`contractno`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -295,35 +291,30 @@ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `contracts` ( + `contractno` int(11) NOT NULL DEFAULT '0', `contractref` varchar(20) NOT NULL DEFAULT '', - `contractdescription` varchar(50) NOT NULL DEFAULT '', + `contractdescription` text NOT NULL DEFAULT '', `debtorno` varchar(10) NOT NULL DEFAULT '', `branchcode` varchar(10) NOT NULL DEFAULT '', - `status` varchar(10) NOT NULL DEFAULT 'Quotation', + `status` tinyint NOT NULL DEFAULT 0, `categoryid` varchar(6) NOT NULL DEFAULT '', - `typeabbrev` char(2) NOT NULL DEFAULT '', `orderno` int(11) NOT NULL DEFAULT '0', - `quotedpricefx` decimal(20,4) NOT NULL DEFAULT '0.0000', - `margin` double NOT NULL DEFAULT '1', - `woref` varchar(20) NOT NULL DEFAULT '', - `requireddate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `canceldate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `margin` double NOT NULL DEFAULT '1', + `wo` int(11) NOT NULL DEFAULT '0', + `requireddate` date NOT NULL DEFAULT '0000-00-00', `quantityreqd` double NOT NULL DEFAULT '1', - `specifications` longblob NOT NULL, - `datequoted` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `units` varchar(15) NOT NULL DEFAULT 'Each', - `drawing` longblob NOT NULL, + `drawing` varchar(50) NOT NULL DEFAULT '', `rate` double NOT NULL DEFAULT '1', - PRIMARY KEY (`contractref`), + PRIMARY KEY (`contractno`), + KEY `ContractRef` (`contractref`), KEY `OrderNo` (`orderno`), KEY `CategoryID` (`categoryid`), KEY `Status` (`status`), - KEY `TypeAbbrev` (`typeabbrev`), - KEY `WORef` (`woref`), + KEY `WO` (`wo`), KEY `DebtorNo` (`debtorno`,`branchcode`), CONSTRAINT `contracts_ibfk_1` FOREIGN KEY (`debtorno`, `branchcode`) REFERENCES `custbranch` (`debtorno`, `branchcode`), - CONSTRAINT `contracts_ibfk_2` FOREIGN KEY (`categoryid`) REFERENCES `stockcategory` (`categoryid`), - CONSTRAINT `contracts_ibfk_3` FOREIGN KEY (`typeabbrev`) REFERENCES `salestypes` (`typeabbrev`) + CONSTRAINT `contracts_ibfk_2` FOREIGN KEY (`categoryid`) REFER... [truncated message content] |
From: <tim...@us...> - 2010-06-07 19:58:27
|
Revision: 3484 http://web-erp.svn.sourceforge.net/web-erp/?rev=3484&view=rev Author: tim_schofield Date: 2010-06-07 19:58:17 +0000 (Mon, 07 Jun 2010) Log Message: ----------- Various changes to correctly deal with suppliers uom plus layout changes to puirchase orders and goods received notes Modified Paths: -------------- trunk/GoodsReceived.php trunk/PDFGrn.php trunk/PO_Items.php trunk/PO_PDFPurchOrder.php trunk/companies/weberpdemo/FormDesigns/GoodsReceived.xml trunk/companies/weberpdemo/FormDesigns/PurchaseOrder.xml trunk/doc/Change.log.html trunk/includes/DefinePOClass.php trunk/includes/PDFGrnHeader.inc trunk/includes/PO_ReadInOrder.inc Modified: trunk/GoodsReceived.php =================================================================== --- trunk/GoodsReceived.php 2010-06-07 01:06:13 UTC (rev 3483) +++ trunk/GoodsReceived.php 2010-06-07 19:58:17 UTC (rev 3484) @@ -129,15 +129,17 @@ } else { $uom=$LnItm->Units; } + $conversionfactor=$uomrow['conversionfactor']; } else { $uom=$LnItm->Units; + $conversionfactor=1; } //Now Display LineItem echo '<td><font size=2>' . $LnItm->StockID . '</font></td>'; echo '<td><font size=2>' . $LnItm->ItemDescription . '</td>'; echo '<td class=number><font size=2>' . $DisplayQtyOrd . '</td>'; - echo '<td><font size=2>' . $uom . '</td>'; + echo '<td><font size=2>' . $LnItm->uom . '</td>'; echo '<td class=number><font size=2>' . $DisplayQtyRec . '</td>'; echo '<td class=number><font size=2>'; @@ -412,7 +414,7 @@ '" . $_POST['DefaultReceivedDate'] . "', " . $OrderLine->ReceiveQty . ", '" . $_SESSION['PO']->SupplierID . "', - " . $CurrentStandardCost . ')'; + " . $CurrentStandardCost *$conversionfactor. ')'; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('A GRN record could not be inserted') . '. ' . _('This receipt of goods has not been processed because'); $DbgMsg = _('The following SQL to insert the GRN record was used'); @@ -477,7 +479,7 @@ 25, " . $GRN . ", '" . $_SESSION['PO']->Location . "', '" . $_POST['DefaultReceivedDate'] . "', - " . $LocalCurrencyPrice . ", + " . $LocalCurrencyPrice / $conversionfactor . ", " . $PeriodNo . ", '" . $_SESSION['PO']->SupplierID . " (" . $_SESSION['PO']->SupplierName . ") - " .$_SESSION['PO']->OrderNo . "', " . $OrderLine->ReceiveQty . ", Modified: trunk/PDFGrn.php =================================================================== --- trunk/PDFGrn.php 2010-06-07 01:06:13 UTC (rev 3483) +++ trunk/PDFGrn.php 2010-06-07 19:58:17 UTC (rev 3484) @@ -28,14 +28,21 @@ include('includes/PDFStarter.php'); $pdf->addInfo('Title', _('Goods Received Note') ); -include('includes/PDFGrnHeader.inc'); - if ($GRNNo=='Preview') { $ListCount = 1; // UldisN } else { - $sql='SELECT itemcode, grnno, deliverydate, itemdescription, qtyrecd, supplierid from grns where grnbatch='.$GRNNo; + $sql='SELECT grns.itemcode, + grns.grnno, + grns.deliverydate, + grns.itemdescription, + grns.qtyrecd, + grns.supplierid + FROM grns + WHERE grnbatch='.$GRNNo; $result=DB_query($sql, $db); $ListCount = DB_num_rows($result); // UldisN + + include('includes/PDFGrnHeader.inc'); } $counter=1; $YPos=$FormDesign->Data->y; @@ -47,15 +54,57 @@ $Quantity='XXXXX.XX'; $Supplier=str_pad('',25,'x'); } else { + $sql='SELECT orddate from purchorders WHERE orderno='.$_GET['PONo']; + $purchorderresult=DB_query($sql, $db); + $purchorderdate=DB_fetch_array($purchorderresult); $myrow=DB_fetch_array($result); + $datesql='SELECT max(effectivefrom) FROM purchdata WHERE supplierno="'.$myrow['supplierid'].'" AND stockid="'.$myrow['itemcode'].'" AND effectivefrom<="'.$purchorderdate[0].'"'; + $dateresult=DB_query($datesql, $db); + $date=DB_fetch_row($dateresult); + if ($date[0]!='') { + $sql='SELECT unitsofmeasure.unitname, + suppliers_partno, + conversionfactor + FROM purchdata + LEFT JOIN unitsofmeasure + ON purchdata.suppliersuom=unitsofmeasure.unitid + WHERE supplierno="'.$myrow['supplierid'].'" + AND stockid="'.$myrow['itemcode'].'" + AND effectivefrom="'.$date[0].'"'; + $purchdataresult=DB_query($sql, $db); + $myrow2=DB_fetch_array($purchdataresult); + } else { + $sql='SELECT units as unitname, stockid as suppliers_partno, 1 as conversionfactor FROM stockmaster WHERE stockid="'.$StockID.'"'; + $purchdataresult=DB_query($sql, $db); + $myrow2=DB_fetch_array($purchdataresult); + } $StockID=$myrow[0]; $GRNNo=$myrow[1]; $Date=ConvertSQLDate($myrow[2]); $Description=$myrow[3]; $Quantity=$myrow[4]; $SupplierID=$myrow[5]; + if ($myrow2['unitname']=='') { + $sql='SELECT units + FROM stockmaster + WHERE stockid="'.$myrow['itemcode'].'"'; + $uomresult=DB_query($sql, $db); + $uomrow=DB_fetch_array($uomresult); + $units=$uomrow['units']; + } else { + $units=$myrow2['unitname']; + } + $sql='SELECT units, + decimalplaces + FROM stockmaster + WHERE stockid="'.$myrow['itemcode'].'"'; + $uomresult=DB_query($sql, $db); + $uomrow=DB_fetch_array($uomresult); + $stockunits=$uomrow['units']; - $sql='select suppname from suppliers where supplierid="'.$SupplierID.'"'; + $sql='SELECT suppname + FROM suppliers + WHERE supplierid="'.$SupplierID.'"'; $supplierresult=DB_query($sql, $db); $suppliermyrow=DB_fetch_array($supplierresult); $Supplier=$suppliermyrow[0]; @@ -64,10 +113,18 @@ $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column1->x,$Page_Height-$YPos,$FormDesign->Data->Column1->Length,$FormDesign->Data->Column1->FontSize, $StockID); $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column2->x,$Page_Height-$YPos,$FormDesign->Data->Column2->Length,$FormDesign->Data->Column2->FontSize, $Description); $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column3->x,$Page_Height-$YPos,$FormDesign->Data->Column3->Length,$FormDesign->Data->Column3->FontSize, $Date); - $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column4->x,$Page_Height-$YPos,$FormDesign->Data->Column4->Length,$FormDesign->Data->Column4->FontSize, $Supplier); - $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column5->x,$Page_Height-$YPos,$FormDesign->Data->Column5->Length,$FormDesign->Data->Column5->FontSize, $Quantity); + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column4->x,$Page_Height-$YPos,$FormDesign->Data->Column4->Length,$FormDesign->Data->Column4->FontSize, number_format($Quantity,$uomrow['decimalplaces']), 'right'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column5->x,$Page_Height-$YPos,$FormDesign->Data->Column5->Length,$FormDesign->Data->Column5->FontSize, $units, 'left'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column6->x,$Page_Height-$YPos,$FormDesign->Data->Column6->Length,$FormDesign->Data->Column6->FontSize, number_format($Quantity*$myrow2['conversionfactor'],$uomrow['decimalplaces']), 'right'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column7->x,$Page_Height-$YPos,$FormDesign->Data->Column7->Length,$FormDesign->Data->Column7->FontSize, $stockunits, 'left'); $YPos += $line_height; $counter++; + if ($YPos >= $FormDesign->LineAboveFooter->starty){ + /* We reached the end of the page so finsih off the page and start a newy */ + $PageNumber++; + $YPos=$FormDesign->Data->y; + include ('includes/PDFGrnHeader.inc'); + } //end if need a new page headed up } $LeftOvers = $pdf->addText($FormDesign->ReceiptDate->x,$Page_Height-$FormDesign->ReceiptDate->y,$FormDesign->ReceiptDate->FontSize, _('Date of Receipt: ').$Date); Modified: trunk/PO_Items.php =================================================================== --- trunk/PO_Items.php 2010-06-07 01:06:13 UTC (rev 3483) +++ trunk/PO_Items.php 2010-06-07 19:58:17 UTC (rev 3484) @@ -753,12 +753,15 @@ purchdata.conversionfactor, purchdata.supplierdescription, purchdata.suppliersuom, + unitsofmeasure.unitname, purchdata.suppliers_partno, purchdata.leadtime FROM stockcategory, chartmaster, stockmaster LEFT JOIN purchdata ON stockmaster.stockid = purchdata.stockid + LEFT JOIN unitsofmeasure + ON purchdata.suppliersuom=unitsofmeasure.unitid AND purchdata.supplierno = '" . $_SESSION['PO'.$identifier]->SupplierID . "' WHERE chartmaster.accountcode = stockcategory.stockact AND stockcategory.categoryid = stockmaster.categoryid @@ -810,11 +813,12 @@ $myrow['accountname'], $myrow['decimalplaces'], $ItemCode, - $myrow['suppliersuom'], + $myrow['unitname'], $myrow['suppliers_partno'], $Quantity*$myrow['price'], $myrow['leadtime'], '', + 0, $myrow['netweight'], $myrow['kgs'], '', @@ -841,8 +845,8 @@ $myrow['accountname'], 0, $ItemCode, + $myrow['units'], '', - '', 0, 0, '', @@ -850,6 +854,7 @@ 0, 0, 0, + 0, 0 ); } @@ -995,8 +1000,6 @@ echo '<div class=centre><input type=submit name="EnterLine" value="Enter Item"></div>'; } -echo '<hr>'; - /* Now show the stock item selection search stuff below */ if (!isset($_GET['Edit'])) { @@ -1010,7 +1013,7 @@ $DbgMsg = _('The SQL used to retrieve the category details but failed was'); $result1 = DB_query($sql,$db,$ErrMsg,$DbgMsg); - echo '<table><tr><p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/magnifier.png" title="' . + 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'>"; @@ -1057,7 +1060,7 @@ if (isset($SearchResult)) { - echo "<table cellpadding=1 colspan=7 border=1>"; + echo "<table cellpadding=1 colspan=7>"; $tableheader = "<tr> <th>" . _('Code') . "</th> @@ -1090,8 +1093,12 @@ $ImageSource = '<i>'._('No Image').'</i>'; } - $uomsql='SELECT conversionfactor, suppliersuom + $uomsql='SELECT conversionfactor, + suppliersuom, + unitsofmeasure.unitname FROM purchdata + LEFT JOIN unitsofmeasure + ON purchdata.suppliersuom=unitsofmeasure.unitid WHERE supplierno="'.$_SESSION['PO'.$identifier]->SupplierID.'" AND stockid="'.$myrow['stockid'].'"'; @@ -1099,24 +1106,20 @@ if (DB_num_rows($uomresult)>0) { $uomrow=DB_fetch_array($uomresult); if (strlen($uomrow['suppliersuom'])>0) { - $uom=$uomrow['suppliersuom']; + $uom=$uomrow['unitname']; } else { $uom=$myrow['units']; } } else { $uom=$myrow['units']; } - printf("<td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td><input class='number' type='text' size=6 value=0 name='qty%s'></td> - </tr>", - $myrow['stockid'], - $myrow['description'], - $uom, - $ImageSource, - $myrow['stockid']); + echo "<td>".$myrow['stockid']."</td> + <td>".$myrow['description']."</td> + <td>".$uom."</td> + <td>".$ImageSource."</td> + <td><input class='number' type='text' size=6 value=0 name='qty".$myrow['stockid']."'></td> + <td><input type='hidden' size=6 value=".$uom." name=uom></td> + </tr>"; $PartsDisplayed++; if ($PartsDisplayed == $Maximum_Number_Of_Parts_To_Show){ @@ -1140,4 +1143,4 @@ echo '</form>'; include('includes/footer.inc'); -?> +?> \ No newline at end of file Modified: trunk/PO_PDFPurchOrder.php =================================================================== --- trunk/PO_PDFPurchOrder.php 2010-06-07 01:06:13 UTC (rev 3483) +++ trunk/PO_PDFPurchOrder.php 2010-06-07 19:58:17 UTC (rev 3484) @@ -255,6 +255,7 @@ if ($YPos-$line_height <= $Bottom_Margin){ /* We reached the end of the page so finsih off the page and start a newy */ $PageNumber++; + $YPos=$Page_Height - $FormDesign->Data->y; include ('includes/PO_PDFOrderPageHeader.inc'); } //end if need a new page headed up /*increment a line down for the next line item */ @@ -268,7 +269,7 @@ } //end while there are line items to print out if ($YPos-$line_height <= $Bottom_Margin){ // need to ensure space for totals $PageNumber++; - include ('includes/PO_PDFOrderPageHeader.inc'); + include ('includes/PO_PDFOrderPageHeader.inc'); } //end if need a new page headed up if ($_POST['ShowAmounts']=='Yes'){ $DisplayOrderTotal = number_format($OrderTotal,2); Modified: trunk/companies/weberpdemo/FormDesigns/GoodsReceived.xml =================================================================== --- trunk/companies/weberpdemo/FormDesigns/GoodsReceived.xml 2010-06-07 01:06:13 UTC (rev 3483) +++ trunk/companies/weberpdemo/FormDesigns/GoodsReceived.xml 2010-06-07 19:58:17 UTC (rev 3484) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <form name="Goods Received Note"> - <PaperSize name="Paper size">A4</PaperSize> + <PaperSize name="Paper size">A4_Landscape</PaperSize> <LineHeight name="Line height">12</LineHeight> <logo type="image" name="Logo" id="Logo"> <x>20</x> @@ -8,30 +8,65 @@ <width>0</width> <height>60</height> </logo> + <SupplierName type="SimpleText" name="Supplier name" id="SupplierName"> + <FontSize>10</FontSize> + <x>325</x> + <y>30</y> + </SupplierName> + <SupplierAddress1 type="SimpleText" name="Supplier Address1" id="SupplierAddress1"> + <FontSize>10</FontSize> + <x>325</x> + <y>42</y> + </SupplierAddress1> + <SupplierAddress2 type="SimpleText" name="Supplier Address2" id="SupplierAddress2"> + <FontSize>10</FontSize> + <x>325</x> + <y>54</y> + </SupplierAddress2> + <SupplierAddress3 type="SimpleText" name="Supplier Address3" id="SupplierAddress3"> + <FontSize>10</FontSize> + <x>325</x> + <y>66</y> + </SupplierAddress3> + <SupplierAddress4 type="SimpleText" name="Supplier Address4" id="SupplierAddress4"> + <FontSize>10</FontSize> + <x>325</x> + <y>78</y> + </SupplierAddress4> + <SupplierAddress5 type="SimpleText" name="Supplier Address5" id="SupplierAddress5"> + <FontSize>10</FontSize> + <x>325</x> + <y>80</y> + </SupplierAddress5> + <SupplierAddress6 type="SimpleText" name="Supplier Address6" id="SupplierAddress6"> + <FontSize>10</FontSize> + <x>325</x> + <y>92</y> + </SupplierAddress6> <CompanyName type="SimpleText" name="Company name" id="CompanyName"> <FontSize>10</FontSize> - <x>425</x> + <x>625</x> <y>30</y> </CompanyName> <GRNNumber type="SimpleText" name="GRN Number" id="GRNNumber"> <FontSize>10</FontSize> - <x>425</x> + <x>625</x> <y>48</y> </GRNNumber> <OrderNumber type="SimpleText" name="Order Number" id="OrderNumber"> <FontSize>10</FontSize> - <x>425</x> + <x>625</x> <y>66</y> </OrderNumber> <PrintDate type="SimpleText" name="Date Printed" id="PrintDate"> <FontSize>10</FontSize> - <x>425</x> + <x>625</x> <y>84</y> </PrintDate> <HeaderRectangle type="Rectangle" name="Header rectangle" id="HeaderRectangle"> <x>40</x> <y>114</y> - <width>525</width> + <width>772</width> <height>24</height> </HeaderRectangle> <Headings type="ElementArray" name="Column headings"> @@ -47,26 +82,58 @@ </Column2> <Column3 type="SimpleText" name="Heading 3" id="Heading3"> <FontSize>10</FontSize> - <x>291</x> + <x>356</x> <y>126</y> </Column3> - <Column4 type="SimpleText" name="Heading 4" id="Heading4"> + <Column4 type="MultiLineText" name="Heading 4" id="Heading4"> <FontSize>10</FontSize> - <x>391</x> - <y>126</y> + <x>486</x> + <y>136</y> + <Length>100</Length> </Column4> - <Column5 type="SimpleText" name="Heading 5" id="Heading5"> + <Column5 type="MultiLineText" name="Heading 5" id="Heading5"> <FontSize>10</FontSize> - <x>491</x> - <y>126</y> + <x>616</x> + <y>136</y> + <Length>100</Length> </Column5> </Headings> <DataRectangle type="Rectangle" name="Data rectangle" id="DataRectangle"> <x>40</x> <y>138</y> - <width>525</width> - <height>674</height> + <width>772</width> + <height>430</height> </DataRectangle> + <LineAboveFooter type="Line" name="Line Above Footer" id="LineAboveFooter"> + <startx>40</startx> + <starty>530</starty> + <endx>812</endx> + <endy>530</endy> + </LineAboveFooter> + <Column1 type="Line" name="Column 1" id="Column1"> + <startx>114</startx> + <starty>114</starty> + <endx>114</endx> + <endy>530</endy> + </Column1> + <Column3 type="Line" name="Column 3" id="Column3"> + <startx>354</startx> + <starty>114</starty> + <endx>354</endx> + <endy>530</endy> + </Column3> + <Column4 type="Line" name="Column 4" id="Column4"> + <startx>489</startx> + <starty>114</starty> + <endx>489</endx> + <endy>530</endy> + </Column4> + <Column5 type="Line" name="Column 5" id="Column5"> + <startx>616</startx> + <starty>114</starty> + <endx>616</endx> + <endy>530</endy> + </Column5> <Data type="ElementArray" name="Column Data"> <y type="StartLine" name="Y co-ordinate of first data line" id="DataStartLine">156</y> <Column1 type="DataText" name="Column 1" id="Data1"> @@ -81,28 +148,38 @@ </Column2> <Column3 type="DataText" name="Column 3" id="Data3"> <FontSize>10</FontSize> - <x>291</x> + <x>356</x> <Length>85</Length> </Column3> <Column4 type="DataText" name="Column 4" id="Data4"> <FontSize>10</FontSize> - <x>356</x> - <Length>150</Length> + <x>506</x> + <Length>60</Length> </Column4> <Column5 type="DataText" name="Column 5" id="Data5"> <FontSize>10</FontSize> - <x>506</x> + <x>568</x> + <Length>30</Length> + </Column5> + <Column6 type="DataText" name="Column 6" id="Data6"> + <FontSize>10</FontSize> + <x>638</x> <Length>60</Length> - </Column5> + </Column6> + <Column7 type="DataText" name="Column 7" id="Data7"> + <FontSize>10</FontSize> + <x>700</x> + <Length>30</Length> + </Column7> </Data> <ReceiptDate type="SimpleText" name="Date Received" id="ReceiptDate"> <FontSize>10</FontSize> - <x>40</x> - <y>722</y> + <x>300</x> + <y>550</y> </ReceiptDate> <SignedFor type="SimpleText" name="Signed Fror" id="SignedFor"> <FontSize>10</FontSize> - <x>40</x> - <y>760</y> + <x>50</x> + <y>550</y> </SignedFor> </form> Modified: trunk/companies/weberpdemo/FormDesigns/PurchaseOrder.xml =================================================================== --- trunk/companies/weberpdemo/FormDesigns/PurchaseOrder.xml 2010-06-07 01:06:13 UTC (rev 3483) +++ trunk/companies/weberpdemo/FormDesigns/PurchaseOrder.xml 2010-06-07 19:58:17 UTC (rev 3484) @@ -21,7 +21,7 @@ <PageNumber type="SimpleText" name="Page number" id="PageNumber"> <FontSize>10</FontSize> <x>762</x> - <y>70</y> + <y>30</y> </PageNumber> <TaxAuthority type="SimpleText" name="Tax Authority" id="TaxAuthority"> <FontSize>10</FontSize> @@ -79,37 +79,37 @@ <Caption type="SimpleText" name="Caption" id="DeliveryAddressCaption"> <FontSize>12</FontSize> <x>448</x> - <y>154</y> + <y>142</y> </Caption> <Line1 type="SimpleText" name="Line 1" id="DeliveryAddress1"> <FontSize>12</FontSize> <x>448</x> - <y>166</y> + <y>154</y> </Line1> <Line2 type="SimpleText" name="Line 2" id="DeliveryAddress2"> <FontSize>12</FontSize> <x>448</x> - <y>178</y> + <y>166</y> </Line2> <Line3 type="SimpleText" name="Line 3" id="DeliveryAddress3"> <FontSize>12</FontSize> <x>448</x> - <y>190</y> + <y>178</y> </Line3> <Line4 type="SimpleText" name="Line 4" id="DeliveryAddress4"> <FontSize>12</FontSize> <x>448</x> - <y>202</y> + <y>190</y> </Line4> <Line5 type="SimpleText" name="Line 5" id="DeliveryAddress5"> <FontSize>12</FontSize> <x>448</x> - <y>214</y> + <y>202</y> </Line5> <Line6 type="SimpleText" name="Line 6" id="DeliveryAddress6"> <FontSize>12</FontSize> <x>448</x> - <y>226</y> + <y>214</y> </Line6> </DeliveryAddress> <DeliveryAddressBox type="CurvedRectangle" name="Delivery address box" id="DeliveryAddressBox"> @@ -122,44 +122,44 @@ <SupplierName type="SimpleText" name="Supplier name" id="SupplierName"> <FontSize>12</FontSize> <x>41</x> - <y>246</y> + <y>226</y> </SupplierName> <SupplierAddress type="ElementArray" name="Supplier address"> <Line1 type="SimpleText" name="Line 1" id="SupplierAddress1"> <FontSize>12</FontSize> <x>71</x> - <y>262</y> + <y>238</y> </Line1> <Line2 type="SimpleText" name="Line 2" id="SupplierAddress2"> <FontSize>12</FontSize> <x>71</x> - <y>274</y> + <y>250</y> </Line2> <Line3 type="SimpleText" name="Line 3" id="SupplierAddress3"> <FontSize>12</FontSize> <x>71</x> - <y>286</y> + <y>262</y> </Line3> <Line4 type="SimpleText" name="Line 4" id="SupplierAddress4"> <FontSize>12</FontSize> <x>71</x> - <y>298</y> + <y>274</y> </Line4> </SupplierAddress> <OrderDate type="SimpleText" name="Order date" id="OrderDate"> <FontSize>12</FontSize> <x>446</x> - <y>262</y> + <y>250</y> </OrderDate> <Initiator type="SimpleText" name="Order initiator" id="Initiator"> <FontSize>12</FontSize> <x>446</x> - <y>278</y> + <y>264</y> </Initiator> <PaymentTerms type="SimpleText" name="Payment terms" id="PaymentTerms"> <FontSize>12</FontSize> <x>446</x> - <y>290</y> + <y>278</y> </PaymentTerms> <Comments type="MultiLineText" name="Comments" id="Comments"> <FontSize>12</FontSize> @@ -170,7 +170,7 @@ <Currency type="SimpleText" name="Currency text" id="Currency"> <FontSize>12</FontSize> <x>40</x> - <y>312</y> + <y>300</y> </Currency> <HeaderRectangle type="Rectangle" name="Header rectangle" id="HeaderRectangle"> <x>40</x> Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-06-07 01:06:13 UTC (rev 3483) +++ trunk/doc/Change.log.html 2010-06-07 19:58:17 UTC (rev 3484) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>07/06/10 Tim: Various changes to correctly deal with suppliers uom plus layout changes to puirchase orders and goods received notes</p> <p>06/06/10 Zhiguo Yuan: WorkOrderReceive.php - Change to make rollup costs change when more labour or overheadcosts change</p> <p>03/06/10 Phil: Added a bit of error trapping to ensure customer/branch set up when going into CounterSales.php</p> <p>03/06/10 Otandeka: Locations.php used explode function rather than substr function to split the cashsalecustomer to get Branch and Debtorno codes - also changed format to just a hypen between debtorno and branchcode</p> Modified: trunk/includes/DefinePOClass.php =================================================================== --- trunk/includes/DefinePOClass.php 2010-06-07 01:06:13 UTC (rev 3483) +++ trunk/includes/DefinePOClass.php 2010-06-07 19:58:17 UTC (rev 3484) @@ -68,7 +68,7 @@ var $paymentterms; var $contact; var $port; - + function PurchOrder(){ /*Constructor function initialises a new purchase order object */ $this->LineItems = array(); @@ -96,6 +96,7 @@ $DecimalPlaces=2, $itemno, $uom, + $leadtime, $suppliers_partno, $subtotal_amount, $package, @@ -119,14 +120,15 @@ $GLCode, $ReqDelDate, $ShiptRef, + 0, $JobRef, - 0, $QtyInv, $QtyRecd, $GLActName, $DecimalPlaces, $itemno, $uom, + $leadtime, $suppliers_partno, $subtotal_amount, $package, @@ -171,7 +173,7 @@ $this->LineItems[$LineNo]->ReqDelDate = $ReqDelDate; $this->LineItems[$LineNo]->ShiptRef = $ShiptRef; $this->LineItems[$LineNo]->JobRef = $JobRef; - $this->LineItems[$LineNo]->itemno = $itemno; + $this->LineItems[$LineNo]->itemno = $itemno; $this->LineItems[$LineNo]->uom = $uom; $this->LineItems[$LineNo]->suppliers_partno = $suppliers_partno; $this->LineItems[$LineNo]->subtotal_amount = $subtotal_amount; @@ -211,7 +213,7 @@ } return 0; } - + function Order_Value() { $TotalValue=0; foreach ($this->LineItems as $OrderedItems) { @@ -245,6 +247,7 @@ Var $suppliers_partno; Var $subtotal_amount; Var $leadtime; + Var $package; Var $pcunit; Var $nw; Var $gw; @@ -258,35 +261,35 @@ Var $SerialItems; /*An array holding the batch/serial numbers and quantities in each batch*/ function LineDetails ( - $LineNo, - $StockItem, - $Serialised, - $Controlled, - $Qty, - $ItemDescr, - $Prc, - $UOM, - $GLCode, - $ReqDelDate, - $ShiptRef =0, + $LineNo, + $StockItem, + $Serialised, + $Controlled, + $Qty, + $ItemDescr, + $Prc, + $UOM, + $GLCode, + $ReqDelDate, + $ShiptRef =0, $Completed, - $JobRef, - $QtyInv, - $QtyRecd, - $GLActName, + $JobRef, + $QtyInv, + $QtyRecd, + $GLActName, $DecimalPlaces, $itemno, $uom, $suppliers_partno, $subtotal_amount, $leadtime, + $package, $pcunit, $nw, $gw, $cuft, $total_quantity, $total_amount) - { /* Constructor function to add a new LineDetail object with passed params */ @@ -305,7 +308,7 @@ $this->GLCode = $GLCode; $this->JobRef = $JobRef; $this->itemno = $itemno; - $this->uom = $uom; + $this->uom = $uom; $this->suppliers_partno = $suppliers_partno; $this->subtotal_amount = $subtotal_amount; $this->leadtime = $leadtime; Modified: trunk/includes/PDFGrnHeader.inc =================================================================== --- trunk/includes/PDFGrnHeader.inc 2010-06-07 01:06:13 UTC (rev 3483) +++ trunk/includes/PDFGrnHeader.inc 2010-06-07 19:58:17 UTC (rev 3484) @@ -5,8 +5,32 @@ $pdf->newPage(); } +$sql='SELECT suppliers.supplierid, + suppname, + address1, + address2 , + address3, + address4, + address5, + address6 + FROM suppliers + LEFT JOIN grns + ON grns.supplierid=suppliers.supplierid + WHERE grnbatch="'.$GRNNo.'"'; +$supplierresult=DB_query($sql, $db); +$supplierrow=DB_fetch_array($supplierresult); + $pdf->addJpegFromFile($_SESSION['LogoFile'] ,$FormDesign->logo->x,$Page_Height-$FormDesign->logo->y,$FormDesign->logo->width,$FormDesign->logo->height); +$LeftOvers = $pdf->addText($FormDesign->SupplierName->x,$Page_Height-$FormDesign->SupplierName->y,$FormDesign->SupplierName->FontSize,$supplierrow['suppname']); +$LeftOvers = $pdf->addText($FormDesign->SupplierAddress1->x,$Page_Height-$FormDesign->SupplierAddress1->y,$FormDesign->SupplierAddress1->FontSize,$supplierrow['address1']); +$LeftOvers = $pdf->addText($FormDesign->SupplierAddress2->x,$Page_Height-$FormDesign->SupplierAddress2->y,$FormDesign->SupplierAddress2->FontSize,$supplierrow['address2']); +$LeftOvers = $pdf->addText($FormDesign->SupplierAddress3->x,$Page_Height-$FormDesign->SupplierAddress3->y,$FormDesign->SupplierAddress3->FontSize,$supplierrow['address3']); +$LeftOvers = $pdf->addText($FormDesign->SupplierAddress4->x,$Page_Height-$FormDesign->SupplierAddress4->y,$FormDesign->SupplierAddress4->FontSize,$supplierrow['address4']); +$LeftOvers = $pdf->addText($FormDesign->SupplierAddress5->x,$Page_Height-$FormDesign->SupplierAddress5->y,$FormDesign->SupplierAddress5->FontSize,$supplierrow['address5']); +$LeftOvers = $pdf->addText($FormDesign->SupplierAddress6->x,$Page_Height-$FormDesign->SupplierAddress6->y,$FormDesign->SupplierAddress6->FontSize,$supplierrow['address6']); + + $LeftOvers = $pdf->addText($FormDesign->CompanyName->x,$Page_Height-$FormDesign->CompanyName->y,$FormDesign->CompanyName->FontSize,$_SESSION['CompanyRecord']['coyname']); $LeftOvers = $pdf->addText($FormDesign->GRNNumber->x,$Page_Height-$FormDesign->GRNNumber->y,$FormDesign->GRNNumber->FontSize, _('GRN number ').' ' . $GRNNo ); $LeftOvers = $pdf->addText($FormDesign->OrderNumber->x,$Page_Height-$FormDesign->OrderNumber->y,$FormDesign->OrderNumber->FontSize, _('PO number ').' ' . $_GET['PONo'] ); @@ -19,11 +43,18 @@ $LeftOvers = $pdf->addText($FormDesign->Headings->Column1->x,$Page_Height - $FormDesign->Headings->Column1->y, $FormDesign->Headings->Column1->FontSize, _('Item Number')); $LeftOvers = $pdf->addText($FormDesign->Headings->Column2->x,$Page_Height - $FormDesign->Headings->Column2->y, $FormDesign->Headings->Column2->FontSize, _('Description')); $LeftOvers = $pdf->addText($FormDesign->Headings->Column3->x,$Page_Height - $FormDesign->Headings->Column3->y, $FormDesign->Headings->Column3->FontSize, _('Date Recd')); -$LeftOvers = $pdf->addText($FormDesign->Headings->Column4->x,$Page_Height - $FormDesign->Headings->Column4->y, $FormDesign->Headings->Column4->FontSize, _('Supplier')); -$LeftOvers = $pdf->addText($FormDesign->Headings->Column5->x,$Page_Height - $FormDesign->Headings->Column5->y, $FormDesign->Headings->Column5->FontSize, _('Quantity')); +$LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column4->x,$Page_Height - $FormDesign->Headings->Column4->y, $FormDesign->Headings->Column4->Length, $FormDesign->Headings->Column4->FontSize, _('Supplier Details'), 'right'); +$LeftOvers = $pdf->addTextWrap($FormDesign->Headings->Column5->x,$Page_Height - $FormDesign->Headings->Column5->y, $FormDesign->Headings->Column5->Length, $FormDesign->Headings->Column5->FontSize, _('Stock Details'), 'right'); /*Draw a rectangle to put the data in */ $pdf->Rectangle($FormDesign->DataRectangle->x, $Page_Height - $FormDesign->DataRectangle->y, $FormDesign->DataRectangle->width,$FormDesign->DataRectangle->height); +$pdf->Line($FormDesign->LineAboveFooter->startx, $Page_Height - $FormDesign->LineAboveFooter->starty, $FormDesign->LineAboveFooter->endx,$Page_Height - $FormDesign->LineAboveFooter->endy); + +$pdf->Line($FormDesign->Column1->startx, $Page_Height - $FormDesign->Column1->starty, $FormDesign->Column1->endx,$Page_Height - $FormDesign->Column1->endy); +$pdf->Line($FormDesign->Column3->startx, $Page_Height - $FormDesign->Column3->starty, $FormDesign->Column3->endx,$Page_Height - $FormDesign->Column3->endy); +$pdf->Line($FormDesign->Column4->startx, $Page_Height - $FormDesign->Column4->starty, $FormDesign->Column4->endx,$Page_Height - $FormDesign->Column4->endy); +$pdf->Line($FormDesign->Column5->startx, $Page_Height - $FormDesign->Column5->starty, $FormDesign->Column5->endx,$Page_Height - $FormDesign->Column5->endy); + $PageNumber++; ?> \ No newline at end of file Modified: trunk/includes/PO_ReadInOrder.inc =================================================================== --- trunk/includes/PO_ReadInOrder.inc 2010-06-07 01:06:13 UTC (rev 3483) +++ trunk/includes/PO_ReadInOrder.inc 2010-06-07 19:58:17 UTC (rev 3484) @@ -145,8 +145,6 @@ stockmaster.controlled, stockmaster.serialised, stockmaster.decimalplaces, - purchdata.suppliersuom, - purchdata.suppliers_partno, subtotal_amount, package, pcunit, @@ -154,8 +152,7 @@ gw, cuft, total_quantity, - total_amount, - MAX(purchdata.effectivefrom) + total_amount FROM purchorderdetails LEFT JOIN stockmaster ON purchorderdetails.itemcode=stockmaster.stockid @@ -163,8 +160,6 @@ ON purchorders.orderno=purchorderdetails.orderno LEFT JOIN chartmaster ON purchorderdetails.glcode=chartmaster.accountcode - LEFT JOIN purchdata - ON purchdata.stockid=purchorderdetails.itemcode AND purchdata.supplierno=purchorders.supplierno WHERE purchorderdetails.completed=0 AND purchorderdetails.orderno =" . $_GET['ModifyOrderNumber'] . ' ORDER BY podetailitem'; @@ -182,16 +177,39 @@ } else { $GLCode = $myrow['glcode']; } - if (is_null($myrow['units'])){ + if (is_null($myrow['units'])){ $Units = _('each'); - } else { + } else { $Units = $myrow['units']; - } - if (is_null($myrow['itemcode'])){ + } + if (is_null($myrow['itemcode'])){ $StockID = ''; - } else { + } else { $StockID = $myrow['itemcode']; - } + } + $datesql='SELECT max(effectivefrom) + FROM purchdata + WHERE supplierno="'.$_SESSION['PO'.$identifier]->SupplierID.'" + AND stockid="'.$StockID.'" + AND effectivefrom<="'.$_SESSION['PO'.$identifier]->Orig_OrderDate.'"'; + $dateresult=DB_query($datesql, $db); + $date=DB_fetch_row($dateresult); + if ($date[0]!='') { + $sql='SELECT unitsofmeasure.unitname, + suppliers_partno + FROM purchdata + LEFT JOIN unitsofmeasure + ON purchdata.suppliersuom=unitsofmeasure.unitid + WHERE supplierno="'.$_SESSION['PO'.$identifier]->SupplierID.'" + AND stockid="'.$StockID.'" + AND effectivefrom="'.$date[0].'"'; + $purchdataresult=DB_query($sql, $db); + $myrow2=DB_fetch_array($purchdataresult); + } else { + $sql='SELECT units as unitname, stockid as suppliers_partno FROM stockmaster WHERE stockid="'.$StockID.'"'; + $purchdataresult=DB_query($sql, $db); + $myrow2=DB_fetch_array($purchdataresult); + } $_SESSION['PO'.$identifier]->add_to_order($_SESSION['PO'.$identifier]->LinesOnOrder+1, $StockID, @@ -211,9 +229,10 @@ $myrow['accountname'], $myrow['decimalplaces'], $myrow['itemno'], - $myrow['suppliersuom'], - $myrow['suppliers_partno'], + $myrow2['unitname'], + $myrow2['suppliers_partno'], $myrow['subtotal_amount'], + 0, $myrow['package'], $myrow['pcunit'], $myrow['nw'], This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-06-08 13:53:34
|
Revision: 3485 http://web-erp.svn.sourceforge.net/web-erp/?rev=3485&view=rev Author: tim_schofield Date: 2010-06-08 13:53:28 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Add option to exclude value information from GRN screen Modified Paths: -------------- trunk/GoodsReceived.php trunk/SystemParameters.php trunk/doc/Change.log.html trunk/sql/mysql/upgrade3.11.1-3.12.sql Modified: trunk/GoodsReceived.php =================================================================== --- trunk/GoodsReceived.php 2010-06-07 19:58:17 UTC (rev 3484) +++ trunk/GoodsReceived.php 2010-06-08 13:53:28 UTC (rev 3485) @@ -71,10 +71,11 @@ <th>' . _('Quantity') . '<br>' . _('Ordered') . '</th> <th>' . _('Units') . '</th> <th>' . _('Already Received') . '</th> - <th>' . _('This Delivery') . '<br>' . _('Quantity') . '</th> - <th>' . _('Price') . '</th> - <th>' . _('Total Value') . '<br>' . _('Received') . '</th>'; + <th>' . _('This Delivery') . '<br>' . _('Quantity') . '</th>'; +if ($_SESSION['ShowValueOnGRN']==1) { + echo '<th>' . _('Price') . '</th><th>' . _('Total Value') . '<br>' . _('Received') . '</th>'; +} echo '<td> </td> </tr>'; @@ -151,8 +152,10 @@ echo '<input type=text class=number name="RecvQty_' . $LnItm->LineNo . '" maxlength=10 size=10 value="' . $LnItm->ReceiveQty . '"></td>'; } - echo '<td class=number><font size=2>' . $DisplayPrice . '</td>'; - echo '<td class=number><font size=2>' . $DisplayLineTotal . '</font></td>'; + if ($_SESSION['ShowValueOnGRN']==1) { + echo '<td class=number><font size=2>' . $DisplayPrice . '</td>'; + echo '<td class=number><font size=2>' . $DisplayLineTotal . '</font></td>'; + } if ($LnItm->Controlled == 1) { @@ -170,9 +173,13 @@ }//If count(LineItems) > 0 $DisplayTotal = number_format($_SESSION['PO']->total,2); -echo '<tr><td colspan=7 class=number><b>' . _('Total value of goods received'). '</b></td> - <td class=number><font size=2><b>'. $DisplayTotal. '</b></font></td> -</tr></table>'; +if ($_SESSION['ShowValueOnGRN']==1) { + echo '<tr><td colspan=7 class=number><b>' . _('Total value of goods received'). '</b></td> + <td class=number><font size=2><b>'. $DisplayTotal. '</b></font></td> + </tr></table>'; +} else { + echo '</table>'; +} $SomethingReceived = 0; if (count($_SESSION['PO']->LineItems)>0){ Modified: trunk/SystemParameters.php =================================================================== --- trunk/SystemParameters.php 2010-06-07 19:58:17 UTC (rev 3484) +++ trunk/SystemParameters.php 2010-06-08 13:53:28 UTC (rev 3485) @@ -198,6 +198,9 @@ if ($_SESSION['DefaultBlindPackNote'] != $_POST['X_DefaultBlindPackNote'] ) { $sql[] = "UPDATE config SET confvalue = '". ($_POST['X_DefaultBlindPackNote'])."' WHERE confname = 'DefaultBlindPackNote'"; } + if ($_SESSION['ShowValueOnGRN'] != $_POST['X_ShowValueOnGRN'] ) { + $sql[] = "UPDATE config SET confvalue = '". ($_POST['X_ShowValueOnGRN'])."' WHERE confname = 'ShowValueOnGRN'"; + } if ($_SESSION['PackNoteFormat'] != $_POST['X_PackNoteFormat'] ) { $sql[] = "UPDATE config SET confvalue = '". ($_POST['X_PackNoteFormat'])."' WHERE confname = 'PackNoteFormat'"; } @@ -431,7 +434,16 @@ <td>' . _('Customer branches can be set by default not to print packing slips with the company logo and address. This is useful for companies that ship to customers customers and to show the source of the shipment would be inappropriate. There is an option on the setup of customer branches to ship blind, this setting is the default applied to all new customer branches') . '</td> </tr>'; +//Show values on GRN +echo '<tr><td>' . _('Show order values on GRN') . ':</td> + <td><select Name="X_ShowValueOnGRN"> + <option '.($_SESSION['ShowValueOnGRN']?'selected ':'').'value="1">'._('Yes').' + <option '.(!$_SESSION['ShowValueOnGRN']?'selected ':'').'value="0">'._('No').' + </select></td> + <td>' . _('Should the value of the purchased stock be shown on the GRN screen') . '</td> + </tr>'; + // DispatchCutOffTime echo '<tr><td>' . _('Dispatch Cut-Off Time') . ':</td> <td><select Name="X_DispatchCutOffTime">'; Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-06-07 19:58:17 UTC (rev 3484) +++ trunk/doc/Change.log.html 2010-06-08 13:53:28 UTC (rev 3485) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>08/06/10 Tim: Add option to exclude value information from GRN screen</p> <p>07/06/10 Tim: Various changes to correctly deal with suppliers uom plus layout changes to puirchase orders and goods received notes</p> <p>06/06/10 Zhiguo Yuan: WorkOrderReceive.php - Change to make rollup costs change when more labour or overheadcosts change</p> <p>03/06/10 Phil: Added a bit of error trapping to ensure customer/branch set up when going into CounterSales.php</p> Modified: trunk/sql/mysql/upgrade3.11.1-3.12.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-06-07 19:58:17 UTC (rev 3484) +++ trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-06-08 13:53:28 UTC (rev 3485) @@ -4,7 +4,7 @@ PRIMARY KEY (`locationid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -DROP TABLE `assetmanager`; +DROP TABLE IF EXISTS `assetmanager`; CREATE TABLE `assetmanager` ( `id` int(11) NOT NULL auto_increment, @@ -227,3 +227,4 @@ ALTER TABLE `salestypes` CHANGE COLUMN `sales_type` `sales_type` VARCHAR(40) NOT NULL DEFAULT '';>>>>>>> .r3482 +INSERT INTO `config` VALUES ('ShowValueOnGRN', 1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-06-09 14:42:09
|
Revision: 3486 http://web-erp.svn.sourceforge.net/web-erp/?rev=3486&view=rev Author: tim_schofield Date: 2010-06-09 14:42:02 +0000 (Wed, 09 Jun 2010) Log Message: ----------- UserSettings.php - Fix sql error for case when password is being updated. Modified Paths: -------------- trunk/UserSettings.php trunk/doc/Change.log.html Modified: trunk/UserSettings.php =================================================================== --- trunk/UserSettings.php 2010-06-08 13:53:28 UTC (rev 3485) +++ trunk/UserSettings.php 2010-06-09 14:42:02 UTC (rev 3486) @@ -81,7 +81,7 @@ theme='" . $_POST['Theme'] . "', language='" . $_POST['Language'] . "', email='". $_POST['email'] ."', - pdflanguage=" . $_POST['PDFLanguage'] . " + pdflanguage=" . $_POST['PDFLanguage'] . ", password='" . CryptPass($_POST['pass']) . "' WHERE userid = '" . $_SESSION['UserID'] . "'"; @@ -97,7 +97,7 @@ $_SESSION['Theme'] = trim($_POST['Theme']); /*already set by session.inc but for completeness */ $theme = $_SESSION['Theme']; $_SESSION['Language'] = trim($_POST['Language']); - + include ('includes/LanguageSetup.php'); } @@ -122,8 +122,8 @@ <td>' . _('Maximum Number of Records to Display') . ":</td> <td><input type='Text' class='number' name='DisplayRecordsMax' size=3 maxlength=3 VALUE=" . $_POST['DisplayRecordsMax'] . " ></td> </tr>"; - - + + echo '<tr> <td>' . _('Language') . ":</td> <td><select name='Language'>"; @@ -132,13 +132,13 @@ while (false != ($LanguageEntry = $LangDirHandle->read())){ - - if (is_dir('locale/' . $LanguageEntry) - AND $LanguageEntry != '..' + + if (is_dir('locale/' . $LanguageEntry) + AND $LanguageEntry != '..' AND $LanguageEntry != 'CVS' - AND $LanguageEntry != '.svn' + AND $LanguageEntry != '.svn' AND $LanguageEntry!='.'){ - + if ($_SESSION['Language'] == $LanguageEntry){ echo "<option selected VALUE='$LanguageEntry'>$LanguageEntry"; } else { @@ -146,10 +146,10 @@ } } } - + echo '</select></td></tr>'; - + echo '<tr> <td>' . _('Theme') . ":</td> <td><select name='Theme'>"; @@ -195,7 +195,7 @@ if (!isset($_POST['PDFLanguage'])){ $_POST['PDFLanguage']=0; } - + echo '<tr><td>' . _('PDF Language Support') . ': </td><td><select name="PDFLanguage">'; for($i=0;$i<=7;$i++){ if ($_POST['PDFLanguage']==$i){ Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-06-08 13:53:28 UTC (rev 3485) +++ trunk/doc/Change.log.html 2010-06-09 14:42:02 UTC (rev 3486) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>09/06/10 Tim: UserSettings.php - Fix sql error for case when password is being updated.</p> <p>08/06/10 Tim: Add option to exclude value information from GRN screen</p> <p>07/06/10 Tim: Various changes to correctly deal with suppliers uom plus layout changes to puirchase orders and goods received notes</p> <p>06/06/10 Zhiguo Yuan: WorkOrderReceive.php - Change to make rollup costs change when more labour or overheadcosts change</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |