From: <tim...@us...> - 2012-12-17 11:53:35
|
Revision: 5762 http://sourceforge.net/p/web-erp/reponame/5762 Author: tim_schofield Date: 2012-12-17 11:53:34 +0000 (Mon, 17 Dec 2012) Log Message: ----------- New inquiry script to show all the items purchased by the selected customer Modified Paths: -------------- trunk/SelectCustomer.php trunk/sql/mysql/upgrade4.09-4.10.sql Added Paths: ----------- trunk/CustomerPurchases.php Added: trunk/CustomerPurchases.php =================================================================== --- trunk/CustomerPurchases.php (rev 0) +++ trunk/CustomerPurchases.php 2012-12-17 11:53:34 UTC (rev 5762) @@ -0,0 +1,103 @@ +<?php + +include('includes/session.inc'); +$title = _('Customer Purchases'); +include('includes/header.inc'); + +if (isset($_GET['DebtorNo'])) { + $DebtorNo = $_GET['DebtorNo']; +} //isset($_GET['DebtorNo']) +else if (isset($_POST['DebtorNo'])) { + $DebtorNo = $_POST['DebtorNo']; +} //isset($_POST['DebtorNo']) +else { + prnMsg(_('This script must be called with a customer number.'), 'notice'); + include('includes/footer.inc'); + exit; +} + +$SQL = "SELECT debtorsmaster.name, + custbranch.brname + FROM debtorsmaster + INNER JOIN custbranch + ON debtorsmaster.debtorno=custbranch.debtorno + WHERE debtorsmaster.debtorno = '" . $DebtorNo . "'"; + +$ErrMsg = _('The customer details could not be retrieved by the SQL because'); +$CustomerResult = DB_query($SQL, $db, $ErrMsg); +$CustomerRecord = DB_fetch_array($CustomerResult); + +echo '<p class="page_title_text"> + <img src="' . $rootpath . '/css/' . $theme . '/images/customer.png" title="' . _('Customer') . '" alt="" /> ' . _('Items Purchased by Customer') . ' : ' . $CustomerRecord['name'] . ' + </p>'; + +$SQL = "SELECT stockmoves.stockid, + stockmaster.description, + systypes.typename, + transno, + locations.locationname, + trandate, + branchcode, + price, + reference, + qty, + narrative + FROM stockmoves + INNER JOIN stockmaster + ON stockmaster.stockid=stockmoves.stockid + INNER JOIN systypes + ON stockmoves.type=systypes.typeid + INNER JOIN locations + ON stockmoves.loccode=locations.loccode + WHERE debtorno='" . $DebtorNo . "' + ORDER BY trandate DESC"; +$ErrMsg = _('The stock movement details could not be retrieved by the SQL because'); +$StockMovesResult = DB_query($SQL, $db, $ErrMsg); + +if (DB_num_rows($StockMovesResult) == 0) { + echo '<br />'; + prnMsg(_('There are no items for this customer'), 'notice'); + echo '<br />'; +} //DB_num_rows($StockMovesResult) == 0 +else { + echo '<table class="selection"> + <tr> + <th>' . _('Transaction Date') . '</th> + <th>' . _('Stock ID') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Type') . '</th> + <th>' . _('Transaction No.') . '</th> + <th>' . _('From Location') . '</th> + <th>' . _('Branch Code') . '</th> + <th>' . _('Price') . '</th> + <th>' . _('Quantity') . '</th> + <th>' . _('Amount of Sale') . '</th> + <th>' . _('Reference') . '</th> + <th>' . _('Narrative') . '</th> + </tr>'; + + while ($StockMovesRow = DB_fetch_array($StockMovesResult)) { + echo '<tr> + <td>' . ConvertSQLDate($StockMovesRow['trandate']) . '</td> + <td>' . $StockMovesRow['stockid'] . '</td> + <td>' . $StockMovesRow['description'] . '</td> + <td>' . $StockMovesRow['typename'] . '</td> + <td>' . $StockMovesRow['transno'] . '</td> + <td>' . $StockMovesRow['locationname'] . '</td> + <td>' . $StockMovesRow['branchcode'] . '</td> + <td class="number">' . locale_number_format($StockMovesRow['price'], $_SESSION['CompanyRecord']['decimalplaces']) . '</td> + <td class="number">' . locale_number_format(-$StockMovesRow['qty'], $_SESSION['CompanyRecord']['decimalplaces']) . '</td> + <td class="number">' . locale_number_format((-$StockMovesRow['qty'] * $StockMovesRow['price']), $_SESSION['CompanyRecord']['decimalplaces']) . '</td> + <td>' . $StockMovesRow['reference'] . '</td> + <td>' . $StockMovesRow['narrative'] . '</td> + </tr>'; + + } //$StockMovesRow = DB_fetch_array($StockMovesResult) + + echo '</table>'; +} + +echo '<br /><div class="centre"><a href="SelectCustomer.php">' . _('Return to customer screen') . '</a></div><br />'; + +include('includes/footer.inc'); +?> \ No newline at end of file Modified: trunk/SelectCustomer.php =================================================================== --- trunk/SelectCustomer.php 2012-12-15 04:56:05 UTC (rev 5761) +++ trunk/SelectCustomer.php 2012-12-17 11:53:34 UTC (rev 5762) @@ -2,31 +2,31 @@ /* $Id$*/ -include ('includes/session.inc'); +include('includes/session.inc'); $title = _('Search Customers'); -include ('includes/header.inc'); -include ('includes/SQL_CommonFunctions.inc'); +include('includes/header.inc'); +include('includes/SQL_CommonFunctions.inc'); if (isset($_GET['Select'])) { $_SESSION['CustomerID'] = $_GET['Select']; -} +} //isset($_GET['Select']) if (!isset($_SESSION['CustomerID'])) { //initialise if not already done $_SESSION['CustomerID'] = ''; -} +} //!isset($_SESSION['CustomerID']) if (isset($_GET['Area'])) { - $_POST['Area']=$_GET['Area']; - $_POST['Search']='Search'; - $_POST['Keywords']=''; - $_POST['CustCode']=''; - $_POST['CustPhone']=''; - $_POST['CustAdd']=''; - $_POST['CustType']=''; -} + $_POST['Area'] = $_GET['Area']; + $_POST['Search'] = 'Search'; + $_POST['Keywords'] = ''; + $_POST['CustCode'] = ''; + $_POST['CustPhone'] = ''; + $_POST['CustAdd'] = ''; + $_POST['CustType'] = ''; +} //isset($_GET['Area']) echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/customer.png" title="' . _('Customer') . '" alt="" />' . ' ' . _('Customers') . '</p>'; if (!isset($_SESSION['CustomerType'])) { //initialise if not already done $_SESSION['CustomerType'] = ''; -} +} //!isset($_SESSION['CustomerType']) // only run geocode if integration is turned on and customer has been selected -if ($_SESSION['geocode_integration'] == 1 AND $_SESSION['CustomerID'] != "") { +if ($_SESSION['geocode_integration'] == 1 and $_SESSION['CustomerID'] != "") { $sql = "SELECT * FROM geocode_param WHERE 1"; $ErrMsg = _('An error occurred in retrieving the information'); $result = DB_query($sql, $db, $ErrMsg); @@ -71,38 +71,28 @@ } </script>'; echo '<body onload="load()" onunload="GUnload()">'; -} +} //$_SESSION['geocode_integration'] == 1 and $_SESSION['CustomerID'] != "" unset($result); $msg = ''; if (isset($_POST['Go1']) or isset($_POST['Go2'])) { $_POST['PageOffset'] = (isset($_POST['Go1']) ? $_POST['PageOffset1'] : $_POST['PageOffset2']); $_POST['Go'] = ''; -} +} //isset($_POST['Go1']) or isset($_POST['Go2']) if (!isset($_POST['PageOffset'])) { $_POST['PageOffset'] = 1; -} else { +} //!isset($_POST['PageOffset']) +else { if ($_POST['PageOffset'] == 0) { $_POST['PageOffset'] = 1; - } + } //$_POST['PageOffset'] == 0 } -if (isset($_POST['Search']) - OR isset($_POST['CSV']) - OR isset($_POST['Go']) - OR isset($_POST['Next']) - OR isset($_POST['Previous'])) { - +if (isset($_POST['Search']) or isset($_POST['CSV']) or isset($_POST['Go']) or isset($_POST['Next']) or isset($_POST['Previous'])) { unset($_POST['JustSelectedACustomer']); if (isset($_POST['Search'])) { $_POST['PageOffset'] = 1; - } + } //isset($_POST['Search']) - if (($_POST['Keywords'] == '') - AND ($_POST['CustCode'] == '') - AND ($_POST['CustPhone'] == '') - AND ($_POST['CustType'] == 'ALL') - AND ($_POST['Area'] == 'ALL') - AND ($_POST['CustAdd'] == '')) { - + if (($_POST['Keywords'] == '') and ($_POST['CustCode'] == '') and ($_POST['CustPhone'] == '') and ($_POST['CustType'] == 'ALL') and ($_POST['Area'] == 'ALL') and ($_POST['CustAdd'] == '')) { //no criteria set then default to all customers $SQL = "SELECT debtorsmaster.debtorno, debtorsmaster.name, @@ -121,7 +111,8 @@ ON debtorsmaster.debtorno = custbranch.debtorno INNER JOIN debtortype ON debtorsmaster.typeid = debtortype.typeid"; - } else { + } //($_POST['Keywords'] == '') and ($_POST['CustCode'] == '') and ($_POST['CustPhone'] == '') and ($_POST['CustType'] == 'ALL') and ($_POST['Area'] == 'ALL') and ($_POST['CustAdd'] == '') + else { $SearchKeywords = mb_strtoupper(trim(str_replace(' ', '%', $_POST['Keywords']))); $_POST['CustCode'] = mb_strtoupper(trim($_POST['CustCode'])); $_POST['CustPhone'] = trim($_POST['CustPhone']); @@ -148,23 +139,22 @@ AND custbranch.phoneno " . LIKE . " '%" . $_POST['CustPhone'] . "%' AND (debtorsmaster.address1 " . LIKE . " '%" . $_POST['CustAdd'] . "%' OR debtorsmaster.address2 " . LIKE . " '%" . $_POST['CustAdd'] . "%' - OR debtorsmaster.address3 " . LIKE . " '%" . $_POST['CustAdd'] . "%' - OR debtorsmaster.address4 " . LIKE . " '%" . $_POST['CustAdd'] . "%')"; + OR debtorsmaster.address3 " . LIKE . " '%" . $_POST['CustAdd'] . "%' + OR debtorsmaster.address4 " . LIKE . " '%" . $_POST['CustAdd'] . "%')"; - if (mb_strlen($_POST['CustType']) > 0 AND $_POST['CustType']!='ALL') { + if (mb_strlen($_POST['CustType']) > 0 and $_POST['CustType'] != 'ALL') { $SQL .= " AND debtortype.typename = '" . $_POST['CustType'] . "'"; - } - if (mb_strlen($_POST['Area']) > 0 AND $_POST['Area']!='ALL') { + } //mb_strlen($_POST['CustType']) > 0 and $_POST['CustType'] != 'ALL' + if (mb_strlen($_POST['Area']) > 0 and $_POST['Area'] != 'ALL') { $SQL .= " AND custbranch.area = '" . $_POST['Area'] . "'"; - } + } //mb_strlen($_POST['Area']) > 0 and $_POST['Area'] != 'ALL' } //one of keywords or custcode or custphone was more than a zero length string if ($_SESSION['SalesmanLogin'] != '') { - $SQL.= " AND custbranch.salesman='" . $_SESSION['SalesmanLogin'] . "'"; - } - $SQL.= " ORDER BY debtorsmaster.name"; + $SQL .= " AND custbranch.salesman='" . $_SESSION['SalesmanLogin'] . "'"; + } //$_SESSION['SalesmanLogin'] != '' + $SQL .= " ORDER BY debtorsmaster.name"; $ErrMsg = _('The searched customer records requested cannot be retrieved because'); - $result = DB_query($SQL, $db, $ErrMsg); if (DB_num_rows($result) == 1) { $myrow = DB_fetch_array($result); @@ -172,37 +162,39 @@ $_SESSION['BranchCode'] = $myrow['branchcode']; unset($result); unset($_POST['Search']); - } elseif (DB_num_rows($result) == 0) { + } //DB_num_rows($result) == 1 + elseif (DB_num_rows($result) == 0) { prnMsg(_('No customer records contain the selected text') . ' - ' . _('please alter your search criteria and try again'), 'info'); echo '<br />'; - } + } //DB_num_rows($result) == 0 } //end of if search -if (isset($_POST['JustSelectedACustomer'])){ +if (isset($_POST['JustSelectedACustomer'])) { /*Need to figure out the number of the form variable that the user clicked on */ - for ($i=0; $i<count($_POST); $i++){ //loop through the returned customers - if(isset($_POST['SubmitCustomerSelection'.$i])){ + for ($i = 0; $i < count($_POST); $i++) { //loop through the returned customers + if (isset($_POST['SubmitCustomerSelection' . $i])) { break; - } + } //isset($_POST['SubmitCustomerSelection' . $i]) + } //$i = 0; $i < count($_POST); $i++ + if ($i == count($_POST)) { + prnMsg(_('Unable to identify the selected customer'), 'error'); + } //$i == count($_POST) + else { + $_SESSION['CustomerID'] = $_POST['SelectedCustomer' . $i]; + $_SESSION['BranchCode'] = $_POST['SelectedBranch' . $i]; } - if ($i==count($_POST)){ - prnMsg(_('Unable to identify the selected customer'),'error'); - } else { - $_SESSION['CustomerID'] = $_POST['SelectedCustomer'.$i]; - $_SESSION['BranchCode'] = $_POST['SelectedBranch'.$i]; - } -} +} //isset($_POST['JustSelectedACustomer']) -if ($_SESSION['CustomerID'] != '' AND !isset($_POST['Search']) AND !isset($_POST['CSV'])) { - if (!isset($_SESSION['BranchCode'])){ - +if ($_SESSION['CustomerID'] != '' and !isset($_POST['Search']) and !isset($_POST['CSV'])) { + if (!isset($_SESSION['BranchCode'])) { $SQL = "SELECT debtorsmaster.name, custbranch.phoneno FROM debtorsmaster INNER JOIN custbranch ON debtorsmaster.debtorno=custbranch.debtorno WHERE custbranch.debtorno='" . $_SESSION['CustomerID'] . "'"; - } else { + } //!isset($_SESSION['BranchCode']) + else { $SQL = "SELECT debtorsmaster.name, custbranch.phoneno FROM debtorsmaster INNER JOIN custbranch @@ -213,9 +205,9 @@ $ErrMsg = _('The customer name requested cannot be retrieved because'); $result = DB_query($SQL, $db, $ErrMsg); if ($myrow = DB_fetch_array($result)) { - $CustomerName = htmlspecialchars($myrow['name'],ENT_QUOTES,'UTF-8',false); + $CustomerName = htmlspecialchars($myrow['name'], ENT_QUOTES, 'UTF-8', false); $PhoneNo = $myrow['phoneno']; - } + } //$myrow = DB_fetch_array($result) unset($result); echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/customer.png" title="' . _('Customer') . '" alt="" />' . ' ' . _('Customer') . ' : ' . $_SESSION['CustomerID'] . ' - ' . $CustomerName . ' - ' . $PhoneNo . _(' has been selected') . '</p>'; @@ -233,13 +225,15 @@ echo '<a href="' . $rootpath . '/Customers.php?DebtorNo=' . $_SESSION['CustomerID'] . '&Modify=No">' . _('View Customer Details') . '</a><br />'; echo '<a href="' . $rootpath . '/PrintCustStatements.php?FromCust=' . $_SESSION['CustomerID'] . '&ToCust=' . $_SESSION['CustomerID'] . '&PrintPDF=Yes">' . _('Print Customer Statement') . '</a><br />'; echo '<a href="' . $rootpath . '/SelectCompletedOrder.php?SelectedCustomer=' . $_SESSION['CustomerID'] . '">' . _('Order Inquiries') . '</a><br />'; + echo '<a href="' . $rootpath . '/CustomerPurchases.php?DebtorNo=' . $_SESSION['CustomerID'] . '">' . _('Show purchases from this customer') . '</a><br />'; wikiLink('Customer', $_SESSION['CustomerID']); echo '</td><td valign="top" class="select">'; echo '<a href="' . $rootpath . '/SelectSalesOrder.php?SelectedCustomer=' . $_SESSION['CustomerID'] . '">' . _('Modify Outstanding Sales Orders') . '</a><br />'; echo '<a href="' . $rootpath . '/CustomerAllocations.php?DebtorNo=' . $_SESSION['CustomerID'] . '">' . _('Allocate Receipts or Credit Notes') . '</a><br />'; - if (isset($_SESSION['CustomerID']) AND isset($_SESSION['BranchCode'])){ + echo '<a href="' . $rootpath . '/JobCards.php?DebtorNo=' . $_SESSION['CustomerID'] . '&BranchNo=' . $_SESSION['BranchCode'] . '">' . _('Job Cards') . '</a><br />'; + if (isset($_SESSION['CustomerID']) and isset($_SESSION['BranchCode'])) { echo '<a href="' . $rootpath . '/CounterSales.php?DebtorNo=' . $_SESSION['CustomerID'] . '&BranchNo=' . $_SESSION['BranchCode'] . '">' . _('Create a Counter Sale for this Customer') . '</a><br />'; - } + } //isset($_SESSION['CustomerID']) and isset($_SESSION['BranchCode']) echo '</td><td valign="top" class="select">'; echo '<a href="' . $rootpath . '/Customers.php?">' . _('Add a New Customer') . '</a><br />'; echo '<a href="' . $rootpath . '/Customers.php?DebtorNo=' . $_SESSION['CustomerID'] . '">' . _('Modify Customer Details') . '</a><br />'; @@ -249,7 +243,8 @@ echo '<a href="' . $rootpath . '/CustLoginSetup.php">' . _('Customer Login Configuration') . '</a>'; echo '</td>'; echo '</tr></table><br />'; -} else { +} //$_SESSION['CustomerID'] != '' and !isset($_POST['Search']) and !isset($_POST['CSV']) +else { echo '<table width="90%"> <tr> <th style="width:33%">' . _('Customer Inquiries') . '</th> @@ -262,21 +257,22 @@ <td class="select">'; if (!isset($_SESSION['SalesmanLogin']) or $_SESSION['SalesmanLogin'] == '') { echo '<a href="' . $rootpath . '/Customers.php?">' . _('Add a New Customer') . '</a><br />'; - } + } //!isset($_SESSION['SalesmanLogin']) or $_SESSION['SalesmanLogin'] == '' echo '</td></tr></table>'; } -echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">'; +echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">'; echo '<div>'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; -if (mb_strlen($msg)>1){ - prnMsg($msg,'info'); -} -echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Search') . '" alt="" />' . ' ' . _('Search for Customers').'</p>'; +if (mb_strlen($msg) > 1) { + prnMsg($msg, 'info'); +} //mb_strlen($msg) > 1 +echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Search') . '" alt="" />' . ' ' . _('Search for Customers') . '</p>'; echo '<table cellpadding="3" class="selection">'; echo '<tr><td colspan="2">' . _('Enter a partial Name') . ':</td><td>'; if (isset($_POST['Keywords'])) { echo '<input type="text" name="Keywords" value="' . $_POST['Keywords'] . '" size="20" maxlength="25" />'; -} else { +} //isset($_POST['Keywords']) +else { echo '<input type="text" name="Keywords" size="20" maxlength="25" />'; } echo '</td> @@ -284,7 +280,8 @@ <td>'; if (isset($_POST['CustCode'])) { echo '<input type="text" name="CustCode" value="' . $_POST['CustCode'] . '" size="15" maxlength="18" />'; -} else { +} //isset($_POST['CustCode']) +else { echo '<input type="text" name="CustCode" size="15" maxlength="18" />'; } echo '</td> @@ -295,7 +292,8 @@ <td>'; if (isset($_POST['CustPhone'])) { echo '<input type="text" name="CustPhone" value="' . $_POST['CustPhone'] . '" size="15" maxlength="18" />'; -} else { +} //isset($_POST['CustPhone']) +else { echo '<input type="text" name="CustPhone" size="15" maxlength="18" />'; } echo '</td>'; @@ -304,7 +302,8 @@ <td>'; if (isset($_POST['CustAdd'])) { echo '<input type="text" name="CustAdd" value="' . $_POST['CustAdd'] . '" size="20" maxlength="25" />'; -} else { +} //isset($_POST['CustAdd']) +else { echo '<input type="text" name="CustAdd" size="20" maxlength="25" />'; } echo '</td></tr>'; @@ -320,21 +319,24 @@ $DataError = 1; echo '<a href="CustomerTypes.php" target="_parent">' . _('Setup Types') . '</a>'; echo '<tr><td colspan="2">' . prnMsg(_('No Customer types defined'), 'error') . '</td></tr>'; - } else { + } //DB_num_rows($result2) == 0 + else { // If OK show select box with option selected echo '<select name="CustType"> <option value="ALL">' . _('Any') . '</option>'; while ($myrow = DB_fetch_array($result2)) { if ($_POST['CustType'] == $myrow['typename']) { - echo '<option selected="selected" value="' . $myrow['typename'] . '">' . $myrow['typename'] . '</option>'; - } else { - echo '<option value="' . $myrow['typename'] . '">' . $myrow['typename'] . '</option>'; + echo '<option selected="selected" value="' . $myrow['typename'] . '">' . $myrow['typename'] . '</option>'; + } //$_POST['CustType'] == $myrow['typename'] + else { + echo '<option value="' . $myrow['typename'] . '">' . $myrow['typename'] . '</option>'; } } //end while loop DB_data_seek($result2, 0); echo '</select></td>'; } -} else { +} //isset($_POST['CustType']) +else { // No option selected="selected" yet, so show Customer Type drop down list $result2 = DB_query("SELECT typeid, typename FROM debtortype", $db); // Error if no customer types setup @@ -342,10 +344,11 @@ $DataError = 1; echo '<a href="CustomerTypes.php" target="_parent">' . _('Setup Types') . '</a>'; echo '<tr><td colspan="2">' . prnMsg(_('No Customer types defined'), 'error') . '</td></tr>'; - } else { + } //DB_num_rows($result2) == 0 + else { // if OK show select box with available options to choose echo '<select name="CustType"> - <option value="ALL">' . _('Any'). '</option>'; + <option value="ALL">' . _('Any') . '</option>'; while ($myrow = DB_fetch_array($result2)) { echo '<option value="' . $myrow['typename'] . '">' . $myrow['typename'] . '</option>'; } //end while loop @@ -363,14 +366,16 @@ $DataError = 1; echo '<a href="Areas.php" target="_parent">' . _('Setup Areas') . '</a>'; echo '<tr><td colspan="2">' . prnMsg(_('No Sales Areas defined'), 'error') . '</td></tr>'; -} else { +} //DB_num_rows($result2) == 0 +else { // if OK show select box with available options to choose echo '<select name="Area">'; echo '<option value="ALL">' . _('Any') . '</option>'; while ($myrow = DB_fetch_array($result2)) { - if (isset($_POST['Area']) and $_POST['Area']==$myrow['areacode']) { + if (isset($_POST['Area']) and $_POST['Area'] == $myrow['areacode']) { echo '<option selected="selected" value="' . $myrow['areacode'] . '">' . $myrow['areadescription'] . '</option>'; - } else { + } //isset($_POST['Area']) and $_POST['Area'] == $myrow['areacode'] + else { echo '<option value="' . $myrow['areacode'] . '">' . $myrow['areadescription'] . '</option>'; } } //end while loop @@ -385,7 +390,7 @@ </div>'; if (isset($_SESSION['SalesmanLogin']) and $_SESSION['SalesmanLogin'] != '') { prnMsg(_('Your account enables you to see only customers allocated to you'), 'warn', _('Note: Sales-person Login')); -} +} //isset($_SESSION['SalesmanLogin']) and $_SESSION['SalesmanLogin'] != '' if (isset($result)) { unset($_SESSION['CustomerID']); $ListCount = DB_num_rows($result); @@ -394,13 +399,13 @@ if (isset($_POST['Next'])) { if ($_POST['PageOffset'] < $ListPageMax) { $_POST['PageOffset'] = $_POST['PageOffset'] + 1; - } - } + } //$_POST['PageOffset'] < $ListPageMax + } //isset($_POST['Next']) if (isset($_POST['Previous'])) { if ($_POST['PageOffset'] > 1) { $_POST['PageOffset'] = $_POST['PageOffset'] - 1; - } - } + } //$_POST['PageOffset'] > 1 + } //isset($_POST['Previous']) echo '<input type="hidden" name="PageOffset" value="' . $_POST['PageOffset'] . '" />'; if ($ListPageMax > 1) { echo '<br /><div class="centre"> ' . $_POST['PageOffset'] . ' ' . _('of') . ' ' . $ListPageMax . ' ' . _('pages') . '. ' . _('Go to Page') . ': '; @@ -409,17 +414,18 @@ while ($ListPage <= $ListPageMax) { if ($ListPage == $_POST['PageOffset']) { echo '<option value="' . $ListPage . '" selected="selected">' . $ListPage . '</option>'; - } else { + } //$ListPage == $_POST['PageOffset'] + else { echo '<option value="' . $ListPage . '">' . $ListPage . '</option>'; } $ListPage++; - } + } //$ListPage <= $ListPageMax echo '</select> <input type="submit" name="Go1" value="' . _('Go') . '" /> <input type="submit" name="Previous" value="' . _('Previous') . '" /> <input type="submit" name="Next" value="' . _('Next') . '" />'; echo '</div>'; - } + } //$ListPageMax > 1 echo '<br /> <table cellpadding="2" class="selection">'; $TableHeader = '<tr> @@ -436,7 +442,7 @@ $j = 1; $k = 0; //row counter to determine background colour $RowIndex = 0; - } + } //!isset($_POST['CSV']) if (DB_num_rows($result) <> 0) { if (isset($_POST['CSV'])) { $FileName = $_SESSION['reports_dir'] . '/Customer_Listing_' . Date('Y-m-d') . '.csv'; @@ -444,25 +450,26 @@ $fp = fopen($FileName, 'w'); while ($myrow2 = DB_fetch_array($result)) { fwrite($fp, $myrow2['debtorno'] . ',' . str_replace(',', '', $myrow2['name']) . ',' . str_replace(',', '', $myrow2['address1']) . ',' . str_replace(',', '', $myrow2['address2']) . ',' . str_replace(',', '', $myrow2['address3']) . ',' . str_replace(',', '', $myrow2['address4']) . ',' . str_replace(',', '', $myrow2['contactname']) . ',' . str_replace(',', '', $myrow2['typename']) . ',' . $myrow2['phoneno'] . ',' . $myrow2['faxno'] . ',' . $myrow2['email'] . "\n"); - } - } + } //$myrow2 = DB_fetch_array($result) + } //isset($_POST['CSV']) if (!isset($_POST['CSV'])) { DB_data_seek($result, ($_POST['PageOffset'] - 1) * $_SESSION['DisplayRecordsMax']); - } - $i=0; //counter for input controls - while (($myrow = DB_fetch_array($result)) AND ($RowIndex <> $_SESSION['DisplayRecordsMax'])) { + } //!isset($_POST['CSV']) + $i = 0; //counter for input controls + while (($myrow = DB_fetch_array($result)) and ($RowIndex <> $_SESSION['DisplayRecordsMax'])) { if ($k == 1) { echo '<tr class="EvenTableRows">'; $k = 0; - } else { + } //$k == 1 + else { echo '<tr class="OddTableRows">'; $k = 1; } - echo '<td><input type="submit" name="SubmitCustomerSelection' . $i .'" value="' . htmlspecialchars($myrow['debtorno'].' '.$myrow['branchcode'],ENT_QUOTES,'UTF-8',false) . '" /> - <input type="hidden" name="SelectedCustomer' . $i . '" value="'.$myrow['debtorno'].'" /> - <input type="hidden" name="SelectedBranch' . $i . '" value="'. $myrow['branchcode'].'" /></td> - <td>' . htmlspecialchars($myrow['name'],ENT_QUOTES,'UTF-8',false) . '</td> - <td>' . htmlspecialchars($myrow['brname'],ENT_QUOTES,'UTF-8',false) . '</td> + echo '<td><input type="submit" name="SubmitCustomerSelection' . $i . '" value="' . htmlspecialchars($myrow['debtorno'] . ' ' . $myrow['branchcode'], ENT_QUOTES, 'UTF-8', false) . '" /> + <input type="hidden" name="SelectedCustomer' . $i . '" value="' . $myrow['debtorno'] . '" /> + <input type="hidden" name="SelectedBranch' . $i . '" value="' . $myrow['branchcode'] . '" /></td> + <td>' . htmlspecialchars($myrow['name'], ENT_QUOTES, 'UTF-8', false) . '</td> + <td>' . htmlspecialchars($myrow['brname'], ENT_QUOTES, 'UTF-8', false) . '</td> <td>' . $myrow['contactname'] . '</td> <td>' . $myrow['typename'] . '</td> <td>' . $myrow['phoneno'] . '</td> @@ -470,19 +477,19 @@ <td>' . $myrow['email'] . '</td> </tr>'; $i++; - $j++;//row counter - if ($j == 11 AND ($RowIndex + 1 != $_SESSION['DisplayRecordsMax'])) { + $j++; //row counter + if ($j == 11 and ($RowIndex + 1 != $_SESSION['DisplayRecordsMax'])) { $j = 1; echo $TableHeader; - } + } //$j == 11 and ($RowIndex + 1 != $_SESSION['DisplayRecordsMax']) $RowIndex++; //end of page full new headings if - } + } //($myrow = DB_fetch_array($result)) and ($RowIndex <> $_SESSION['DisplayRecordsMax']) //end of while loop echo '</table>'; echo '<input type="hidden" name="JustSelectedACustomer" value="Yes" />'; - } -} + } //DB_num_rows($result) <> 0 +} //isset($result) //end if results to show if (!isset($_POST['CSV'])) { if (isset($ListPageMax) and $ListPageMax > 1) { @@ -492,19 +499,20 @@ while ($ListPage <= $ListPageMax) { if ($ListPage == $_POST['PageOffset']) { echo '<option value="' . $ListPage . '" selected="selected">' . $ListPage . '</option>'; - } else { + } //$ListPage == $_POST['PageOffset'] + else { echo '<option value="' . $ListPage . '">' . $ListPage . '</option>'; } $ListPage++; - } + } //$ListPage <= $ListPageMax echo '</select> <input type="submit" name="Go2" value="' . _('Go') . '" /> <input type="submit" name="Previous" value="' . _('Previous') . '" /> <input type="submit" name="Next" value="' . _('Next') . '" />'; - echo '</div>'; - } + echo '</div>'; + } //isset($ListPageMax) and $ListPageMax > 1 //end if results to show -} +} //!isset($_POST['CSV']) echo '</div> </form>'; // Only display the geocode map if the integration is turned on, and there is a latitude/longitude to display @@ -513,7 +521,8 @@ echo '<br />'; if ($Lattitude == 0) { echo '<div class="centre">' . _('Mapping is enabled, but no Mapping data to display for this Customer.') . '</div>'; - } else { + } //$Lattitude == 0 + else { echo '<tr> <td colspan="2"> <table width="45%" cellpadding="4"> @@ -531,7 +540,7 @@ </tr> </table>'; } - } + } //$_SESSION['geocode_integration'] == 1 // Extended Customer Info only if selected in Configuration if ($_SESSION['Extended_CustomerInfo'] == 1) { if ($_SESSION['CustomerID'] != '') { @@ -569,13 +578,15 @@ $row = DB_fetch_array($Total1Result); echo '<table width="45%" cellpadding="4">'; echo '<tr><th style="width:33%" colspan="3">' . _('Customer Data') . '</th></tr>'; - echo '<tr><td valign="top" class="select">'; /* Customer Data */ + echo '<tr><td valign="top" class="select">'; + /* Customer Data */ if ($myrow['lastpaiddate'] == 0) { echo _('No receipts from this customer.') . '</td> <td class="select"></td> <td class="select"></td> </tr>'; - } else { + } //$myrow['lastpaiddate'] == 0 + else { echo _('Last Paid Date:') . '</td> <td class="select"> <b>' . ConvertSQLDate($myrow['lastpaiddate']) . '</b> </td> <td class="select">' . $myrow['lastpaiddays'] . ' ' . _('days') . '</td> @@ -595,7 +606,8 @@ <td class="select"></td> <td class="select"></td> </tr>'; - } else { + } //$row['total'] == 0 + else { echo '<tr> <td class="select">' . _('Total Spend from this Customer (inc tax):') . ' </td> <td class="select"><b>' . locale_number_format($row['total'], $myrow['currdecimalplaces']) . '</b></td> @@ -608,7 +620,7 @@ <td class="select"></td> </tr>'; echo '</table>'; - } + } //$_SESSION['CustomerID'] != '' // Customer Contacts $sql = "SELECT * FROM custcontacts WHERE debtorno='" . $_SESSION['CustomerID'] . "' @@ -616,7 +628,7 @@ $result = DB_query($sql, $db); if (DB_num_rows($result) <> 0) { echo '<br /><div class="centre"><img src="' . $rootpath . '/css/' . $theme . '/images/group_add.png" title="' . _('Customer Contacts') . '" alt="" />' . ' ' . _('Customer Contacts') . '</div>'; - echo '<br /><table width="45%">'; + echo '<br /><table width="45%">'; echo '<tr> <th>' . _('Name') . '</th> <th>' . _('Role') . '</th> @@ -632,7 +644,8 @@ if ($k == 1) { echo '<tr class="OddTableRows">'; $k = 0; - } else { + } //$k == 1 + else { echo '<tr class="EvenTableRows">'; $k = 1; } @@ -646,10 +659,11 @@ </tr>'; } //END WHILE LIST LOOP echo '</table>'; - } else { + } //DB_num_rows($result) <> 0 + else { if ($_SESSION['CustomerID'] != "") { echo '<br /><div class="centre"><img src="' . $rootpath . '/css/' . $theme . '/images/group_add.png" title="' . _('Customer Contacts') . '" alt="" /><a href="AddCustomerContacts.php?DebtorNo=' . $_SESSION['CustomerID'] . '">' . ' ' . _('Add New Contact') . '</a></div>'; - } + } //$_SESSION['CustomerID'] != "" } // Customer Notes $sql = "SELECT noteid, @@ -679,7 +693,8 @@ if ($k == 1) { echo '<tr class="OddTableRows">'; $k = 0; - } else { + } //$k == 1 + else { echo '<tr class="EvenTableRows">'; $k = 1; } @@ -692,10 +707,11 @@ </tr>'; } //END WHILE LIST LOOP echo '</table>'; - } else { + } //DB_num_rows($result) <> 0 + else { if ($_SESSION['CustomerID'] != '') { echo '<br /><div class="centre"><img src="' . $rootpath . '/css/' . $theme . '/images/note_add.png" title="' . _('Customer Notes') . '" alt="" /><a href="AddCustomerNotes.php?DebtorNo=' . $_SESSION['CustomerID'] . '">' . ' ' . _('Add New Note for this Customer') . '</a></div>'; - } + } //$_SESSION['CustomerID'] != '' } // Custome Type Notes $sql = "SELECT * FROM debtortypenotes @@ -719,7 +735,8 @@ if ($k == 1) { echo '<tr class="OddTableRows">'; $k = 0; - } else { + } //$k == 1 + else { echo '<tr class="EvenTableRows">'; $k = 1; } @@ -732,13 +749,14 @@ </tr>'; } //END WHILE LIST LOOP echo '</table>'; - } else { + } //DB_num_rows($result) <> 0 + else { if ($_SESSION['CustomerID'] != '') { - echo '<br /><div class="centre"><img src="' . $rootpath . '/css/' . $theme . '/images/folder_add.png" title="' . _('Customer Group Notes') . '" alt="" /><a href="AddCustomerTypeNotes.php?DebtorType=' . $CustomerType . '">' . ' ' . _('Add New Group Note') . '</a></div><br />'; - } + echo '<br /><div class="centre"><img src="' . $rootpath . '/css/' . $theme . '/images/folder_add.png" title="' . _('Customer Group Notes') . '" alt="" /><a href="AddCustomerTypeNotes.php?DebtorType=' . $CustomerType . '">' . ' ' . _('Add New Group Note') . '</a></div><br />'; + } //$_SESSION['CustomerID'] != '' } - } -} + } //$_SESSION['Extended_CustomerInfo'] == 1 +} //isset($_SESSION['CustomerID']) and $_SESSION['CustomerID'] != '' echo '<script type="text/javascript">defaultControl(document.forms[0].CustCode);</script>'; -include ('includes/footer.inc'); +include('includes/footer.inc'); ?> \ No newline at end of file Modified: trunk/sql/mysql/upgrade4.09-4.10.sql =================================================================== --- trunk/sql/mysql/upgrade4.09-4.10.sql 2012-12-15 04:56:05 UTC (rev 5761) +++ trunk/sql/mysql/upgrade4.09-4.10.sql 2012-12-17 11:53:34 UTC (rev 5762) @@ -10,4 +10,4 @@ ); UPDATE config SET confvalue='4.10.0' WHERE confname='VersionNumber'; - +INSERT INTO scripts VALUES ('CustomerPurchases.php','5','Shows the purchases a customer has made.'); |