From: <dai...@us...> - 2010-07-25 06:29:59
|
Revision: 3659 http://web-erp.svn.sourceforge.net/web-erp/?rev=3659&view=rev Author: daintree Date: 2010-07-25 06:29:52 +0000 (Sun, 25 Jul 2010) Log Message: ----------- Phil: SelectContract.php new script to select a contract <p>25/07/10 Phil: ContractOtherReqts.php new script to enter other requirements for a contract <p>25/07/10 Phil: Contracts.php and includes/DefineContractClass.php debugging Modified Paths: -------------- trunk/ContractBOM.php trunk/Contracts.php trunk/css/default/default.css trunk/css/fresh/default.css trunk/css/gel/default.css trunk/css/jelly/default.css trunk/css/professional/default.css trunk/css/silverwolf/default.css trunk/doc/Change.log.html trunk/includes/DefineContractClass.php trunk/index.php trunk/sql/mysql/upgrade3.11.1-3.12.sql Added Paths: ----------- trunk/ContractOtherReqts.php trunk/SelectContract.php trunk/css/default/images/contract.png trunk/css/fresh/images/contract.png trunk/css/gel/images/contract.png trunk/css/jelly/images/contract.png trunk/css/professional/images/contract.png Modified: trunk/ContractBOM.php =================================================================== --- trunk/ContractBOM.php 2010-07-22 15:31:55 UTC (rev 3658) +++ trunk/ContractBOM.php 2010-07-25 06:29:52 UTC (rev 3659) @@ -1,8 +1,8 @@ <?php -/* $Id: $ */ +/* $Id: $ */ -$PageSecurity = 4; +$PageSecurity = 6; include('includes/DefineContractClass.php'); @@ -28,7 +28,7 @@ foreach ($_SESSION['Contract'.$identifier]->ContractBOM as $ContractComponent) { if ($_POST['Qty'.$ContractComponent->ComponentID]==0){ //this is the same as deleting the line - so delete it - $_SESSION['Contract'.$identifier]->remove_ContractComponent($ContractComponent->ComponentID); + $_SESSION['Contract'.$identifier]->Remove_ContractComponent($ContractComponent->ComponentID); } else { $_SESSION['Contract'.$identifier]->ContractBOM[$ContractComponent->ComponentID]->Quantity=$_POST['Qty'.$ContractComponent->ComponentID]; } @@ -157,7 +157,7 @@ if(isset($_GET['Delete'])){ if($_SESSION['Contract'.$identifier]->Status!=2){ - $_SESSION['Contract'.$identifier]->remove_ContractComponent($_GET['Delete']); + $_SESSION['Contract'.$identifier]->Remove_ContractComponent($_GET['Delete']); } else { prnMsg( _('The contract BOM cannot be alterned because the customer has already placed the order'),'warn'); } @@ -226,7 +226,7 @@ echo '<form name="ContractBOMForm" action="' . $_SERVER['PHP_SELF'] . '?' . SID . 'identifier='.$identifier. '" method="post">'; if (count($_SESSION['Contract'.$identifier]->ContractBOM)>0){ - echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/contract.png" title="' . _('Contract Bill of Material') . '" alt=""> '.$_SESSION['Contract'.$identifier]->CustomerName; if (isset($_SESSION['Contract'.$identifier]->ContractRef)) { Added: trunk/ContractOtherReqts.php =================================================================== --- trunk/ContractOtherReqts.php (rev 0) +++ trunk/ContractOtherReqts.php 2010-07-25 06:29:52 UTC (rev 3659) @@ -0,0 +1,145 @@ +<?php + +/* $Id: $ */ + +$PageSecurity = 4; + +include('includes/DefineContractClass.php'); + +include('includes/session.inc'); +$title = _('Contract Other Requirements'); + +$identifier=$_GET['identifier']; + +/* If a contract header doesn't exist, then go to + * Contracts.php to create one + */ + +if (!isset($_SESSION['Contract'.$identifier])){ + header('Location:' . $rootpath . '/Contracts.php?' . SID); + exit; +} +include('includes/header.inc'); + + +if (isset($_POST['UpdateLines']) OR isset($_POST['BackToHeader'])) { + if($_SESSION['Contract'.$identifier]->Status!=2){ //dont do anything if the customer has committed to the contract + foreach ($_SESSION['Contract'.$identifier]->ContractReqts as $ContractComponentID => $ContractRequirementItem) { + + if ($_POST['Qty'.$ContractComponentID]==0){ + //this is the same as deleting the line - so delete it + $_SESSION['Contract'.$identifier]->Remove_ContractRequirement($ContractComponentID); + } else { + $_SESSION['Contract'.$identifier]->ContractReqts[$ContractComponentID]->Quantity=$_POST['Qty'.$ContractComponentID]; + $_SESSION['Contract'.$identifier]->ContractReqts[$ContractComponentID]->CostPerUnit=$_POST['CostPerUnit'.$ContractComponentID]; + $_SESSION['Contract'.$identifier]->ContractReqts[$ContractComponentID]->Requirement=$_POST['Requirement'.$ContractComponentID]; + } + } // end loop around the items on the contract requirements array + } // end if the contract is not currently committed to by the customer +}// end if the user has hit the update lines or back to header buttons + + +if (isset($_POST['BackToHeader'])){ + echo '<meta http-equiv="Refresh" content="0; url=' . $rootpath . '/Contracts.php?' . SID . 'identifier='.$identifier. '">'; + echo '<p>'; + prnMsg(_('You should automatically be forwarded to the Contract page. If this does not happen perhaps the browser does not support META Refresh') . '<a href="' . $rootpath . '/Contracts.php?' . SID. 'identifier='.$identifier . '">' . _('click here') . '</a> ' . _('to continue'),'info'); + include('includes/footer.inc'); + exit; +} + + +if(isset($_GET['Delete'])){ + if($_SESSION['Contract'.$identifier]->Status!=2){ + $_SESSION['Contract'.$identifier]->Remove_ContractRequirement($_GET['Delete']); + } else { + prnMsg( _('The other contract requirements cannot be altered because the customer has already placed the order'),'warn'); + } +} +if (isset($_POST['EnterNewRequirement'])){ + $InputError = false; + if (!is_numeric($_POST['Quantity'])){ + prnMsg(_('The quantity of the new requirement is expected to be numeric'),'error'); + $InputError = true; + } + if (!is_numeric($_POST['CostPerUnit'])){ + prnMsg(_('The cost per unit of the new requirement is expected to be numeric'),'error'); + $InputError = true; + } + if (!$InputError){ + $_SESSION['Contract'.$identifier]->Add_To_ContractRequirements ($_POST['RequirementDescription'], + $_POST['Quantity'], + $_POST['CostPerUnit']); + unset($_POST['RequirementDescription']); + unset($_POST['Quantity']); + unset($_POST['CostPerUnit']); + } +} + +/* This is where the other requirement as entered/modified should be displayed reflecting any deletions or insertions*/ + +echo '<form name="ContractReqtsForm" action="' . $_SERVER['PHP_SELF'] . '?' . SID . 'identifier='.$identifier. '" method="post">'; +echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/contract.png" title="' . + _('Contract Other Requirements') . '" alt=""> ' . _('Contract Other Requirements') . ' - ' . $_SESSION['Contract'.$identifier]->CustomerName; + +if (count($_SESSION['Contract'.$identifier]->ContractReqts)>0){ + + + if (isset($_SESSION['Contract'.$identifier]->ContractRef)) { + echo ' ' . _('Contract Reference:') .' '. $_SESSION['Contract'.$identifier]->ContractRef; + } + + echo '<table cellpadding=2 colspan=7 border=1>'; + echo '<tr> + <th>' . _('Description') . '</th> + <th>' . _('Quantity') . '</th> + <th>' . _('Unit Cost') . '</th> + <th>' . _('Sub-total') . '</th> + </tr>'; + + $_SESSION['Contract'.$identifier]->total = 0; + $k = 0; //row colour counter + $TotalCost =0; + foreach ($_SESSION['Contract'.$identifier]->ContractReqts as $ContractReqtID => $ContractComponent) { + + $LineTotal = $ContractComponent->Quantity * $ContractComponent->CostPerUnit; + + $DisplayLineTotal = number_format($LineTotal,2); + + if ($k==1){ + echo '<tr class="EvenTableRows">'; + $k=0; + } else { + echo '<tr class="OddTableRows">'; + $k=1; + } + + echo '<td><textarea name="Requirement' . $ContractReqtID . '" cols="30" rows="3">' . $ContractComponent->Requirement . '</textarea></td> + <td><input type=text class="number" name="Qty' . $ContractReqtID . '" size="11" value="' . $ContractComponent->Quantity . '"></td> + <td><input type=text class="number" name="CostPerUnit' . $ContractReqtID . '" size="11" value="' . $ContractComponent->CostPerUnit . '"></td> + <td class="number">' . $DisplayLineTotal . '</td> + <td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . 'identifier='.$identifier. '&Delete=' . $ContractReqtID . '">' . _('Delete') . '</a></td></tr>'; + $TotalCost += $LineTotal; + } + + $DisplayTotal = number_format($TotalCost,2); + echo '<tr><td colspan="4" class="number">' . _('Total Other Requirements Cost') . '</td><td class="number"><b>' . $DisplayTotal . '</b></td></tr></table>'; + echo '<br><div class="centre"><input type="submit" name="UpdateLines" value="' . _('Update Other Requirements Lines') . '">'; + echo ' <input type="submit" name="BackToHeader" value="' . _('Back To Contract Header') . '">'; + +} /*Only display the contract other requirements lines if there are any !! */ + +echo '<hr>'; +/*Now show form to add new requirements to the contract */ +echo '<table> + <tr><th colspan="2">' . _('Enter New Requirements') . '</th></tr> + <tr><td>' . _('Requirement Description') . '</td> + <td><textarea name="RequirementDescription" cols="30" rows="3">' . $_POST['RequirementDescription'] . '</textarea></td></tr>'; +echo '<tr><td>' . _('Quantity Required') . ':</td><td><input type="text" name="Quantity" size=10 maxlength=10 value="' . $_POST['Quantity'] . '"></td></tr>'; +echo '<tr><td>' . _('Cost Per Unit') . ':</td><td><input type="text" name="CostPerUnit" size=10 maxlength=10 value="' . $_POST['CostPerUnit'] . '"></td></tr>'; +echo '</table>'; + +echo '<div class="centre"><input type="submit" name="EnterNewRequirement" value="' . _('Enter New Contract Requirement') . '"></div>'; + +echo '</form>'; +include('includes/footer.inc'); +?> \ No newline at end of file Modified: trunk/Contracts.php =================================================================== --- trunk/Contracts.php 2010-07-22 15:31:55 UTC (rev 3658) +++ trunk/Contracts.php 2010-07-25 06:29:52 UTC (rev 3659) @@ -1,8 +1,8 @@ <?php -/* $Id: Contract_Header.php 3325 2010-01-25 16:50:32Z tim_schofield $ */ +/* $Id: $ */ -$PageSecurity = 4; +$PageSecurity = 6; include('includes/DefineContractClass.php'); include('includes/session.inc'); @@ -69,8 +69,6 @@ $_SESSION['Contract'.$identifier]->RequiredDate = $_POST['RequiredDate']; $_SESSION['Contract'.$identifier]->Margin = $_POST['Margin']; $_SESSION['Contract'.$identifier]->CustomerRef = $_POST['CustomerRef']; - $_SESSION['Contract'.$identifier]->QuantityReqd = $_POST['QuantityReqd']; - $_SESSION['Contract'.$identifier]->Units = $_POST['Units']; $_SESSION['Contract'.$identifier]->ExRate = $_POST['ExRate']; @@ -92,17 +90,17 @@ exit; } if (isset($_POST['EnterContractRequirements']) AND !$InputError){ - echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . '/ContractRequirements.php?' . SID . 'identifier='.$identifier. "'>"; + echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . '/ContractOtherReqts.php?' . SID . 'identifier='.$identifier. "'>"; echo '<p>'; prnMsg(_('You should automatically be forwarded to the entry of the Contract requirements page') . '. ' . _('If this does not happen') . ' (' . _('if the browser does not support META Refresh') . ') ' . - "<a href='$rootpath/ContractRequirements.php?" . SID. 'identifier='.$identifier . "'>" . _('click here') . '</a> ' . _('to continue'),'info'); + "<a href='$rootpath/ContractOtherReqts.php?" . SID. 'identifier='.$identifier . "'>" . _('click here') . '</a> ' . _('to continue'),'info'); include('includes/footer.inc'); exit; } } /* end of if going to contract BOM or contract requriements */ -echo '<a href="'. $rootpath . '/ContractSelect.php?' . SID . 'identifier='.$identifier.'">'. _('Back to Contracts'). '</a><br>'; +echo '<a href="'. $rootpath . '/SelectContract.php?' . SID .'">'. _('Back to Contract Selection'). '</a><br>'; //attempting to upload the drawing image file if (isset($_FILES['Drawing']) AND $_FILES['Drawing']['name'] !='' AND $_SESSION['Contract'.$identifier]->ContractRef!='') { @@ -165,8 +163,6 @@ margin, wo, requireddate, - quantityreqd, - units, drawing, exrate FROM contracts @@ -179,24 +175,23 @@ if (DB_num_rows($ContractHdrResult)==1 and !isset($_SESSION['Contract'.$identifier]->ContractRef )) { $myrow = DB_fetch_array($ContractHdrResult); - $_SESSION['Contract'.$identifier]->ContractRef = $_GET['ModifyOrderRef']; + $_SESSION['Contract'.$identifier]->ContractRef = $_GET['ModifyContractRef']; $_SESSION['Contract'.$identifier]->ContractDescription = $myrow['contractdescription']; $_SESSION['Contract'.$identifier]->DebtorNo = $myrow['debtorno']; $_SESSION['Contract'.$identifier]->BranchCode = $myrow['branchcode']; $_SESSION['Contract'.$identifier]->Status = $myrow['status']; $_SESSION['Contract'.$identifier]->CategoryID = $myrow['categoryid']; $_SESSION['Contract'.$identifier]->OrderNo = $myrow['orderno']; - $_SESSION['Contract'.$identifier]->Margin = $myrow['Margin']; + $_SESSION['Contract'.$identifier]->Margin = $myrow['margin']; $_SESSION['Contract'.$identifier]->WO = $myrow['wo']; - $_SESSION['Contract'.$identifier]->RequiredDate = $myrow['RequiredDate']; - $_SESSION['Contract'.$identifier]->QuantityRequired = $myrow['QuantityRequired']; - $_SESSION['Contract'.$identifier]->Units = $myrow['units']; + $_SESSION['Contract'.$identifier]->RequiredDate = ConvertSQLDate($myrow['requireddate']); $_SESSION['Contract'.$identifier]->Drawing = $myrow['drawing']; $_SESSION['Contract'.$identifier]->ExRate = $myrow['exrate']; /*now populate the contract BOM array with the items required for the contract */ $ContractBOMsql = "SELECT contractbom.stockid, + stockmaster.description, contractbom.workcentreadded, contractbom.quantity, stockmaster.units, @@ -207,11 +202,12 @@ $ErrMsg = _('The bill of material cannot be retrieved because'); $DbgMsg = _('The SQL statement that was used to retrieve the contract bill of material was'); - $ContractBOMResult = db_query($ContractBOMSQL,$db,$ErrMsg,$DbgMsg); + $ContractBOMResult = db_query($ContractBOMsql,$db,$ErrMsg,$DbgMsg); if (db_num_rows($ContractBOMResult) > 0) { while ($myrow=db_fetch_array($ContractBOMResult)) { $_SESSION['Contract'.$identifier]->Add_To_ContractBOM($myrow['stockid'], + $myrow['description'], $myrow['workcentreadded'], $myrow['quantity'], $myrow['cost'], @@ -219,7 +215,7 @@ } /* add contract bill of materials BOM lines*/ } //end is there was a contract BOM to add //Now add the contract requirments - $ContractReqtsSQL = "SELECT component, + $ContractReqtsSQL = "SELECT requirement, quantity, costperunit, contractreqid @@ -233,7 +229,7 @@ if (db_num_rows($ContractReqtsResult) > 0) { while ($myrow=db_fetch_array($ContractReqtsResult)) { - $_SESSION['Contract'.$identifier]->Add_To_ContractRequirements($myrow['component'], + $_SESSION['Contract'.$identifier]->Add_To_ContractRequirements($myrow['requirement'], $myrow['quantity'], $myrow['costperunit'], $myrow['contractreqid']); @@ -330,14 +326,7 @@ prnMsg(_('The date that the contract is to be completed by is expected to be a date in the future. Make the required date a date after today before proceeding.'),'error'); $InputError =true; } - if (!is_numeric($_POST['QuantityReqd'])){ - prnMsg(_('The quantity required is expected to be numeric. Please enter a number in the quantity required field before proceeding.'),'error'); - $InputError=true; - } - if ($_POST['QuantityReqd']<=0){ - prnMsg(_('The quantity required is expected to be a positive number. Please enter a postive number in the quantity required field before proceeding.'),'error'); - $InputError=true; - } + if (!$InputError) { $_SESSION['Contract'.$identifier]->ContractRef=$_POST['ContractRef']; $_SESSION['Contract'.$identifier]->ContractDescription=$_POST['ContractDescription']; @@ -346,11 +335,25 @@ $_SESSION['Contract'.$identifier]->Margin = $_POST['Margin']; $_SESSION['Contract'.$identifier]->Status = $_POST['Status']; $_SESSION['Contract'.$identifier]->CustomerRef = $_POST['CustomerRef']; - $_SESSION['Contract'.$identifier]->QuantityReqd = $_POST['QuantityReqd']; - $_SESSION['Contract'.$identifier]->Units = $_POST['Units']; $_SESSION['Contract'.$identifier]->ExRate = $_POST['ExRate']; - } + /*Get the first work centre for the users location - until we set this up properly */ + $result = DB_query("SELECT code FROM workcentres WHERE location='" . $_SESSION['UserStockLocation'] ."'",$db); + if (DB_num_rows($result)>0){ + $WorkCentreRow = DB_fetch_row($result); + $WorkCentre = $WorkCentreRow[0]; + } else { //need to add a default work centre for the location + $result = DB_query("INSERT INTO workcentres (code, location, description, overheadrecoveryact) + VALUES ('" . $_SESSION['UserStockLocation'] . "', + '" . $_SESSION['UserStockLocation'] . "', + '" . _('Default for') . ' ' . $_SESSION['UserStockLocation'] . "', + '" . '1' . "')",$db); + $WorkCentre = $_SESSION['UserStockLocation']; + } + /*The above is a bit of a hack to get a default workcentre for a location based on the users default location*/ + + } + $sql = "SELECT contractref, debtorno, branchcode, @@ -372,36 +375,14 @@ prnMsg(_('The contract reference cannot be the same as a previously created contract for another customer. Please modify the contract reference before continuing'),'error'); $InputError=true; } - if ($ExistingContract['status'] == 0 AND $_POST['Status']==2){ - prnMsg(_('The contract must first be made into a customer quotation - only then can it be completed.'),'error'); - $InputError=true; - } - if ($ExistingContract['status'] == 1 AND $_POST['Status']==0){ - prnMsg(_('Having made the contract into a quotation it cannot now be changed back into just a costing.'),'error'); - $InputError=true; - } - if ($ExistingContract['status'] == 1 AND $_POST['Status']==2){ - /* then we are completing this contract - need to : - * close the work order - * do the variances postings - */ - - - - - - - } + if($ExistingContract['status']<=1 AND ! $InputError){ //then we can accept any changes at all do an update on the whole lot $sql = "UPDATE contracts SET categoryid = '" . $_POST['CategoryID'] ."', requireddate = '" . FormatDateForSQL($_POST['RequiredDate']) . "', margin = " . $_POST['Margin'] . ", customerref = '" . $_POST['CustomerRef'] . "', - quantityreqd = " . $_POST['QuantityReqd'] . ", - units = '" . $_POST['Units'] . "', - exrate = " . $_POST['ExRate'] . ", - status = " . $_POST['Status'] . " + exrate = " . $_POST['ExRate'] . " WHERE contractref ='" . $_POST['ContractRef'] . "'"; $ErrMsg = _('Cannot update the contract because'); $result = DB_query($sql,$db,$ErrMsg); @@ -415,7 +396,7 @@ quantity) VALUES ( '" . $_POST['ContractRef'] . "', '" . $Component->StockID . "', - '" . $Component->WorkCentre . "', + '" . $WorkCentre . "', " . $Component->Quantity . ")"; $result = DB_query($sql,$db,$ErrMsg); } @@ -451,31 +432,30 @@ } - } else { /*Its a new contract - so insert */ + } elseif (!$InputError) { /*Its a new contract - so insert */ if ($_POST['Status'] !=0){ //a new contract being created with a status of not a quotation - create it anyway but with status=0 prnMsg(_('A contract can only be created with a status of costing initially'),'warn'); } + $sql = "INSERT INTO contracts ( contractref, debtorno, branchcode, + contractdescription, categoryid, requireddate, margin, customerref, - quantityreqd, - units, exrate) VALUES ('" . $_POST['ContractRef'] . "', '" . $_SESSION['Contract'.$identifier]->DebtorNo . "', '" . $_SESSION['Contract'.$identifier]->BranchCode . "', + '" . $_POST['ContractDescription'] . "', '" . $_POST['CategoryID'] . "', '" . FormatDateForSQL($_POST['RequiredDate']) . "', " . $_POST['Margin'] . ", '" . $_POST['CustomerRef'] . "', - " . $_POST['QuantityReqd'] . ", - '" . $_POST['Units'] . "', ". $_POST['ExRate'] .")"; $ErrMsg = _('The new contract could not be added because'); @@ -490,7 +470,7 @@ quantity) VALUES ( '" . $_POST['ContractRef'] . "', '" . $Component->StockID . "', - '" . $Component->WorkCentre . "', + '" . $WorkCentre . "', " . $Component->Quantity . ")"; $result = DB_query($sql,$db,$ErrMsg); } @@ -508,6 +488,17 @@ $result = DB_query($sql,$db,$ErrMsg); } prnMsg(_('The new contract has been added to the database'),'success'); + unset($_SESSION['Contract'.$identifier]->ContractBOM); + unset($_SESSION['Contract'.$identifier]->ContractReqts); + unset($_SESSION['Contract' . $identifier]); + unset($_POST['ContractRef']); + unset($_POST['Description']); + unset($_POST['CategoryID']); + unset($_POST['RequiredDate']); + unset($_POST['Margin']); + unset($_POST['CustomerRef']); + unset($_POST['ExRate']); + } //end of adding a new contract }//end of commital to database @@ -646,7 +637,7 @@ if (!isset($_SESSION['Contract'.$identifier]->DebtorNo) OR $_SESSION['Contract'.$identifier]->DebtorNo=='' ) { - echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/customer.png" title="' . + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/contract.png" title="' . _('Contract') . '" alt="">' . ' ' . _('Contract: Select Customer') . ''; echo '<form action="' . $_SERVER['PHP_SELF'] . '?' .SID .'&identifier=' . $identifier .'" name="CustomerSelection" method=post>'; @@ -717,7 +708,7 @@ echo '<form name="ContractEntry" enctype="multipart/form-data" action="' . $_SERVER['PHP_SELF'] . '?' . SID . '&identifier=' . $identifier . '" method="post">'; echo '<p class="page_title_text"> - <img src="'.$rootpath.'/css/'.$theme.'/images/customer.png" title="' . _('Contract') . '" alt=""> + <img src="'.$rootpath.'/css/'.$theme.'/images/contract.png" title="' . _('Contract') . '" alt=""> ' . $_SESSION['Contract'.$identifier]->CustomerName; if ($_SESSION['CompanyRecord']['currencydefault'] != $_SESSION['Contract'.$identifier]->CurrCode){ @@ -732,7 +723,7 @@ echo '<table>'; echo '<tr><td>' . _('Contract Reference') . ':</td><td>'; - if ($_SESSION['Contract'.$identifier]->Status==0) { + if ($_SESSION['Contract'.$identifier]->Status==100) { /*Then the contract has not become an order yet and we can allow changes to the ContractRef */ echo '<input type="text" name="ContractRef" size=21 maxlength=20 value="' . $_SESSION['Contract'.$identifier]->ContractRef . '">'; } else { @@ -782,8 +773,6 @@ echo '<tr><td>' . _('Required Date') . ':</td><td><input type="text" class=date alt="' .$_SESSION['DefaultDateFormat'] . '" name="RequiredDate" size=11 value="' . $_SESSION['Contract'.$identifier]->RequiredDate . '"></td></tr>'; - echo '<tr><td>' . _('Quantity Required') . ':</td><td><input type="text" name="QuantityReqd" size=10 maxlength=10 value="' . $_SESSION['Contract'.$identifier]->QuantityReqd . '"></td></tr>'; - echo '<tr><td>' . _('Customer Reference') . ':</td><td><input type="text" name="CustomerRef" size=21 maxlength=20 value="' . $_SESSION['Contract'.$identifier]->CustomerRef . '"></td></tr>'; if (!isset($_SESSION['Contract'.$identifier]->Margin)){ $_SESSION['Contract'.$identifier]->Margin =50; @@ -797,25 +786,27 @@ echo '<input type="hidden" name="ExRate" value=' . $_SESSION['Contract'.$identifier]->ExRate . '>'; } - echo '<tr><td>' . _('Contract Status') . ':</td><td><select name="Status">'; + echo '<tr><td>' . _('Contract Status') . ':</td><td>'; $StatusText = array(); $StatusText[0] = _('Setup'); $StatusText[1] = _('Quote'); $StatusText[2] = _('Completed'); - for ($Status=0;$Status<3;$Status++) { - if ($_SESSION['Contract'.$identifier]->Status == $Status){ - echo '<option selected value="' . $Status . '">' . $StatusText[$Status] . '</option>'; - } else { - echo '<option value="'.$Status.'">' . $StatusText[$Status] . '</option>'; - } + if ($_SESSION['Contract'.$identifier]->Status == 0){ + echo _('Contract Setup'); + } elseif ($_SESSION['Contract'.$identifier]->Status == 1){ + echo _('Customer Already Quoted'); + } elseif ($_SESSION['Contract'.$identifier]->Status == 2){ + echo _('Order Placed'); } echo '</select></td></tr>'; - + if ($_SESSION['Contract'.$identifier]->Status>=1) { + echo '<tr><td>' . _('Quotation Reference/Sales Order No') . ':</td><td>' . $_SESSION['Contract'.$identifier]->OrderNo . '</td></tr>'; + } if ($_SESSION['Contract'.$identifier]->Status!=0) { echo '<tr><td>' . _('Contract Work Order Ref') . ':</td><td>' . $_SESSION['Contract'.$identifier]->WorkOrder . '</td></tr>'; } - echo '</table>'; + echo '</table><hr>'; echo '<table><tr><td> <table><tr><th colspan=6>' . _('Stock Items Required') . '</th></tr>'; @@ -837,12 +828,12 @@ </tr>'; $ContractBOMCost += ($Component->ItemCost * $Component->Quantity); } - echo '<tr><td colspan="5">' . _('Total stock cost') . '</td><td class="number">' . number_format($ContractBOMCost,2) . '</td></tr>'; + echo '<tr><th colspan="5"><b>' . _('Total stock cost') . '</b></th><th class="number"><b>' . number_format($ContractBOMCost,2) . '</b></th></tr>'; } else { //there are no items set up against this contract echo '<tr><td colspan="6"><i>' . _('None Entered') . '</i></td></tr>'; } echo '</table></td>'; //end of contract BOM table - echo '<td> + echo '<td valign="top"> <table><tr><th colspan=4>' . _('Other Requirements') . '</th></tr>'; $ContractReqtsCost = 0; if (count($_SESSION['Contract'.$identifier]->ContractReqts)!=0){ @@ -858,12 +849,12 @@ </tr>'; $ContractReqtsCost += ($Requirement->CostPerUnit * $Requirement->Quantity); } - echo '<tr><td colspan="3">' . _('Total other costs') . '</td><td class="number">' . number_format($ContractReqtsCost,2) . '</td></tr>'; + echo '<tr><th colspan="3"><b>' . _('Total other costs') . '</b></th><th class="number"><b>' . number_format($ContractReqtsCost,2) . '</b></th></tr>'; } else { //there are no items set up against this contract echo '<tr><td colspan="4"><i>' . _('None Entered') . '</i></td></tr>'; } echo '</table></td></tr></table>'; - + echo '<hr>'; echo'<table><tr><th>' . _('Total Contract Cost') . '</th><th class="number">' . number_format(($ContractBOMCost+$ContractReqtsCost),2) . '</th><th>' . _('Contract Price') . '</th><th class="number">' . number_format(($ContractBOMCost+$ContractReqtsCost)/((100-$_SESSION['Contract'.$identifier]->Margin)/100),2) . '</th></tr></table>'; echo'<p></p>'; Added: trunk/SelectContract.php =================================================================== --- trunk/SelectContract.php (rev 0) +++ trunk/SelectContract.php 2010-07-25 06:29:52 UTC (rev 3659) @@ -0,0 +1,200 @@ +<?php + +/* $Id: $*/ + +$PageSecurity = 6; + +include('includes/session.inc'); +$title = _('Select Contract'); +include('includes/header.inc'); + +echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/contract.png" title="' . _('Contracts') . '" alt="">' . ' ' . _('Select A Contract') . '</p> '; + +echo '<form action=' . $_SERVER['PHP_SELF'] .'?' .SID . ' method=post>'; + + +echo '<p><div class="centre">'; + +if (isset($_REQUEST['ContractRef']) AND $_REQUEST['ContractRef']!='') { + $_REQUEST['ContractRef'] = trim($_REQUEST['ContractRef']); + echo _('Contract Reference') . ' - ' . $_REQUEST['ContractRef']; +} else { + if (isset($_REQUEST['SelectedCustomer'])) { + echo _('For customer') . ': ' . $_REQUEST['SelectedCustomer'] . ' ' . _('and') . ' '; + echo '<input type="hidden" name="SelectedCustomer" value="' . $_REQUEST['SelectedCustomer'] . '">'; + } +} + +if (!isset($_REQUEST['ContractRef']) or $_REQUEST['ContractRef']==''){ + + echo _('Contract Reference') . ': <input type="text" name="ContractRef" maxlength=20 size=20>  '; + echo '<select name="Status">'; + + if (isset($_GET['Status'])){ + $_POST['Status']=$_GET['Status']; + } + if (!isset($_POST['Status'])){ + $_POST['Status']=4; + } + if ($_POST['Status']==0){ + echo '<option selected value="0">' . _('Not Yet Quoted'). '</option>'; + echo '<option value="1">' . _('Quoted - No Order Placed'). '</option>'; + echo '<option value="2">' . _('Order Placed') . '</option>'; + echo '<option value="3">' . _('Completed') . '</option>'; + echo '<option value="4">' . _('All Contracts') . '</option>'; + } elseif($_POST['Status']==1) { + echo '<option value="0">' . _('Not Yet Quoted'). '</option>'; + echo '<option selected value="1">' . _('Quoted - No Order Placed'). '</option>'; + echo '<option value="2">' . _('Order Placed') . '</option>'; + echo '<option value="3">' . _('Completed') . '</option>'; + echo '<option value="4">' . _('All Contracts') . '</option>'; + } elseif($_POST['Status']==2) { + echo '<option value="0">' . _('Not Yet Quoted'). '</option>'; + echo '<option value="1">' . _('Quoted - No Order Placed'). '</option>'; + echo '<option selected value="2">' . _('Order Placed') . '</option>'; + echo '<option value="3">' . _('Completed') . '</option>'; + echo '<option value="4">' . _('All Contracts') . '</option>'; + } elseif($_POST['Status']==3) { + echo '<option value="0">' . _('Not Yet Quoted'). '</option>'; + echo '<option value="1">' . _('Quoted - No Order Placed'). '</option>'; + echo '<option value="2">' . _('Order Placed') . '</option>'; + echo '<option selected value="3">' . _('Completed') . '</option>'; + echo '<option value="4">' . _('All Contracts') . '</option>'; + } elseif($_POST['Status']==4) { + echo '<option value="0">' . _('Not Yet Quoted'). '</option>'; + echo '<option value="1">' . _('Quoted - No Order Placed'). '</option>'; + echo '<option value="2">' . _('Order Placed') . '</option>'; + echo '<option value="3">' . _('Completed') . '</option>'; + echo '<option selected value="4">' . _('All Contracts') . '</option>'; + } + echo '</select>   '; +} +echo '<input type="submit" name="SearchContracts" VALUE="' . _('Search') . '">'; +echo ' <a href="' . $rootpath . '/Contracts.php?' . SID . '">' . _('New Contract') . '</a>'; + + +//figure out the SQL required from the inputs available + +if (isset($_REQUEST['ContractRef']) AND $_REQUEST['ContractRef'] !='') { + $SQL = "SELECT contractref, + contractdescription, + categoryid, + contracts.debtorno, + debtorsmaster.name AS customername, + branchcode, + status, + orderno, + wo, + customerref, + requireddate + FROM contracts INNER JOIN debtorsmaster + ON contracts.debtorno = debtorsmaster.debtorno + WHERE contractref='". $_REQUEST['ContractRef'] ."'"; + +} else { //contractref not selected + if (isset($_REQUEST['SelectedCustomer'])) { + + $SQL = "SELECT contractref, + contractdescription, + categoryid, + contracts.debtorno, + debtorsmaster.name AS customername, + branchcode, + status, + orderno, + wo, + customerref, + requireddate + FROM contracts INNER JOIN debtorsmaster + ON contracts.debtorno = debtorsmaster.debtorno + WHERE debtorno='". $_REQUEST['SelectedCustomer'] ."'"; + if ($_POST['Status']!=4){ + $SQL .= " AND status='" . $_POST['Status'] . "'"; + } + } else { //no customer selected + $SQL = 'SELECT contractref, + contractdescription, + categoryid, + contracts.debtorno, + debtorsmaster.name AS customername, + branchcode, + status, + orderno, + wo, + customerref, + requireddate + FROM contracts INNER JOIN debtorsmaster + ON contracts.debtorno = debtorsmaster.debtorno'; + if ($_POST['Status']!=4){ + $SQL .= " AND status='" . $_POST['Status'] . "'"; + } + } +} //end not contract ref selected + +$ErrMsg = _('No contracts were returned by the SQL because'); +$ContractsResult = DB_query($SQL,$db,$ErrMsg); + +/*show a table of the contracts returned by the SQL */ + +echo '<table cellpadding=2 colspan=7 WIDTH=100%>'; + +$tableheader = '<tr> + <th>' . _('Modify') . '</th> + <th>' . _('Order') . '</th> + <th>' . _('Issue To WO') . '</th> + <th>' . _('Contract Ref') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Customer') . '</th> + <th>' . _('Required Date') . '</th> + </tr>'; + +echo $tableheader; + +$j = 1; +$k=0; //row colour counter +while ($myrow=DB_fetch_array($ContractsResult)) { + if ($k==1){ + echo '<tr class="EvenTableRows">'; + $k=0; + } else { + echo '<tr class="OddTableRows">'; + $k++; + } + + $ModifyPage = $rootpath . '/Contracts.php?' . SID . '&ModifyContractRef=' . $myrow['contractref']; + $OrderModifyPage = $rootpath . '/SelectOrderItems.php?' . SID . '&ModifyOrderNo=' . $myrow['orderno']; + $IssueToWOPage = $rootpath . '/WOIssue.php?' . SID . '&WO=' . $myrow['wo']; + $FormatedRequiredDate = ConvertSQLDate($myrow['requireddate']); + + if ($myrow['status']==0){ //still setting up the contract + echo '<td><a href="' . $ModifyPage . '">' . _('Modify') . '</a></td>'; + } else { + echo '<td>' . _('n/a') . '</td>'; + } + if ($myrow['status']==1 OR $myrow['status']==2){ // quoted or ordered + echo '<td><a href="' . $OrderModifyPage . '">' . $myrow['orderno'] . '</a></td>'; + } else { + echo '<td>' . _('n/a') . '</td>'; + } + if ($myrow['status']==2){ //the customer has accepted the quote but not completed contract yet + echo '<td><a href="' . $IssueToWOPage . '">' . $myrow['wo'] . '</a></td>'; + } else { + echo '<td>' . _('n/a') . '</td>'; + } + echo '<td>' . $myrow['contractref'] . '</td> + <td>' . $myrow['contractdescription'] . '</td> + <td>' . $myrow['customername'] . '</td> + <td>' . $FormatedRequiredDate . '</td></tr>'; + + $j++; + if ($j == 12){ + $j=1; + echo $tableheader; + } +//end of page full new headings if +} +//end of while loop + +echo '</table></form>'; +include('includes/footer.inc'); +?> \ No newline at end of file Modified: trunk/css/default/default.css =================================================================== --- trunk/css/default/default.css 2010-07-22 15:31:55 UTC (rev 3658) +++ trunk/css/default/default.css 2010-07-25 06:29:52 UTC (rev 3659) @@ -121,6 +121,13 @@ color: white; } +th.number { + text-align: right; + font-weight: normal; + background-color: #800000; + color: white; +} + div.error { background-color:#fddbdb; color: red; Added: trunk/css/default/images/contract.png =================================================================== (Binary files differ) Property changes on: trunk/css/default/images/contract.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/css/fresh/default.css =================================================================== --- trunk/css/fresh/default.css 2010-07-22 15:31:55 UTC (rev 3658) +++ trunk/css/fresh/default.css 2010-07-25 06:29:52 UTC (rev 3659) @@ -120,7 +120,12 @@ color: white; text-align: center; } - +th.number { + text-align: right; + font-weight: normal; + background-color: #800000; + color: white; +} div.error { background-color:#fddbdb; color: red; Added: trunk/css/fresh/images/contract.png =================================================================== (Binary files differ) Property changes on: trunk/css/fresh/images/contract.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/css/gel/default.css =================================================================== --- trunk/css/gel/default.css 2010-07-22 15:31:55 UTC (rev 3658) +++ trunk/css/gel/default.css 2010-07-25 06:29:52 UTC (rev 3659) @@ -141,7 +141,13 @@ color: #330000; text-align: center; } - +th.number { + text-align: right; + font-weight: normal; + background-color: #ccc; + font-size: 12px; + color: #330000; +} div.error { background-color:red; color: white; Added: trunk/css/gel/images/contract.png =================================================================== (Binary files differ) Property changes on: trunk/css/gel/images/contract.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/css/jelly/default.css =================================================================== --- trunk/css/jelly/default.css 2010-07-22 15:31:55 UTC (rev 3658) +++ trunk/css/jelly/default.css 2010-07-25 06:29:52 UTC (rev 3659) @@ -125,6 +125,13 @@ text-align: center; } +th.number { + font-weight: normal; + background: #ccc; + font-size: 12px; + color: #330000; + text-align: right; +} div.error { background:red; color: white; Added: trunk/css/jelly/images/contract.png =================================================================== (Binary files differ) Property changes on: trunk/css/jelly/images/contract.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/css/professional/default.css =================================================================== --- trunk/css/professional/default.css 2010-07-22 15:31:55 UTC (rev 3658) +++ trunk/css/professional/default.css 2010-07-25 06:29:52 UTC (rev 3659) @@ -121,6 +121,14 @@ text-align: center; } +th.number { + font-weight: normal; + font-size: 12px; + background-color: #cccce5; + color: #330000; + text-align: right; +} + div.error { background-color:#fddbdb; color: red; Added: trunk/css/professional/images/contract.png =================================================================== (Binary files differ) Property changes on: trunk/css/professional/images/contract.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/css/silverwolf/default.css =================================================================== --- trunk/css/silverwolf/default.css 2010-07-22 15:31:55 UTC (rev 3658) +++ trunk/css/silverwolf/default.css 2010-07-25 06:29:52 UTC (rev 3659) @@ -15,7 +15,7 @@ | reflected throughout Web-ERP. | \--------------------------------------------------*/ -/* $Id: default.css 3446 2010-05-05 10:11:54Z tim_schofield $*/ +/* $Id$*/ body { font-family: Arial, Verdana, Helvetica, sans-serif; @@ -67,6 +67,14 @@ vertical-align: middle; } +th.number { + font-weight: normal; + background-color: #cccce5; + font-size: 100%; + color: #300; + text-align: right; + vertical-align: middle; +} .tableheader { font-weight: normal; background-color: #cccce5; Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-22 15:31:55 UTC (rev 3658) +++ trunk/doc/Change.log.html 2010-07-25 06:29:52 UTC (rev 3659) @@ -1,5 +1,8 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>25/07/10 Phil: SelectContract.php new script to select a contract +<p>25/07/10 Phil: ContractOtherReqts.php new script to enter other requirements for a contract +<p>25/07/10 Phil: Contracts.php and includes/DefineContractClass.php debugging <p>22/07/10 Tim: GLAccountInquiry.php - Add in running balance. Cumulative for BS account, and period for PL accounts.</p> <p>22/07/10 Simon Peter Otandeka: FixedAssetList.php - New script that provides a simple list of assets and their properties.</p> <p>22/07/10 Tim: FixedAssetJournal.php - Corrections to depreciation calculation layout changes, and sql quoting</p> Modified: trunk/includes/DefineContractClass.php =================================================================== --- trunk/includes/DefineContractClass.php 2010-07-22 15:31:55 UTC (rev 3658) +++ trunk/includes/DefineContractClass.php 2010-07-25 06:29:52 UTC (rev 3659) @@ -1,5 +1,5 @@ <?php -/* $Id: $*/ +/* $Id: $*/ /* definition of the Contract class */ Class Contract { @@ -18,9 +18,7 @@ var $Margin; /*the margin used in quoting for the contract */ var $WO; /*the wo created when the quotation is converted to an order */ var $RequiredDate; - var $QuantityReqd; - var $Units; /*the unit of measure of the contract item*/ - var $Drawing; /*a link to the contract drawing*/ + var $Drawing; /*a link to the contract drawing*/ var $CurrCode; /*the currency of the customer to quote in */ var $ExRate; /*the rate of exchange between customer currency and company functional currency used when quoting */ var $BOMComponentCounter; @@ -35,11 +33,16 @@ $this->ContractReqts = array(); $this->BOMComponentCounter=0; $this->RequirementsCounter=0; - $this->QuantityReqd=1; - $this->Status =0; + $this->Status =100; } - function Add_To_ContractBOM($StockID, $ItemDescription, $WorkCentre, $Quantity, $ItemCost, $UOM){ + function Add_To_ContractBOM($StockID, + $ItemDescription, + $WorkCentre, + $Quantity, + $ItemCost, + $UOM){ + if (isset($StockID) AND $Quantity!=0){ $this->ContractBOM[$this->BOMComponentCounter] = new ContractComponent($this->BOMComponentCounter, $StockID, @@ -54,24 +57,28 @@ Return 0; } - function remove_ContractComponent($ContractComponent_ID){ + function Remove_ContractComponent($ContractComponent_ID){ + global $db; + $result = DB_query("DELETE FROM contractbom WHERE contractref='" . $this->ContractRef . "' AND stockid='" . $this->ContractBOM[$ContractComponent_ID]->StockID . "'",$db); unset($this->ContractBOM[$ContractComponent_ID]); } /*Requirments Methods */ -function Add_To_ContractRequirements($Requirment, $Quantity, $CostPerUnit,$ContractReqID){ - if (isset($Requirment) AND $Quantity!=0 AND $CostPerUnit!=0){ - $this->ContractReqts[$this->RequirementsCounter] = new ContractRequirement($Requirment, $Quantity, $CostPerUnit,$ContractReqID); +function Add_To_ContractRequirements($Requirement, $Quantity, $CostPerUnit,$ContractReqID=0){ + if (isset($Requirement) AND $Quantity!=0 AND $CostPerUnit!=0){ + $this->ContractReqts[$this->RequirementsCounter] = new ContractRequirement($Requirement, $Quantity, $CostPerUnit,$ContractReqID); $this->RequirementsCounter++; Return 1; } Return 0; } - function remove_ContractRequirement($ContractRequirmentID){ - unset($this->ContractReqts[$ContractRequirmentID]); + function Remove_ContractRequirement($ContractRequirementID){ + global $db; + $result = DB_query("DELETE FROM contractreqts WHERE contractreqid='" . $this->ContractReqts[$ContractRequirementID]->ContractReqID . "'",$db); + unset($this->ContractReqts[$ContractRequirementID]); } } /* end of class defintion */ @@ -105,10 +112,10 @@ var $Quantity; var $CostPerUnit; - function ContractRequirement ($Requirment, $Quantity, $CostPerUnit,$ContractReqID=0){ + function ContractRequirement ($Requirement, $Quantity, $CostPerUnit,$ContractReqID=0){ /* Constructor function to add a new Contract Component object with passed params */ - $this->Requirement =$Requirement; + $this->Requirement = $Requirement; $this->Quantity = $Quantity; $this->CostPerUnit = $CostPerUnit; $this->ItemCost= $ItemCost; @@ -116,7 +123,4 @@ } } - - - ?> \ No newline at end of file Modified: trunk/index.php =================================================================== --- trunk/index.php 2010-07-22 15:31:55 UTC (rev 3658) +++ trunk/index.php 2010-07-25 06:29:52 UTC (rev 3659) @@ -1336,19 +1336,19 @@ <tr> <td class="menu_group_items"> <!-- Contract Costing transactions options --> <table width="100%" class="table_index"> + <tr> - <td class="menu_group_item"> - <?php echo '<p>• <a href="' . $rootpath . '/Contracts.php?' . sid . '">' . _('Create Contract') . '</a></p>'; ?> - </td> - </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 '<p>• <a href="' . $rootpath . '/SelectContract.php?' . sid . '">' . _('Select Contract') . '</a></p>'; ?> + </td> + </tr> + <tr> + <td class="menu_group_item"> <?php echo GetRptLinks('fa'); ?> </td> </tr> @@ -1356,7 +1356,11 @@ </td> <td class="menu_group_items"> <!-- Contract Costing Maintenance options --> <table width="100%" class="table_index"> - + <tr> + <td class="menu_group_item"> + <?php echo '<p>• <a href="' . $rootpath . '/Contracts.php?' . sid . '">' . _('Create Contract') . '</a></p>'; ?> + </td> + </tr> </table> </td> </table> Modified: trunk/sql/mysql/upgrade3.11.1-3.12.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-07-22 15:31:55 UTC (rev 3658) +++ trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-07-25 06:29:52 UTC (rev 3659) @@ -213,8 +213,6 @@ `margin` double NOT NULL DEFAULT '1', `wo` int(11) NOT NULL DEFAULT '0', `requireddate` date NOT NULL DEFAULT '0000-00-00', - `quantityreqd` double NOT NULL DEFAULT '1', - `units` varchar(15) NOT NULL DEFAULT 'Each', `drawing` varchar(50) NOT NULL DEFAULT '', `exrate` double NOT NULL DEFAULT '1', PRIMARY KEY (`contractref`), @@ -282,3 +280,5 @@ INSERT INTO `config` VALUES ('VersionNumber', '3.12'); UPDATE `securitytokens` SET `tokenname`='Prices Security' WHERE tokenid=12; + +ALTER TABLE `www_users` CHANGE `supplierid` `supplierid` VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |