From: <dai...@us...> - 2012-07-07 06:21:14
|
Revision: 5481 http://web-erp.svn.sourceforge.net/web-erp/?rev=5481&view=rev Author: daintree Date: 2012-07-07 06:21:07 +0000 (Sat, 07 Jul 2012) Log Message: ----------- new purge prices script Modified Paths: -------------- trunk/Prices.php trunk/doc/Change.log trunk/includes/DateFunctions.inc trunk/includes/MainMenuLinksArray.php trunk/sql/mysql/upgrade4.08-4.09.sql Modified: trunk/Prices.php =================================================================== --- trunk/Prices.php 2012-07-06 09:24:44 UTC (rev 5480) +++ trunk/Prices.php 2012-07-07 06:21:07 UTC (rev 5481) @@ -74,35 +74,35 @@ $InputError =1; prnMsg (_('The date this price is to take effect from must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat'],'error'); } - - if (FormatDateForSQL($_POST['EndDate'])!='0000-00-00'){ - 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 ($_POST['EndDate']!='') { + if (FormatDateForSQL($_POST['EndDate'])!='0000-00-00'){ + 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']) AND $_POST['EndDate']!='' AND FormatDateForSQL($_POST['EndDate'])!='0000-00-00'){ + $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['EndDate']) AND $_POST['EndDate']!='' AND FormatDateForSQL($_POST['EndDate'])!='0000-00-00'){ + $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 (Date1GreaterThanDate2($_POST['StartDate'],$_POST['EndDate']) AND $_POST['EndDate']!='' AND FormatDateForSQL($_POST['EndDate'])!='0000-00-00'){ - $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['EndDate']) AND $_POST['EndDate']!='' AND FormatDateForSQL($_POST['EndDate'])!='0000-00-00'){ - $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'; } - + $sql = "SELECT COUNT(typeabbrev) FROM prices WHERE prices.stockid='".$Item."' AND startdate='" .FormatDateForSQL($_POST['StartDate']) . "' AND enddate ='" . $SQLEndDate . "' AND prices.typeabbrev='" . $_POST['TypeAbbrev'] . "' - AND prices.currabrev='" . $_POST['CurrAbrev'] . "' - AND prices.price='" . filter_number_format($_POST['Price']) . "'"; + AND prices.currabrev='" . $_POST['CurrAbrev'] . "'"; $result = DB_query($sql, $db); $myrow = DB_fetch_row($result); @@ -111,9 +111,9 @@ prnMsg( _('This price has already been entered. To change it you should edit it') , 'warn'); $InputError =1; } - - - + + + if (isset($_POST['OldTypeAbbrev']) AND isset($_POST['OldCurrAbrev']) AND mb_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*/ @@ -157,10 +157,11 @@ '" . filter_number_format($_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']); unset($_POST['EndDate']); @@ -182,176 +183,176 @@ } //Always do this stuff -if ($InputError ==0){ - $sql = "SELECT currencies.currency, - salestypes.sales_type, - prices.price, - prices.stockid, - prices.typeabbrev, - prices.currabrev, - prices.startdate, - prices.enddate, - currencies.decimalplaces AS currdecimalplaces - FROM prices - INNER JOIN salestypes - ON prices.typeabbrev = salestypes.typeabbrev - INNER JOIN currencies - ON prices.currabrev=currencies.currabrev - WHERE prices.stockid='".$Item."' - AND prices.debtorno='' - ORDER BY prices.currabrev, - prices.typeabbrev, - prices.startdate"; - $result = DB_query($sql,$db); +$sql = "SELECT currencies.currency, + salestypes.sales_type, + prices.price, + prices.stockid, + prices.typeabbrev, + prices.currabrev, + prices.startdate, + prices.enddate, + currencies.decimalplaces AS currdecimalplaces + FROM prices + INNER JOIN salestypes + ON prices.typeabbrev = salestypes.typeabbrev + INNER JOIN currencies + ON prices.currabrev=currencies.currabrev + WHERE prices.stockid='".$Item."' + AND prices.debtorno='' + ORDER BY prices.currabrev, + prices.typeabbrev, + prices.startdate"; - if (DB_num_rows($result) > 0) { - echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '">'; - echo '<div>'; - echo '<table class="selection"> - <tr> - <th colspan="7"> - <input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />' . - _('Pricing for part') . ': - <input type="text" name="Item" size="22" value="' . $Item . '" maxlength="20" /> - <input type="submit" name="NewPart" value="' . _('Review Prices') . '" /></th> - </tr>'; +$result = DB_query($sql,$db); - echo '<tr><th>' . _('Currency') . '</th> - <th>' . _('Sales Type') . '</th> - <th>' . _('Price') . '</th> - <th>' . _('Start Date') . ' </th> - <th>' . _('End Date') . '</th> - </tr>'; +if (DB_num_rows($result) > 0) { + echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '">'; + echo '<div>'; + echo '<table class="selection"> + <tr> + <th colspan="7"> + <input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />' . + _('Pricing for part') . ': + <input type="text" name="Item" size="22" value="' . $Item . '" maxlength="20" /> + <input type="submit" name="NewPart" value="' . _('Review Prices') . '" /></th> + </tr>'; - $k=0; //row colour counter + echo '<tr><th>' . _('Currency') . '</th> + <th>' . _('Sales Type') . '</th> + <th>' . _('Price') . '</th> + <th>' . _('Start Date') . ' </th> + <th>' . _('End Date') . '</th> + </tr>'; - while ($myrow = DB_fetch_array($result)) { - if ($k==1){ - echo '<tr class="EvenTableRows">'; - $k=0; - } else { - 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'])) { - echo '<td>' . $myrow['currency'] . '</td> - <td>' . $myrow['sales_type'] . '</td> - <td class="number">' . locale_number_format($myrow['price'],$myrow['currdecimalplaces']) . '</td> - <td>' . ConvertSQLDate($myrow['startdate']) . '</td> - <td>' . $EndDateDisplay . '</td> - <td><a href="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?Item=' . $myrow['stockid'] . '&TypeAbbrev=' .$myrow['typeabbrev'] . '&CurrAbrev=' . $myrow['currabrev'] . '&Price=' . $myrow['price'] . '&StartDate=' . $myrow['startdate'] . '&EndDate=' . $myrow['enddate'] . '&Edit=1">' . _('Edit') . '</a></td> - <td><a href="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?Item=' . $myrow['stockid'] . '&TypeAbbrev=' .$myrow['typeabbrev'] . '&CurrAbrev=' . $myrow['currabrev'] . '&StartDate=' . $myrow['startdate'] . '&EndDate=' . $myrow['enddate'] . '&delete=yes" onclick="return confirm(\'' . _('Are you sure you wish to delete this price?') . '\');">' . _('Delete') . '</a></td></tr>'; - - } else { - echo '<td>' . $myrow['currency'] . '</td> - <td>' . $myrow['sales_type'] . '</td> - <td class="number">' . locale_number_format($myrow['price'],$myrow['currdecimalplaces']) . '</td> - <td>' . ConvertSQLDate($myrow['startdate']) . '</td> - <td>' . $EndDateDisplay . '</td></tr>'; - } + $k=0; //row colour counter + while ($myrow = DB_fetch_array($result)) { + if ($k==1){ + echo '<tr class="EvenTableRows">'; + $k=0; + } else { + echo '<tr class="OddTableRows">'; + $k=1; } - //END WHILE LIST LOOP - echo '</table><br />'; - echo '</div> - </form>'; - } else { - prnMsg(_('There are no prices set up for this part'),'warn'); - } + 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'])) { + echo '<td>' . $myrow['currency'] . '</td> + <td>' . $myrow['sales_type'] . '</td> + <td class="number">' . locale_number_format($myrow['price'],$myrow['currdecimalplaces']) . '</td> + <td>' . ConvertSQLDate($myrow['startdate']) . '</td> + <td>' . $EndDateDisplay . '</td> + <td><a href="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?Item=' . $myrow['stockid'] . '&TypeAbbrev=' .$myrow['typeabbrev'] . '&CurrAbrev=' . $myrow['currabrev'] . '&Price=' . $myrow['price'] . '&StartDate=' . $myrow['startdate'] . '&EndDate=' . $myrow['enddate'] . '&Edit=1">' . _('Edit') . '</a></td> + <td><a href="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?Item=' . $myrow['stockid'] . '&TypeAbbrev=' .$myrow['typeabbrev'] . '&CurrAbrev=' . $myrow['currabrev'] . '&StartDate=' . $myrow['startdate'] . '&EndDate=' . $myrow['enddate'] . '&delete=yes" onclick="return confirm(\'' . _('Are you sure you wish to delete this price?') . '\');">' . _('Delete') . '</a></td></tr>'; - echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '">'; - echo '<div>'; - echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - if (isset($_GET['Edit'])){ - echo '<input type="hidden" name="OldTypeAbbrev" value="' . $_GET['TypeAbbrev'] .'" />'; - echo '<input type="hidden" name="OldCurrAbrev" value="' . $_GET['CurrAbrev'] . '" />'; - echo '<input type="hidden" name="OldStartDate" value="' . $_GET['StartDate'] . '" />'; - echo '<input type="hidden" name="OldEndDate" value="' . $_GET['EndDate'] . '" />'; - $_POST['CurrAbrev'] = $_GET['CurrAbrev']; - $_POST['TypeAbbrev'] = $_GET['TypeAbbrev']; - /*the price sent with the get is sql format price so no need to filter */ - $_POST['Price'] = $_GET['Price']; - $_POST['StartDate'] = ConvertSQLDate($_GET['StartDate']); - if ($_GET['EndDate']=='' OR $_GET['EndDate']=='0000-00-00'){ - $_POST['EndDate'] = ''; } else { - $_POST['EndDate'] = ConvertSQLDate($_GET['EndDate']); + echo '<td>' . $myrow['currency'] . '</td> + <td>' . $myrow['sales_type'] . '</td> + <td class="number">' . locale_number_format($myrow['price'],$myrow['currdecimalplaces']) . '</td> + <td>' . ConvertSQLDate($myrow['startdate']) . '</td> + <td>' . $EndDateDisplay . '</td></tr>'; } + } + //END WHILE LIST LOOP + echo '</table><br />'; + echo '</div> + </form>'; +} else { + prnMsg(_('There are no prices set up for this part'),'warn'); +} - $SQL = "SELECT currabrev, - currency - FROM currencies"; - $result = DB_query($SQL,$db); +echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '">'; +echo '<div>'; +echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; +if (isset($_GET['Edit'])){ + echo '<input type="hidden" name="OldTypeAbbrev" value="' . $_GET['TypeAbbrev'] .'" />'; + echo '<input type="hidden" name="OldCurrAbrev" value="' . $_GET['CurrAbrev'] . '" />'; + echo '<input type="hidden" name="OldStartDate" value="' . $_GET['StartDate'] . '" />'; + echo '<input type="hidden" name="OldEndDate" value="' . $_GET['EndDate'] . '" />'; + $_POST['CurrAbrev'] = $_GET['CurrAbrev']; + $_POST['TypeAbbrev'] = $_GET['TypeAbbrev']; + /*the price sent with the get is sql format price so no need to filter */ + $_POST['Price'] = $_GET['Price']; + $_POST['StartDate'] = ConvertSQLDate($_GET['StartDate']); + if ($_GET['EndDate']=='' OR $_GET['EndDate']=='0000-00-00'){ + $_POST['EndDate'] = ''; + } else { + $_POST['EndDate'] = ConvertSQLDate($_GET['EndDate']); + } +} - echo '<br /><table class="selection">'; - echo '<tr><th colspan="5"><h3>' . $Item . ' - ' . $PartDescription . '</h3></th></tr>'; - echo '<tr><td>' . _('Currency') . ':</td> - <td><select name="CurrAbrev">'; - while ($myrow = DB_fetch_array($result)) { - if ($myrow['currabrev']==$_POST['CurrAbrev']) { - echo '<option selected="selected" value="'; - } else { - echo '<option value="'; - } - echo $myrow['currabrev'] . '">' . $myrow['currency'] . '</option>'; - } //end while loop +$SQL = "SELECT currabrev, + currency + FROM currencies"; +$result = DB_query($SQL,$db); - DB_free_result($result); +echo '<br /><table class="selection">'; +echo '<tr><th colspan="5"><h3>' . $Item . ' - ' . $PartDescription . '</h3></th></tr>'; +echo '<tr><td>' . _('Currency') . ':</td> + <td><select name="CurrAbrev">'; +while ($myrow = DB_fetch_array($result)) { + if ($myrow['currabrev']==$_POST['CurrAbrev']) { + echo '<option selected="selected" value="'; + } else { + echo '<option value="'; + } + echo $myrow['currabrev'] . '">' . $myrow['currency'] . '</option>'; +} //end while loop - echo '</select> </td></tr> - <tr> - <td>' . _('Sales Type Price List') . ':</td> - <td><select name="TypeAbbrev">'; +DB_free_result($result); - $SQL = "SELECT typeabbrev, sales_type FROM salestypes"; - $result = DB_query($SQL,$db); +echo '</select> </td></tr> + <tr> + <td>' . _('Sales Type Price List') . ':</td> + <td><select name="TypeAbbrev">'; - while ($myrow = DB_fetch_array($result)) { - if ($myrow['typeabbrev']==$_POST['TypeAbbrev']) { - echo '<option selected="selected" value="'; - } else { - echo '<option value="'; - } - echo $myrow['typeabbrev'] . '">' . $myrow['sales_type'] . '</option>'; +$SQL = "SELECT typeabbrev, sales_type FROM salestypes"; +$result = DB_query($SQL,$db); - } //end while loop - echo '</select></td></tr>'; - - DB_free_result($result); +while ($myrow = DB_fetch_array($result)) { + if ($myrow['typeabbrev']==$_POST['TypeAbbrev']) { + echo '<option selected="selected" value="'; + } else { + echo '<option value="'; + } + echo $myrow['typeabbrev'] . '">' . $myrow['sales_type'] . '</option>'; - if (!isset($_POST['StartDate'])){ - $_POST['StartDate'] = Date($_SESSION['DefaultDateFormat']); - } - if (!isset($_POST['EndDate'])){ - $_POST['EndDate'] = ''; - } - echo '<tr><td>' . _('Price Effective From Date') . ':</td> - <td><input type="text" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" name="StartDate" size="10" maxlength="10" value="' . $_POST['StartDate'] . '" /></td></tr>'; - echo '<tr><td>' . _('Price Effective To Date') . ':</td> - <td><input type="text" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" name="EndDate" size="10" maxlength="10" value="' . $_POST['EndDate'] . '" />'; - echo '<input type="hidden" name="Item" value="' . $Item.'" /></td></tr>'; - echo '<tr><td>' . _('Price') . ':</td> - <td> - <input type="text" class="number" name="Price" size="12" maxlength="11" value="'; - if (isset($_POST['Price'])) { - echo $_POST['Price']; - } - echo '" /> - </td></tr> - </table> - <br /><div class="centre"> - <input type="submit" name="submit" value="' . _('Enter') . '/' . _('Amend Price') . '" /> - </div>'; +} //end while loop +echo '</select></td></tr>'; + +DB_free_result($result); + +if (!isset($_POST['StartDate'])){ + $_POST['StartDate'] = Date($_SESSION['DefaultDateFormat']); } +if (!isset($_POST['EndDate'])){ + $_POST['EndDate'] = ''; +} +echo '<tr><td>' . _('Price Effective From Date') . ':</td> + <td><input type="text" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" name="StartDate" size="10" maxlength="10" value="' . $_POST['StartDate'] . '" /></td></tr>'; +echo '<tr><td>' . _('Price Effective To Date') . ':</td> + <td><input type="text" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" name="EndDate" size="10" maxlength="10" value="' . $_POST['EndDate'] . '" />'; +echo '<input type="hidden" name="Item" value="' . $Item.'" /></td></tr>'; +echo '<tr><td>' . _('Price') . ':</td> + <td> + <input type="text" class="number" name="Price" size="12" maxlength="11" value="'; + if (isset($_POST['Price'])) { + echo $_POST['Price']; + } + echo '" /> + </td></tr> +</table> +<br /><div class="centre"> +<input type="submit" name="submit" value="' . _('Enter') . '/' . _('Amend Price') . '" /> +</div>'; + echo '</div> </form>'; include('includes/footer.inc'); @@ -361,7 +362,7 @@ /*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 - * + * * After further discussion (Ricard) if the new price has a blank end date - i.e. no end then the pre-existing price with no end date should be changed to have an end date just prior to the new default (no end date) price commencing */ //this is just the case where debtorno='' - see the Prices_Customer.php script for customer special prices @@ -376,7 +377,7 @@ AND enddate <>'0000-00-00' ORDER BY startdate, enddate"; $result = DB_query($SQL,$db); - + while ($myrow = DB_fetch_array($result)){ if (isset($NextStartDate)){ if (Date1GreaterThanDate2(ConvertSQLDate($myrow['startdate']),$NextStartDate)){ @@ -402,7 +403,7 @@ $EndDate = $myrow['enddate']; $Price = $myrow['price']; } // end of loop around all prices - + //Now look for duplicate prices with no end $SQL = "SELECT price, startdate, @@ -415,7 +416,7 @@ AND enddate ='0000-00-00' ORDER BY startdate"; $result = DB_query($SQL,$db); - + while ($myrow = DB_fetch_array($result)) { if (isset($OldStartDate)){ /*Need to make the end date the new start date less 1 day */ @@ -431,7 +432,7 @@ } $OldStartDate = $myrow['startdate']; } // end of loop around duplicate no end date prices - + } // end function ReSequenceEffectiveDates ?> \ No newline at end of file Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2012-07-06 09:24:44 UTC (rev 5480) +++ trunk/doc/Change.log 2012-07-07 06:21:07 UTC (rev 5481) @@ -1,5 +1,7 @@ webERP Change Log +6/7/12 Phil: Add stable versions to UpgradeDatabase.php script +6/7/12 Phil: Added new Z_DeleteOldPrices.php script to purge prices which are past their end date 30/6/12 Phil: Attempt at quicker price retrieval 30/6/12 Phil: Allow creation of work orders for Raw materials - well intermediary components manufacture - per Bob Thomas email 26/06/12 Bob Thomas: StockAdjustments fix link to controlled stock adjustments entry Modified: trunk/includes/DateFunctions.inc =================================================================== --- trunk/includes/DateFunctions.inc 2012-07-06 09:24:44 UTC (rev 5480) +++ trunk/includes/DateFunctions.inc 2012-07-07 06:21:07 UTC (rev 5481) @@ -92,7 +92,7 @@ if (mb_strlen($Date_Array[2])>4) { $Date_Array[2]= mb_substr($Date_Array[2],0,2); } - + $MonthName = GetMonthText(date('n', mktime(0,0,0, (int)$Date_Array[1],(int)$Date_Array[2],(int)$Date_Array[0]))); return $MonthName . ' ' . date('Y', mktime(0,0,0, (int)$Date_Array[1],(int)$Date_Array[2],(int)$Date_Array[0])); @@ -458,7 +458,7 @@ /* takes a date in a the format specified in $_SESSION['DefaultDateFormat'] and converts to a yyyy/mm/dd format */ - $DateArray = array(); + $Date_Array = array(); $DateEntry = trim($DateEntry); if (mb_strpos($DateEntry,'/')) { @@ -487,7 +487,7 @@ } return $Date_Array[0].'-'.$Date_Array[1].'-'.$Date_Array[2]; - }elseif (($_SESSION['DefaultDateFormat']=='d/m/Y') + } elseif (($_SESSION['DefaultDateFormat']=='d/m/Y') OR $_SESSION['DefaultDateFormat']=='d.m.Y'){ if (mb_strlen($Date_Array[2])==2) { if ((int)$Date_Array[2] <=60) { @@ -522,11 +522,11 @@ function LastDayOfMonth ( $DateEntry) { /*Expects a date in DefaultDateFormat and * Returns the last day of the month in the entered date - * in the DefaultDateFormat - * + * in the DefaultDateFormat + * * mktime (0,0,0 month, day, year) */ - + $DateEntry = trim($DateEntry); if (mb_strpos($DateEntry,'/')) { @@ -565,8 +565,8 @@ } } $DateStamp = mktime(0,0,0, $Date_Array[1]+1, 0, $Date_Array[2]); - - + + } elseif ($_SESSION['DefaultDateFormat']=='m/d/Y') { if (mb_strlen($Date_Array[2])==2) { if ((int)$Date_Array[2] <=60) { @@ -719,13 +719,13 @@ } function DateAdd ($DateToAddTo,$PeriodString,$NumberPeriods){ - /*Takes - * DateToAddTo in $_SESSION['DefaultDateFormat'] format + /*Takes + * DateToAddTo in $_SESSION['DefaultDateFormat'] format * $PeriodString is one of: * d - days * w - weeks * m - months - * y - years + * y - years * $NumberPeriods is an integer positve or negative */ $DateToAddTo = trim($DateToAddTo); @@ -925,7 +925,7 @@ } elseif (mb_strpos ($TransDate,'.')) { $Date_Array = explode('.',$TransDate); } - + if (($_SESSION['DefaultDateFormat']=='d/m/Y') or ($_SESSION['DefaultDateFormat']=='d.m.Y')){ $TransDate = mktime(0,0,0,$Date_Array[1],$Date_Array[0],$Date_Array[2]); } elseif ($_SESSION['DefaultDateFormat']=='m/d/Y'){ @@ -947,7 +947,7 @@ $sql = "SELECT MAX(lastdate_in_period), MAX(periodno) from periods"; $result = DB_query($sql, $db); $myrow=DB_fetch_row($result); - + if (is_null($myrow[0])){ $InsertFirstPeriodResult = DB_query("INSERT INTO periods VALUES (0,'" . Date('Y-m-d',mktime(0,0,0,Date('m')+1,0,Date('Y'))) . "')",$db,_('Could not insert first period')); $InsertFirstPeriodResult = DB_query("INSERT INTO periods VALUES (1,'" . Date('Y-m-d',mktime(0,0,0,Date('m')+2,0,Date('Y'))) . "')",$db,_('Could not insert second period')); @@ -969,11 +969,11 @@ /* If the period number doesn't exist */ if (!PeriodExists($TransDate, $db)) { /* if the transaction is after the last period */ - + if ($TransDate > $LastPeriodEnd) { - + $PeriodEnd = mktime(0,0,0,Date('m', $TransDate)+1, 0, Date('Y', $TransDate)); - + while ($PeriodEnd >= $LastPeriodEnd) { if (Date('m', $LastPeriodEnd)<=13) { $LastPeriodEnd = mktime(0,0,0,Date('m', $LastPeriodEnd)+2, 0, Date('Y', $LastPeriodEnd)); @@ -1011,9 +1011,9 @@ /* Now return the period number of the transaction */ $MonthAfterTransDate = Mktime(0,0,0,Date('m',$TransDate)+1,Date('d',$TransDate),Date('Y',$TransDate)); - $GetPrdSQL = "SELECT periodno - FROM periods - WHERE lastdate_in_period < '" . Date('Y-m-d', $MonthAfterTransDate) . "' + $GetPrdSQL = "SELECT periodno + FROM periods + WHERE lastdate_in_period < '" . Date('Y-m-d', $MonthAfterTransDate) . "' AND lastdate_in_period >= '" . Date('Y-m-d', $TransDate) . "'"; $ErrMsg = _('An error occurred in retrieving the period number'); Modified: trunk/includes/MainMenuLinksArray.php =================================================================== --- trunk/includes/MainMenuLinksArray.php 2012-07-06 09:24:44 UTC (rev 5480) +++ trunk/includes/MainMenuLinksArray.php 2012-07-07 06:21:07 UTC (rev 5481) @@ -565,7 +565,8 @@ _('Import Fixed Assets from .csv file'), _('Create new company template SQL file and submit to webERP'), _('Re-calculate brought forward amounts in GL'), - _('Re-Post all GL transactions from a specified period') + _('Re-Post all GL transactions from a specified period'), + _('Purge all old prices') ); $MenuItems['Utilities']['Maintenance']['URL'] = array ('/Z_poAdmin.php', @@ -575,6 +576,7 @@ '/Z_ImportFixedAssets.php', '/Z_CreateCompanyTemplateFile.php', '/Z_UpdateChartDetailsBFwd.php', - '/Z_RePostGLFromPeriod.php' + '/Z_RePostGLFromPeriod.php', + '/Z_DeleteOldPrices.php' ); ?> \ No newline at end of file Modified: trunk/sql/mysql/upgrade4.08-4.09.sql =================================================================== --- trunk/sql/mysql/upgrade4.08-4.09.sql 2012-07-06 09:24:44 UTC (rev 5480) +++ trunk/sql/mysql/upgrade4.08-4.09.sql 2012-07-07 06:21:07 UTC (rev 5481) @@ -1,2 +1,4 @@ +INSERT INTO scripts VALUES ('Z_DeleteOldPrices.php','15','Deletes all old prices'); +INSERT INTO scripts VALUES ('Z_ChangeLocationCode.php','15','Change a locations code and in all tables where the old code was used to the new code') UPDATE config SET confvalue='4.08.1' WHERE confname='VersionNumber'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |