[Weberp-svn] SF.net SVN: weberp:[4803] trunk
Brought to you by:
sotandeka,
tim_schofield
From: <tim...@us...> - 2011-03-22 20:18:58
|
Revision: 4803 http://weberp.svn.sourceforge.net/weberp/?rev=4803&view=rev Author: tim_schofield Date: 2011-03-22 20:18:49 +0000 (Tue, 22 Mar 2011) Log Message: ----------- New tendering system, initial upload Modified Paths: -------------- trunk/PO_Header.php trunk/PO_Items.php trunk/SelectProduct.php trunk/Stocks.php trunk/SupplierTenders.php trunk/includes/DefineOfferClass.php trunk/includes/DefinePOClass.php trunk/includes/footer.inc trunk/includes/session.inc trunk/index.php trunk/sql/mysql/updates/65.php Added Paths: ----------- trunk/Manufacturers.php trunk/SupplierTenderCreate.php trunk/companies/weberpdemo/ trunk/companies/weberpdemo/EDI_Incoming_Orders/ trunk/companies/weberpdemo/EDI_Incoming_Orders/Order1.edi trunk/companies/weberpdemo/EDI_MsgPending/ trunk/companies/weberpdemo/EDI_Sent/ trunk/companies/weberpdemo/EDI_Sent/EDI_INV_67.edi trunk/companies/weberpdemo/EDI_Sent/EDI_INV_68.edi trunk/companies/weberpdemo/FormDesigns/ trunk/companies/weberpdemo/FormDesigns/GoodsReceived.xml trunk/companies/weberpdemo/FormDesigns/PickingList.xml trunk/companies/weberpdemo/FormDesigns/PurchaseOrder.xml trunk/companies/weberpdemo/FormDesigns/SalesInvoice.xml trunk/companies/weberpdemo/logo.jpg trunk/companies/weberpdemo/logo.png trunk/companies/weberpdemo/logo1.jpg trunk/companies/weberpdemo/logo2.jpg trunk/companies/weberpdemo/logo4.jpg trunk/companies/weberpdemo/logo5.jpg trunk/companies/weberpdemo/logo6.jpg trunk/companies/weberpdemo/logo7.jpg trunk/companies/weberpdemo/part_pics/ trunk/companies/weberpdemo/part_pics/HON90021.jpg trunk/companies/weberpdemo/part_pics/HON90022.jpg trunk/companies/weberpdemo/part_pics/PHIS01.jpg trunk/companies/weberpdemo/part_pics/webERPsmall.png trunk/companies/weberpdemo/pdf_append/ trunk/companies/weberpdemo/reports/ trunk/companies/weberpdemo/reportwriter/ trunk/companies/weberpdemo/reportwriter/labels.xml trunk/includes/DefineTenderClass.php trunk/sql/mysql/updates/67.php trunk/sql/mysql/updates/68.php trunk/sql/mysql/updates/69.php trunk/sql/mysql/updates/70.php trunk/sql/mysql/updates/71.php trunk/sql/mysql/updates/72.php Removed Paths: ------------- trunk/companies/weberpdemo/ trunk/sql/mysql/updates/67.php Added: trunk/Manufacturers.php =================================================================== --- trunk/Manufacturers.php (rev 0) +++ trunk/Manufacturers.php 2011-03-22 20:18:49 UTC (rev 4803) @@ -0,0 +1,297 @@ +<?php + +//$PageSecurity = 5; + +include('includes/session.inc'); + +$title = _('Manufacturing Company Maintenance'); + +include('includes/header.inc'); + +if (isset($_GET['ManufacturerID'])){ + $ManufacturerID = strtoupper($_GET['ManufacturerID']); + $_POST['amend']=True; +} elseif (isset($_POST['ManufacturerID'])){ + $ManufacturerID = strtoupper($_POST['ManufacturerID']); +} else { + unset($ManufacturerID); +} + +if (isset($_POST['Create'])) { + $ManufacturerID = 0; + $_POST['New'] = "Yes"; +}; + +echo '<div class="centre"><p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' + . _('Manufacturing Companies') . '" alt="" />' . ' ' .$title . '</p></div>'; + +/* This section has been reached because the user has pressed either the insert/update buttons on the + form hopefully with input in the correct fields, which we check for firsrt. */ + +//initialise no input errors assumed initially before we test +$InputError = 0; + +if (isset($_POST['submit']) or isset($_POST['update']) or isset($_POST['delete'])) { + + if (strlen($_POST['ManufacturerName']) > 40 or strlen($_POST['ManufacturerName']) == 0 or $_POST['ManufacturerName'] == '') { + $InputError = 1; + prnMsg(_('The manufacturing company name must be entered and be forty characters or less long'),'error'); + } + + // But if errors were found in the input + if ($InputError>0) { + prnMsg(_('Validation failed') . _('no updates or deletes took place'),'warn'); + include('includes/footer.inc'); + exit; + } + + /* If no input errors have been recieved */ + if ($InputError == 0 and isset($_POST['submit'])){ + //And if its not a new part then update existing one + + $sql = "INSERT INTO manufacturers (id, + coyname, + address1, + address2, + address3, + address4, + address5, + address6, + contact, + telephone, + fax, + email) + VALUES (null, + '" .$_POST['ManufacturerName'] . "', + '" . $_POST['Address1'] . "', + '" . $_POST['Address2'] . "', + '" . $_POST['Address3'] . "', + '" . $_POST['Address4'] . "', + '" . $_POST['Address5'] . "', + '" . $_POST['Address6'] . "', + '" . $_POST['ContactName'] . "', + '" . $_POST['Telephone'] . "', + '" . $_POST['Fax'] . "', + '" . $_POST['Email'] . "')"; + + $ErrMsg = _('The manufacturing company') . ' ' . $_POST['ManufacturerName'] . ' ' . _('could not be added because'); + $DbgMsg = _('The SQL that was used to insert the manufacturer but failed was'); + + $result = DB_query($sql, $db, $ErrMsg, $DbgMsg); + + prnMsg(_('A new manufacturing company for') . ' ' . $_POST['ManufacturerName'] . ' ' . _('has been added to the database'),'success'); + + unset ($ManufacturerID); + unset($_POST['ManufacturerName']); + unset($_POST['Address1']); + unset($_POST['Address2']); + unset($_POST['Address3']); + unset($_POST['Address4']); + unset($_POST['Address5']); + unset($_POST['Address6']); + unset($_POST['ContactName']); + unset($_POST['Telephone']); + unset($_POST['Fax']); + unset($_POST['Email']); + + } + + if ($InputError == 0 and isset($_POST['update'])) { + $sql = "UPDATE manufacturers SET coyname='" . $_POST['ManufacturerName'] . "', + address1='" . $_POST['Address1'] . "', + address2='" . $_POST['Address2'] . "', + address3='" . $_POST['Address3'] . "', + address4='" . $_POST['Address4'] . "', + address5='" . $_POST['Address5'] . "', + address6='" . $_POST['Address6'] . "', + contact='" . $_POST['ContactName'] . "', + telephone='" . $_POST['Telephone'] . "', + fax='" . $_POST['Fax'] . "', + email='" . $_POST['Email'] . "' + WHERE id = '" .$ManufacturerID."'"; + + $ErrMsg = _('The manufacturing company could not be updated because'); + $DbgMsg = _('The SQL that was used to update the manufacturer but failed was'); + $result = DB_query($sql, $db, $ErrMsg, $DbgMsg); + + prnMsg(_('The manufacturing company record for') . ' ' . $_POST['ManufacturerName'] . ' ' . _('has been updated'),'success'); + + //If it is a new part then insert it + } + + /* If neither the Update or Insert buttons were pushed was it the delete button? */ + + if (isset($_POST['delete'])) { + + $CancelDelete = 0; + + // PREVENT DELETES IF DEPENDENT RECORDS IN 'SuppTrans' , PurchOrders, SupplierContacts + + $sql= "SELECT COUNT(*) FROM suppliers WHERE manufacturerid='".$ManufacturerID."'"; + $result = DB_query($sql, $db); + $myrow = DB_fetch_row($result); + if ($myrow[0] > 0) { + $CancelDelete = 1; + prnMsg(_('Cannot delete this manufacturer because there are suppliers using them'),'warn'); + echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('suppliers using this manufacturer'); + } + + if ($CancelDelete == 0) { + $sql="DELETE FROM manufacturers WHERE id='".$ManufacturerID."'"; + $result = DB_query($sql, $db); + prnMsg(_('Manufacturing company record record for') . ' ' . $_POST['ManufacturerName'] . ' ' . _('has been deleted'),'success'); + echo '<br>'; + unset($_SESSION['ManufacturerID']); + } //end if Delete + } + unset($ManufacturerID); +} +/* So the page hasn't called itself with the input/update/delete/buttons */ + +/* If it didn't come with a $ManufacturerID it must be a completely fresh start, so choose a new $ManufacturerID or give the + option to create a new one*/ + +if (!isset($ManufacturerID)) { + + echo "<form method='post' action='" . $_SERVER['PHP_SELF'] . "?" . SID . "'>"; + echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + + echo "<input type='hidden' name='New' VALUE='No'>"; + echo '<table class=selection><tr>'; + echo '<th>' . _('ID') . '</th>'; + echo '<th>' . _('Company Name').'</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>' . _('Contact').'</th>'; + echo '<th>' . _('Telephone').'</th>'; + echo '<th>' . _('Fax Number').'</th>'; + echo '<th>' . _('Email').'</th></tr>'; + $sql = "SELECT id, + coyname, + address1, + address2, + address3, + address4, + address5, + address6, + contact, + telephone, + fax, + email + FROM manufacturers"; + $result=DB_query($sql, $db); + $j=1; + while ($myrow = DB_fetch_array($result)) { + if ($j==1) { + echo '<tr class="OddTableRows">'; + $j=0; + } else { + echo '<tr class="EvenTableRows">'; + $j++; + } + echo '<td>' . $myrow['id'] . '</td>'; + echo '<td>' . $myrow['coyname'].'</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['contact'].'</td>'; + echo '<td>' . $myrow['telephone'].'</td>'; + echo '<td>' . $myrow['fax'].'</td>'; + echo '<td>' . $myrow['email'].'</td>'; + echo '<td><a href="'.$rootpath . '/Manufacturers.php?' . SID . '&ManufacturerID='.$myrow['id'].'">'._('Edit').'</a></td></tr>'; + } + echo "</table><p><div class='centre'>"; + echo "<br><input tabindex=3 type='Submit' name='Create' value='" . _('Create New Manufacturer') . "'>"; + echo '</div></form>'; + include('includes/footer.inc'); + exit; + +} + +if (isset($ManufacturerID) and isset($_POST['amend'])) { + + $sql = "SELECT id, + coyname, + address1, + address2, + address3, + address4, + address5, + address6, + contact, + telephone, + fax, + email + FROM manufacturers + WHERE id = '".$ManufacturerID."'"; + + $result = DB_query($sql, $db); + $myrow = DB_fetch_array($result); + + $_POST['ManufacturerName'] = $myrow['coyname']; + $_POST['Address1'] = $myrow['address1']; + $_POST['Address2'] = $myrow['address2']; + $_POST['Address3'] = $myrow['address3']; + $_POST['Address4'] = $myrow['address4']; + $_POST['Address5'] = $myrow['address5']; + $_POST['Address6'] = $myrow['address6']; + $_POST['ContactName'] = $myrow['contact']; + $_POST['Telephone'] = $myrow['telephone']; + $_POST['Fax'] = $myrow['fax']; + $_POST['Email'] = $myrow['email']; + +} else { + $_POST['ManufacturerName'] = ''; + $_POST['Address1'] = ''; + $_POST['Address2'] = ''; + $_POST['Address3'] = ''; + $_POST['Address4'] = ''; + $_POST['Address5'] = ''; + $_POST['Address6'] = ''; + $_POST['ContactName'] = ''; + $_POST['Telephone'] = ''; + $_POST['Fax'] = ''; + $_POST['Email'] = ''; +} + +if (isset($_POST['amend']) or isset($_POST['Create'])) { + // its a new manufacturer being added + + echo "<form method='post' action='" . $_SERVER['PHP_SELF'] . "?" . SID . "'>"; + echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + echo "<input type=hidden name='ManufacturerID' value='".$ManufacturerID."'>"; + echo '<table class=selection>'; + echo "<input type=hidden name='New' value='Yes'>"; + echo '<tr><td>' . _('Manufacturer Name') . ":</td><td><input tabindex=1 type='text' name='ManufacturerName' size=42 maxlength=40 value='".$_POST['ManufacturerName']."'></td></tr>"; + echo '<tr><td>' . _('Address Line 1') . ":</td><td><input tabindex=2 type='text' name='Address1' size=42 maxlength=40 value='".$_POST['Address1']."'></td></tr>"; + echo '<tr><td>' . _('Address Line 2') . ":</td><td><input tabindex=3 type='text' name='Address2' size=42 maxlength=40 value='".$_POST['Address2']."'></td></tr>"; + echo '<tr><td>' . _('Address Line 3') . ":</td><td><input tabindex=4 type='text' name='Address3' size=42 maxlength=40 value='".$_POST['Address3']."'></td></tr>"; + echo '<tr><td>' . _('Address Line 4') . ":</td><td><input tabindex=5 type='text' name='Address4' size=42 maxlength=40 value='".$_POST['Address4']."'></td></tr>"; + echo '<tr><td>' . _('Address Line 5') . ":</td><td><input tabindex=6 type='text' name='Address5' size=42 maxlength=40 value='".$_POST['Address5']."'></td></tr>"; + echo '<tr><td>' . _('Address Line 6') . ":</td><td><input tabindex=7 type='text' name='Address6' size=42 maxlength=40 value='".$_POST['Address6']."'></td></tr>"; + echo '<tr><td>' . _('Contact Name') . ":</td><td><input tabindex=8 type='text' name='ContactName' size=13 maxlength=25 value='".$_POST['ContactName']."'></td></tr>"; + echo '<tr><td>' . _('Telephone') . ":</td><td><input tabindex=9 type='text' name='Telephone' size=13 maxlength=25 value='".$_POST['Telephone']."'></td></tr>"; + echo '<tr><td>' . _('Fax') . ":</td><td><input tabindex=10 type='text' name='Fax' VALUE=0 size=13 maxlength=25 value='".$_POST['Fax']."'></td></tr>"; + echo '<tr><td>' . _('Email') . ":</td><td><input tabindex=11 type='text' name='Email' size=55 maxlength=55 value='".$_POST['Email']."'></td></tr>"; + echo '</form>'; +} + + +if (isset($_POST['Create'])) { + echo "</table><p><div class='centre'><input tabindex=12 type='Submit' name='submit' VALUE='" . _('Insert New Manufacturer') . "'></div>"; +} else if (isset($_POST['amend'])) { + echo "</table><p><div class='centre'><input tabindex=13 type='Submit' name='update' VALUE='" . _('Update Manufacturer') . "'><p>"; + prnMsg ( _('There is no second warning if you hit the delete button below') . '. ' . _('However checks will be made to ensure there are no suppliers are using this manufacturer before the deletion is processed'), 'warn'); + echo "<p><input tabindex=14 type='Submit' name='delete' VALUE='" . _('Delete Manufacturer') . "' onclick=\"return confirm('" . _('Are you sure you wish to delete this manufacturer?') . "');\"></form></div>"; +} + + +include('includes/footer.inc'); +?> \ No newline at end of file Modified: trunk/PO_Header.php =================================================================== --- trunk/PO_Header.php 2011-03-22 20:17:41 UTC (rev 4802) +++ trunk/PO_Header.php 2011-03-22 20:18:49 UTC (rev 4803) @@ -609,10 +609,10 @@ $sql="SELECT stockmaster.controlled, stockmaster.serialised, stockmaster.description, - stockmaster.units , + stockmaster.units as stockunits, stockmaster.decimalplaces, purchdata.price, - purchdata.suppliersuom, + unitsofmeasure.unitname as supplierunits, purchdata.suppliers_partno, purchdata.conversionfactor, stockcategory.stockact @@ -620,11 +620,17 @@ ON stockmaster.categoryid=stockcategory.categoryid LEFT JOIN purchdata ON stockmaster.stockid = purchdata.stockid + LEFT JOIN unitsofmeasure + ON purchdata.suppliersuom=unitsofmeasure.unitid WHERE stockmaster.stockid='".$Purch_Item. "' AND purchdata.supplierno ='" . $_GET['SelectedSupplier'] . "'"; $result=DB_query($sql, $db); $PurchItemRow=DB_fetch_array($result); - + if ($PurchItemRow['supplierunits'] != '') { + $PurchItemRow['units'] = $PurchItemRow['supplierunits']; + } else { + $PurchItemRow['units'] = $PurchItemRow['stocksunits']; + } if (!isset($PurchItemRow['conversionfactor'])) { $PurchItemRow['conversionfactor']=1; } Modified: trunk/PO_Items.php =================================================================== --- trunk/PO_Items.php 2011-03-22 20:17:41 UTC (rev 4802) +++ trunk/PO_Items.php 2011-03-22 20:18:49 UTC (rev 4803) @@ -41,6 +41,7 @@ purchdata.suppliers_partno, purchdata.conversionfactor, purchdata.suppliersuom, + purchdata.minorderqty, stockmaster.pkg_type, stockmaster.units, stockmaster.netweight, @@ -65,6 +66,7 @@ $_POST['nw'] = $myrow['netweight']; $_POST['gw'] = $myrow['kgs']; $_POST['CuFt'] = $myrow['volume']; + $_POST['MinimumOrderQty'] = $myrow['minorderqty']; } // end if (isset($_POST['StockID2']) && $_GET['Edit']=='') if (isset($_POST['UpdateLines']) OR isset($_POST['Commit'])) { @@ -131,8 +133,8 @@ suppdeladdress4, suppdeladdress5, suppdeladdress6, + supptel, contact, - supptel, version, revised, deliveryby, @@ -165,7 +167,7 @@ '" . $_SESSION['PO'.$identifier]->Contact . "', '" . $_SESSION['PO'.$identifier]->Version . "', '" . Date('Y-m-d') . "', - '" . $_SESSION['PO'.$identifier]->DeliveryBy . "', + '" . FormatDateForSQL($_SESSION['PO'.$identifier]->DeliveryBy) . "', 'Pending', '" . $StatusComment . "', '" . FormatDateForSQL($_SESSION['PO'.$identifier]->DeliveryDate) . "', @@ -532,7 +534,8 @@ if (isset($_POST['LookupPrice']) and isset($_POST['StockID2'])){ $sql = "SELECT purchdata.price, purchdata.conversionfactor, - purchdata.supplierdescription + purchdata.supplierdescription, + purchdata.minorderqty FROM purchdata WHERE purchdata.supplierno = '" . $_SESSION['PO'.$identifier]->SupplierID . "' AND purchdata.stockid = '". strtoupper($_POST['StockID2']) . "'"; @@ -545,6 +548,7 @@ $myrow = DB_fetch_array($LookupResult); $_POST['Price'] = $myrow['price']/$myrow['conversionfactor']; $_POST['ConversionFactor'] = $myrow['conversionfactor']; + $_POST['MinimumOrderQty'] = $myrow['minorderqty']; } else { prnMsg(_('Sorry') . ' ... ' . _('there is no purchasing data set up for this supplier') . ' - ' . $_SESSION['PO'.$identifier]->SupplierID . ' ' . _('and item') . ' ' . strtoupper($_POST['StockID']),'warn'); } @@ -776,6 +780,7 @@ purchdata.suppliersuom, unitsofmeasure.unitname, purchdata.suppliers_partno, + purchdata.minorderqty, purchdata.leadtime FROM stockcategory, chartmaster, @@ -783,8 +788,8 @@ ON stockmaster.stockid = purchdata.stockid LEFT JOIN unitsofmeasure ON purchdata.suppliersuom=unitsofmeasure.unitid + WHERE chartmaster.accountcode = stockcategory.stockact AND purchdata.supplierno = '" . $_SESSION['PO'.$identifier]->SupplierID . "' - WHERE chartmaster.accountcode = stockcategory.stockact AND stockcategory.categoryid = stockmaster.categoryid AND stockmaster.stockid = '". $ItemCode . "' AND purchdata.effectivefrom = @@ -814,8 +819,15 @@ $result1 = DB_query($sql,$db,$ErrMsg,$DbgMsg); if ($myrow = DB_fetch_array($result1)){ + if (isset($myrow['price']) and is_numeric($myrow['price'])){ - + if ($Quantity < $myrow['minorderqty']) { + prnMsg( _('The quantity ordered is less than the minimum order quantity for this supplier.') . + '<br />' . _('Are you sure you wish to continue?'), 'warn'); + } else if ($Quantity % $myrow['minorderqty']) { + prnMsg( _('The quantity ordered should be a multiple of the minimum order quantity for this supplier.') . + '<br />' . _('Are you sure you wish to continue?'), 'warn'); + } $_SESSION['PO'.$identifier]->add_to_order ($_SESSION['PO'.$identifier]->LinesOnOrder+1, $ItemCode, 0, /*Serialised */ Modified: trunk/SelectProduct.php =================================================================== --- trunk/SelectProduct.php 2011-03-22 20:17:41 UTC (rev 4802) +++ trunk/SelectProduct.php 2011-03-22 20:18:49 UTC (rev 4803) @@ -175,6 +175,17 @@ echo '</table>'; //end of first nested table // Item Category Property mod: display the item properties echo '<table align="left">'; + if (isset($_POST['UpdateProps'])) { + $PropertyCounter=0; + while (isset($_POST['PropValue' . $PropertyCounter])) { + $UpdateSql="UPDATE stockitemproperties + SET value='".$_POST['PropValue' . $PropertyCounter] . "' + WHERE stockid='" . $StockID . "' + AND stkcatpropid ='" . $_POST['CatPropID']."'"; + $UpdateResult=DB_query($UpdateSql, $db);; + $PropertyCounter++; + } + } $CatValResult = DB_query("SELECT categoryid FROM stockmaster WHERE stockid='" . $StockID . "'", $db); @@ -198,53 +209,67 @@ AND stkcatpropid ='" . $PropertyRow['stkcatpropid']."'", $db); $PropValRow = DB_fetch_row($PropValResult); $PropertyValue = $PropValRow[0]; + echo '<form name="CatPropForm" enctype="multipart/form-data" method="post" action="' . $_SERVER['PHP_SELF'] . '?' .SID .'">'; + echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<tr><th align="right">' . $PropertyRow['label'] . ':</th>'; switch ($PropertyRow['controltype']) { case 0; //textbox - echo '<td class="select" width="60"><input type="text" name="PropValue' . $PropertyCounter . '" value="' . $PropertyValue . '" />'; - break; - case 1; //select box - $OptionValues = explode(',', $PropertyRow['defaultvalue']); - echo '<td align="left" width="60"><select name="PropValue' . $PropertyCounter . '">'; - foreach($OptionValues as $PropertyOptionValue) { - if ($PropertyOptionValue == $PropertyValue) { - echo '<option selected="True" value="' . $PropertyOptionValue . '">' . $PropertyOptionValue . '</option>'; - } else { - echo '<option value="' . $PropertyOptionValue . '">' . $PropertyOptionValue . '</option>'; - } - } - echo '</select>'; - break; - case 2; //checkbox - echo '<td align="left" width="60"><input type="checkbox" name="PropValue' . $PropertyCounter . '"'; - if ($PropertyValue == 1) { - echo ' checked'; - } - echo ' />'; -break; -} //end switch -echo '</td></tr>'; -$PropertyCounter++; -} //end loop round properties for the item category -echo '</table>'; //end of Item Category Property mod -echo '<td style="width: 15%; vertical-align: top"> + echo '<td class="select" width="60"><input type="text" name="PropValue' . $PropertyCounter . '" value="' . $PropertyValue . '" />'; + break; + case 1; //select box + $OptionValues = array(); + if ($PropertyRow['label']='Manufacturers') { + $sql="SELECT coyname from manufacturers"; + $ManufacturerResult=DB_query($sql, $db); + while ($ManufacturerRow=DB_fetch_array($ManufacturerResult)) { + $OptionValues[]=$ManufacturerRow['coyname']; + } + } else { + $OptionValues = explode(',',$PropertyRow['defaultvalue']); + } + echo '<input type="hidden" name="CatPropID" value="'.$PropertyRow['stkcatpropid'].'" />'; + echo '<td align="left" width="60"><select name="PropValue' . $PropertyCounter . '" onChange="ReloadForm(UpdateProps)" >'; + foreach ($OptionValues as $PropertyOptionValue){ + if ($PropertyOptionValue == $PropertyValue){ + echo '<option selected value="' . $PropertyOptionValue . '">' . $PropertyOptionValue . '</option>'; + } else { + echo '<option value="' . $PropertyOptionValue . '">' . $PropertyOptionValue . '</option>'; + } + } + echo '</select>'; + break; + case 2; //checkbox + echo '<td align="left" width="60"><input type="checkbox" name="PropValue' . $PropertyCounter . '"'; + if ($PropertyValue == 1) { + echo ' checked'; + } + echo ' />'; + break; + } //end switch + echo '</td></tr>'; + $PropertyCounter++; + } //end loop round properties for the item category + echo '<input type="submit" name="UpdateProps" style="visibility:hidden;width:1px" value="' . _('Categories') . '">'; + echo '</form>'; + echo '</table>'; //end of Item Category Property mod + echo '<td style="width: 15%; vertical-align: top"> <table>'; //nested table to show QOH/orders -$QOH = 0; -switch ($myrow['mbflag']) { - case 'A': - case 'D': - case 'K': - $QOH = _('N/A'); - $QOO = _('N/A'); - break; - case 'M': - case 'B': - $QOHResult = DB_query("SELECT sum(quantity) + $QOH = 0; + switch ($myrow['mbflag']) { + case 'A': + case 'D': + case 'K': + $QOH = _('N/A'); + $QOO = _('N/A'); + break; + case 'M': + case 'B': + $QOHResult = DB_query("SELECT sum(quantity) FROM locstock WHERE stockid = '" . $StockID . "'", $db); - $QOHRow = DB_fetch_row($QOHResult); - $QOH = number_format($QOHRow[0], $myrow['decimalplaces']); - $QOOSQL="SELECT SUM((purchorderdetails.quantityord*purchorderdetails.conversionfactor) - + $QOHRow = DB_fetch_row($QOHResult); + $QOH = number_format($QOHRow[0], $myrow['decimalplaces']); + $QOOSQL="SELECT SUM((purchorderdetails.quantityord*purchorderdetails.conversionfactor) - (purchorderdetails.quantityrecd*purchorderdetails.conversionfactor)) FROM purchorders LEFT JOIN purchorderdetails @@ -254,38 +279,38 @@ AND purchorders.status<>'Cancelled' AND purchorders.status<>'Pending' AND purchorders.status<>'Rejected'"; - $QOOResult = DB_query($QOOSQL, $db); - if (DB_num_rows($QOOResult) == 0) { - $QOO = 0; - } else { - $QOORow = DB_fetch_row($QOOResult); - $QOO = $QOORow[0]; - } - //Also the on work order quantities - $sql = "SELECT SUM(woitems.qtyreqd-woitems.qtyrecd) AS qtywo + $QOOResult = DB_query($QOOSQL, $db); + if (DB_num_rows($QOOResult) == 0) { + $QOO = 0; + } else { + $QOORow = DB_fetch_row($QOOResult); + $QOO = $QOORow[0]; + } + //Also the on work order quantities + $sql = "SELECT SUM(woitems.qtyreqd-woitems.qtyrecd) AS qtywo FROM woitems INNER JOIN workorders ON woitems.wo=workorders.wo WHERE workorders.closed=0 AND woitems.stockid='" . $StockID . "'"; - $ErrMsg = _('The quantity on work orders for this product cannot be retrieved because'); - $QOOResult = DB_query($sql, $db, $ErrMsg); - if (DB_num_rows($QOOResult) == 1) { - $QOORow = DB_fetch_row($QOOResult); - $QOO+= $QOORow[0]; - } - $QOO = number_format($QOO, $myrow['decimalplaces']); - break; -} -$Demand = 0; -$DemResult = DB_query("SELECT SUM(salesorderdetails.quantity-salesorderdetails.qtyinvoiced) AS dem + $ErrMsg = _('The quantity on work orders for this product cannot be retrieved because'); + $QOOResult = DB_query($sql, $db, $ErrMsg); + if (DB_num_rows($QOOResult) == 1) { + $QOORow = DB_fetch_row($QOOResult); + $QOO+= $QOORow[0]; + } + $QOO = number_format($QOO, $myrow['decimalplaces']); + break; + } + $Demand = 0; + $DemResult = DB_query("SELECT SUM(salesorderdetails.quantity-salesorderdetails.qtyinvoiced) AS dem FROM salesorderdetails INNER JOIN salesorders ON salesorders.orderno = salesorderdetails.orderno WHERE salesorderdetails.completed=0 AND salesorders.quotation=0 AND salesorderdetails.stkcode='" . $StockID . "'", $db); -$DemRow = DB_fetch_row($DemResult); -$Demand = $DemRow[0]; -$DemAsComponentResult = DB_query("SELECT SUM((salesorderdetails.quantity-salesorderdetails.qtyinvoiced)*bom.quantity) AS dem + $DemRow = DB_fetch_row($DemResult); + $Demand = $DemRow[0]; + $DemAsComponentResult = DB_query("SELECT SUM((salesorderdetails.quantity-salesorderdetails.qtyinvoiced)*bom.quantity) AS dem FROM salesorderdetails, salesorders, bom, @@ -297,10 +322,10 @@ AND stockmaster.stockid=bom.parent AND stockmaster.mbflag='A' AND salesorders.quotation=0", $db); -$DemAsComponentRow = DB_fetch_row($DemAsComponentResult); -$Demand+= $DemAsComponentRow[0]; -//Also the demand for the item as a component of works orders -$sql = "SELECT SUM(qtypu*(woitems.qtyreqd - woitems.qtyrecd)) AS woqtydemo + $DemAsComponentRow = DB_fetch_row($DemAsComponentResult); + $Demand+= $DemAsComponentRow[0]; + //Also the demand for the item as a component of works orders + $sql = "SELECT SUM(qtypu*(woitems.qtyreqd - woitems.qtyrecd)) AS woqtydemo FROM woitems INNER JOIN worequirements ON woitems.stockid=worequirements.parentstockid INNER JOIN workorders @@ -308,19 +333,19 @@ AND woitems.wo=worequirements.wo WHERE worequirements.stockid='" . $StockID . "' AND workorders.closed=0"; -$ErrMsg = _('The workorder component demand for this product cannot be retrieved because'); -$DemandResult = DB_query($sql, $db, $ErrMsg); -if (DB_num_rows($DemandResult) == 1) { - $DemandRow = DB_fetch_row($DemandResult); - $Demand+= $DemandRow[0]; -} -echo '<tr><th class="number" width="15%">' . _('Quantity On Hand') . ':</th><td width="17%" class="select">' . $QOH . '</td></tr>'; -echo '<tr><th class="number" width="15%">' . _('Quantity Demand') . ':</th><td width="17%" class="select">' . number_format($Demand, $myrow['decimalplaces']) . '</td></tr>'; -echo '<tr><th class="number" width="15%">' . _('Quantity On Order') . ':</th><td width="17%" class="select">' . $QOO . '</td></tr> + $ErrMsg = _('The workorder component demand for this product cannot be retrieved because'); + $DemandResult = DB_query($sql, $db, $ErrMsg); + if (DB_num_rows($DemandResult) == 1) { + $DemandRow = DB_fetch_row($DemandResult); + $Demand+= $DemandRow[0]; + } + echo '<tr><th class="number" width="15%">' . _('Quantity On Hand') . ':</th><td width="17%" class="select">' . $QOH . '</td></tr>'; + echo '<tr><th class="number" width="15%">' . _('Quantity Demand') . ':</th><td width="17%" class="select">' . number_format($Demand, $myrow['decimalplaces']) . '</td></tr>'; + echo '<tr><th class="number" width="15%">' . _('Quantity On Order') . ':</th><td width="17%" class="select">' . $QOO . '</td></tr> </table>'; //end of nested table -echo '</td>'; //end cell of master table -if ($myrow['mbflag'] == 'B' or ($myrow['mbflag'] == 'M')) { - echo '<td width="50%" valign="top"><table> + echo '</td>'; //end cell of master table + if ($myrow['mbflag'] == 'B' or ($myrow['mbflag'] == 'M')) { + echo '<td width="50%" valign="top"><table> <tr><th width="50%">' . _('Supplier') . '</th> <th width="15%">' . _('Cost') . '</th> <th width="5%">' . _('Curr') . '</th> @@ -328,7 +353,7 @@ <th width="10%">' . _('Lead Time') . '</th> <th width="10%">' . _('Min Order Qty') . '</th> <th width="5%">' . _('Prefer') . '</th></tr>'; - $SuppResult = DB_query("SELECT suppliers.suppname, + $SuppResult = DB_query("SELECT suppliers.suppname, suppliers.currcode, suppliers.supplierid, purchdata.price, @@ -341,100 +366,100 @@ ON purchdata.supplierno=suppliers.supplierid WHERE purchdata.stockid = '" . $StockID . "' ORDER BY purchdata.preferred DESC, purchdata.effectivefrom DESC", $db); - while ($SuppRow = DB_fetch_array($SuppResult)) { - echo '<tr><td class="select">' . $SuppRow['suppname'] . '</td> + while ($SuppRow = DB_fetch_array($SuppResult)) { + echo '<tr><td class="select">' . $SuppRow['suppname'] . '</td> <td class="select">' . number_format($SuppRow['price'] / $SuppRow['conversionfactor'], 2) . '</td> <td class="select">' . $SuppRow['currcode'] . '</td> <td class="select">' . ConvertSQLDate($SuppRow['effectivefrom']) . '</td> <td class="select">' . $SuppRow['leadtime'] . '</td> <td class="select">' . $SuppRow['minorderqty'] . '</td>'; - if ($SuppRow['preferred']==1) { //then this is the preferred supplier - echo '<td class="select">' . _('Yes') . '</td>'; - } else { - echo '<td class="select">' . _('No') . '</td>'; + if ($SuppRow['preferred']==1) { //then this is the preferred supplier + echo '<td class="select">' . _('Yes') . '</td>'; + } else { + echo '<td class="select">' . _('No') . '</td>'; + } + echo '<td class="select"><a href="' . $rootpath . '/PO_Header.php?' . SID . '&NewOrder=Yes' . '&SelectedSupplier=' . + $SuppRow['supplierid'] . '&StockID=' . $StockID . '&Quantity='.$SuppRow['minorderqty'].'">' . _('Order') . ' </a></td>'; + echo '</tr>'; } - echo '<td class="select"><a href="' . $rootpath . '/PO_Header.php?' . SID . '&NewOrder=Yes' . '&SelectedSupplier=' . - $SuppRow['supplierid'] . '&StockID=' . $StockID . '&Quantity='.$SuppRow['minorderqty'].'">' . _('Order') . ' </a></td>'; - echo '</tr>'; + echo '</table></td>'; + DB_data_seek($result, 0); } - echo '</table></td>'; - DB_data_seek($result, 0); -} -echo '</td></tr></table><br />'; // end first item details table -echo '<table width="90%"><tr> + echo '</td></tr></table><br />'; // end first item details table + echo '<table width="90%"><tr> <th width="33%">' . _('Item Inquiries') . '</th> <th width="33%">' . _('Item Transactions') . '</th> <th width="33%">' . _('Item Maintenance') . '</th> </tr>'; -echo '<tr><td valign="top" class="select">'; -/*Stock Inquiry Options */ -echo '<a href="' . $rootpath . '/StockMovements.php?' . SID . '&StockID=' . $StockID . '">' . _('Show Stock Movements') . '</a><br />'; -if ($Its_A_Kitset_Assembly_Or_Dummy == False) { - echo '<a href="' . $rootpath . '/StockStatus.php?' . SID . '&StockID=' . $StockID . '">' . _('Show Stock Status') . '</a><br />'; - echo '<a href="' . $rootpath . '/StockUsage.php?' . SID . '&StockID=' . $StockID . '">' . _('Show Stock Usage') . '</a><br />'; -} -echo '<a href="' . $rootpath . '/SelectSalesOrder.php?' . SID . '&SelectedStockItem=' . $StockID . '">' . _('Search Outstanding Sales Orders') . '</a><br />'; -echo '<a href="' . $rootpath . '/SelectCompletedOrder.php?' . SID . '&SelectedStockItem=' . $StockID . '">' . _('Search Completed Sales Orders') . '</a><br />'; -if ($Its_A_Kitset_Assembly_Or_Dummy == False) { - echo '<a href="' . $rootpath . '/PO_SelectOSPurchOrder.php?' . SID . '&SelectedStockItem=' . $StockID . '">' . _('Search Outstanding Purchase Orders') . '</a><br />'; - echo '<a href="' . $rootpath . '/PO_SelectPurchOrder.php?' . SID . '&SelectedStockItem=' . $StockID . '">' . _('Search All Purchase Orders') . '</a><br />'; - echo '<a href="' . $rootpath . '/' . $_SESSION['part_pics_dir'] . '/' . $StockID . '.jpg?' . SID . '">' . _('Show Part Picture (if available)') . '</a><br />'; -} -if ($Its_A_Dummy == False) { - echo '<a href="' . $rootpath . '/BOMInquiry.php?' . SID . '&StockID=' . $StockID . '">' . _('View Costed Bill Of Material') . '</a><br />'; - echo '<a href="' . $rootpath . '/WhereUsedInquiry.php?' . SID . '&StockID=' . $StockID . '">' . _('Where This Item Is Used') . '</a><br />'; -} -if ($Its_A_Labour_Item == True) { - echo '<a href="' . $rootpath . '/WhereUsedInquiry.php?' . SID . '&StockID=' . $StockID . '">' . _('Where This Labour Item Is Used') . '</a><br />'; -} -wikiLink('Product', $StockID); -echo '</td><td valign="top" class="select">'; -/* Stock Transactions */ -if ($Its_A_Kitset_Assembly_Or_Dummy == False) { - echo '<a href="' . $rootpath . '/StockAdjustments.php?' . SID . '&StockID=' . $StockID . '">' . _('Quantity Adjustments') . '</a><br />'; - echo '<a href="' . $rootpath . '/StockTransfers.php?' . SID . '&StockID=' . $StockID . '">' . _('Location Transfers') . '</a><br />'; - if ($myrow['mbflag'] == 'B') { + echo '<tr><td valign="top" class="select">'; + /*Stock Inquiry Options */ + echo '<a href="' . $rootpath . '/StockMovements.php?' . SID . '&StockID=' . $StockID . '">' . _('Show Stock Movements') . '</a><br />'; + if ($Its_A_Kitset_Assembly_Or_Dummy == False) { + echo '<a href="' . $rootpath . '/StockStatus.php?' . SID . '&StockID=' . $StockID . '">' . _('Show Stock Status') . '</a><br />'; + echo '<a href="' . $rootpath . '/StockUsage.php?' . SID . '&StockID=' . $StockID . '">' . _('Show Stock Usage') . '</a><br />'; + } + echo '<a href="' . $rootpath . '/SelectSalesOrder.php?' . SID . '&SelectedStockItem=' . $StockID . '">' . _('Search Outstanding Sales Orders') . '</a><br />'; + echo '<a href="' . $rootpath . '/SelectCompletedOrder.php?' . SID . '&SelectedStockItem=' . $StockID . '">' . _('Search Completed Sales Orders') . '</a><br />'; + if ($Its_A_Kitset_Assembly_Or_Dummy == False) { + echo '<a href="' . $rootpath . '/PO_SelectOSPurchOrder.php?' . SID . '&SelectedStockItem=' . $StockID . '">' . _('Search Outstanding Purchase Orders') . '</a><br />'; + echo '<a href="' . $rootpath . '/PO_SelectPurchOrder.php?' . SID . '&SelectedStockItem=' . $StockID . '">' . _('Search All Purchase Orders') . '</a><br />'; + echo '<a href="' . $rootpath . '/' . $_SESSION['part_pics_dir'] . '/' . $StockID . '.jpg?' . SID . '">' . _('Show Part Picture (if available)') . '</a><br />'; + } + if ($Its_A_Dummy == False) { + echo '<a href="' . $rootpath . '/BOMInquiry.php?' . SID . '&StockID=' . $StockID . '">' . _('View Costed Bill Of Material') . '</a><br />'; + echo '<a href="' . $rootpath . '/WhereUsedInquiry.php?' . SID . '&StockID=' . $StockID . '">' . _('Where This Item Is Used') . '</a><br />'; + } + if ($Its_A_Labour_Item == True) { + echo '<a href="' . $rootpath . '/WhereUsedInquiry.php?' . SID . '&StockID=' . $StockID . '">' . _('Where This Labour Item Is Used') . '</a><br />'; + } + wikiLink('Product', $StockID); + echo '</td><td valign="top" class="select">'; + /* Stock Transactions */ + if ($Its_A_Kitset_Assembly_Or_Dummy == False) { + echo '<a href="' . $rootpath . '/StockAdjustments.php?' . SID . '&StockID=' . $StockID . '">' . _('Quantity Adjustments') . '</a><br />'; + echo '<a href="' . $rootpath . '/StockTransfers.php?' . SID . '&StockID=' . $StockID . '">' . _('Location Transfers') . '</a><br />'; + if ($myrow['mbflag'] == 'B') { echo '<br />'; - $SuppResult = DB_query("SELECT suppliers.suppname, + $SuppResult = DB_query("SELECT suppliers.suppname, suppliers.supplierid, purchdata.preferred, purchdata.minorderqty FROM purchdata INNER JOIN suppliers ON purchdata.supplierno=suppliers.supplierid WHERE purchdata.stockid = '" . $StockID . "'", $db); - while ($SuppRow = DB_fetch_array($SuppResult)) { - if ($myrow['eoq'] == 0) { - $EOQ = $SuppRow['minorderqty']; - } else { - $EOQ = $myrow['eoq']; - } - echo '<a href="' . $rootpath . '/PO_Header.php?' . SID . '&NewOrder=Yes' . '&SelectedSupplier=' . $SuppRow['supplierid'] . - '&StockID=' . $StockID . '&Quantity=' . $EOQ . '">' . _('Purchase this Item from') . ' ' . $SuppRow['suppname'] . ' (' . _('default') . ')</a><br />'; - /**/ - } /* end of while */ - } /* end of $myrow['mbflag'] == 'B' */ -} /* end of ($Its_A_Kitset_Assembly_Or_Dummy == False) */ -echo '</td><td valign="top" class="select">'; -/* Stock Maintenance Options */ -echo '<a href="' . $rootpath . '/Stocks.php?">' . _('Add Inventory Items') . '</a><br />'; -echo '<a href="' . $rootpath . '/Stocks.php?' . SID . '&StockID=' . $StockID . '">' . _('Modify Item Details') . '</a><br />'; -if ($Its_A_Kitset_Assembly_Or_Dummy == False) { - echo '<a href="' . $rootpath . '/StockReorderLevel.php?' . SID . '&StockID=' . $StockID . '">' . _('Maintain Reorder Levels') . '</a><br />'; - echo '<a href="' . $rootpath . '/StockCostUpdate.php?' . SID . '&StockID=' . $StockID . '">' . _('Maintain Standard Cost') . '</a><br />'; - echo '<a href="' . $rootpath . '/PurchData.php?' . SID . '&StockID=' . $StockID . '">' . _('Maintain Purchasing Data') . '</a><br />'; -} -if ($Its_A_Labour_Item == True) { - echo '<a href="' . $rootpath . '/StockCostUpdate.php?' . SID . '&StockID=' . $StockID . '">' . _('Maintain Standard Cost') . '</a><br />'; -} -if (!$Its_A_Kitset) { - echo '<a href="' . $rootpath . '/Prices.php?' . SID . '&Item=' . $StockID . '">' . _('Maintain Pricing') . '</a><br />'; - if (isset($_SESSION['CustomerID']) AND $_SESSION['CustomerID'] != "" AND Strlen($_SESSION['CustomerID']) > 0) { - echo '<a href="' . $rootpath . '/Prices_Customer.php?' . SID . '&Item=' . $StockID . '">' . _('Special Prices for customer') . ' - ' . $_SESSION['CustomerID'] . '</a><br />'; + while ($SuppRow = DB_fetch_array($SuppResult)) { + if ($myrow['eoq'] == 0) { + $EOQ = $SuppRow['minorderqty']; + } else { + $EOQ = $myrow['eoq']; + } + echo '<a href="' . $rootpath . '/PO_Header.php?' . SID . '&NewOrder=Yes' . '&SelectedSupplier=' . $SuppRow['supplierid'] . + '&StockID=' . $StockID . '&Quantity=' . $EOQ . '">' . _('Purchase this Item from') . ' ' . $SuppRow['suppname'] . ' (' . _('default') . ')</a><br />'; + /**/ + } /* end of while */ + } /* end of $myrow['mbflag'] == 'B' */ + } /* end of ($Its_A_Kitset_Assembly_Or_Dummy == False) */ + echo '</td><td valign="top" class="select">'; + /* Stock Maintenance Options */ + echo '<a href="' . $rootpath . '/Stocks.php?">' . _('Add Inventory Items') . '</a><br />'; + echo '<a href="' . $rootpath . '/Stocks.php?' . SID . '&StockID=' . $StockID . '">' . _('Modify Item Details') . '</a><br />'; + if ($Its_A_Kitset_Assembly_Or_Dummy == False) { + echo '<a href="' . $rootpath . '/StockReorderLevel.php?' . SID . '&StockID=' . $StockID . '">' . _('Maintain Reorder Levels') . '</a><br />'; + echo '<a href="' . $rootpath . '/StockCostUpdate.php?' . SID . '&StockID=' . $StockID . '">' . _('Maintain Standard Cost') . '</a><br />'; + echo '<a href="' . $rootpath . '/PurchData.php?' . SID . '&StockID=' . $StockID . '">' . _('Maintain Purchasing Data') . '</a><br />'; } - echo '<a href="' . $rootpath . '/DiscountCategories.php?' . SID . '&StockID=' . $StockID . '">' . _('Maintain Discount Category') . '</a><br />'; -} -echo '</td></tr></table>'; + if ($Its_A_Labour_Item == True) { + echo '<a href="' . $rootpath . '/StockCostUpdate.php?' . SID . '&StockID=' . $StockID . '">' . _('Maintain Standard Cost') . '</a><br />'; + } + if (!$Its_A_Kitset) { + echo '<a href="' . $rootpath . '/Prices.php?' . SID . '&Item=' . $StockID . '">' . _('Maintain Pricing') . '</a><br />'; + if (isset($_SESSION['CustomerID']) AND $_SESSION['CustomerID'] != "" AND Strlen($_SESSION['CustomerID']) > 0) { + echo '<a href="' . $rootpath . '/Prices_Customer.php?' . SID . '&Item=' . $StockID . '">' . _('Special Prices for customer') . ' - ' . $_SESSION['CustomerID'] . '</a><br />'; + } + echo '<a href="' . $rootpath . '/DiscountCategories.php?' . SID . '&StockID=' . $StockID . '">' . _('Maintain Discount Category') . '</a><br />'; + } + echo '</td></tr></table>'; } else { // options (links) to pages. This requires stock id also to be passed. echo '<table width="90%" colspan="2" cellpadding="4">'; Modified: trunk/Stocks.php =================================================================== --- trunk/Stocks.php 2011-03-22 20:17:41 UTC (rev 4802) +++ trunk/Stocks.php 2011-03-22 20:18:49 UTC (rev 4803) @@ -991,7 +991,16 @@ } break; case 1; //select box - $OptionValues = explode(',',$PropertyRow['defaultvalue']); + $OptionValues = array(); + if ($PropertyRow['label']='Manufacturers') { + $sql="SELECT coyname from manufacturers"; + $result=DB_query($sql, $db); + while ($myrow=DB_fetch_array($result)) { + $OptionValues[]=$myrow['coyname']; + } + } else { + $OptionValues = explode(',',$PropertyRow['defaultvalue']); + } echo '<select name="PropValue' . $PropertyCounter . '">'; foreach ($OptionValues as $PropertyOptionValue){ if ($PropertyOptionValue == $PropertyValue){ @@ -1018,7 +1027,7 @@ echo '</table><br>'; echo '<input type="hidden" name="PropertyCounter" value=' . $PropertyCounter . '>'; -if (isset($New)) { +if (true) { echo '<input type="Submit" name="submit" value="' . _('Insert New Item') . '">'; echo '<input type="submit" name="UpdateCategories" style="visibility:hidden;width:1px" value="' . _('Categories') . '">'; Added: trunk/SupplierTenderCreate.php =================================================================== --- trunk/SupplierTenderCreate.php (rev 0) +++ trunk/SupplierTenderCreate.php 2011-03-22 20:18:49 UTC (rev 4803) @@ -0,0 +1,803 @@ +<?php +/* $Id$*/ + +//$PageSecurity = 9; + +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']); +} + +$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'] . '?' . SID . '&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 (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 (substr($key,0,3)=='qty') { + $StockID=substr($key,3); + $Quantity=$value; + } + if (substr($key,0,5)=='price') { + $Price=$value; + } + if (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['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'] . '?' . SID . '" method=post>'; + echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + echo '<table class=selection>'; + echo '<tr><th colspan="4"><font size="3" color="navy">' . _('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 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="navy">' . _('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'] . "?" . SID . "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="navy">' . _('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">' . number_format($LineItems->Quantity,$LineItems->DecimalPlaces).'</td>'; + echo '<td>'.$LineItems->Units.'</td>'; + echo "<td><a href='" . $_SERVER['PHP_SELF'] . "?" . SID . "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 (strlen($_POST['Keywords']) > 0 AND 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 (strlen($_POST['Keywords']) > 0) { + $_POST['Keywords'] = 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 (strlen($_POST['SupplierCode']) > 0) { + $_POST['SupplierCode'] = 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 *... [truncated message content] |