|
From: <dai...@us...> - 2012-06-28 19:21:53
|
Revision: 5463
http://web-erp.svn.sourceforge.net/web-erp/?rev=5463&view=rev
Author: daintree
Date: 2012-06-28 19:21:46 +0000 (Thu, 28 Jun 2012)
Log Message:
-----------
POS Data creation
Modified Paths:
--------------
trunk/api/api_webERPsettings.php
trunk/api/api_xml-rpc.php
trunk/includes/GetPrice.inc
Added Paths:
-----------
trunk/Z_POS_Data.php
trunk/includes/Z_POSDataCreation.php
Added: trunk/Z_POS_Data.php
===================================================================
--- trunk/Z_POS_Data.php (rev 0)
+++ trunk/Z_POS_Data.php 2012-06-28 19:21:46 UTC (rev 5463)
@@ -0,0 +1,69 @@
+<?php
+include('includes/GetPrice.inc');
+/* $Id: Z_POS_Data.php 3843 2010-09-30 14:49:45Z daintree $*/
+$PageSecurity = 9;
+
+include('includes/session.inc');
+
+$title = _('Create POS Data Upload File');
+
+include('includes/header.inc');
+
+if (!isset($_GET['POSDebtorNo']) AND !isset($_GET['POSBranchCode'])){
+ echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/maintenance.png" title="' . _('Create POS Data File') . '" alt="">' . ' ' . $title.'<br />';
+ echo "<form method='post' action=" . $_SERVER['PHP_SELF'] . '><br>';
+ echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
+
+ //Need to get POS customer as need to know currency for prices and the sale type for prices
+ if (!isset($_POST['POSDebtorNo'])){
+ $_POST['POSDebtorNo']='';
+ }
+ if (!isset($_POST['POSBranchCode'])){
+ $_POST['POSBranchCode']='';
+ }
+ echo '<table class="selection">
+ <tr>
+ <td>' . _('POS Customer Code') . ':</td>
+ <td><input tabindex="1" type="text" name="POSDebtorNo" value="' . $_POST['POSDebtorNo'] . '" size="12" maxlength="12" /></td>
+ </tr>
+ <tr>
+ <td>' . _('POS Branch Code') . ':</td>
+ <td><input tabindex="2" type="text" name="POSBranchCode" value="' . $_POST['POSBranchCode'] .'" size="12" maxlength="12" /></td>
+ </tr>';
+
+ echo '<tr><td colspan=2><div class="centre"><input tabindex="3" type="Submit" name="CreatePOSDataFile" value=' . _('Create POS Data File') .'></div></td></tr>';
+ echo '</table></form>';
+} else {
+ $_POST['POSDebtorNo'] = $_GET['POSDebtorNo'];
+ $_POST['POSBranchCode'] = $_GET['POSBranchCode'];
+ $_POST['CreatePOSDataFile'] = 'Yes Please';
+}
+
+if (isset($_POST['CreatePOSDataFile'])){
+
+ $InputError =0;
+
+ if (!isset($_POST['POSDebtorNo']) OR $_POST['POSDebtorNo'] == ''){
+ prnMsg(_('Cannot create POS Data file without the POS Customer Code'),'error');
+ $InputError =1;
+ } elseif(!isset($_POST['POSBranchCode']) OR $_POST['POSBranchCode']==''){
+ prnMsg(_('Cannot create POS Data file without the POS Customer Branch Code'),'error');
+ $InputError =1;
+ }
+
+ if ($InputError ==0) {
+
+ include('includes/Z_POSDataCreation.php');
+ if (CreatePOSDataFull($_POST['POSDebtorNo'],$_POST['POSBranchCode'],$db) ==1){
+ echo '<br />
+ <br />
+ <a href="' . $_SESSION['reports_dir'] . '/POS.sql.zip">' . _('Download POS Upload File') . '</a>';
+ } else {
+ prnMsg(_('Unable to create POS Data file - perhaps the POS Customer Code or Branch Code do not exist'),'error');
+ }
+
+ } // end if no input errors
+} //hit create POSDataFile
+
+include('includes/footer.inc');
+?>
\ No newline at end of file
Modified: trunk/api/api_webERPsettings.php
===================================================================
--- trunk/api/api_webERPsettings.php 2012-06-28 13:47:00 UTC (rev 5462)
+++ trunk/api/api_webERPsettings.php 2012-06-28 19:21:46 UTC (rev 5463)
@@ -67,7 +67,7 @@
}
$sql = "select defaultlocation from www_users where userid='".$user."'";
$result = DB_query($sql, $db);
- $answer=DB_fetch_array($result);
+ $answer=DB_fetch_array($result);
$ReturnValue[0]=0;
$ReturnValue[1]=$answer;
return $ReturnValue;
@@ -90,5 +90,24 @@
$ReturnValue[1]=$answer;
return $ReturnValue;
}
+
+ /* This function creates a POS zipped update file */
+ include('../../includes/POSDataCreation.php');
+
+ function CreatePOSDataFull($POSDebtorNo, $POSBranchCode, $User, $Password) {
+ $Errors = array();
+ $db = db($User, $Password);
+ if (gettype($db)=='integer') {
+ $Errors[0]=NoAuthorisation;
+ return $Errors;
+ }
+ if (CreatePOSDataFull($_POST['POSDebtorNo'],$_POST['POSBranchCode'],$db) ==1){
+ $ReturnValue=0;
+ } else {
+ $ReturnValue=1;
+ }
+ return $ReturnValue;
+ }
+
?>
Modified: trunk/api/api_xml-rpc.php
===================================================================
--- trunk/api/api_xml-rpc.php 2012-06-28 13:47:00 UTC (rev 5462)
+++ trunk/api/api_xml-rpc.php 2012-06-28 19:21:46 UTC (rev 5463)
@@ -2931,12 +2931,12 @@
unset($Parameter);
unset($ReturnValue);
- $Description = _('Returns the webERP currency code');
+ $Description = _('Returns the webERP default inventory location');
$Parameter[0]['name'] = _('User name');
$Parameter[0]['description'] = _('A valid weberp username. This user should have security access to this data.');
$Parameter[1]['name'] = _('User password');
$Parameter[1]['description'] = _('The weberp password associated with this user name. ');
- $ReturnValue[0] = _('If successful this function returns a string contain the default currency code. ')
+ $ReturnValue[0] = _('If successful this function returns a string contain the default inventory location. ')
._('Otherwise an array of error codes is returned. ');
/*E*/ $GetDefaultLocation_sig = array(array($xmlrpcStruct),
@@ -2960,6 +2960,43 @@
unset($Parameter);
unset($ReturnValue);
+ $Description = _('This function creates a POS data file on the webERP server for download by the POS');
+ $Parameter[0]['name'] = _('POS Customer Code - a valid webERP customer that sales from the POS are made against.');
+ $Parameter[0]['description'] = _('POS Customer Branch Code - a valid branch code of the webERP customer that the POS sales are made against');
+ $Parameter[1]['name'] = _('User name');
+ $Parameter[1]['description'] = _('A valid weberp username. This user should have security access to this data.');
+ $Parameter[2]['name'] = _('User name');
+ $Parameter[2]['description'] = _('A valid weberp username. This user should have security access to this data.');
+ $Parameter[3]['name'] = _('User password');
+ $Parameter[3]['description'] = _('The weberp password associated with this user name. ');
+ $ReturnValue[0] = _('If successful this function returns 0 for success and 1 for error. ');
+
+ $GetCreatePOSDataFull_sig = array(array($xmlrpcStruct),
+ array($xmlrpcStruct,$xmlrpcString,$xmlrpcString,$xmlrpcString,$xmlrpcString));
+ $GetCreatePOSDataFull_doc = apiBuildDocHTML( $Description,$Parameter,$ReturnValue );
+
+ function xmlrpc_CreatePOSDataFull($xmlrpcmsg){
+ ob_start('ob_file_callback');
+/*x*/ if ($xmlrpcmsg->getNumParams() == 4) {
+/*x*/ $rtn = new xmlrpcresp( php_xmlrpc_encode(CreatePOSDataFull($xmlrpcmsg->getParam( 0 )->scalarval( ),
+/*x*/ $xmlrpcmsg->getParam( 1 )->scalarval( ),
+ $xmlrpcmsg->getParam( 2 )->scalarval( ),
+ $xmlrpcmsg->getParam( 3 )->scalarval( ))) );
+/*x*/ } else {
+/*e*/ $rtn = new xmlrpcresp( php_xmlrpc_encode(CreatePOSDataFull( $xmlrpcmsg->getParam( 0 )->scalarval( ),
+/*x*/ $xmlrpcmsg->getParam( 1 )->scalarval( ),
+ '',
+ '')));
+/*x*/ }
+ ob_end_flush();
+ return $rtn;
+ }
+
+
+ unset($Description);
+ unset($Parameter);
+ unset($ReturnValue);
+
$Description = _('Returns the value of the specified stock category property for the specified stock item category');
$Parameter[0]['name'] = _('Property');
$Parameter[0]['description'] = _('The name of the specific property to be returned.');
Modified: trunk/includes/GetPrice.inc
===================================================================
--- trunk/includes/GetPrice.inc 2012-06-28 13:47:00 UTC (rev 5462)
+++ trunk/includes/GetPrice.inc 2012-06-28 19:21:46 UTC (rev 5463)
@@ -1,6 +1,6 @@
<?php
/* $Id$*/
-function GetPrice ($StockID, $DebtorNo, $BranchCode, $db){
+function GetPrice ($StockID, $DebtorNo, $BranchCode, $db, $ReportZeroPrice=1){
$Price = 0;
/*Search by branch and customer for a date specified price */
@@ -140,7 +140,9 @@
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');
+ if ($ReportZeroPrice ==1){
+ prnMsg(_('There are no prices set up for') . ' ' . $StockID,'warn');
+ }
Return 0;
}
}
Added: trunk/includes/Z_POSDataCreation.php
===================================================================
--- trunk/includes/Z_POSDataCreation.php (rev 0)
+++ trunk/includes/Z_POSDataCreation.php 2012-06-28 19:21:46 UTC (rev 5463)
@@ -0,0 +1,139 @@
+<?php
+
+function CreatePOSDataFull ( $POSDebtorNo, $POSBranchCode, $db) {
+ $result = DB_query("SELECT currcode, salestype FROM debtorsmaster WHERE debtorno='" . $POSDebtorNo . "'",$db);
+ $CustomerRow = DB_fetch_array($result);
+ if (DB_num_rows($result)==0){
+ return 0;
+ }
+ $CurrCode = $CustomerRow['currcode'];
+ $SalesType = $CustomerRow['salestype'];
+
+ $FileHandle = fopen($_SESSION['reports_dir'] . '/POS.sql','w');
+
+ fwrite($FileHandle,"DELETE FROM currencies;\n");
+ $result = DB_query('SELECT currency, currabrev, country, hundredsname,decimalplaces, rate FROM currencies',$db);
+ while ($CurrRow = DB_fetch_array($result)) {
+
+ fwrite($FileHandle,"INSERT INTO currencies VALUES ('" . $CurrRow['currency'] . "', '" . $CurrRow['currabrev'] . "', '" . sqlite_escape_string ($CurrRow['country']) . "', '" . sqlite_escape_string ($CurrRow['hundredsname']) . "', '" .$CurrRow['decimalplaces'] . "', '" .$CurrRow['rate'] . "');\n");
+
+ }
+
+ fwrite($FileHandle,"DELETE FROM salestypes;\n");
+
+ $result = DB_query('SELECT typeabbrev, sales_type FROM salestypes',$db);
+ while ($myrow = DB_fetch_array($result)) {
+
+ fwrite($FileHandle,"INSERT INTO salestypes VALUES ('" . $myrow['typeabbrev'] . "', '" . sqlite_escape_string ($myrow['sales_type']) . "');\n");
+
+ }
+ fwrite($FileHandle,"DELETE FROM holdreasons;\n");
+
+ $result = DB_query('SELECT reasoncode, reasondescription, dissallowinvoices FROM holdreasons',$db);
+ while ($myrow = DB_fetch_array($result)) {
+
+ fwrite($FileHandle,"INSERT INTO holdreasons VALUES ('" . $myrow['reasoncode'] . "', '" . sqlite_escape_string ($myrow['reasondescription']) . "', '" . $myrow['dissallowinvoices'] . "');\n");
+
+ }
+ fwrite($FileHandle,"DELETE FROM paymentterms;\n");
+
+ $result = DB_query('SELECT termsindicator, terms FROM paymentterms',$db);
+ while ($myrow = DB_fetch_array($result)) {
+
+ fwrite($FileHandle,"INSERT INTO paymentterms VALUES ('" . $myrow['termsindicator'] . "', '" . sqlite_escape_string ($myrow['terms']) . "');\n");
+
+ }
+
+ fwrite($FileHandle,"DELETE FROM paymentmethods;\n");
+ $result = DB_query('SELECT paymentid, paymentname,opencashdrawer FROM paymentmethods',$db);
+ while ($myrow = DB_fetch_array($result)) {
+
+ fwrite($FileHandle,"INSERT INTO paymentmethods VALUES ('" . $myrow['paymentid'] . "', '" . sqlite_escape_string ($myrow['paymentname']) . "', '" . $myrow['opencashdrawer'] . "');\n");
+
+ }
+
+ fwrite($FileHandle,"DELETE FROM locations;\n");
+ $result = DB_query('SELECT loccode, locationname,taxprovinceid FROM locations',$db);
+ while ($myrow = DB_fetch_array($result)) {
+
+ fwrite($FileHandle,"INSERT INTO locations VALUES ('" . $myrow['loccode'] . "', '" . sqlite_escape_string ($myrow['locationname']) . "', '" . $myrow['taxprovinceid'] . "');\n");
+
+ }
+
+ fwrite($FileHandle,"DELETE FROM stockcategory;\n");
+ $result = DB_query('SELECT categoryid, categorydescription FROM stockcategory',$db);
+ while ($myrow = DB_fetch_array($result)) {
+
+ fwrite($FileHandle,"INSERT INTO stockcategory VALUES ('" . $myrow['categoryid'] . "', '" . sqlite_escape_string ($myrow['categorydescription']) . "');\n");
+
+ }
+ fwrite($FileHandle,"DELETE FROM taxgroups;\n");
+ $result = DB_query('SELECT taxgroupid, taxgroupdescription FROM taxgroups',$db);
+ while ($myrow = DB_fetch_array($result)) {
+
+ fwrite($FileHandle,"INSERT INTO taxgroups VALUES ('" . $myrow['taxgroupid'] . "', '" . sqlite_escape_string ($myrow['taxgroupdescription']) . "');\n");
+
+ }
+
+ fwrite($FileHandle,"DELETE FROM taxgrouptaxes;\n");
+ $result = DB_query('SELECT taxgroupid, taxauthid, calculationorder, taxontax FROM taxgrouptaxes',$db);
+ while ($myrow = DB_fetch_array($result)) {
+
+ fwrite($FileHandle,"INSERT INTO taxgrouptaxes VALUES ('" . $myrow['taxgroupid'] . "', '" . $myrow['taxauthid'] . "', '" . $myrow['calculationorder'] . "', '" . $myrow['taxontax'] . "');\n");
+
+ }
+ fwrite($FileHandle,"DELETE FROM taxauthorities;\n");
+ $result = DB_query('SELECT taxid, description FROM taxauthorities',$db);
+ while ($myrow = DB_fetch_array($result)) {
+
+ fwrite($FileHandle,"INSERT INTO taxauthorities VALUES ('" . $myrow['taxid'] . "', '" . sqlite_escape_string ($myrow['description']) . "');\n");
+
+ }
+ fwrite($FileHandle,"DELETE FROM taxauthrates;\n");
+ $result = DB_query('SELECT taxauthority, dispatchtaxprovince, taxcatid, taxrate FROM taxauthrates',$db);
+ while ($myrow = DB_fetch_array($result)) {
+
+ fwrite($FileHandle,"INSERT INTO taxauthrates VALUES ('" . $myrow['taxauthority'] . "', '" . $myrow['dispatchtaxprovince'] . "', '" . $myrow['taxcatid'] . "', '" . $myrow['taxrate'] . "');\n");
+
+ }
+ fwrite($FileHandle,"DELETE FROM stockmaster;\n");
+ $result = DB_query("SELECT stockid, categoryid, description, longdescription, units, barcode, taxcatid, decimalplaces FROM stockmaster WHERE (mbflag='B' OR mbflag='M') AND discontinued=0 AND controlled=0",$db);
+ while ($myrow = DB_fetch_array($result)) {
+
+ fwrite($FileHandle,"INSERT INTO stockmaster VALUES ('" . sqlite_escape_string ($myrow['stockid']) . "', '" . sqlite_escape_string ($myrow['categoryid']) . "', '" . sqlite_escape_string ($myrow['description']) . "', '" . sqlite_escape_string (str_replace("\n", '', $myrow['longdescription'])) . "', '" . sqlite_escape_string ($myrow['units']) . "', '" . sqlite_escape_string ($myrow['barcode']) . "', '" . $myrow['taxcatid'] . "', '" . $myrow['decimalplaces'] . "');\n");
+ $Price = GetPrice ($myrow['stockid'], $_POST['POSDebtorNo'], $_POST['POSBranchCode'], $db,0);
+ if ($Price!=0) {
+ fwrite($FileHandle,"INSERT INTO prices (stockid, currabrev, typeabbrev, price) VALUES('" . $myrow['stockid'] . "', '" . $CurrCode . "', '" . $SalesType . "', '" . $Price . "');\n");
+ }
+
+ }
+ fwrite($FileHandle,"DELETE FROM debtorsmaster;\n");
+ $result = DB_query("SELECT debtorno, name, currcode, salestype, holdreason, paymentterms, discount, creditlimit, discountcode FROM debtorsmaster WHERE currcode='". $CurrCode . "'",$db);
+ while ($myrow = DB_fetch_array($result)) {
+
+ fwrite($FileHandle,"INSERT INTO debtorsmaster VALUES ('" . $myrow['debtorno'] . "', '" . sqlite_escape_string ($myrow['name']) . "', '" . $myrow['currcode'] . "', '" . $myrow['salestype'] . "', '" . $myrow['holdreason'] . "', '" . sqlite_escape_string ($myrow['paymentterms']) . "', '" . $myrow['discount'] . "', '" . $myrow['creditlimit'] . "', '" . $myrow['discountcode'] . "');\n");
+
+ }
+ fwrite($FileHandle,"DELETE FROM custbranch;\n");
+ $result = DB_query("SELECT branchcode, debtorsmaster.debtorno, brname, contactname, specialinstructions,taxgroupid FROM custbranch INNER JOIN debtorsmaster ON custbranch.debtorno=debtorsmaster.debtorno WHERE debtorsmaster.currcode='". $CurrCode . "'",$db);
+ while ($myrow = DB_fetch_array($result)) {
+
+ fwrite($FileHandle,"INSERT INTO custbranch VALUES ('" . $myrow['branchcode'] . "', '" . $myrow['debtorno'] . "', '" . sqlite_escape_string ($myrow['brname']) . "', '" . sqlite_escape_string ($myrow['contactname']) . "', '" . sqlite_escape_string ($myrow['specialinstructions']) . "', '" . $myrow['taxgroupid'] . "');\n");
+
+ }
+
+ fclose($FileHandle);
+ /*Now compress to a zip archive */
+ if (file_exists($_SESSION['reports_dir'] . '/POS.sql.zip')){
+ unlink($_SESSION['reports_dir'] . '/POS.sql.zip');
+ }
+ $ZipFile = new ZipArchive();
+ if ($ZipFile->open($_SESSION['reports_dir'] . '/POS.sql.zip', ZIPARCHIVE::CREATE)!==TRUE) {
+ exit("cannot open <" . $_SESSION['reports_dir'] . "/POS.sql.zip\n");
+ include('includes/footer.inc');
+ }
+ $ZipFile->addFile($_SESSION['reports_dir'] . '/POS.sql','POS.sql');
+ $ZipFile->close();
+}
+
+?>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|