|
From: <tim...@us...> - 2012-01-20 13:49:05
|
Revision: 4821
http://web-erp.svn.sourceforge.net/web-erp/?rev=4821&view=rev
Author: tim_schofield
Date: 2012-01-20 13:48:53 +0000 (Fri, 20 Jan 2012)
Log Message:
-----------
Merge Tims branch into trunk: Add tendering facility
Modified Paths:
--------------
trunk/SupplierTenders.php
trunk/UpgradeDatabase.php
trunk/WWW_Users.php
trunk/doc/Change.log
trunk/includes/ConnectDB.inc
trunk/includes/DefineOfferClass.php
trunk/includes/UserLogin.php
trunk/index.php
trunk/sql/mysql/upgrade4.05-4.06.sql
Added Paths:
-----------
trunk/SupplierTenderCreate.php
trunk/includes/DefineTenderClass.php
Added: trunk/SupplierTenderCreate.php
===================================================================
--- trunk/SupplierTenderCreate.php (rev 0)
+++ trunk/SupplierTenderCreate.php 2012-01-20 13:48:53 UTC (rev 4821)
@@ -0,0 +1,809 @@
+<?php
+/* $Id$*/
+
+include('includes/DefineTenderClass.php');
+include('includes/SQL_CommonFunctions.inc');
+include('includes/session.inc');
+
+$Maximum_Number_Of_Parts_To_Show=50;
+
+if (isset($_GET['New']) and isset($_SESSION['tender'])) {
+ unset($_SESSION['tender']);
+}
+
+if (isset($_GET['New']) and $_SESSION['CanCreateTender']==0) {
+ $title = _('Authorisation Problem');
+ include('includes/header.inc');
+ echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . $title . '" alt="" /> '.$title . '</p>';
+ prnMsg( _('You do not have authority to create supplier tenders for this company.') . '<br />' .
+ _('Please see your system administrator'), 'warn');
+ include('includes/footer.inc');
+ exit;
+}
+
+if (isset($_GET['Edit']) and $_SESSION['CanCreateTender']==0) {
+ $title = _('Authorisation Problem');
+ include('includes/header.inc');
+ echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . $title . '" alt="" /> '.$title . '</p>';
+ prnMsg( _('You do not have authority to amend supplier tenders for this company.') . '<br />' .
+ _('Please see your system administrator'), 'warn');
+ include('includes/footer.inc');
+ exit;
+}
+
+$ShowTender = 0;
+
+if (isset($_GET['ID'])) {
+ $sql="SELECT tenderid,
+ location,
+ address1,
+ address2,
+ address3,
+ address4,
+ address5,
+ address6,
+ telephone
+ FROM tenders
+ WHERE tenderid='" . $_GET['ID'] . "'";
+ $result=DB_query($sql, $db);
+ $myrow=DB_fetch_array($result);
+ if (isset($_SESSION['tender'])) {
+ unset($_SESSION['tender']);
+ }
+ $_SESSION['tender'] = new Tender();
+ $_SESSION['tender']->TenderId = $myrow['tenderid'];
+ $_SESSION['tender']->Location = $myrow['location'];
+ $_SESSION['tender']->DelAdd1 = $myrow['address1'];
+ $_SESSION['tender']->DelAdd2 = $myrow['address2'];
+ $_SESSION['tender']->DelAdd3 = $myrow['address3'];
+ $_SESSION['tender']->DelAdd4 = $myrow['address4'];
+ $_SESSION['tender']->DelAdd5 = $myrow['address5'];
+ $_SESSION['tender']->DelAdd6 = $myrow['address6'];
+
+ $sql="SELECT tenderid,
+ tendersuppliers.supplierid,
+ suppliers.suppname,
+ tendersuppliers.email
+ FROM tendersuppliers
+ LEFT JOIN suppliers
+ ON tendersuppliers.supplierid=suppliers.supplierid
+ WHERE tenderid='" . $_GET['ID'] . "'";
+ $result=DB_query($sql, $db);
+ while ($myrow=DB_fetch_array($result)) {
+ $_SESSION['tender']->add_supplier_to_tender(
+ $myrow['supplierid'],
+ $myrow['suppname'],
+ $myrow['email']);
+ }
+
+ $sql="SELECT tenderid,
+ tenderitems.stockid,
+ tenderitems.quantity,
+ stockmaster.description,
+ tenderitems.units,
+ stockmaster.decimalplaces
+ FROM tenderitems
+ LEFT JOIN stockmaster
+ ON tenderitems.stockid=stockmaster.stockid
+ WHERE tenderid='" . $_GET['ID'] . "'";
+ $result=DB_query($sql, $db);
+ while ($myrow=DB_fetch_array($result)) {
+ $_SESSION['tender']->add_item_to_tender(
+ $_SESSION['tender']->LinesOnTender,
+ $myrow['stockid'],
+ $myrow['quantity'],
+ $myrow['description'],
+ $myrow['units'],
+ $myrow['decimalplaces'],
+ DateAdd(date($_SESSION['DefaultDateFormat']),'m',3));
+ }
+ $ShowTender = 1;
+}
+
+if (isset($_GET['Edit'])) {
+ $title = _('Edit an Existing Supplier Tender Request');
+ include('includes/header.inc');
+ echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . _('Purchase Order Tendering') . '" alt="" /> '.$title . '</p>';
+ $sql="SELECT tenderid,
+ location,
+ address1,
+ address2,
+ address3,
+ address4,
+ address5,
+ address6,
+ telephone
+ FROM tenders
+ WHERE closed=0";
+ $result=DB_query($sql, $db);
+ echo '<table class="selection">';
+ echo '<tr><th>' . _('Tender ID') . '</th>';
+ echo '<th>' . _('Location') . '</th>';
+ echo '<th>' . _('Address 1') . '</th>';
+ echo '<th>' . _('Address 2') . '</th>';
+ echo '<th>' . _('Address 3') . '</th>';
+ echo '<th>' . _('Address 4') . '</th>';
+ echo '<th>' . _('Address 5') . '</th>';
+ echo '<th>' . _('Address 6') . '</th>';
+ echo '<th>' . _('Telephone') . '</th></tr>';
+ while ($myrow=DB_fetch_array($result)) {
+ echo '<tr><td>' . $myrow['tenderid'] . '</td>';
+ echo '<td>' . $myrow['location'] . '</td>';
+ echo '<td>' . $myrow['address1'] . '</td>';
+ echo '<td>' . $myrow['address2'] . '</td>';
+ echo '<td>' . $myrow['address3'] . '</td>';
+ echo '<td>' . $myrow['address4'] . '</td>';
+ echo '<td>' . $myrow['address5'] . '</td>';
+ echo '<td>' . $myrow['address6'] . '</td>';
+ echo '<td>' . $myrow['telephone'] . '</td>';
+ echo '<td><a href="'.$_SERVER['PHP_SELF'] . '?ID='.$myrow['tenderid'].'">'. _('Edit') .'</a></td>';
+ }
+ echo '</table>';
+ include('includes/footer.inc');
+ exit;
+} else if (isset($_GET['ID']) or (isset($_SESSION['tender']->TenderId))) {
+ $title = _('Edit an Existing Supplier Tender Request');
+ include('includes/header.inc');
+ echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . _('Purchase Order Tendering') . '" alt="" /> '.$title . '</p>';
+} else {
+ $title = _('Create a New Supplier Tender Request');
+ include('includes/header.inc');
+ echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . _('Purchase Order Tendering') . '" alt="" /> '.$title . '</p>';
+}
+
+if (isset($_POST['Save'])) {
+ $_SESSION['tender']->RequiredByDate=$_POST['RequiredByDate'];
+ $_SESSION['tender']->save($db);
+ $_SESSION['tender']->EmailSuppliers();
+ prnMsg( _('The tender has been successfully saved'), 'success');
+ include('includes/footer.inc');
+ exit;
+}
+
+if (isset($_GET['DeleteSupplier'])) {
+ $_SESSION['tender']->remove_supplier_from_tender($_GET['DeleteSupplier']);
+ $ShowTender = 1;
+}
+
+if (isset($_GET['DeleteItem'])) {
+ $_SESSION['tender']->remove_item_from_tender($_GET['DeleteItem']);
+ $ShowTender = 1;
+}
+
+if (isset($_POST['SelectedSupplier'])) {
+ $sql = "SELECT suppname,
+ email
+ FROM suppliers
+ WHERE supplierid='" . $_POST['SelectedSupplier'] . "'";
+ $result = DB_query($sql, $db);
+ $myrow = DB_fetch_array($result);
+ if (mb_strlen($myrow['email'])>0) {
+ $_SESSION['tender']->add_supplier_to_tender(
+ $_POST['SelectedSupplier'],
+ $myrow['suppname'],
+ $myrow['email']);
+ } else {
+ prnMsg( _('The supplier must have an email set up or they cannot be part of a tender'), 'warn');
+ }
+ $ShowTender = 1;
+}
+
+if (isset($_POST['NewItem']) and !isset($_POST['Refresh'])) {
+ foreach ($_POST as $key => $value) {
+ if (mb_substr($key,0,7)=='StockID') {
+ $Index = mb_substr($key,7,mb_strlen($key)-7);
+ $StockID = $value;
+ $Quantity = filter_number_format($_POST['Qty'.$Index]);
+ $UOM = $_POST['UOM'.$Index];
+ $sql="SELECT description, decimalplaces FROM stockmaster WHERE stockid='".$StockID."'";
+ $result=DB_query($sql, $db);
+ $myrow=DB_fetch_array($result);
+ $_SESSION['tender']->add_item_to_tender(
+ $_SESSION['tender']->LinesOnTender,
+ $StockID,
+ $Quantity,
+ $myrow['description'],
+ $UOM,
+ $myrow['decimalplaces'],
+ DateAdd(date($_SESSION['DefaultDateFormat']),'m',3));
+ unset($UOM);
+ }
+ }
+ $ShowTender = 1;
+}
+
+if (!isset($_SESSION['tender']) or isset($_POST['LookupDeliveryAddress']) or $ShowTender==1) {
+ /* Show Tender header screen */
+ if (!isset($_SESSION['tender'])) {
+ $_SESSION['tender']=new Tender();
+ }
+ echo '<form name="form1" action="' . $_SERVER['PHP_SELF'] . '" method="post">';
+ echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
+ echo '<table class="selection">';
+ echo '<tr><th colspan="4"><font size="3" color="#616161">' . _('Tender header details') . '</font></th></tr>';
+ echo '<tr><td>' . _('Delivery Must Be Made Before') . '</td>';
+ echo '<td><input type="text" class="date" alt="' .$_SESSION['DefaultDateFormat'] . '" name="RequiredByDate" size="11" value="' . date($_SESSION['DefaultDateFormat']) . '" /></td></tr>';
+
+ if (!isset($_POST['StkLocation']) OR $_POST['StkLocation']==''){
+ /* If this is the first time
+ * the form loaded set up defaults */
+
+ $_POST['StkLocation'] = $_SESSION['UserStockLocation'];
+
+ $sql = "SELECT deladd1,
+ deladd2,
+ deladd3,
+ deladd4,
+ deladd5,
+ deladd6,
+ tel,
+ contact
+ FROM locations
+ WHERE loccode='" . $_POST['StkLocation'] . "'";
+
+ $LocnAddrResult = DB_query($sql,$db);
+ if (DB_num_rows($LocnAddrResult)==1){
+ $LocnRow = DB_fetch_array($LocnAddrResult);
+ $_POST['DelAdd1'] = $LocnRow['deladd1'];
+ $_POST['DelAdd2'] = $LocnRow['deladd2'];
+ $_POST['DelAdd3'] = $LocnRow['deladd3'];
+ $_POST['DelAdd4'] = $LocnRow['deladd4'];
+ $_POST['DelAdd5'] = $LocnRow['deladd5'];
+ $_POST['DelAdd6'] = $LocnRow['deladd6'];
+ $_POST['Tel'] = $LocnRow['tel'];
+ $_POST['Contact'] = $LocnRow['contact'];
+
+ $_SESSION['tender']->Location= $_POST['StkLocation'];
+ $_SESSION['tender']->DelAdd1 = $_POST['DelAdd1'];
+ $_SESSION['tender']->DelAdd2 = $_POST['DelAdd2'];
+ $_SESSION['tender']->DelAdd3 = $_POST['DelAdd3'];
+ $_SESSION['tender']->DelAdd4 = $_POST['DelAdd4'];
+ $_SESSION['tender']->DelAdd5 = $_POST['DelAdd5'];
+ $_SESSION['tender']->DelAdd6 = $_POST['DelAdd6'];
+ $_SESSION['tender']->Telephone = $_POST['Tel'];
+ $_SESSION['tender']->Contact = $_POST['Contact'];
+
+ } else {
+ /*The default location of the user is crook */
+ prnMsg(_('The default stock location set up for this user is not a currently defined stock location') .
+ '. ' . _('Your system administrator needs to amend your user record'),'error');
+ }
+
+
+ } elseif (isset($_POST['LookupDeliveryAddress'])){
+
+ $sql = "SELECT deladd1,
+ deladd2,
+ deladd3,
+ deladd4,
+ deladd5,
+ deladd6,
+ tel,
+ contact
+ FROM locations
+ WHERE loccode='" . $_POST['StkLocation'] . "'";
+
+ $LocnAddrResult = DB_query($sql,$db);
+ if (DB_num_rows($LocnAddrResult)==1){
+ $LocnRow = DB_fetch_array($LocnAddrResult);
+ $_POST['DelAdd1'] = $LocnRow['deladd1'];
+ $_POST['DelAdd2'] = $LocnRow['deladd2'];
+ $_POST['DelAdd3'] = $LocnRow['deladd3'];
+ $_POST['DelAdd4'] = $LocnRow['deladd4'];
+ $_POST['DelAdd5'] = $LocnRow['deladd5'];
+ $_POST['DelAdd6'] = $LocnRow['deladd6'];
+ $_POST['Tel'] = $LocnRow['tel'];
+ $_POST['Contact'] = $LocnRow['contact'];
+
+ $_SESSION['tender']->Location= $_POST['StkLocation'];
+ $_SESSION['tender']->DelAdd1 = $_POST['DelAdd1'];
+ $_SESSION['tender']->DelAdd2 = $_POST['DelAdd2'];
+ $_SESSION['tender']->DelAdd3 = $_POST['DelAdd3'];
+ $_SESSION['tender']->DelAdd4 = $_POST['DelAdd4'];
+ $_SESSION['tender']->DelAdd5 = $_POST['DelAdd5'];
+ $_SESSION['tender']->DelAdd6 = $_POST['DelAdd6'];
+ $_SESSION['tender']->Telephone = $_POST['Tel'];
+ $_SESSION['tender']->Contact = $_POST['Contact'];
+ }
+ }
+ echo '<tr><td>' . _('Warehouse') . ':</td>
+ <td><select name=StkLocation onChange="ReloadForm(form1.LookupDeliveryAddress)">';
+
+ $sql = "SELECT loccode,
+ locationname
+ FROM locations";
+ $LocnResult = DB_query($sql,$db);
+
+ while ($LocnRow=DB_fetch_array($LocnResult)){
+ if ((isset($_SESSION['tender']->Location) and $_SESSION['tender']->Location == $LocnRow['loccode'])){
+ echo '<option selected="True" value="' . $LocnRow['loccode'] . '">' . $LocnRow['locationname'] . '</option>';
+ } else {
+ echo '<option value="' . $LocnRow['loccode'] . '">' . $LocnRow['locationname'] . '</option>';
+ }
+ }
+
+ echo '</select>
+ <input type="submit" name="LookupDeliveryAddress" value="' ._('Select') . '" /></td>
+ </tr>';
+
+ /* Display the details of the delivery location
+ */
+ echo '<tr><td>' . _('Delivery Contact') . ':</td>
+ <td><input type="text" name="Contact" size="41" value="' . $_SESSION['tender']->Contact . '" /></td>
+ </tr>';
+ echo '<tr><td>' . _('Address') . ' 1 :</td>
+ <td><input type="text" name="DelAdd1" size="41" maxlength="40" value="' . $_POST['DelAdd1'] . '" /></td>
+ </tr>';
+ echo '<tr><td>' . _('Address') . ' 2 :</td>
+ <td><input type="text" name="DelAdd2" size="41" maxlength="40" value="' . $_POST['DelAdd2'] . '" /></td>
+ </tr>';
+ echo '<tr><td>' . _('Address') . ' 3 :</td>
+ <td><input type="text" name="DelAdd3" size="41" maxlength="40" value="' . $_POST['DelAdd3'] . '" /></td>
+ </tr>';
+ echo '<tr><td>' . _('Address') . ' 4 :</td>
+ <td><input type="text" name="DelAdd4" size="21" maxlength="20" value="' . $_POST['DelAdd4'] . '" /></td>
+ </tr>';
+ echo '<tr><td>' . _('Address') . ' 5 :</td>
+ <td><input type="text" name="DelAdd5" size="16" maxlength="15" value="' . $_POST['DelAdd5'] . '" /></td>
+ </tr>';
+ echo '<tr><td>' . _('Address') . ' 6 :</td>
+ <td><input type="text" name="DelAdd6" size="16" maxlength="15" value="' . $_POST['DelAdd6'] . '" /></td>
+ </tr>';
+ echo '<tr><td>' . _('Phone') . ':</td>
+ <td><input type="text" name="Tel" size="31" maxlength="30" value="' . $_SESSION['tender']->Telephone . '" /></td>
+ </tr>';
+ echo '</table><br />';
+
+ /* Display the supplier/item details
+ */
+ echo '<table>';
+
+ /* Supplier Details
+ */
+ echo '<tr><td valign="top"><table class="selection">';
+ echo '<tr><th colspan="4"><font size="3" color="#616161">' . _('Suppliers To Send Tender') . '</font></th></tr>';
+ echo '<tr><th>'. _('Supplier Code') . '</th><th>' ._('Supplier Name') . '</th><th>' ._('Email Address') . '</th></tr>';
+ foreach ($_SESSION['tender']->Suppliers as $Supplier) {
+ echo '<tr><td>' . $Supplier->SupplierCode . '</td>';
+ echo '<td>' . $Supplier->SupplierName . '</td>';
+ echo '<td>' . $Supplier->EmailAddress . '</td>';
+ echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?DeleteSupplier=' . $Supplier->SupplierCode . '">' . _('Delete') . '</a></td></tr>';
+ }
+ echo '</table></td>';
+ /* Item Details
+ */
+ echo '<td valign="top"><table class="selection">';
+ echo '<tr><th colspan="6"><font size="3" color="#616161">' . _('Items in Tender') . '</font></th></tr>';
+ echo '<tr>';
+ echo '<th>'._('Stock ID').'</th>';
+ echo '<th>'._('Description').'</th>';
+ echo '<th>'._('Quantity').'</th>';
+ echo '<th>'._('UOM').'</th>';
+ echo '</tr>';
+ $k=0;
+ foreach ($_SESSION['tender']->LineItems as $LineItems) {
+ if ($LineItems->Deleted==False) {
+ if ($k==1){
+ echo '<tr class="EvenTableRows">';
+ $k=0;
+ } else {
+ echo '<tr class="OddTableRows">';
+ $k=1;
+ }
+ echo '<td>'.$LineItems->StockID.'</td>';
+ echo '<td>'.$LineItems->ItemDescription.'</td>';
+ echo '<td class="number">' . locale_number_format($LineItems->Quantity,$LineItems->DecimalPlaces).'</td>';
+ echo '<td>'.$LineItems->Units.'</td>';
+ echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?DeleteItem=' . $LineItems->LineNo . '">' . _('Delete') . '</a></td></tr>';
+ echo '</tr>';
+ }
+ }
+ echo '</table></td></tr></table><br />';
+
+ echo '<div class="centre"><input type="submit" name="Suppliers" value="' . _('Select Suppliers') . '" />';
+ echo '<input type="submit" name="Items" value="' . _('Select Item Details') . '" /></div><br />';
+ if ($_SESSION['tender']->LinesOnTender > 0 and $_SESSION['tender']->SuppliersOnTender > 0) {
+ echo '<div class="centre"><input type="submit" name="Save" value="' . _('Save Tender') . '" /></div>';
+ }
+ echo '</form>';
+ include('includes/footer.inc');
+ exit;
+}
+
+if (isset($_POST['SearchSupplier']) OR isset($_POST['Go']) OR isset($_POST['Next']) OR isset($_POST['Previous'])) {
+ if (mb_strlen($_POST['Keywords']) > 0 AND mb_strlen($_POST['SupplierCode']) > 0) {
+ prnMsg( '<br />' . _('Supplier name keywords have been used in preference to the Supplier code extract entered'), 'info' );
+ }
+ if ($_POST['Keywords'] == '' AND $_POST['SupplierCode'] == '') {
+ $SQL = "SELECT supplierid,
+ suppname,
+ currcode,
+ address1,
+ address2,
+ address3,
+ address4
+ FROM suppliers
+ ORDER BY suppname";
+ } else {
+ if (mb_strlen($_POST['Keywords']) > 0) {
+ $_POST['Keywords'] = mb_strtoupper($_POST['Keywords']);
+ //insert wildcard characters in spaces
+ $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%';
+ $SQL = "SELECT supplierid,
+ suppname,
+ currcode,
+ address1,
+ address2,
+ address3,
+ address4
+ FROM suppliers
+ WHERE suppname " . LIKE . " '$SearchString'
+ ORDER BY suppname";
+ } elseif (mb_strlen($_POST['SupplierCode']) > 0) {
+ $_POST['SupplierCode'] = mb_strtoupper($_POST['SupplierCode']);
+ $SQL = "SELECT supplierid,
+ suppname,
+ currcode,
+ address1,
+ address2,
+ address3,
+ address4
+ FROM suppliers
+ WHERE supplierid " . LIKE . " '%" . $_POST['SupplierCode'] . "%'
+ ORDER BY supplierid";
+ }
+ } //one of keywords or SupplierCode was more than a zero length string
+ $result = DB_query($SQL, $db);
+ if (DB_num_rows($result) == 1) {
+ $myrow = DB_fetch_row($result);
+ $SingleSupplierReturned = $myrow[0];
+ }
+} //end of if search
+if (isset($SingleSupplierReturned)) { /*there was only one supplier returned */
+ $_SESSION['SupplierID'] = $SingleSupplierReturned;
+ unset($_POST['Keywords']);
+ unset($_POST['SupplierCode']);
+}
+
+if (!isset($_POST['PageOffset'])) {
+ $_POST['PageOffset'] = 1;
+} else {
+ if ($_POST['PageOffset'] == 0) {
+ $_POST['PageOffset'] = 1;
+ }
+}
+
+if (isset($_POST['Suppliers'])) {
+ echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">';
+ echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
+ echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Search') . '" alt="" />' . ' ' . _('Search for Suppliers') . '</p>
+ <table cellpadding="3" colspan="4" class="selection"><tr><td>' . _('Enter a partial Name') . ':</td><td>';
+ if (isset($_POST['Keywords'])) {
+ echo '<input type="text" name="Keywords" value="' . $_POST['Keywords'] . '" size="20" maxlength="25" />';
+ } else {
+ echo '<input type="text" name="Keywords" size="20" maxlength="25" />';
+ }
+ echo '</td><td><b>' . _('OR') . '</b></font></td><td>' . _('Enter a partial Code') . ':</font></td><td>';
+ if (isset($_POST['SupplierCode'])) {
+ echo '<input type="text" name="SupplierCode" value="' . $_POST['SupplierCode'] . '" size="15" maxlength="18" />';
+ } else {
+ echo '<input type="text" name="SupplierCode" size="15" maxlength="18" />';
+ }
+ echo '</td></tr></table><br /><div class="centre"><input type="submit" name="SearchSupplier" value="' . _('Search Now') . '" /></div>';
+ echo '</form>';
+}
+
+if (isset($_POST['SearchSupplier'])) {
+ echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">';
+ echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
+ $ListCount = DB_num_rows($result);
+ $ListPageMax = ceil($ListCount / $_SESSION['DisplayRecordsMax']);
+ if (isset($_POST['Next'])) {
+ if ($_POST['PageOffset'] < $ListPageMax) {
+ $_POST['PageOffset'] = $_POST['PageOffset'] + 1;
+ }
+ }
+ if (isset($_POST['Previous'])) {
+ if ($_POST['PageOffset'] > 1) {
+ $_POST['PageOffset'] = $_POST['PageOffset'] - 1;
+ }
+ }
+ if ($ListPageMax > 1) {
+ echo '<br /> ' . $_POST['PageOffset'] . ' ' . _('of') . ' ' . $ListPageMax . ' ' . _('pages') . '. ' . _('Go to Page') . ': ';
+ echo '<select name="PageOffset">';
+ $ListPage = 1;
+ while ($ListPage <= $ListPageMax) {
+ if ($ListPage == $_POST['PageOffset']) {
+ echo '<option value=' . $ListPage . ' selected>' . $ListPage . '</option>';
+ } else {
+ echo '<option value=' . $ListPage . '>' . $ListPage . '</option>';
+ }
+ $ListPage++;
+ }
+ echo '</select>
+ <input type="submit" name="Go" value="' . _('Go') . '" />
+ <input type="submit" name="Previous" value="' . _('Previous') . '" />
+ <input type="submit" name="Next" value="' . _('Next') . '" />';
+ echo '<br />';
+ }
+ echo '<input type="hidden" name="Search" value="' . _('Search Now') . '" />';
+ echo '<br /><br />';
+ echo '<br /><table cellpadding="2" colspan="7">';
+ $tableheader = '<tr>
+ <th>' . _('Code') . '</th>
+ <th>' . _('Supplier Name') . '</th>
+ <th>' . _('Currency') . '</th>
+ <th>' . _('Address 1') . '</th>
+ <th>' . _('Address 2') . '</th>
+ <th>' . _('Address 3') . '</th>
+ <th>' . _('Address 4') . '</th>
+ </tr>';
+ echo $tableheader;
+ $j = 1;
+ $k = 0; //row counter to determine background colour
+ $RowIndex = 0;
+ if (DB_num_rows($result) <> 0) {
+ DB_data_seek($result, ($_POST['PageOffset'] - 1) * $_SESSION['DisplayRecordsMax']);
+ }
+ while (($myrow = DB_fetch_array($result)) AND ($RowIndex <> $_SESSION['DisplayRecordsMax'])) {
+ if ($k == 1) {
+ echo '<tr class="EvenTableRows">';
+ $k = 0;
+ } else {
+ echo '<tr class="OddTableRows">';
+ $k = 1;
+ }
+ echo '<td><input type="submit" name="SelectedSupplier" value="'.$myrow['supplierid'].'" /></td>
+ <td>'.$myrow['suppname'].'</td>
+ <td>'.$myrow['currcode'].'</td>
+ <td>'.$myrow['address1'].'</td>
+ <td>'.$myrow['address2'].'</td>
+ <td>'.$myrow['address3'].'</td>
+ <td>'.$myrow['address4'].'</td>
+ </tr>';
+ $RowIndex = $RowIndex + 1;
+ //end of page full new headings if
+ }
+ //end of while loop
+ echo '</table>';
+}
+
+/*The supplier has chosen option 2
+ */
+if (isset($_POST['Items'])) {
+ echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">';
+ echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
+ echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Search') . '" alt="" />' . ' ' . _('Search for Inventory Items') . '</p>';
+ $sql = "SELECT categoryid,
+ categorydescription
+ FROM stockcategory
+ ORDER BY categorydescription";
+ $result = DB_query($sql, $db);
+ if (DB_num_rows($result) == 0) {
+ echo '<br /><font size="4" color="red">' . _('Problem Report') . ':</font><br />' .
+ _('There are no stock categories currently defined please use the link below to set them up');
+ echo '<br /><a href="' . $rootpath . '/StockCategories.php">' . _('Define Stock Categories') . '</a>';
+ exit;
+ }
+ echo '<table class="selection"><tr>';
+ echo '<td>' . _('In Stock Category') . ':';
+ echo '<select name="StockCat">';
+ if (!isset($_POST['StockCat'])) {
+ $_POST['StockCat'] = "";
+ }
+ if ($_POST['StockCat'] == 'All') {
+ echo '<option selected="True" value="All">' . _('All') . '</option>';
+ } else {
+ echo '<option value="All">' . _('All') . '</option>';
+ }
+ while ($myrow1 = DB_fetch_array($result)) {
+ if ($myrow1['categoryid'] == $_POST['StockCat']) {
+ echo '<option selected="True" value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>';
+ } else {
+ echo '<option value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>';
+ }
+ }
+ echo '</select>';
+ echo '<td>' . _('Enter partial') . '<b> ' . _('Description') . '</b>:</td><td>';
+ if (isset($_POST['Keywords'])) {
+ echo '<input type="text" name="Keywords" value="' . $_POST['Keywords'] . '" size="20" maxlength="25" />';
+ } else {
+ echo '<input type="text" name="Keywords" size="20" maxlength="25" />';
+ }
+ echo '</td></tr><tr><td></td>';
+ echo '<td><font size="3"><b>' . _('OR') . ' ' . '</b></font>' . _('Enter partial') . ' <b>' . _('Stock Code') . '</b>:</td>';
+ echo '<td>';
+ if (isset($_POST['StockCode'])) {
+ echo '<input type="text" name="StockCode" value="' . $_POST['StockCode'] . '" size="15" maxlength="18" />';
+ } else {
+ echo '<input type="text" name="StockCode" size="15" maxlength="18" />';
+ }
+ echo '</td></tr></table><br />';
+ echo '<div class="centre"><input type="submit" name="Search" value="' . _('Search Now') . '" /></div><br /></form>';
+ echo '<script type="text/javascript">defaultControl(document.forms[0].StockCode);</script>';
+ echo '</form>';
+}
+
+if (isset($_POST['Search'])){ /*ie seach for stock items */
+ echo '<form method="post" action="' . $_SERVER['PHP_SELF'] .'">';
+ echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
+ echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/supplier.png" title="' . _('Tenders') . '" alt="" />' . ' ' . _('Select items required on this tender').'</p>';
+
+ if ($_POST['Keywords'] AND $_POST['StockCode']) {
+ prnMsg( _('Stock description keywords have been used in preference to the Stock code extract entered'), 'info' );
+ }
+ if ($_POST['Keywords']) {
+ //insert wildcard characters in spaces
+ $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%';
+
+ if ($_POST['StockCat']=='All'){
+ $sql = "SELECT stockmaster.stockid,
+ stockmaster.description,
+ stockmaster.units
+ FROM stockmaster INNER JOIN stockcategory
+ ON stockmaster.categoryid=stockcategory.categoryid
+ WHERE stockmaster.mbflag!='D'
+ AND stockmaster.mbflag!='A'
+ AND stockmaster.mbflag!='K'
+ and stockmaster.discontinued!=1
+ AND stockmaster.description " . LIKE . " '$SearchString'
+ ORDER BY stockmaster.stockid";
+ } else {
+ $sql = "SELECT stockmaster.stockid,
+ stockmaster.description,
+ stockmaster.units
+ FROM stockmaster INNER JOIN stockcategory
+ ON stockmaster.categoryid=stockcategory.categoryid
+ WHERE stockmaster.mbflag!='D'
+ AND stockmaster.mbflag!='A'
+ AND stockmaster.mbflag!='K'
+ and stockmaster.discontinued!=1
+ AND stockmaster.description " . LIKE . " '$SearchString'
+ AND stockmaster.categoryid='" . $_POST['StockCat'] . "'
+ ORDER BY stockmaster.stockid";
+ }
+
+ } elseif ($_POST['StockCode']){
+
+ $_POST['StockCode'] = '%' . $_POST['StockCode'] . '%';
+
+ if ($_POST['StockCat']=='All'){
+ $sql = "SELECT stockmaster.stockid,
+ stockmaster.description,
+ stockmaster.units
+ FROM stockmaster INNER JOIN stockcategory
+ ON stockmaster.categoryid=stockcategory.categoryid
+ WHERE stockmaster.mbflag!='D'
+ AND stockmaster.mbflag!='A'
+ AND stockmaster.mbflag!='K'
+ and stockmaster.discontinued!=1
+ AND stockmaster.stockid " . LIKE . " '" . $_POST['StockCode'] . "'
+ ORDER BY stockmaster.stockid";
+ } else {
+ $sql = "SELECT stockmaster.stockid,
+ stockmaster.description,
+ stockmaster.units
+ FROM stockmaster INNER JOIN stockcategory
+ ON stockmaster.categoryid=stockcategory.categoryid
+ WHERE stockmaster.mbflag!='D'
+ AND stockmaster.mbflag!='A'
+ AND stockmaster.mbflag!='K'
+ and stockmaster.discontinued!=1
+ AND stockmaster.stockid " . LIKE . " '" . $_POST['StockCode'] . "'
+ AND stockmaster.categoryid='" . $_POST['StockCat'] . "'
+ ORDER BY stockmaster.stockid";
+ }
+
+ } else {
+ if ($_POST['StockCat']=='All'){
+ $sql = "SELECT stockmaster.stockid,
+ stockmaster.description,
+ stockmaster.units
+ FROM stockmaster INNER JOIN stockcategory
+ ON stockmaster.categoryid=stockcategory.categoryid
+ WHERE stockmaster.mbflag!='D'
+ AND stockmaster.mbflag!='A'
+ AND stockmaster.mbflag!='K'
+ and stockmaster.discontinued!=1
+ ORDER BY stockmaster.stockid";
+ } else {
+ $sql = "SELECT stockmaster.stockid,
+ stockmaster.description,
+ stockmaster.units
+ FROM stockmaster INNER JOIN stockcategory
+ ON stockmaster.categoryid=stockcategory.categoryid
+ WHERE stockmaster.mbflag!='D'
+ AND stockmaster.mbflag!='A'
+ AND stockmaster.mbflag!='K'
+ and stockmaster.discontinued!=1
+ AND stockmaster.categoryid='" . $_POST['StockCat'] . "'
+ ORDER BY stockmaster.stockid";
+ }
+ }
+
+ $ErrMsg = _('There is a problem selecting the part records to display because');
+ $DbgMsg = _('The SQL statement that failed was');
+ $SearchResult = DB_query($sql,$db,$ErrMsg,$DbgMsg);
+
+ if (DB_num_rows($SearchResult)==0 and $debug==1){
+ prnMsg( _('There are no products to display matching the criteria provided'),'warn');
+ }
+ if (DB_num_rows($SearchResult)==1){
+
+ $myrow=DB_fetch_array($SearchResult);
+ $_GET['NewItem'] = $myrow['stockid'];
+ DB_data_seek($SearchResult,0);
+ }
+
+ if (isset($SearchResult)) {
+
+ echo '<table cellpadding="1" colspan="7">';
+
+ $tableheader = '<tr>
+ <th>' . _('Code') . '</th>
+ <th>' . _('Description') . '</th>
+ <th>' . _('Units') . '</th>
+ <th>' . _('Image') . '</th>
+ <th>' . _('Quantity') . '</th>
+ </tr>';
+ echo $tableheader;
+
+ $i = 0;
+ $k = 0; //row colour counter
+ $PartsDisplayed=0;
+ while ($myrow=DB_fetch_array($SearchResult)) {
+
+ if ($k==1){
+ echo '<tr class="EvenTableRows">';
+ $k=0;
+ } else {
+ echo '<tr class="OddTableRows">';
+ $k=1;
+ }
+
+ $filename = $myrow['stockid'] . '.jpg';
+ if (file_exists( $_SESSION['part_pics_dir'] . '/' . $filename) ) {
+
+ $ImageSource = '<img src="'.$rootpath . '/' . $_SESSION['part_pics_dir'] . '/' . $myrow['stockid'] . '.jpg" width="50" height="50" />';
+
+ } else {
+ $ImageSource = '<i>'._('No Image').'</i>';
+ }
+
+ $uom=$myrow['units'];
+
+ echo '<td>'.$myrow['stockid'].'</td>
+ <td>'.$myrow['description'].'</td>
+ <td>'.$uom.'</td>
+ <td>'.$ImageSource.'</td>
+ <td><input class="number" type="text" size="6" value="0" name="Qty'.$i.'" /></td>
+ <input type="hidden" value="'.$uom.'" name="UOM'.$i.'" />
+ <input type="hidden" value="'.$myrow['stockid'].'" name="StockID'.$i.'" />
+ </tr>';
+
+ $PartsDisplayed++;
+ if ($PartsDisplayed == $Maximum_Number_Of_Parts_To_Show){
+ break;
+ }
+ $i++;
+#end of page full new headings if
+ }
+#end of while loop
+ echo '</table>';
+ if ($PartsDisplayed == $Maximum_Number_Of_Parts_To_Show){
+
+ /*$Maximum_Number_Of_Parts_To_Show defined in config.php */
+
+ prnMsg( _('Only the first') . ' ' . $Maximum_Number_Of_Parts_To_Show . ' ' . _('can be displayed') . '. ' .
+ _('Please restrict your search to only the parts required'),'info');
+ }
+ echo '<a name="end"></a><br /><div class="centre"><input type="submit" name="NewItem" value="Add to Tender" /></div>';
+ }#end if SearchResults to show
+
+ echo '</form>';
+
+} //end of if search
+
+include('includes/footer.inc');
+
+?>
\ No newline at end of file
Modified: trunk/SupplierTenders.php
===================================================================
--- trunk/SupplierTenders.php 2012-01-20 08:19:32 UTC (rev 4820)
+++ trunk/SupplierTenders.php 2012-01-20 13:48:53 UTC (rev 4821)
@@ -8,6 +8,10 @@
$Maximum_Number_Of_Parts_To_Show=50;
+if (isset($_GET['TenderType'])) {
+ $_POST['TenderType']=$_GET['TenderType'];
+}
+
if (!isset($_POST['SupplierID'])) {
$sql="SELECT supplierid FROM www_users WHERE userid='" . $_SESSION['UserID'] . "'";
$result=DB_query($sql, $db);
@@ -27,12 +31,110 @@
$_SESSION['offer']->remove_from_offer($_GET['Delete']);
}
-$sql="SELECT suppname, currcode FROM suppliers WHERE supplierid='" . $_POST['SupplierID'] . "'";
+$sql="SELECT suppname,
+ currcode
+ FROM suppliers
+ WHERE supplierid='".$_POST['SupplierID']."'";
$result=DB_query($sql, $db);
$myrow=DB_fetch_array($result);
$Supplier=$myrow['suppname'];
$Currency=$myrow['currcode'];
+if (isset($_POST['Confirm'])) {
+ $_SESSION['offer']->Save($db);
+ $_SESSION['offer']->EmailOffer();
+ $sql="UPDATE tendersuppliers
+ SET responded=1
+ WHERE supplierid='" . $_SESSION['offer']->SupplierID . "'
+ AND tenderid='" . $_SESSION['offer']->TenderID . "'";
+ $result=DB_query($sql, $db);
+}
+
+if (isset($_POST['Process'])) {
+ if (isset($_SESSION['offer'])) {
+ unset($_SESSION['offer']);
+ }
+ $_SESSION['offer']=new Offer($_POST['SupplierID']);
+ $_SESSION['offer']->TenderID=$_POST['Tender'];
+ $_SESSION['offer']->CurrCode=$Currency;
+ $LineNo=0;
+ foreach ($_POST as $key=>$value) {
+ if (mb_substr($key,0,7)=='StockID') {
+ $Index = mb_substr($key,7,mb_strlen($key)-7);
+ $ItemCode=$value;
+ $Quantity=$_POST['Qty'.$Index];
+ $Price=$_POST['Price'.$Index];
+ $_SESSION['offer']->add_to_offer(
+ $LineNo,
+ $ItemCode,
+ $Quantity,
+ $_POST['ItemDescription'.$Index],
+ $Price,
+ $_POST['UOM'.$Index],
+ $_POST['DecimalPlaces'.$Index],
+ $_POST['RequiredByDate'.$Index]);
+ $LineNo++;
+ }
+ }
+ echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/supplier.png" title="' . _('Tenders') . '" alt="" />' . ' ' . _('Confirm the Response For Tender') . ' ' . $_SESSION['offer']->TenderID .'</p>';
+ echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF']) . '" method="post">';
+ echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
+ echo '<table class="selection">';
+ echo '<input type="hidden" name="TenderType" value="3" />';
+ $LocationSQL="SELECT tenderid,
+ locations.locationname,
+ address1,
+ address2,
+ address3,
+ address4,
+ address5,
+ address6,
+ telephone
+ FROM tenders
+ LEFT JOIN locations
+ ON tenders.location=locations.loccode
+ WHERE closed=0
+ AND tenderid='".$_SESSION['offer']->TenderID."'";
+ $LocationResult=DB_query($LocationSQL, $db);
+ $MyLocationRow=DB_fetch_row($LocationResult);
+ $CurrencySQL="SELECT decimalplaces from currencies WHERE currabrev='".$_SESSION['offer']->CurrCode."'";
+ $CurrencyResult=DB_query($CurrencySQL, $db);
+ $CurrencyRow=DB_fetch_array($CurrencyResult);
+ echo '<tr><td valign="top" style="background-color:#cccce5">' . _('Deliver To') . ':</td><td valign="top" style="background-color:#cccce5">';
+ for ($i=1; $i<8; $i++) {
+ if ($MyLocationRow[$i]!='') {
+ echo $MyLocationRow[$i] . '<br />';
+ }
+ }
+ echo '</td>';
+ echo '<th colspan="8" style="vertical-align:top"><font size="2" color="#616161">' . _('Tender Number') . ': ' .$_SESSION['offer']->TenderID . '</font></th>';
+ echo '<input type="hidden" value="' . $_SESSION['offer']->TenderID . '" name="Tender" />';
+ echo '<tr><th>' . stripslashes($_SESSION['CompanyRecord']['coyname']) . '<br />' . _('Item Code') . '</th>';
+ echo '<th>' . _('Item Description') . '</th>';
+ echo '<th>' . _('Quantity') . '<br />' . _('Offered') . '</th>';
+ echo '<th>' . $Supplier . '<br />' . _('Units of Measure') . '</th>';
+ echo '<th>' . _('Currency') . '</th>';
+ echo '<th>' . $Supplier . '<br />' . _('Price') . '</th>';
+ echo '<th>' . _('Line Value') . '</th>';
+ echo '<th>' . _('Delivery By') . '</th>';
+ foreach ($_SESSION['offer']->LineItems as $LineItem) {
+ echo '<tr><td>' . $LineItem->StockID . '</td>';
+ echo '<td>' . $LineItem->ItemDescription . '</td>';
+ echo '<td class="number"> ' .locale_number_format($LineItem->Quantity, $LineItem->DecimalPlaces) . '</td>';
+ echo '<td>' . $LineItem->Units . '</td>';
+ echo '<td>' . $_SESSION['offer']->CurrCode . '</td>';
+ echo '<td class="number">' . locale_number_format($LineItem->Price, $CurrencyRow['decimalplaces']) . '</td>';
+ echo '<td class="number">' . locale_number_format($LineItem->Price*$LineItem->Quantity,$CurrencyRow['decimalplaces']) . '</td>';
+ echo '<td>' . $LineItem->ExpiryDate . '</td>';
+ }
+ echo '</table><br />';
+ echo '<div class="centre"><input type="submit" name="Confirm" value="' . _('Confirm and Send Email') . '" /><br />';
+ echo '<br /><input type="submit" name="Cancel" value="' . _('Cancel Offer') . '" /></div>';
+ echo '</form>';
+ include('includes/footer.inc');
+ exit;
+}
+
/* If the supplierID is set then it must be a login from the supplier but if nothing else is
* set then the supplier must have just logged in so show them the choices.
*/
@@ -42,66 +144,57 @@
}
echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF']) . '">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
- echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/supplier.png" title="' .
- _('Tenders') . '" alt="" />' . ' ' . _('Create or View Offers from') . ' '.$Supplier.'</p>';
+ echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/supplier.png" title="' . _('Tenders') . '" alt="" />' . ' ' . _('Create or View Offers from') . ' '.$Supplier.'</p>';
echo '<table class="selection">';
echo'<tr><td>'._('Select option for tendering').'</td>';
- echo '<td><select name=TenderType>';
- echo '<option value=1>'._('View or Amend outstanding offers from').' '.$Supplier .'</option>';
- echo '<option value=2>'._('Create a new offer from').' '.$Supplier .'</option>';
-// echo '<option value=3>'._('View any open tenders without an offer from').' '.$Supplier .'</option>';
+ echo '<td><select name="TenderType">';
+ echo '<option value="1">'._('View or Amend outstanding offers from').' '.$Supplier .'</option>';
+ echo '<option value="2">'._('Create a new offer from').' '.$Supplier .'</option>';
+ echo '<option value="3">'._('View any open tenders without an offer from').' '.$Supplier .'</option>';
echo '</select></td></tr>';
- echo '<input type="hidden" name="SupplierID" value="'.$_POST['SupplierID'].'"';
- echo '<tr><td colspan="2"><div class="centre"><input type="submit" name="submit" value="' . _('Select') . '"></div></td></tr>';
- echo '</table>
- </form>';
+ echo '<input type="hidden" name="SupplierID" value="'.$_POST['SupplierID'].'" />';
+ echo '<tr><td colspan="2"><div class="centre"><input type="submit" name="submit" value="' . _('Select') . '" /></div></td></tr>';
+ echo '</table></form>';
}
if (isset($_POST['NewItem']) and !isset($_POST['Refresh'])) {
foreach ($_POST as $key => $value) {
- if (mb_substr($key,0,3)=='qty') {
- $StockID=mb_substr($key,3);
- $Quantity=$value;
+ if (mb_substr($key,0,7)=='StockID') {
+ $Index = mb_substr($key,7,mb_strlen($key)-7);
+ $StockID=$value;
+ $Quantity=filter_number_format($_POST['Qty'.$Index]);
+ $Price=filter_number_format($_POST['Price'.$Index]);
+ $UOM=$_POST['uom'.$Index];
+ if (isset($UOM) and $Quantity>0) {
+ $sql="SELECT description, decimalplaces FROM stockmaster WHERE stockid='".$StockID."'";
+ $result=DB_query($sql, $db);
+ $myrow=DB_fetch_array($result);
+ $_SESSION['offer']->add_to_offer($_SESSION['offer']->LinesOnOffer,
+ $StockID,
+ $Quantity,
+ $myrow['description'],
+ $Price,
+ $UOM,
+ $myrow['decimalplaces'],
+ DateAdd(date($_SESSION['DefaultDateFormat']),'m',3));
+ unset($UOM);
+ }
}
- if (mb_substr($key,0,5)=='price') {
- $Price=$value;
- }
- if (mb_substr($key,0,3)=='uom') {
- $UOM=$value;
- }
- if (isset($UOM)) {
- $sql="SELECT description, decimalplaces FROM stockmaster WHERE stockid='" . $StockID."'";
- $result=DB_query($sql, $db);
- $myrow=DB_fetch_array($result);
- $_SESSION['offer']->add_to_offer(
- $_SESSION['offer']->LinesOnOffer,
- $StockID,
- $Quantity,
- $myrow['description'],
- $Price,
- $UOM,
- $myrow['decimalplaces'],
- DateAdd(date($_SESSION['DefaultDateFormat']),'m',3));
- unset($UOM);
- }
}
}
if (isset($_POST['Refresh']) and !isset($_POST['NewItem'])) {
foreach ($_POST as $key => $value) {
- if (mb_substr($key,0,3)=='qty') {
- $LineNo=mb_substr($key,3);
- $Quantity=$value;
+ if (mb_substr($key,0,7)=='StockID') {
+ $Index = mb_substr($key,7,mb_strlen($key)-7);
+ $StockID=$value;
+ $Quantity=filter_number_format($_POST['Qty'.$Index]);
+ $Price=filter_number_format($_POST['Price'.$Index]);
+ $ExpiryDate=$_POST['expirydate'.$Index];
}
- if (mb_substr($key,0,5)=='price') {
- $Price=$value;
- }
- if (mb_substr($key,0,10)=='expirydate') {
- $ExpiryDate=$value;
- }
if (isset($ExpiryDate)) {
$_SESSION['offer']->update_offer_item(
- $LineNo,
+ $Index,
$Quantity,
$Price,
$ExpiryDate);
@@ -111,7 +204,6 @@
}
if (isset($_POST['Update'])) {
- $MailText='';
foreach ($_POST as $key => $value) {
if (mb_substr($key,0,3)=='qty') {
$LineNo=mb_substr($key,3);
@@ -132,31 +224,14 @@
unset($ExpiryDate);
}
}
- foreach ($_SESSION['offer']->LineItems as $LineItems) {
- $sql="UPDATE offers SET
- quantity='".$LineItems->Quantity."',
- price='".$LineItems->Price."',
- expirydate='".FormatDateForSQL($LineItems->ExpiryDate)."'
- WHERE offerid='".$LineItems->LineNo . "'";
- $ErrMsg = _('The suppliers offer could not be updated on the database because');
- $DbgMsg = _('The SQL statement used to update the suppliers offer record and failed was');
- $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true);
- if (DB_error_no($db)==0) {
- prnMsg( _('The offer for').' '.$LineItems->StockID.' '._('has been updated in the database'), 'success');
- $MailText .= $LineItems->Quantity.$LineItems->Units.' '._('of').' '.$LineItems->StockID.' '._('at a price of').
- ' '.$Currency.$LineItems->Price."\n";
- } else {
- prnMsg( _('The offer for').' '.$LineItems->StockID.' '._('could not be updated in the database'), 'error');
- include('includes/footer.inc');
- exit;
- }
- }
+ $_SESSION['offer']->Save($db, 'Yes');
+ $_SESSION['offer']->EmailOffer();
+ unset($_SESSION['offer']);
include('includes/footer.inc');
exit;
}
if (isset($_POST['Save'])) {
- $MailText='';
foreach ($_POST as $key => $value) {
if (mb_substr($key,0,3)=='qty') {
$LineNo=mb_substr($key,3);
@@ -177,46 +252,9 @@
unset($ExpiryDate);
}
}
- foreach ($_SESSION['offer']->LineItems as $LineItems) {
- if ($LineItems->Deleted==False) {
- $sql="INSERT INTO offers (
- supplierid,
- stockid,
- quantity,
- uom,
- price,
- expirydate,
- currcode)
- VALUES (
- '".$_POST['SupplierID']."',
- '".$LineItems->StockID."',
- '".$LineItems->Quantity."',
- '".$LineItems->Units."',
- '".$LineItems->Price."',
- '".FormatDateForSQL($LineItems->ExpiryDate)."',
- '".$Currency."'
- )";
- $ErrMsg = _('The suppliers offer could not be inserted into the database because');
- $DbgMsg = _('The SQL statement used to insert the suppliers offer record and failed was');
- $result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true);
- if (DB_error_no($db)==0) {
- prnMsg( _('The offer for').' '.$LineItems->StockID.' '._('has been inserted into the database'), 'success');
- $MailText .= $LineItems->Quantity.$LineItems->Units.' '._('of').' '.$LineItems->StockID.' '._('at a price of').
- ' '.$Currency.$LineItems->Price."\n";
- } else {
- prnMsg( _('The offer for').' '.$LineItems->StockID.' '._('could not be inserted into the database'), 'error');
- include('includes/footer.inc');
- exit;
- }
- }
- }
- include ('includes/htmlMimeMail.php');
- $mail = new htmlMimeMail();
- $mail->setSubject(_('Offer received from').' '.$Supplier);
- $mail->setText(_('This email is automatically generated by webERP')."\n" .
- _('You have received the following offer from').' '.$Supplier."\n\n".$MailText);
- $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . ' <' . $_SESSION['CompanyRecord']['email'] . '>');
- $result = $mail->send(array($_SESSION['PurchasingManagerEmail']), 'smtp');
+ $_SESSION['offer']->Save($db);
+ $_SESSION['offer']->EmailOffer();
+ unset($_SESSION['offer']);
include('includes/footer.inc');
exit;
}
@@ -234,11 +272,10 @@
stockmaster.decimalplaces
FROM offers
INNER JOIN stockmaster
- ON offers.stockid=stockmaster.stockid
- WHERE offers.supplierid='" . $_POST['SupplierID']."'";
+ ON offers.stockid=stockmaster.stockid
+ WHERE offers.supplierid='" . $_POST['SupplierID'] . "'";
$result=DB_query($sql, $db);
- $_SESSION['offer']=new Offer();
- $_SESSION['offer']->SupplierID=$_POST['SupplierID'];
+ $_SESSION['offer']=new Offer($_POST['SupplierID']);
$_SESSION['offer']->CurrCode=$Currency;
while ($myrow=DB_fetch_array($result)) {
$_SESSION['offer']->add_to_offer(
@@ -253,11 +290,10 @@
}
}
-if (isset($_SESSION['offer']) and $_SESSION['offer']->LinesOnOffer>0 or isset($_POST['Update'])) {
+if (isset($_POST['TenderType']) and $_POST['TenderType']!=3 and isset($_SESSION['offer']) and $_SESSION['offer']->LinesOnOffer>0 or isset($_POST['Update'])) {
echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF']) . '">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
- echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/supplier.png" title="' .
- _('Search') . '" alt="" />' . ' ' . _('Items to offer from').' '.$Supplier .'</p>';
+ echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/supplier.png" title="' . _('Search') . '" alt="" />' . ' ' . _('Items to offer from').' '.$Supplier .'</p>';
echo '<table>';
echo '<tr>
<th>'._('Stock ID').'</th>
@@ -279,27 +315,28 @@
$k=1;
}
if ($LineItems->ExpiryDate < date('Y-m-d')) {
- echo '<tr bgcolor=#F7A9A9>';
+ echo '<tr bgcolor="#F7A9A9">';
}
+ echo '<input type="hidden" name="StockID'.$LineItems->LineNo.'" value="'.$LineItems->StockID.'" />';
echo '<td>'.$LineItems->StockID.'</td>';
echo '<td>'.$LineItems->ItemDescription.'</td>';
- echo '<td><input type="text" class=number name="qty'.$LineItems->LineNo.'" value='.locale_number_format($LineItems->Quantity,$LineItems->DecimalPlaces).'></td>';
+ echo '<td><input type="text" class="number" name="Qty'.$LineItems->LineNo.'" value="'.locale_number_format($LineItems->Quantity,$LineItems->DecimalPlaces).'" /></td>';
echo '<td>'.$LineItems->Units.'</td>';
- echo '<td><input type="text" class=number name="price'.$LineItems->LineNo.'" value='.locale_number_format($LineItems->Price,2,'.','').'></td>';
- echo '<td class=number>'.locale_number_format($LineItems->Price*$LineItems->Quantity,2).'</td>';
- echo '<td><input type="text" size=11 class=date alt='.$_SESSION['DefaultDateFormat'].' name="expirydate'.$LineItems->LineNo.'" value='.$LineItems->ExpiryDate.'></td>';
+ echo '<td><input type="text" class="number" name="Price'.$LineItems->LineNo.'" value="'.locale_number_format($LineItems->Price,2,'.','').'" /></td>';
+ echo '<td class="number">'.locale_number_format($LineItems->Price*$LineItems->Quantity,2).'</td>';
+ echo '<td><input type="text" size="11" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" name="expirydate'.$LineItems->LineNo.'" value="'.$LineItems->ExpiryDate.'" /></td>';
echo '<td><a href="' . htmlspecialchars($_SERVER['PHP_SELF']) . '?Delete=' . $LineItems->LineNo . '&Type=' . $_POST['TenderType'] . '">' . _('Remove') . '</a></td></tr>';
echo '</tr>';
}
}
echo '</table>';
- echo '<input type=hidden name=TenderType value="'.$_POST['TenderType'].'">';
+ echo '<input type="hidden" name="TenderType" value="'.$_POST['TenderType'].'" />';
if ($_POST['TenderType']==1) {
- echo '<br /><div class="centre"><input type="submit" name="Update" value="Update offer">';
- echo '<input type="submit" name="Refresh" value="Refresh screen"></div>';
+ echo '<br /><div class="centre"><input type="submit" name="Update" value="Update offer" />';
+ echo '<input type="submit" name="Refresh" value="Refresh screen" /></div>';
} else if ($_POST['TenderType']==2) {
echo '<br /><div class="centre"><input type="submit" name="Save" value="Save offer">';
- echo '<input type="submit" name="Refresh" value="Refresh screen"></div>';
+ echo '<input type="submit" name="Refresh" value="Refresh screen" /></div>';
}
echo '</form>';
}
@@ -308,74 +345,175 @@
*/
if (isset($_POST['TenderType']) and $_POST['TenderType']==2 and !isset($_POST['Search']) or isset($_GET['Delete'])) {
if (!isset($_SESSION['offer'])) {
- $_SESSION['offer']=new Offer();
- $_SESSION['offer']->SupplierID=$_POST['SupplierID'];
+ $_SESSION['offer']=new Offer($_POST['SupplierID']);
}
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF']) . '" method="post">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
- echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' .
- _('Search') . '" alt="" />' . ' ' . _('Search for Inventory Items') . '</p>';
-
- $sql = 'SELECT categoryid,
+ echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Search') . '" alt="" />' . ' ' . _('Search for Inventory Items') . '</p>';
+
+ $sql = "SELECT categoryid,
categorydescription
FROM stockcategory
- ORDER BY categorydescription';
+ ORDER BY categorydescription";
$result = DB_query($sql, $db);
-
+
if (DB_num_rows($result) == 0) {
- echo '<p><font size=4 color=red>' . _('Problem Report') . ':</font><br />' .
+ echo '<p><font size="4" color="red">' . _('Problem Report') . ':</font><br />' .
_('There are no stock categories currently defined please use the link below to set them up');
- echo '<br /><a href="' . $rootpath . '/StockCategories.php">' . _('Define Stock Categories') . '</a>';
+ echo '<br /><a href="' . $rootpath . '/StockCategories.php">' . _('Define Stock Categories') . '</a></p>';
exit;
}
- echo '<table class=selection><tr>';
+ echo '<table class="selection"><tr>';
echo '<td>' . _('In Stock Category') . ':';
echo '<select name="StockCat">';
if (!isset($_POST['StockCat'])) {
$_POST['StockCat'] = '';
}
if ($_POST['StockCat'] == 'All') {
- echo '<option selected value="All">' . _('All');
+ echo '<option selected="True" value="All">' . _('All') . '</option>';
} else {
- echo '<option value="All">' . _('All');
+ echo '<option value="All">' . _('All') . '</option>';
}
while ($myrow1 = DB_fetch_array($result)) {
if ($myrow1['categoryid'] == $_POST['StockCat']) {
- echo '<option selected VALUE="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription'];
+ echo '<option selected="True" value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>';
} else {
- echo '<option value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription'];
+ echo '<option value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription'] . '</option>';
}
}
echo '</select>';
echo '<td>' . _('Enter partial') . '<b> ' . _('Description') . '</b>:</td><td>';
if (isset($_POST['Keywords'])) {
- echo '<input type="text" name="Keywords" value="' . $_POST['Keywords'] . '" size="20" maxlength="25">';
+ echo '<input type="text" name="Keywords" value="' . $_POST['Keywords'] . '" size="20" maxlength="25" />';
} else {
- echo '<input type="text" name="Keywords" size="20" maxlength="25">';
+ echo '<input type="text" name="Keywords" size="20" maxlength="25" />';
}
- echo '<input type="hidden" name="TenderType" value='.$_POST['TenderType'].'>';
- echo '<input type="hidden" name="SupplierID" value='.$_POST['SupplierID'].'>';
+ echo '<input type="hidden" name="TenderType" value="'.$_POST['TenderType'].'" />';
+ echo '<input type="hidden" name="SupplierID" value="'.$_POST['SupplierID'].'" />';
echo '</td></tr><tr><td></td>';
- echo '<td><font size 3><b>' . _('OR') . ' ' . '</b></font>' . _('Enter partial') . ' <b>' . _('Stock Code') . '</b>:</td>';
+ echo '<td><font size="3"><b>' . _('OR') . ' ' . '</b></font>' . _('Enter partial') . ' <b>' . _('Stock Code') . '</b>:</td>';
echo '<td>';
if (isset($_POST['StockCode'])) {
- echo '<input type="text" name="StockCode" value="' . $_POST['StockCode'] . '" size="15" maxlength="18">';
+ echo '<input type="text" name="StockCode" value="' . $_POST['StockCode'] . '" size="15" maxlength="18" />';
} else {
- echo '<input type="text" name="StockCode" size="15" maxlength="18">';
+ echo '<input type="text" name="StockCode" size="15" maxlength="18" />';
}
echo '</td></tr></table><br />';
- echo '<div class="centre"><input type=submit name="Search" value="' . _('Search Now') . '"></div><br /></form>';
+ echo '<div class="centre"><input type="submit" name="Search" value="' . _('Search Now') . '" /></div><br /></form>';
echo '<script type="text/javascript">defaultControl(document.forms[0].StockCode);</script>';
echo '</form>';
}
+/*The supplier has chosen option 3
+ */
+if (isset($_POST['TenderType']) and $_POST['TenderType']==3 and !isset($_POST['Search']) or isset($_GET['Delete'])) {
+ echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/supplier.png" title="' . _('Tenders') . '" alt="" />' . ' ' . _('Tenders Waiting For Offers').'</p>';
+ $sql="SELECT DISTINCT tendersuppliers.tenderid,
+ suppliers.currcode
+ FROM tendersuppliers
+ LEFT JOIN suppliers
+ ON suppliers.supplierid=tendersuppliers.supplierid
+ LEFT JOIN tenders
+ ON tenders.tenderid=tendersuppliers.tenderid
+ WHERE tendersuppliers.supplierid='" . $_POST['SupplierID'] . "'
+ AND tenders.closed=0
+ AND tendersuppliers.responded=0
+ ORDER BY tendersuppliers.tenderid";
+ $result=DB_query($sql, $db);
+ echo '<table class="selection">';
+ echo '<tr><th colspan="13"><font size="3" color="#616161">' . _('Outstanding Tenders Waiting For Offer') . '</font></th></tr>';
+ while ($myrow=DB_fetch_row($result)) {
+ echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">';
+ echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
+ echo '<input type="hidden" name="TenderType" value="3" />';
+ $LocationSQL="SELECT tenderid,
+ locations.locationname,
+ address1,
+ address2,
+ address3,
+ address4,
+ address5,
+ address6,
+ telephone
+ FROM tenders
+ LEFT JOIN locations
+ ON tenders.location=locations.loccode
+ WHERE closed=0
+ AND tenderid='".$myrow[0]."'";
+ $LocationResult=DB_query($LocationSQL, $db);
+ $MyLocationRow=DB_fetch_row($LocationResult);
+ echo '<tr><td valign="top" style="background-color:#cccce5">' . _('Deliver To') . ':</td><td valign="top" style="background-color:#cccce5">';
+ for ($i=1; $i<8; $i++) {
+ if ($MyLocationRow[$i]!='') {
+ echo $MyLocationRow[$i] . '<br />';
+ }
+ }
+ echo '</td>';
+ echo '<th colspan="8" style="vertical-align:top"><font size="2" color="#616161">' . _('Tender Number') . ': ' .$myrow[0] . '</font></th>';
+ echo '<input type="hidden" value="' . $myrow[0] . '" name="Tender" />';
+ echo '<th><input type="submit" value="' . _('Process') . "\n" . _('Tender') . '" name="Process" /></th></tr>';
+ $ItemSQL="SELECT tenderitems.tenderid,
+ tenderitems.stockid,
+ stockmaster.description,
+ stockmaster.decimalplaces,
+ purchdata.suppliers_partno,
+ tenderitems.quantity,
+ tenderitems.units,
+ tenders.requiredbydate,
+ purchdata.suppliersuom
+ FROM tenderitems
+ LEFT JOIN stockmaster
+ ON tenderitems.stockid=stockmaster.stockid
+ LEFT JOIN purchdata
+ ON tenderitems.stockid=purchdata.stockid
+ AND purchdata.supplierno='".$_POST['SupplierID']."'
+ LEFT JOIN tenders
+ ON tenders.tenderid=tenderitems.tenderid
+ WHERE tenderitems.tenderid='" . $myrow[0] . "'";
+ $ItemResult=DB_query($ItemSQL, $db);
+ echo '<tr><th>' . stripslashes($_SESSION['CompanyRecord']['coyname']) . '<br />' . _('Item Code') . '</th>';
+ echo '<th>' . _('Item Description') . '</th>';
+ echo '<th>' . $Supplier . '<br />' . _('Item Code') . '</th>';
+ echo '<th>' . _('Quantity') . '<br />' . _('Required') . '</th>';
+ echo '<th>' . stripslashes($_SESSION['CompanyRecord']['coyname']) . '<br />' . _('Units of Measure') . '</th>';
+ echo '<th>' . _('Required By') . '</th>';
+ echo '<th>' . _('Quantity') . '<br />' . _('Offered') . '</th>';
+ echo '<th>' . $Supplier . '<br />' . _('Units of Measure') . '</th>';
+ echo '<th>' . _('Currency') . '</th>';
+ echo '<th>' . $Supplier . '<br />' . _('Price') . '</th>';
+ echo '<th>' . _('Delivery By') . '</th>';
+ $i=0;
+ while ($MyItemRow=DB_fetch_array($ItemResult)) {
+ echo '<tr><td>' . $MyItemRow['stockid'] . '</td>';
+ echo '<td>' . $MyItemRow['description'] . '</td>';
+ echo '<input type="hidden" name="StockID'. $i . '" value="' . $MyItemRow['stockid'] . '" />';
+ echo '<input type="hidden" name="ItemDescription'. $i . '" value="' . $MyItemRow['description'] . '" />';
+ echo '<td>' . $MyItemRow['suppliers_partno'] . '</td>';
+ echo '<td class="number">' . locale_number_format($MyItemRow['quantity'], $MyItemRow['decimalplaces']) . '</td>';
+ echo '<td>' . $MyItemRow['units'] . '</td>';
+ echo '<td>' . ConvertSQLDate($MyItemRow['requiredbydate']) . '</td>';
+ if ($MyItemRow['suppliersuom']=='') {
+ $MyItemRow['suppliersuom']=$MyItemRow['units'];
+ }
+ echo '<td><input type="text" class="number" size="10" name="Qty'. $i . '" value="' . locale_number_format($MyItemRow['quantity'], $MyItemRow['decimalplaces']) . '" /></td>';
+ echo '<input type="hidden" name="UOM'. $i . '" value="' . $MyItemRow['units'] . '" />';
+ echo '<input type="hidden" name="DecimalPlaces'. $i . '" value="' . $MyItemRow['decimalplaces'] . '" />';
+ echo '<td>' . $MyItemRow['suppliersuom'] . '</td>';
+ echo '<td>' . $myrow[1] . '</td>';
+ echo '<td><input type="text" class="number" size="10" name="Price'. $i . '" value="0.00" /></td>';
+ echo '<td><input type="text" class="date" alt="' .$_SESSION['DefaultDateFormat'] .'" name="RequiredByDate'. $i . '" size="11" value="' . ConvertSQLDate($MyItemRow['requiredbydate']) . '" /></td>';
+ }
+ echo '</form>';
+ }
+ echo '</table>';
+}
+
if (isset($_POST['Search'])){ /*ie seach for stock items */
echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF']) . '">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
- echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/supplier.png" title="' .
- _('Tenders') . '" alt="" />' . ' ' . _('Select items to offer from').' '.$Supplier .'</p>';
+ echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/supplier.png" title="' . _('Tenders') . '" alt="" />' . ' ' . _('Select items to offer from').' '.$Supplier .'</p>';
- if ($_POST['Keywords'] AND $_POST['StockCode']) {
+ if ($_POST['Keywords'] and $_POST['StockCode']) {
prnMsg( _('Stock description keywords have been used in preference to the Stock code extract entered'), 'info' );
}
if ($_POST['Keywords']) {
@@ -471,7 +609,7 @@
$DbgMsg = _('The SQL statement that failed was');
$SearchResult = DB_query($sql,$db,$ErrMsg,$DbgMsg);
- if (DB_num_rows($SearchResult)==0 && $debug==1){
+ if (DB_num_rows($SearchResult)==0 and $debug==1){
prnMsg( _('There are no products to display matching the criteria provided'),'warn');
}
if (DB_num_rows($SearchResult)==1){
@@ -483,7 +621,7 @@
if (isset($SearchResult)) {
- echo "<table cellpadding=1 colspan=7>";
+ echo '<table cellpadding="1" colspan="7">';
$tableheader = '<tr>
<th>' . _('Code') . '</th>
@@ -495,8 +633,8 @@
</tr>';
echo $tableheader;
- $j = 1;
- $k=0; //row colour counter
+ $i = 0;
+ $k = 0; //row colour counter
$PartsDisplayed=0;
while ($myrow=DB_fetch_array($SearchResult)) {
@@ -511,8 +649,7 @@
$filename = $myrow['stockid'] . '.jpg';
if (file_exists( $_SESSION['part_pics_dir'] . '/' . $filename) ) {
- $ImageSource = '<img src="'.$rootpath . '/' . $_SESSION['part_pics_dir'] . '/' . $myrow['stockid'] .
- '.jpg" width="50" height="50">';
+ $ImageSource = '<img src="'.$rootpath . '/' . $_SESSION['part_pics_dir'] . '/' . $myrow['stockid'] . '.jpg" width="50" height="50" />';
} else {
$ImageSource = '<i>'._('No Image').'</i>';
@@ -525,7 +662,7 @@
LEFT JOIN unitsofmeasure
ON purchdata.suppliersuom=unitsofmeasure.unitid
WHERE supplierno='".$_POST['SupplierID']."'
- AND stockid='" . $myrow['stockid']. "'";
+ AND stockid='" . $myrow['stockid'] . "'";
$uomresult=DB_query($uomsql, $db);
if (DB_num_rows($uomresult)...
[truncated message content] |