From: <dai...@us...> - 2011-09-25 09:15:12
|
Revision: 4706 http://web-erp.svn.sourceforge.net/web-erp/?rev=4706&view=rev Author: daintree Date: 2011-09-25 09:15:03 +0000 (Sun, 25 Sep 2011) Log Message: ----------- number_formats Modified Paths: -------------- trunk/GLAccountReport.php trunk/SalesCategoryPeriodInquiry.php trunk/SalesInquiry.php trunk/SalesPeople.php trunk/SalesTopItemsInquiry.php trunk/SalesTypes.php trunk/SecurityTokens.php trunk/includes/LanguageSetup.php Modified: trunk/GLAccountReport.php =================================================================== --- trunk/GLAccountReport.php 2011-09-25 03:05:27 UTC (rev 4705) +++ trunk/GLAccountReport.php 2011-09-25 09:15:03 UTC (rev 4706) @@ -136,19 +136,8 @@ if ($myrow['periodno']!=$PeriodNo){ if ($PeriodNo!=-9999){ //ie its not the first time around - /*Get the ChartDetails balance b/fwd and the actual movement in the account for the period as recorded in the chart details - need to ensure integrity of transactions to the chart detail movements. Also, for a balance sheet account it is the balance carried forward that is important, not just the transactions*/ - $sql = "SELECT bfwd, - actual, - period - FROM chartdetails - WHERE chartdetails.accountcode='" . $SelectedAccount . "' - AND chartdetails.period='" . $PeriodNo . "'"; - - $ErrMsg = _('The chart details for account') . ' ' . $SelectedAccount . ' ' . _('could not be retrieved'); - $ChartDetailsResult = DB_query($sql,$db,$ErrMsg); - $ChartDetailRow = DB_fetch_array($ChartDetailsResult); - $YPos -=$line_height; - $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,150,$FontSize, _('Period Total')); + $YPos -=$line_height; + $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,150,$FontSize, _('Period Total')); if ($PeriodTotal < 0 ){ //its a credit balance b/fwd $LeftOvers = $pdf->addTextWrap(210,$YPos,50,$FontSize, locale_money_format(-$PeriodTotal,$_SESSION['CompanyRecord']['decimalplaces']) , 'right'); } else { //its a debit balance b/fwd Modified: trunk/SalesCategoryPeriodInquiry.php =================================================================== --- trunk/SalesCategoryPeriodInquiry.php 2011-09-25 03:05:27 UTC (rev 4705) +++ trunk/SalesCategoryPeriodInquiry.php 2011-09-25 09:15:03 UTC (rev 4706) @@ -15,7 +15,7 @@ $_POST['DateRange']='ThisMonth'; } -echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">'; +echo '<form name="form1" action="' . $_SERVER['PHP_SELF'] . '" method="post">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<table cellpadding=2 class="selection">'; @@ -28,7 +28,7 @@ if ($_POST['DateRange']=='Custom'){ echo 'checked'; } -echo ' /></td> +echo ' onChange="ReloadForm(form1.ShowSales)" /></td> </tr> <tr> <td>' . _('This Week') . ':</td> @@ -36,7 +36,7 @@ if ($_POST['DateRange']=='ThisWeek'){ echo 'checked'; } -echo ' /></td> +echo ' onChange="ReloadForm(form1.ShowSales)" /></td> </tr> <tr> <td>' . _('This Month') . ':</td> @@ -44,7 +44,7 @@ if ($_POST['DateRange']=='ThisMonth'){ echo 'checked'; } -echo ' /></td> +echo ' onChange="ReloadForm(form1.ShowSales)" /></td> </tr> <tr> <td>' . _('This Quarter') . ':</td> @@ -52,9 +52,14 @@ if ($_POST['DateRange']=='ThisQuarter'){ echo 'checked'; } -echo ' /></td> +echo ' onChange="ReloadForm(form1.ShowSales)" /></td> </tr>'; if ($_POST['DateRange']=='Custom'){ + if (!isset($_POST['FromDate'])){ + unset($_POST['ShowSales']); + $_POST['FromDate'] = Date($_SESSION['DefaultDateFormat'],mktime(1,1,1,Date('m')-12,Date('d')+1,Date('Y'))); + $_POST['ToDate'] = Date($_SESSION['DefaultDateFormat']); + } echo '<tr> <td>' . _('Date From') . ':</td> <td><input type="text" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" name="FromDate" maxlength="10" size="11" value="' . $_POST['FromDate'] . '" /></td> @@ -67,14 +72,10 @@ echo '</table>'; -echo '<br /><div class="centre"><input tabindex=4 type=submit name="ShowSales" value="' . _('Show Sales') . '" />'; +echo '<br /><div class="centre"><input tabindex=4 type="submit" name="ShowSales" value="' . _('Show Sales') . '" />'; echo '</form></div>'; echo '<br />'; -if ($_POST['DateRange']=='Custom' AND !isset($_POST['FromDate']) AND !isset($_POST['ToDate'])){ - //Don't run the report until custom dates entered - unset($_POST['ShowSales']); -} if (isset($_POST['ShowSales'])){ $InputError=0; //assume no input errors now test for errors @@ -154,7 +155,6 @@ $ErrMsg = _('The sales data could not be retrieved because') . ' - ' . DB_error_msg($db); $SalesResult = DB_query($sql,$db,$ErrMsg); - $OrdersResult = DB_query($OrdersSQL,$db,$ErrMsg); echo '<table cellpadding=2 class="selection">'; Modified: trunk/SalesInquiry.php =================================================================== --- trunk/SalesInquiry.php 2011-09-25 03:05:27 UTC (rev 4705) +++ trunk/SalesInquiry.php 2011-09-25 09:15:03 UTC (rev 4706) @@ -26,39 +26,52 @@ } # Part Number operator - either LIKE or = -$PartNumberOp = $_POST['PartNumberOp']; +if (isset($_POST['PartNumberOp'])){ + $PartNumberOp = $_POST['PartNumberOp']; +} else { + $PartNumberOp = '='; +} if (isset($_POST['DebtorNo'])){ $DebtorNo = trim(mb_strtoupper($_POST['DebtorNo'])); } elseif (isset($_GET['DebtorNo'])){ $DebtorNo = trim(mb_strtoupper($_GET['DebtorNo'])); } - -$DebtorNoOp = $_POST['DebtorNoOp']; - +if (isset($_POST['DebtorNoOp'])){ + $DebtorNoOp = $_POST['DebtorNoOp']; +} else { + $DebtorNoOp = '='; +} if (isset($_POST['DebtorName'])){ $DebtorName = trim(mb_strtoupper($_POST['DebtorName'])); } elseif (isset($_GET['DebtorName'])){ $DebtorName = trim(mb_strtoupper($_GET['DebtorName'])); } +if (isset($_POST['DebtorNameOp'])){ + $DebtorNameOp = $_POST['DebtorNameOp']; +} else { + $DebtorNameOp = '='; +} -$DebtorNameOp = $_POST['DebtorNameOp']; - -// Save $_POST['SummaryType'] in $savesummarytype because change $_POST['SummaryType'] when +// Save $_POST['SummaryType'] in $SaveSummaryType because change $_POST['SummaryType'] when // create $sql -$savesummarytype = $_POST['SummaryType']; +if (isset($_POST['SummaryType'])){ + $SaveSummaryType = $_POST['SummaryType']; +} else { + $SaveSummaryType = 'name'; +} if (isset($_POST['submit'])) { - submit($db,$PartNumber,$PartNumberOp,$DebtorNo,$DebtorNoOp,$DebtorName,$DebtorNameOp,$savesummarytype); + submit($db,$PartNumber,$PartNumberOp,$DebtorNo,$DebtorNoOp,$DebtorName,$DebtorNameOp,$SaveSummaryType); } else { display($db); } //####_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT#### -function submit(&$db,$PartNumber,$PartNumberOp,$DebtorNo,$DebtorNoOp,$DebtorName,$DebtorNameOp,$savesummarytype) { +function submit(&$db,$PartNumber,$PartNumberOp,$DebtorNo,$DebtorNoOp,$DebtorName,$DebtorNameOp,$SaveSummaryType) { - //initialize no input errors + //initialise no input errors $InputError = 0; /* actions to take once the user has clicked the submit button @@ -115,8 +128,10 @@ } if (mb_strlen($DebtorNo) > 0) { $WhereDebtorNo = " AND salesorders.debtorno " . $DebtorNoOp . " '" . $DebtorNo . "' "; + } else { + $WhereDebtorNo = ' '; } - + $WhereDebtorName = ' '; if (mb_strlen($DebtorName) > 0 AND $DebtorNameOp == 'LIKE') { $DebtorName = $DebtorName . '%'; @@ -128,9 +143,10 @@ } if (mb_strlen($_POST['OrderNo']) > 0) { $WhereOrderNo = " AND salesorderdetails.orderno = " . " '" . $_POST['OrderNo'] . "' "; + } else { + $WhereOrderNo = " "; } - $WhereLineStatus = ' '; # Had to use IF statement instead of comparing 'linestatus' to $_POST['LineStatus'] #in WHERE clause because the WHERE clause did not recognize @@ -163,7 +179,7 @@ if ($_POST['InvoiceType'] != 'All') { $WhereType = " AND tempstockmoves.type = '" . $_POST['InvoiceType'] . "'"; } - if ($inputError !=1) { + if ($InputError !=1) { $FromDate = FormatDateForSQL($_POST['FromDate']); $ToDate = FormatDateForSQL($_POST['ToDate']); if ($_POST['ReportType'] == 'Detail') { @@ -191,18 +207,18 @@ LEFT JOIN debtorsmaster ON salesorders.debtorno = debtorsmaster.debtorno LEFT JOIN custbranch ON salesorders.branchcode = custbranch.branchcode LEFT JOIN stockmaster ON salesorderdetails.stkcode = stockmaster.stockid - WHERE salesorders.orddate >='$FromDate' - AND salesorders.orddate <='$ToDate' - AND salesorders.quotation = '" . $_POST['OrderType'] . "' - $WherePart - $WhereOrderNo - $WhereDebtorNo - $WhereDebtorName - $WhereLineStatus - $WhereArea - $WhereSalesman - $WhereCategory - ORDER BY " . $_POST['SortBy']; + WHERE salesorders.orddate >='" . $FromDate . "' + AND salesorders.orddate <='" . $ToDate . "' + AND salesorders.quotation = '" . $_POST['OrderType'] . "'" . + $WherePart . + $WhereOrderNo . + $WhereDebtorNo . + $WhereDebtorName . + $WhereLineStatus . + $WhereArea . + $WhereSalesman . + $WhereCategory . + "ORDER BY " . $_POST['SortBy']; } else { // Selects by tempstockmoves.trandate not order date $sql = "SELECT salesorderdetails.orderno, @@ -233,21 +249,21 @@ LEFT JOIN debtorsmaster ON salesorders.debtorno = debtorsmaster.debtorno LEFT JOIN custbranch ON salesorders.branchcode = custbranch.branchcode LEFT JOIN stockmaster ON salesorderdetails.stkcode = stockmaster.stockid - WHERE tempstockmoves.trandate >='$FromDate' - AND tempstockmoves.trandate <='$ToDate' + WHERE tempstockmoves.trandate >='" . $FromDate . "' + AND tempstockmoves.trandate <='" . $ToDate . "' AND tempstockmoves.stockid=salesorderdetails.stkcode AND tempstockmoves.hidemovt=0 - AND salesorders.quotation = '" . $_POST['OrderType'] . "' - $WherePart - $WhereType - $WhereOrderNo - $WhereDebtorNo - $WhereDebtorName - $WhereLineStatus - $WhereArea - $WhereSalesman - $WhereCategory - ORDER BY " . $_POST['SortBy']; + AND salesorders.quotation = '" . $_POST['OrderType'] . "' " . + $WherePart . + $WhereType . + $WhereOrderNo . + $WhereDebtorNo . + $WhereDebtorName . + $WhereLineStatus . + $WhereArea . + $WhereSalesman . + $WhereCategory . + "ORDER BY " . $_POST['SortBy']; } } else { // sql for Summary report @@ -260,7 +276,7 @@ $orderby = 'extprice DESC'; } if ($_POST['DateType'] == 'Order') { - if ($_POST['SummaryType'] == 'extprice' || $_POST['SummaryType'] == 'stkcode') { + if ($_POST['SummaryType'] == 'extprice' OR $_POST['SummaryType'] == 'stkcode') { $sql = "SELECT salesorderdetails.stkcode, SUM(salesorderdetails.quantity) as quantity, SUM(salesorderdetails.qtyinvoiced) as qtyinvoiced, @@ -276,18 +292,18 @@ LEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid LEFT JOIN salesman ON salesman.salesmancode = custbranch.salesman LEFT JOIN areas ON areas.areacode = custbranch.area - WHERE salesorders.orddate >='$FromDate' - AND salesorders.orddate <='$ToDate' - AND salesorders.quotation = '" . $_POST['OrderType'] . "' - $WherePart - $WhereOrderNo - $WhereDebtorNo - $WhereDebtorName - $WhereLineStatus - $WhereArea - $WhereSalesman - $WhereCategory - GROUP BY " . $_POST['SummaryType'] . + WHERE salesorders.orddate >='" . $FromDate . "' + AND salesorders.orddate <='" . $ToDate . "' + AND salesorders.quotation = '" . $_POST['OrderType'] . "' " . + $WherePart . + $WhereOrderNo . + $WhereDebtorNo . + $WhereDebtorName . + $WhereLineStatus . + $WhereArea . + $WhereSalesman . + $WhereCategory . + "GROUP BY " . $_POST['SummaryType'] . ",salesorderdetails.stkcode, stockmaster.description, stockmaster.decimalplaces @@ -308,22 +324,22 @@ LEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid LEFT JOIN salesman ON salesman.salesmancode = custbranch.salesman LEFT JOIN areas ON areas.areacode = custbranch.area - WHERE salesorders.orddate >='$FromDate' - AND salesorders.orddate <='$ToDate' - AND salesorders.quotation = '" . $_POST['OrderType'] . "' - $WherePart - $WhereOrderNo - $WhereDebtorNo - $WhereDebtorName - $WhereLineStatus - $WhereArea - $WhereSalesman - $WhereCategory - GROUP BY " . $_POST['SummaryType'] . + WHERE salesorders.orddate >='" . $FromDate . "' + AND salesorders.orddate <='" . $ToDate . "' + AND salesorders.quotation = '" . $_POST['OrderType'] . "' " . + $WherePart . + $WhereOrderNo . + $WhereDebtorNo . + $WhereDebtorName . + $WhereLineStatus . + $WhereArea . + $WhereSalesman . + $WhereCategory . + "GROUP BY " . $_POST['SummaryType'] . ",salesorders.debtorno, debtorsmaster.name ORDER BY " . $orderby; - } elseif ($_POST['SummaryType'] == 'debtorno' || $_POST['SummaryType'] == 'name') { + } elseif ($_POST['SummaryType'] == 'debtorno' OR $_POST['SummaryType'] == 'name') { if ($_POST['SummaryType'] == 'name') { $orderby = 'name'; } @@ -341,21 +357,20 @@ LEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid LEFT JOIN salesman ON salesman.salesmancode = custbranch.salesman LEFT JOIN areas ON areas.areacode = custbranch.area - WHERE salesorders.orddate >='$FromDate' - AND salesorders.orddate <='$ToDate' - AND salesorders.quotation = '" . $_POST['OrderType'] . "' - $WherePart - $WhereOrderNo - $WhereDebtorNo - $WhereDebtorName - $WhereLineStatus - $WhereArea - $WhereSalesman - $WhereCategory - - GROUP BY debtorsmaster.debtorno" . ' ' . - ",debtorsmaster.name - ORDER BY " . $orderby; + WHERE salesorders.orddate >='" . $FromDate . "' + AND salesorders.orddate <='" . $ToDate . "' + AND salesorders.quotation = '" . $_POST['OrderType'] . "' " . + $WherePart . + $WhereOrderNo . + $WhereDebtorNo . + $WhereDebtorName . + $WhereLineStatus . + $WhereArea . + $WhereSalesman . + $WhereCategory . + "GROUP BY debtorsmaster.debtorno + ,debtorsmaster.name + ORDER BY " . $orderby; } elseif ($_POST['SummaryType'] == 'month') { $sql = "SELECT EXTRACT(YEAR_MONTH from salesorders.orddate) as month, CONCAT(MONTHNAME(salesorders.orddate),' ',YEAR(salesorders.orddate)) as monthname, @@ -371,20 +386,20 @@ LEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid LEFT JOIN salesman ON salesman.salesmancode = custbranch.salesman LEFT JOIN areas ON areas.areacode = custbranch.area - WHERE salesorders.orddate >='$FromDate' - AND salesorders.orddate <='$ToDate' - AND salesorders.quotation = '" . $_POST['OrderType'] . "' - $WherePart - $WhereOrderNo - $WhereDebtorNo - $WhereDebtorName - $WhereLineStatus - $WhereArea - $WhereSalesman - $WhereCategory - GROUP BY " . $_POST['SummaryType'] . + WHERE salesorders.orddate >='" . $FromDate . "' + AND salesorders.orddate <='" . $ToDate . "' + AND salesorders.quotation = '" . $_POST['OrderType'] . "'" . + $WherePart . + $WhereOrderNo . + $WhereDebtorNo . + $WhereDebtorName . + $WhereLineStatus . + $WhereArea . + $WhereSalesman . + $WhereCategory . + "GROUP BY " . $_POST['SummaryType'] . ",monthname - ORDER BY " . $orderby; + ORDER BY " . $orderby; } elseif ($_POST['SummaryType'] == 'categoryid') { $sql = "SELECT stockmaster.categoryid, stockcategory.categorydescription, @@ -400,20 +415,20 @@ LEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid LEFT JOIN salesman ON salesman.salesmancode = custbranch.salesman LEFT JOIN areas ON areas.areacode = custbranch.area - WHERE salesorders.orddate >='$FromDate' - AND salesorders.orddate <='$ToDate' - AND salesorders.quotation = '" . $_POST['OrderType'] . "' - $WherePart - $WhereOrderNo - $WhereDebtorNo - $WhereDebtorName - $WhereLineStatus - $WhereArea - $WhereSalesman - $WhereCategory - GROUP BY " . $_POST['SummaryType'] . + WHERE salesorders.orddate >='" . $FromDate . "' + AND salesorders.orddate <='" . $ToDate . "' + AND salesorders.quotation = '" . $_POST['OrderType'] . "'" . + $WherePart . + $WhereOrderNo . + $WhereDebtorNo . + $WhereDebtorName . + $WhereLineStatus . + $WhereArea . + $WhereSalesman . + $WhereCategory . + "GROUP BY " . $_POST['SummaryType'] . ",categorydescription - ORDER BY " . $orderby; + ORDER BY " . $orderby; } elseif ($_POST['SummaryType'] == 'salesman') { $sql = "SELECT custbranch.salesman, salesman.salesmanname, @@ -429,20 +444,20 @@ LEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid LEFT JOIN salesman ON salesman.salesmancode = custbranch.salesman LEFT JOIN areas ON areas.areacode = custbranch.area - WHERE salesorders.orddate >='$FromDate' - AND salesorders.orddate <='$ToDate' - AND salesorders.quotation = '" . $_POST['OrderType'] . "' - $WherePart - $WhereOrderNo - $WhereDebtorNo - $WhereDebtorName - $WhereLineStatus - $WhereArea - $WhereSalesman - $WhereCategory - GROUP BY " . $_POST['SummaryType'] . + WHERE salesorders.orddate >='" . $FromDate . "' + AND salesorders.orddate <='" . $ToDate . "' + AND salesorders.quotation = '" . $_POST['OrderType'] . "'" . + $WherePart . + $WhereOrderNo . + $WhereDebtorNo . + $WhereDebtorName . + $WhereLineStatus . + $WhereArea . + $WhereSalesman . + $WhereCategory . + "GROUP BY " . $_POST['SummaryType'] . ",salesmanname - ORDER BY " . $orderby; + ORDER BY " . $orderby; } elseif ($_POST['SummaryType'] == 'area') { $sql = "SELECT custbranch.area, areas.areadescription, @@ -458,24 +473,24 @@ LEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid LEFT JOIN salesman ON salesman.salesmancode = custbranch.salesman LEFT JOIN areas ON areas.areacode = custbranch.area - WHERE salesorders.orddate >='$FromDate' - AND salesorders.orddate <='$ToDate' - AND salesorders.quotation = '" . $_POST['OrderType'] . "' - $WherePart - $WhereOrderNo - $WhereDebtorNo - $WhereDebtorName - $WhereLineStatus - $WhereArea - $WhereSalesman - $WhereCategory - GROUP BY " . $_POST['SummaryType'] . - ",areas.areadescription - ORDER BY " . $orderby; + WHERE salesorders.orddate >='" . $FromDate . "' + AND salesorders.orddate <='" . $ToDate . "' + AND salesorders.quotation = '" . $_POST['OrderType'] . "' " . + $WherePart . + $WhereOrderNo . + $WhereDebtorNo . + $WhereDebtorName . + $WhereLineStatus . + $WhereArea . + $WhereSalesman . + $WhereCategory . + "GROUP BY " . $_POST['SummaryType'] . + ",areas.areadescription + ORDER BY " . $orderby; } } else { // Selects by tempstockmoves.trandate not order date - if ($_POST['SummaryType'] == 'extprice' || $_POST['SummaryType'] == 'stkcode') { + if ($_POST['SummaryType'] == 'extprice' OR $_POST['SummaryType'] == 'stkcode') { $sql = "SELECT salesorderdetails.stkcode, SUM(salesorderdetails.quantity) as quantity, SUM(salesorderdetails.qtyinvoiced) as qtyinvoiced, @@ -492,23 +507,23 @@ LEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid LEFT JOIN salesman ON salesman.salesmancode = custbranch.salesman LEFT JOIN areas ON areas.areacode = custbranch.area - WHERE tempstockmoves.trandate >='$FromDate' - AND tempstockmoves.trandate <='$ToDate' + WHERE tempstockmoves.trandate >='" . $FromDate . "' + AND tempstockmoves.trandate <='" . $ToDate . "' AND tempstockmoves.stockid=salesorderdetails.stkcode AND tempstockmoves.hidemovt=0 - AND salesorders.quotation = '" . $_POST['OrderType'] . "' - $WherePart - $WhereType - $WhereOrderNo - $WhereDebtorNo - $WhereDebtorName - $WhereLineStatus - $WhereArea - $WhereSalesman - $WhereCategory - GROUP BY " . $_POST['SummaryType'] . + AND salesorders.quotation = '" . $_POST['OrderType'] . "'" . + $WherePart . + $WhereType . + $WhereOrderNo . + $WhereDebtorNo . + $WhereDebtorName . + $WhereLineStatus . + $WhereArea . + $WhereSalesman . + $WhereCategory . + "GROUP BY " . $_POST['SummaryType'] . ",stockmaster.description - ORDER BY " . $orderby; + ORDER BY " . $orderby; } elseif ($_POST['SummaryType'] == 'orderno') { $sql = "SELECT salesorderdetails.orderno, salesorders.debtorno, @@ -527,25 +542,25 @@ LEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid LEFT JOIN salesman ON salesman.salesmancode = custbranch.salesman LEFT JOIN areas ON areas.areacode = custbranch.area - WHERE tempstockmoves.trandate >='$FromDate' - AND tempstockmoves.trandate <='$ToDate' + WHERE tempstockmoves.trandate >='" . $FromDate . "' + AND tempstockmoves.trandate <='" . $ToDate . "' AND tempstockmoves.stockid=salesorderdetails.stkcode AND tempstockmoves.hidemovt=0 - AND salesorders.quotation = '" . $_POST['OrderType'] . "' - $WherePart - $WhereType - $WhereOrderNo - $WhereDebtorNo - $WhereDebtorName - $WhereLineStatus - $WhereArea - $WhereSalesman - $WhereCategory - GROUP BY " . $_POST['SummaryType'] . + AND salesorders.quotation = '" . $_POST['OrderType'] . "'" . + $WherePart . + $WhereType . + $WhereOrderNo . + $WhereDebtorNo . + $WhereDebtorName . + $WhereLineStatus . + $WhereArea . + $WhereSalesman . + $WhereCategory . + "GROUP BY " . $_POST['SummaryType'] . ",salesorders.debtorno, - debtorsmaster.name - ORDER BY " . $orderby; - } elseif ($_POST['SummaryType'] == 'debtorno' || $_POST['SummaryType'] == 'name') { + debtorsmaster.name + ORDER BY " . $orderby; + } elseif ($_POST['SummaryType'] == 'debtorno' OR $_POST['SummaryType'] == 'name') { if ($_POST['SummaryType'] == 'name') { $orderby = 'name'; } @@ -565,23 +580,23 @@ LEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid LEFT JOIN salesman ON salesman.salesmancode = custbranch.salesman LEFT JOIN areas ON areas.areacode = custbranch.area - WHERE tempstockmoves.trandate >='$FromDate' - AND tempstockmoves.trandate <='$ToDate' + WHERE tempstockmoves.trandate >='" . $FromDate . "' + AND tempstockmoves.trandate <='" . $ToDate . "' AND tempstockmoves.stockid=salesorderdetails.stkcode AND tempstockmoves.hidemovt=0 - AND salesorders.quotation = '" . $_POST['OrderType'] . "' - $WherePart - $WhereType - $WhereOrderNo - $WhereDebtorNo - $WhereDebtorName - $WhereLineStatus - $WhereArea - $WhereSalesman - $WhereCategory - GROUP BY debtorsmaster.debtorno" . ' ' . + AND salesorders.quotation = '" . $_POST['OrderType'] . "'" . + $WherePart . + $WhereType . + $WhereOrderNo . + $WhereDebtorNo . + $WhereDebtorName . + $WhereLineStatus . + $WhereArea . + $WhereSalesman . + $WhereCategory . + "GROUP BY debtorsmaster.debtorno" . ' ' . ",debtorsmaster.name - ORDER BY " . $orderby; + ORDER BY " . $orderby; } elseif ($_POST['SummaryType'] == 'month') { $sql = "SELECT EXTRACT(YEAR_MONTH from salesorders.orddate) as month, CONCAT(MONTHNAME(salesorders.orddate),' ',YEAR(salesorders.orddate)) as monthname, @@ -599,21 +614,21 @@ LEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid LEFT JOIN salesman ON salesman.salesmancode = custbranch.salesman LEFT JOIN areas ON areas.areacode = custbranch.area - WHERE tempstockmoves.trandate >='$FromDate' - AND tempstockmoves.trandate <='$ToDate' + WHERE tempstockmoves.trandate >='" . $FromDate . "' + AND tempstockmoves.trandate <='" . $ToDate . "' AND tempstockmoves.stockid=salesorderdetails.stkcode AND tempstockmoves.hidemovt=0 - AND salesorders.quotation = '" . $_POST['OrderType'] . "' - $WherePart - $WhereType - $WhereOrderNo - $WhereDebtorNo - $WhereDebtorName - $WhereLineStatus - $WhereArea - $WhereSalesman - $WhereCategory - GROUP BY " . $_POST['SummaryType'] . + AND salesorders.quotation = '" . $_POST['OrderType'] . "'" . + $WherePart . + $WhereType . + $WhereOrderNo . + $WhereDebtorNo . + $WhereDebtorName . + $WhereLineStatus . + $WhereArea . + $WhereSalesman . + $WhereCategory . + "GROUP BY " . $_POST['SummaryType'] . ",monthname ORDER BY " . $orderby; } elseif ($_POST['SummaryType'] == 'categoryid') { @@ -633,21 +648,21 @@ LEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid LEFT JOIN salesman ON salesman.salesmancode = custbranch.salesman LEFT JOIN areas ON areas.areacode = custbranch.area - WHERE tempstockmoves.trandate >='$FromDate' - AND tempstockmoves.trandate <='$ToDate' + WHERE tempstockmoves.trandate >='" . $FromDate . "' + AND tempstockmoves.trandate <='" . $ToDate . "' AND tempstockmoves.stockid=salesorderdetails.stkcode AND tempstockmoves.hidemovt=0 - AND salesorders.quotation = '" . $_POST['OrderType'] . "' - $WherePart - $WhereType - $WhereOrderNo - $WhereDebtorNo - $WhereDebtorName - $WhereLineStatus - $WhereArea - $WhereSalesman - $WhereCategory - GROUP BY " . $_POST['SummaryType'] . + AND salesorders.quotation = '" . $_POST['OrderType'] . "'" . + $WherePart . + $WhereType . + $WhereOrderNo . + $WhereDebtorNo . + $WhereDebtorName . + $WhereLineStatus . + $WhereArea . + $WhereSalesman . + $WhereCategory . + "GROUP BY " . $_POST['SummaryType'] . ",categorydescription ORDER BY " . $orderby; } elseif ($_POST['SummaryType'] == 'salesman') { @@ -667,21 +682,21 @@ LEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid LEFT JOIN salesman ON salesman.salesmancode = custbranch.salesman LEFT JOIN areas ON areas.areacode = custbranch.area - WHERE tempstockmoves.trandate >='$FromDate' - AND tempstockmoves.trandate <='$ToDate' + WHERE tempstockmoves.trandate >='" . $FromDate . "' + AND tempstockmoves.trandate <='" . $ToDate . "' AND tempstockmoves.stockid=salesorderdetails.stkcode AND tempstockmoves.hidemovt=0 - AND salesorders.quotation = '" . $_POST['OrderType'] . "' - $WherePart - $WhereType - $WhereOrderNo - $WhereDebtorNo - $WhereDebtorName - $WhereLineStatus - $WhereArea - $WhereSalesman - $WhereCategory - GROUP BY " . $_POST['SummaryType'] . + AND salesorders.quotation = '" . $_POST['OrderType'] . "'" . + $WherePart . + $WhereType . + $WhereOrderNo . + $WhereDebtorNo . + $WhereDebtorName . + $WhereLineStatus . + $WhereArea . + $WhereSalesman . + $WhereCategory . + "GROUP BY " . $_POST['SummaryType'] . ",salesmanname ORDER BY " . $orderby; } elseif ($_POST['SummaryType'] == 'area') { @@ -701,21 +716,21 @@ LEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid LEFT JOIN salesman ON salesman.salesmancode = custbranch.salesman LEFT JOIN areas ON areas.areacode = custbranch.area - WHERE tempstockmoves.trandate >='$FromDate' - AND tempstockmoves.trandate <='$ToDate' + WHERE tempstockmoves.trandate >='" . $FromDate . "' + AND tempstockmoves.trandate <='" . $ToDate . "' AND tempstockmoves.stockid=salesorderdetails.stkcode AND tempstockmoves.hidemovt=0 - AND salesorders.quotation = '" . $_POST['OrderType'] . "' - $WherePart - $WhereType - $WhereOrderNo - $WhereDebtorNo - $WhereDebtorName - $WhereLineStatus - $WhereArea - $WhereSalesman - $WhereCategory - GROUP BY " . $_POST['SummaryType'] . + AND salesorders.quotation = '" . $_POST['OrderType'] . "'" . + $WherePart . + $WhereType . + $WhereOrderNo . + $WhereDebtorNo . + $WhereDebtorName . + $WhereLineStatus . + $WhereArea . + $WhereSalesman . + $WhereCategory . + "GROUP BY " . $_POST['SummaryType'] . ",areas.areadescription ORDER BY " . $orderby; } @@ -731,7 +746,7 @@ $TotalExtPrice = 0; $TotalInvQty = 0; - // Create array for summary type to display in header. Access it with $savesummarytype + // Create array for summary type to display in header. Access it with $SaveSummaryType $Summary_Array['orderno'] = _('Order Number'); $Summary_Array['stkcode'] = _('Stock Code'); $Summary_Array['extprice'] = _('Extended Price'); @@ -751,7 +766,7 @@ // Display Header info if ($_POST['ReportType'] == 'Summary') { - $SortBy_Display = $Summary_Array[$savesummarytype]; + $SortBy_Display = $Summary_Array[$SaveSummaryType]; } else { $SortBy_Display = $Detail_Array[$_POST['SortBy']]; } @@ -836,8 +851,8 @@ $myrow['name'], $myrow['brname'], locale_number_format($myrow['quantity'],$myrow['decimalplaces']), - locale_number_format($myrow['extcost'],2), - locale_number_format($myrow['extprice'],2), + locale_money_format($myrow['extcost'],$_SESSION['CompanyRecord']['decimalplaces']), + locale_money_format($myrow['extprice'],$_SESSION['CompanyRecord']['decimalplaces']), locale_number_format($myrow['qtyinvoiced'],$myrow['decimalplaces']), $myrow['linestatus'], ConvertSQLDate($myrow['itemdue']), @@ -857,8 +872,8 @@ $myrow['name'], $myrow['brname'], locale_number_format($myrow['qty'],$myrow['decimalplaces']), - locale_number_format($myrow['extcost'],2), - locale_number_format($myrow['extprice'],2), + locale_money_format($myrow['extcost'],$_SESSION['CompanyRecord']['decimalplaces']), + locale_money_format($myrow['extprice'],$_SESSION['CompanyRecord']['decimalplaces']), $myrow['linestatus'], ConvertSQLDate($myrow['trandate']), $myrow['salesman'], @@ -882,8 +897,8 @@ ' ', ' ', locale_number_format($TotalQty,2), - locale_number_format($TotalExtCost,2), - locale_number_format($TotalExtPrice,2), + locale_money_format($TotalExtCost,$_SESSION['CompanyRecord']['decimalplaces']), + locale_money_format($TotalExtPrice,$_SESSION['CompanyRecord']['decimalplaces']), locale_number_format($TotalInvQty,2), ' ', ' ', @@ -899,8 +914,8 @@ ' ', ' ', locale_number_format($TotalQty,2), - locale_number_format($TotalExtCost,2), - locale_number_format($TotalExtPrice,2), + locale_money_format($TotalExtCost,$_SESSION['CompanyRecord']['decimalplaces']), + locale_money_format($TotalExtPrice,$_SESSION['CompanyRecord']['decimalplaces']), ' ', ' ', ' '); @@ -990,8 +1005,8 @@ $myrow[$SummaryType], $myrow[$Description], locale_number_format($DisplayQty,2), - locale_number_format($myrow['extcost'],2), - locale_number_format($myrow['extprice'],2), + locale_money_format($myrow['extcost'],$_SESSION['CompanyRecord']['decimalplaces']), + locale_money_format($myrow['extprice'],$_SESSION['CompanyRecord']['decimalplaces']), locale_number_format($myrow['qtyinvoiced'],2), $column7); @@ -1006,8 +1021,8 @@ _('Totals'), _('Lines - ') . $linectr, locale_number_format($TotalQty,2), - locale_number_format($TotalExtCost,2), - locale_number_format($TotalExtPrice,2), + locale_money_format($TotalExtCost,$_SESSION['CompanyRecord']['decimalplaces']), + locale_money_format($TotalExtPrice,$_SESSION['CompanyRecord']['decimalplaces']), locale_number_format($TotalInvQty,2), ' '); echo '</pre>'; @@ -1029,81 +1044,122 @@ echo '<table>'; - echo '<tr><td>' . _('Report Type') . ':</td>'; - echo '<td><select name="ReportType">'; - echo '<option selected value="Detail">' . _('Detail') . '</option>'; - echo '<option value="Summary">' . _('Summary') . '</option>'; - echo '</select></td><td> </td></tr>'; + echo '<tr> + <td>' . _('Report Type') . ':</td> + <td><select name="ReportType"> + <option selected value="Detail">' . _('Detail') . '</option> + <option value="Summary">' . _('Summary') . '</option> + </select></td> + <td> </td> + </tr>'; - echo '<tr><td>' . _('Order Type') . ':</td>'; - echo '<td><select name="OrderType">'; - echo '<option selected value="0">' . _('Sales Order') . '</option>'; - echo '<option value="1">' . _('Quotation') . '</option>'; - echo '</select></td><td> </td></tr>'; + echo '<tr> + <td>' . _('Order Type') . ':</td> + <td><select name="OrderType"> + <option selected value="0">' . _('Sales Order') . '</option> + <option value="1">' . _('Quotation') . '</option> + </select></td> + <td> </td> + </tr>'; - echo '<tr><td>' . _('Date Type') . ':</td>'; - echo '<td><select name="DateType">'; - echo '<option selected value="Order">' . _('Order Date') . '</option>'; - echo '<option value="Invoice">' . _('Invoice Date') . '</option>'; - echo '</select></td><td> </td></tr>'; + echo '<tr> + <td>' . _('Date Type') . ':</td> + <td><select name="DateType"> + <option selected value="Order">' . _('Order Date') . '</option> + <option value="Invoice">' . _('Invoice Date') . '</option> + </select></td> + <td> </td> + </tr>'; - echo '<tr><td>' . _('Invoice Type') . ':</td>'; - echo '<td><select name="InvoiceType">'; - echo '<option selected value="All">' . _('All') . '</option>'; - echo '<option value="10">' . _('Sales Invoice') . '</option>'; - echo '<option value="11">' . _('Credit Note') . '</option>'; - echo '</select></td><td> </td><td>' . _('Only Applies To Invoice Date Type') . '</td></tr>'; + echo '<tr> + <td>' . _('Invoice Type') . ':</td> + <td><select name="InvoiceType"> + <option selected value="All">' . _('All') . '</option> + <option value="10">' . _('Sales Invoice') . '</option> + <option value="11">' . _('Credit Note') . '</option> + </select></td> + <td> </td> + <td>' . _('Only Applies To Invoice Date Type') . '</td> + </tr>'; echo '<tr> - <td>' . _('Date Range') . ':</td> - <td><input type="text" class="date" alt="' .$_SESSION['DefaultDateFormat'] .'" name="FromDate" size=10 maxlength=10 value="' . $_POST['FromDate'] . '"></td> - <td>' . _('To') . ':</td> - <td><input type="text" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" name="ToDate" size=10 maxlength=10 value="' . $_POST['ToDate'] . '"></td> - </tr>'; + <td>' . _('Date Range') . ':</td> + <td><input type="text" class="date" alt="' .$_SESSION['DefaultDateFormat'] .'" name="FromDate" size=10 maxlength=10 value="' . $_POST['FromDate'] . '"></td> + <td>' . _('To') . ':</td> + <td><input type="text" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" name="ToDate" size=10 maxlength=10 value="' . $_POST['ToDate'] . '"></td> + </tr>'; + if (!isset($_POST['PartNumber'])){ + $_POST['PartNumber']=''; + } + echo '<tr> + <td>' . _('Stock Code') . ':</td> + <td><select name="PartNumberOp"> + <option selected value="Equals">' . _('Equals') . '</option> + <option value="LIKE">' . _('Begins With') . '</option> + </select></td> + <td> </td> + <td><input type="text" name="PartNumber" size=20 maxlength=20 value="'. $_POST['PartNumber'] . '"></td> + </tr>'; + if (!isset($_POST['DebtorNo'])){ + $_POST['DebtorNo']=''; + } + echo '<tr> + <td>' . _('Customer Number') . ':</td> + <td><select name="DebtorNoOp"> + <option selected value="Equals">' . _('Equals') . '</option> + <option value="LIKE">' . _('Begins With') . '</option> + </select></td> + <td> </td> + <td><input type="text" name="DebtorNo" size=10 maxlength=10 value="' . $_POST['DebtorNo'] . '"></td> + </tr>'; + if (!isset($_POST['DebtorName'])){ + $_POST['DebtorName']=''; + } + echo '<tr> + <td>' . _('Customer Name') . ':</td> + <td><select name="DebtorNameOp"> + <option selected value="LIKE">' . _('Begins With') . '</option> + <option value="Equals">' . _('Equals') . '</option> + </select></td> + <td> </td> + <td><input type="text" name="DebtorName" size=30 maxlength=30 value="' . $_POST['DebtorName'] .'"></td> + </tr>'; + if (!isset($_POST['OrderNo'])){ + $_POST['OrderNo']=''; + } + echo '<tr> + <td>' . _('Order Number') . ':</td> + <td>' . _('Equals') . '</td> + <td> </td> + <td><input type="text" name="OrderNo" size=10 maxlength=10 value="' . $_POST['OrderNo'] . '" /></td> + </tr>'; - echo '<tr><td>' . _('Stock Code') . ':</td>'; - echo '<td><select name="PartNumberOp">'; - echo '<option selected value="Equals">' . _('Equals') . '</option>'; - echo '<option value="LIKE">' . _('Begins With') . '</option>'; - echo '</select></td><td> </td>'; - echo '<td><input type="text" name="PartNumber" size=20 maxlength=20 value="'. $_POST['PartNumber'] . '"></td></tr>'; + echo '<tr> + <td>' . _('Line Item Status') . ':</td> + <td><select name="LineStatus"> + <option selected value="All">' . _('All') . '</option> + <option value="Completed">' . _('Completed') . '</option> + <option value="Open">' . _('Not Completed') . '</option> + </select></td> + <td> </td> + </tr>'; - echo '<tr><td>' . _('Customer Number') . ':</td>'; - echo '<td><select name="DebtorNoOp">'; - echo '<option selected value="Equals">' . _('Equals') . '</option>'; - echo '<option value="LIKE">' . _('Begins With') . '</option>'; - echo '</select></td><td> </td>'; - echo '<td><input type="text" name="DebtorNo" size=10 maxlength=10 value="' . $_POST['DebtorNo'] . '"></td></tr>'; + echo '<tr> + <td>' . _('Stock Categories') . ':</td> + <td><select name="Category">'; - echo '<tr><td>' . _('Customer Name') . ':</td>'; - echo '<td><select name="DebtorNameOp">'; - echo '<option selected value="LIKE">' . _('Begins With') . '</option>'; - echo '<option value="Equals">' . _('Equals') . '</option>'; - echo '</select></td><td> </td>'; - echo '<td><input type="text" name="DebtorName" size=30 maxlength=30 value="' . $_POST['DebtorName'] .'"></td></tr>'; - - echo '<tr><td>' . _('Order Number') . ':</td>'; - echo '<td>Equals</td><td> </td>'; - echo '<td><input type="text" name="OrderNo" size=10 maxlength=10 value="' . $_POST['OrderNo'] . '" /></td></tr>'; - - echo '<tr><td>' . _('Line Item Status') . ':</td>'; - echo '<td><select name="LineStatus">'; - echo '<option selected value="All">' . _('All') . '</option>'; - echo '<option value="Completed">' . _('Completed') . '</option>'; - echo '<option value="Open">' . _('Not Completed') . '</option>'; - echo '</select></td><td> </td></tr>'; - - echo '<tr><td>' . _('Stock Categories') . ':</td><td><select name="Category">'; - $CategoryResult= DB_query("SELECT categoryid, categorydescription FROM stockcategory",$db); echo '<option selected value="All">' . _('All Categories') . '</option>'; While ($myrow = DB_fetch_array($CategoryResult)){ echo '<option value="' . $myrow['categoryid'] . '">' . $myrow['categorydescription'] . '</option>'; } - echo '</select></td></tr>'; + echo '</select></td> + </tr>'; - echo '<tr><td>' . _('For Sales Man') . ':</td><td><select name="Salesman">'; + echo '<tr> + <td>' . _('For Sales Person') . ':</td> + <td><select name="Salesman">'; $sql="SELECT salesmancode, salesmanname FROM salesman"; $SalesmanResult= DB_query($sql,$db); echo '<option selected value="All">' . _('All Salesmen') . '</option>'; @@ -1113,7 +1169,8 @@ echo '</select></td></tr>'; // Use name='Areas[]' multiple - if want to create an array for Areas and allow multiple selections - echo '<tr><td>' . _('For Sales Areas') . ':</td><td><select name="Area">'; + echo '<tr><td>' . _('For Sales Areas') . ':</td> + <td><select name="Area">'; $AreasResult= DB_query("SELECT areacode, areadescription FROM areas",$db); echo '<option selected value="All">' . _('All Areas') . '</option>'; While ($myrow = DB_fetch_array($AreasResult)){ @@ -1122,42 +1179,49 @@ echo '</select></td></tr>'; echo '<tr><td> </td></tr>'; - echo '<tr><td>' . _('Sort By') . ':</td>'; - echo '<td><select name="SortBy">'; - echo '<option selected value="salesorderdetails.orderno">' . _('Order Number') . '</option>'; - echo '<option value="salesorderdetails.stkcode">' . _('Stock Code') . '</option>'; - echo '<option value="debtorsmaster.debtorno,salesorderdetails.orderno">' . _('Customer Number') . '</option>'; - echo '<option value="debtorsmaster.name,debtorsmaster.debtorno,salesorderdetails.orderno">' . _('Customer Name') . '</option>'; - echo '<option value="tempstockmoves.transno,salesorderdetails.stkcode">' . _('Transaction Number') . '</option>'; - echo '</select></td><td> </td><td>Transaction Number sort only valid for Invoice Date Type</td></tr>'; + echo '<tr> + <td>' . _('Sort By') . ':</td> + <td><select name="SortBy"> + <option selected value="salesorderdetails.orderno">' . _('Order Number') . '</option> + <option value="salesorderdetails.stkcode">' . _('Stock Code') . '</option> + <option value="debtorsmaster.debtorno,salesorderdetails.orderno">' . _('Customer Number') . '</option> + <option value="debtorsmaster.name,debtorsmaster.debtorno,salesorderdetails.orderno">' . _('Customer Name') . '</option> + <option value="tempstockmoves.transno,salesorderdetails.stkcode">' . _('Transaction Number') . '</option> + </select></td> + <td> </td> + <td>' . _('Transaction Number sort only valid for Invoice Date Type') . '</td> + </tr>'; echo '<tr><td> </td></tr> - <tr><td> </td></tr> - <tr><td> </td></tr>'; - + <tr><td> </td></tr> + <tr><td> </td></tr>'; + echo '<tr><td> </td></tr>'; - echo '<tr><td>' . _('Summary Type') . ':</td>'; - echo '<td><select name="SummaryType">'; - echo '<option selected value="orderno">' . _('Order Number') . '</option>'; - echo '<option value="transno">' . _('Transaction Number') . '</option>'; - echo '<option value="stkcode">' . _('Stock Code') . '</option>'; - echo '<option value="extprice">' . _('Extended Price') . '</option>'; - echo '<option value="debtorno">' . _('Customer Number') . '</option>'; - echo '<option value="name">' . _('Customer Name') . '</option>'; - echo '<option value="month">' . _('Month') . '</option>'; - echo '<option value="categoryid">' . _('Stock Category') . '</option>'; - echo '<option value="salesman">' . _('Salesman') . '</option>'; - echo '<option value="area">' . _('Sales Area') . '</option>'; - echo '</select></td><td> </td><td>Transaction Number summary only valid for Invoice Date Type</td></tr>'; + echo '<tr><td>' . _('Summary Type') . ':</td> + <td><select name="SummaryType"> + <option selected value="orderno">' . _('Order Number') . '</option> + <option value="transno">' . _('Transaction Number') . '</option> + <option value="stkcode">' . _('Stock Code') . '</option> + <option value="extprice">' . _('Extended Price') . '</option> + <option value="debtorno">' . _('Customer Number') . '</option> + <option value="name">' . _('Customer Name') . '</option> + <option value="month">' . _('Month') . '</option> + <option value="categoryid">' . _('Stock Category') . '</option> + <option value="salesman">' . _('Salesman') . '</option> + <option value="area">' . _('Sales Area') . '</option> + </select></td> + <td> </td> + <td>' . _('Transaction Number summary only valid for Invoice Date Type') . '</td> + </tr>'; - echo ' - <tr><td> </td></tr> - <tr><td> </td></tr> - <tr><td> </td></tr> - <tr><td> </td> - <td><input type="submit" name="submit" value="' . _('Run Inquiry') . '"></td> - </tr> - </table> + echo '<tr><td> </td></tr> + <tr><td> </td></tr> + <tr><td> </td></tr> + <tr> + <td> </td> + <td><input type="submit" name="submit" value="' . _('Run Inquiry') . '" /></td> + </tr> + </table> <br />'; echo '</form>'; Modified: trunk/SalesPeople.php =================================================================== --- trunk/SalesPeople.php 2011-09-25 03:05:27 UTC (rev 4705) +++ trunk/SalesPeople.php 2011-09-25 09:15:03 UTC (rev 4706) @@ -5,10 +5,10 @@ $title = _('Sales People Maintenance'); include('includes/header.inc'); -if (isset($_GET['SelectedSaleperson'])){ - $SelectedSaleperson =mb_strtoupper($_GET['SelectedSaleperson']); -} elseif(isset($_POST['SelectedSaleperson'])){ - $SelectedSaleperson =mb_strtoupper($_POST['SelectedSaleperson']); +if (isset($_GET['SelectedSalesPerson'])){ + $SelectedSalesPerson =mb_strtoupper($_GET['SelectedSalesPerson']); +} elseif(isset($_POST['SelectedSalesPerson'])){ + $SelectedSalesPerson =mb_strtoupper($_POST['SelectedSalesPerson']); } if (isset($Errors)) { @@ -53,10 +53,14 @@ $InputError = 1; prnMsg(_('The salesperson telephone number must be twenty characters or less long'),'error'); - } elseif (!is_double((double)$_POST['CommissionRate1']) OR !is_double((double) $_POST['CommissionRate2'])) { + } elseif (!is_numeric(filter_number_format($_POST['CommissionRate1'])) + OR !is_numeric(filter_number_format($_POST['CommissionRate2']))) { $InputError = 1; prnMsg(_('The commission rates must be a floating point number'),'error'); - } elseif (!is_double((double)$_POST['Breakpoint'])) { + echo '<br/>Commission Rate 1 = ' . filter_number_format($_POST['CommissionRate1']); + echo '<br/>Commission Rate 2 = ' . filter_number_format($_POST['CommissionRate2']); + echo '<br/>The locale decimal point is ' . $LocaleInfo['decimal_point']; + } elseif (!is_numeric(filter_number_format($_POST['Breakpoint']))) { $InputError = 1; prnMsg(_('The breakpoint should be a floating point number'),'error'); } @@ -80,18 +84,18 @@ $_POST['Current']=0; } - if (isset($SelectedSaleperson) AND $InputError !=1) { + if (isset($SelectedSalesPerson) AND $InputError !=1) { - /*SelectedSaleperson could also exist if submit had not been clicked this code would not run in this case cos submit is false of course see the delete code below*/ + /*SelectedSalesPerson could also exist if submit had not been clicked this code would not run in this case cos submit is false of course see the delete code below*/ $sql = "UPDATE salesman SET salesmanname='" . $_POST['SalesmanName'] . "', - commissionrate1='" . $_POST['CommissionRate1'] . "', + commissionrate1='" . filter_number_format($_POST['CommissionRate1']) . "', smantel='" . $_POST['SManTel'] . "', smanfax='" . $_POST['SManFax'] . "', - breakpoint='" . $_POST['Breakpoint'] . "', - commissionrate2='" . $_POST['CommissionRate2'] . "', + breakpoint='" . filter_number_format($_POST['Breakpoint']) . "', + commissionrate2='" . filter_number_format($_POST['CommissionRate2']) . "', current='" . $_POST['Current'] . "' - WHERE salesmancode = '".$SelectedSaleperson."'"; + WHERE salesmancode = '".$SelectedSalesPerson."'"; $msg = _('Salesperson record for') . ' ' . $_POST['SalesmanName'] . ' ' . _('has been updated'); } elseif ($InputError !=1) { @@ -107,12 +111,12 @@ smanfax, current) VALUES ('" . $_POST['SalesmanCode'] . "', - '" . $_POST['SalesmanName'] . "', - '" . $_POST['CommissionRate1'] . "', - '" . $_POST['CommissionRate2'] . "', - '" . $_POST['Breakpoint'] . "', - '" . $_POST['SManTel'] . "', - '" . $_POST['SManFax'] . "', + '" . DB_escape_string($_POST['SalesmanName']) . "', + '" . filter_number_format($_POST['CommissionRate1']) . "', + '" . filter_number_format($_POST['CommissionRate2']) . "', + '" . filter_number_format($_POST['Breakpoint']) . "', + '" . DB_escape_string($_POST['SManTel']) . "', + '" . DB_escape_string($_POST['SManFax']) . "', '" . $_POST['Current'] . "' )"; @@ -126,7 +130,7 @@ prnMsg($msg , 'success'); - unset($SelectedSalesperson); + unset($SelectedSalesPerson); unset($_POST['SalesmanCode']); unset($_POST['SalesmanName']); unset($_POST['CommissionRate1']); @@ -142,61 +146,63 @@ // PREVENT DELETES IF DEPENDENT RECORDS IN 'DebtorsMaster' - $sql= "SELECT COUNT(*) FROM custbranch WHERE custbranch.salesman='".$SelectedSaleperson."'"; + $sql= "SELECT COUNT(*) FROM custbranch WHERE custbranch.salesman='".$SelectedSalesPerson."'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { prnMsg(_('Cannot delete this salesperson because branches are set up referring to them') . ' - ' . _('first alter the branches concerned') . '<br />' . _('There are') . ' ' . $myrow[0] . ' ' . _('branches that refer to this salesperson'),'error'); } else { - $sql= "SELECT COUNT(*) FROM salesanalysis WHERE salesanalysis.salesperson='".$SelectedSaleperson."'"; + $sql= "SELECT COUNT(*) FROM salesanalysis WHERE salesanalysis.salesperson='".$SelectedSalesPerson."'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { prnMsg(_('Cannot delete this salesperson because sales analysis records refer to them') , '<br />' . _('There are') . ' ' . $myrow[0] . ' ' . _('sales analysis records that refer to this salesperson'),'error'); } else { - $sql="DELETE FROM salesman WHERE salesmancode='".$SelectedSaleperson."'"; + $sql="DELETE FROM salesman WHERE salesmancode='". $SelectedSalesPerson."'"; $ErrMsg = _('The salesperson could not be deleted because'); $result = DB_query($sql,$db,$ErrMsg); - prnMsg(_('Salesperson') . ' ' . $SelectedSalesperson . ' ' . _('has been deleted from the database'),'success'); - unset ($SelectedSalesperson); + prnMsg(_('Salesperson') . ' ' . $SelectedSalesPerson . ' ' . _('has been deleted from the database'),'success'); + unset ($SelectedSalesPerson); unset($delete); } } //end if Sales-person used in GL accounts } -if (!isset($SelectedSaleperson)) { +if (!isset($SelectedSalesPerson)) { -/* It could still be the second time the page has been run and a record has been selected for modification - SelectedSaleperson will exist because it was sent with the new call. If its the first time the page has been displayed with no parameters +/* It could still be the second time the page has been run and a record has been selected for modification - SelectedSalesPerson will exist because it was sent with the new call. If its the first time the page has been displayed with no parameters then none of the above are true and the list of Sales-persons will be displayed with links to delete or edit each. These will call the same page again and allow update/input or deletion of the records*/ $sql = "SELECT salesmancode, - salesmanname, - smantel, - smanfax, - commissionrate1, - breakpoint, - commissionrate2, - current - FROM salesman"; + salesmanname, + smantel, + smanfax, + commissionrate1, + breakpoint, + commissionrate2, + current + FROM salesman"; $result = DB_query($sql,$db); - echo '<table class=selection>'; - echo '<tr><th>' . _('Code') . '</th> - <th>' . _('Name') . '</th> - <th>' . _('Telephone') . '</th> - <th>' . _('Facsimile') . '</th> - <th>' . _('Comm Rate 1') . '</th> - <th>' . _('Break') . '</th> - <th>' . _('Comm Rate 2') . '</th> - <th>' . _('Current') . '</th></tr>'; + echo '<table class="selection">'; + echo '<tr> + <th>' . _('Code') . '</th> + <th>' . _('Name') . '</th> + <th>' . _('Telephone') . '</th> + <th>' . _('Facsimile') . '</th> + <th>' . _('Comm Rate 1') . '</th> + <th>' . _('Break') . '</th> + <th>' . _('Comm Rate 2') . '</th> + <th>' . _('Current') . '</th> + </tr>'; $k=0; - while ($myrow=DB_fetch_row($result)) { + while ($myrow=DB_fetch_array($result)) { if ($k==1){ echo '<tr class="EvenTableRows">'; @@ -205,38 +211,41 @@ echo '<tr class="OddTableRows">'; $k++; } - if ($myrow[7] == 1) $ActiveText = _("Yes"); else $ActiveText = _("No"); + if ($myrow[7] == 1) { + $ActiveText = _('Yes'); + } else { + $ActiveText = _('No'); + } - printf(' - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td class=number>%s</td> - <td class=number>%s</td> - <td class=number>%s</td> - <td>%s</td> - <td><a href="%sSelectedSaleperson=%s">'. _('Edit') . '</a></td> - <td><a href="%sSelectedSaleperson=%s&delete=1">' . _('Delete') . '</a></td> - </tr>', - $myrow[0], - $myrow[1], - $myrow[2], - $myrow[3], - $myrow[4], - $myrow[5], - $myrow[6], - $ActiveText, - $_SERVER['PHP_SELF'] . '?' . SID . '&', - $myrow[0], - $_SERVER['PHP_SELF'] . '?' . SID . '&', - $myrow[0]); - + printf('<td>%s</td> + <td>%s</td> + <td>%s</td> + <td>%s</td> + <td class="number">%s</td> + <td class="number">%s</td> + <td class="number">%s</td> + <td>%s</td> + <td><a href="%sSelectedSalesPerson=%s">'. _('Edit') . '</a></td> + <td><a href="%sSelectedSalesPerson=%s&delete=1" onclick="return confirm(\'' . _('Are you sure you wish to delete this sales person?') . '\');">' . _('Delete') . '</a></td> + </tr>', + $myrow['salesmancode'], + $myrow['salesmanname'], + $myrow['smantel'], + $myrow['smanfax'], + locale_number_format($myrow['commissionrate1'],2), + locale_money_format($myrow['breakpoint'],$_SESSION['CompanyRecord']['decimalplaces']), + locale_number_format($myrow['commissionrate2'],2), + $ActiveText, + $_SERVER['PHP_SELF'] . '?', + $myrow['salesmancode'], + $_SERVER['PHP_SELF'] . '?', + $myrow['salesmancode']); + } //END WHILE LIST LOOP echo '</table><br />'; } //end of ifs and buts! -if (isset($SelectedSaleperson)) { +if (isset($SelectedSalesPerson)) { echo '<div class="centre"><a href="' . $_SERVER['PHP_SELF'] . '">' . _('Show All Sales People') . '</a></div>'; } @@ -245,19 +254,19 @@ echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - if (isset($SelectedSaleperson)) { + if (isset($SelectedSalesPerson)) { //editing an existing Sales-person $sql = "SELECT salesmancode, - salesmanname, - smantel, - smanfax, - commissionrate1, - breakpoint, - commissionrate2, - current - FROM salesman - WHERE salesmancode='".$SelectedSaleperson."'"; + salesmanname, + smantel, + smanfax, + commissionrate1, + breakpoint, + commissionrate2, + current + FROM salesman + WHERE salesmancode='".$SelectedSalesPerson."'"; $result = DB_query($sql, $db); $myrow = DB_fetch_array($result); @@ -272,15 +281,20 @@ $_POST['Current'] = $myrow['current']; - echo '<input type=hidden name="SelectedSaleperson" VALUE="' . $SelectedSaleperson . '">'; - echo '<input type=hidden name="SalesmanCode" VALUE="' . $_POST['SalesmanCode'] . '">'; - echo '<table class=selection> <tr><td>' . _('Salesperson code') . ':</td><td>'; - echo $_POST['SalesmanCode'] . '</td></tr>'; + echo '<input type=hidden name="SelectedSalesPerson" value="' . $SelectedSalesPerson . '" />'; + echo '<input type=hidden name="SalesmanCode" value="' . $_POST['SalesmanCode'] . '" />'; + echo '<table class="selection"> + <tr> + <td>' . _('Salesperson code') . ':</td> + <td>' . $_POST['SalesmanCode'] . '</td></tr>'; - } else { //end of if $SelectedSaleperson only do the else when a new record is being entered + } else { //end of if $SelectedSalesPerson only do the else when a new record is being entered - echo '<table class=selection><tr><td>' . _('Salesperson code') . ':</td> - <td><input type="text" '. (in_array('SalesmanCode',$Errors) ? 'class="inputerror"' : '' ) .' name="SalesmanCode" size=3 maxlength=3></td></tr>'; + echo '<table class="selection"> + <tr> + <td>' . _('Salesperson code') . ':</td> + <td><input type="text" '. (in_array('SalesmanCode',$Errors) ? 'class="inputerror"' : '' ) .' name="SalesmanCode" size=3 maxlength=3></td> + </tr>'; } if (!isset($_POST['SalesmanName'])){ $_POST['SalesmanName']=''; @@ -304,14 +318,34 @@ $_POST['Current']=0; } - echo '<tr><td>' . _('Salesperson Name') . ':</td><td><input type="text" '. (in_array('SalesmanName',$Errors) ? 'class="inputerror"' : '' ) .' name="SalesmanName" size=30 maxlength=30 VALUE="' . $_POST['SalesmanName'] . '"></td></tr>'; - echo '<tr><td>' . _('Telephone No') . ':</td><td><input type="text" name="SManTel" size=20 maxlength=20 VALUE="' . $_POST['SManTel'] . '"></td></tr>'; - echo '<tr><td>' . _('Facsimile No') . ':</td><td><input type="text" name="SManFax" size=20 maxlength=20 VALUE="' . $_POST['SManFax'] . '"></td></tr>'; - echo '<tr><td>' . _('Commission Rate 1') . ':</td><td><input type="text" class=number name="CommissionRate1" size=5 maxlength=5 VALUE="' . $_POST['CommissionRate1'] . '"></td></tr>'; - echo '<tr><td>' . _('Breakpoint') . ':</td><td><input type="text" class=number name="Breakpoint" size=6 maxlength=6 VALUE="' . $_POST['Breakpoint'] . '"></td></tr>'; - echo '<tr><td>' . _('Commission Rate 2') . ':</td><td><input type="text" class=number name="CommissionRate2" size=5 maxlength=5 VALUE="' . $_POST['CommissionRate2']. '"></td></tr>'; + echo '<tr> + <td>' . _('Salesperson Name') . ':</td> + <td><input type="text" '. (in_array('SalesmanName',$Errors) ? 'class="inputerror"' : '' ) .' name="SalesmanName" size=30 maxlength=30 value="' . $_POST['SalesmanName'] . '"></td> + </tr>'; + echo '<tr> + <td>' . _('Telephone No') . ':</td> + <td><input type="text" name="SManTel" size=20 maxlength=20 value="' . $_POST['SManTel'] . '"></td> + </tr>'; + echo '<tr> + <td>' . _('Facsimile No') . ':</td> + <td><input type="text" name="SManFax" size=20 maxlength=20 value="' . $_POST['SManFax'] . '"></td> + </tr>'; + echo '<tr> + <td>' . _('Commission Rate 1') . ':</td> + <td><input type="text" class="number" name="CommissionRate1" size="5" maxlength="5" value="' . $_POST['CommissionRate1'] . '"></td> + </tr>'; + echo '<tr> + <td>' . _('Breakpoint') . ':</td> + <td><input type="text" class="number" name="Breakpoint" size="6" maxlength="6" value="' . $_POST['Breakpoint'] . '"></td> + </tr>'; + echo '<tr> + <td>' . _('Commission Rate 2') . ':</td> + <td><input type="text" class="number" name="CommissionRate2" size="5" maxlength="5" value="' . $_POST['CommissionRate2']. '"></td> + </tr>'; - echo '<tr><td>' . _('Current?') . ':</td><td><select name="Current">'; + echo '<tr> + <td>' . _('Current?') . ':</td> + <td><select name="Current">'; if ($_POST['Current']==1){ echo '<option selected value=1>' . _('Yes') . '</option>'; } else { @@ -322,7 +356,8 @@ } else { echo '<option value=0>' . _('No') . '</option>'; } - echo '</selec... [truncated message content] |