From: <dai...@us...> - 2010-07-09 08:01:20
|
Revision: 3595 http://web-erp.svn.sourceforge.net/web-erp/?rev=3595&view=rev Author: daintree Date: 2010-07-09 08:01:14 +0000 (Fri, 09 Jul 2010) Log Message: ----------- <p>09/07/10 Phil: includes/DateFunctions.inc added assumption for 2 digit years to d/m/Y m/d/Y and Y/m/d formats <p>09/07/10 Phil: Prices.php fixed error trapping to allow end dates of 0000-00-00 - the default no end date used by the logic Modified Paths: -------------- trunk/Prices.php trunk/doc/Change.log.html trunk/includes/DateFunctions.inc Modified: trunk/Prices.php =================================================================== --- trunk/Prices.php 2010-07-08 19:50:50 UTC (rev 3594) +++ trunk/Prices.php 2010-07-09 08:01:14 UTC (rev 3595) @@ -58,7 +58,7 @@ echo _('Pricing for part') . ':<input type=text name="Item" MAXSIZEe=22 VALUE="' . $Item . '" maxlength=20><input type=submit name=NewPart Value="' . _('Review Prices') . '">'; echo '<hr>'; -if ($myrow[1]=="K"){ +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; } @@ -79,18 +79,21 @@ $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']) 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 (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']!=''){ - $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']!=''){ - $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 { @@ -270,14 +273,14 @@ $_POST['TypeAbbrev'] = $_GET['TypeAbbrev']; $_POST['Price'] = $_GET['Price']; $_POST['StartDate'] = ConvertSQLDate($_GET['StartDate']); - if ($_GET['EndDate']==''){ - $_POST['EndDate'] =''; + if ($_GET['EndDate']=='' OR $_GET['EndDate']=='0000-00-00'){ + $_POST['EndDate'] = ''; } else { $_POST['EndDate'] = ConvertSQLDate($_GET['EndDate']); } } - $SQL = "SELECT currabrev, currency FROM currencies"; + $SQL = 'SELECT currabrev, currency FROM currencies'; $result = DB_query($SQL,$db); echo '<table><tr><td>' . _('Currency') . ':</td><td><select name="CurrAbrev">'; @@ -329,7 +332,9 @@ <tr><td><?php echo _('Price'); ?>:</td> <td> <input type="Text" class=number name="Price" size=12 maxlength=11 value= - <?php if(isset($_POST['Price'])) {echo $_POST['Price'];}?>> + <?php if(isset($_POST['Price'])) { + echo $_POST['Price']; + }?>> </td></tr> Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-08 19:50:50 UTC (rev 3594) +++ trunk/doc/Change.log.html 2010-07-09 08:01:14 UTC (rev 3595) @@ -1,5 +1,7 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>09/07/10 Phil: includes/DateFunctions.inc added assumption for 2 digit years to d/m/Y m/d/Y and Y/m/d formats +<p>09/07/10 Phil: Prices.php fixed error trapping to allow end dates of 0000-00-00 - the default no end date used by the logic <p>08/07/10 Tim: GLProfit_Loss - Layout improvements and sql fixes</p> <p>08/07/10 Tim: GLJournal - Layout improvements and sql fixes</p> <p>08/07/10 Tim: GLBudgets - Bug fixes and layout improvements and sql fixes</p> Modified: trunk/includes/DateFunctions.inc =================================================================== --- trunk/includes/DateFunctions.inc 2010-07-08 19:50:50 UTC (rev 3594) +++ trunk/includes/DateFunctions.inc 2010-07-09 08:01:14 UTC (rev 3595) @@ -376,10 +376,8 @@ /* takes a date in a the format specified in $_SESSION['DefaultDateFormat'] and converts to a yyyy/mm/dd format */ - $DateEntry = trim($DateEntry); - if (strpos($DateEntry,'/')) { $Date_Array = explode('/',$DateEntry); } elseif (strpos ($DateEntry,'-')) { @@ -397,29 +395,36 @@ } if ($_SESSION['DefaultDateFormat']=='Y/m/d') { + if (strlen($Date_Array[0])==2) { + if ((int)$Date_Array[0] <=60) { + $Date_Array[0] = '20'.$Date_Array[2]; + } elseif ((int)$Date_Array[0] >60 AND (int)$Date_Array[2] <100) { + $Date_Array[0] = '19'.$Date_Array[2]; + } + } return $Date_Array[0].'-'.$Date_Array[1].'-'.$Date_Array[2]; - } - -//to modify assumption in 2030 - if (strlen($Date_Array[0])==2) { - if ((int)$Date_Array[2] <60) { - $Date_Array[2] = '20'.$Date_Array[2]; - } elseif ((int)$Date_Array[2] >59 AND (int)$Date_Array[2] <100) { - $Date_Array[0] = '19'.$Date_Array[2]; - } elseif ((int)$Date_Array[2] >9999) { - return 0; + + }elseif (($_SESSION['DefaultDateFormat']=='d/m/Y') OR $_SESSION['DefaultDateFormat']=='d.m.Y'){ + if (strlen($Date_Array[2])==2) { + if ((int)$Date_Array[2] <=60) { + $Date_Array[2] = '20'.$Date_Array[2]; + } elseif ((int)$Date_Array[2] >60 AND (int)$Date_Array[2] <100) { + $Date_Array[2] = '19'.$Date_Array[2]; + } } - } - if (($_SESSION['DefaultDateFormat']=='d/m/Y')){ /* echo '<BR>The date returned is ' . $Date_Array[2].'/'.$Date_Array[1].'/'.$Date_Array[0]; */ return $Date_Array[2].'-'.$Date_Array[1].'-'.$Date_Array[0]; - } elseif ($_SESSION['DefaultDateFormat']=='d.m.Y') { - return $Date_Array[2].'-'.$Date_Array[1].'-'.$Date_Array[0]; + } elseif ($_SESSION['DefaultDateFormat']=='m/d/Y') { + if (strlen($Date_Array[2])==2) { + if ((int)$Date_Array[2] <=60) { + $Date_Array[2] = '20'.$Date_Array[2]; + } elseif ((int)$Date_Array[2] >60 AND (int)$Date_Array[2] <100) { + $Date_Array[2] = '19'.$Date_Array[2]; + } + } return $Date_Array[2].'-'.$Date_Array[0].'-'.$Date_Array[1]; - } elseif ($_SESSION['DefaultDateFormat']=='Y/m/d') { - return $Date_Array[0].'-'.$Date_Array[1].'-'.$Date_Array[2]; - } + } }// end of function This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |