From: <lin...@us...> - 2010-02-18 06:09:29
|
Revision: 3351 http://web-erp.svn.sourceforge.net/web-erp/?rev=3351&view=rev Author: lindsayh Date: 2010-02-18 06:09:20 +0000 (Thu, 18 Feb 2010) Log Message: ----------- Mostly fixing date formatting for salesorders operations (date format was not recognised by mysql, and thus defaulted). Also added an API method to list branches for a given customer/debtorno. Modified Paths: -------------- trunk/api/api_branches.php trunk/api/api_salesorders.php trunk/api/api_session.inc trunk/api/api_xml-rpc.php trunk/doc/Change.log.html trunk/includes/DateFunctions.inc Modified: trunk/api/api_branches.php =================================================================== --- trunk/api/api_branches.php 2010-02-17 22:11:45 UTC (rev 3350) +++ trunk/api/api_branches.php 2010-02-18 06:09:20 UTC (rev 3351) @@ -527,12 +527,17 @@ return $Errors; } $sql='SELECT * FROM custbranch WHERE debtorno="'.$DebtorNumber.'" and branchcode="'.$BranchCode.'"'; - $result = DB_Query($sql, $db); - if (sizeof($Errors)==0) { - return DB_fetch_array($result); - } else { - return $Errors; + $result = api_DB_Query($sql, $db); + if (DB_error_no($result) != 0 ) + $Errors[0] = DatabaseUpdateFailed; + else + { + $Errors[0] = 0; + if (DB_num_rows($result) > 0) + $Errors += DB_fetch_array($result); } + + return $Errors; } Modified: trunk/api/api_salesorders.php =================================================================== --- trunk/api/api_salesorders.php 2010-02-17 22:11:45 UTC (rev 3350) +++ trunk/api/api_salesorders.php 2010-02-18 06:09:20 UTC (rev 3351) @@ -5,6 +5,13 @@ //revision 1.14 */ +// InsertSalesOrderHeader and ModifySalesOrderHeader have date fields +// which need to be converted to the appropriate format. This is +// a list of such fields used to detect date values and format appropriately. +$SOH_DateFields = array ('orddate', 'deliverydate', + 'datepackingslipprinted', + 'quotedate', 'confirmeddate' ); + /* Check that the custmerref field is 50 characters or less long */ function VerifyCustomerRef($customerref, $i, $Errors) { if (strlen($customerref)>50) { @@ -330,9 +337,12 @@ } $FieldNames=''; $FieldValues=''; + global $SOH_DateFields; $OrderHeader['orderno'] = GetNextTransNo(30,$db); foreach ($OrderHeader as $key => $value) { $FieldNames.=$key.', '; + if (in_array($key, $SOH_DateFields) ) + $value = FormatDateforSQL($value); // Fix dates $FieldValues.='"'.$value.'", '; } $sql = 'INSERT INTO salesorders ('.substr($FieldNames,0,-2).') '. @@ -424,8 +434,11 @@ if (isset($OrderHeader['quotation'])){ $Errors=VerifyQuotation($OrderHeader['quotation'], sizeof($Errors), $Errors); } + global $SOH_DateFields; $sql='UPDATE salesorders SET '; foreach ($OrderHeader as $key => $value) { + if (in_array($key, $SOH_DateFields) ) + $value = FormatDateforSQL($value); // Fix dates $sql .= $key.'="'.$value.'", '; } $sql = substr($sql,0,-2).' WHERE orderno="'.$OrderHeader['orderno'].'"'; @@ -481,6 +494,10 @@ $FieldValues=''; foreach ($OrderLine as $key => $value) { $FieldNames.=$key.', '; + if ($key == 'actualdispatchdate') { + $value = FormatDateWithTimeForSQL($value); + } elseif ($key == 'itemdue') + $value = FormatDateForSQL($value); $FieldValues.='"'.$value.'", '; } $sql = 'INSERT INTO salesorderdetails ('.substr($FieldNames,0,-2).') '. @@ -533,6 +550,11 @@ } $sql='UPDATE salesorderdetails SET '; foreach ($OrderLine as $key => $value) { + if ($key == 'actualdispatchdate') { + $value = FormatDateWithTimeForSQL($value); + } + elseif ($key == 'itemdue') + $value = FormatDateForSQL($value); $sql .= $key.'="'.$value.'", '; } //$sql = substr($sql,0,-2).' WHERE orderno="'.$OrderLine['orderno'].'" and Modified: trunk/api/api_session.inc =================================================================== --- trunk/api/api_session.inc 2010-02-17 22:11:45 UTC (rev 3350) +++ trunk/api/api_session.inc 2010-02-18 06:09:20 UTC (rev 3351) @@ -42,7 +42,7 @@ /*User is logged in so get configuration parameters - save in session*/ if (isset($_SESSION['db']) AND $_SESSION['db'] != '' ) { - //include($PathPrefix . 'includes/GetConfig.php'); + include($PathPrefix . 'includes/GetConfig.php'); } if(isset($_SESSION['DB_Maintenance'])){ Modified: trunk/api/api_xml-rpc.php =================================================================== --- trunk/api/api_xml-rpc.php 2010-02-17 22:11:45 UTC (rev 3350) +++ trunk/api/api_xml-rpc.php 2010-02-18 06:09:20 UTC (rev 3351) @@ -248,7 +248,9 @@ $Parameter[3]['name'] = _('User password'); $Parameter[3]['description'] = _('The weberp password associated with this user name. '); $ReturnValue[0] = _('If successful this function returns a set of key/value pairs containing the details of this branch. ') - ._('The key will be identical with field name from the custbranch table. All fields will be in the set regardless of whether the value was set.').'<p>' + ._('The key will be identical with field name from the ') + .'<a href="../../Z_DescribeTable.php?table=custbranch">'._('custbranch table. ').'</a>' + ._('All fields will be in the set regardless of whether the value was set.').'<p>' ._('Otherwise an array of error codes is returned. '); /*E*/ $GetCustomerBranch_sig = array(array($xmlrpcStruct,$xmlrpcString,$xmlrpcString), Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-02-17 22:11:45 UTC (rev 3350) +++ trunk/doc/Change.log.html 2010-02-18 06:09:20 UTC (rev 3351) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>18/02/10 Lindsay: API: date formatting in api_salesorders.php; added FormatDateWithTimeForSQL function to includes/DateFunctions.inc <p>16/02/10 Pak Ricard: New Petty cash module</p> <p>16/02/10 Lindsay: Added GetCustomerBranchCodes() to API, and aoi_DB_query function to record DB error message and SQL causing it.</p> <p>15/02/10 Lindsay: Return no error indication from SearchCustomer() API</p> Modified: trunk/includes/DateFunctions.inc =================================================================== --- trunk/includes/DateFunctions.inc 2010-02-17 22:11:45 UTC (rev 3350) +++ trunk/includes/DateFunctions.inc 2010-02-18 06:09:20 UTC (rev 3351) @@ -423,6 +423,14 @@ }// end of function +function FormatDateWithTimeForSQL ($datetime) { + // Split the time off, fix date and add the time to returned value. + $dt = explode(' ', $datetime); + + return FormatDateForSQL( $dt[0] ) . ' ' . $dt[1]; +} + + function Date1GreaterThanDate2 ($Date1, $Date2) { /* returns 1 true if Date1 is greater than Date 2 */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |