From: <tim...@us...> - 2010-06-17 08:45:30
|
Revision: 3498 http://web-erp.svn.sourceforge.net/web-erp/?rev=3498&view=rev Author: tim_schofield Date: 2010-06-17 08:45:24 +0000 (Thu, 17 Jun 2010) Log Message: ----------- Tim: Enable a supplier to login and make an offer to the company Modified Paths: -------------- trunk/SystemParameters.php trunk/doc/Change.log.html trunk/includes/session.inc trunk/index.php trunk/sql/mysql/upgrade3.11.1-3.12.sql Added Paths: ----------- trunk/SupplierTenders.php trunk/includes/DefineOfferClass.php Added: trunk/SupplierTenders.php =================================================================== --- trunk/SupplierTenders.php (rev 0) +++ trunk/SupplierTenders.php 2010-06-17 08:45:24 UTC (rev 3498) @@ -0,0 +1,465 @@ +<?php +/* $Id$*/ + +$PageSecurity = 9; + +include('includes/DefineOfferClass.php'); +include('includes/session.inc'); +$title = _('Supplier Tendering'); +include('includes/header.inc'); + +$Maximum_Number_Of_Parts_To_Show=50; + +if (!isset($_POST['SupplierID'])) { + $sql='SELECT supplierid FROM www_users WHERE userid="'.$_SESSION['UserID'].'"'; + $result=DB_query($sql, $db); + $myrow=DB_fetch_array($result); + if ($myrow['supplierid']=='') { + prnMsg(_('This functionality can only be accessed via a supplier login.'), 'warning'); + include('includes/footer.inc'); + exit; + } else { + $_POST['SupplierID']=$myrow['supplierid']; + } +} + +if (isset($_GET['Delete'])) { + $_POST['SupplierID']=$_SESSION['offer']->SupplierID; + $_POST['TenderType']=$_GET['Type']; + $_SESSION['offer']->remove_from_offer($_GET['Delete']); +} + +$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 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. + */ +if (isset($_POST['SupplierID']) and empty($_POST['TenderType']) and empty($_POST['Search']) and empty($_POST['NewItem']) and empty($_GET['Delete'])) { + if (isset($_SESSION['offer'])) { + unset($_SESSION['offer']); + } + echo "<form method='post' action=" . $_SERVER['PHP_SELF'] . "?" . SID . ">"; + 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 '</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>'; +} + +if (isset($_POST['NewItem']) and !isset($_POST['Update'])) { + 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['offer']->add_to_offer( + $_SESSION['offer']->LinesOnOffer, + $StockID, + $Quantity, + $myrow['description'], + $Price, + $UOM, + $myrow['decimalplaces']); + unset($UOM); + } + } +} + +if (isset($_POST['Update']) and !isset($_POST['NewItem'])) { + foreach ($_POST as $key => $value) { + if (substr($key,0,3)=='qty') { + $LineNo=substr($key,3); + $Quantity=$value; + } + if (substr($key,0,5)=='price') { + $Price=$value; + } + if (isset($Price)) { + $_SESSION['offer']->update_offer_item( + $LineNo, + $Quantity, + $Price); + unset($Price); + } + } +} + +if (isset($_POST['Save'])) { + $MailText=''; + 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(DateAdd(date($_SESSION['DefaultDateFormat']),'m',3)).'", + "'.$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('tim...@go...'), 'smtp'); + echo 'x'.$result.'x'; + include('includes/footer.inc'); + exit; +} + +if (isset($_SESSION['offer']) and $_SESSION['offer']->LinesOnOffer>0 or isset($_POST['Update'])) { + echo "<form method='post' action=" . $_SERVER['PHP_SELF'] . "?" . SID . ">"; + echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/supplier.png" title="' . + _('Search') . '" alt="">' . ' ' . _('Items to offer from').' '.$Supplier; + echo '<table>'; + echo '<tr>'; + echo '<th>'._('Stock ID').'</th>'; + echo '<th>'._('Description').'</th>'; + echo '<th>'._('Quantity').'</th>'; + echo '<th>'._('UOM').'</th>'; + echo '<th>'._('Price').' ('.$Currency.')</th>'; + echo '<th>'._('Line Total').' ('.$Currency.')</th>'; + echo '</tr>'; + $k=0; + foreach ($_SESSION['offer']->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><input type=text class=number name="qty'.$LineItems->LineNo.'" value='.number_format($LineItems->Quantity,$LineItems->DecimalPlaces).'></td>'; + echo '<td>'.$LineItems->Units.'</td>'; + echo '<td><input type=text class=number name="price'.$LineItems->LineNo.'" value='.number_format($LineItems->Price,2,'.','').'></td>'; + echo '<td class=number>'.number_format($LineItems->Price*$LineItems->Quantity,2).'</td>'; + echo "<td><a href='" . $_SERVER['PHP_SELF'] . "?" . SID . "Delete=" . $LineItems->LineNo . "&Type=" . $_POST['TenderType'] . "'>" . _('Remove') . "</a></td></tr>"; + echo '</tr>'; + } + } + echo '</table>'; + echo '<input type=hidden name=TenderType value="'.$_POST['TenderType'].'">'; + echo '<br><div class="centre"><input type="submit" name="Update" value="Update offer">'; + echo '<input type="submit" name="Save" value="Save offer"></div>'; + echo '</form>'; +} + +/*The supplier has chosen option 1 + */ +if (isset($_POST['TenderType']) and $_POST['TenderType']==1) { +} + +/*The supplier has chosen option 2 + */ +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']; + } + echo '<form action="' . $_SERVER['PHP_SELF'] . '?' . SID . '" method=post>'; + echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . + _('Search') . '" alt="">' . ' ' . _('Search for Inventory Items'); + $sql = 'SELECT categoryid, + categorydescription + FROM stockcategory + 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>' . + _('There are no stock categories currently defined please use the link below to set them up'); + echo '<br><a href="' . $rootpath . '/StockCategories.php?' . SID . '">' . _('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 value="All">' . _('All'); + } else { + echo '<option value="All">' . _('All'); + } + while ($myrow1 = DB_fetch_array($result)) { + if ($myrow1['categoryid'] == $_POST['StockCat']) { + echo '<option selected VALUE="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription']; + } else { + echo '<option value="' . $myrow1['categoryid'] . '">' . $myrow1['categorydescription']; + } + } + 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 '<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>'; + 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'] . "?" . SID . ">"; + 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']) { + $msg=_('Stock description keywords have been used in preference to the Stock code extract entered'); + } + 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 && $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> + <th>" . _('Price') .' ('.$Currency.")</th> + </tr>"; + echo $tableheader; + + $j = 1; + $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>'; + } + + $uomsql='SELECT conversionfactor, + suppliersuom, + unitsofmeasure.unitname + FROM purchdata + LEFT JOIN unitsofmeasure + ON purchdata.suppliersuom=unitsofmeasure.unitid + WHERE supplierno="'.$_POST['SupplierID'].'" + AND stockid="'.$myrow['stockid'].'"'; + + $uomresult=DB_query($uomsql, $db); + if (DB_num_rows($uomresult)>0) { + $uomrow=DB_fetch_array($uomresult); + if (strlen($uomrow['suppliersuom'])>0) { + $uom=$uomrow['unitname']; + } else { + $uom=$myrow['units']; + } + } else { + $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".$myrow['stockid']."'></td> + <td><input class='number' type='text' size=12 value=0 name='price".$myrow['stockid']."'></td> + <input type='hidden' size=6 value=".$uom." name='uom".$myrow['stockid']."'> + </tr>"; + + $PartsDisplayed++; + if ($PartsDisplayed == $Maximum_Number_Of_Parts_To_Show){ + break; + } +#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="Update offer"></div>'; + }#end if SearchResults to show + echo '<input type="hidden" name="TenderType" value='.$_POST['TenderType'].'>'; + echo '<input type="hidden" name="SupplierID" value='.$_POST['SupplierID'].'>'; + + echo '</form>'; + +} //end of if search + +include('includes/footer.inc'); + +?> \ No newline at end of file Property changes on: trunk/SupplierTenders.php ___________________________________________________________________ Added: svn:keywords + Id Modified: trunk/SystemParameters.php =================================================================== --- trunk/SystemParameters.php 2010-06-16 08:23:27 UTC (rev 3497) +++ trunk/SystemParameters.php 2010-06-17 08:45:24 UTC (rev 3498) @@ -80,6 +80,9 @@ }elseif (!IsEmailAddress($_POST['X_FactoryManagerEmail'])){ $InputError = 1; prnMsg(_('The Factory Manager Email address does not appear to be valid'),'error'); + }elseif (!IsEmailAddress($_POST['X_PurchasingManagerEmail'])){ + $InputError = 1; + prnMsg(_('The Purchasing Manager Email address does not appear to be valid'),'error'); }elseif (strlen($_POST['X_FrequentlyOrderedItems']) > 2 || !is_numeric($_POST['X_FrequentlyOrderedItems'])) { $InputError = 1; prnMsg(_('The number of frequently ordered items to display must be numeric'),'error'); @@ -261,6 +264,9 @@ if ($_SESSION['FactoryManagerEmail'] != $_POST['X_FactoryManagerEmail']){ $sql[] = "UPDATE config SET confvalue='" . $_POST['X_FactoryManagerEmail'] . "' WHERE confname='FactoryManagerEmail'"; } + if ($_SESSION['PurchasingManagerEmail'] != $_POST['X_PurchasingManagerEmail']){ + $sql[] = "UPDATE config SET confvalue='" . $_POST['X_PurchasingManagerEmail'] . "' WHERE confname='PurchasingManagerEmail'"; + } if ($_SESSION['AutoCreateWOs'] != $_POST['X_AutoCreateWOs']){ $sql[] = 'UPDATE config SET confvalue=' . $_POST['X_AutoCreateWOs'] . " WHERE confname='AutoCreateWOs'"; } @@ -970,7 +976,11 @@ <td><input type="text" name="X_FactoryManagerEmail" size=50 maxlength=50 value="' . $_SESSION['FactoryManagerEmail'] . '"></td> <td>' . _('Work orders automatically created when sales orders are entered will be emailed to this address') .'</td></tr>'; +echo '<tr><td>' . _('Purchasing Manager Email Address') . ':</td> + <td><input type="text" name="X_PurchasingManagerEmail" size=50 maxlength=50 value="' . $_SESSION['PurchasingManagerEmail'] . '"></td> + <td>' . _('The email address for the purchasing manager, used to receive notifications by the tendering system') .'</td></tr>'; + echo '</table><div class="centre"><input type="Submit" Name="submit" value="' . _('Update') . '"></div></form>'; include('includes/footer.inc'); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-06-16 08:23:27 UTC (rev 3497) +++ trunk/doc/Change.log.html 2010-06-17 08:45:24 UTC (rev 3498) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>17/06/10 Tim: Enable a supplier to login and make an offer to the company</p> <p>16/06/10 Tim: SelectProduct.php - Layout improvements</p> <p>16/06/10 Tim: Customers.php - Correctly show fax and phone numbers</p> <p>16/06/10 Tim: CustloginSetup.php - Improvements to layout, and correctly get customer name</p> Copied: trunk/includes/DefineOfferClass.php (from rev 3491, trunk/includes/DefinePOClass.php) =================================================================== --- trunk/includes/DefineOfferClass.php (rev 0) +++ trunk/includes/DefineOfferClass.php 2010-06-17 08:45:24 UTC (rev 3498) @@ -0,0 +1,138 @@ +<?php +/* $Id$ */ +/* Definition of the Offer class to hold all the information for a supplier offer +*/ + + +Class Offer { + + var $LineItems; /*array of objects of class LineDetails using the product id as the pointer */ + var $CurrCode; + var $ExRate; + var $Initiator; + var $deliverydate; + var $RequisitionNo; + var $DelAdd1; + var $DelAdd2; + var $DelAdd3; + var $DelAdd4; + var $DelAdd5; + var $DelAdd6; + var $tel; + var $suppDelAdd1; + var $suppDelAdd2; + var $suppDelAdd3; + var $suppDelAdd4; + var $suppDelAdd5; + var $suppDelAdd6; + var $SupplierContact; + var $supptel; + var $Comments; + var $Location; + var $Managed; + var $SupplierID; + var $SupplierName; + var $Orig_OrderDate; + var $OrderNo; /*Only used for modification of existing orders otherwise only established when order committed */ + var $LinesOnOffer; + var $PrintedPurchaseOrder; + var $DatePurchaseOrderPrinted; + var $total; + var $GLLink; /*Is the GL link to stock activated only checked when order initiated or reading in for modification */ + var $version; + var $Stat; + var $StatComments; + var $AllowPrintPO; + var $revised; + var $deliveryby; + var $paymentterms; + var $contact; + var $port; + + function Offer(){ + /*Constructor function initialises a new purchase offer object */ + $this->LineItems = array(); + $this->total=0; + $this->LinesOnOffer=0; + } + + function add_to_offer( + $LineNo, + $StockID, + $Qty, + $ItemDescr, + $Price, + $UOM, + $DecimalPlaces){ + + if (isset($Qty) and $Qty!=0){ + + $this->LineItems[$LineNo] = new LineDetails($LineNo, + $StockID, + $Qty, + $ItemDescr, + $Price, + $UOM, + $DecimalPlaces); + $this->LinesOnOffer++; + Return 1; + } + Return 0; + } + + function update_offer_item($LineNo, + $Qty, + $Price){ + + $this->LineItems[$LineNo]->Quantity = $Qty; + $this->LineItems[$LineNo]->Price = $Price; + } + + function remove_from_offer(&$LineNo){ + $this->LineItems[$LineNo]->Deleted = True; + } + + + function Offer_Value() { + $TotalValue=0; + foreach ($this->LineItems as $OrderedItems) { + $TotalValue += ($OrderedItems->Price)*($OrderedItems->Quantity); + } + return $TotalValue; + } +} /* end of class defintion */ + +Class LineDetails { +/* PurchOrderDetails */ + var $LineNo; + var $StockID; + var $ItemDescription; + var $Quantity; + var $Price; + var $Units; + var $DecimalPlaces; + var $Deleted; + + function LineDetails ( + $LineNo, + $StockItem, + $Qty, + $ItemDescr, + $Prc, + $UOM, + $DecimalPlaces) + { + + /* Constructor function to add a new LineDetail object with passed params */ + $this->LineNo = $LineNo; + $this->StockID =$StockItem; + $this->ItemDescription = $ItemDescr; + $this->Quantity = $Qty; + $this->Price = $Prc; + $this->Units = $UOM; + $this->DecimalPlaces = $DecimalPlaces; + $this->Deleted = False; + } +} + +?> \ No newline at end of file Modified: trunk/includes/session.inc =================================================================== --- trunk/includes/session.inc 2010-06-16 08:23:27 UTC (rev 3497) +++ trunk/includes/session.inc 2010-06-17 08:45:24 UTC (rev 3498) @@ -138,16 +138,16 @@ $CurrenciesResult = DB_query('SELECT currabrev FROM currencies',$db); while ($CurrencyRow = DB_fetch_row($CurrenciesResult)){ if ($CurrencyRow[0]!=$_SESSION['CompanyRecord']['currencydefault']){ - - $UpdateCurrRateResult = DB_query('UPDATE currencies SET + + $UpdateCurrRateResult = DB_query('UPDATE currencies SET rate=' . GetCurrencyRate ($CurrencyRow[0],$CurrencyRates) . " ' WHERE currabrev='" . $CurrencyRow[0] . "'",$db); } } $_SESSION['UpdateCurrencyRatesDaily'] = Date('Y-m-d'); - - - + + + $UpdateConfigResult = DB_query("UPDATE config SET confvalue = '" . Date('Y-m-d') . "' WHERE confname='UpdateCurrencyRatesDaily'",$db); } } @@ -232,6 +232,14 @@ exit; } +/* Nasty kludge to allow Supplier only logins as well as Customer logins */ +if (count($_SESSION['AllowedPageSecurityTokens'])==1 and $_SESSION['AllowedPageSecurityTokens'][0]==9 and $PageSecurity==1){ + $_SESSION['AllowedPageSecurityTokens'][0]=1; + $SupplierLogin=1; +} else { + $SupplierLogin=0; +} + if (!isset($AllowAnyone)){ if ((!in_array($PageSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($PageSecurity))) { $title = _('Security Permissions Problem'); @@ -252,6 +260,11 @@ } } +/* Nasty kludge to allow Supplier only logins as well as Customer logins */ +if ($SupplierLogin==1) { + $_SESSION['AllowedPageSecurityTokens'][0]=9; +} + if (in_array(15, $_SESSION['AllowedPageSecurityTokens'])) { $debug = 1; } else { Modified: trunk/index.php =================================================================== --- trunk/index.php 2010-06-16 08:23:27 UTC (rev 3497) +++ trunk/index.php 2010-06-17 08:45:24 UTC (rev 3498) @@ -12,16 +12,16 @@ /*The module link codes are hard coded in a switch statement below to determine the options to show for each tab */ $ModuleLink = array('orders', 'AR', 'AP', 'PO', 'stock', 'manuf', 'Contracts', 'GL', 'FA', 'PC', 'system'); /*The headings showing on the tabs accross the main index used also in WWW_Users for defining what should be visible to the user */ -$ModuleList = array(_('Sales'), - _('Receivables'), - _('Payables'), - _('Purchases'), - _('Inventory'), +$ModuleList = array(_('Sales'), + _('Receivables'), + _('Payables'), + _('Purchases'), + _('Inventory'), _('Manufacturing'), - _('Contracts'), - _('General Ledger'), - _('Asset Manager'), - _('Petty Cash'), + _('Contracts'), + _('General Ledger'), + _('Asset Manager'), + _('Petty Cash'), _('Setup')); if (isset($_GET['Application'])){ /*This is sent by this page (to itself) when the user clicks on a tab */ @@ -30,9 +30,11 @@ include('includes/header.inc'); -if (count($_SESSION['AllowedPageSecurityTokens'])==1){ +if (count($_SESSION['AllowedPageSecurityTokens'])==1 and $SupplierLogin==0){ -/* if there is only one security access and its 1 (it has to be 1 for this page came up at all)- it must be a customer log on need to limit the menu to show only the customer accessible stuff this is what the page looks like for customers logging in */ +/* if there is only one security access and its 1 (it has to be 1 for this page came up at all)- it must be a customer log on + * need to limit the menu to show only the customer accessible stuff this is what the page looks like for customers logging in + */ ?> <tr> @@ -58,6 +60,20 @@ <?php include('includes/footer.inc'); exit; +} else if (count($_SESSION['AllowedPageSecurityTokens'])==1 and $SupplierLogin==1){ +?> + + <tr> + <td class="menu_group_items"> <!-- Orders transaction options --> + <table class="table_index"> + <tr> + <td class="menu_group_item"> + <?php echo '<p>• <a href="' . $rootpath . '/SupplierTenders.php?' . sid . '">' . _('Supplier Tenders') . '</a></p>'; ?> + </td> + </tr> + </table> + </td> +<?php } else { /* Security settings DO allow seeing the main menu */ ?> @@ -1300,12 +1316,12 @@ <?php echo '<p>• <a href="' . $rootpath . '/Contracts.php?' . sid . '">' . _('Create Contract') . '</a></p>'; ?> </td> </tr> - <tr> + <tr> </table> </td> <td class="menu_group_items"> <!-- Contract Costing Inquiries/Reports options --> <table width="100%" class="table_index"> - + <tr> <td class="menu_group_item"> <?php echo GetRptLinks('fa'); ?> @@ -1315,7 +1331,7 @@ </td> <td class="menu_group_items"> <!-- Contract Costing Maintenance options --> <table width="100%" class="table_index"> - + </table> </td> </table> Modified: trunk/sql/mysql/upgrade3.11.1-3.12.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-06-16 08:23:27 UTC (rev 3497) +++ trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-06-17 08:45:24 UTC (rev 3498) @@ -166,13 +166,16 @@ ALTER TABLE `www_users` add `supplierid` varchar(10) NOT NULL DEFAULT '' AFTER `customerid`; INSERT INTO `securityroles` VALUES (9,'Supplier Log On Only'); +UPDATE `securitytokens` SET `tokenname`='Supplier centre - Supplier access only' WHERE tokenid=9; +INSERT INTO `securitygroups` VALUES(9,9); ALTER TABLE locations add cashsalecustomer VARCHAR(21) NOT NULL DEFAULT ''; DROP TABLE contracts; DROP TABLE contractreqts; DROP TABLE contractbom; -CREATE TABLE `contractbom` ( + +CREATE TABLE IF NOT EXISTS `contractbom` ( contractref varchar(20) NOT NULL DEFAULT '0', `stockid` varchar(20) NOT NULL DEFAULT '', `workcentreadded` char(5) NOT NULL DEFAULT '', @@ -186,7 +189,7 @@ ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE `contractreqts` ( +CREATE TABLE IF NOT EXISTS `contractreqts` ( `contractreqid` int(11) NOT NULL AUTO_INCREMENT, `contractref` varchar(20) NOT NULL DEFAULT '0', `requirement` varchar(40) NOT NULL DEFAULT '', @@ -198,7 +201,7 @@ ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE `contracts` ( +CREATE TABLE IF NOT EXISTS `contracts` ( `contractref` varchar(20) NOT NULL DEFAULT '', `contractdescription` text NOT NULL DEFAULT '', `debtorno` varchar(10) NOT NULL DEFAULT '', @@ -228,4 +231,21 @@ ALTER TABLE `salestypes` CHANGE COLUMN `sales_type` `sales_type` VARCHAR(40) NOT NULL DEFAULT ''; INSERT INTO `config` VALUES ('ShowValueOnGRN', 1); -ALTER TABLE `www_users` CHANGE COLUMN `modulesallowed` `modulesallowed` varchar(40) NOT NULL DEFAULT '1,1,1,1,1,1,1,1,1,1,1,'; \ No newline at end of file +ALTER TABLE `www_users` CHANGE COLUMN `modulesallowed` `modulesallowed` varchar(40) NOT NULL DEFAULT '1,1,1,1,1,1,1,1,1,1,1,'; + +CREATE TABLE IF NOT EXISTS `offers` ( + offerid int(11) NOT NULL AUTO_INCREMENT, + tenderid int(11) NOT NULL DEFAULT 0, + supplierid varchar(10) NOT NULL DEFAULT '', + stockid varchar(20) NOT NULL DEFAULT '', + quantity double NOT NULL DEFAULT 0.0, + uom varchar(15) NOT NULL DEFAULT '', + price double NOT NULL DEFAULT 0.0, + expirydate date NOT NULL DEFAULT '0000-00-00', + currcode char(3) NOT NULL DEFAULT '', + PRIMARY KEY (`offerid`), + CONSTRAINT `offers_ibfk_1` FOREIGN KEY (`supplierid`) REFERENCES `suppliers` (`supplierid`), + CONSTRAINT `offers_ibfk_2` FOREIGN KEY (`stockid`) REFERENCES `stockmaster` (`stockid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO `config` VALUES('PurchasingManagerEmail', ''); \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |