From: <tim...@us...> - 2010-07-17 20:19:56
|
Revision: 3632 http://web-erp.svn.sourceforge.net/web-erp/?rev=3632&view=rev Author: tim_schofield Date: 2010-07-17 20:19:50 +0000 (Sat, 17 Jul 2010) Log Message: ----------- SQL quoting and layout changes Modified Paths: -------------- trunk/PaymentAllocations.php trunk/doc/Change.log.html Modified: trunk/PaymentAllocations.php =================================================================== --- trunk/PaymentAllocations.php 2010-07-17 20:19:27 UTC (rev 3631) +++ trunk/PaymentAllocations.php 2010-07-17 20:19:50 UTC (rev 3632) @@ -18,8 +18,8 @@ if (!isset($_GET['SuppID'])){ prnMsg( _('Supplier ID Number is not Set, can not display result'),'warn'); - include('includes/footer.inc'); - exit; + include('includes/footer.inc'); + exit; } if (!isset($_GET['InvID'])){ @@ -70,7 +70,7 @@ exit; } -echo '<table cellpadding=2 colspan=7 width=100% border=0>'; +echo '<table cellpadding=2 colspan=7 width=80% class=selection>'; $TableHeader = "<tr> <th>" . _('Supplier Number') . '<br>' . _('Reference') . "</th> <th>" . _('Payment') .'<br>' . _('Reference') . "</th> @@ -90,21 +90,17 @@ $k++; } - printf('<td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - </tr>', - $myrow['supplierno'], - $myrow['suppreference'], - ConvertSQLDate($myrow['trandate']), - $myrow['alloc'] ); + echo '<td>'.$myrow['supplierno'].'</td> + <td>'.$myrow['suppreference'].'</td> + <td>'.ConvertSQLDate($myrow['trandate']).'</td> + <td class=number>'.number_format($myrow['alloc'],2).'</td> + </tr>'; $j++; - If ($j == 18){ - $j=1; - echo $TableHeader; - } + if ($j == 18){ + $j=1; + echo $TableHeader; + } } echo '</table>'; Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-17 20:19:27 UTC (rev 3631) +++ trunk/doc/Change.log.html 2010-07-17 20:19:50 UTC (rev 3632) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>17/07/10 Tim: PaymentAllocations.php - SQL quoting and layout changes</p> <p>17/07/10 Tim: OutstandingGRNs.php - SQL quoting and layout changes</p> <p>17/07/10 Tim: SelectCompletedOrder.php - SQL quoting and layout changes</p> <p>17/07/10 Tim: OrderDetails.php - SQL quoting and layout changes</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-17 20:20:16
|
Revision: 3633 http://web-erp.svn.sourceforge.net/web-erp/?rev=3633&view=rev Author: tim_schofield Date: 2010-07-17 20:20:10 +0000 (Sat, 17 Jul 2010) Log Message: ----------- SQL quoting and layout changes Modified Paths: -------------- trunk/PaymentMethods.php trunk/doc/Change.log.html Modified: trunk/PaymentMethods.php =================================================================== --- trunk/PaymentMethods.php 2010-07-17 20:19:50 UTC (rev 3632) +++ trunk/PaymentMethods.php 2010-07-17 20:20:10 UTC (rev 3633) @@ -10,6 +10,9 @@ include('includes/header.inc'); +echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/transactions.png" title="' . _('Payments') . + '" alt="">' . ' ' . $title.'</p>'; + if ( isset($_GET['SelectedPaymentID']) ) $SelectedPaymentID = $_GET['SelectedPaymentID']; elseif (isset($_POST['SelectedPaymentID'])) @@ -18,9 +21,9 @@ if (isset($Errors)) { unset($Errors); } - -$Errors = array(); +$Errors = array(); + if (isset($_POST['submit'])) { //initialise no input errors assumed initially before we test @@ -37,20 +40,20 @@ $InputError = 1; prnMsg( _('The payment method cannot contain the character') . " '&' " . _('or the character') ." '",'error'); $Errors[$i] = 'MethodName'; - $i++; + $i++; } if ( trim($_POST['MethodName']) == "") { $InputError = 1; prnMsg( _('The payment method may not be empty.'),'error'); $Errors[$i] = 'MethodName'; - $i++; + $i++; } - if ($_POST['SelectedPaymentID']!='' AND $InputError !=1) { + if (isset($_POST['SelectedPaymentID']) AND $InputError !=1) { /*SelectedPaymentID could also exist if submit had not been clicked this code would not run in this case cos submit is false of course see the delete code below*/ // Check the name does not clash - $sql = "SELECT count(*) FROM paymentmethods - WHERE paymentid <> " . $SelectedPaymentID ." + $sql = "SELECT count(*) FROM paymentmethods + WHERE paymentid <> '" . $SelectedPaymentID ."' AND paymentname ".LIKE." '" . $_POST['MethodName'] . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); @@ -59,20 +62,20 @@ prnMsg( _('The payment method can not be renamed because another with the same name already exists.'),'error'); } else { // Get the old name and check that the record still exists need to be very careful here - - $sql = "SELECT paymentname FROM paymentmethods - WHERE paymentid = " . $SelectedPaymentID; + + $sql = "SELECT paymentname FROM paymentmethods + WHERE paymentid = '" . $SelectedPaymentID . "'"; $result = DB_query($sql,$db); if ( DB_num_rows($result) != 0 ) { $myrow = DB_fetch_row($result); $OldName = $myrow[0]; $sql = "UPDATE paymentmethods SET paymentname='" . $_POST['MethodName'] . "', - paymenttype = " . $_POST['ForPayment'] . ", - receipttype = " . $_POST['ForReceipt'] . " - WHERE paymentname ".LIKE." '".$OldName."'"; - - /* lets leave well alone existing entries + paymenttype = '" . $_POST['ForPayment'] . "', + receipttype = '" . $_POST['ForReceipt'] . "' + WHERE paymentname LIKE '".$OldName."'"; + + /* lets leave well alone existing entries if ($_POST['MethodName'] != $OldMeasureName ) { // Less work if not required this could take a while. $sql = "UPDATE banktrans @@ -89,8 +92,8 @@ $ErrMsg = _('Could not update payment method'); } elseif ($InputError !=1) { /*SelectedPaymentID is null cos no item selected on first time round so must be adding a record*/ - $sql = "SELECT count(*) FROM paymentmethods - WHERE paymentname " .LIKE. " '".$_POST['MethodName'] ."'"; + $sql = "SELECT count(*) FROM paymentmethods + WHERE paymentname LIKE'".$_POST['MethodName'] ."'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ( $myrow[0] > 0 ) { @@ -98,13 +101,13 @@ prnMsg( _('The payment method can not be created because another with the same name already exists.'),'error'); } else { $sql = "INSERT INTO paymentmethods ( - paymentname, - paymenttype, + paymentname, + paymenttype, receipttype) VALUES ( '" . $_POST['MethodName'] ."', - " . $_POST['ForPayment'] . ", - " . $_POST['ForReceipt'] . " + '" . $_POST['ForPayment'] ."', + '" . $_POST['ForReceipt'] ."' )"; } $msg = _('Record inserted'); @@ -114,6 +117,7 @@ if ($InputError!=1){ $result = DB_query($sql,$db, $ErrMsg); prnMsg($msg,'success'); + echo '<p>'; } unset ($SelectedPaymentID); unset ($_POST['SelectedPaymentID']); @@ -125,8 +129,8 @@ //the link to delete a selected record was clicked instead of the submit button // PREVENT DELETES IF DEPENDENT RECORDS IN 'stockmaster' // Get the original name of the payment method the ID is just a secure way to find the payment method - $sql = "SELECT paymentname FROM paymentmethods - WHERE paymentid = " . $SelectedPaymentID; + $sql = "SELECT paymentname FROM paymentmethods + WHERE paymentid = '" . $SelectedPaymentID . "'"; $result = DB_query($sql,$db); if ( DB_num_rows($result) == 0 ) { // This is probably the safest way there is @@ -134,16 +138,17 @@ } else { $myrow = DB_fetch_row($result); $OldMeasureName = $myrow[0]; - $sql= "SELECT COUNT(*) FROM banktrans WHERE banktranstype ".LIKE." '" . $OldMeasureName . "'"; + $sql= "SELECT COUNT(*) FROM banktrans WHERE banktranstype LIKE '" . $OldMeasureName . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { prnMsg( _('Cannot delete this payment method because bank transactions have been created using this payment method'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('bank transactions that refer to this payment method') . '</font>'; } else { - $sql="DELETE FROM paymentmethods WHERE paymentname ".LIKE."'" . $OldMeasureName . "'"; + $sql="DELETE FROM paymentmethods WHERE paymentname LIKE '" . $OldMeasureName . "'"; $result = DB_query($sql,$db); prnMsg( $OldMeasureName . ' ' . _('payment method has been deleted') . '!','success'); + echo '<br>'; } //end if not used } //end if payment method exist unset ($SelectedPaymentID); @@ -158,7 +163,7 @@ if (!isset($SelectedPaymentID)) { -/* A payment method could be posted when one has been edited and is being updated +/* A payment method could be posted when one has been edited and is being updated or GOT when selected for modification SelectedPaymentID will exist because it was sent with the page in a GET . If its the first time the page has been displayed with no parameters @@ -176,7 +181,7 @@ $ErrMsg = _('Could not get payment methods because'); $result = DB_query($sql,$db,$ErrMsg); - echo "<table> + echo "<table class=selection> <tr> <th>" . _('Payment Method') . "</th> <th>" . _('For Payments') . "</th> @@ -224,7 +229,7 @@ paymenttype, receipttype FROM paymentmethods - WHERE paymentid=" . $SelectedPaymentID; + WHERE paymentid='" . $SelectedPaymentID . "'"; $result = DB_query($sql, $db); if ( DB_num_rows($result) == 0 ) { @@ -239,14 +244,14 @@ $_POST['ForReceipt'] = $myrow['receipttype']; echo "<input type=hidden name='SelectedPaymentID' VALUE='" . $_POST['MethodID'] . "'>"; - echo "<table>"; + echo "<table class=selection>"; } } else { $_POST['MethodName']=''; $_POST['ForPayment'] = 1; // Default is use for payment $_POST['ForReceipt'] = 1; // Default is use for receipts - echo "<table>"; + echo "<table class=selection>"; } echo "<tr> <td>" . _('Payment Method') . ':' . "</td> @@ -267,11 +272,11 @@ echo '</table>'; - echo '<div class="centre"><input type=Submit name=submit value=' . _('Enter Information') . '></div>'; + echo '<br><div class="centre"><input type=Submit name=submit value=' . _('Enter Information') . '></div>'; echo '</form>'; } //end if record deleted no point displaying form to add record include('includes/footer.inc'); -?> +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-17 20:19:50 UTC (rev 3632) +++ trunk/doc/Change.log.html 2010-07-17 20:20:10 UTC (rev 3633) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>17/07/10 Tim: PaymentMethods.php - SQL quoting and layout changes</p> <p>17/07/10 Tim: PaymentAllocations.php - SQL quoting and layout changes</p> <p>17/07/10 Tim: OutstandingGRNs.php - SQL quoting and layout changes</p> <p>17/07/10 Tim: SelectCompletedOrder.php - SQL quoting and layout changes</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-17 22:12:09
|
Revision: 3634 http://web-erp.svn.sourceforge.net/web-erp/?rev=3634&view=rev Author: tim_schofield Date: 2010-07-17 22:12:03 +0000 (Sat, 17 Jul 2010) Log Message: ----------- Bug fixes, SQL quoting and layout changes Modified Paths: -------------- trunk/Payments.php trunk/doc/Change.log.html Modified: trunk/Payments.php =================================================================== --- trunk/Payments.php 2010-07-17 20:20:10 UTC (rev 3633) +++ trunk/Payments.php 2010-07-17 22:12:03 UTC (rev 3634) @@ -33,7 +33,8 @@ //note this is already linked from this page //echo "<a href='" . $rootpath . '/SelectSupplier.php?' . SID . "'>" . _('Back to Suppliers') . '</a><br>'; -echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/transactions.png" title="' . _('Payment Entry') . '" alt="">' . ' ' . _('Payment Entry') . '</p>'; +echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/transactions.png" title="' . _('Payment Entry') + . '" alt="">' . ' ' . _('Payment Entry') . '</p>'; echo '<div class="page_help_text">' . _('Use this screen to enter payments FROM your bank account. <br>Note: To enter a payment FROM a supplier, first select the Supplier, click Enter a Payment to, or Receipt from the Supplier, and use a negative Payment amount on this form.') . '</div><br><div class="centre">'; if (isset($_GET['SupplierID'])){ @@ -281,12 +282,12 @@ chequeno, tag) '; $SQL= $SQL . "VALUES (1, - " . $TransNo . ", + '" . $TransNo . "', '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', - " . $PeriodNo . ", - " . $PaymentItem->GLCode . ", + '" . $PeriodNo . "', + '" . $PaymentItem->GLCode . "', '" . $PaymentItem->Narrative . "', - " . ($PaymentItem->Amount/$_SESSION['PaymentDetail']->ExRate/$_SESSION['PaymentDetail']->FunctionalExRate) . ", + '" . ($PaymentItem->Amount/$_SESSION['PaymentDetail']->ExRate/$_SESSION['PaymentDetail']->FunctionalExRate) . "', '". $PaymentItem->cheque ."', '" . $PaymentItem->tag . "' )"; @@ -308,10 +309,10 @@ /*Need to deal with the case where the payment from one bank account could be to a bank account in another currency */ /*Get the currency and rate of the bank account transferring to*/ - $SQL = 'SELECT currcode, rate + $SQL = "SELECT currcode, rate FROM bankaccounts INNER JOIN currencies ON bankaccounts.currcode = currencies.currabrev - WHERE accountcode=' . $PaymentItem->GLCode; + WHERE accountcode='" . $PaymentItem->GLCode . "'"; $TrfToAccountResult = DB_query($SQL,$db); $TrfToBankRow = DB_fetch_array($TrfToAccountResult) ; $TrfToBankCurrCode = $TrfToBankRow['currcode']; @@ -350,7 +351,7 @@ */ $ReceiptTransNo = GetNextTransNo( 2, $db); - $SQL= 'INSERT INTO banktrans (transno, + $SQL= "INSERT INTO banktrans (transno, type, bankact, ref, @@ -360,15 +361,15 @@ banktranstype, amount, currcode) - VALUES (' . $ReceiptTransNo . ', + VALUES ('" . $ReceiptTransNo . "', 2, - ' . $PaymentItem->GLCode . ", '" - . _('Act Transfer From ') . $_SESSION['PaymentDetail']->Account . ' - ' . $PaymentItem->Narrative . " ', - " . (($_SESSION['PaymentDetail']->ExRate * $_SESSION['PaymentDetail']->FunctionalExRate)/$TrfToBankExRate). ", - " . $TrfToBankExRate . ", + '" . $PaymentItem->GLCode . "', + '" . _('Act Transfer From ') . $_SESSION['PaymentDetail']->Account . ' - ' . $PaymentItem->Narrative . "', + '" . (($_SESSION['PaymentDetail']->ExRate * $_SESSION['PaymentDetail']->FunctionalExRate)/$TrfToBankExRate). "', + '" . $TrfToBankExRate . "', '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', '" . $_SESSION['PaymentDetail']->Paymenttype . "', - " . $PaymentItem->Amount . ", + '" . $PaymentItem->Amount . "', '" . $_SESSION['PaymentDetail']->Currency . "' )"; $ErrMsg = _('Cannot insert a bank transaction because'); @@ -394,14 +395,14 @@ rate, ovamount, transtext) "; - $SQL = $SQL . 'VALUES (' . $TransNo . ", + $SQL = $SQL . "VALUES ('" . $TransNo . "', 22, '" . $_SESSION['PaymentDetail']->SupplierID . "', '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', '" . date('Y-m-d H-i-s') . "', '" . $_SESSION['PaymentDetail']->Paymenttype . "', - " . ($_SESSION['PaymentDetail']->ExRate/$_SESSION['PaymentDetail']->FunctionalExRate) . ", - " . (-$_SESSION['PaymentDetail']->Amount-$_SESSION['PaymentDetail']->Discount) . ", + '" . ($_SESSION['PaymentDetail']->ExRate/$_SESSION['PaymentDetail']->FunctionalExRate) . "', + '" . (-$_SESSION['PaymentDetail']->Amount-$_SESSION['PaymentDetail']->Discount) . "', '" . $_SESSION['PaymentDetail']->Narrative . "' )"; @@ -412,7 +413,7 @@ /*Update the supplier master with the date and amount of the last payment made */ $SQL = "UPDATE suppliers SET lastpaiddate = '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', - lastpaid=" . $_SESSION['PaymentDetail']->Amount ." + lastpaid='" . $_SESSION['PaymentDetail']->Amount ."' WHERE suppliers.supplierid='" . $_SESSION['PaymentDetail']->SupplierID . "'"; @@ -435,12 +436,12 @@ amount) "; $SQL=$SQL . "VALUES ( 22, - " . $TransNo . ", + '" . $TransNo . "', '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', - " . $PeriodNo . ", - " . $_SESSION['CompanyRecord']['creditorsact'] . ", + '" . $PeriodNo . "', + '" . $_SESSION['CompanyRecord']['creditorsact'] . "', '" . $_SESSION['PaymentDetail']->Narrative . "', - " . $CreditorTotal . " + '" . $CreditorTotal . "' )"; $ErrMsg = _('Cannot insert a GL transaction for the creditors account debit because'); $DbgMsg = _('Cannot insert a GL transaction for the creditors account debit using the SQL'); @@ -456,12 +457,12 @@ narrative, amount) "; $SQL=$SQL . "VALUES (22, - " . $TransNo . ", + '" . $TransNo . "', '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', - " . $PeriodNo . ", - " . $_SESSION['CompanyRecord']["pytdiscountact"] . ", + '" . $PeriodNo . "', + '" . $_SESSION['CompanyRecord']["pytdiscountact"] . "', '" . $_SESSION['PaymentDetail']->Narrative . "', - " . (-$_SESSION['PaymentDetail']->Discount/$_SESSION['PaymentDetail']->ExRate/$_SESSION['PaymentDetail']->FunctionalExRate) . " + '" . (-$_SESSION['PaymentDetail']->Discount/$_SESSION['PaymentDetail']->ExRate/$_SESSION['PaymentDetail']->FunctionalExRate) . "' )"; $ErrMsg = _('Cannot insert a GL transaction for the payment discount credit because'); $DbgMsg = _('Cannot insert a GL transaction for the payment discount credit using the SQL'); @@ -481,13 +482,13 @@ account, narrative, amount) "; - $SQL = $SQL . 'VALUES (' . $Transtype . ', - ' . $TransNo . ", + $SQL = $SQL . "VALUES ('" . $Transtype . "', + '" . $TransNo . "', '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', - " . $PeriodNo . ", - " . $_SESSION['PaymentDetail']->Account . ", + '" . $PeriodNo . "', + '" . $_SESSION['PaymentDetail']->Account . "', '" . $_SESSION['PaymentDetail']->Narrative . "', - " . (-$_SESSION['PaymentDetail']->Amount/$_SESSION['PaymentDetail']->ExRate/$_SESSION['PaymentDetail']->FunctionalExRate) . " + '" . (-$_SESSION['PaymentDetail']->Amount/$_SESSION['PaymentDetail']->ExRate/$_SESSION['PaymentDetail']->FunctionalExRate) . "' )"; $ErrMsg = _('Cannot insert a GL transaction for the bank account credit because'); @@ -509,15 +510,15 @@ banktranstype, amount, currcode) "; - $SQL= $SQL . "VALUES (" . $TransNo . ", - " . $Transtype . ", - " . $_SESSION['PaymentDetail']->Account . ", + $SQL= $SQL . "VALUES ('" . $TransNo . "', + '" . $Transtype . "', + '" . $_SESSION['PaymentDetail']->Account . "', '" . $_SESSION['PaymentDetail']->Narrative . "', - " . $_SESSION['PaymentDetail']->ExRate . " , - " . $_SESSION['PaymentDetail']->FunctionalExRate . ", + '" . $_SESSION['PaymentDetail']->ExRate . "', + '" . $_SESSION['PaymentDetail']->FunctionalExRate . "', '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', '" . $_SESSION['PaymentDetail']->Paymenttype . "', - " . -$_SESSION['PaymentDetail']->Amount . ", + '" . -$_SESSION['PaymentDetail']->Amount . "', '" . $_SESSION['PaymentDetail']->Currency . "' )"; @@ -536,15 +537,15 @@ banktranstype, amount, currcode) "; - $SQL= $SQL . "VALUES (" . $TransNo . ", - " . $Transtype . ", - " . $_SESSION['PaymentDetail']->Account . ", + $SQL= $SQL . "VALUES ('" . $TransNo . "', + '" . $Transtype . "', + '" . $_SESSION['PaymentDetail']->Account . "', '" . $_SESSION['PaymentDetail']->Narrative . "', - " . $_SESSION['PaymentDetail']->ExRate . " , - " . $_SESSION['PaymentDetail']->FunctionalExRate . ", + '" . $_SESSION['PaymentDetail']->ExRate . "', + " . $_SESSION['PaymentDetail']->FunctionalExRate . "', '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', '" . $_SESSION['PaymentDetail']->Paymenttype . "', - " . -$PaymentItem->Amount . ", + '" . -$PaymentItem->Amount . "', '" . $_SESSION['PaymentDetail']->Currency . "' )"; @@ -575,8 +576,15 @@ unset($_SESSION['PaymentDetail']); /*Set up a newy in case user wishes to enter another */ - echo '<br><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '">' . _('Enter a General Ledger Payment') . '</a><br>'; - echo '<br><a href="' . $rootpath . '/Payments.php?SupplierID=' . $lastSupplier . '">' . _('Enter another Payment for this Supplier') . '</a>'; + if (isset($lastSupplier) and $lastSupplier!='') { + $sql="SELECT suppname FROM suppliers WHERE supplierid='".$lastSupplier."'"; + $result=DB_query($sql, $db); + $myrow=DB_fetch_array($result); + echo '<br><a href="' . $rootpath . '/Payments.php?SupplierID=' . $lastSupplier . '">' . + _('Enter another Payment for') . ' ' . $myrow['suppname'] . '</a>'; + } else { + echo '<br><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '">' . _('Enter another General Ledger Payment') . '</a><br>'; + } } include('includes/footer.inc'); @@ -594,7 +602,7 @@ $SQL = "select accountname FROM chartmaster - WHERE accountcode=" . $_POST['GLManualCode']; + WHERE accountcode='" . $_POST['GLManualCode'] . "'"; $Result=DB_query($SQL,$db); @@ -615,7 +623,7 @@ } else if (DB_num_rows($ChequeNoResult)!=0 and $_POST['cheque']!=''){ prnMsg( _('The cheque number has already been used') . ' - ' . _('This GL analysis item could not be added'),'error'); } else { - $SQL = "select accountname FROM chartmaster WHERE accountcode=" . $_POST['GLCode']; + $SQL = "select accountname FROM chartmaster WHERE accountcode='" . $_POST['GLCode'] . "'"; $Result=DB_query($SQL,$db); $myrow=DB_fetch_array($Result); $_SESSION['PaymentDetail']->add_to_glanalysis($_POST['GLAmount'], @@ -657,7 +665,7 @@ FROM bankaccounts, chartmaster WHERE bankaccounts.accountcode= chartmaster.accountcode - AND chartmaster.accountcode=" . $_POST['BankAccount']; + AND chartmaster.accountcode='" . $_POST['BankAccount'] . "'"; $ErrMsg = _('The bank account name cannot be retrieved because'); $DbgMsg = _('SQL used to retrieve the bank account name was'); @@ -677,8 +685,13 @@ echo '<form action=' . $_SERVER['PHP_SELF'] . '?' . SID . ' method=post>'; -echo '<font size=3 color=BLUE>' . _('Payment'); +// Note this is duplicated +//echo '<div class="page_help_text">' . _('Note: To enter a payment FROM ') . $_SESSION['PaymentDetail']->SuppName . _(' use a negative Payment amount.'); +echo '<p><table class=selection>'; + +echo '<tr><th colspan=4><font size=3 color=blue>' . _('Payment'); + if ($_SESSION['PaymentDetail']->SupplierID!=""){ echo ' ' . _('to') . ' ' . $_SESSION['PaymentDetail']->SuppName; } @@ -687,13 +700,8 @@ echo ' ' . _('from the') . ' ' . $_SESSION['PaymentDetail']->BankAccountName; } -echo ' ' . _('on') . ' ' . $_SESSION['PaymentDetail']->DatePaid . '</font>'; +echo ' ' . _('on') . ' ' . $_SESSION['PaymentDetail']->DatePaid . '</font></th></tr>'; -// Note this is duplicated -//echo '<div class="page_help_text">' . _('Note: To enter a payment FROM ') . $_SESSION['PaymentDetail']->SuppName . _(' use a negative Payment amount.'); - -echo '<p><table>'; - $SQL = 'SELECT bankaccountname, bankaccounts.accountcode, bankaccounts.currcode @@ -705,7 +713,7 @@ $DbgMsg = _('The SQL used to retrieve the bank accounts was'); $AccountsResults = DB_query($SQL,$db,$ErrMsg,$DbgMsg); -echo '<tr><td>' . _('Bank Account') . ':</td><td><select name="BankAccount">'; +echo '<tr><td>' . _('Bank Account') . ':</td><td><select name="BankAccount" onChange="ReloadForm(UpdateHeader)">'; if (DB_num_rows($AccountsResults)==0){ echo '</select></td></tr></table><p>'; @@ -734,7 +742,7 @@ if ($_SESSION['PaymentDetail']->SupplierID==''){ - echo '<tr><td>' . _('Currency of Payment') . ':</td><td><select name="Currency">'; + echo '<tr><td>' . _('Currency of Payment') . ':</td><td><select name="Currency" onChange="ReloadForm(UpdateHeader)">'; $SQL = 'SELECT currency, currabrev, rate FROM currencies'; $result=DB_query($SQL,$db); @@ -836,40 +844,9 @@ if ($_SESSION['CompanyRecord']['gllink_creditors']==1 AND $_SESSION['PaymentDetail']->SupplierID==''){ /* Set upthe form for the transaction entry for a GL Payment Analysis item */ - echo '<table class="table1" border="1"><tr> - <th>' . _('Cheque No').'</th> - <th>' . _('Amount') . ' (' . $_SESSION['PaymentDetail']->Currency . ')</th> - <th>' . _('GL Account') . '</th> - <th>' . _('Narrative') . '</th> - <th>' . _('Tag') . '</th> - </tr>'; + echo '<br><table class=selection>'; + echo '<tr><th colspan=2><font size=3 color=blue>' . _('General Ledger Payment Analysis Entry') . '</font></th></tr>'; - $PaymentTotal = 0; - foreach ($_SESSION['PaymentDetail']->GLItems as $PaymentItem) { - $tagsql='SELECT tagdescription from tags where tagref='.$PaymentItem->tag; - $tagresult=DB_query($tagsql, $db); - $tagmyrow=DB_fetch_row($tagresult); - if ($PaymentItem->tag==0) { - $tagname='None'; - } else { - $tagname=$tagmyrow[0]; - } - echo '<tr> - <td align=left>' . $PaymentItem->cheque . '</td> - <td class=number>' . number_format($PaymentItem->Amount,2) . '</td> - <td>' . $PaymentItem->GLCode . ' - ' . $PaymentItem->GLActName . '</td> - <td>' . stripslashes($PaymentItem->Narrative) . '</td> - <td>' . $PaymentItem->tag . ' - ' . $tagname . '</td> - <td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&Delete=' . $PaymentItem->ID . '">' . _('Delete') . '</a></td> - </tr>'; - $PaymentTotal += $PaymentItem->Amount; - - } - echo '<tr><td></td><td class=number><b>' . number_format($PaymentTotal,2) . '</b></td><td></td><td></td><td></td></tr></table>'; - - - echo '<br><font size=3 color=BLUE><div class="centre">' . _('General Ledger Payment Analysis Entry') . '</div></font><br><table>'; - //Select the tag echo '<tr><td>' . _('Select Tag') . ':</td><td><select name="tag">'; @@ -938,17 +915,49 @@ echo '<tr><td>' . _('Amount') . ' (' . $_SESSION['PaymentDetail']->Currency . '):</td><td><input type=Text Name="GLAmount" Maxlength=12 size=12 class=number></td></tr>'; } - echo '</table>'; + echo '</table><br>'; echo '<div class="centre"><input type=submit name="Process" value="' . _('Accept') . '"><input type=submit name="Cancel" value="' . _('Cancel') . '"></div>'; + if (sizeOf($_SESSION['PaymentDetail']->GLItems)>0) { + echo '<br><table class=selection><tr> + <th>' . _('Cheque No').'</th> + <th>' . _('Amount') . ' (' . $_SESSION['PaymentDetail']->Currency . ')</th> + <th>' . _('GL Account') . '</th> + <th>' . _('Narrative') . '</th> + <th>' . _('Tag') . '</th> + </tr>'; + + $PaymentTotal = 0; + foreach ($_SESSION['PaymentDetail']->GLItems as $PaymentItem) { + $tagsql='SELECT tagdescription from tags where tagref='.$PaymentItem->tag; + $tagresult=DB_query($tagsql, $db); + $tagmyrow=DB_fetch_row($tagresult); + if ($PaymentItem->tag==0) { + $tagname='None'; + } else { + $tagname=$tagmyrow[0]; + } + echo '<tr> + <td align=left>' . $PaymentItem->cheque . '</td> + <td class=number>' . number_format($PaymentItem->Amount,2) . '</td> + <td>' . $PaymentItem->GLCode . ' - ' . $PaymentItem->GLActName . '</td> + <td>' . stripslashes($PaymentItem->Narrative) . '</td> + <td>' . $PaymentItem->tag . ' - ' . $tagname . '</td> + <td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '&Delete=' . $PaymentItem->ID . '">' . _('Delete') . '</a></td> + </tr>'; + $PaymentTotal += $PaymentItem->Amount; + } + echo '<tr><td></td><td class=number><b>' . number_format($PaymentTotal,2) . '</b></td><td></td><td></td><td></td></tr></table><br>'; + echo '<input type=submit name="CommitBatch" value="' . _('Accept and Process Payment') . '">'; + } + } else { /*a supplier is selected or the GL link is not active then set out the fields for entry of receipt amt and disc */ + echo '<table class=selection><tr><td>' . _('Amount of Payment') . ' ' . $_SESSION['PaymentDetail']->Currency . ':</td> + <td><input class=number type="text" name="Amount" maxlength=12 size=13 value=' . $_SESSION['PaymentDetail']->Amount . '></td></tr>'; - echo '<table><tr><td>' . _('Amount of Payment') . ' ' . $_SESSION['PaymentDetail']->Currency . ':</td> - <td><input class=number type="text" name="Amount" maxlength=12 size=13 value=' . $_SESSION['PaymentDetail']->Amount . '></td></tr>'; - if (isset($_SESSION['PaymentDetail']->SupplierID)){ /*So it is a supplier payment so show the discount entry item */ echo '<tr><td>' . _('Amount of Discount') . ':</td> <td><input class=number type="text" name="Discount" maxlength=12 size=13 value=' . $_SESSION['PaymentDetail']->Discount . '></td></tr>'; @@ -956,11 +965,10 @@ } else { echo '<input type="hidden" name="discount" Value=0>'; } - echo '</table>'; - + echo '</table><br>'; + echo '<input type=submit name="CommitBatch" value="' . _('Accept and Process Payment') . '">'; } -echo '<br><br><input type=submit name="CommitBatch" value="' . _('Accept and Process Payment') . '">'; echo '</form>'; include('includes/footer.inc'); -?> +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-17 20:20:10 UTC (rev 3633) +++ trunk/doc/Change.log.html 2010-07-17 22:12:03 UTC (rev 3634) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>17/07/10 Tim: Payments.php - Bug fixes, SQL quoting and layout changes</p> <p>17/07/10 Tim: PaymentMethods.php - SQL quoting and layout changes</p> <p>17/07/10 Tim: PaymentAllocations.php - SQL quoting and layout changes</p> <p>17/07/10 Tim: OutstandingGRNs.php - SQL quoting and layout changes</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-18 08:11:10
|
Revision: 3636 http://web-erp.svn.sourceforge.net/web-erp/?rev=3636&view=rev Author: tim_schofield Date: 2010-07-18 08:11:03 +0000 (Sun, 18 Jul 2010) Log Message: ----------- Bug fixes, SQL quoting and layout changes Modified Paths: -------------- trunk/PaymentTerms.php trunk/doc/Change.log.html Modified: trunk/PaymentTerms.php =================================================================== --- trunk/PaymentTerms.php 2010-07-17 22:12:16 UTC (rev 3635) +++ trunk/PaymentTerms.php 2010-07-18 08:11:03 UTC (rev 3636) @@ -11,9 +11,7 @@ include('includes/header.inc'); echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_add.png" title="' . _('Payment Terms') . '" alt="">' . ' ' . $title . '</p>'; -echo '<div class="page_help_text">' . _('Payment Terms') . '.</div><br>'; - if (isset($_GET['SelectedTerms'])){ $SelectedTerms = $_GET['SelectedTerms']; } elseif (isset($_POST['SelectedTerms'])){ @@ -84,12 +82,12 @@ $sql = "UPDATE paymentterms SET terms='" . $_POST['Terms'] . "', dayinfollowingmonth=0, - daysbeforedue=" . $_POST['DayNumber'] . " + daysbeforedue='" . $_POST['DayNumber'] . "' WHERE termsindicator = '" . $SelectedTerms . "'"; } else { $sql = "UPDATE paymentterms SET terms='" . $_POST['Terms'] . "', - dayinfollowingmonth=" . $_POST['DayNumber'] . ", + dayinfollowingmonth='" . $_POST['DayNumber'] . "', daysbeforedue=0 WHERE termsindicator = '" . $SelectedTerms . "'"; } @@ -107,7 +105,7 @@ VALUES ( '" . $_POST['TermsIndicator'] . "', '" . $_POST['Terms'] . "', - " . $_POST['DayNumber'] . ", + '" . $_POST['DayNumber'] . "', 0 )"; } else { @@ -119,7 +117,7 @@ '" . $_POST['TermsIndicator'] . "', '" . $_POST['Terms'] . "', 0, - " . $_POST['DayNumber'] . " + '" . $_POST['DayNumber'] . "' )"; } @@ -141,14 +139,14 @@ // PREVENT DELETES IF DEPENDENT RECORDS IN DebtorsMaster - $sql= "SELECT COUNT(*) FROM debtorsmaster WHERE debtorsmaster.paymentterms = '$SelectedTerms'"; + $sql= "SELECT COUNT(*) FROM debtorsmaster WHERE debtorsmaster.paymentterms = '" . $SelectedTerms . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0] > 0) { prnMsg( _('Cannot delete this payment term because customer accounts have been created referring to this term'),'warn'); echo '<br> ' . _('There are') . ' ' . $myrow[0] . ' ' . _('customer accounts that refer to this payment term'); } else { - $sql= "SELECT COUNT(*) FROM suppliers WHERE suppliers.paymentterms = '$SelectedTerms'"; + $sql= "SELECT COUNT(*) FROM suppliers WHERE suppliers.paymentterms = '" . $SelectedTerms . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0] > 0) { @@ -157,7 +155,7 @@ } else { //only delete if used in neither customer or supplier accounts - $sql="DELETE FROM paymentterms WHERE termsindicator='$SelectedTerms'"; + $sql="DELETE FROM paymentterms WHERE termsindicator='" . $SelectedTerms . "'"; $result = DB_query($sql,$db); prnMsg( _('The payment term definition record has been deleted') . '!','success'); } @@ -176,7 +174,8 @@ $sql = 'SELECT termsindicator, terms, daysbeforedue, dayinfollowingmonth FROM paymentterms'; $result = DB_query($sql, $db); - echo '<table border=1>'; + echo '<table class=selection>'; + echo '<tr><th colspan=6><font color=blue size=3>'._('Payment Terms.').'</font></th></tr>'; echo '<tr><th>' . _('Term Code') . '</th> <th>' . _('Description') . '</th> <th>' . _('Following Month On') . '</th> @@ -233,7 +232,7 @@ daysbeforedue, dayinfollowingmonth FROM paymentterms - WHERE termsindicator='$SelectedTerms'"; + WHERE termsindicator='" . $SelectedTerms . "'"; $result = DB_query($sql, $db); $myrow = DB_fetch_array($result); @@ -245,7 +244,9 @@ echo '<input type=hidden name="SelectedTerms" VALUE="' . $SelectedTerms . '">'; echo '<input type=hidden name="TermsIndicator" VALUE="' . $_POST['TermsIndicator'] . '">'; - echo '<table><tr><td>' . _('Term Code') . ':</td><td>'; + echo '<br><table class=selection>'; + echo '<tr><th colspan=6><font color=blue size=3>'._('Update Payment Terms.').'</font></th></tr>'; + echo '<tr><td>' . _('Term Code') . ':</td><td>'; echo $_POST['TermsIndicator'] . '</td></tr>'; } else { //end of if $SelectedTerms only do the else when a new record is being entered @@ -256,7 +257,9 @@ unset($DayInFollowingMonth); // Rather unset for a new record if (!isset($_POST['Terms'])) $_POST['Terms']=''; - echo '<table><tr><td>' . _('Term Code') . ':</td><td><input type="Text" name="TermsIndicator" + echo '<table class=selection>'; + echo '<tr><th colspan=6><font color=blue size=3>'._('New Payment Terms.').'</font></th></tr>'; + echo '<tr><td>' . _('Term Code') . ':</td><td><input type="Text" name="TermsIndicator" ' . (in_array('TermsIndicator',$Errors) ? 'class="inputerror"' : '' ) .' value="' . $_POST['TermsIndicator'] . '" size=3 maxlength=2></td></tr>'; } @@ -275,8 +278,8 @@ } else { if (isset($DayInFollowingMonth)) {echo $DayInFollowingMonth;} } - echo '></td></tr></table><div class="centre"><input type="Submit" name="submit" value="'._('Enter Information').'"></form></div>'; + echo '></td></tr></table><br><div class="centre"><input type="Submit" name="submit" value="'._('Enter Information').'"></form></div>'; } //end if record deleted no point displaying form to add record include('includes/footer.inc'); -?> +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-17 22:12:16 UTC (rev 3635) +++ trunk/doc/Change.log.html 2010-07-18 08:11:03 UTC (rev 3636) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>17/07/10 Tim: PaymentTerms.php - Bug fixes, SQL quoting and layout changes</p> <p>17/07/10 Tim: Payments.php - Bug fixes, SQL quoting and layout changes</p> <p>17/07/10 Tim: PaymentMethods.php - SQL quoting and layout changes</p> <p>17/07/10 Tim: PaymentAllocations.php - SQL quoting and layout changes</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dai...@us...> - 2010-07-18 09:39:14
|
Revision: 3637 http://web-erp.svn.sourceforge.net/web-erp/?rev=3637&view=rev Author: daintree Date: 2010-07-18 09:39:07 +0000 (Sun, 18 Jul 2010) Log Message: ----------- 18/07/10 Phil: CounterSales.php - was not retrieving ReceiptNumber if the debtor integration was disabled - also the correct period was not retrieved because the date format was not in the correct DateFormat because of a typo in SESSION[DefaultDateFormat] <p>18/07/10 Phil: New script ContractBOM.php to allow defining the bill of materials for a contract Further work on Contracts.php Modified Paths: -------------- trunk/Contracts.php trunk/CounterSales.php trunk/doc/Change.log.html trunk/includes/DefineContractClass.php trunk/includes/DefinePOClass.php Added Paths: ----------- trunk/ContractBOM.php Added: trunk/ContractBOM.php =================================================================== --- trunk/ContractBOM.php (rev 0) +++ trunk/ContractBOM.php 2010-07-18 09:39:07 UTC (rev 3637) @@ -0,0 +1,397 @@ +<?php + +/* $Id: $ */ + +$PageSecurity = 4; + +include('includes/DefineContractClass.php'); + +include('includes/session.inc'); +$title = _('Contract Bill of Materials'); + +$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'); + +$Maximum_Number_Of_Parts_To_Show=50; + +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]->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); + } else { + $_SESSION['Contract'.$identifier]->ContractBOM[$ContractComponent->ComponentID]->Quantity=$_POST['Qty'.$ContractComponent->ComponentID]; + } + } // end loop around the items on the contract BOM + } // 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($_POST['Search'])){ /*ie seach for stock items */ + + 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); + } + +} //end of if search + + +if(isset($_GET['Delete'])){ + if($_SESSION['Contract'.$identifier]->Status!=2){ + $_SESSION['Contract'.$identifier]->remove_ContractComponent($_GET['Delete']); + } else { + prnMsg( _('The contract BOM cannot be alterned because the customer has already placed the order'),'warn'); + } +} + + + +if (isset($_POST['NewItem'])){ /* NewItem is set from the part selection list as the part code selected */ +/* take the form entries and enter the data from the form into the PurchOrder class variable */ + foreach ($_POST as $key => $value) { + if (substr($key, 0, 3)=='qty') { + $ItemCode=substr($key, 3, strlen($key)-3); + $Quantity=$value; + $AlreadyOnThisBOM = 0; + + if (count($_SESSION['Contract'.$identifier]->ContractBOM)!=0){ + + foreach ($_SESSION['Contract'.$identifier]->ContractBOM AS $Component) { + + /* do a loop round the items on the order to see that the item + is not already on this order */ + if ($Component->StockID == $ItemCode) { + $AlreadyOnThisBOM = 1; + prnMsg( _('The item') . ' ' . $ItemCode . ' ' . _('is already in the bill of material for this contract. The system will not allow the same item on the contract more than once. However you can change the quantity required for the item.'),'error'); + } + } /* end of the foreach loop to look for preexisting items of the same code */ + } + + if ($AlreadyOnThisBOM!=1 and $Quantity>0){ + + $sql = "SELECT stockmaster.description, + stockmaster.stockid, + stockmaster.units, + stockmaster.decimalplaces, + stockmaster.materialcost+labourcost+overheadcost AS unitcost + FROM stockmaster + WHERE stockmaster.stockid = '". $ItemCode . "'"; + + $ErrMsg = _('The item details could not be retrieved'); + $DbgMsg = _('The SQL used to retrieve the item details but failed was'); + $result1 = DB_query($sql,$db,$ErrMsg,$DbgMsg); + + if ($myrow = DB_fetch_array($result1)){ + + $_SESSION['Contract'.$identifier]->Add_To_ContractBOM ($ItemCode, + $myrow['description'], + $DefaultWorkCentre, + $Quantity, /* Qty */ + $myrow['unitcost'], + $myrow['units']); + } else { + prnMsg (_('The item code') . ' ' . $ItemCode . ' ' . _('does not exist in the database and therefore cannot be added to the contract BOM'),'error'); + if ($debug==1){ + echo "<br>".$sql; + } + include('includes/footer.inc'); + exit; + } + } /* end of if not already on the contract BOM */ + } + } +} /* end of if its a new item */ + +/* This is where the order as selected should be displayed reflecting any deletions or insertions*/ + +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="' . + _('Contract Bill of Material') . '" alt=""> '.$_SESSION['Contract'.$identifier]->CustomerName; + + if (isset($_SESSION['Contract'.$identifier]->ContractRef)) { + echo ' ' . _('Contract Reference:') .' '. $_SESSION['Contract'.$identifier]->ContractRef; + } + + echo '<table cellpadding=2 colspan=7 border=1>'; + echo '<tr> + <th>' . _('Item Code') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Quantity') . '</th> + <th>' . _('UOM') .'</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]->ContractBOM as $ContractComponent) { + + $LineTotal = $ContractComponent->Quantity * $ContractComponent->ItemCost; + + $DisplayLineTotal = number_format($LineTotal,2); + + if ($k==1){ + echo '<tr class="EvenTableRows">'; + $k=0; + } else { + echo '<tr class="OddTableRows">'; + $k=1; + } + + echo '<td>' . $ContractComponent->StockID . '</td> + <td>' . $ContractComponent->ItemDescription . '</td> + <td><input type=text class="number" name="Qty' . $ContractComponent->ComponentID . '" size="11" value="' . $ContractComponent->Quantity . '"></td> + <td>' . $ContractComponent->UOM . '</td> + <td class="number">' . $ContractComponent->ItemCost . '</td> + <td class="number">' . $DisplayLineTotal . '</td> + <td><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . 'identifier='.$identifier. '&Delete=' . $ContractComponent->ComponentID . '">' . _('Delete') . '</a></td></tr>'; + $TotalCost += $LineTotal; + } + + $DisplayTotal = number_format($TotalCost,2); + echo '<tr><td colspan=6 class="number">' . _('Total Cost') . '</td><td class="number"><b>' . $DisplayTotal . '</b></td></tr></table>'; + echo '<br><div class="centre"><input type="submit" name="UpdateLines" value="' . _('Update Order Lines') . '">'; + echo ' <input type="submit" name="BackToHeader" value="' . _('Back To Contract Header') . '">'; + +} /*Only display the contract BOM lines if there are any !! */ + +if (!isset($_GET['Edit'])) { + $sql="SELECT categoryid, + categorydescription + FROM stockcategory + WHERE stocktype<>'L' + AND stocktype<>'D' + ORDER BY categorydescription"; + $ErrMsg = _('The supplier category details could not be retrieved because'); + $DbgMsg = _('The SQL used to retrieve the category details but failed was'); + $result1 = DB_query($sql,$db,$ErrMsg,$DbgMsg); + + echo '<table class=selection><tr><p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/magnifier.png" title="' . + _('Print') . '" alt="">' . ' ' . _('Search For Stock Items') . ''; + + echo ":</font></tr><tr><td><select name='StockCat'>"; + + echo "<option selected value='All'>" . _('All'); + while ($myrow1 = DB_fetch_array($result1)) { + if (isset($_POST['StockCat']) and $_POST['StockCat']==$myrow1['categoryid']){ + echo "<option selected value=". $myrow1['categoryid'] . '>' . $myrow1['categorydescription']; + } else { + echo "<option value=". $myrow1['categoryid'] . '>' . $myrow1['categorydescription']; + } + } + + unset($_POST['Keywords']); + unset($_POST['StockCode']); + + if (!isset($_POST['Keywords'])) { + $_POST['Keywords']=''; + } + + if (!isset($_POST['StockCode'])) { + $_POST['StockCode']=''; + } + + echo '</select></td> + <td><font size=2>' . _('Enter text extracts in the description') . ":</font></td> + <td><input type='text' name='Keywords' size=20 maxlength=25 value='" . $_POST['Keywords'] . "'></td></tr> + <tr><td></td> + <td><font size=3><b>" . _('OR') . ' </b></font><font size=2>' . _('Enter extract of the Stock Code') . + ":</font></td> + <td><input type='text' name='StockCode' size=15 maxlength=18 value='" . $_POST['StockCode'] . "'></td> + </tr> + <tr><td></td> + <td><font size=3><b>" . _('OR') . ' </b></font><font size=2><a target="_blank" href="'.$rootpath.'/Stocks.php?"' . SID . + '">' . _('Create a New Stock Item') . "</a></font></td></tr> + </table><br> + <div class='centre'><input type=submit name='Search' value='" . _('Search Now') . "'> + </div><br>"; + + + $PartsDisplayed =0; +} + +if (isset($SearchResult)) { + + echo '<table cellpadding=1 colspan=7>'; + + $tableheader = '<tr> + <th>' . _('Code') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Units') . '</th> + <th>' . _('Image') . '</th> + <th>' . _('Quantity') . '</th + </tr>'; + echo $tableheader; + + $j = 1; + $k=0; //row colour counter + + 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'] . '/' . $filename . '" width="50" height="50">'; + } else { + $ImageSource = '<i>'._('No Image').'</i>'; + } + + echo '<td>'.$myrow['stockid'].'</td> + <td>'.$myrow['description'].'</td> + <td>'.$myrow['units'] . '</td> + <td>'.$ImageSource.'</td> + <td><input class="number" type="text" size="6" value="0" name="qty'.$myrow['stockid'].'"></td> + </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 '<br><div class="centre"><input type="submit" name="NewItem" value="' . _('Add to Contract Bill Of Material') .'"></div>'; +}#end if SearchResults to show + +echo '<hr>'; + +echo '</form>'; +include('includes/footer.inc'); +?> \ No newline at end of file Modified: trunk/Contracts.php =================================================================== --- trunk/Contracts.php 2010-07-18 08:11:03 UTC (rev 3636) +++ trunk/Contracts.php 2010-07-18 09:39:07 UTC (rev 3637) @@ -33,11 +33,8 @@ $identifier=$_GET['identifier']; } -/*Page is called with NewContract=Yes when a new order is to be entered - * the session variable that holds all the Contract data $_SESSION['Contract'][$identifier] - * is unset to allow all new details to be created */ -if (isset($_GET['NewContract']) and isset($_SESSION['Contract'.$identifier])){ +if (isset($_GET['NewContract']) AND isset($_SESSION['Contract'.$identifier])){ unset($_SESSION['Contract'.$identifier]); $_SESSION['ExistingContract'] = 0; } @@ -53,21 +50,21 @@ /* initialize new class object */ $_SESSION['Contract'.$identifier] = new Contract; - $_SESSION['RequireCustomerSelection'] = 0; $_POST['SelectedCustomer'] = $_GET['SelectedCustomer']; + + $_SESSION['Contract'.$identifier]->Status =0; /*The customer is checked for credit and the Contract Object populated * using the usual logic of when a customer is selected * */ } -if (isset($_POST['EnterContractBOM']) OR isset($_POST['EnterContractRequirements'])){ -/*User hit the button to enter line items - - * ensure session variables updated then meta refresh to Contract_Items.php*/ - +if(isset($_SESSION['Contract'.$identifier]) AND + (isset($_POST['EnterContractBOM']) + OR isset($_POST['EnterContractRequirements']))){ + /** Ensure session variables updated */ + $_SESSION['Contract'.$identifier]->ContractRef=$_POST['ContractRef']; $_SESSION['Contract'.$identifier]->ContractDescription=$_POST['ContractDescription']; - $_SESSION['Contract'.$identifier]->DebtorNo = $_POST['DebtorNo']; - $_SESSION['Contract'.$identifier]->BranchCode = $_POST['BranchCode']; $_SESSION['Contract'.$identifier]->CategoryID = $_POST['CategoryID']; $_SESSION['Contract'.$identifier]->RequiredDate = $_POST['RequiredDate']; $_SESSION['Contract'.$identifier]->Margin = $_POST['Margin']; @@ -75,8 +72,18 @@ $_SESSION['Contract'.$identifier]->QuantityReqd = $_POST['QuantityReqd']; $_SESSION['Contract'.$identifier]->Units = $_POST['Units']; $_SESSION['Contract'.$identifier]->ExRate = $_POST['ExRate']; - if (isset($_POST['EnterContractBOM'])){ - echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . '/Contract_Items.php?' . SID . 'identifier='.$identifier. "'>"; + + +/*User hit the button to enter line items - + then meta refresh to Contract_Items.php*/ + $InputError = false; + if(strlen($_SESSION['Contract'.$identifier]->ContractRef)<2){ + prnMsg(_('The contract reference must be entered (and be longer than 2 characters) before the requirements of the contract can be setup'),'warn'); + $InputError = true; + } + + if (isset($_POST['EnterContractBOM']) AND !$InputError){ + echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . '/ContractBOM.php?' . SID . 'identifier='.$identifier. "'>"; echo '<p>'; prnMsg(_('You should automatically be forwarded to the entry of the Contract line items page') . '. ' . _('If this does not happen') . ' (' . _('if the browser does not support META Refresh') . ') ' . @@ -84,7 +91,7 @@ include('includes/footer.inc'); exit; } - if (isset($_POST['EnterContractRequirements'])){ + if (isset($_POST['EnterContractRequirements']) AND !$InputError){ echo "<meta http-equiv='Refresh' content='0; url=" . $rootpath . '/ContractRequirements.php?' . SID . 'identifier='.$identifier. "'>"; echo '<p>'; prnMsg(_('You should automatically be forwarded to the entry of the Contract requirements page') . '. ' . @@ -95,7 +102,7 @@ } } /* 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 . '/ContractSelect.php?' . SID . 'identifier='.$identifier.'">'. _('Back to Contracts'). '</a><br>'; //attempting to upload the drawing image file if (isset($_FILES['Drawing']) AND $_FILES['Drawing']['name'] !='' AND $_SESSION['Contract'.$identifier]->ContractRef!='') { @@ -256,21 +263,18 @@ $ErrMsg = _('The contract bill of materials could not be deleted because'); $DelResult=DB_query($sql,$db,$ErrMsg); $sql = "DELETE FROM contractreqts WHERE contractref='" . $_SESSION['Contract'.$identifier]->ContractRef . "'"; - $ErrMsg = _('The contract requirments could not be deleted because'); + $ErrMsg = _('The contract requirements could not be deleted because'); $DelResult=DB_query($sql,$db,$ErrMsg); $sql= "DELETE FROM contracts WHERE contractref='" . $_SESSION['Contract'.$identifier]->ContractRef . "'"; $ErrMsg = _('The contract could not be deleted because'); $DelResult=DB_query($sql,$db,$ErrMsg); prnMsg( _('Contract').' '.$_SESSION['Contract'.$identifier]->ContractRef.' '._('has been cancelled'), 'success'); - unset($_SESSION['Contract'.$identifier]); unset($_SESSION['ExistingContract']); } unset($_SESSION['Contract'.$identifier]->ContractBOM); unset($_SESSION['Contract'.$identifier]->ContractReqts); unset($_SESSION['Contract'.$identifier]); - $_SESSION['Contract'.$identifier] = new Contract; - $_SESSION['RequireCustomerSelection'] = 1; } } @@ -284,6 +288,8 @@ $_SESSION['ExistingContract']= 0; $_SESSION['Contract'.$identifier] = new Contract; + $_SESSION['Contract'.$identifier]->Status = 0; //new contracts are just quotes ... + if ($_SESSION['Contract'.$identifier]->DebtorNo=='' OR !isset($_SESSION['Contract'.$identifier]->DebtorNo)){ /* a session variable will have to maintain if a supplier @@ -428,8 +434,7 @@ " . $Requirement->Quantity . ")"; $result = DB_query($sql,$db,$ErrMsg); } - - + prnMsg(_('The changes to the contract have been committed to the database'),'success'); } if ($ExistingContract['status']==1 AND ! $InputError){ @@ -638,8 +643,7 @@ } //end if a customer has just been selected -if ($_SESSION['RequireCustomerSelection'] == 1 - OR !isset($_SESSION['Contract'.$identifier]->DebtorNo) +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="' . @@ -724,9 +728,6 @@ } echo '</p>'; - //echo '<meta http-equiv="refresh" content="0; url=' . $rootpath . '/Contract_Items.php?' . SID . '&identifier='.$identifier. '">'; - - /*Set up form for entry of contract header stuff */ echo '<table>'; @@ -799,7 +800,7 @@ echo '<tr><td>' . _('Contract Status') . ':</td><td><select name="Status">'; $StatusText = array(); - $StatusText[0] = _('Costing'); + $StatusText[0] = _('Setup'); $StatusText[1] = _('Quote'); $StatusText[2] = _('Completed'); for ($Status=0;$Status<3;$Status++) { @@ -868,7 +869,7 @@ echo'<p></p>'; echo '<div class="centre"><input type="submit" name="EnterContractBOM" value="' . _('Enter Items Required') . '"> - <input type=submit name="EnterContractReqts" value="' . _('Enter Other Requirements') .'"> + <input type=submit name="EnterContractRequirements" value="' . _('Enter Other Requirements') .'"> <input type=submit name="CommitContract" value="' . _('Commit Changes') .'"></div>'; if ($_SESSION['Contract'.$identifier]->Status!=2) { echo '<p><div class="centre"><input type="submit" name="CancelContract" value="' . _('Cancel and Delete Contract') . '"></div></p>'; Modified: trunk/CounterSales.php =================================================================== --- trunk/CounterSales.php 2010-07-18 08:11:03 UTC (rev 3636) +++ trunk/CounterSales.php 2010-07-18 09:39:07 UTC (rev 3637) @@ -1148,7 +1148,7 @@ * GetPeriod() in includes/DateFunctions.inc */ $InvoiceNo = GetNextTransNo(10, $db); - $PeriodNo = GetPeriod(Date($SESSION['DefaultDateFormat']), $db); + $PeriodNo = GetPeriod(Date($_SESSION['DefaultDateFormat']), $db); /*Start an SQL transaction */ @@ -1774,106 +1774,111 @@ $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); }//amount paid we not zero } /*end of if Sales and GL integrated */ - //Now need to add the receipt banktrans record - //First get the account currency that it has been banked into - $result = DB_query("SELECT rate FROM currencies - INNER JOIN bankaccounts ON currencies.currabrev=bankaccounts.currcode - WHERE bankaccounts.accountcode='" . $_POST['BankAccount'] . "'",$db); - $myrow = DB_fetch_row($result); - $BankAccountExRate = $myrow[0]; + if ($_POST['AmountPaid']!=0){ + if (!isset($ReceiptNumber)){ + $ReceiptNumber = GetNextTransNo(12,$db); + } + //Now need to add the receipt banktrans record + //First get the account currency that it has been banked into + $result = DB_query("SELECT rate FROM currencies + INNER JOIN bankaccounts ON currencies.currabrev=bankaccounts.currcode + WHERE bankaccounts.accountcode='" . $_POST['BankAccount'] . "'",$db); + $myrow = DB_fetch_row($result); + $BankAccountExRate = $myrow[0]; + + /* + * Some interesting exchange rate conversion going on here + * Say : + * The business's functional currency is NZD + * Customer location counter sales are in AUD - 1 NZD = 0.80 AUD + * Banking money into a USD account - 1 NZD = 0.68 USD + * + * Customer sale is for $100 AUD + * GL entries conver the AUD 100 to NZD - 100 AUD / 0.80 = $125 NZD + * Banktrans entries convert the AUD 100 to USD using 100/0.8 * 0.68 + */ + + //insert the banktrans record in the currency of the bank account + + $SQL='INSERT INTO banktrans (type, + transno, + bankact, + ref, + exrate, + functionalexrate, + transdate, + banktranstype, + amount, + currcode) + VALUES (12, + ' . $ReceiptNumber . ', + ' . $_POST['BankAccount'] . ", + '" . $_SESSION['Items'.$identifier]->LocationName . ' ' . _('Counter Sale') . ' ' . $InvoiceNo . "', + " . $ExRate . ", + " . $BankAccountExRate . ", + '" . $DefaultDispatchDate . "', + '" . $_POST['PaymentMethod'] . "', + " . ($_POST['AmountPaid'] * $BankAccountExRate) . ", + '" . $_SESSION['Items'.$identifier]->DefaultCurrency . "')"; + + $DbgMsg = _('The SQL that failed to insert the bank account transaction was'); + $ErrMsg = _('Cannot insert a bank transaction'); + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - /* - * Some interesting exchange rate conversion going on here - * Say : - * The business's functional currency is NZD - * Customer location counter sales are in AUD - 1 NZD = 0.80 AUD - * Banking money into a USD account - 1 NZD = 0.68 USD - * - * Customer sale is for $100 AUD - * GL entries conver the AUD 100 to NZD - 100 AUD / 0.80 = $125 NZD - * Banktrans entries convert the AUD 100 to USD using 100/0.8 * 0.68 - */ - - //insert the banktrans record in the currency of the bank account - - $SQL='INSERT INTO banktrans (type, - transno, - bankact, - ref, - exrate, - functionalexrate, - transdate, - banktranstype, - amount, - currcode) - VALUES (12, - ' . $ReceiptNumber . ', - ' . $_POST['BankAccount'] . ", - '" . $_SESSION['Items'.$identifier]->LocationName . ' ' . _('Counter Sale') . ' ' . $InvoiceNo . "', - " . $ExRate . ", - " . $BankAccountExRate . ", - '" . $DefaultDispatchDate . "', - '" . $_POST['PaymentMethod'] . "', - " . ($_POST['AmountPaid'] * $BankAccountExRate) . ", - '" . $_SESSION['Items'.$identifier]->DefaultCurrency . "')"; - - $DbgMsg = _('The SQL that failed to insert the bank account transaction was'); - $ErrMsg = _('Cannot insert a bank transaction'); - $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + //insert a new debtortrans for the receipt + + $SQL = 'INSERT INTO debtortrans (transno, + type, + debtorno, + trandate, + inputdate, + prd, + reference, + rate, + ovamount, + alloc, + invtext) + VALUES (' . $ReceiptNumber . ", + 12, + '" . $_SESSION['Items'.$identifier]->DebtorNo . "', + '" . $DefaultDispatchDate . "', + '" . date('Y-m-d H-i-s') . "', + " . $PeriodNo . ", + " . $InvoiceNo . ", + " . $ExRate . ", + " . -$_POST['AmountPaid'] . ", + " . -$_POST['AmountPaid'] . ", + '" . $_SESSION['Items'.$identifier]->LocationName . ' ' . _('Counter Sale') ."')"; + + $DbgMsg = _('The SQL that failed to insert the customer receipt transaction was'); + $ErrMsg = _('Cannot insert a receipt transaction against the customer because') ; + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - //insert a new debtortrans for the receipt + $ReceiptDebtorTransID = DB_Last_Insert_ID($db,'debtortrans','id'); + + $SQL = "UPDATE debtorsmaster SET lastpaiddate = '" . $DefaultDispatchDate . "', + lastpaid=" . $_POST['AmountPaid'] ." + WHERE debtorsmaster.debtorno='" . $_SESSION['Items'.$identifier]->DebtorNo . "'"; + + $DbgMsg = _('The SQL that failed to update the date of the last payment received was'); + $ErrMsg = _('Cannot update the customer record for the date of the last payment received because'); + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + + //and finally add the allocation record between receipt and invoice + + $SQL = 'INSERT INTO custallocns ( amt, + datealloc, + transid_allocfrom, + transid_allocto ) + VALUES (' . $_POST['AmountPaid'] . ", + '" . $DefaultDispatchDate . "', + " . $ReceiptDebtorTransID . ", + " . $DebtorTransID . ')'; + $DbgMsg = _('The SQL that failed to insert the allocation of the receipt to the invoice was'); + $ErrMsg = _('Cannot insert the customer allocation of the receipt to the invoice because'); + $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); + } //end if $_POST['AmountPaid']!= 0 - $SQL = 'INSERT INTO debtortrans (transno, - type, - debtorno, - trandate, - inputdate, - prd, - reference, - rate, - ovamount, - alloc, - invtext) - VALUES (' . $ReceiptNumber . ", - 12, - '" . $_SESSION['Items'.$identifier]->DebtorNo . "', - '" . $DefaultDispatchDate . "', - '" . date('Y-m-d H-i-s') . "', - " . $PeriodNo . ", - " . $InvoiceNo . ", - " . $ExRate . ", - " . -$_POST['AmountPaid'] . ", - " . -$_POST['AmountPaid'] . ", - '" . $_SESSION['Items'.$identifier]->LocationName . ' ' . _('Counter Sale') ."')"; - - $DbgMsg = _('The SQL that failed to insert the customer receipt transaction was'); - $ErrMsg = _('Cannot insert a receipt transaction against the customer because') ; - $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - - $ReceiptDebtorTransID = DB_Last_Insert_ID($db,'debtortrans','id'); - - $SQL = "UPDATE debtorsmaster SET lastpaiddate = '" . $DefaultDispatchDate . "', - lastpaid=" . $_POST['AmountPaid'] ." - WHERE debtorsmaster.debtorno='" . $_SESSION['Items'.$identifier]->DebtorNo . "'"; - - $DbgMsg = _('The SQL that failed to update the date of the last payment received was'); - $ErrMsg = _('Cannot update the customer record for the date of the last payment received because'); - $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - - //and finally add the allocation record between receipt and invoice - - $SQL = 'INSERT INTO custallocns ( amt, - datealloc, - transid_allocfrom, - transid_allocto ) - VALUES (' . $_POST['AmountPaid'] . ", - '" . $DefaultDispatchDate . "', - " . $ReceiptDebtorTransID . ", - " . $DebtorTransID . ')'; - $DbgMsg = _('The SQL that failed to insert the allocation of the receipt to the invoice was'); - $ErrMsg = _('Cannot insert the customer allocation of the receipt to the invoice because'); - $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - DB_Txn_Commit($db); // ************************************************************************* // E N D O F I N V O I C E S Q L P R O C E S S I N G Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-18 08:11:03 UTC (rev 3636) +++ trunk/doc/Change.log.html 2010-07-18 09:39:07 UTC (rev 3637) @@ -1,5 +1,8 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>18/07/10 Phil: CounterSales.php - was not retrieving ReceiptNumber if the debtor integration was disabled - also the correct period was not retrieved because the date format was not in the correct DateFormat because of a typo in SESSION['DefaultDateFormat'] +<p>18/07/10 Phil: New script ContractBOM.php to allow defining the bill of materials for a contract +<p>18/07/10 Phil: Further work on Contracts.php <p>17/07/10 Tim: PaymentTerms.php - Bug fixes, SQL quoting and layout changes</p> <p>17/07/10 Tim: Payments.php - Bug fixes, SQL quoting and layout changes</p> <p>17/07/10 Tim: PaymentMethods.php - SQL quoting and layout changes</p> Modified: trunk/includes/DefineContractClass.php =================================================================== --- trunk/includes/DefineContractClass.php 2010-07-18 08:11:03 UTC (rev 3636) +++ trunk/includes/DefineContractClass.php 2010-07-18 09:39:07 UTC (rev 3637) @@ -41,7 +41,8 @@ function Add_To_ContractBOM($StockID, $ItemDescription, $WorkCentre, $Quantity, $ItemCost, $UOM){ if (isset($StockID) AND $Quantity!=0){ - $this->ContractBOM[$this->BOMComponentCounter] = new ContractComponent($StockID, + $this->ContractBOM[$this->BOMComponentCounter] = new ContractComponent($this->BOMComponentCounter, + $StockID, $ItemDescription, $WorkCentre, $Quantity, @@ -76,7 +77,7 @@ } /* end of class defintion */ Class ContractComponent { - + var $ComponentID; var $StockID; var $ItemDescription; var $WorkCentre; @@ -84,9 +85,10 @@ var $ItemCost; var $UOM; - function ContractComponent ($StockID, $ItemDescription, $WorkCentre, $Quantity, $ItemCost, $UOM){ + function ContractComponent ($ComponentID, $StockID, $ItemDescription, $WorkCentre, $Quantity, $ItemCost, $UOM){ /* Constructor function to add a new Contract Component object with passed params */ + $this->ComponentID = $ComponentID; $this->StockID = $StockID; $this->ItemDescription = $ItemDescription; $this->WorkCentre = $WorkCentre; Modified: trunk/includes/DefinePOClass.php =================================================================== --- trunk/includes/DefinePOClass.php 2010-07-18 08:11:03 UTC (rev 3636) +++ trunk/includes/DefinePOClass.php 2010-07-18 09:39:07 UTC (rev 3637) @@ -96,17 +96,17 @@ $DecimalPlaces=2, $itemno, $uom, - $ConversionFactor, - $leadtime, - $suppliers_partno, - $subtotal_amount, - $package, - $pcunit, - $nw, - $gw, - $cuft, - $total_quantity, - $total_amount){ + $ConversionFactor=1, + $leadtime=1, + $suppliers_partno='', + $subtotal_amount=0, + $package=0, + $pcunit=0, + $nw=0, + $gw=0, + $cuft=0, + $total_quantity=0, + $total_amount=0){ if ($Qty!=0 && isset($Qty)){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-18 10:31:05
|
Revision: 3638 http://web-erp.svn.sourceforge.net/web-erp/?rev=3638&view=rev Author: tim_schofield Date: 2010-07-18 10:30:59 +0000 (Sun, 18 Jul 2010) Log Message: ----------- Provide option for tagging stock adjustments, change layout, allow for searching for a part code, and sql quoting Modified Paths: -------------- trunk/StockAdjustments.php trunk/doc/Change.log.html trunk/includes/DefineStockAdjustment.php Modified: trunk/StockAdjustments.php =================================================================== --- trunk/StockAdjustments.php 2010-07-18 09:39:07 UTC (rev 3637) +++ trunk/StockAdjustments.php 2010-07-18 10:30:59 UTC (rev 3638) @@ -14,23 +14,30 @@ if (isset($_GET['NewAdjustment'])){ unset($_SESSION['Adjustment']); - $_SESSION['Adjustment'] = new StockAdjustment; + $_SESSION['Adjustment'] = new StockAdjustment(); } if (!isset($_SESSION['Adjustment'])){ - $_SESSION['Adjustment'] = new StockAdjustment; + $_SESSION['Adjustment'] = new StockAdjustment(); } $NewAdjustment = false; if (isset($_GET['StockID'])){ - $_SESSION['Adjustment']->StockID = trim(strtoupper($_GET['StockID'])); + $StockID = trim(strtoupper($_GET['StockID'])); + $_SESSION['Adjustment']->StockID = trim(strtoupper($StockID)); + $_SESSION['Adjustment']->ItemDescription = trim(strtoupper($_GET['Description'])); + $result = DB_query("SELECT controlled FROM stockmaster WHERE stockid='" . $_SESSION['Adjustment']->StockID . "'",$db); + $myrow = DB_fetch_row($result); + $_SESSION['Adjustment']->Controlled = $myrow[0]; $NewAdjustment = true; } elseif (isset($_POST['StockID'])){ if(isset($_POST['StockID']) and $_POST['StockID'] != $_SESSION['Adjustment']->StockID){ $NewAdjustment = true; $_SESSION['Adjustment']->StockID = trim(strtoupper($_POST['StockID'])); + $StockID = trim(strtoupper($_POST['StockID'])); } + $_SESSION['Adjustment']->tag = $_POST['tag']; $_SESSION['Adjustment']->Narrative = $_POST['Narrative']; $_SESSION['Adjustment']->StockLocation = $_POST['StockLocation']; if ($_POST['Quantity']=='' or !is_numeric($_POST['Quantity'])){ @@ -42,43 +49,26 @@ echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/supplier.png" title="' . _('Inventory Adjustment') . '" alt="">' . ' ' . _('Inventory Adjustment') . '</p>'; -if ($NewAdjustment){ +if (isset($_POST['CheckCode'])) { - $sql ="SELECT description, - units, - mbflag, - materialcost+labourcost+overheadcost as standardcost, - controlled, - serialised, - decimalplaces - FROM stockmaster - WHERE stockid='" . $_SESSION['Adjustment']->StockID . "'"; - $ErrMsg = _('Unable to load StockMaster info for part'). ':' . $_SESSION['Adjustment']->StockID; - $result = DB_query($sql, $db, $ErrMsg); - $myrow = DB_fetch_row($result); + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/magnifier.png" title="' . _('Dispatch') . + '" alt="">' . ' ' . _('Select Item to Adjust') . ''; - if (DB_num_rows($result)==0){ - prnMsg( _('Unable to locate Stock Code').' '.$_SESSION['Adjustment']->StockID, 'error' ); - unset($_SESSION['Adjustment']); - } elseif (DB_num_rows($result)>0){ - - $_SESSION['Adjustment']->ItemDescription = $myrow[0]; - $_SESSION['Adjustment']->PartUnit = $myrow[1]; - $_SESSION['Adjustment']->StandardCost = $myrow[3]; - $_SESSION['Adjustment']->Controlled = $myrow[4]; - $_SESSION['Adjustment']->Serialised = $myrow[5]; - $_SESSION['Adjustment']->DecimalPlaces = $myrow[6]; - $_SESSION['Adjustment']->SerialItems = array(); - - if ($myrow[2]=='D' OR $myrow[2]=='A' OR $myrow[2]=='K'){ - prnMsg( _('The part entered is either or a dummy part or an assembly or kit-set part') . '. ' . _('These parts are not physical parts and no stock holding is maintained for them') . '. ' . _('Stock adjustments are therefore not possible'),'error'); - echo '<hr>'; - echo '<a href="'. $rootpath .'/StockAdjustments.php?' . SID .'">'. _('Enter another adjustment'). '</a>'; - unset ($_SESSION['Adjustment']); - include ('includes/footer.inc'); - exit; - } + if (strlen($_POST['StockText'])>0) { + $sql='SELECT stockid, description from stockmaster where description like "%'.$_POST['StockText'].'%"'; + } else { + $sql='SELECT stockid, description from stockmaster where stockid like "%'.$_POST['StockCode'].'%"'; } + $ErrMsg=_('The stock information cannot be retrieved because'); + $DbgMsg=_('The SQL to get the stock description was'); + $result = DB_query($sql,$db,$ErrMsg,$DbgMsg); + echo '<table class=selection><tr><th>'._('Stock Code').'</th><th>'._('Stock Description').'</th></tr>'; + while ($myrow = DB_fetch_row($result)) { + echo '<tr><td>'.$myrow[0].'</td><td>'.$myrow[1].'</td><td><a href="StockAdjustments.php?StockID='.$myrow[0].'&Description='.$myrow[1].'">'._('Adjust').'</a></tr>'; + } + echo '</table>'; + include('includes/footer.inc'); + exit; } if (isset($_POST['EnterAdjustment']) && $_POST['EnterAdjustment']!= ''){ @@ -149,13 +139,13 @@ VALUES ( '" . $_SESSION['Adjustment']->StockID . "', 17, - " . $AdjustmentNumber . ", + '" . $AdjustmentNumber . "', '" . $_SESSION['Adjustment']->StockLocation . "', '" . $SQLAdjustmentDate . "', - " . $PeriodNo . ", + '" . $PeriodNo . "', '" . $_SESSION['Adjustment']->Narrative ."', - " . $_SESSION['Adjustment']->Quantity . ", - " . ($QtyOnHandPrior + $_SESSION['Adjustment']->Quantity) . " + '" . $_SESSION['Adjustment']->Quantity . "', + '" . ($QtyOnHandPrior + $_SESSION['Adjustment']->Quantity) . "' )"; @@ -208,7 +198,8 @@ '" . $_SESSION['Adjustment']->StockLocation . "', '" . $Item->BundleRef . "', '', - " . $Item->BundleQty . ")"; + '" . $Item->BundleQty . "' + )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The serial stock item record could not be updated because'); $DbgMsg = _('The following SQL to update the serial stock item record was used'); @@ -222,10 +213,10 @@ stockid, serialno, moveqty) - VALUES (" . $StkMoveNo . ", + VALUES ('" . $StkMoveNo . "', '" . $_SESSION['Adjustment']->StockID . "', '" . $Item->BundleRef . "', - " . $Item->BundleQty . ")"; + '" . $Item->BundleQty . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The serial stock movement record could not be inserted because'); $DbgMsg = _('The following SQL to insert the serial stock movement records was used'); $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true); @@ -235,7 +226,7 @@ - $SQL = "UPDATE locstock SET quantity = quantity + " . $_SESSION['Adjustment']->Quantity . " + $SQL = "UPDATE locstock SET quantity = quantity + '" . $_SESSION['Adjustment']->Quantity . "' WHERE stockid='" . $_SESSION['Adjustment']->StockID . "' AND loccode='" . $_SESSION['Adjustment']->StockLocation . "'"; @@ -254,14 +245,18 @@ periodno, account, amount, - narrative) + narrative, + tag) VALUES (17, - " .$AdjustmentNumber . ", + '" .$AdjustmentNumber . "', '" . $SQLAdjustmentDate . "', - " . $PeriodNo . ", - " . $StockGLCodes['adjglact'] . ", - " . $_SESSION['Adjustment']->StandardCost * -($_SESSION['Adjustment']->Quantity) . ", - '" . $_SESSION['Adjustment']->StockID . " x " . $_SESSION['Adjustment']->Quantity . " @ " . $_SESSION['Adjustment']->StandardCost . " " . $_SESSION['Adjustment']->Narrative . "')"; + '" . $PeriodNo . "', + '" . $StockGLCodes['adjglact'] . "', + '" . $_SESSION['Adjustment']->StandardCost * -($_SESSION['Adjustment']->Quantity) . "', + '" . $_SESSION['Adjustment']->StockID . " x " . $_SESSION['Adjustment']->Quantity . " @ " . + $_SESSION['Adjustment']->StandardCost . " " . $_SESSION['Adjustment']->Narrative . "', + '" . $_SESSION['Adjustment']->tag . "' + )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The general ledger transaction entries could not be added because'); $DbgMsg = _('The following SQL to insert the GL entries was used'); @@ -273,14 +268,17 @@ periodno, account, amount, - narrative) + narrative, + tag) VALUES (17, - " .$AdjustmentNumber . ", + '" .$AdjustmentNumber . "', '" . $SQLAdjustmentDate . "', - " . $PeriodNo . ", - " . $StockGLCodes['stockact'] . ", - " . $_SESSION['Adjustment']->StandardCost * $_SESSION['Adjustment']->Quantity . ", - '" . $_SESSION['Adjustment']->StockID . " x " . $_SESSION['Adjustment']->Quantity . " @ " . $_SESSION['Adjustment']->StandardCost . " " . $_SESSION['Adjustment']->Narrative . "')"; + '" . $PeriodNo . "', + '" . $StockGLCodes['stockact'] . "', + '" . $_SESSION['Adjustment']->StandardCost * $_SESSION['Adjustment']->Quantity . "', + '" . $_SESSION['Adjustment']->StockID . " x " . $_SESSION['Adjustment']->Quantity . " @ " . $_SESSION['Adjustment']->StandardCost . " " . $_SESSION['Adjustment']->Narrative . "', + '" . $_SESSION['Adjustment']->tag . "' + )"; $Errmsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The general ledger transaction entries could not be added because'); $DbgMsg = _('The following SQL to insert the GL entries was used'); @@ -307,11 +305,35 @@ $StockID = $_SESSION['Adjustment']->StockID; $Controlled = $_SESSION['Adjustment']->Controlled; $Quantity = $_SESSION['Adjustment']->Quantity; + $sql="SELECT materialcost, labourcost, overheadcost, units FROM stockmaster WHERE stockid='".$StockID."'"; + $result=DB_query($sql, $db); + $myrow=DB_fetch_array($result); + $_SESSION['Adjustment']->PartUnit=$myrow['units']; + $_SESSION['Adjustment']->StandardCost=$myrow['materialcost']+$myrow['labourcost']+$myrow['overheadcost']; } -echo '<br><table class=selection><tr><td>'. _('Stock Code'). ':</td><td><input type=text name="StockID" size=21 value="' . $StockID . '" maxlength=20> <input type=submit name="CheckCode" VALUE="'._('Check Part').'"></td></tr>'; - +echo '<br><table class=selection>'; +echo '<tr><th colspan=4><font color=blue size=3>'._('Adjustment Details').'</font></th></tr>'; +if (!isset($_GET['Description'])) { + $_GET['Description']=''; +} +echo '<tr><td>'. _('Stock Code'). ':</td><td>'; +if (isset($StockID)) { + echo '<input type=text name="StockID" size=21 value="' . $StockID . '" maxlength=20></td></tr>'; +} else { + echo '<input type=text name="StockID" size=21 value="" maxlength=20></td></tr>'; +} +echo '<tr><td>'. _('Partial Description'). ':</td><td><input type=text name="StockText" size=21 value="' . + $_GET['Description'] .'"> '._('Partial Stock Code'). ':</td><td>'; +if (isset($StockID)) { + echo '<input type=text name="StockCode" size=21 value="' . $StockID .'" maxlength=20>'; +} else { + echo '<input type=text name="StockCode" size=21 value="" maxlength=20>'; +} +echo '</td><td><input type=submit name="CheckCode" VALUE="'._('Check Part').'"></td></tr>'; if (isset($_SESSION['Adjustment']) and strlen($_SESSION['Adjustment']->ItemDescription)>1){ - echo '<tr><td colspan=3><font color=BLUE size=3>' . $_SESSION['Adjustment']->ItemDescription . ' ('._('In Units of').' ' . $_SESSION['Adjustment']->PartUnit . ' ) - ' . _('Unit Cost').' = ' . $_SESSION['Adjustment']->StandardCost . '</font></td></tr>'; + echo '<tr><td colspan=3><font color=BLUE size=3>' . $_SESSION['Adjustment']->ItemDescription . ' ('._('In Units of').' ' . + $_SESSION['Adjustment']->PartUnit . ' ) - ' . _('Unit Cost').' = ' . + number_format($_SESSION['Adjustment']->StandardCost,4) . '</font></td></tr>'; } echo '<tr><td>'. _('Adjustment to Stock At Location').':</td><td><select name="StockLocation"> '; @@ -357,15 +379,33 @@ echo '<input type=TEXT class="number" name="Quantity" size=12 maxlength=12 Value="' . $Quantity . '">'; } echo '</td></tr>'; + //Select the tag +echo '<tr><td>'._('Select Tag').'</td><td><select name="tag">'; -echo '</table><div class="centre"><br><input type=submit name="EnterAdjustment" VALUE="'. _('Enter Stock Adjustment'). '">'; -echo '<hr>'; +$SQL = "SELECT tagref, + tagdescription + FROM tags + ORDER BY tagref"; +$result=DB_query($SQL,$db); +echo '<option value=0>0 - None'; +while ($myrow=DB_fetch_array($result)){ + if (isset($_SESSION['Adjustment']->tag) and $_SESSION['Adjustment']->tag==$myrow['tagref']){ + echo '<option selected value=' . $myrow['tagref'] . '>' . $myrow['tagref'].' - ' .$myrow['tagdescription']; + } else { + echo '<option value=' . $myrow['tagref'] . '>' . $myrow['tagref'].' - ' .$myrow['tagdescription']; + } +} +echo '</select></td>'; +// End select tag + +echo '</table><div class="centre"><br><input type=submit name="EnterAdjustment" value="'. _('Enter Stock Adjustment'). '"><br>'; + if (!isset($_POST['StockLocation'])) { $_POST['StockLocation']=''; } -echo '<a href="'. $rootpath. '/StockStatus.php?' . SID . '&StockID='. $StockID . '">'._('Show Stock Status').'</a>'; +echo '<br><a href="'. $rootpath. '/StockStatus.php?' . SID . '&StockID='. $StockID . '">'._('Show Stock Status').'</a>'; echo '<br><a href="'.$rootpath.'/StockMovements.php?' . SID . '&StockID=' . $StockID . '">'._('Show Movements').'</a>'; echo '<br><a href="'.$rootpath.'/StockUsage.php?' . SID . '&StockID=' . $StockID . '&StockLocation=' . $_POST['StockLocation'] . '">'._('Show Stock Usage').'</a>'; echo '<br><a href="'.$rootpath.'/SelectSalesOrder.php?' . SID . '&SelectedStockItem='. $StockID .'&StockLocation=' . $_POST['StockLocation'] . '">'. _('Search Outstanding Sales Orders').'</a>'; Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-18 09:39:07 UTC (rev 3637) +++ trunk/doc/Change.log.html 2010-07-18 10:30:59 UTC (rev 3638) @@ -1,8 +1,9 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> -<p>18/07/10 Phil: CounterSales.php - was not retrieving ReceiptNumber if the debtor integration was disabled - also the correct period was not retrieved because the date format was not in the correct DateFormat because of a typo in SESSION['DefaultDateFormat'] -<p>18/07/10 Phil: New script ContractBOM.php to allow defining the bill of materials for a contract -<p>18/07/10 Phil: Further work on Contracts.php +<p>18/07/10 Tim: StockAdjustments.php - Provide option for tagging stock adjustments, change layout, allow for searching for a part code, and sql quoting</p> +<p>18/07/10 Phil: CounterSales.php - was not retrieving ReceiptNumber if the debtor integration was disabled - also the correct period was not retrieved because the date format was not in the correct DateFormat because of a typo in SESSION['DefaultDateFormat'] </p> +<p>18/07/10 Phil: New script ContractBOM.php to allow defining the bill of materials for a contract</p> +<p>18/07/10 Phil: Further work on Contracts.php</p> <p>17/07/10 Tim: PaymentTerms.php - Bug fixes, SQL quoting and layout changes</p> <p>17/07/10 Tim: Payments.php - Bug fixes, SQL quoting and layout changes</p> <p>17/07/10 Tim: PaymentMethods.php - SQL quoting and layout changes</p> @@ -41,8 +42,8 @@ <p>09/07/10 Tim: GLTrialBalance.php - Bug fixes, layout improvements changed period number to date and year and sql fixes</p> <p>09/07/10 Tim: GLTransInquiry.php - Layout improvements changed period number to date and year and sql fixes</p> <p>09/07/10 Tim: GLTags - Layout improvements and sql fixes</p> -<p>09/07/10 Phil: includes/DateFunctions.inc added assumption for 2 digit years to d/m/Y m/d/Y and Y/m/d formats -<p>09/07/10 Phil: Prices.php fixed error trapping to allow end dates of 0000-00-00 - the default no end date used by the logic +<p>09/07/10 Phil: includes/DateFunctions.inc added assumption for 2 digit years to d/m/Y m/d/Y and Y/m/d formats</p> +<p>09/07/10 Phil: Prices.php fixed error trapping to allow end dates of 0000-00-00 - the default no end date used by the logic</p> <p>08/07/10 Tim: GLTagProfit_Loss - Layout improvements and sql fixes</p> <p>08/07/10 Tim: GLProfit_Loss - Layout improvements and sql fixes</p> <p>08/07/10 Tim: GLJournal - Layout improvements and sql fixes</p> @@ -71,7 +72,7 @@ <p>05/07/10 Tim: CustomerAllocations.php - Corrections to sql statements and layout changes</p> <p>05/07/10 Tim: CustomerAllocations.php - Corrections to sql statements and layout changes</p> <p>05/07/10 Tim: CustLoginSetup.php - Minor bug fixes, corrections to sql statements</p> -<p>05/07/10 Pak Ricard: upgrade3.11.1-3.12.sql - Error in table name +<p>05/07/10 Pak Ricard: upgrade3.11.1-3.12.sql - Error in table name</p> <p>05/07/10 Pak Ricard: PricesByCost.php - Margin must be decimal to allow margins like 2,5 or 3,3 time standard cost. Also ot has to be large enough to accept "currency margins". If you have a standard costs in EUR and want to check prices in IDR or viceversa, you'll need to compute large margins.</p> <p>04/07/10 Tim: CustEDISetup.php - Corrections to sql statements</p> <p>04/07/10 Tim: Currencies.php - Corrections to sql statements and layout changes</p> Modified: trunk/includes/DefineStockAdjustment.php =================================================================== --- trunk/includes/DefineStockAdjustment.php 2010-07-18 09:39:07 UTC (rev 3637) +++ trunk/includes/DefineStockAdjustment.php 2010-07-18 10:30:59 UTC (rev 3638) @@ -11,6 +11,7 @@ Var $StandardCost; Var $DecimalPlaces; Var $Quantity; + var $tag; var $SerialItems; /*array to hold controlled items*/ //Constructor @@ -25,6 +26,7 @@ $this->DecimalPlaces = 0; $this->SerialItems = array(); $Quantity =0; + $this->tag=0; } } ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-19 11:51:53
|
Revision: 3639 http://web-erp.svn.sourceforge.net/web-erp/?rev=3639&view=rev Author: tim_schofield Date: 2010-07-19 11:51:46 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Layout changes, sql quoting Modified Paths: -------------- trunk/PcAssignCashToTab.php trunk/doc/Change.log.html Modified: trunk/PcAssignCashToTab.php =================================================================== --- trunk/PcAssignCashToTab.php 2010-07-18 10:30:59 UTC (rev 3638) +++ trunk/PcAssignCashToTab.php 2010-07-19 11:51:46 UTC (rev 3639) @@ -4,7 +4,7 @@ $PageSecurity = 6; include('includes/session.inc'); -$title = _('Assignation of Cash to Petty Cash Tab'); +$title = _('Assignment of Cash to Petty Cash Tab'); include('includes/header.inc'); if (isset($_POST['SelectedTabs'])){ @@ -35,6 +35,9 @@ //initialise no input errors assumed initially before we test $InputError = 0; + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_add.png" title="' . + _('Search') . '" alt="">' . ' ' . $title. '</p>'; + /* actions to take once the user has clicked the submit button ie the page has called itself with some user input */ @@ -49,13 +52,13 @@ $sqlLimit = "SELECT tablimit FROM pctabs - WHERE tabcode='$SelectedTabs'"; + WHERE tabcode='" . $SelectedTabs . "'"; $ResultLimit = DB_query($sqlLimit,$db); $Limit=DB_fetch_array($ResultLimit); if (($_POST['CurrentAmount']+$_POST['Amount'])>$Limit['tablimit']){ - prnMsg('<br>' . _('The balance after this assignation would be greater than the specified limit for this PC tab'),'warning'); + prnMsg('<br>' . _('The balance after this assignment would be greater than the specified limit for this PC tab'),'warning'); } if ($InputError !=1 AND isset($SelectedIndex) ) { @@ -66,8 +69,8 @@ authorized = '0000-00-00', notes = '" . $_POST['Notes'] . "', receipt = '" . $_POST['Receipt'] . "' - WHERE counterindex = '$SelectedIndex'"; - $msg = _('Assignation of cash to PC Tab ') . ' ' . $SelectedTabs . ' ' . _('has been updated'); + WHERE counterindex = '" . $SelectedIndex . "'"; + $msg = _('Assignment of cash to PC Tab ') . ' ' . $SelectedTabs . ' ' . _('has been updated'); } elseif ($InputError !=1 ) { // Add new record on submit @@ -86,12 +89,12 @@ '".FormatDateForSQL($_POST['Date'])."', 'ASSIGNCASH', '" .$_POST['Amount'] . "', - '0000-00-00', + authorized = '0000-00-00', '0', '" . $_POST['Notes'] . "', '" . $_POST['Receipt'] . "' )"; - $msg = _('Assignation of cash to PC Tab ') . ' ' . $_POST["SelectedTabs"] . ' ' . _('has been created'); + $msg = _('Assignment of cash to PC Tab ') . ' ' . $_POST["SelectedTabs"] . ' ' . _('has been created'); } if ( $InputError !=1) { @@ -105,11 +108,14 @@ } } elseif ( isset($_GET['delete']) ) { + + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_add.png" title="' . + _('Search') . '" alt="">' . ' ' . $title. '</p>'; $sql="DELETE FROM pcashdetails - WHERE counterindex='$SelectedIndex'"; - $ErrMsg = _('The assignation of cash record could not be deleted because'); + WHERE counterindex='" . $SelectedIndex . "'"; + $ErrMsg = _('The assignment of cash record could not be deleted because'); $result = DB_query($sql,$db,$ErrMsg); - prnMsg(_('Assignation of cash to PC Tab ') . ' ' . $SelectedTabs . ' ' . _('has been deleted') ,'success'); + prnMsg(_('Assignment of cash to PC Tab ') . ' ' . $SelectedTabs . ' ' . _('has been deleted') ,'success'); unset($_GET['delete']); } @@ -119,10 +125,11 @@ then none of the above are true and the list of sales types will be displayed with links to delete or edit each. These will call the same page again and allow update/input or deletion of the records*/ + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_add.png" title="' . + _('Search') . '" alt="">' . ' ' . $title. '</p>'; echo "<form method='post' action=" . $_SERVER['PHP_SELF'] . '?' . SID . '>'; - echo '<p><table border=1>'; //Main table - echo '<td><table>'; // First column + echo '<p><table class=selection>'; //Main table echo '<tr><td>' . _('Petty Cash Tab To Assign Cash') . ":</td><td><select name='SelectedTabs'>"; @@ -136,37 +143,30 @@ while ($myrow = DB_fetch_array($result)) { if (isset($_POST['SelectTabs']) and $myrow['tabcode']==$_POST['SelectTabs']) { - echo "<option selected VALUE='"; + echo "<option selected value='"; } else { - echo "<option VALUE='"; + echo "<option value='"; } echo $myrow['tabcode'] . "'>" . $myrow['tabcode']; } echo '</select></td></tr>'; - echo '</table>'; // close table in first column echo '</td></tr></table>'; // close main table - echo '<p><div class="centre"><input type=submit name=process VALUE="' . _('Accept') . '"><input type=submit name=Cancel VALUE="' . _('Cancel') . '"></div>'; + echo '<p><div class="centre"><input type=submit name=process VALUE="' . _('Accept') . '"><input type=submit name=Cancel value="' . _('Cancel') . '"></div>'; echo '</form>'; } //end of ifs and buts! -if (isset($_POST['process'])OR isset($SelectedTabs)) { +if (isset($_POST['process']) OR isset($SelectedTabs)) { - echo '<p><div class="centre"><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '">' . _('Details Of Petty Cash Tab ') . '' .$SelectedTabs. '<a/></div><p>'; + if (!isset($_POST['submit'])) { + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_add.png" title="' . + _('Search') . '" alt="">' . ' ' . $title. '</p>'; + } + echo '<p><div class="centre"><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '">' . _('Details Of Petty Cash Tab ') . '' .$SelectedTabs. '<a/></div>'; if (! isset($_GET['edit']) OR isset ($_POST['GO'])){ - echo "<form method='post' action=" . $_SERVER['PHP_SELF'] . '?' . SID . '>'; - echo "<div class='centre'><p>" . _('Detail Of PC Tab Movements For Last ') .': '; - if(!isset ($Days)){ - $Days=30; - } - echo "<input type=hidden name='SelectedTabs' VALUE=" . $SelectedTabs . ">"; - echo "<input type=text class=number name='Days' VALUE=" . $Days . " MAXLENGTH =3 size=4> Days "; - echo '<input type=submit name="Go" value="' . _('Go') . '">'; - echo '<p></div></form>'; - if (isset($_POST['Cancel'])) { unset($_POST['Amount']); unset($_POST['Date']); @@ -188,20 +188,29 @@ AND pcashdetails.date >=DATE_SUB(CURDATE(), INTERVAL ".$Days." DAY) ORDER BY pcashdetails.counterindex Asc"; */ + if(!isset ($Days)){ + $Days=30; + } $sql = "SELECT * FROM pcashdetails - WHERE tabcode='$SelectedTabs' - AND date >=DATE_SUB(CURDATE(), INTERVAL ".$Days." DAY) + WHERE tabcode='" . $SelectedTabs . "' + AND date >=DATE_SUB(CURDATE(), INTERVAL '".$Days."' DAY) ORDER BY date, counterindex ASC"; $result = DB_query($sql,$db); - echo '<br><table BORDER=1>'; + echo '<table class=selection>'; + echo "<form method='post' action=" . $_SERVER['PHP_SELF'] . '?' . SID . '>'; + echo "<tr><th colspan=8>" . _('Detail Of PC Tab Movements For Last ') .': '; + echo "<input type=hidden name='SelectedTabs' value=" . $SelectedTabs . ">"; + echo "<input type=text class=number name='Days' value=" . $Days . " maxlength =3 size=4> Days "; + echo '<input type=submit name="Go" value="' . _('Go') . '">'; + echo '</th></tr></form>'; echo "<tr> <th>" . _('Date') . "</th> <th>" . _('Expense Code') . "</th> <th>" . _('Amount') . "</th> - <th>" . _('Authorized') . "</th> + <th>" . _('Authorised') . "</th> <th>" . _('Notes') . "</th> <th>" . _('Receipt') . "</th> </tr>"; @@ -230,44 +239,34 @@ if (($myrow['5'] == "0000-00-00") and ($Description['0'] == 'ASSIGNCASH')){ // only cash assignations NOT authorized can be modified or deleted - printf("<td>%s</td> - <td>%s</td> - <td class=number>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td><a href='%sSelectedIndex=%s&SelectedTabs=$SelectedTabs&Days=$Days&edit=yes'>" . _('Edit') . "</td> - <td><a href='%sSelectedIndex=%s&SelectedTabs=$SelectedTabs&Days=$Days&delete=yes' onclick=\"return confirm('" . _('Are you sure you wish to delete this code and the expense it may have set up?') . "');\">" . _('Delete') . "</td> - </tr>", - ConvertSQLDate($myrow['2']), - $Description['0'], - number_format($myrow['4'],2), - ConvertSQLDate($myrow['5']), - $myrow['7'], - $myrow['8'], - $_SERVER['PHP_SELF'] . '?' . SID, $myrow['0'], - $_SERVER['PHP_SELF'] . '?' . SID, $myrow['0']); + echo "<td>".ConvertSQLDate($myrow['2'])."</td> + <td>".$Description['0']."</td> + <td class=number>".number_format($myrow['4'],2)."</td> + <td>".ConvertSQLDate($myrow['5'])."</td> + <td>".$myrow['7']."</td> + <td>".$myrow['8']."</td> + <td><a href='".$_SERVER['PHP_SELF'] . '?' . SID ."SelectedIndex=".$myrow['0']."&SelectedTabs=" . + $SelectedTabs . "&Days=" . $Days . "&edit=yes'>" . _('Edit') . "</td> + <td><a href='".$_SERVER['PHP_SELF'] . '?' . SID ."SelectedIndex=".$myrow['0']."&SelectedTabs=" . + $SelectedTabs . "&Days=" . $Days . "&delete=yes' onclick=\"return confirm('" . + _('Are you sure you wish to delete this code and the expense it may have set up?') . "');\">" . + _('Delete') . "</td> + </tr>"; }else{ - printf("<td>%s</td> - <td>%s</td> - <td class=number>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - </tr>", - ConvertSQLDate($myrow['2']), - $Description['0'], - number_format($myrow['4'],2), - ConvertSQLDate($myrow['5']), - $myrow['7'], - $myrow['8']); + echo "<td>".ConvertSQLDate($myrow['2'])."</td> + <td>".$Description['0']."</td> + <td class=number>".number_format($myrow['4'],2)."</td> + <td>".ConvertSQLDate($myrow['5'])."</td> + <td>".ConvertSQLDate($myrow['5'])."</td> + <td>".$myrow['7']."</td> + </tr>"; } } //END WHILE LIST LOOP $sqlamount="SELECT sum(amount) FROM pcashdetails - WHERE tabcode='$SelectedTabs'"; + WHERE tabcode='".$SelectedTabs."'"; $ResultAmount = DB_query($sqlamount,$db); $Amount=DB_fetch_array($ResultAmount); @@ -276,8 +275,8 @@ $Amount['0']=0; } - echo "<tr><td colspan=4 style=text-align:right >" . _('Current balance') . ":</td> - <td colspan=2>".number_format($Amount['0'],2)."</td></tr>"; + echo "<tr><td colspan=2 style=text-align:right ><b>" . _('Current balance') . ":</b></td> + <td>".number_format($Amount['0'],2)."</td></tr>"; echo '</table>'; @@ -285,14 +284,21 @@ if (! isset($_GET['delete'])) { + if (!isset($Amount['0'])) { + $Amount['0']=0; + } + echo "<form method='post' action=" . $_SERVER['PHP_SELF'] . '?' . SID . '>'; - echo '<p><table border=1>'; //Main table - echo '<td><table>'; // First column - + echo '<p><table class=selection>'; //Main table + if (isset($_GET['SelectedIndex'])) { + echo "<tr><th colspan=2><font color=blue size=3>"._('Update Cash Assignment')."</font></th></tr>"; + } else { + echo "<tr><th colspan=2><font color=blue size=3>"._('New Cash Assignment')."</font></th></tr>"; + } if ( isset($_GET['edit'])) { $sql = "SELECT * FROM pcashdetails - WHERE counterindex='$SelectedIndex'"; + WHERE counterindex='".$SelectedIndex."'"; $result = DB_query($sql, $db); $myrow = DB_fetch_array($result); @@ -303,10 +309,10 @@ $_POST['Notes'] = $myrow['notes']; $_POST['Receipt'] = $myrow['receipt']; - echo "<input type=hidden name='SelectedTabs' VALUE=" . $SelectedTabs . ">"; - echo "<input type=hidden name='SelectedIndex' VALUE=" . $SelectedIndex. ">"; - echo "<input type=hidden name='CurrentAmount' VALUE=" . $Amount['0']. ">"; - echo "<input type=hidden name='Days' VALUE=" .$Days. ">"; + echo "<input type=hidden name='SelectedTabs' value=" . $SelectedTabs . ">"; + echo "<input type=hidden name='SelectedIndex' value=" . $SelectedIndex. ">"; + echo "<input type=hidden name='CurrentAmount' value=" . $Amount[0]. ">"; + echo "<input type=hidden name='Days' value=" .$Days. ">"; } /* Ricard: needs revision of this date initialization */ @@ -337,14 +343,13 @@ echo "<tr><td>" . _('Receipt') . ":</td><td><input type='Text' name='Receipt' size=50 maxlength=49 value='" . $_POST['Receipt'] . "'></td></tr>"; - echo "<input type=hidden name='CurrentAmount' VALUE=" . $Amount['0']. ">"; - echo "<input type=hidden name='SelectedTabs' VALUE=" . $SelectedTabs . ">"; - echo "<input type=hidden name='Days' VALUE=" .$Days. ">"; + echo "<input type=hidden name='CurrentAmount' value=" . $Amount['0']. ">"; + echo "<input type=hidden name='SelectedTabs' value=" . $SelectedTabs . ">"; + echo "<input type=hidden name='Days' value=" .$Days. ">"; - echo '</table>'; // close table in first column echo '</td></tr></table>'; // close main table - echo '<p><div class="centre"><input type=submit name=submit VALUE="' . _('Accept') . '"><input type=submit name=Cancel VALUE="' . _('Cancel') . '"></div>'; + echo '<p><div class="centre"><input type=submit name=submit value="' . _('Accept') . '"><input type=submit name=Cancel value="' . _('Cancel') . '"></div>'; echo '</form>'; Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-18 10:30:59 UTC (rev 3638) +++ trunk/doc/Change.log.html 2010-07-19 11:51:46 UTC (rev 3639) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>18/07/10 Tim: PCAssignCashToTab.php - Layout changes, sql quoting</p> <p>18/07/10 Tim: StockAdjustments.php - Provide option for tagging stock adjustments, change layout, allow for searching for a part code, and sql quoting</p> <p>18/07/10 Phil: CounterSales.php - was not retrieving ReceiptNumber if the debtor integration was disabled - also the correct period was not retrieved because the date format was not in the correct DateFormat because of a typo in SESSION['DefaultDateFormat'] </p> <p>18/07/10 Phil: New script ContractBOM.php to allow defining the bill of materials for a contract</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-19 11:52:17
|
Revision: 3640 http://web-erp.svn.sourceforge.net/web-erp/?rev=3640&view=rev Author: tim_schofield Date: 2010-07-19 11:52:11 +0000 (Mon, 19 Jul 2010) Log Message: ----------- New script to choose an asset type for editing Modified Paths: -------------- trunk/doc/Change.log.html Added Paths: ----------- trunk/SelectAssetType.php Added: trunk/SelectAssetType.php =================================================================== --- trunk/SelectAssetType.php (rev 0) +++ trunk/SelectAssetType.php 2010-07-19 11:52:11 UTC (rev 3640) @@ -0,0 +1,312 @@ +<?php +/* $Id$*/ +$PageSecurity = 2; +$PricesSecurity = 9; +include ('includes/session.inc'); +$title = _('Search Asset Types'); +include ('includes/header.inc'); +$msg = ''; +if (isset($_GET['StockID'])) { + //The page is called with a StockID + $_GET['StockID'] = trim(strtoupper($_GET['StockID'])); + $_POST['Select'] = trim(strtoupper($_GET['StockID'])); +} + +if (isset($_GET['NewSearch']) or isset($_POST['Next']) or isset($_POST['Previous']) or isset($_POST['Go'])) { + unset($StockID); + unset($_SESSION['SelectedStockItem']); + unset($_POST['Select']); +} +if (!isset($_POST['PageOffset'])) { + $_POST['PageOffset'] = 1; +} else { + if ($_POST['PageOffset'] == 0) { + $_POST['PageOffset'] = 1; + } +} +if (isset($_POST['StockCode'])) { + $_POST['StockCode'] = trim(strtoupper($_POST['StockCode'])); +} +// Always show the search facilities +$SQL = 'SELECT categoryid, + categorydescription + FROM stockcategory + WHERE stocktype="A" + ORDER BY categorydescription'; +$result1 = DB_query($SQL, $db); +if (DB_num_rows($result1) == 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; +} +// end of showing search facilities +/* displays item options if there is one and only one selected */ +if (!isset($_POST['Search']) AND (isset($_POST['Select']) OR isset($_SESSION['SelectedStockItem']))) { + if (isset($_POST['Select'])) { + $_SESSION['SelectedStockItem'] = $_POST['Select']; + $StockID = $_POST['Select']; + unset($_POST['Select']); + } else { + $StockID = $_SESSION['SelectedStockItem']; + } + $sql="SELECT stockmaster.description, + stockmaster.mbflag, + stockcategory.stocktype, + stockmaster.units, + stockmaster.decimalplaces, + stockmaster.controlled, + stockmaster.serialised, + stockmaster.materialcost+stockmaster.labourcost+stockmaster.overheadcost AS cost, + stockmaster.discontinued, + stockmaster.eoq, + stockmaster.volume, + stockmaster.kgs + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE stockid='" . $StockID . "'"; + $result = DB_query($sql, $db); + $myrow = DB_fetch_array($result); + $Its_A_Kitset_Assembly_Or_Dummy = false; + $Its_A_Dummy = false; + $Its_A_Kitset = false; + $Its_A_Labour_Item = false; +} else { + // options (links) to pages. This requires stock id also to be passed. +} // end displaying item options if there is one and only one record +echo '<form action="SelectAssetType.php?' . SID . '" method=post>'; +echo '<b>' . $msg . '</b>'; +echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Search') . '" alt="">' . ' ' . _('Search for Inventory Items'); +echo '<table class=selection><tr>'; +echo '<td>' . _('In Stock Category') . ':'; +echo '<select name="StockCat">'; +if (!isset($_POST['StockCat'])) { + $_POST['StockCat'] = ""; +} + +while ($myrow1 = DB_fetch_array($result1)) { + 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 '</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>'; +// query for list of record(s) +if(isset($_POST['Go']) OR isset($_POST['Next']) OR isset($_POST['Previous'])) { + $_POST['Search']='Search'; +} +if (isset($_POST['Search']) OR isset($_POST['Go']) OR isset($_POST['Next']) OR isset($_POST['Previous'])) { + if (!isset($_POST['Go']) AND !isset($_POST['Next']) AND !isset($_POST['Previous'])) { + // if Search then set to first page + $_POST['PageOffset'] = 1; + } + 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 + $_POST['Keywords'] = strtoupper($_POST['Keywords']); + $SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%'; + if ($_POST['StockCat'] == 'All') { + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units, + stockmaster.mbflag, + stockmaster.decimalplaces + FROM stockmaster + WHERE stockmaster.description " . LIKE . " '$SearchString' + GROUP BY stockmaster.stockid, + stockmaster.description, + stockmaster.units, + stockmaster.mbflag, + stockmaster.decimalplaces + ORDER BY stockmaster.stockid"; + } else { + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.units, + stockmaster.mbflag, + stockmaster.decimalplaces + FROM stockmaster + WHERE description " . LIKE . " '$SearchString' + AND categoryid='" . $_POST['StockCat'] . "' + GROUP BY stockmaster.stockid, + stockmaster.description, + stockmaster.units, + stockmaster.mbflag, + stockmaster.decimalplaces + ORDER BY stockmaster.stockid"; + } + } elseif (isset($_POST['StockCode'])) { + $_POST['StockCode'] = strtoupper($_POST['StockCode']); + if ($_POST['StockCat'] == 'All') { + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.mbflag, + stockmaster.units, + stockmaster.decimalplaces + FROM stockmaster + WHERE stockmaster.stockid " . LIKE . " '%" . $_POST['StockCode'] . "%' + GROUP BY stockmaster.stockid, + stockmaster.description, + stockmaster.units, + stockmaster.mbflag, + stockmaster.decimalplaces + ORDER BY stockmaster.stockid"; + } else { + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.mbflag, + stockmaster.units, + stockmaster.decimalplaces + FROM stockmaster + WHERE stockmaster.stockid " . LIKE . " '%" . $_POST['StockCode'] . "%' + AND categoryid='" . $_POST['StockCat'] . "' + GROUP BY stockmaster.stockid, + stockmaster.description, + stockmaster.units, + stockmaster.mbflag, + stockmaster.decimalplaces + ORDER BY stockmaster.stockid"; + } + } elseif (!isset($_POST['StockCode']) AND !isset($_POST['Keywords'])) { + if ($_POST['StockCat'] == 'All') { + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.mbflag, + stockmaster.units, + stockmaster.decimalplaces + FROM stockmaster + GROUP BY stockmaster.stockid, + stockmaster.description, + stockmaster.units, + stockmaster.mbflag, + stockmaster.decimalplaces + ORDER BY stockmaster.stockid"; + } else { + $SQL = "SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.mbflag, + stockmaster.units, + stockmaster.decimalplaces + FROM stockmaster + WHERE categoryid='" . $_POST['StockCat'] . "' + GROUP BY stockmaster.stockid, + stockmaster.description, + stockmaster.units, + stockmaster.mbflag, + stockmaster.decimalplaces + ORDER BY stockmaster.stockid"; + } + } + $ErrMsg = _('No stock items were returned by the SQL because'); + $DbgMsg = _('The SQL that returned an error was'); + $searchresult = DB_query($SQL, $db, $ErrMsg, $DbgMsg); + if (DB_num_rows($searchresult) == 0) { + prnMsg(_('No stock items were returned by this search please re-enter alternative criteria to try again'), 'info'); + } + unset($_POST['Search']); +} +/* end query for list of records */ +/* display list if there is more than one record */ +if (isset($searchresult) AND !isset($_POST['Select'])) { + echo '<form action="FixedAssetItems.php?' . SID . '" method=post>'; + $ListCount = DB_num_rows($searchresult); + if ($ListCount > 0) { + // If the user hit the search button and there is more than one item to show + $ListPageMax = ceil($ListCount / $_SESSION['DisplayRecordsMax']); + if (isset($_POST['Next'])) { + if ($_POST['PageOffset'] < $ListPageMax) { + $_POST['PageOffset'] = $_POST['PageOffset'] + 1; + } + } + if (isset($_POST['Previous'])) { + if ($_POST['PageOffset'] > 1) { + $_POST['PageOffset'] = $_POST['PageOffset'] - 1; + } + } + if ($_POST['PageOffset'] > $ListPageMax) { + $_POST['PageOffset'] = $ListPageMax; + } + if ($ListPageMax > 1) { + echo "<div class='centre'><p> " . $_POST['PageOffset'] . ' ' . _('of') . ' ' . $ListPageMax . ' ' . _('pages') . '. ' . _('Go to Page') . ': '; + echo '<select name="PageOffset">'; + $ListPage = 1; + while ($ListPage <= $ListPageMax) { + if ($ListPage == $_POST['PageOffset']) { + echo '<option value=' . $ListPage . ' selected>' . $ListPage . '</option>'; + } else { + echo '<option value=' . $ListPage . '>' . $ListPage . '</option>'; + } + $ListPage++; + } + echo '</select> + <input type=submit name="Go" value="' . _('Go') . '"> + <input type=submit name="Previous" value="' . _('Previous') . '"> + <input type=submit name="Next" value="' . _('Next') . '">'; + echo '<input type=hidden name=Keywords value="'.$_POST['Keywords'].'">'; + echo '<input type=hidden name=StockCat value="'.$_POST['StockCat'].'">'; + echo '<input type=hidden name=StockCode value="'.$_POST['StockCode'].'">'; +// echo '<input type=hidden name=Search value="Search">'; + echo '<p></div>'; + } + echo '<table cellpadding=2 colspan=7>'; + $tableheader = '<tr> + <th>' . _('Code') . '</th> + <th>' . _('Description') . '</th> + <th>' . _('Units') . '</th> + <th>' . _('Stock Status') . '</th> + </tr>'; + echo $tableheader; + $j = 1; + $k = 0; //row counter to determine background colour + $RowIndex = 0; + if (DB_num_rows($searchresult) <> 0) { + DB_data_seek($searchresult, ($_POST['PageOffset'] - 1) * $_SESSION['DisplayRecordsMax']); + } + while (($myrow = DB_fetch_array($searchresult)) AND ($RowIndex <> $_SESSION['DisplayRecordsMax'])) { + if ($k == 1) { + echo '<tr class="EvenTableRows">'; + $k = 0; + } else { + echo '<tr class="OddTableRows">'; + $k++; + } + echo "<td><input type=submit name='Select' value='".$myrow['stockid']."'></td> + <td>".$myrow['description']."</td> + <td>".$myrow['units']."</td> + <td><a target='_blank' href='" . $rootpath . "/StockStatus.php?" . SID . "&StockID=".$myrow['stockid']."'>" . _('View') . "</a></td> + </tr>"; + $j++; + if ($j == 20 AND ($RowIndex + 1 != $_SESSION['DisplayRecordsMax'])) { + $j = 1; + echo $tableheader; + } + $RowIndex = $RowIndex + 1; + //end of page full new headings if + } + //end of while loop + echo '</table></form><br>'; + } +} +/* end display list if there is more than one record */ +include ('includes/footer.inc'); +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-19 11:51:46 UTC (rev 3639) +++ trunk/doc/Change.log.html 2010-07-19 11:52:11 UTC (rev 3640) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>19/07/10 Tim: SelectAssetType.php - New script to choose an asset type for editing</p> <p>18/07/10 Tim: PCAssignCashToTab.php - Layout changes, sql quoting</p> <p>18/07/10 Tim: StockAdjustments.php - Provide option for tagging stock adjustments, change layout, allow for searching for a part code, and sql quoting</p> <p>18/07/10 Phil: CounterSales.php - was not retrieving ReceiptNumber if the debtor integration was disabled - also the correct period was not retrieved because the date format was not in the correct DateFormat because of a typo in SESSION['DefaultDateFormat'] </p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-19 11:52:42
|
Revision: 3641 http://web-erp.svn.sourceforge.net/web-erp/?rev=3641&view=rev Author: tim_schofield Date: 2010-07-19 11:52:36 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Layout changes and include editing of item type Modified Paths: -------------- trunk/FixedAssetItems.php trunk/doc/Change.log.html Modified: trunk/FixedAssetItems.php =================================================================== --- trunk/FixedAssetItems.php 2010-07-19 11:52:11 UTC (rev 3640) +++ trunk/FixedAssetItems.php 2010-07-19 11:52:36 UTC (rev 3641) @@ -6,15 +6,22 @@ $PageSecurity = 11; include('includes/session.inc'); -$title = _('Fixed Asset Maintenance'); +$title = _('Fixed Asset Item Maintenance'); include('includes/header.inc'); +echo '<a href="' . $rootpath . '/SelectAssetType.php?' . SID . '">' . _('Back to Select') . '</a><br>' . "\n"; + +echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_add.png" title="' . + _('Fixed Asset Items') . '" alt="">' . ' ' . $title . '</p>'; + /*If this form is called with the StockID then it is assumed that the stock item is to be modified */ if (isset($_GET['StockID'])){ $StockID =trim(strtoupper($_GET['StockID'])); } elseif (isset($_POST['StockID'])){ $StockID =trim(strtoupper($_POST['StockID'])); +} elseif (isset($_POST['Select'])){ + $StockID =trim(strtoupper($_POST['Select'])); } else { $StockID = ''; } @@ -24,13 +31,12 @@ $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]==0) { + $New=0; + } else { $New=1; } } -echo '<a href="' . $rootpath . '/SelectProduct.php?' . SID . '">' . _('Back to Items') . '</a><br>' . "\n"; - - if (isset($_FILES['ItemPicture']) AND $_FILES['ItemPicture']['name'] !='') { $result = $_FILES['ItemPicture']['error']; @@ -200,7 +206,7 @@ if ($_POST['Serialised']==1){ /*Not appropriate to have several dp on serial items */ $_POST['DecimalPlaces']=0; } - if (!isset($_POST['New']) and !isset($New)) { /*so its an existing one */ + if ($_POST['submit']==_('Update')) { /*so its an existing one */ /*first check on the changes being made we must disallow: - changes from manufactured or purchased to Service, Assembly or Kitset if there is stock - changes from manufactured, kitset or assembly where a BOM exists @@ -208,14 +214,14 @@ $sql = "SELECT mbflag, controlled, serialised - FROM stockmaster WHERE stockid = '$StockID'"; + FROM stockmaster WHERE stockid = '" . $StockID . "'"; $MBFlagResult = DB_query($sql,$db); $myrow = DB_fetch_row($MBFlagResult); $OldMBFlag = $myrow[0]; $OldControlled = $myrow[1]; $OldSerialised = $myrow[2]; - $sql = "SELECT SUM(locstock.quantity) FROM locstock WHERE stockid='$StockID'"; + $sql = "SELECT SUM(locstock.quantity) FROM locstock WHERE stockid='" . $StockID . "'"; $result = DB_query($sql,$db); $stkqtychk = DB_fetch_row($result); @@ -236,7 +242,7 @@ if ($_POST['MBFlag']=='K') { $sql = "SELECT quantity-qtyinvoiced FROM salesorderdetails - WHERE stkcode = '$StockID' + WHERE stkcode = '" . $StockID . "' AND completed=0"; $result = DB_query($sql,$db); @@ -251,7 +257,7 @@ $sql = "SELECT quantityord-quantityrecd FROM purchorderdetails - WHERE itemcode = '$StockID' + WHERE itemcode = '" . $StockID . "' AND completed=0"; $result = DB_query($sql,$db); @@ -264,7 +270,7 @@ /*now check that if it was a Manufactured, Kitset, Phantom or Assembly and is being changed to a purchased or dummy - that no BOM exists */ if (($OldMBFlag=='M' OR $OldMBFlag =='K' OR $OldMBFlag=='A' OR $OldMBFlag=='G') AND ($_POST['MBFlag']=='B' OR $_POST['MBFlag']=='D')) { - $sql = "SELECT COUNT(*) FROM bom WHERE parent = '$StockID'"; + $sql = "SELECT COUNT(*) FROM bom WHERE parent = '" . $StockID . "'"; $result = DB_query($sql,$db); $ChkBOM = DB_fetch_row($result); if ($ChkBOM[0]!=0){ @@ -275,7 +281,7 @@ /*now check that if it was Manufac, Phantom or Purchased and is being changed to assembly or kitset, it is not a component on an existing BOM */ if (($OldMBFlag=='M' OR $OldMBFlag =='B' OR $OldMBFlag=='D' OR $OldMBFlag=='G') AND ($_POST['MBFlag']=='A' OR $_POST['MBFlag']=='K')) { - $sql = "SELECT COUNT(*) FROM bom WHERE component = '$StockID'"; + $sql = "SELECT COUNT(*) FROM bom WHERE component = '" . $StockID . "'"; $result = DB_query($sql,$db); $ChkBOM = DB_fetch_row($result); if ($ChkBOM[0]!=0){ @@ -301,25 +307,25 @@ $sql = "UPDATE stockmaster SET longdescription='" . $_POST['LongDescription'] . "', description='" . $_POST['Description'] . "', - discontinued=" . $_POST['Discontinued'] . ", - controlled=" . $_POST['Controlled'] . ", - serialised=" . $_POST['Serialised'].", - perishable=" . $_POST['Perishable'].", + discontinued='" . $_POST['Discontinued'] . "', + controlled='" . $_POST['Controlled'] . "', + serialised='" . $_POST['Serialised']."', + perishable='" . $_POST['Perishable']."', categoryid='" . $_POST['CategoryID'] . "', units='" . $_POST['Units'] . "', mbflag='" . $_POST['MBFlag'] . "', - eoq=" . $_POST['EOQ'] . ", - volume=" . $_POST['Volume'] . ", - kgs=" . $_POST['KGS'] . ", + eoq='" . $_POST['EOQ'] . "', + volume='" . $_POST['Volume'] . "', + kgs='" . $_POST['KGS'] . "', barcode='" . $_POST['BarCode'] . "', discountcategory='" . $_POST['DiscountCategory'] . "', - taxcatid=" . $_POST['TaxCat'] . ", - decimalplaces=" . $_POST['DecimalPlaces'] . ", + taxcatid='" . $_POST['TaxCat'] . "', + decimalplaces='" . $_POST['DecimalPlaces'] . "', appendfile='" . $_POST['ItemPDF'] . "', - shrinkfactor=" . $_POST['ShrinkFactor'] . ", - pansize=" . $_POST['Pansize'] . ", - nextserialno=" . $_POST['NextSerialNo'] . " - WHERE stockid='$StockID'"; + shrinkfactor='" . $_POST['ShrinkFactor'] . "', + pansize='" . $_POST['Pansize'] . "', + nextserialno='" . $_POST['NextSerialNo'] . "' + WHERE stockid='" . $StockID . "'"; $ErrMsg = _('The stock item could not be updated because'); $DbgMsg = _('The SQL that was used to update the stock item and failed was'); @@ -344,11 +350,12 @@ stkcatpropid, value) VALUES ('" . $StockID . "', - " . $_POST['PropID' . $i] . ", + '" . $_POST['PropID' . $i] . "', '" . $_POST['PropValue' . $i] . "')", $db); } //end of loop around properties defined for the category prnMsg( _('Stock Item') . ' ' . $StockID . ' ' . _('has been updated'), 'success'); + echo '<br>'; } } else { //it is a NEW part @@ -379,26 +386,26 @@ appendfile, shrinkfactor, pansize) - VALUES ('$StockID', + VALUES ('" . $StockID . "', '" . $_POST['Description'] . "', '" . $_POST['LongDescription'] . "', '" . $_POST['CategoryID'] . "', '" . $_POST['Units'] . "', '" . $_POST['MBFlag'] . "', - " . $_POST['EOQ'] . ", - " . $_POST['Discontinued'] . ", - " . $_POST['Controlled'] . ", - " . $_POST['Serialised']. ", - " . $_POST['Perishable']. ", - " . $_POST['Volume'] . ", - " . $_POST['KGS'] . ", + '" . $_POST['EOQ'] . "', + '" . $_POST['Discontinued'] . "', + '" . $_POST['Controlled'] . "', + '" . $_POST['Serialised']. "', + '" . $_POST['Perishable']. "', + '" . $_POST['Volume'] . "', + '" . $_POST['KGS'] . "', '" . $_POST['BarCode'] . "', '" . $_POST['DiscountCategory'] . "', - " . $_POST['TaxCat'] . ", - " . $_POST['DecimalPlaces']. ", + '" . $_POST['TaxCat'] . "', + '" . $_POST['DecimalPlaces']. "', '" . $_POST['ItemPDF']. "', - " . $_POST['ShrinkFactor'] . ", - " . $_POST['Pansize'] . " + '" . $_POST['ShrinkFactor'] . "', + '" . $_POST['Pansize'] . "' )"; $ErrMsg = _('The item could not be added because'); @@ -418,7 +425,7 @@ stkcatpropid, value) VALUES ('" . $StockID . "', - " . $_POST['PropID' . $i] . ", + '" . $_POST['PropID' . $i] . "', '" . $_POST['PropValue' . $i] . "')"; $result = DB_query($sql,$db); } //end of loop around properties defined for the category @@ -429,7 +436,7 @@ SELECT locations.loccode, '" . $StockID . "' FROM locations"; - + $ErrMsg = _('The locations for the item') . ' ' . $StockID . ' ' . _('could not be added because'); $DbgMsg = _('NB Locations records can be added by opening the utility page') . ' <i>Z_MakeStockLocns.php</i> ' . _('The SQL that was used to add the location records that failed was'); $InsResult = DB_query($sql,$db,$ErrMsg,$DbgMsg); @@ -474,7 +481,7 @@ // PREVENT DELETES IF DEPENDENT RECORDS IN 'StockMoves' - $sql= "SELECT COUNT(*) FROM stockmoves WHERE stockid='$StockID'"; + $sql= "SELECT COUNT(*) FROM stockmoves WHERE stockid='" . $StockID . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -483,7 +490,7 @@ echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('stock movements that refer to this item'); } else { - $sql= "SELECT COUNT(*) FROM bom WHERE component='$StockID'"; + $sql= "SELECT COUNT(*) FROM bom WHERE component='" . $StockID . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -491,7 +498,7 @@ prnMsg( _('Cannot delete this item record because there are bills of material that require this part as a component'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('bills of material that require this part as a component'); } else { - $sql= "SELECT COUNT(*) FROM salesorderdetails WHERE stkcode='$StockID'"; + $sql= "SELECT COUNT(*) FROM salesorderdetails WHERE stkcode='" . $StockID . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -499,7 +506,7 @@ prnMsg( _('Cannot delete this item record because there are existing sales orders for this part'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('sales order items against this part'); } else { - $sql= "SELECT COUNT(*) FROM salesanalysis WHERE stockid='$StockID'"; + $sql= "SELECT COUNT(*) FROM salesanalysis WHERE stockid='" . $StockID . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -507,7 +514,7 @@ prnMsg(_('Cannot delete this item because sales analysis records exist for it'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('sales analysis records against this part'); } else { - $sql= "SELECT COUNT(*) FROM purchorderdetails WHERE itemcode='$StockID'"; + $sql= "SELECT COUNT(*) FROM purchorderdetails WHERE itemcode='" . $StockID . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { @@ -515,7 +522,7 @@ prnMsg(_('Cannot delete this item because there are existing purchase order items for it'),'warn'); echo '<br>' . _('There are') . ' ' . $myrow[0] . ' ' . _('purchase order item record relating to this part'); } else { - $sql = "SELECT SUM(quantity) AS qoh FROM locstock WHERE stockid='$StockID'"; + $sql = "SELECT SUM(quantity) AS qoh FROM locstock WHERE stockid='" . $StockID . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]!=0) { @@ -533,18 +540,18 @@ $result = DB_Txn_Begin($db); /*Deletes LocStock records*/ - $sql ="DELETE FROM locstock WHERE stockid='$StockID'"; + $sql ="DELETE FROM locstock WHERE stockid='" . $StockID . "'"; $result=DB_query($sql,$db,_('Could not delete the location stock records because'),'',true); /*Deletes Price records*/ - $sql ="DELETE FROM prices WHERE stockid='$StockID'"; + $sql ="DELETE FROM prices WHERE stockid='" . $StockID . "'"; $result=DB_query($sql,$db,_('Could not delete the prices for this stock record because'),'',true); /*and cascade deletes in PurchData */ - $sql ="DELETE FROM purchdata WHERE stockid='$StockID'"; + $sql ="DELETE FROM purchdata WHERE stockid='" . $StockID . "'"; $result=DB_query($sql,$db,_('Could not delete the purchasing data because'),'',true); /*and cascade delete the bill of material if any */ - $sql = "DELETE FROM bom WHERE parent='$StockID'"; + $sql = "DELETE FROM bom WHERE parent='" . $StockID . "'"; $result=DB_query($sql,$db,_('Could not delete the bill of material because'),'',true); - $sql="DELETE FROM stockmaster WHERE stockid='$StockID'"; + $sql="DELETE FROM stockmaster WHERE stockid='" . $StockID . "'"; $result=DB_query($sql,$db, _('Could not delete the item record'),'',true); $result = DB_Txn_Commit($db); @@ -581,15 +588,16 @@ } -echo '<form name="ItemForm" enctype="multipart/form-data" method="post" action="' . $_SERVER['PHP_SELF'] . '?' .SID .'"><table> - <tr><td><table>'. "\n"; // Nested table +echo '<form name="ItemForm" enctype="multipart/form-data" method="post" action="' . $_SERVER['PHP_SELF'] . '?' .SID . + '"><table class=selection>'; if (!isset($StockID) or $StockID=='') { /*If the page was called without $StockID passed to page then assume a new stock item is to be entered show a form with a part Code field other wise the form showing the fields with the existing entries against the part will show for editing with only a hidden StockID field. New is set to flag that the page may have called itself and still be entering a new part, in which case the page needs to know not to go looking up details for an existing part*/ $New = true; - echo '<input type="hidden" name="New" value="1">'. "\n"; + echo '<input type="hidden" name="New" value=">'. "\n"; +// echo '<input type="hidden" name="StockID" value="'.$StockID.'">'. "\n"; echo '<tr><td>'. _('Asset Code'). ':</td><td><input ' . (in_array('StockID',$Errors) ? 'class="inputerror"' : '' ) .' type="text" name="StockID" size=21 maxlength=20></td></tr>'. "\n"; @@ -615,7 +623,7 @@ appendfile, nextserialno FROM stockmaster - WHERE stockid = '$StockID'"; + WHERE stockid ='" . $StockID . "'"; $result = DB_query($sql, $db); $myrow = DB_fetch_array($result); @@ -641,6 +649,7 @@ echo '<tr><td>' . _('Asset Code') . ':</td><td>'.$StockID.'</td></tr>'. "\n"; echo '<input type="Hidden" name="StockID" value='.$StockID.'>'. "\n"; + echo '<input type="Hidden" name="NextSerialNo" value='.$_POST['NextSerialNo'].'>'. "\n"; } else { // some changes were made to the data so don't re-set form variables to DB ie the code above echo '<tr><td>' . _('Asset Code') . ':</td><td>'.$StockID.'</td></tr>'; @@ -698,14 +707,38 @@ if (!isset($_POST['ItemPDF'])) { $_POST['ItemPDF'] = ''; } -echo '<tr><td>' . _('PDF attachment (.pdf)') . ':' . "\n</td><td>" . select_files('companies/' . $_SESSION['DatabaseName'] .'/pdf_append//','' , 'ItemPDF', $_POST['ItemPDF'], '60') . '</td></tr>'. "\n"; +echo '<tr><td>' . _('PDF attachment (.pdf)') . ':' . "\n</td><td>" . select_files('companies/' . $_SESSION['DatabaseName'] . + '/pdf_append//','' , 'ItemPDF', $_POST['ItemPDF'], '60') . '</td></tr>'. "\n"; // Add image upload for New Item - by Ori -echo '<tr><td>'. _('Image File (.jpg)') . ':</td><td><input type="file" id="ItemPicture" name="ItemPicture"></td></tr>'; +echo '<tr><td>'. _('Image File (.jpg)') . ':</td><td><input type="file" id="ItemPicture" name="ItemPicture"></td>'; // EOR Add Image upload for New Item - by Ori - echo '<tr><td>' . _('Category') . ':</td><td><select name="CategoryID" onChange="ReloadForm(ItemForm.UpdateCategories)">'; +if (function_exists('imagecreatefromjpg')){ + $StockImgLink = '<img src="GetStockImage.php?SID&automake=1&textcolor=FFFFFF&bgcolor=CCCCCC'. + '&StockID='.urlencode($StockID). + '&text='. + '&width=64'. + '&height=64'. + '" >'; +} else { + if( isset($StockID) and file_exists($_SESSION['part_pics_dir'] . '/' .$StockID.'.jpg') ) { + $StockImgLink = '<img src="' . $_SESSION['part_pics_dir'] . '/' .$StockID.'.jpg" >'; + } else { + $StockImgLink = _('No Image'); + } +} +if ($StockImgLink!=_('No Image')) { + echo '<td>' . _('Image') . '<br>'.$StockImgLink . '</td></tr>'; +} else { + echo '</td></tr>'; +} + +// EOR Add Image upload for New Item - by Ori + +echo '<tr><td>' . _('Category') . ':</td><td><select name="CategoryID" onChange="ReloadForm(ItemForm.UpdateCategories)">'; + $sql = 'SELECT categoryid, categorydescription FROM stockcategory WHERE stocktype="A"'; $ErrMsg = _('The stock categories could not be retrieved because'); $DbgMsg = _('The SQL used to retrieve stock categories and failed was'); @@ -822,33 +855,16 @@ } } //end while loop -echo '</select></td></tr>'; +echo '</select></td></tr></table>'; -echo '<input type="hidden" class="number" name="Pansize" size="6" maxlength="6" value=' . $_POST['Pansize'] . '>'; +echo '<input type="hidden" class="number" name="Pansize" size="6" maxlength="6" value=' . $_POST['Pansize'] . '>'; echo '<input type="hidden" class="number" name="ShrinkFactor" size="6" maxlength="6" value=' . $_POST['ShrinkFactor'] . '>'; - if (function_exists('imagecreatefrompng')){ - $StockImgLink = '<img src="GetStockImage.php?SID&automake=1&textcolor=FFFFFF&bgcolor=CCCCCC'. - '&StockID='.urlencode($StockID). - '&text='. - '&width=64'. - '&height=64'. - '" >'; -} else { - if( isset($StockID) and file_exists($_SESSION['part_pics_dir'] . '/' .$StockID.'.jpg') ) { - $StockImgLink = '<img src="' . $_SESSION['part_pics_dir'] . '/' .$StockID.'.jpg" >'; - } else { - $StockImgLink = _('No Image'); - } -} - -echo '</table></td><td>' . _('Image') . '<br>'.$StockImgLink . '</td></tr></table><div class="centre">'; - if (!isset($_POST['CategoryID'])) { $_POST['CategoryID'] = ''; } -echo '<table><tr><th colspan="2">' . _('Asset Category Properties') . '</th></tr>'; +echo '<br><table class=selection><tr><th colspan="2">' . _('Depreciation Properties') . '</th></tr>'; $sql = "SELECT stkcatpropid, label, controltype, @@ -867,7 +883,7 @@ $PropValResult = DB_query("SELECT value FROM stockitemproperties WHERE stockid='" . $StockID . "' - AND stkcatpropid =" . $PropertyRow['stkcatpropid'], + AND stkcatpropid ='" . $PropertyRow['stkcatpropid'] . "'", $db); $PropValRow = DB_fetch_row($PropValResult); $PropertyValue = $PropValRow[0]; @@ -905,23 +921,20 @@ $PropertyCounter++; } //end loop round properties for the item category echo '</table>'; -echo '<input type="hidden" name="PropertyCounter" value=2>'; +echo '<input type="hidden" name="PropertyCounter" value=1>'; -if (isset($New)) { - echo '<input type="Submit" name="submit" value="' . _('Insert New Item') . '">'; - echo '<input type="submit" name="UpdateCategories" style="visibility:hidden;width:1px" value="' . _('Categories') . '">'; +if ($New==1) { + echo '<div class=centre><br><input type="Submit" name="submit" value="' . _('Insert New Item') . '">'; } else { // Now the form to enter the item properties - - echo '<input type="submit" name="submit" value="' . _('Update') . '">'; + echo '<br><div class=centre><input type="submit" name="submit" value="' . _('Update') . '"></div>'; echo '<input type="submit" name="UpdateCategories" style="visibility:hidden;width:1px" value="' . _('Categories') . '">'; - echo '<p>'; prnMsg( _('Only click the Delete button if you are sure you wish to delete the item!') . _('Checks will be made to ensure that there are no stock movements, sales analysis records, sales order items or purchase order items for the item') . '. ' . _('No deletions will be allowed if they exist'), 'warn', _('WARNING')); - echo '<p><input type="Submit" name="delete" value="' . _('Delete This Item') . '" onclick="return confirm(\'' . _('Are You Sure?') . '\');">'; + echo '<br><div class=centre><input type="Submit" name="delete" value="' . _('Delete This Item') . '" onclick="return confirm(\'' . _('Are You Sure?') . '\');"></div>'; } echo '</form></div>'; include('includes/footer.inc'); -?> +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-19 11:52:11 UTC (rev 3640) +++ trunk/doc/Change.log.html 2010-07-19 11:52:36 UTC (rev 3641) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>19/07/10 Tim: FixedAssetItems.php - Layout changes and include editing of item type</p> <p>19/07/10 Tim: SelectAssetType.php - New script to choose an asset type for editing</p> <p>18/07/10 Tim: PCAssignCashToTab.php - Layout changes, sql quoting</p> <p>18/07/10 Tim: StockAdjustments.php - Provide option for tagging stock adjustments, change layout, allow for searching for a part code, and sql quoting</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-19 11:53:16
|
Revision: 3643 http://web-erp.svn.sourceforge.net/web-erp/?rev=3643&view=rev Author: tim_schofield Date: 2010-07-19 11:53:10 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Layout changes and sql quoting Modified Paths: -------------- trunk/FixedAssetCategories.php trunk/doc/Change.log.html Modified: trunk/FixedAssetCategories.php =================================================================== --- trunk/FixedAssetCategories.php 2010-07-19 11:52:49 UTC (rev 3642) +++ trunk/FixedAssetCategories.php 2010-07-19 11:53:10 UTC (rev 3643) @@ -1,6 +1,5 @@ <?php -/* $Revision: 1.2 $ */ -/* $Id$*/ +/* $Revision: 1.1 $ */ $PageSecurity = 11; @@ -10,6 +9,9 @@ include('includes/header.inc'); +echo '<div class="centre"><p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_add.png" title="' . + _('Fixed Asset Categories') . '" alt="">' . ' ' . $title . ''; + if (isset($_GET['SelectedCategory'])){ $SelectedCategory = strtoupper($_GET['SelectedCategory']); } else if (isset($_POST['SelectedCategory'])){ @@ -19,9 +21,9 @@ if (isset($_GET['DeleteProperty'])){ $ErrMsg = _('Could not delete the property') . ' ' . $_GET['DeleteProperty'] . ' ' . _('because'); - $sql = "DELETE FROM stockitemproperties WHERE stkcatpropid=" . $_GET['DeleteProperty']; + $sql = "DELETE FROM stockitemproperties WHERE stkcatpropid='" . $_GET['DeleteProperty'] . "'"; $result = DB_query($sql,$db,$ErrMsg); - $sql = "DELETE FROM stockcatproperties WHERE stkcatpropid=" . $_GET['DeleteProperty']; + $sql = "DELETE FROM stockcatproperties WHERE stkcatpropid='" . $_GET['DeleteProperty'] . "'"; $result = DB_query($sql,$db,$ErrMsg); prnMsg(_('Deleted the property') . ' ' . $_GET['DeleteProperty'],'success'); } @@ -49,110 +51,69 @@ prnMsg(_('The Fixed Asset Category description must be twenty characters or less long'),'error'); } - if ($SelectedCategory AND $InputError !=1) { + if (isset($SelectedCategory) AND $InputError !=1) { /*SelectedCategory could also exist if submit had not been clicked this code would not run in this case cos submit is false of course see the delete code below*/ - $sql = "UPDATE stockcategory SET + $sql = "UPDATE stockcategory SET stocktype = '" . $_POST['StockType'] . "', categorydescription = '" . $_POST['CategoryDescription'] . "', - stockact = " . $_POST['StockAct'] . ", - adjglact = " . $_POST['AdjGLAct'] . ", - materialuseagevarac = " . $_POST['MaterialUseageVarAc'] . ", - wipact = " . $_POST['WIPAct'] . " - WHERE - categoryid = '$SelectedCategory'"; + stockact = '" . $_POST['StockAct'] . "', + adjglact = '" . $_POST['AdjGLAct'] . "', + materialuseagevarac = '" . $_POST['MaterialUseageVarAc'] . "', + wipact = '" . $_POST['WIPAct'] . "' + WHERE categoryid = '".$SelectedCategory . "'"; $ErrMsg = _('Could not update the fixed asset category') . $_POST['CategoryDescription'] . _('because'); $result = DB_query($sql,$db,$ErrMsg); -/* for ($i=0;$i<=$_POST['PropertyCounter'];$i++){ - - if (isset($_POST['PropReqSO' .$i]) and $_POST['PropReqSO' .$i] == true){ - $_POST['PropReqSO' .$i] =1; - } else { - $_POST['PropReqSO' .$i] =0; - } - if ($_POST['PropID' .$i] =='NewProperty' AND strlen($_POST['PropLabel'.$i])>0){ - $sql = "INSERT INTO stockcatproperties (categoryid, - label, - controltype, - defaultvalue, - reqatsalesorder) - VALUES ('" . $SelectedCategory . "', - '" . $_POST['PropLabel' . $i] . "', - " . $_POST['PropControlType' . $i] . ", - '" . $_POST['PropDefault' .$i] . "', - " . $_POST['PropReqSO' .$i] . ')'; - $ErrMsg = _('Could not insert a new category property for') . $_POST['PropLabel' . $i]; - $result = DB_query($sql,$db,$ErrMsg); - } elseif ($_POST['PropID' .$i] !='NewProperty') { //we could be amending existing properties - $sql = "UPDATE stockcatproperties SET label ='" . $_POST['PropLabel' . $i] . "', - controltype = " . $_POST['PropControlType' . $i] . ", - defaultvalue = '" . $_POST['PropDefault' .$i] . "', - reqatsalesorder = " . $_POST['PropReqSO' .$i] . " - WHERE stkcatpropid =" . $_POST['PropID' .$i]; - $ErrMsg = _('Updated the asset category property for') . ' ' . $_POST['PropLabel' . $i]; - $result = DB_query($sql,$db,$ErrMsg); - } - - } //end of loop round properties -*/ prnMsg(_('Updated the fixed asset category record for') . ' ' . $_POST['CategoryDescription'],'success'); } elseif ($InputError !=1) { - /*Selected category is null cos no item selected on first time round so must be adding a record must be submitting new entries in the new asset category form */ + /*Selected category is null cos no item selected on first time round so must be adding a record must be submitting new entries in the new stock category form */ $sql = "INSERT INTO stockcategory (categoryid, - stocktype, - categorydescription, - stockact, - adjglact, - materialuseagevarac, - wipact) - VALUES ( - '" . $_POST['CategoryID'] . "', - '" . $_POST['StockType'] . "', - '" . $_POST['CategoryDescription'] . "', - " . $_POST['StockAct'] . ", - " . $_POST['AdjGLAct'] . ", - " . $_POST['MaterialUseageVarAc'] . ", - " . $_POST['WIPAct'] . ")"; - $ErrMsg = _('Could not insert the new asset category') . $_POST['CategoryDescription'] . _('because'); - $result = DB_query($sql,$db,$ErrMsg); - prnMsg(_('A new asset category record has been added for') . ' ' . $_POST['CategoryDescription'],'success'); - $sql="INSERT INTO stockcatproperties + stocktype, + categorydescription, + stockact, + adjglact, + materialuseagevarac, + wipact) + VALUES ( + '" . $_POST['CategoryID'] . "', + '" . $_POST['StockType'] . "', + '" . $_POST['CategoryDescription'] . "', + '" . $_POST['StockAct'] . "', + '" . $_POST['AdjGLAct'] . "', + '" . $_POST['MaterialUseageVarAc'] . "', + '" . $_POST['WIPAct'] . "')"; + $ErrMsg = _('Could not insert the new stock category') . $_POST['CategoryDescription'] . _('because'); + $result = DB_query($sql,$db,$ErrMsg); + prnMsg(_('A new stock category record has been added for') . ' ' . $_POST['CategoryDescription'],'success'); + $sql="INSERT INTO stockcatproperties VALUES( - NULL, - '".$_POST['CategoryID']."', + NULL, + '".$_POST['CategoryID']."', '"._('Depreciation Type')."', '1', '"._('Straight Line').","._('Reducing Balance')."', '0')"; $result=DB_query($sql,$db); - $sql="INSERT INTO stockcatproperties + $sql="INSERT INTO stockcatproperties VALUES( - NULL, - '".$_POST['CategoryID']."', + NULL, + '".$_POST['CategoryID']."', '"._('Annual Depreciation Percentage')."', '0', '5', '0')"; $result=DB_query($sql,$db); - $sql="INSERT INTO stockcatproperties - VALUES( - NULL, - '".$_POST['CategoryID']."', - '"._('Annual Internal Depreciation Percentage')."', - '0', - '5', - '0')"; - $result=DB_query($sql,$db); } //run the SQL from either of the above possibilites + unset($_POST['CategoryID']); unset($_POST['StockType']); unset($_POST['CategoryDescription']); unset($_POST['StockAct']); @@ -167,53 +128,53 @@ // PREVENT DELETES IF DEPENDENT RECORDS IN 'StockMaster' - $sql= "SELECT COUNT(*) FROM stockmaster WHERE stockmaster.categoryid='$SelectedCategory'"; + $sql= "SELECT COUNT(*) FROM stockmaster WHERE stockmaster.categoryid='" . $SelectedCategory . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { - prnMsg(_('Cannot delete this asset category because stock items have been created using this asset category') . - '<br> ' . _('There are') . ' ' . $myrow[0] . ' ' . _('items referring to this asset category code'),'warn'); + prnMsg(_('Cannot delete this stock category because stock items have been created using this stock category') . + '<br> ' . _('There are') . ' ' . $myrow[0] . ' ' . _('items referring to this stock category code'),'warn'); } else { - $sql = "SELECT COUNT(*) FROM salesglpostings WHERE stkcat='$SelectedCategory'"; + $sql = "SELECT COUNT(*) FROM salesglpostings WHERE stkcat='" . $SelectedCategory . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { - prnMsg(_('Cannot delete this asset category because it is used by the sales') . ' - ' . _('GL posting interface') . '. ' . _('Delete any records in the Sales GL Interface set up using this asset category first'),'warn'); + prnMsg(_('Cannot delete this stock category because it is used by the sales') . ' - ' . _('GL posting interface') . '. ' . _('Delete any records in the Sales GL Interface set up using this stock category first'),'warn'); } else { - $sql = "SELECT COUNT(*) FROM cogsglpostings WHERE stkcat='$SelectedCategory'"; + $sql = "SELECT COUNT(*) FROM cogsglpostings WHERE stkcat='" . $SelectedCategory . "'"; $result = DB_query($sql,$db); $myrow = DB_fetch_row($result); if ($myrow[0]>0) { - prnMsg(_('Cannot delete this asset category because it is used by the cost of sales') . ' - ' . _('GL posting interface') . '. ' . _('Delete any records in the Cost of Sales GL Interface set up using this asset category first'),'warn'); + prnMsg(_('Cannot delete this stock category because it is used by the cost of sales') . ' - ' . _('GL posting interface') . '. ' . _('Delete any records in the Cost of Sales GL Interface set up using this stock category first'),'warn'); } else { - $sql="DELETE FROM stockcategory WHERE categoryid='$SelectedCategory'"; + $sql="DELETE FROM stockcategory WHERE categoryid='" . $SelectedCategory . "'"; $result = DB_query($sql,$db); - prnMsg(_('The asset category') . ' ' . $SelectedCategory . ' ' . _('has been deleted') . ' !','success'); + prnMsg(_('The stock category') . ' ' . $SelectedCategory . ' ' . _('has been deleted') . ' !','success'); unset ($SelectedCategory); } } - } //end if asset category used in debtor transactions + } //end if stock category used in debtor transactions } -if (!isset($SelectedCategory)) { +if (!isset($SelectedCategory) or isset($_POST['submit'])) { /* It could still be the second time the page has been run and a record has been selected for modification - SelectedCategory will exist because it was sent with the new call. If its the first time the page has been displayed with no parameters -then none of the above are true and the list of asset categorys will be displayed with +then none of the above are true and the list of stock categorys will be displayed with links to delete or edit each. These will call the same page again and allow update/input or deletion of the records*/ - $sql = "SELECT * FROM stockcategory WHERE stocktype='".'A'."'"; + $sql = "SELECT * FROM stockcategory WHERE stocktype='A'"; $result = DB_query($sql,$db); - echo "<br><table border=1>\n"; + echo "<br><table class=selection>\n"; echo '<tr><th>' . _('Cat Code') . '</th> - <th>' . _('Description') . '</th> - <th>' . _('Type') . '</th> - <th>' . _('Asset GL') . '</th> - <th>' . _('P & L Depn GL') . '</th> - <th>' . _('Sale of Asset account') . '</th> - <th>' . _('BS Depn GL') . '</th></tr>'; + <th>' . _('Description') . '</th> + <th>' . _('Type') . '</th> + <th>' . _('Asset GL') . '</th> + <th>' . _('P & L Depn GL') . '</th> + <th>' . _('Sale of Asset account') . '</th> + <th>' . _('BS Depn GL') . '</th></tr>'; $k=0; //row colour counter @@ -226,27 +187,27 @@ $k=1; } printf("<td>%s</td> - <td>%s</td> - <td>%s</td> - <td class=number>%s</td> - <td class=number>%s</td> - <td class=number>%s</td> - <td class=number>%s</td> - <td><a href=\"%sSelectedCategory=%s\">" . _('Edit') . "</td> - <td><a href=\"%sSelectedCategory=%s&delete=yes\" onclick=\"return confirm('" . _('Are you sure you wish to delete this asset category? Additional checks will be performed before actual deletion to ensure data integrity is not compromised.') . "');\">" . _('Delete') . "</td> - </tr>", - $myrow[0], - $myrow[1], - $myrow[2], - $myrow[3], - $myrow[4], -// $myrow[5], - $myrow[6], - $myrow[7], - $_SERVER['PHP_SELF'] . '?' . SID, - $myrow[0], - $_SERVER['PHP_SELF'] . '?' . SID, - $myrow[0]); + <td>%s</td> + <td>%s</td> + <td align=right>%s</td> + <td align=right>%s</td> + <td align=right>%s</td> + <td align=right>%s</td> + <td><a href=\"%sSelectedCategory=%s\">" . _('Edit') . "</td> + <td><a href=\"%sSelectedCategory=%s&delete=yes\" onclick=\"return confirm('" . _('Are you sure you wish to delete this stock category? Additional checks will be performed before actual deletion to ensure data integrity is not compromised.') . "');\">" . _('Delete') . "</td> + </tr>", + $myrow[0], + $myrow[1], + $myrow[2], + $myrow[3], + $myrow[4], +// $myrow[5], + $myrow[6], + $myrow[7], + $_SERVER['PHP_SELF'] . '?' . SID, + $myrow[0], + $_SERVER['PHP_SELF'] . '?' . SID, + $myrow[0]); } //END WHILE LIST LOOP echo '</table>'; @@ -254,214 +215,156 @@ //end of ifs and buts! -?> +if (isset($SelectedCategory)) { + echo "<br><div class='centre'><a href='" . $_SERVER['PHP_SELF'] . '?' . SID . ">" ._('Show All Stock Categories') . "</a></div>"; +} -<p> -<?php -if (isset($SelectedCategory)) { ?> - <div class='centre'><a href="<?php echo $_SERVER['PHP_SELF'] . '?' . SID;?>"><?php echo _('Show All Stock Categories'); ?></a></div> -<?php } ?> +echo '<form name="CategoryForm" method="post" action="' . $_SERVER['PHP_SELF'] . '?' . SID . '">'; -<p> +if (isset($SelectedCategory) and !isset($_POST['submit'])) { + //editing an existing stock category + if (!isset($_POST['UpdateTypes'])) { + $sql = "SELECT categoryid, + stocktype, + categorydescription, + stockact, + adjglact, + purchpricevaract, + materialuseagevarac, + wipact + FROM stockcategory + WHERE categoryid='" . $SelectedCategory . "'"; -<?php + $result = DB_query($sql, $db); + $myrow = DB_fetch_array($result); -if (! isset($_GET['delete'])) { + $_POST['CategoryID'] = $myrow['categoryid']; + $_POST['StockType'] = $myrow['stocktype']; + $_POST['CategoryDescription'] = $myrow['categorydescription']; + $_POST['StockAct'] = $myrow['stockact']; + $_POST['AdjGLAct'] = $myrow['adjglact']; + $_POST['PurchPriceVarAct'] = $myrow['purchpricevaract']; + $_POST['MaterialUseageVarAc'] = $myrow['materialuseagevarac']; + $_POST['WIPAct'] = $myrow['wipact']; + } + echo '<input type=hidden name="SelectedCategory" value="' . $SelectedCategory . '">'; + echo '<input type=hidden name="CategoryID" value="' . $_POST['CategoryID'] . '">'; + echo '<table class=selection><tr><td>' . _('Category Code') . ':</td><td>' . $_POST['CategoryID'] . '</td></tr>'; - echo '<form name="CategoryForm" method="post" action="' . $_SERVER['PHP_SELF'] . '?' . SID . '">'; - - if (isset($SelectedCategory)) { - //editing an existing asset category - if (!isset($_POST['UpdateTypes'])) { - $sql = "SELECT categoryid, - stocktype, - categorydescription, - stockact, - adjglact, - purchpricevaract, - materialuseagevarac, - wipact - FROM stockcategory - WHERE categoryid='" . $SelectedCategory . "'"; - - $result = DB_query($sql, $db); - $myrow = DB_fetch_array($result); - - $_POST['CategoryID'] = $myrow['categoryid']; - $_POST['StockType'] = $myrow['stocktype']; - $_POST['CategoryDescription'] = $myrow['categorydescription']; - $_POST['StockAct'] = $myrow['stockact']; - $_POST['AdjGLAct'] = $myrow['adjglact']; - $_POST['PurchPriceVarAct'] = $myrow['purchpricevaract']; - $_POST['MaterialUseageVarAc'] = $myrow['materialuseagevarac']; - $_POST['WIPAct'] = $myrow['wipact']; - } - echo '<input type=hidden name="SelectedCategory" value="' . $SelectedCategory . '">'; - echo '<input type=hidden name="CategoryID" value="' . $_POST['CategoryID'] . '">'; - echo '<table><tr><td>' . _('Asset Category Code') . ':</td><td>' . $_POST['CategoryID'] . '</td></tr>'; - - } else { //end of if $SelectedCategory only do the else when a new record is being entered - if (!isset($_POST['CategoryID'])) { - $_POST['CategoryID'] = ''; - } - echo '<table><tr><td>' . _('Asset Category Code') . ':</td> - <td><input type="Text" name="CategoryID" size=7 maxlength=6 value="' . $_POST['CategoryID'] . '"></td></tr>'; +} else { //end of if $SelectedCategory only do the else when a new record is being entered + if (!isset($_POST['CategoryID'])) { + $_POST['CategoryID'] = ''; } + echo '<table class=selection><tr><td>' . _('Category Code') . ':</td> + <td><input type="Text" name="CategoryID" size=7 maxlength=6 value="' . $_POST['CategoryID'] . '"></td></tr>'; +} - //SQL to poulate account selection boxes - $sql = "SELECT accountcode, - accountname - FROM chartmaster, - accountgroups - WHERE chartmaster.group_=accountgroups.groupname and - accountgroups.pandl=0 - ORDER BY accountcode"; +//SQL to poulate account selection boxes +$sql = "SELECT accountcode, + accountname + FROM chartmaster, + accountgroups + WHERE chartmaster.group_=accountgroups.groupname and + accountgroups.pandl=0 + ORDER BY accountcode"; - $BSAccountsResult = DB_query($sql,$db); +$BSAccountsResult = DB_query($sql,$db); - $sql = "SELECT accountcode, - accountname - FROM chartmaster, - accountgroups - WHERE chartmaster.group_=accountgroups.groupname and - accountgroups.pandl!=0 - ORDER BY accountcode"; +$sql = "SELECT accountcode, + accountname + FROM chartmaster, + accountgroups + WHERE chartmaster.group_=accountgroups.groupname and + accountgroups.pandl!=0 + ORDER BY accountcode"; - $PnLAccountsResult = DB_query($sql,$db); +$PnLAccountsResult = DB_query($sql,$db); - if (!isset($_POST['CategoryDescription'])) { - $_POST['CategoryDescription'] = ''; - } - - echo '<tr><td>' . _('Category Description') . ':</td> - <td><input type="Text" name="CategoryDescription" size=22 maxlength=20 value="' . $_POST['CategoryDescription'] . '"></td></tr>'; +if (!isset($_POST['CategoryDescription'])) { + $_POST['CategoryDescription'] = ''; +} +echo '<tr><td>' . _('Category Description') . ':</td> + <td><input type="Text" name="CategoryDescription" size=22 maxlength=20 value="' . $_POST['CategoryDescription'] . '"></td></tr>'; -/* echo '<tr><td>' . _('Stock Type') . ':</td> - <td><select name="StockType" onChange="ReloadForm(CategoryForm.UpdateTypes)" >'; - if (isset($_POST['StockType']) and $_POST['StockType']=='F') { - echo '<option selected value="F">' . _('Finished Goods'); - } else { - echo '<option value="F">' . _('Finished Goods'); - } - if (isset($_POST['StockType']) and $_POST['StockType']=='M') { - echo '<option selected value="M">' . _('Raw Materials'); - } else { - echo '<option value="M">' . _('Raw Materials'); - } - if (isset($_POST['StockType']) and $_POST['StockType']=='D') { - echo '<option selected value="D">' . _('Dummy Item - (No Movements)'); - } else { - echo '<option value="D">' . _('Dummy Item - (No Movements)'); - } - if (isset($_POST['StockType']) and $_POST['StockType']=='L') { - echo '<option selected value="L">' . _('Labour'); - } else { - echo '<option value="L">' . _('Labour'); - } +echo '<input type=hidden name="StockType" value="A">'; +echo '<input type="submit" name="UpdateTypes" style="visibility:hidden;width:1px" value="Not Seen">'; +echo '<tr><td>' . _('Fixed Asset GL Code'); - echo '</select></td></tr>'; -*/ - echo '<input type=hidden name="StockType" value="A">'; - echo '<input type="submit" name="UpdateTypes" style="visibility:hidden;width:1px" value="Not Seen">'; - echo '<tr><td>' . _('Fixed Asset GL Code'); +echo ':</td><td><select name="StockAct">'; - echo ':</td><td><select name="StockAct">'; - - while ($myrow = DB_fetch_array($BSAccountsResult)){ - - if (isset($_POST['StockAct']) and $myrow['accountcode']==$_POST['StockAct']) { - echo '<option selected value='; - } else { - echo '<option value='; - } - echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')'; - } //end while loop - DB_data_seek($PnLAccountsResult,0); - DB_data_seek($BSAccountsResult,0); - echo '</select></td></tr>'; +while ($myrow = DB_fetch_array($BSAccountsResult)){ - echo '<tr><td>' . _('Balance Sheet Depreciation GL Code') . ':</td><td><select name="WIPAct">'; + if (isset($_POST['StockAct']) and $myrow['accountcode']==$_POST['StockAct']) { + echo '<option selected value='; + } else { + echo '<option value='; + } + echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')'; +} //end while loop +DB_data_seek($PnLAccountsResult,0); +DB_data_seek($BSAccountsResult,0); +echo '</select></td></tr>'; - while ($myrow = DB_fetch_array($BSAccountsResult)) { - - if (isset($_POST['WIPAct']) and $myrow['accountcode']==$_POST['WIPAct']) { - echo '<option selected value='; - } else { - echo '<option value='; - } - echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')'; +echo '<tr><td>' . _('Balance Sheet Depreciation GL Code') . ':</td><td><select name="WIPAct">'; - } //end while loop - echo '</select></td></tr>'; - DB_data_seek($BSAccountsResult,0); +while ($myrow = DB_fetch_array($BSAccountsResult)) { - echo '<tr><td>' . _('Profit and Loss Depreciation GL Code') . ':</td> - <td><select name="AdjGLAct">'; + if (isset($_POST['WIPAct']) and $myrow['accountcode']==$_POST['WIPAct']) { + echo '<option selected value='; + } else { + echo '<option value='; + } + echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')'; - while ($myrow = DB_fetch_array($PnLAccountsResult)) { - if (isset($_POST['AdjGLAct']) and $myrow['accountcode']==$_POST['AdjGLAct']) { - echo '<option selected value='; - } else { - echo '<option value='; - } - echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')'; +} //end while loop +echo '</select></td></tr>'; +DB_data_seek($BSAccountsResult,0); - } //end while loop - DB_data_seek($PnLAccountsResult,0); - echo '</select></td></tr>'; - -/* echo '<tr><td>' . _('Price Variance GL Code') . ':</td> - <td><select name="PurchPriceVarAct">'; +echo '<tr><td>' . _('Profit and Loss Depreciation GL Code') . ':</td> + <td><select name="AdjGLAct">'; - while ($myrow = DB_fetch_array($PnLAccountsResult)) { - if (isset($_POST['PurchPriceVarAct']) and $myrow['accountcode']==$_POST['PurchPriceVarAct']) { - echo '<option selected value='; - } else { - echo '<option value='; - } - echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')'; +while ($myrow = DB_fetch_array($PnLAccountsResult)) { + if (isset($_POST['AdjGLAct']) and $myrow['accountcode']==$_POST['AdjGLAct']) { + echo '<option selected value='; + } else { + echo '<option value='; + } + echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')'; - } //end while loop - DB_data_seek($PnLAccountsResult,0); +} //end while loop +DB_data_seek($PnLAccountsResult,0); +echo '</select></td></tr>'; - echo '</select></td></tr><tr><td>'; */ - echo '<tr><td>'; - if (isset($_POST['StockType']) and $_POST['StockType']=='L') { - echo _('Other Capitalized Goods P/L Code'); +echo '<tr><td>'; +if (isset($_POST['StockType']) and $_POST['StockType']=='L') { + echo _('Labour Efficiency Variance GL Code'); +} else { + echo _('Sale of Asset account'); +} +echo ':</td><td><select name="MaterialUseageVarAc">'; + +while ($myrow = DB_fetch_array($PnLAccountsResult)) { + if (isset($_POST['MaterialUseageVarAc']) and $myrow['accountcode']==$_POST['MaterialUseageVarAc']) { + echo '<option selected value='; } else { - echo _('Sale of Asset account'); + echo '<option value='; } - echo ':</td><td><select name="MaterialUseageVarAc">'; + echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')'; - while ($myrow = DB_fetch_array($PnLAccountsResult)) { - if (isset($_POST['MaterialUseageVarAc']) and $myrow['accountcode']==$_POST['MaterialUseageVarAc']) { - echo '<option selected value='; - } else { - echo '<option value='; - } - echo $myrow['accountcode'] . '>' . $myrow['accountname'] . ' ('.$myrow['accountcode'].')'; +} //end while loop +DB_free_result($PnLAccountsResult); +echo '</select></td></tr></table><br>'; - } //end while loop - DB_free_result($PnLAccountsResult); - echo '</select></td></tr></table><br>'; - - $sql='SELECT COUNT(categoryid) +$sql='SELECT COUNT(categoryid) FROM stockcatproperties WHERE categoryid="dpntyp"'; - $result=DB_query($sql,$db); - $row=DB_fetch_array($result); - if ($row['categoryid']==0) { - } - echo '<table>'; +$result=DB_query($sql,$db); +$row=DB_fetch_array($result); +echo '<div class="centre"><input type="Submit" name="submit" value="' . _('Enter Information') . '"></div>'; - echo '<div class="centre"><input type="Submit" name="submit" value="' . _('Enter Information') . '"></div>'; +echo '</form>'; - echo '</form>'; - -} //end if record deleted no point displaying form to add record - - include('includes/footer.inc'); -?> +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-19 11:52:49 UTC (rev 3642) +++ trunk/doc/Change.log.html 2010-07-19 11:53:10 UTC (rev 3643) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>19/07/10 Tim: FixedAssetCategories.php - Layout changes and sql quoting</p> <p>19/07/10 Tim: FixedAssetItems.php - Layout changes and include editing of item type</p> <p>19/07/10 Tim: SelectAssetType.php - New script to choose an asset type for editing</p> <p>18/07/10 Tim: PCAssignCashToTab.php - Layout changes, sql quoting</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-19 18:30:18
|
Revision: 3644 http://web-erp.svn.sourceforge.net/web-erp/?rev=3644&view=rev Author: tim_schofield Date: 2010-07-19 18:30:12 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Change prices security to token 12 Modified Paths: -------------- trunk/SelectProduct.php trunk/doc/Change.log.html trunk/sql/mysql/upgrade3.11.1-3.12.sql Modified: trunk/SelectProduct.php =================================================================== --- trunk/SelectProduct.php 2010-07-19 11:53:10 UTC (rev 3643) +++ trunk/SelectProduct.php 2010-07-19 18:30:12 UTC (rev 3644) @@ -1,7 +1,7 @@ <?php /* $Id$*/ $PageSecurity = 2; -$PricesSecurity = 9; +$PricesSecurity = 12; include ('includes/session.inc'); $title = _('Search Inventory Items'); include ('includes/header.inc'); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-19 11:53:10 UTC (rev 3643) +++ trunk/doc/Change.log.html 2010-07-19 18:30:12 UTC (rev 3644) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>19/07/10 Tim: SelectProduct.php - Change prices security to token 12</p> <p>19/07/10 Tim: FixedAssetCategories.php - Layout changes and sql quoting</p> <p>19/07/10 Tim: FixedAssetItems.php - Layout changes and include editing of item type</p> <p>19/07/10 Tim: SelectAssetType.php - New script to choose an asset type for editing</p> Modified: trunk/sql/mysql/upgrade3.11.1-3.12.sql =================================================================== --- trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-07-19 11:53:10 UTC (rev 3643) +++ trunk/sql/mysql/upgrade3.11.1-3.12.sql 2010-07-19 18:30:12 UTC (rev 3644) @@ -280,4 +280,5 @@ ALTER TABLE `loctransfers` CHANGE COLUMN `shipqty` `shipqty` double NOT NULL DEFAULT 0.0; -INSERT INTO `config` VALUES ('VersionNumber', '3.12'); \ No newline at end of file +INSERT INTO `config` VALUES ('VersionNumber', '3.12'); +UPDATE `securitytokens` SET `tokenname`='Prices Security' WHERE tokenid=12; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-19 18:30:39
|
Revision: 3645 http://web-erp.svn.sourceforge.net/web-erp/?rev=3645&view=rev Author: tim_schofield Date: 2010-07-19 18:30:33 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Remove order values when security token 12 is not set Modified Paths: -------------- trunk/PO_SelectOSPurchOrder.php trunk/doc/Change.log.html Modified: trunk/PO_SelectOSPurchOrder.php =================================================================== --- trunk/PO_SelectOSPurchOrder.php 2010-07-19 18:30:12 UTC (rev 3644) +++ trunk/PO_SelectOSPurchOrder.php 2010-07-19 18:30:33 UTC (rev 3645) @@ -5,6 +5,7 @@ /* $Revision: 1.21 $ */ $PageSecurity = 2; +$PricesSecurity = 12; include('includes/session.inc'); @@ -40,8 +41,8 @@ if (isset($OrderNumber) && $OrderNumber!='') { if (!is_numeric($OrderNumber)){ - echo '<br><b>' . _('The Order Number entered') . ' <U>' . _('MUST') . '</U> ' . _('be numeric') . '.</b><br>'; - unset ($OrderNumber); + echo '<br><b>' . _('The Order Number entered') . ' <U>' . _('MUST') . '</U> ' . _('be numeric') . '.</b><br>'; + unset ($OrderNumber); } else { echo _('Order Number') . ' - ' . $OrderNumber; } @@ -132,7 +133,7 @@ if (!isset($OrderNumber) or $OrderNumber=='' ){ echo '<a href="' . $rootpath . '/PO_Header.php?' .SID . '&NewOrder=Yes">' . _('Add Purchase Order') . '</a>'; echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/magnifier.png" title="' . _('Search') . '" alt="">' . ' ' . $title.'</p>'; - echo '<div class="centre">'._('Order Number') . ': <input type=text name="OrderNumber" MAXLENGTH =8 size=9> ' . _('Into Stock Location') . ':<select name="StockLocation"> '; + echo '<table class=selection><tr><td>'._('Order Number') . ': <input type=text name="OrderNumber" MAXLENGTH =8 size=9> ' . _('Into Stock Location') . ':<select name="StockLocation"> '; $sql = 'SELECT loccode, locationname FROM locations'; $resultStkLocs = DB_query($sql,$db); while ($myrow=DB_fetch_array($resultStkLocs)){ @@ -149,47 +150,38 @@ } } - echo '</select> <input type=submit name="SearchOrders" VALUE="' . _('Search Purchase Orders') . '"></div>'; + echo '</select> <input type=submit name="SearchOrders" value="' . _('Search Purchase Orders') . '"></td></tr></table>'; } $SQL='SELECT categoryid, categorydescription FROM stockcategory ORDER BY categorydescription'; $result1 = DB_query($SQL,$db); -?> +echo "<br><font size=1><div class='page_help_text'>" ._('To search for purchase orders for a specific part use the part selection facilities below') + ."</div> </font>"; +echo "<br><table class=selection><tr>"; -<hr> -<font size=1><div class='page_help_text'><?php echo _('To search for purchase orders for a specific part use the part selection facilities below'); ?></div> </font> -<br><table align="center"> -<tr> -<td><font size=1><?php echo _('Select a stock category'); ?>:</font> -<select name="StockCat"> -<?php +echo "<td><font size=1>" . _('Select a stock category') . ":</font><select name='StockCat'>"; + while ($myrow1 = DB_fetch_array($result1)) { if (isset($_POST['StockCat']) and $myrow1['categoryid']==$_POST['StockCat']){ - echo "<option selected VALUE='". $myrow1['categoryid'] . "'>" . $myrow1['categorydescription']; + echo "<option selected value='". $myrow1['categoryid'] . "'>" . $myrow1['categorydescription']; } else { - echo "<option VALUE='". $myrow1['categoryid'] . "'>" . $myrow1['categorydescription']; + echo "<option value='". $myrow1['categoryid'] . "'>" . $myrow1['categorydescription']; } } -?> -</select> -<td><font size=1><?php echo _('Enter text extracts in the'); ?> <b><?php echo _('description'); ?></b>:</font></td> -<td><input type="Text" name="Keywords" size=20 maxlength=25></td></tr> -<tr><td></td> -<td><font SIZE 3><b><?php echo _('OR'); ?> </b></font><font size=1><?php echo _('Enter extract of the'); ?> <b><?php echo _('Stock Code'); ?></b>:</font></td> -<td><input type="Text" name="StockCode" size=15 maxlength=18></td> -</tr> -</table><br> -<table align="center"><tr><td><input type=submit name="SearchParts" VALUE="<?php echo _('Search Parts Now'); ?>"> -<input type=submit name="ResetPart" VALUE="<?php echo _('Show All'); ?>"></td></tr></table> +echo "</select>"; +echo "<td><font size=1>" . _('Enter text extracts in the') . "<b>" . _('description') . "</b>:</font></td>"; +echo '<td><input type="Text" name="Keywords" size=20 maxlength=25></td></tr><tr><td></td>'; +echo "<td><font size<b>" . _('OR') . "</b></font><font size=1>" . _('Enter extract of the') . "<b>" . _('Stock Code') . "</b>:</font></td>"; +echo '<td><input type="Text" name="StockCode" size=15 maxlength=18></td></tr></table><br>'; +echo '<table><tr><td><input type=submit name="SearchParts" value="' . _('Search Parts Now') . '">'; +echo '<input type=submit name="ResetPart" value="' . _('Show All') . '"></td></tr></table>'; -<hr> +echo "<br>"; -<?php - if (isset($StockItemsResult)) { - echo '<table cellpadding=2 colspan=7 BORDER=2>'; + echo '<table cellpadding=2 colspan=7 class=selection>'; $TableHeader = '<tr><th>' . _('Code') . '</th> <th>' . _('Description') . '</th> <th>' . _('On Hand') . '</th> @@ -398,22 +390,24 @@ /*show a table of the orders returned by the SQL */ - echo '<table cellpadding=2 colspan=7 WIDTH=100%>'; + echo '<table cellpadding=2 colspan=7 width=97% class=selection>'; // '</td><td class="tableheader">' . _('Receive') . - $TableHeader = '<tr><th>' . _('Order #') . + + echo '<tr><th>' . _('Order #') . '</th><th>' . _('Order Date') . '</th><th>' . _('Initiated by') . '</th><th>' . _('Supplier') . '</th><th>' . _('Currency') . - '</th><th>' . _('Order Total') . - '</th><th>' . _('Status') . + '</th>'; + if (in_array($PricesSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($PricesSecurity)) { + echo '<th>' . _('Order Total') .'</th>'; + } + echo '<th>' . _('Status') . '</th><th>' . _('Modify') . '</th><th>' . _('Print') . '</th><th>' . _('Receive') . '</th></tr>'; - - echo $TableHeader; $j = 1; $k=0; //row colour counter while ($myrow=DB_fetch_array($PurchOrdersResult)) { @@ -466,36 +460,19 @@ // '</td><td class="tableheader">' . _('Requisition') . // '</td><td class="tableheader">' . _('Initiator') . // <td><a href='%s'>" . _('Receive') . "</a></td> - printf("<td>%s</font></td> - <td>%s</td> - <td>%s</td> - <td>%s</td> - <td>%s</font></td> - <td class=number>%s</font></td> - <td>%s</td> - <td><a href='%s'>Modify</a></font></td> - <td>%s</font></td> - <td>%s</font></td> - </tr>", - $myrow["orderno"], - $FormatedOrderDate, - $myrow['initiator'], - $myrow['suppname'], - $myrow['currcode'], - $FormatedOrderValue, - _($myrow['status']), - $ModifyPage, - $PrintPurchOrder, - $ReceiveOrder - ); - - - - $j++; - If ($j == 12){ - $j=1; - echo $TableHeader; + echo "<td>".$myrow["orderno"]."</font></td> + <td>".$FormatedOrderDate."</td> + <td>".$myrow['initiator']."</td> + <td>".$myrow['suppname']."</td> + <td>".$myrow['currcode']."</td>"; + if (in_array($PricesSecurity, $_SESSION['AllowedPageSecurityTokens']) OR !isset($PricesSecurity)) { + echo "<td class=number>".$FormatedOrderValue."</td>"; } + echo "<td>"._($myrow['status'])."</td> + <td><a href='".$ModifyPage."'>Modify</a></td> + <td>".$PrintPurchOrder."</td> + <td>".$ReceiveOrder."</td> + </tr>"; //end of page full new headings if } //end of while loop @@ -505,4 +482,4 @@ echo "<script>defaultControl(document.forms[0].StockCode);</script>"; echo '</form>'; include('includes/footer.inc'); -?> +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-19 18:30:12 UTC (rev 3644) +++ trunk/doc/Change.log.html 2010-07-19 18:30:33 UTC (rev 3645) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>19/07/10 Tim: PO_SelectOSPurchOrder.php - Remove order values when security token 12 is not set</p> <p>19/07/10 Tim: SelectProduct.php - Change prices security to token 12</p> <p>19/07/10 Tim: FixedAssetCategories.php - Layout changes and sql quoting</p> <p>19/07/10 Tim: FixedAssetItems.php - Layout changes and include editing of item type</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-19 20:49:32
|
Revision: 3646 http://web-erp.svn.sourceforge.net/web-erp/?rev=3646&view=rev Author: tim_schofield Date: 2010-07-19 20:49:25 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Layout changes and sql quoting, proper checks for deletion of location Modified Paths: -------------- trunk/FixedAssetLocations.php trunk/doc/Change.log.html Modified: trunk/FixedAssetLocations.php =================================================================== --- trunk/FixedAssetLocations.php 2010-07-19 18:30:33 UTC (rev 3645) +++ trunk/FixedAssetLocations.php 2010-07-19 20:49:25 UTC (rev 3646) @@ -1,6 +1,5 @@ <?php -/* $Id$*/ $PageSecurity = 11; include('includes/session.inc'); @@ -9,7 +8,7 @@ echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/maintenance.png" title="' . _('Search') . '" alt="">' . ' ' . $title; -if (isset($_POST['submit'])) { +if (isset($_POST['submit']) and !isset($_POST['delete'])) { $InputError=0; if (!isset($_POST['locationid']) or strlen($_POST['locationid'])<1) { prnMsg(_('You must enter at least one character in the location ID'),'error'); @@ -38,40 +37,74 @@ } else { $locationid=''; - $locdesc=''; + $locdesc=''; } -//Batman: Attempting to update fields +//Batman: Attempting to update fields -if (isset($_POST['update'])) { - $InputError=0; - /*Batman: Removing the ID +if (isset($_POST['update']) and !isset($_POST['delete'])) { + $InputError=0; + /*Batman: Removing the ID if (!isset($_POST['locationid']) or strlen($_POST['locationid'])<1) { - prnMsg(_('You must enter at least one character in the location ID'),'error'); - $InputError=1; - }*/ - if (!isset($_POST['locdesc']) or strlen($_POST['locdesc'])<1) { - prnMsg(_('You must enter at least one character in the location description'),'error'); - $InputError=1; - } - if ($InputError==0) { - $sql='UPDATE fixedassetlocations SET - locationdescription="'.$_POST['locdesc'].'", + prnMsg(_('You must enter at least one character in the location ID'),'error'); + $InputError=1; + }*/ + if (!isset($_POST['locdesc']) or strlen($_POST['locdesc'])<1) { + prnMsg(_('You must enter at least one character in the location description'),'error'); + $InputError=1; + } + if ($InputError==0) { + $sql='UPDATE fixedassetlocations SET + locationdescription="'.$_POST['locdesc'].'", parentlocationid="'.$_POST['parentlocationid'].'" - WHERE locationid ="'.$_POST['locationid'].'"'; - $result=DB_query($sql,$db); + WHERE locationid ="'.$_POST['locationid'].'"'; + $result=DB_query($sql,$db); //Batman: Testing leaking sql echo $sql; echo '<meta http-equiv="Refresh" content="0; url="'.$_SERVER['PHP_SELF'].'">'; } -} +} else { + // if you are not updating then you want to delete but lets be sure first. + if (isset($_POST['delete'])) { + $InputError=0; + if (!isset($_POST['locdesc']) or strlen($_POST['locdesc'])<1) { + prnMsg(_('You must enter at least one character in the location description'),'error'); + $InputError=1; + } + + $sql="SELECT COUNT(locationid) FROM fixedassetlocations WHERE parentlocationid='" . $_POST['locationid']."'"; + $result = DB_query($sql,$db); + $myrow=DB_fetch_row($result); + if ($myrow[0]>0) { + prnMsg(_('This location has child locations so cannot be removed'), 'warning'); + $InputError=1; + } + $sql="SELECT COUNT(id) FROM assetmanager WHERE location='" . $_POST['locationid']."'"; + $result = DB_query($sql,$db); + $myrow=DB_fetch_row($result); + if ($myrow[0]>0) { + prnMsg(_('You have assets in this location location so cannot be removed'), 'warning'); + $InputError=1; + } + if ($InputError==0) { + $sql = "DELETE FROM fixedassetlocations WHERE locationid = '".$_POST['locationid']."'"; + $result = DB_query($sql,$db); + prnMsg(_('The location has been deleted successfully'), 'success'); + } + } +} + $sql='SELECT * FROM fixedassetlocations'; $result=DB_query($sql, $db); -echo '<table><tr>'; -echo '<th>'._('Location ID').'</th><th>'._('Location Description').'</th><th>'._('Parent Location').'</th></tr>'; +if (DB_num_rows($result) > 0) { + echo '<table class=selection><tr>'; + echo '<th>'._('Location ID').'</th> + <th>'._('Location Description').'</th> + <th>'._('Parent Location').'</th></tr>'; +} +while ($myrow=DB_fetch_array($result)) { -while ($myrow=DB_fetch_array($result)) { - $parentsql='select locationdescription from fixedassetlocations where locationid="'.$myrow['parentlocationid'].'"'; + $parentsql="select locationdescription from fixedassetlocations where locationid='".$myrow['parentlocationid']."'"; $parentresult=DB_query($parentsql, $db); $parentrow=DB_fetch_array($parentresult); echo '<tr><td>'.$myrow['locationid'].'</td>'; @@ -79,20 +112,20 @@ echo '<td>'.$parentrow['locationdescription'].'</td>'; echo '<td><a href="'.$_SERVER['PHP_SELF'] . '?' . SID.'SelectedLocation='.$myrow['locationid'].'">' . _('Edit') . '</td>'; //Batman: added '; and duplicated line as below - echo '<td><a href="'.$_SERVER['PHP_SELF'] . '?' . SID.'SelectedLocation='.$myrow['locationid'].'">' . - _('Delete') . '</td></tr>'; //Batman: Just hashed this out</tr>'; } -//Batman: Captureing the location ID before the update process +//Batman: Capturing the location ID before the update process //echo $loc = "'.$_POST['locationid'].'"; echo '</table><br>'; -echo '<form name="LocationForm" method="post" action="' . $_SERVER['PHP_SELF'] . '?' . SID . '"><table>'; +echo '<form name="LocationForm" method="post" action="' . $_SERVER['PHP_SELF'] . '?' . SID . '"><table class=selection>'; echo '<tr><th style="text-align:left">'._('Location ID').'</th>'; -if (isset($_GET['SelectedLocation'])) - echo '<td><b><input type=text name=locationid size=6 value="'.$locationid.'"></b></td>'; -else +if (isset($_GET['SelectedLocation'])) { + echo '<input type=hidden name=locationid value="'.$locationid.'">'; + echo '<td>'.$locationid.'</td>'; +} else { echo '<td><input type=text name=locationid size=6 value="'.$locationid.'"></td></tr>'; +} echo '<tr><th style="text-align:left">'._('Location Description').'</th>'; echo '<td><input type=text name=locdesc size=20 value="'.$locdesc.'"></td></tr>'; @@ -118,15 +151,19 @@ echo '</table><br>'; -//Batman: parentlocationid checking the location ID +//Batman: parentlocationid checking the location ID //echo $locationid; echo '<div class="centre">'; -if (isset($_GET['SelectedLocation'])) - echo '<input type="Submit" name="update" value="' . _('Update Information') . '">'; -else echo '<input type="submit" name="submit" value="' . _('Enter Information') . '">'; +if (isset($_GET['SelectedLocation'])) { + echo '<input type="Submit" name="update" value="' . _('Update Information') . '">'; + echo '<p>'; + echo '<p><center><input type="Submit" name="delete" value="' . _('Delete This Location') . '">'; +} else { + echo '<input type="submit" name="submit" value="' . _('Enter Information') . '">'; +} echo '</div>'; echo '</form>'; include('includes/footer.inc'); -?> +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-19 18:30:33 UTC (rev 3645) +++ trunk/doc/Change.log.html 2010-07-19 20:49:25 UTC (rev 3646) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>19/07/10 Tim: FixedassetLocations.php - Layout changes and sql quoting, proper checks for deletion of location</p> <p>19/07/10 Tim: PO_SelectOSPurchOrder.php - Remove order values when security token 12 is not set</p> <p>19/07/10 Tim: SelectProduct.php - Change prices security to token 12</p> <p>19/07/10 Tim: FixedAssetCategories.php - Layout changes and sql quoting</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-19 20:49:56
|
Revision: 3647 http://web-erp.svn.sourceforge.net/web-erp/?rev=3647&view=rev Author: tim_schofield Date: 2010-07-19 20:49:50 +0000 (Mon, 19 Jul 2010) Log Message: ----------- Layout changes and sql quoting, use javascript to change location Modified Paths: -------------- trunk/FixedAssetTransfer.php trunk/doc/Change.log.html Modified: trunk/FixedAssetTransfer.php =================================================================== --- trunk/FixedAssetTransfer.php 2010-07-19 20:49:25 UTC (rev 3646) +++ trunk/FixedAssetTransfer.php 2010-07-19 20:49:50 UTC (rev 3647) @@ -1,6 +1,5 @@ <?php -/* $Id$*/ $PageSecurity = 11; include('includes/session.inc'); @@ -13,7 +12,7 @@ if (substr($key,0,4)=='move') { $id=substr($key,4); $location=$_POST['location'.$id]; - $sql='UPDATE assetmanager + $sql='UPDATE assetmanager SET location="'.$location.'" WHERE id='.$id; $result=DB_query($sql, $db); @@ -28,10 +27,9 @@ $sql='SELECT categoryid, categorydescription FROM stockcategory WHERE stocktype="'.'A'.'"'; $result=DB_query($sql, $db); echo '<form action="'. $_SERVER['PHP_SELF'] . '?' . SID .'" method=post>'; - echo '<b>' . $msg . '</b>'; - echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/magnifier.png" title="' . _('Search') . - '" alt="">' . ' ' . _('Search for a Fixed Asset'); - echo '<table><tr>'; + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/magnifier.png" title="' . _('Search') . + '" alt="">' . ' ' . $title . '</p>'; + echo '<table class=selection><tr>'; echo '<td>'. _('In Asset Category') . ': '; echo '<select name="StockCat">'; @@ -39,12 +37,6 @@ $_POST['StockCat'] = ""; } - if ($_POST['StockCat'] == "All") { - echo '<option selected value="All">' . _('All'); - } else { - echo '<option value="All">' . _('All'); - } - while ($myrow = DB_fetch_array($result)) { if ($myrow['categoryid'] == $_POST['StockCat']) { echo '<option selected VALUE="' . $myrow['categoryid'] . '">' . $myrow['categorydescription']; @@ -58,7 +50,7 @@ if (isset($_POST['Keywords'])) { - echo '<input type="text" name="Keywords" value="' . $_POST['Keywords'] . '" size=20 maxlength=25>'; + echo '<input type="text" name="Keywords" value="' . trim($_POST['Keywords'],'%') . '" size=20 maxlength=25>'; } else { echo '<input type="text" name="Keywords" size=20 maxlength=25>'; } @@ -69,7 +61,7 @@ echo '<td>'; if (isset($_POST['StockCode'])) { - echo '<input type="text" name="StockCode" value="'. $_POST['StockCode'] . '" size=15 maxlength=18>'; + echo '<input type="text" name="StockCode" value="'. trim($_POST['StockCode'],'%') . '" size=15 maxlength=18>'; } else { echo '<input type="text" name="StockCode" size=15 maxlength=18>'; } @@ -80,14 +72,14 @@ echo '<td>'; if (isset($_POST['StockCode'])) { - echo '<input type="text" name="SerialNumber" value="'. $_POST['SerialNumber'] . '" size=15 maxlength=18>'; + echo '<input type="text" name="SerialNumber" value="'. trim($_POST['SerialNumber'],'%') . '" size=15 maxlength=18>'; } else { echo '<input type="text" name="SerialNumber" size=15 maxlength=18>'; } - + echo '</td></tr></table><br>'; - echo '<div class="centre"><input type=submit name="Search" value="'. _('Search Now') . '"></div><hr></form>'; + echo '<div class="centre"><input type=submit name="Search" value="'. _('Search Now') . '"></div></form><br>'; } if (isset($_POST['Search'])) { if ($_POST['StockCat']=='All') { @@ -108,7 +100,7 @@ } else { $_POST['SerialNumber']='%'; } - $sql= 'SELECT assetmanager.*,stockmaster.description, fixedassetlocations.locationdescription + $sql= 'SELECT assetmanager.*,stockmaster.description, fixedassetlocations.locationdescription FROM assetmanager LEFT JOIN stockmaster ON assetmanager.stockid=stockmaster.stockid @@ -116,10 +108,10 @@ ON assetmanager.location=fixedassetlocations.locationid WHERE stockmaster.categoryid like "'.$_POST['StockCat'].'" AND stockmaster.description like "'.$_POST['Keywords'].'" - AND assetmanager.stockid like "'.$_POST['StockCode'].'" + AND assetmanager.stockid like "'.$_POST['StockCode'].'" AND assetmanager.serialno like "'.$_POST['SerialNumber'].'"'; $result=DB_query($sql, $db); - echo '<form action="'. $_SERVER['PHP_SELF'] . '?' . SID .'" method=post><table>'; + echo '<form action="'. $_SERVER['PHP_SELF'] . '?' . SID .'" method=post><table class=selection>'; echo '<tr><th>'._('Asset ID').'</th> <th>'._('Stock Code').'</th> <th>'._('Description').'</th> @@ -139,7 +131,7 @@ echo '<td class=number>'.number_format($myrow['cost'],2).'</td>'; echo '<td class=number>'.number_format($myrow['depn'],2).'</td>'; echo '<td>'.$myrow['locationdescription'].'</td>'; - echo '<td><select name="location'.$myrow['id'].'">'; + echo '<td><select name="location'.$myrow['id'].'" onChange="ReloadForm(move'.$myrow['id'].')">'; echo '<option></option>'; while ($locationrow=DB_fetch_array($locationresult)) { if ($locationrow['locationid']==$myrow['location']) { @@ -150,13 +142,18 @@ } } echo '</select></td>'; + echo '<input type=hidden name=StockCat value="' . $_POST['StockCat'].'"'; + echo '<input type=hidden name=Keywords value="' . $_POST['Keywords'].'"'; + echo '<input type=hidden name=StockCode value="' . $_POST['StockCode'].'"'; + echo '<input type=hidden name=SerialNumber value="' . $_POST['SerialNumber'].'"'; + echo '<input type=hidden name=Search value="' . $_POST['Search'].'"'; echo '<td><input type=submit name="move'.$myrow['id'].'" value=Move></td>'; echo '</tr>'; } echo '</table></form>'; } //} - + include('includes/footer.inc'); ?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-19 20:49:25 UTC (rev 3646) +++ trunk/doc/Change.log.html 2010-07-19 20:49:50 UTC (rev 3647) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>19/07/10 Tim: FixedassetTransfer.php - Layout changes and sql quoting, use javascript to change location</p> <p>19/07/10 Tim: FixedassetLocations.php - Layout changes and sql quoting, proper checks for deletion of location</p> <p>19/07/10 Tim: PO_SelectOSPurchOrder.php - Remove order values when security token 12 is not set</p> <p>19/07/10 Tim: SelectProduct.php - Change prices security to token 12</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-20 11:20:05
|
Revision: 3648 http://web-erp.svn.sourceforge.net/web-erp/?rev=3648&view=rev Author: tim_schofield Date: 2010-07-20 11:19:57 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Daily Transactions listings - Show reports correctly even in mysql strict mode Modified Paths: -------------- trunk/PDFCustTransListing.php trunk/PDFSuppTransListing.php trunk/doc/Change.log.html Modified: trunk/PDFCustTransListing.php =================================================================== --- trunk/PDFCustTransListing.php 2010-07-19 20:49:50 UTC (rev 3647) +++ trunk/PDFCustTransListing.php 2010-07-20 11:19:57 UTC (rev 3648) @@ -63,7 +63,7 @@ invtext FROM debtortrans WHERE type=" . $_POST['TransType'] . " - AND date_format(inputdate, '%Y/%m/%d')='".FormatDateForSQL($_POST['Date'])."'"; + AND date_format(inputdate, '%Y-%m-%d')='".FormatDateForSQL($_POST['Date'])."'"; $result=DB_query($sql,$db,'','',false,false); Modified: trunk/PDFSuppTransListing.php =================================================================== --- trunk/PDFSuppTransListing.php 2010-07-19 20:49:50 UTC (rev 3647) +++ trunk/PDFSuppTransListing.php 2010-07-20 11:19:57 UTC (rev 3648) @@ -63,7 +63,7 @@ transtext FROM supptrans WHERE type=" . $_POST['TransType'] . " - AND date_format(inputdate, '%Y/%m/%d')='".FormatDateForSQL($_POST['Date'])."'"; + AND date_format(inputdate, '%Y-%m-%d')='".FormatDateForSQL($_POST['Date'])."'"; $result=DB_query($sql,$db,'','',false,false); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-19 20:49:50 UTC (rev 3647) +++ trunk/doc/Change.log.html 2010-07-20 11:19:57 UTC (rev 3648) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>20/07/10 Tim: Daily Transactions listings - Show reports correctly even in mysql strict mode</p> <p>19/07/10 Tim: FixedassetTransfer.php - Layout changes and sql quoting, use javascript to change location</p> <p>19/07/10 Tim: FixedassetLocations.php - Layout changes and sql quoting, proper checks for deletion of location</p> <p>19/07/10 Tim: PO_SelectOSPurchOrder.php - Remove order values when security token 12 is not set</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-20 11:37:03
|
Revision: 3649 http://web-erp.svn.sourceforge.net/web-erp/?rev=3649&view=rev Author: tim_schofield Date: 2010-07-20 11:36:56 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Show value in functional currency, and show decimal places correctly Modified Paths: -------------- trunk/TopItems.php trunk/doc/Change.log.html Modified: trunk/TopItems.php =================================================================== --- trunk/TopItems.php 2010-07-20 11:19:57 UTC (rev 3648) +++ trunk/TopItems.php 2010-07-20 11:36:56 UTC (rev 3649) @@ -66,11 +66,15 @@ SUM(salesorderdetails.qtyinvoiced) TotalInvoiced, SUM(salesorderdetails.qtyinvoiced * salesorderdetails.unitprice ) AS ValueSales, stockmaster.description, - stockmaster.units - FROM salesorderdetails, salesorders, debtorsmaster,stockmaster + stockmaster.units, + currencies.rate, + debtorsmaster.currcode, + stockmaster.decimalplaces + FROM salesorderdetails, salesorders, debtorsmaster,stockmaster, currencies WHERE salesorderdetails.orderno = salesorders.orderno AND salesorderdetails.stkcode = stockmaster.stockid AND salesorders.debtorno = debtorsmaster.debtorno + AND debtorsmaster.currcode = currencies.currabrev AND salesorderdetails.ActualDispatchDate >= DATE_SUB(CURDATE(), INTERVAL " . $_POST['NumberOfDays'] . " DAY) GROUP BY salesorderdetails.stkcode ORDER BY " . $_POST["order"] . " DESC @@ -82,11 +86,15 @@ SUM(salesorderdetails.qtyinvoiced) TotalInvoiced, SUM(salesorderdetails.qtyinvoiced * salesorderdetails.unitprice ) AS ValueSales, stockmaster.description, - stockmaster.units - FROM salesorderdetails, salesorders, debtorsmaster,stockmaster + stockmaster.units, + currencies.rate, + debtorsmaster.currcode, + stockmaster.decimalplaces + FROM salesorderdetails, salesorders, debtorsmaster,stockmaster, currencies WHERE salesorderdetails.orderno = salesorders.orderno AND salesorderdetails.stkcode = stockmaster.stockid AND salesorders.debtorno = debtorsmaster.debtorno + AND debtorsmaster.currcode = currencies.currabrev AND debtorsmaster.typeid = '" . $_POST["Customers"] . "' AND salesorderdetails.ActualDispatchDate >= DATE_SUB(CURDATE(), INTERVAL " . $_POST['NumberOfDays'] . " DAY) GROUP BY salesorderdetails.stkcode @@ -100,11 +108,15 @@ SUM(salesorderdetails.qtyinvoiced) TotalInvoiced, SUM(salesorderdetails.qtyinvoiced * salesorderdetails.unitprice ) AS ValueSales, stockmaster.description, - stockmaster.units - FROM salesorderdetails, salesorders, debtorsmaster,stockmaster + stockmaster.units, + currencies.rate, + debtorsmaster.currcode, + stockmaster.decimalplaces + FROM salesorderdetails, salesorders, debtorsmaster,stockmaster, currencies WHERE salesorderdetails.orderno = salesorders.orderno AND salesorderdetails.stkcode = stockmaster.stockid AND salesorders.debtorno = debtorsmaster.debtorno + AND debtorsmaster.currcode = currencies.currabrev AND salesorders.fromstkloc = '" . $_POST["Location"] . "' AND salesorderdetails.ActualDispatchDate >= DATE_SUB(CURDATE(), INTERVAL " . $_POST['NumberOfDays'] . " DAY) GROUP BY salesorderdetails.stkcode @@ -117,11 +129,15 @@ SUM(salesorderdetails.qtyinvoiced) TotalInvoiced, SUM(salesorderdetails.qtyinvoiced * salesorderdetails.unitprice ) AS ValueSales, stockmaster.description, - stockmaster.units - FROM salesorderdetails, salesorders, debtorsmaster,stockmaster + stockmaster.units, + currencies.rate, + debtorsmaster.currcode, + stockmaster.decimalplaces + FROM salesorderdetails, salesorders, debtorsmaster,stockmaster, currencies WHERE salesorderdetails.orderno = salesorders.orderno AND salesorderdetails.stkcode = stockmaster.stockid AND salesorders.debtorno = debtorsmaster.debtorno + AND debtorsmaster.currcode = currencies.currabrev AND salesorders.fromstkloc = '" . $_POST["Location"] . "' AND debtorsmaster.typeid = '" . $_POST['Customers'] . "' AND salesorderdetails.ActualDispatchDate >= DATE_SUB(CURDATE(), INTERVAL " . $_POST['NumberOfDays'] . " DAY) @@ -165,7 +181,6 @@ echo '<tr class="OddTableRows">'; $k = 1; } - $val = number_format($myrow['2'], 2); printf('<td class="number">%s</td> <td>%s</font></td> <td>%s</td> @@ -175,8 +190,8 @@ <td class="number">%s</td> </tr>', $i, $myrow['0'], $myrow['3'], $myrow['1'], //total invoice here $myrow['4'], //unit - $val, //value sales here - $ohRow[0] //on hand + number_format($myrow['2']/$myrow['5'],2), //value sales here + number_format($ohRow[0], $myrow['7']) //on hand ); $i+= 1; } Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-20 11:19:57 UTC (rev 3648) +++ trunk/doc/Change.log.html 2010-07-20 11:36:56 UTC (rev 3649) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>20/07/10 Tim: TopItems.php - Show value in functional currency, and show decimal places correctly</p> <p>20/07/10 Tim: Daily Transactions listings - Show reports correctly even in mysql strict mode</p> <p>19/07/10 Tim: FixedassetTransfer.php - Layout changes and sql quoting, use javascript to change location</p> <p>19/07/10 Tim: FixedassetLocations.php - Layout changes and sql quoting, proper checks for deletion of location</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-20 13:55:45
|
Revision: 3650 http://web-erp.svn.sourceforge.net/web-erp/?rev=3650&view=rev Author: tim_schofield Date: 2010-07-20 13:55:38 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Add in the new quantity on hand field Modified Paths: -------------- trunk/StockLocMovements.php trunk/doc/Change.log.html Modified: trunk/StockLocMovements.php =================================================================== --- trunk/StockLocMovements.php 2010-07-20 11:36:56 UTC (rev 3649) +++ trunk/StockLocMovements.php 2010-07-20 13:55:38 UTC (rev 3650) @@ -11,6 +11,10 @@ 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="">' . ' ' . $title.'</p>'; + +echo '<table class=selection><tr><td>'; echo ' ' . _('From Stock Location') . ':<select name="StockLocation"> '; $sql = 'SELECT loccode, locationname FROM locations'; @@ -30,7 +34,7 @@ } } -echo '</select><br>'; +echo '</select>'; if (!isset($_POST['BeforeDate']) OR !Is_Date($_POST['BeforeDate'])){ $_POST['BeforeDate'] = Date($_SESSION['DefaultDateFormat']); @@ -40,8 +44,8 @@ } echo ' ' . _('Show Movements before') . ': <input type=TEXT name="BeforeDate" size=12 maxlength=12 Value="' . $_POST['BeforeDate'] . '">'; echo ' ' . _('But after') . ': <input type=TEXT name="AfterDate" size=12 maxlength=12 Value="' . $_POST['AfterDate'] . '">'; -echo ' <input type=submit name="ShowMoves" VALUE="' . _('Show Stock Movements') . '">'; -echo '<hr>'; +echo '</td></tr></table><br>'; +echo '<div class=centre><input type=submit name="ShowMoves" VALUE="' . _('Show Stock Movements') . '"></div><br>'; $SQLBeforeDate = FormatDateForSQL($_POST['BeforeDate']); @@ -72,7 +76,7 @@ $ErrMsg = _('The stock movements for the selected criteria could not be retrieved because'); $MovtsResult = DB_query($sql, $db,$ErrMsg); -echo '<table cellpadding=5 CELLSPACING=4 BORDER=0>'; +echo '<table cellpadding=5 CELLSPACING=4 class=selection>'; $tableheader = '<tr> <th>' . _('Item Code') . '</th> <th>' . _('Type') . '</th> @@ -83,6 +87,7 @@ <th>' . _('Reference') . '</th> <th>' . _('Price') . '</th> <th>' . _('Discount') . '</th> + <th>' . _('Quantity on Hand') . '</th> </tr>'; echo $tableheader; @@ -111,6 +116,7 @@ <td>%s</td> <td class=number>%s</td> <td class=number>%s</td> + <td class=number>%s</td> </tr>", strtoupper($myrow['stockid']), strtoupper($myrow['stockid']), @@ -122,7 +128,8 @@ $myrow['decimalplaces']), $myrow['reference'], number_format($myrow['price'],2), - number_format($myrow['discountpercent']*100,2)); + number_format($myrow['discountpercent']*100,2), + number_format($myrow['newqoh'],$myrow['decimalplaces'])); $j++; If ($j == 16){ $j=1; @@ -132,7 +139,7 @@ } //end of while loop -echo '</table><hr>'; +echo '</table>'; echo '</form>'; include('includes/footer.inc'); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-20 11:36:56 UTC (rev 3649) +++ trunk/doc/Change.log.html 2010-07-20 13:55:38 UTC (rev 3650) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>20/07/10 Tim: StockLocMovements.php - Add in the new quantity on hand field</p> <p>20/07/10 Tim: TopItems.php - Show value in functional currency, and show decimal places correctly</p> <p>20/07/10 Tim: Daily Transactions listings - Show reports correctly even in mysql strict mode</p> <p>19/07/10 Tim: FixedassetTransfer.php - Layout changes and sql quoting, use javascript to change location</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-20 13:56:04
|
Revision: 3651 http://web-erp.svn.sourceforge.net/web-erp/?rev=3651&view=rev Author: tim_schofield Date: 2010-07-20 13:55:58 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Add a filter to only show stock with available balances Modified Paths: -------------- trunk/StockLocStatus.php trunk/doc/Change.log.html Modified: trunk/StockLocStatus.php =================================================================== --- trunk/StockLocStatus.php 2010-07-20 13:55:38 UTC (rev 3650) +++ trunk/StockLocStatus.php 2010-07-20 13:55:58 UTC (rev 3651) @@ -16,16 +16,17 @@ } -echo '<hr><form action="' . $_SERVER['PHP_SELF'] . '?'. SID . '" method=post>'; +echo '<form action="' . $_SERVER['PHP_SELF'] . '?'. SID . '" method=post>'; $sql = "SELECT loccode, locationname FROM locations"; $resultStkLocs = DB_query($sql,$db); -echo '<table><tr><td>'; +echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Search') . + '" alt="">' . ' ' . $title.'</p>'; -echo '<table><tr><td>' . _('From Stock Location') . ':</td><td><select name="StockLocation"> '; +echo '<table class=selection><tr><td>' . _('From Stock Location') . ':</td><td><select name="StockLocation"> '; while ($myrow=DB_fetch_array($resultStkLocs)){ if (isset($_POST['StockLocation']) AND $_POST['StockLocation']!='All'){ if ($myrow['loccode'] == $_POST['StockLocation']){ @@ -45,9 +46,7 @@ $SQL='SELECT categoryid, categorydescription FROM stockcategory ORDER BY categorydescription'; $result1 = DB_query($SQL,$db); if (DB_num_rows($result1)==0){ - echo '</table></td></tr> - </table> - <p>'; + echo '</table><p>'; prnMsg(_('There are no stock categories currently defined please use the link below to set them up'),'warn'); echo '<br><a href="' . $rootpath . '/StockCategories.php?' . SID .'">' . _('Define Stock Categories') . '</a>'; include ('includes/footer.inc'); @@ -74,30 +73,28 @@ echo '</select></td></tr>'; -echo '<tr><td>' . _('Shown Only Items Where Available Less Than Re-order Quantity') . ':</td><td><select name="BelowReorderQuantity">'; +echo '<tr><td>' . _('Shown Only Items Where') . ':</td><td><select name="BelowReorderQuantity">'; if (!isset($_POST['BelowReorderQuantity'])){ $_POST['BelowReorderQuantity']='All'; } if ($_POST['BelowReorderQuantity']=='All'){ echo '<option selected value="All">' . _('All') . '</option>'; echo '<option value="Below">' . _('Only Items Below Re-order Quantity') . '</option>'; -} else { + echo '<option value="NotZero">' . _('Only items where stock is available') . '</option>'; +} else if ($_POST['BelowReorderQuantity']=='Below') { echo '<option value="All">' . _('All') . '</option>'; echo '<option selected value="Below">' . _('Only Items Below Re-order Quantity') . '</option>'; + echo '<option value="NotZero">' . _('Only items where stock is available') . '</option>'; +} else { + echo '<option value="All">' . _('All') . '</option>'; + echo '<option value="Below">' . _('Only Items Below Re-order Quantity') . '</option>'; + echo '<option selected value="NotZero">' . _('Only items where stock is available') . '</option>'; } - - echo '</td></tr></table>'; +echo '<br><div class="centre"><input type=submit name="ShowStatus" value="' . _('Show Stock Status') . '"></div>'; - -echo '</td></tr></table><br><div class="centre"><input type=submit name="ShowStatus" value="' . _('Show Stock Status') . '">'; - -echo '</div>'; -echo '<hr>'; - - if (isset($_POST['ShowStatus'])){ if ($_POST['StockCat']=='All') { @@ -144,7 +141,7 @@ $DbgMsg = _('The SQL that failed was'); $LocStockResult = DB_query($sql, $db, $ErrMsg, $DbgMsg); - echo '<table cellpadding=5 cellspacing=4 border=0>'; + echo '<br><table cellpadding=5 cellspacing=4 class=selection>'; $tableheader = '<tr> <th>' . _('StockID') . '</th> @@ -161,14 +158,6 @@ while ($myrow=DB_fetch_array($LocStockResult)) { - if ($k==1){ - echo '<tr class="OddTableRows">'; - $k=0; - } else { - echo '<tr class="EvenTableRows">'; - $k=1; - } - $StockID = $myrow['stockid']; $sql = "SELECT Sum(salesorderdetails.quantity-salesorderdetails.qtyinvoiced) AS dem @@ -242,16 +231,25 @@ $QOOQty = 0; } - if (($_POST['BelowReorderQuantity']=='Below' AND ($myrow['quantity']-$myrow['reorderlevel']-$DemandQty)<0) - OR $_POST['BelowReorderQuantity']=='All' ){ - - printf("<td><a target='_blank' href='StockStatus.php?StockID=%s'>%s</a></td> + if (($_POST['BelowReorderQuantity']=='Below' AND ($myrow['quantity']-$myrow['reorderlevel']-$DemandQty)<0) + OR $_POST['BelowReorderQuantity']=='All' OR $_POST['BelowReorderQuantity']=='NotZero'){ + + if (($_POST['BelowReorderQuantity']=='NotZero') and (($myrow['quantity']-$DemandQty)!=0)) { + + if ($k==1){ + echo '<tr class="OddTableRows">'; + $k=0; + } else { + echo '<tr class="EvenTableRows">'; + $k=1; + } + printf("<td><a target='_blank' href='StockStatus.php?StockID=%s'>%s</a></td> <td>%s</td> <td class=number>%s</td> <td class=number>%s</td> <td class=number>%s</td> <td class=number><a target='_blank' href='SelectProduct.php?StockID=%s'>%s</a></td> - <td class=number>%s</td>", + <td class=number>%s</td></tr>", strtoupper($myrow['stockid']), strtoupper($myrow['stockid']), $myrow['description'], @@ -261,25 +259,51 @@ strtoupper($myrow['stockid']), number_format($myrow['quantity'] - $DemandQty,$myrow['decimalplaces']), number_format($QOO,$myrow['decimalplaces'])); - - if ($myrow['serialised'] ==1){ /*The line is a serialised item*/ + if ($myrow['serialised'] ==1){ /*The line is a serialised item*/ - echo '<td><a target="_blank" href="' . $rootpath . '/StockSerialItems.php?' . SID . '&Serialised=Yes&Location=' . $myrow['loccode'] . '&StockID=' . $StockID . '">' . _('Serial Numbers') . '</a></td></tr>'; - } elseif ($myrow['controlled']==1){ - echo '<td><a target="_blank" href="' . $rootpath . '/StockSerialItems.php?' . SID . '&Location=' . $myrow['loccode'] . '&StockID=' . $StockID . '">' . _('Batches') . '</a></td></tr>'; + echo '<td><a target="_blank" href="' . $rootpath . '/StockSerialItems.php?' . SID . '&Serialised=Yes&Location=' . $myrow['loccode'] . '&StockID=' . $StockID . '">' . _('Serial Numbers') . '</a></td></tr>'; + } elseif ($myrow['controlled']==1){ + echo '<td><a target="_blank" href="' . $rootpath . '/StockSerialItems.php?' . SID . '&Location=' . $myrow['loccode'] . '&StockID=' . $StockID . '">' . _('Batches') . '</a></td></tr>'; + } + } else if ($_POST['BelowReorderQuantity']!='NotZero') { + if ($k==1){ + echo '<tr class="OddTableRows">'; + $k=0; + } else { + echo '<tr class="EvenTableRows">'; + $k=1; + } + printf("<td><a target='_blank' href='StockStatus.php?StockID=%s'>%s</a></td> + <td>%s</td> + <td class=number>%s</td> + <td class=number>%s</td> + <td class=number>%s</td> + <td class=number><a target='_blank' href='SelectProduct.php?StockID=%s'>%s</a></td> + <td class=number>%s</td>", + strtoupper($myrow['stockid']), + strtoupper($myrow['stockid']), + $myrow['description'], + number_format($myrow['quantity'],$myrow['decimalplaces']), + number_format($myrow['reorderlevel'],$myrow['decimalplaces']), + number_format($DemandQty,$myrow['decimalplaces']), + strtoupper($myrow['stockid']), + number_format($myrow['quantity'] - $DemandQty,$myrow['decimalplaces']), + number_format($QOO,$myrow['decimalplaces']).'xxx'); + if ($myrow['serialised'] ==1){ /*The line is a serialised item*/ + + echo '<td><a target="_blank" href="' . $rootpath . '/StockSerialItems.php?' . SID . '&Serialised=Yes&Location=' . $myrow['loccode'] . '&StockID=' . $StockID . '">' . _('Serial Numbers') . '</a></td></tr>'; + } elseif ($myrow['controlled']==1){ + echo '<td><a target="_blank" href="' . $rootpath . '/StockSerialItems.php?' . SID . '&Location=' . $myrow['loccode'] . '&StockID=' . $StockID . '">' . _('Batches') . '</a></td></tr>'; + } } - $j++; - If ($j == 20){ - $j=1; - echo $tableheader; - } + //end of page full new headings if } //end of if BelowOrderQuantity or all items } //end of while loop - echo '</table><hr>'; + echo '</table>'; echo '</form>'; } /* Show status button hit */ include('includes/footer.inc'); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-20 13:55:38 UTC (rev 3650) +++ trunk/doc/Change.log.html 2010-07-20 13:55:58 UTC (rev 3651) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>20/07/10 Tim: StockLocStatus.php - Add a filter to only show stock with available balances</p> <p>20/07/10 Tim: StockLocMovements.php - Add in the new quantity on hand field</p> <p>20/07/10 Tim: TopItems.php - Show value in functional currency, and show decimal places correctly</p> <p>20/07/10 Tim: Daily Transactions listings - Show reports correctly even in mysql strict mode</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-22 09:10:19
|
Revision: 3652 http://web-erp.svn.sourceforge.net/web-erp/?rev=3652&view=rev Author: tim_schofield Date: 2010-07-22 09:10:08 +0000 (Thu, 22 Jul 2010) Log Message: ----------- Layout changes, correctly export to csv, and sql quoting Modified Paths: -------------- trunk/FixedAssetRegister.php trunk/doc/Change.log.html trunk/includes/PDFAssetRegisterHeader.inc Modified: trunk/FixedAssetRegister.php =================================================================== --- trunk/FixedAssetRegister.php 2010-07-20 13:55:58 UTC (rev 3651) +++ trunk/FixedAssetRegister.php 2010-07-22 09:10:08 UTC (rev 3652) @@ -48,14 +48,11 @@ $line_height = 12; include ('includes/PDFAssetRegisterHeader.inc'); } elseif (isset($_POST['csv'])) { - $csv_output = "Asset ID,Stock ID"; // 'Description','Serial Number','Location','Date Acquired','Cost','Depreciation','NBV','Cost','Depreciation','NBV','Disposal Value'"; + $csv_output = "'Asset ID','Stock ID', 'Description','Serial Number','Location','Date Acquired','Cost','Depreciation','NBV','Disposal Value'"; $csv_output.= "\n"; } else { - echo '<form name="RegisterForm" method="post" action="' . $_SERVER['PHP_SELF'] . '?' . SID . '"><table>'; - echo '<br><table width=80% cellspacing="9"><tr>'; - echo '<th colspan=6></th>'; - echo '<th colspan=3>' . _('External Depreciation') . '</th>'; - echo '<th colspan=3>' . _('Internal Depreciation') . '</th><th></th></tr><tr>'; + echo '<form name="RegisterForm" method="post" action="' . $_SERVER['PHP_SELF'] . '?' . SID . '"><table class=selection>'; + echo '<br><table width=80% cellspacing="1" class=selection><tr>'; echo '<th>' . _('Asset ID') . '</th>'; echo '<th>' . _('Stock ID') . '</th>'; echo '<th>' . _('Description') . '</th>'; @@ -65,9 +62,6 @@ echo '<th>' . _('Cost') . '</th>'; echo '<th>' . _('Depreciation') . '</th>'; echo '<th>' . _('NBV') . '</th>'; - echo '<th>' . _('Cost') . '</th>'; - echo '<th>' . _('Depreciation') . '</th>'; - echo '<th>' . _('NBV') . '</th>'; echo '<th>' . _('Disposal Value') . '</th></tr>'; } while ($myrow = DB_fetch_array($result)) { @@ -84,17 +78,7 @@ $i++; $ancestors[$i] = $parentrow['locationdescription']; } - $catidsql = 'SELECT stkcatpropid FROM stockcatproperties WHERE categoryid="' . $myrow['categoryid'] . '" AND label="' . _('Annual Internal Depreciation Percentage') . '"'; - $catidresult = DB_query($catidsql, $db); - $catidrow = DB_fetch_array($catidresult); - $catvaluesql = 'SELECT value FROM stockitemproperties WHERE stockid="' . $myrow['stockid'] . '" AND stkcatpropid=' . $catidrow['stkcatpropid']; - $catvalueresult = DB_query($catvaluesql, $db); - $catvaluerow = DB_fetch_array($catvalueresult); $MonthsOld = DateDiff(date('d/m/Y'), ConvertSQLDate($myrow['datepurchased']), 'm'); - $InternalDepreciation = $myrow['cost'] * $catvaluerow['value'] / 100 * $MonthsOld / 12; - if (($InternalDepreciation + $myrow['disposalvalue']) > $myrow['cost']) { - $InternalDepreciation = $myrow['cost'] - $myrow['disposalvalue']; - } if (in_array($_POST['assetlocation'], $ancestors) or $_POST['assetlocation'] == 'All') { if (isset($_POST['pdf'])) { $LeftOvers = $pdf->addTextWrap($Xpos, $YPos, 300 - $Left_Margin, $FontSize, $myrow['id']); @@ -114,15 +98,14 @@ $LeftOvers = $pdf->addTextWrap($Xpos + 440, $YPos, 55, $FontSize, number_format($myrow['cost'], 0), 'right'); $LeftOvers = $pdf->addTextWrap($Xpos + 495, $YPos, 55, $FontSize, number_format($myrow['depn'], 0), 'right'); $LeftOvers = $pdf->addTextWrap($Xpos + 550, $YPos, 50, $FontSize, number_format($myrow['cost'] - $myrow['depn'], 0), 'right'); - $LeftOvers = $pdf->addTextWrap($Xpos + 600, $YPos, 55, $FontSize, number_format($myrow['cost'], 0), 'right'); - $LeftOvers = $pdf->addTextWrap($Xpos + 655, $YPos, 55, $FontSize, number_format($InternalDepreciation, 0), 'right'); - $LeftOvers = $pdf->addTextWrap($Xpos + 710, $YPos, 50, $FontSize, number_format($myrow['cost'] - $InternalDepreciation, 0), 'right'); $YPos = $TempYPos - (0.8 * $line_height); if ($YPos < $Bottom_Margin + $line_height) { include ('includes/PDFAssetRegisterHeader.inc'); } } elseif (isset($_POST['csv'])) { - $csv_output.= $myrow['id'] . "," . $myrow['stockid'] . "\n"; //;.",".$myrow['longdescription'].",".$myrow['serialno'].",".$myrow['locationdescription'].",".$myrow['datepurchased'].",".$myrow['cost'].",".$myrow['depn'].",".($myrow['cost']-$myrow['depn']).",".$myrow['cost'].",".$InternalDepreciation.",".($myrow['cost']-$InternalDepreciation).",".$myrow['disposalvalue']."\n"; + $csv_output.= $myrow['id'] . "," . $myrow['stockid'] .",".$myrow['longdescription'].",". + $myrow['serialno'].",".$myrow['locationdescription'].",".$myrow['datepurchased'].",".$myrow['cost']. + ",".$myrow['depn'].",".($myrow['cost']-$myrow['depn'])."\n"; } else { echo '<tr><td style="vertical-align:top">' . $myrow['id'] . '</td>'; @@ -140,16 +123,11 @@ echo '<td style="vertical-align:top" class=number>' . number_format($myrow['cost'], 2) . '</td>'; echo '<td style="vertical-align:top" class=number>' . number_format($myrow['depn'], 2) . '</td>'; echo '<td style="vertical-align:top" class=number>' . number_format($myrow['cost'] - $myrow['depn'], 2) . '</td>'; - echo '<td style="vertical-align:top" class=number>' . number_format($myrow['cost'], 2) . '</td>'; - echo '<td style="vertical-align:top" class=number>' . number_format($InternalDepreciation, 2) . '</td>'; - echo '<td style="vertical-align:top" class=number>' . number_format($myrow['cost'] - $InternalDepreciation, 2) . '</td>'; echo '<td style="vertical-align:top" class=number>' . number_format($myrow['disposalvalue'], 2) . '</td></tr>'; } $TotalCost = $TotalCost + $myrow['cost']; - $Totaldepn = $Totaldepn_pdf + $myrow['depn']; + $Totaldepn = $Totaldepn + $myrow['depn']; $TotalNBV = $TotalCost - $Totaldepn; - $TotaldepnInt = $TotaldepnInt + $InternalDepreciation; - $TotalNBVInt = $TotalCost - $TotaldepInt; $Totaldisp = $Totaldisp + $myrow['disposalvalue']; } } @@ -164,19 +142,15 @@ $LeftOvers = $pdf->addTextWrap($Xpos + 440, $YPos, 55, $FontSize, number_format($TotalCost, 2), 'right'); $LeftOvers = $pdf->addTextWrap($Xpos + 495, $YPos, 55, $FontSize, number_format($Totaldepn, 2), 'right'); $LeftOvers = $pdf->addTextWrap($Xpos + 550, $YPos, 50, $FontSize, number_format($TotalNBV, 2), 'right'); - //$LeftOvers = $pdf->addTextWrap($Xpos+600,$YPos,50,$FontSize, number_format($TotalNBV_pdf,2),'right'); - $LeftOvers = $pdf->addTextWrap($Xpos + 600, $YPos, 55, $FontSize, number_format($TotalCost, 2), 'right'); - $LeftOvers = $pdf->addTextWrap($Xpos + 655, $YPos, 50, $FontSize, number_format($TotaldepnInt, 2), 'right'); - $LeftOvers = $pdf->addTextWrap($Xpos + 705, $YPos, 55, $FontSize, number_format($TotalNBVInt, 2), 'right'); $pdf->Output($_SESSION['DatabaseName'] . '_Asset Register_' . date('Y-m-d') . '.pdf', 'I'); exit; } elseif (isset($_POST['csv'])) { // download now. WFT am I waiting for??? Don't use headers, kinda messy // $filename="/tmp/".date("Y-m-d").".csv"; - $filename = "/home/tim/workbench/webERP/trunk/companies/weberpdemo/reportwriter/test.csv"; + $filename = "companies/".$_SESSION['DatabaseName']."/reportwriter/test.csv"; $csvfile = fopen($filename, 'w'); $i = fwrite($csvfile, $csv_output); - header("Location: companies/weberpdemo/reportwriter/test.csv"); + header("Location: companies/".$_SESSION['DatabaseName']."/reportwriter/test.csv"); // echo "Testing successfully done"; // header("Content-Type: text/csv"); // header("Content-disposition: attachment; filename= $cvsfile"); @@ -188,31 +162,26 @@ echo '<input type=hidden name=assettype value=' . $_POST['assettype'] . '>'; echo '<input type=hidden name=assetlocation value=' . $_POST['assetlocation'] . '>'; //Total Values - echo '<tr></tr>'; echo '<tr><th style="vertical-align:top">TOTAL</th>'; echo '<th style="vertical-align:top"></th>'; echo '<th style="vertical-align:top"></th>'; echo '<th style="vertical-align:top"></th>'; echo '<th style="vertical-align:top"></th>'; echo '<th style="vertical-align:top"></th>'; - echo '<th style="vertical-align:top" class=number>' . number_format($TotalCost, 2) . '</th>'; - echo '<th style="vertical-align:top" class=number>' . number_format($Totaldepn, 2) . '</th>'; - echo '<th style="vertical-align:top" class=number>' . number_format($TotalNBV, 2) . '</th>'; - echo '<th style="vertical-align:top" class=number>' . number_format($TotalCost, 2) . '</th>'; - echo '<th style="vertical-align:top" class=number>' . number_format($TotaldepnInt, 2) . '</th>'; - echo '<th style="vertical-align:top" class=number>' . number_format($TotalNBVInt, 2) . '</th>'; - echo '<th style="vertical-align:top" class=number>' . number_format($Totaldisp, 2) . '</th></tr>'; + echo '<th style="text-align:right">' . number_format($TotalCost, 2) . '</th>'; + echo '<th style="text-align:right">' . number_format($Totaldepn, 2) . '</th>'; + echo '<th style="text-align:right">' . number_format($TotalNBV, 2) . '</th>'; + echo '<th style="text-align:right">' . number_format($Totaldisp, 2) . '</th></tr>'; echo '</table>'; - echo '<div class="centre"><input type="Submit" name="pdf" value="' . _('Print as a pdf') . '"></div></form>'; - echo '</p>'; - echo '<div class="centre"><input type="Submit" name="csv" value="' . _('Print as CSV') . '"></div></form>'; + echo '<br><div class="centre"><input type="Submit" name="pdf" value="' . _('Print as a pdf') . '"> '; + echo '<input type="Submit" name="csv" value="' . _('Print as CSV') . '"></div></form>'; } } else { include ('includes/header.inc'); echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Search') . '" alt="">' . ' ' . $title; $sql = "SELECT * FROM stockcategory WHERE stocktype='" . 'A' . "'"; $result = DB_query($sql, $db); - echo '<form name="RegisterForm" method="post" action="' . $_SERVER['PHP_SELF'] . '?' . SID . '"><table>'; + echo '<form name="RegisterForm" method="post" action="' . $_SERVER['PHP_SELF'] . '?' . SID . '"><table class=selection>'; echo '<tr><th>' . _('Asset Category') . '</th>'; echo '<td><select name=assetcategory>'; echo '<option value="%">' . _('ALL') . '</option>'; @@ -263,9 +232,9 @@ echo '</tr>'; //end of FULUSI STUFF echo '</table><br>'; - echo '<div class="centre"><input type="Submit" name="submit" value="' . _('Show Assets') . '"></div><br />'; - echo '<div class="centre"><input type="Submit" name="pdf" value="' . _('Print as a pdf') . '"></div><br/>'; - echo '<div class="centre"><input type="Submit" name = "csv" value= "' . _('Print as CSV') . '"></div>'; + echo '<div class="centre"><input type="Submit" name="submit" value="' . _('Show Assets') . '"> '; + echo '<input type="Submit" name="pdf" value="' . _('Print as a pdf') . '"> '; + echo '<input type="Submit" name = "csv" value= "' . _('Print as CSV') . '"></div>'; echo '</form>'; } include ('includes/footer.inc'); Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-20 13:55:58 UTC (rev 3651) +++ trunk/doc/Change.log.html 2010-07-22 09:10:08 UTC (rev 3652) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>20/07/10 Tim: FixedAssetRegister.php - Layout changes, correctly export to csv, and sql quoting</p> <p>20/07/10 Tim: StockLocStatus.php - Add a filter to only show stock with available balances</p> <p>20/07/10 Tim: StockLocMovements.php - Add in the new quantity on hand field</p> <p>20/07/10 Tim: TopItems.php - Show value in functional currency, and show decimal places correctly</p> Modified: trunk/includes/PDFAssetRegisterHeader.inc =================================================================== --- trunk/includes/PDFAssetRegisterHeader.inc 2010-07-20 13:55:58 UTC (rev 3651) +++ trunk/includes/PDFAssetRegisterHeader.inc 2010-07-22 09:10:08 UTC (rev 3652) @@ -54,8 +54,6 @@ /*set up the headings */ $FontSize=8; $Xpos = $Left_Margin+1; -$LeftOvers = $pdf->addTextWrap($Xpos+440,$YPos,300-$Left_Margin,$FontSize, _('<--------------External Depreciation-------------->'), 'centre'); -$LeftOvers = $pdf->addTextWrap($Xpos+605,$YPos,300-$Left_Margin,$FontSize, _('<--------------Internal Depreciation-------------->'), 'centre'); $YPos -=(0.8*$line_height); $LeftOvers = $pdf->addTextWrap($Xpos,$YPos,40,$FontSize, _('Asset ID'), 'centre'); $LeftOvers = $pdf->addTextWrap($Xpos+40,$YPos,300-$Left_Margin,$FontSize, _('Stock ID'), 'centre'); @@ -66,9 +64,6 @@ $LeftOvers = $pdf->addTextWrap($Xpos+440,$YPos,55,$FontSize, _('Cost'), 'right'); $LeftOvers = $pdf->addTextWrap($Xpos+495,$YPos,55,$FontSize, _('Depn'), 'right'); $LeftOvers = $pdf->addTextWrap($Xpos+550,$YPos,50,$FontSize, _('NBV'), 'right'); -$LeftOvers = $pdf->addTextWrap($Xpos+600,$YPos,55,$FontSize, _('Cost'), 'right'); -$LeftOvers = $pdf->addTextWrap($Xpos+655,$YPos,55,$FontSize, _('Depn'), 'right'); -$LeftOvers = $pdf->addTextWrap($Xpos+710,$YPos,50,$FontSize, _('NBV'), 'right'); $pdf->line($Left_Margin, $YTopLeft,$Page_Width-$Right_Margin, $YTopLeft); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-22 09:10:36
|
Revision: 3653 http://web-erp.svn.sourceforge.net/web-erp/?rev=3653&view=rev Author: tim_schofield Date: 2010-07-22 09:10:30 +0000 (Thu, 22 Jul 2010) Log Message: ----------- Layout changes, and sql quoting Modified Paths: -------------- trunk/PcAuthorizeExpenses.php trunk/doc/Change.log.html Modified: trunk/PcAuthorizeExpenses.php =================================================================== --- trunk/PcAuthorizeExpenses.php 2010-07-22 09:10:08 UTC (rev 3652) +++ trunk/PcAuthorizeExpenses.php 2010-07-22 09:10:30 UTC (rev 3653) @@ -34,23 +34,24 @@ if (isset($SelectedTabs)) { echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/magnifier.png" title="' . _('Petty Cash') . - '" alt="">' . ' <a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '">' . _('Authorization Of Petty Cash Expenses ') . ''.$SelectedTabs.'<a/>'; + '" alt="">' . _('Authorization Of Petty Cash Expenses ') . ''.$SelectedTabs.'</p>'; } else { echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/magnifier.png" title="' . _('Petty Cash') . - '" alt="">' . ' <a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '">' . _('Authorization Of Petty Cash Expenses ') . '<a/>'; + '" alt="">' . _('Authorization Of Petty Cash Expenses ') . '</p>'; } if (isset($_POST['submit']) or isset($_POST['update']) OR isset($SelectedTabs) OR isset ($_POST['GO'])) { echo "<form method='post' action=" . $_SERVER['PHP_SELF'] . '?' . SID . '>'; - echo "<div class='centre'><p>" . _('Detail Of Movement For Last ') .': '; if(!isset ($Days)){ $Days=30; } echo "<input type=hidden name='SelectedTabs' VALUE=" . $SelectedTabs . ">"; + echo '<br><table class=selection>'; + echo "<tr><th colspan=7>" . _('Detail Of Movement For Last ') .': '; echo "<input type=text class=number name='Days' VALUE=" . $Days . " MAXLENGTH =3 size=4> Days "; - echo '<input type=submit name="Go" value="' . _('Go') . '">'; - echo '<p></div></form>'; + echo '<input type=submit name="Go" value="' . _('Go') . '"></tr></th>'; + echo '</form>'; $sql = "SELECT pcashdetails.counterindex, pcashdetails.tabcode, @@ -69,13 +70,12 @@ FROM pcashdetails, pctabs, currencies WHERE pcashdetails.tabcode = pctabs.tabcode AND pctabs.currency = currencies.currabrev - AND pcashdetails.tabcode = '$SelectedTabs' - AND pcashdetails.date >= DATE_SUB(CURDATE(), INTERVAL ".$Days." DAY) + AND pcashdetails.tabcode = '" . $SelectedTabs . "' + AND pcashdetails.date >= DATE_SUB(CURDATE(), INTERVAL '".$Days."' DAY) ORDER BY pcashdetails.date, pcashdetails.counterindex ASC"; $result = DB_query($sql,$db); - echo '<br><table BORDER=1>'; echo "<tr> <th>" . _('Date') . "</th> <th>" . _('Expense Code') . "</th> @@ -124,6 +124,7 @@ //build narrative $narrative= "PettyCash - ".$myrow['tabcode']." - ".$myrow['codeexpense']." - ".$myrow['notes']." - ".$myrow['receipt'].""; //insert to gltrans + DB_Txn_Begin($db); $sqlFrom="INSERT INTO `gltrans` (`counterindex`, @@ -151,7 +152,7 @@ '', 0)"; - $ResultFrom = DB_Query($sqlFrom, $db); + $ResultFrom = DB_Query($sqlFrom, $db, '', '', true); $sqlTo="INSERT INTO `gltrans` (`counterindex`, @@ -179,12 +180,12 @@ '', 0)"; - $ResultTo = DB_Query($sqlTo, $db); + $ResultTo = DB_Query($sqlTo, $db, '', '', true); if ($myrow['codeexpense'] == 'ASSIGNCASH'){ // if it's a cash assignation we need to updated banktrans table as well. $ReceiptTransNo = GetNextTransNo( 2, $db); - $SQLBank= 'INSERT INTO banktrans (transno, + $SQLBank= "INSERT INTO banktrans (transno, type, bankact, ref, @@ -194,15 +195,15 @@ banktranstype, amount, currcode) - VALUES (' . $ReceiptTransNo . ', + VALUES ('". $ReceiptTransNo . "', 1, - ' . $AccountFrom . ", '" - . $narrative . " ', + '" . $AccountFrom . "', + '" . $narrative . "', 1, - " . $myrow['rate'] . ", + '" . $myrow['rate'] . "', '" . $myrow['date'] . "', 'Cash', - " . -$myrow['amount'] . ", + '" . -$myrow['amount'] . "', '" . $myrow['currency'] . "' )"; $ErrMsg = _('Cannot insert a bank transaction because'); @@ -215,7 +216,8 @@ SET authorized = '".Date('Y-m-d')."', posted = 1 WHERE counterindex = '".$myrow['counterindex']."'"; - $resultupdate = DB_query($sql,$db); + $resultupdate = DB_query($sql,$db, '', '', true); + DB_Txn_Commit($db); } if ($k==1){ @@ -261,8 +263,7 @@ echo "<form method='post' action=" . $_SERVER['PHP_SELF'] . '?' . SID . '>'; - echo '<p><table border=1>'; //Main table - echo '<td><table>'; // First column + echo '<p><table class=selection>'; //Main table echo '<tr><td>' . _('Authorize expenses to Petty Cash Tab') . ":</td><td><select name='SelectedTabs'>"; @@ -285,12 +286,11 @@ echo '</select></td></tr>'; - echo '</table>'; // close table in first column - echo '</td></tr></table>'; // close main table + echo '</td></tr></table>'; // close main table echo '<p><div class="centre"><input type=submit name=process VALUE="' . _('Accept') . '"><input type=submit name=Cancel VALUE="' . _('Cancel') . '"></div>'; echo '</form>'; } /*end of else not submit */ include('includes/footer.inc'); -?> +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-22 09:10:08 UTC (rev 3652) +++ trunk/doc/Change.log.html 2010-07-22 09:10:30 UTC (rev 3653) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>20/07/10 Tim: PcAuthoriseExpenses.php - Layout changes, and sql quoting</p> <p>20/07/10 Tim: FixedAssetRegister.php - Layout changes, correctly export to csv, and sql quoting</p> <p>20/07/10 Tim: StockLocStatus.php - Add a filter to only show stock with available balances</p> <p>20/07/10 Tim: StockLocMovements.php - Add in the new quantity on hand field</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-22 09:11:24
|
Revision: 3654 http://web-erp.svn.sourceforge.net/web-erp/?rev=3654&view=rev Author: tim_schofield Date: 2010-07-22 09:11:16 +0000 (Thu, 22 Jul 2010) Log Message: ----------- Update to latest phplot, add in choice of graph types layout changes, and sql quoting Modified Paths: -------------- trunk/SalesGraph.php trunk/doc/Change.log.html trunk/includes/phplot/ChangeLog trunk/includes/phplot/NEWS.txt trunk/includes/phplot/README.txt trunk/includes/phplot/phplot.php Added Paths: ----------- trunk/includes/phplot/HorizontalBars.txt trunk/includes/phplot/contrib/ trunk/includes/phplot/contrib/README.txt trunk/includes/phplot/contrib/color_range.example.php trunk/includes/phplot/contrib/color_range.php trunk/includes/phplot/contrib/color_range.test1.php trunk/includes/phplot/contrib/color_range.test2.php trunk/includes/phplot/contrib/prune_labels.example.php trunk/includes/phplot/contrib/prune_labels.php trunk/includes/phplot/contrib/prune_labels.test.php Modified: trunk/SalesGraph.php =================================================================== --- trunk/SalesGraph.php 2010-07-22 09:10:30 UTC (rev 3653) +++ trunk/SalesGraph.php 2010-07-22 09:11:16 UTC (rev 3654) @@ -6,11 +6,11 @@ include('includes/phplot/phplot.php'); $title=_('Sales Report Graph'); include('includes/header.inc'); - + $SelectADifferentPeriod =''; - + if (isset($_POST['FromPeriod']) AND isset($_POST['ToPeriod'])){ - + if ($_POST['FromPeriod'] > $_POST['ToPeriod']){ prnMsg(_('The selected period from is actually after the period to! Please re-select the reporting period'),'error'); $SelectADifferentPeriod =_('Select A Different Period'); @@ -24,14 +24,16 @@ $SelectADifferentPeriod= _('Select A Different Period'); } } - - if ((! isset($_POST['FromPeriod']) OR ! isset($_POST['ToPeriod'])) + + if ((! isset($_POST['FromPeriod']) OR ! isset($_POST['ToPeriod'])) OR $SelectADifferentPeriod==_('Select A Different Period')){ - + echo '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '?' . SID . '">'; + + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/maintenance.png" title="' . _('Search') . '" alt="">' . ' ' . $title.'</p>'; /*Show a form to allow input of criteria for TB to show */ - echo '<table><tr><td>' . _('Select Period From:') . '</td><td><select Name="FromPeriod">'; - + echo '<table class=selection><tr><td>' . _('Select Period From:') . '</td><td><select Name="FromPeriod">'; + if (Date('m') > $_SESSION['YearEnd']){ /*Dates in SQL format */ $DefaultFromDate = Date ('Y-m-d', Mktime(0,0,0,$_SESSION['YearEnd'] + 2,0,Date('Y'))); @@ -59,11 +61,7 @@ echo '</select></td></tr>'; if (!isset($_POST['ToPeriod']) OR $_POST['ToPeriod']==''){ - $sql = 'SELECT Max(periodno) FROM periods'; - $MaxPrd = DB_query($sql,$db); - $MaxPrdrow = DB_fetch_row($MaxPrd); - - $DefaultToPeriod = (int) ($MaxPrdrow[0]-1); + $DefaultToPeriod = GetPeriod(DateAdd(ConvertSQLDate($DefaultFromDate),'m',11),$db); } else { $DefaultToPeriod = $_POST['ToPeriod']; } @@ -81,9 +79,9 @@ } } echo '</select></td></tr>'; - + $AreasResult = DB_query('SELECT areacode, areadescription FROM areas',$db); - + if (!isset($_POST['SalesArea'])){ $_POST['SalesArea']=''; } @@ -101,9 +99,9 @@ } } echo '</select></td></tr>'; - + $CategoriesResult = DB_query('SELECT categoryid, categorydescription FROM stockcategory',$db); - + if (!isset($_POST['CategoryID'])){ $_POST['CategoryID']=''; } @@ -121,16 +119,16 @@ } } echo '</select></td></tr>'; - + $SalesFolkResult = DB_query('SELECT salesmancode, salesmanname FROM salesman',$db); - - + + if (! isset($_POST['SalesmanCode'])){ $_POST['SalesmanCode'] = ''; } - + echo '<tr><td>' . _('For Sales Person:') .'</td><td><select Name="SalesmanCode">'; - + if($_POST['SalesmanCode']=='All'){ echo '<option selected VALUE="All">' . _('All'); } else { @@ -144,7 +142,21 @@ } } echo '</select></td><td>' . $_POST['SalesmanCode'] . '</td></tr>'; - + + echo '<tr><td>'._('Graph Type').'</td>'; + echo '<td><select name=GraphType>'; + echo '<option value=bars>'._('Bar Graph').'</option>'; + echo '<option value=stackedbars>'._('Stacked Bar Graph').'</option>'; + echo '<option value=lines>'._('Line Graph').'</option>'; + echo '<option value=linepoints>'._('Line Point Graph').'</option>'; + echo '<option value=area>'._('Area Graph').'</option>'; + echo '<option value=points>'._('Points Graph').'</option>'; + echo '<option value=pie>'._('Pie Graph').'</option>'; + echo '<option value=thinbarline>'._('Thin Bar Line Graph').'</option>'; + echo '<option value=squared>'._('Squared Graph').'</option>'; + echo '<option value=stackedarea>'._('Stacked Area Graph').'</option>'; + echo '</select></td></tr>'; + if (!isset($_POST['ValueFrom'])){ $_POST['ValueFrom']=''; } @@ -157,17 +169,18 @@ <input type="RADIO" name="GraphOn" VALUE="StockID">' . _('Item Code') . '</td></tr>'; echo '<tr><td>' . _('From:') . ' <input type=TEXT name="ValueFrom" VALUE=' . $_POST['ValueFrom'] . '></td> <td>' . _('To:') . ' <input type=TEXT name="ValueTo" VALUE=' . $_POST['ValueTo'] . '></td></tr>'; - + echo '<tr><td>' . _('Graph Value:') . '</td><td> <input type="RADIO" name="GraphValue" VALUE="Net" CHECKED>' . _('Net Sales Value') . '<br> <input type="RADIO" name="GraphValue" VALUE="GP">' . _('Gross Profit') . '<br> - <input type="RADIO" name="GraphValue" VALUE="Quantity">' . _('Quantity') . '</td></tr>'; - + <input type="RADIO" name="GraphValue" VALUE="Quantity">' . _('Quantity') . '</td></tr>'; + echo '</table>'; - + echo '<br><div class="centre"><input type=submit Name="ShowGraph" Value="' . _('Show Sales Graph') .'"></div>'; - } else { - + include('includes/footer.inc'); +} else { + $graph =& new PHPlot(950,450); $SelectClause =''; $WhereClause =''; @@ -182,9 +195,9 @@ $GraphTitle = _('Unit Sales'); $SelectClause = 'qty'; } - + $GraphTitle .= ' ' . _('From Period') . ' ' . $_POST['FromPeriod'] . ' ' . _('to') . ' ' . $_POST['ToPeriod'] . "\n\r"; - + if ($_POST['SalesArea']=='All'){ $GraphTitle .= ' ' . _('For All Sales Areas'); } else { @@ -200,7 +213,7 @@ $myrow = DB_fetch_row($result); $GraphTitle .= ' ' . _('For') . ' ' . $myrow[0]; $WhereClause .= " stkcategory='" . $_POST['CategoryID'] . "' AND"; - + } if ($_POST['SalesmanCode']=='All'){ $GraphTitle .= ' ' . _('For All Salespeople'); @@ -209,7 +222,7 @@ $myrow = DB_fetch_row($result); $GraphTitle .= ' ' . _('For Salesperson:') . ' ' . $myrow[0]; $WhereClause .= " salesperson='" . $_POST['SalesmanCode'] . "' AND"; - + } if ($_POST['GraphOn']=='Customer'){ $GraphTitle .= ' ' . _('For Customers from') . ' ' . $_POST['ValueFrom'] . ' ' . _('to') . ' ' . $_POST['ValueTo']; @@ -219,45 +232,44 @@ $GraphTitle .= ' ' . _('For Items from') . ' ' . $_POST['ValueFrom'] . ' ' . _('to') . ' ' . $_POST['ValueTo']; $WhereClause .= " stockid>='" . $_POST['ValueFrom'] . "' AND stockid<='" . $_POST['ValueTo'] . "' AND"; } - + $WhereClause = 'WHERE ' . $WhereClause . ' salesanalysis.periodno>=' . $_POST['FromPeriod'] . ' AND salesanalysis.periodno <= ' . $_POST['ToPeriod']; - - $SQL = 'SELECT salesanalysis.periodno, - periods.lastdate_in_period, + + $SQL = 'SELECT salesanalysis.periodno, + periods.lastdate_in_period, SUM(CASE WHEN budgetoractual=1 THEN ' . $SelectClause . ' ELSE 0 END) AS sales, SUM(CASE WHEN budgetoractual=0 THEN ' . $SelectClause . ' ELSE 0 END) AS budget FROM salesanalysis INNER JOIN periods ON salesanalysis.periodno=periods.periodno ' . $WhereClause . ' GROUP BY salesanalysis.periodno, periods.lastdate_in_period ORDER BY salesanalysis.periodno'; - - + + $graph->SetTitle($GraphTitle); $graph->SetTitleColor('blue'); $graph->SetOutputFile('companies/' .$_SESSION['DatabaseName'] . '/reports/salesgraph.png'); $graph->SetXTitle(_('Month')); - if ($_POST['GraphValue']=='Net'){ + if ($_POST['GraphValue']=='Net'){ $graph->SetYTitle(_('Sales Value')); - } elseif ($_POST['GraphValue']=='GP'){ + } elseif ($_POST['GraphValue']=='GP'){ $graph->SetYTitle(_('Gross Profit')); } else { $graph->SetYTitle(_('Quantity')); } $graph->SetXTickPos('none'); $graph->SetXTickLabelPos('none'); - $graph->SetBackgroundColor("wheat"); + $graph->SetBackgroundColor("selection"); $graph->SetTitleColor("blue"); $graph->SetFileFormat("png"); - $graph->SetPlotType("bars"); + $graph->SetPlotType($_POST['GraphType']); $graph->SetIsInline("1"); $graph->SetShading(5); $graph->SetDrawYGrid(TRUE); - $graph->SetMarginsPixels(80,40,40,40); $graph->SetDataType('text-data'); - + $SalesResult = DB_query($SQL, $db); if (DB_error_no($db) !=0) { - + prnMsg(_('The sales graph data for the selected criteria could not be retrieved because') . ' - ' . DB_error_msg($db),'error'); include('includes/footer.inc'); exit; @@ -267,24 +279,26 @@ include('includes/footer.inc'); exit; } - + $GraphArrays = array(); $i = 0; while ($myrow = DB_fetch_array($SalesResult)){ $GraphArray[$i] = array(MonthAndYearFromSQLDate($myrow['lastdate_in_period']),$myrow['sales'],$myrow['budget']); $i++; } - + $graph->SetDataValues($GraphArray); $graph->SetDataColors( - array('blue','red'), //Data Colors + array('grey','wheat'), //Data Colors array('black') //Border Colors - ); + ); $graph->SetLegend(array(_('Actual'),_('Budget'))); - + //Draw it $graph->DrawGraph(); + echo '<table class=selection><tr><td>'; echo '<p><img src="companies/' .$_SESSION['DatabaseName'] . '/reports/salesgraph.png" alt="Sales Report Graph"></img></p>'; + echo '</td></tr></table>'; include('includes/footer.inc'); } ?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-22 09:10:30 UTC (rev 3653) +++ trunk/doc/Change.log.html 2010-07-22 09:11:16 UTC (rev 3654) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>20/07/10 Tim: SalesGraph.php - Layout changes, and sql quoting</p> <p>20/07/10 Tim: PcAuthoriseExpenses.php - Layout changes, and sql quoting</p> <p>20/07/10 Tim: FixedAssetRegister.php - Layout changes, correctly export to csv, and sql quoting</p> <p>20/07/10 Tim: StockLocStatus.php - Add a filter to only show stock with available balances</p> Modified: trunk/includes/phplot/ChangeLog =================================================================== --- trunk/includes/phplot/ChangeLog 2010-07-22 09:10:30 UTC (rev 3653) +++ trunk/includes/phplot/ChangeLog 2010-07-22 09:11:16 UTC (rev 3654) @@ -2,6 +2,168 @@ The project home page is http://sourceforge.net/projects/phplot/ ----------------------------------------------------------------------------- +2010-06-29 (lbayuk) ===== Released as 5.1.2 ===== + * phplot.php: Updated version + * README.txt: Updated for new release + * NEWS.txt: Add text for new release + +2010-06-26 + * Feature request 2885930 "Horizontal Bars": + Horizontal bar charts are implemented, as an experimental feature. + A new data type 'text-data-yx' was added, which works with + 'bars' plot type to produce a horizontal bar chart from a data + array with X values for each Y value. Changes were made to + FindDataLimits, CalcMargins, CalcPlotAreaWorld, CalcBarWidths, + and CalcMaxDataLabelSize to handle the new data type. Other + changes were made to handle label position defaults and grid + defaults. New drawing functions were added for horizontal bars. + + * HorizontalBars.txt: new documentation file for experimental feature. + * Makefile: List new documentation file. + +2010-06-25 + * Each plot-type drawing function now checks that it is getting a data + type that it knows how to handle. A new internal function unifies the + checking and error message. (This is associated with an upcoming, + bigger change.) + + Compatibility: If you were using an invalid data type for a plot type + whose function did not check, will now get an error. + + * Removed some dubious code from DrawLines() and DrawSquared() and + rewrote comments there. The code initialized lastx[0] and lasty[0], + but lasty was mapped using the X (rather than Y) function. This was + obviously wrong, but closer inspection showed that the values were + never, used so the code was removed. + +2010-06-13 + * Truecolor.txt: removed + * Makefile, README.txt: Removed reference to Truecolor.txt. Full + documentation for truecolor images is now in the Reference Manual. + +2010-06-02 + * Fix bug 3010116 "Bad rendering of title in multi-plot image + when using TTF": + Make sure the main title is drawn only once. (If drawn multiple + times with TrueType font text, the anti-aliasing effects result + in poor quality text.) + +2010-05-31 + * Improvements to truecolor support (from feature request 2947679): + Truecolor support is now better integrated. The derived class only + has the constructor now, and the base class itself provides the alpha + color component support through the internal functions SetIndexColor(), + SetIndexDarkColor(), and SetRGBColor(). This means alpha channel + works with palette images too (in so far as GD supports this). + + * Truecolor.txt: Updated per changes to truecolor support. + + * Image tiling with mode 'scale' in tile_img(), used with image and + plot area backgrounds, now uses imagecopyresampled() rather than + imagecopyresized(). They are the same with palette images, but the + resampled copy gets better results with truecolor images. + +2010-05-29 + * Feature request 3002606 "Add to plot and image border options": + Added options 'right', 'top', and 'bottom' to SetPlotBorderType() + (existing options are 'left', 'sides', 'none', and 'full'). This + now also accepts an array of the above options, giving complete + control over which sides to draw. + Added option 'solid' to SetImageBorderType() to use the actual + color set with SetImageBorderColor(), rather than the darker + shade as type 'plain' does (for some reason). + New function SetImageBorderWidth() sets the width of the image + border. The image border width is now accounted for in margin + calculations, although existing plots will not change. + +2010-04-04 (lbayuk) ===== Released as 5.1.1 ===== + * phplot.php: Updated version + * README.txt: Updated for new release + * NEWS.txt: Add text for new release + +2010-04-01 + * Remove & from argument in SetDataValues(). The data array is not + modified and does not need to be passed by reference. (There is + no performance advantage, either.) + +2010-03-29 + * Feature request 2947679 "Support for alpha blending/Truecolor": + Implemented truecolor image support with a new class + PHPlot_truecolor, extended color specifications to allow + specification of an alpha value, and added a new optional parameter + to SetDataColors for a default alpha value for all data colors. + This feature is *EXPERIMENTAL* (see next item). + + * Truecolor.txt: New file, documentation for the new truecolor capability. + (The Truecolor feature is experimental, which means it is subject to + change in incompatible ways and the documentation has not yet been + incorporated into the PHPlot Reference Manual.) + + * Makefile: Include new documentation file in release. + +2010-03-26 + Fixed bug 2976735 "Improvements and fixes for 'area' plots": + Rewrote DrawArea() function which handles 'area' plot. + Part 1: This is related to feature request 2947679, Truecolor support + with transparency. The area plot function was filling each area from the X + axis up to the Y value, resulting in area overlaps. This wasn't a problem + with opaque colors, but with transparency, the overlapping areas resulted + in changed colors. The rewritten function fills the area between each line + instead of from each line down to the X axis. Plots with opaque colors + will not change. + Part 2: Area plots now work when the X axis is moved up with + SetXAxisPosition(). + Part 3: Fixed FindDataLimits() for area (and stackedbars too) to + take absolute values of Y values. The drawing function was doing this, + but not FindDataLimits, resulting in incorrect limits if any Y<0. + Part 4: The rewritten DrawArea() also handles a new plot type + 'stackedarea'. This is an area plot where the Y values are stacked, + similar to 'stackedbars'. + Note: As part of the changes, it is now an error to try an area plot + with an unequal number of Y points for each X. + +2010-03-23 + * Feature request 2973995 "Add y-Data to Stackedbars": + Implemented Y Data Labels for Stacked Bar charts (stackedbars). + The labels are enabled with SetYDataLabelPos, same as with bar charts. + There are two types of labels: above the stack with the total, and + within the bars at each segment. 'plotin' turns on the upper ones, and + 'plotstack' turns both on. + + * Other changes: + + Removed unimplemented second argument to SetYDataLabelPos. + + Fixed questionable logic in SetYDataLabelPos when given an argument + that belongs with SetYTickLabelPos. + + Fix comments at top of plot-type Draw functions. + + * Fix for bug 2974639 "Stacked bars plot breaks with X axis != 0": + Stacked bar plots with non-zero X axis position no longer break apart + into segments with gaps. The bars are drawn up from the X axis, and + any segments or partial segments below the X axis are not drawn. + +2010-03-22 + * Change related to feature request 2947679 - Fix 'dot' point shape: + Use imagefilledellipse(), not imagefilledarc(), when drawing the 'dot' + point shape. The fix was needed for future support of truecolor images + with transparency, but filled dots from imagefilledellipse() look + better (rounder) with regular images and opaque colors. + Credit to mvaldez for identifying the problem and providing the fix. + +2010-03-04 + * Fix for bug 2963757 "point_counts undefined error in 5.1.0": + Fixed CheckPointParams so it sets point_counts even when the point shape + and point size arrays are already the same size and do not need padding. + +2010-01-26 + * Fix for bug 2938219 "Bars go in wrong direction": + Fixed CalcAxisPositions() to be consistent in positioning the X axis. + When all Y values are <0 and the Y=0 line is not part of the plot range, + PHPlot will now default the X axis to the top of the plot, not the + bottom. This fixes the problem with bars to negative Y values being + drawn downward if Y=0 is visible, but upward if Y=0 is not visible. + This also affects thinbarline plots. + Credit to lauryn1298 for finding the bug. + 2009-12-24 (lbayuk) ===== Released as 5.1.0 ===== 2009-12-18 Added: trunk/includes/phplot/HorizontalBars.txt =================================================================== --- trunk/includes/phplot/HorizontalBars.txt (rev 0) +++ trunk/includes/phplot/HorizontalBars.txt 2010-07-22 09:11:16 UTC (rev 3654) @@ -0,0 +1,243 @@ +phplot/HorizontalBars - Documentation for an experimental new plot type +Last updated for PHPlot-5.1.2 on 2010-06-26 +The project home page is http://sourceforge.net/projects/phplot/ +----------------------------------------------------------------------------- +Overview: + +This file documents a new plot type, Horizontal Bars. This was added to +PHPlot in version 5.1.2 as an experimental feature. + + NOTICE: + + This new plot type is experimental. This means anything about this + may change in future releases, in ways that might be incompatible + with the current implementation, or the new plot type might even + be removed completely. The new plot type is not yet documented in + the PHPlot Reference Manual. This text file is the only documentation. + +Feedback on this feature is welcome. Please use the "help & discussion" +forum at http://sourceforge.net/projects/phplot/ + +----------------------------------------------------------------------------- +Usage: + +In a horizontal bar chart, the X axis and Y axis are oriented the same as +in other PHPlot plot types: X axis is horizontal, increasing towards the +right, and Y axis is vertical, increasing towards the top. + + Y + ^ + | + |============== + | + |===== + | + |========= + | + +---------------------> X + +To make a horizontal bar chart, use the same plot type as vertical bar +charts ('bars'), but use the new data type 'text-data-yx'. The new data +type indicates your data array has a different representation, mapping Y +values to X values (instead of X values to Y values). + +For a normal (vertical) bar chart, the data array has type 'text-data' and +looks like this: + $data = array( array('Label1', Y11, Y12, ...), + array('Label2', Y21, Y22, ...), + ...); +Each entry (row) in the data array represents one group of bars. Each group +has a label and one or more Y values. The X values are implicit: the first +row has the first X value, the second row has the second X value, etc. + +For the new horizontal bar charts, the data array has the new type +'text-data-yx' and looks like this: + $data = array( array('Label1', X11, X12, ...), + array('Label2', X21, X22, ...), + ...); +Each entry (row) in the data array represents one group of bars. Each group +has a label and one or more X values. The Y values are implicit: the first +row has the first Y value, the second row has the second Y value, etc. + +As you can see, a vertical bar chart can be changed to a horizontal bar +chart simply by changing the data type passed to SetDataType(). The data +array itself does not change. Other issues with horizontal bar charts are +discussed below. + +This complete script makes a very simple horizontal bar chart: + <?php + require 'phplot.php'; + $p = new PHPlot(800, 800); + $p->SetDataValues(array(array('A', 10, 25), array('B', 30, 5))); + $p->SetDataType('text-data-yx'); + $p->SetPlotType('bars'); + $p->DrawGraph(); + +Note that the bars in a horizontal bar chart are ordered from bottom to top +(that is, increasing Y values). In the example above, the "A" label bar +group is drawn below the "B" label bar group. If you need bars ordered from +top to bottom, you will have to change your data array accordingly. + +----------------------------------------------------------------------------- +Ticks and Labels: + +Since the X axis and Y axis do not change positions for horizontal bar +charts, the label and tick controls still refer to the X and Y axis. +However, the independent values are now Y, and the dependent values are +now X. Also, the label strings in your data array are plotted along the Y +axis for horizontal bar charts, rather than along the X axis for regular +bar charts. + +To control the data labels positions, use SetYDataLabelPos(). New option +values have been added to this function, which was previously used only to +position bar chart value labels with the options 'plotin', 'plotstack', or +'none'. With horizontal bar charts, SetYDataLabelPos() positions the +regular data labels that go along the Y axis. The new option values are +'plotleft', 'plotright', or 'both'. + 'plotleft' : Draw data labels along the left side of the plot area. + 'plotright' : Draw data labels along the right side of the plot area. + 'both' : Draw data labels along both left and right sides. + 'none' : Do not draw data labels. + +For bar charts, it makes no sense to have ticks or tick labels along the +independent axis. This is the Y axis for horizontal bar charts. Therefore, +you should use SetYTickPos('none') to turn off the tick marks on the Y +axis. You do not normally need to use SetYTickLabelPos('none') to turn off +the tick labels along the Y axis, since PHPlot will do this automatically +if your data array has labels. + +To control the presentation of the data labels with horizontal bar charts, +use the correct functions that refer to the Y data labels, not X data +labels as with vertical bar charts. + + SetYDataLabelAngle() or SetYLabelAngle() + Set angle of data label text. Default is 0 degrees. + + SetYDataLabelType() or SetYLabelType() + Select the type of formatting for the data labels. + + SetFont(), SetFontGD(), or SetFontTTF() + Use the element name 'y_label' for the data labels. + +Note that the PHPlot Reference Manual currently says the Y Data Label +functions are only for bar chart data value labels (see Data Value Labels +below regarding this term). That information is out of date. These +functions are now also used for data labels in horizontal bar charts. + +----------------------------------------------------------------------------- +Grid: + +For horizontal bar charts, the X grid lines default on, and the Y grid lines +default off. (This is the opposite of normal bar charts, where the X grid +lines default off, and the Y grid lines default on.) + +----------------------------------------------------------------------------- +Y Axis Position: + +PHPlot uses a different default for the X axis and the Y axis positions. +This affects horizontal bar charts if you have any data values which are +less than zero. The X axis is normally positioned at Y=0, and the Y axis +is normally positioned at the left side of the plot. + +If you have both positive and negative values in your data array, both +vertical and horizontal bar charts will draw the bars away from the zero +value. For vertical bar charts, the X axis will be drawn at that zero value +(perhaps in the middle of the plot), with bars going up and down from +there. But for horizontal bar charts, the Y axis will by default remain at +the left edge of the plot; the bars will start from the X=0 value +(somewhere in the middle of the plot area) and go left and right from +there. In this situation, you might want to use SetYAxisPosition(0) to +force the Y axis to be at X=0. + +----------------------------------------------------------------------------- +Scaling: + +You can use SetPlotAreaWorld() to explicitly set any or all of the 4 limits +of the plot area. Any limits you do not provide will be calculated for you. +The algorithm is due for replacement, but it will now apply the same +calculations to Y and X values in horizontal bar charts as it currently +applies to X and Y (respectively) in vertical bar charts. That is, the +range for the independent variable will be calculated to contain and center +the bar groups, and the range for the dependent variable will include and +usually exceed the actual data range. + +The example under Usage above will produce an auto-calculated Y range of 4 +to 33, with the X range set to center the two bar groups. If you change +'text-data-yx' to 'text-data', you will get a vertical bar chart with the +same automatic range. + +----------------------------------------------------------------------------- +Data Value Labels: + +Data Value Labels are not yet available with horizontal bar charts. These +are the text labels within the plot that identify the data value just above +the bars. (See Example 5.19 "Bar Chart with Data Labels" in the manual.) + +Note: Data Value Labels are currently referred to in the manual as Y Data +Labels. If horizontal bars are accepted and documented in the manual, this +will be changed to call them 'Data Value Labels'. This is necessary to +avoid confusion with X Data Labels and Y Data Labels. + +----------------------------------------------------------------------------- +Other Plot Types Not Available: + +There is currently no corresponding horizontal analog for plot type +stackedbars, nor are there any other horizontal plot types at this time. +Using data type 'text-data-yx' with other plot types will fail. +(Starting with 5.1.2, PHPlot always checks that the selected data type +is supported for the selected plot type.) + +----------------------------------------------------------------------------- +Implementation Notes: + +The following is a summary of the changes made to PHPlot to implement +horizontal bar charts. + +1) Do not initialize y_tick_label_pos or y_data_label_pos. The defaults +have to be dynamically calculated for horizontal bar charts, so tick labels +can be suppressed. (This was already being done for X labels.) Existing +internal function CheckLabels() was extended to do this for Y also. + +2) Do not initialize the X and Y grid setting variables. The defaults have +to be dynamically calculated because they differ with swapped data arrays. +New internal function CalcGridSettings() does this. + +3) SetYDataLabelPos() accepts the new arguments plotleft, plotright, and +both. Old compatibility code that passed these values to SetYTickLabelPos() +has been removed. + +4) SetDataType() accepts a new value: 'text-data-yx'. + +5) FindDataLimits() was changed to properly calculate minimum and maximum +values from text-data-yx data arrays. The arrays data_miny and data_maxy +were renamed to just data_min and data_max, since they now describe limits +of either X or Y values, depending on the data type. + +6) Changes were made to CalcMargins() to account for the labels in the data +array being drawn on the Y axis instead of X axis, in the text-data-yx +case. + +7) CalcPlotAreaWorld() is extended to calculate defaulted plot ranges +correctly for the swapped X/Y case. The algorithm is the same (and due for +replacement). It applies a fixed range to Y and an extended range to X. It +is also ready for possible future expansion to include swapped X/Y plots +with explicit Y values. + +8) Changed CalcBarWidths() to use either the plot area width or height, +depending on the bar directions, when calculating the bar widths. + +9) Extended CalcMaxDataLabelSize() to work with both X and Y labels. +Before, it returned the maximum height of the data labels. Now it can +instead return the maximum width of the data labels; this is used for +horizontal bar charts. It also has to pick the proper font, angle, and +format code for X or Y. + +10) New internal function DrawYDataLabel() to draw data labels for +horizontal bar charts. + +11) New internal function DrawHorizBars() draws the horizontal bar chart. + +12) DrawGraph() now decides to draw a bar or horizontal bar chart based on +the data type (text-data or text-data-yx). + +----------------------------------------------------------------------------- Modified: trunk/includes/phplot/NEWS.txt =================================================================== --- trunk/includes/phplot/NEWS.txt 2010-07-22 09:10:30 UTC (rev 3653) +++ trunk/includes/phplot/NEWS.txt 2010-07-22 09:11:16 UTC (rev 3654) @@ -3,7 +3,140 @@ The project home page is http://phplot.sourceforge.net/ Refer the the ChangeLog file for detailed source changes. ----------------------------------------------------------------------------- -/* Id */ + +2010-06-29 Release 5.1.2 + +Overview: + +This is the current stable release of PHPlot. Truecolor image support is no +longer considered 'experimental', and is now documented in the reference +manual. There is a new experimental feature for horizontal bar charts. This +release also contains a bug fix and new feature. + + +Cautions and Important Notes: + +The advisory against using PHP-5.3.2 or PHP-5.2.13 with PHPlot if you use +TrueType fonts (TTF) continues. See the item below for PHPlot-5.1.1. The +good news is that this has been fixed by the PHP Team and will be in the +next releases. + +Compatibility of data type and plot type are now checked completely. If +you used an incorrect data type with certain plot types, your script may no +longer work until you fix the data type. Specifically, the area, squared, +and thinbarline plot types failed to check the data type they received, and +treated anything other than 'data-data' as 'text-data'. If you have a +squared plot with data type 'data-data-error', for example (which is not +supposed to work), it did produce a plot, but will now result in an error. + +The addition of horizontal bar charts should not impact any existing plot, +with one small exception. The function SetYDataLabelPos() used to accept +some additional, undocumented options (plotleft, plotright, both, yaxis) +and pass these through to SetYTickLabelPos() "for compatibility". It no +longer does so, as some of those are now used for horizontal bar chart +labels. To position Y tick labels, use only SetYTickLabelPos(). + + +New features in 5.1.2: + +#3002606 "Add to plot and image border options": + SetPlotBorderType() now accepts 'right', 'top', and 'bottom', as well + as an array of options. So you can now control exactly which of the 4 + border sides will be drawn. + SetImageBorderType() now accepts 'solid' as a choice. This will use the + actual color set with SetImageBorderColor(), rather than the darker + shade as type 'plain' does (which may have been a bug). + SetImageBorderWidth() is a new function that sets the width of the image + border. The defaults are the same as the fixed values used before: 1 + pixel for plain, 2 pixels for raised. The image border width is now + accounted for in margin calculations, if it is greater than 2 (to make + sure existing plots will not change). + +#2885930 "Horizontal Bars": + Horizontal bar charts are implemented, as an experimental feature. + 'Experimental' means they are not yet documented in the reference manual, + and subject to change or removal. + Refer to the text file HorizontalBars.txt for details. + +#2947679 (follow-up) "Support for alpha blending/Truecolor": + Truecolor support is now documented in the Reference Manual. The interim + documentation file Truecolor.txt has been removed. Alpha channel + specification now works with both constructors and both image types. This + fixes an issue if the base constructor was used with a truecolor background + image. (In PHPlot-5.1.1, the result would be a truecolor image, but the + alpha channel features were not available.) + + +Bug Fixed in 5.1.2: + +#3010116 "Bad rendering of title in multi-plot image when using TTF": + Make sure the main title is drawn only once, to avoid bad rendering of + TTF titles with multiple plots due to anti-aliasing. + +----------------------------------------------------------------------------- + +2010-04-04 Release 5.1.1 + +Overview: + +This is the current stable release of PHPlot. This release adds truecolor +image support as an experimental feature, fixes a number of bugs and adds +a few new features. + +The PHPlot reference manual has been updated to match this release. The +manual is available as a separate download from Sourceforge. The manual is +also available for on-line viewing from the project home page. + +See the ChangeLog file in the release for more about changes and bug fixes. + + +Cautions and Important Notes: + +Avoid using PHP-5.3.2 or PHP-5.2.13 with PHPlot if you use TrueType fonts +(TTF). Some new bugs were introduced in those releases that adversely +affects accurate positioning and rendering of TrueType font text. + + +New features in 5.1.1: + +#2947679 "Support for alpha blending/Truecolor": + PHPlot can now produce truecolor images, with alpha blending of colors and + other effects. This is considered an experimental feature, meaning it is + not yet documented in the PHPlot Reference Manual, and subject to change. + Refer to the text file Truecolor.txt included in the PHPlot release for + information on using truecolor. + Two drawing changes were made to improve plot appearance with Truecolor: + + Filled dots (in points & linespoints plots) are now drawn better. This + also makes them look rounder with regular (non-Truecolor) plots. + + Area plots have the areas filled without overlapping each area down to + the Y axis. This was needed to fix problems with alpha blending, and + should have no effect on non-Truecolor plots. + +#2973995 "Add y-Data to Stackedbars": + You can now have Y Data Labels with 'stackedbars' plots. These label the Y + values (incremental and total) for each bar. Refer to the reference manual + page for SetYDataLabelPos(). + + +Bug Fixes in 5.1.1: + +#2976735 "Improvements and fixes for 'area' plots": + Moving X axis works; handle Y<0 better; new 'stackedarea' plot type is a + variation on 'area' with the data represented differently. + +#2974639 "Stacked bars plot breaks with X axis != 0": + Moving X axis works. + +#2963757 "point_counts undefined error in 5.1.0": + Fixed an error introduced in PHPlot-5.1.0 when point size and shape arrays + were set to the same size. + +#2938219 "Bars go in wrong direction": + For bar charts with all Y<0, bars will still be drawn down even if Y=0 is + not in range. + +----------------------------------------------------------------------------- + 2009-12-24 Release 5.1.0 Overview: @@ -651,7 +784,7 @@ Testing: - + Since its output is visual (graphics), and it has so many interconnected modes and options, PHPlot is difficult to test. But at least we are now trying. I have a collection of PHPlot scripts (currently about 60) and a Modified: trunk/includes/phplot/README.txt =================================================================== --- trunk/includes/phplot/README.txt 2010-07-22 09:10:30 UTC (rev 3653) +++ trunk/includes/phplot/README.txt 2010-07-22 09:11:16 UTC (rev 3654) @@ -1,9 +1,9 @@ This is the README file for PHPlot -Last updated for PHPlot-5.1.0 on 2009-12-24 +Last updated for PHPlot-5.1.2 on 2010-06-29 The project web site is http://sourceforge.net/projects/phplot/ The project home page is http://phplot.sourceforge.net/ ----------------------------------------------------------------------------- -/* Id */ + OVERVIEW: PHPlot is a PHP class for creating scientific and business charts. @@ -20,6 +20,7 @@ COPYING . . . . . . . . . . . . LGPL 2.1 License file ChangeLog . . . . . . . . . . . Lists changes to the sources + HorizontalBars.txt . . . . . . . Experimental feature documentation NEWS.txt . . . . . . . . . . . . Highlights changes in releases README.txt . . . . . . . . . . This file contrib . . . . . . . . . . . . "Contributed" directory, add-ons @@ -27,14 +28,20 @@ phplot_data.php . . . . . . . . Auxiliary and extended functions rgb.inc.php . . . . . . . . . . Optional extended color table - REQUIREMENTS: -You need a recent version of PHP5, and you are advised to use the latest -stable release. This version of PHPlot has been tested with PHP-5.3.1 and -PHP-5.2.12 on Linux, and with PHP-5.3.1 on Windows/XP. PHP4 is no longer -supported. +You need a recent version of PHP5. Usually, we recommend you use the latest +stable release, however due to problems with PHP-5.3.2 and PHP-5.2.13 you +are advised to use the previous releases if possible. The problems are +specific to TrueType font (TTF) text. If you are not using TTF text, you +may use PHP-5.3.2 or 5.2.13. (The PHP team already has a fix for this TTF +problem in PHP-5.3.3 development snapshots, so the fix should be in the +next releases PHP-5.3.3 and PHP-5.2.14.) +This version of PHPlot has been tested with PHP-5.3.1 and PHP-5.2.12 on +Linux, and with PHP-5.3.1 on Windows/XP. The PHPlot Test Suite currently +contains 432 test cases. + You need the GD extension to PHP either built in to PHP or loaded as a module. Refer to the PHP documentation for more information - see the Image Functions chapter in the PHP Manual. We test PHPlot only with the @@ -46,7 +53,7 @@ PHPlot supports TrueType fonts, but does not include any TrueType font files. If you want to use TrueType fonts on your charts, you need to have TrueType support in GD, and some TrueType font files. By default, PHPlot -uses a simple font built-in to the GD library. +uses a simple font which is built in to the GD library. INSTALLATION: @@ -60,7 +67,7 @@ phplot_data.php rgb.inc.php (Only phplot.php is necessary for most graphs.) -Make sure the protections on these files allow the web server to read them. +Make sure the permissions on these files allow the web server to read them. The ideal place is a directory outside your web server document area, and on your PHP include path. You can add to the include path in the PHP @@ -72,7 +79,7 @@ Here are some of the problems we know about in PHPlot. See the bug tracker on the PHPlot project web site for more information. -#1795969 The automatic range calculation for Y values needs to be rewritten. +#1795969 The automatic range calculation for Y values needs to be rewritten. This is especially a problem with small offset ranges (e.g. Y=[999:1001]). You can use SetPlotAreaWorld to set a specific range instead. @@ -83,7 +90,10 @@ Tick interval calculations should try for intervals of 1, 2, or 5 times a power of 10. +PHP Bugs #51207, #51094, and others: These are PHP bugs, not PHPlot, +on rendering of TrueType font (TTF) text in PHP-5.3.2 and 5.2.13. + If you think you found a problem with PHPlot, or want to ask questions or provide feedback, please use the Help and Discussion forum at http://sourceforge.net/projects/phplot/ @@ -129,7 +139,7 @@ COPYRIGHT and LICENSE: -PHPlot is Copyright (C) 1998-2009 Afan Ottenheimer +PHPlot is Copyright (C) 1998-2010 Afan Ottenheimer This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public Added: trunk/includes/phplot/contrib/README.txt =================================================================== --- trunk/includes/phplot/contrib/README.txt (rev 0) +++ trunk/includes/phplot/contrib/README.txt 2010-07-22 09:11:16 UTC (rev 3654) @@ -0,0 +1,31 @@ +This is the README for PHPlot Contributed Code +The project web site is http://sourceforge.net/projects/phplot/ +Last updated on 2009-12-08 +----------------------------------------------------------------------------- + +The PHPlot Contributed Code directory contains code you might find useful +with PHPlot, but that doesn't quite belong as part of PHPlot itself. + +You will have to read the comments in the code files, and see the example +files, to determine what these do and if they are useful to you. None of +these functions is documented in the PHPlot Reference Manual. + +You may include or paste these functions into your own scripts. Check the +files for details, but some of these are considered "public domain" with no +usage or license restrictions. + +----------------------------------------------------------------------------- +Contents: + +prune_labels: Reduce the number of labels along the X axis + prune_labels.php . . . . . . . . . . . . Code + prune_labels.example.php . . . . . . . . Example + prune_labels.test.php . . . . . . . . . Test + +color_range: Create a gradient color map for data colors + color_range.php . . . . . . . . . . . . Code + color_range.example.php . . . . . . . . Example + color_range.test1.php . . . . . . . . . Image creation test + color_range.test2.php . . . . . . . . . Unit test + +----------------------------------------------------------------------------- Added: trunk/includes/phplot/contrib/color_range.example.php =================================================================== --- trunk/includes/phplot/contrib/color_range.example.php (rev 0) +++ trunk/includes/phplot/contrib/color_range.example.php 2010-07-22 09:11:16 UTC (rev 3654) @@ -0,0 +1,35 @@ +<?php +# PHPlot / contrib / color_range : Example +# $Id: color_range.example.php,v 1.1 2009/12/09 03:45:45 lbayuk Exp $ +# This is a bar chart with a color gradient for the bars in each group. + +require_once 'phplot.php'; +require_once 'color_range.php'; + +$bars_per_group = 10; +$x_values = 4; + +mt_srand(1); +$data = array(); +for ($i = 0; $i < $x_values; $i++) { + $row = array($i); + for ($j = 0; $j < $bars_per_group; $j++) $row[] = mt_rand(0, 100); + $data[] = $row; +} + +$p = new PHPlot(800, 600); +$p->SetTitle('Example - Bar Chart with gradient colors'); +$p->SetDataType('text-data'); +$p->SetDataValues($data); +$p->SetPlotAreaWorld(0, 0, $x_values, 100); + +# This isn't necessary, as we do know how many data sets (bars_per_group): +$n_data = count_data_sets($data, 'text-data'); +# Make a gradient color map: +$colors = color_range($p->SetRGBColor('SkyBlue'), + $p->SetRGBColor('DarkGreen'), $n_data); +$p->SetDataColors($colors); +$p->SetXTickLabelPos('none'); +$p->SetXTickPos('none'); +$p->SetPlotType('bars'); +$p->DrawGraph(); Added: trunk/includes/phplot/contrib/color_range.php =================================================================== --- trunk/includes/phplot/contrib/color_range.php (rev 0) +++ trunk/includes/phplot/contrib/color_range.php 2010-07-22 09:11:16 UTC (rev 3654) @@ -0,0 +1,100 @@ +<?php +/* + PHPlot / contrib / color_range + $Id: color_range.php,v 1.1 2009/12/09 03:45:48 lbayuk Exp $ + PHPlot contrib code - public domain - no copyright - use as you wish + + Original contribution from: Josep Sanz <josep dot sans at w3 dot es> + "I wrote this code to calculate the range of colors between 2 colors + to plot using the range from color_a to color_b..." + + I have changed the code and repackaged it, but the idea is the same. + Given 2 colors and number of data sets, computes an array of colors + that make up a gradient between the two provided colors, for use + with SetDataColors(). + + Provides the following functions: + $colors = color_range($color_a, $color_b, $n_intervals) + Returns a color array for SetDataColors. + + $n = count_data_sets($data, $data_type) + Counts the number of data sets in a data array. + This can be used to provide $n_intervals in color_range(). +*/ + + + +/* + Fill a color map with a gradient step between two colors. + Arguments: + $color_a : Starting color for the gradient. Array of (r, g, b) + $color_b : Ending color for the gradient. Array of (r, g, b) + $n_steps : Total number of color steps, including color_a and color_b. + + Returns: A color map array with n_steps colors in the form + $colors[i][3], suitable for SetDataColors(). + + Notes: + You may use the PHPlot internal function $plot->SetRGBColor($color) + to convert a color name or #rrggbb notation into the required array + of 3 values (r, g, b) for color_a and color_b. + +*/ +function color_range($color_a, $color_b, $n_steps) +{ + if ($n_steps < 2) $n_steps = 2; + $nc = $n_steps - 1; + # Note: $delta[] and $current[] are kept as floats. $colors is integers. + for ($i = 0; $i < 3; $i++) + $delta[$i] = ($color_b[$i] - $color_a[$i]) / $nc; + $current = $color_a; + for ($col = 0; $col < $nc; $col++) { + for ($i = 0; $i < 3; $i++) { + $colors[$col][$i] = (int)$current[$i]; + $current[$i] += $delta[$i]; + } + } + $colors[$nc] = $color_b; # Make sure the last color is exact. + return $colors; +} + + +/* + Determine the number of data sets (plot lines, bars per group, pie + segments, etc.) contained in a data array. + This can be used to determine n_steps for $color_range. + + Arguments: + $data : PHPlot data array + $data_type : PHPlot data type, describing $data. (e.g. 'data-data') + Returns: The number of data sets in the data array. + Notes: + This has to scan the entire data array. Don't use this unless you + really don't have a better way to determine the number of data sets. + + This does NOT require that the data array be integer indexed. + +*/ +function count_data_sets($data, $data_type) +{ + + if ($data_type == 'text-data-single') + return count($data); # Pie chart, 1 segment per record + + # Get the longest data record: + $max_row = 0; + foreach ($data as $row) + if (($n = count($row)) > $max_row) $max_row = $n; + + if ($data_type == 'text-data') + return ($max_row - 1); # Each record is (label Y1 Y2...) + + if ($data_type == 'data-data') + return ($max_row - 2); # Each record is (label X Y1 Y2...) + + if ($data_type == 'data-data-error') + return (($max_row - 2) / 3); # Each record is (label X Y1 Y1+ Y1-...) + + # Not a recognized data type... Just return something sane. + return $max_row; +} Property changes on: trunk/includes/phplot/contrib/color_range.php ___________________________________________________________________ Added: svn:executable + * Added: trunk/includes/phplot/contrib/color_range.test1.php =================================================================== --- trunk/includes/phplot/contrib/color_range.test1.php (rev 0) +++ trunk/includes/phplot/contrib/color_range.test1.php 2010-07-22 09:11:16 UTC (rev 3654) @@ -0,0 +1,55 @@ +<?php +# PHPlot / contrib / color_range : Test 1, make a picture +# $Id: color_range.test1.php,v 1.1 2009/12/09 03:45:49 lbayuk Exp $ +# This creates a PNG file on output with a color gradient. + +require_once 'color_range.php'; + +function usage() +{ + fwrite(STDERR, "Usage: color_range.test1.php color1 color2 number_of_colors +Each color is of the form rrggbb with 2 digit hex color components. +"); + exit(1); +} + +# Split color "rrggbb" into separate components. Code is from PHPlot. +function rgb($color) +{ + return array(hexdec(substr($color, 1, 2)), + hexdec(substr($color, 3, 2)), + hexdec(substr($color, 5, 2))); +} + +if ($_SERVER['argc'] != 4) usage(); + +$color1 = rgb($_SERVER['argv'][1]); +$color2 = rgb($_SERVER['argv'][2]); +$n_col = (int)$_SERVER['argv'][3]; +if ($n_col < 2) usage(); + +# Build a color map from colors[0]=color1 to colors[$n_col-1]=color2. +$colors = color_range($color1, $color2, $n_col); + +# Make a picture: +$w = 800; +$h = 800; +$im = imagecreate($w, $h); +$background = imagecolorresolve($im, 0, 0, 0); +for ($col = 0; $col < $n_col; $col++) { + list($r, $g, $b) = $colors[$col]; + $colmap[$col] = imagecolorresolve($im, $r, $g, $b); +} + +$margin = 20; +$bar_width = (int)(($w - 2 * $margin) / $n_col); +$x1 = $margin; +$x2 = $x1 + $bar_width; +$y1 = $margin; +$y2 = $h - $margin; +for ($col = 0; $col < $n_col; $col++) { + imagefilledrectangle($im, $x1, $y1, $x2, $y2, $colmap[$col]); + $x1 = $x2; + $x2 += $bar_width; +} +imagepng($im); Added: trunk/includes/phplot/contrib/color_range.test2.php =================================================================== --- trunk/includes/phplot/contrib/color_range.test2.php (rev 0) +++ trunk/includes/phplot/contrib/color_range.test2.php 2010-07-22 09:11:16 UTC (rev 3654) @@ -0,0 +1,73 @@ +<?php +/* + PHPlot / contrib / color_range : Unit tests + $Id: color_range.test2.php,v 1.1 2009/12/09 03:45:51 lbayuk Exp $ + + Tests color.range.php functions: + color_range($color_a, $color_b, $n_steps) + count_data_sets($data, $data_type) + +*/ +require_once 'color_range.php'; + + +# Testing count_data_sets() +function test_count_data_sets($data, $data_type, $expected) +{ + $n = count_data_sets($data, $data_type); + if ($n == $expected) $result = "Pass"; + else $result = "FAIL: Expected $expected but got"; + echo "$result: $n data sets, $data_type with " . count($data) . " records.\n"; +} + +function test_driver_count_data_sets() +{ + echo "\nTesting count_data_sets():\n"; + $data1 = array(array('a', 1, 2, 3), array('b', 2, 2, 3)); + $data2 = array(array('a', 1, 2, 3, 4, 5, 6, 7), array('b', 2, 4, 5, 6)); + $data3 = array(array('', 1), array('', 2), array('', 3), array('', 4)); + $data4 = array(array('', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), + array('', 1, 2, 3, 4, 5, 6, 7), + array('', 1, 2, 3, 4)); + + test_count_data_sets($data1, 'text-data', 3); + test_count_data_sets($data1, 'data-data', 2); + test_count_data_sets($data2, 'data-data-error', 2); + test_count_data_sets($data3, 'text-data-single', 4); + + test_count_data_sets($data4, 'text-data', 13); + test_count_data_sets($data4, 'data-data', 12); + test_count_data_sets($data4, 'data-data-error', 4); + test_count_data_sets($data4, 'text-data-single', 3); +} + +# Testing color_range() +function test_color_range($color1, $color2, $nsteps, $expected) +{ + $info = 'From (' . implode(', ', $color1) + . ') To (' . implode(', ', $color2) . ") with $nsteps steps"; + + $colors = color_range($color1, $color2, $nsteps); + if ($colors == $expected) echo "Pass: $info\n"; + else echo "FAIL: $info\n" . print_r($colors, True) . "\n"; + if (($n = count($colors)) != $nsteps) + echo "FAIL: Bad count $n expecting $nsteps\n"; +} + +function test_driver_color_range() +{ + echo "\nTesting color_range():\n"; + test_color_range(array(0,0,0), array(255,255,255), 3, + array(array(0,0,0), array(127,127,127), array(255,255,255))); + + test_color_range(array(255,0,0), array(0,255,0), 2, + array(array(255,0,0), array(0,255,0))); + + test_color_range(array(100,0,100), array(0,100,0), 6, + array(array(100,0,100), array(80,20,80), array(60,40,60), + array(40,60,40), array(20,80,20), array(0,100,0))); +} + + +test_driver_count_data_sets(); +test_driver_color_range(); Added: trunk/includes/phplot/contrib/prune_labels.example.php =================================================================== --- trunk/includes/phplot/contrib/prune_labels.example.php (rev 0) +++ trunk/includes/phplot/contrib/prune_labels.example.php 2010-07-22 09:11:16 UTC (rev 3654) @@ -0,0 +1,31 @@ +<?php +# PHPlot / contrib / prune_labels : Example +# $Id: prune_labels.example.php,v 1.1 2009/12/09 03:45:53 lbayuk Exp $ +# This produces 250 data points with date-formatted labels, and sets +# a max of 20 labels to display. + +require_once 'phplot.php'; +require_once 'prune_labels.php'; + +$base = mktime(12, 0, 0, 1, 1, 2000); +$data = array(); +for ($i = 0; $i < 250; $i++) { + $data[] = array(86400 * $i + $base, $i, $i * 0.20); +} + +# Show no more than 20 labels: +prune_labels($data, 20); + +$p = new PHPlot(800, 600); +$p->SetTitle('Example - pruned data labels'); +$p->SetDataType('data-data'); +$p->SetDataValues($data); +$p->SetXLabelType('time', '%Y-%m-%d'); +$p->SetXLabelAngle(90); +$p->SetXDataLabelPos('plotdown'); +$p->SetXTickLabelPos('none'); +$p->SetXTickPos('none'); +$p->SetDrawXGrid(False); +$p->SetDrawYGrid(False); +$p->SetPlotType('lines'); +$p->DrawGraph(); Added: trunk/includes/phplot/contrib/prune_labels.php =================================================================== --- trunk/includes/phplot/contrib/prune_labels.php (rev 0) +++ trunk/includes/phplot/contrib/prune_labels.php 2010-07-22 09:11:16 UTC (rev 3654) @@ -0,0 +1,36 @@ +<?php +/* + PHPlot / contrib / prune_labels + $Id: prune_labels.php,v 1.1 2009/12/09 03:45:55 lbayuk Exp $ + PHPlot contrib code - public domain - no copyright - use as you wish + +Reduce the number of data labels along the X axis, when the density is too +high. This simply blanks out M-1 of every M labels in the data array. +There are other ways to do this, but we need to keep the labels uniformly +spaced. You select the target maximum label count (maxlabels), and you will +get no more than maxlabels data labels. + + Arguments: + $data - The PHPlot data array (reference variable) + $maxlabels - The maximum number of data labels you are willing to have, + Returns: Nothing + Modifies the $data array in place to remove some of the labels. + + Notes: + The data array and its rows must be 0-based integer indexed arrays. +*/ +function prune_labels(&$data, $maxlabels) +{ + # Do nothing if there are not already too many labels: + if (($n = count($data)) <= $maxlabels) return; + + # Compute how many labels to erase. Keep 1 of every $m labels. + $m = (int)ceil($n / $maxlabels); + + # Process the data array, zapping M-1 of every M labels: + $k = 0; + for ($i = 0; $i < $n; $i++) { + if ($k > 0) $data[$i][0] = ''; + if (++$k >= $m) $k = 0; + } +} Added: trunk/includes/phplot/contrib/prune_labels.test.php =================================================================== --- trunk/includes/phplot/contrib/prune_labels.test.php (rev 0) +++ trunk/includes/phplot/contrib/prune_labels.test.php 2010-07-22 09:11:16 UTC (rev 3654) @@ -0,0 +1,41 @@ +<?php +# PHPlot / contrib / prune_labels : Test +# $Id: prune_labels.test.php,v 1.1 2009/12/09 03:45:57 lbayuk Exp $ +# Test driver for contrib / prune_labels + +require_once 'prune_labels.php'; + +/* Testing the prune_labels function: */ +function test($count, $maxlabels) +{ + # Make an array of count records, like PHPlot uses, with labels: + $data = array(); + for ($i = 0; $i < $count; $i++) { + $data[] = array("Row $i", $i, 100, 200, 300); + } + + prune_labels($data, $maxlabels); + + # See how many labels are non-blank now: + $line = ''; + $non_blank = 0; + for ($i = 0; $i < $count; $i++) { + if (!empty($data[$i][0])) { + $non_blank++; + $line .= '*'; + } else { + $line .= '_'; + } + } + $status = ($non_blank <= $maxlabels) ? 'PASS' : 'FAIL'; + echo "$status: $count rows, maxlabels=$maxlabels => $non_blank labels\n"; + echo substr($line, 0, 80) . "\n"; # Only show first 80 chars. +} + +/* Test cases for prune_labels */ +for ($n = 7; $n <= 1000; $n *= 2) test($n, 10); +for ($g = 5; $g <= 40; $g++) test(72, $g); +# Edge cases +test(80, 41); +test(80, 40); +test(80, 39); Modified: trunk/includes/phplot/phplot.php =================================================================== --- trunk/includes/phplot/phplot.php 2010-07-22 09:10:30 UTC (rev 3653) +++ trunk/includes/phplot/phplot.php 2010-07-22 09:11:16 UTC (rev 3654) @@ -1,13 +1,13 @@ <?php -/* $Id: phplot.php,v 1.167 2009/12/23 22:37:47 lbayuk Exp $ */ +/* $Id: phplot.php,v 1.182 2010/06/30 00:39:08 lbayuk Exp $ */ /* - * PHPLOT Version 5.1.0 + * PHPLOT Version 5.1.2 * * A PHP class for creating scientific and business charts * Visit http://sourceforge.net/projects/phplot/ * for PHPlot documentation, downloads, and discussions. * --------------------------------------------------------------------- - * Copyright (C) 1998-2009 Afan Ottenheimer + * Copyright (C) 1998-2010 Afan Ottenheimer * * This is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -74,7 +74,7 @@ public $output_file = ''; // For output to a file instead of stdout //Data - public $data_type = 'text-data'; // text-data, data-data-error, data-data, text-data-single + public $data_type = 'text-data'; // Structure of the data array public $plot_type= 'linepoints'; // bars, lines, linepoints, area, points, pie, thinbarline, squared public $label_scale_position = 0.5; // Shifts data labels in pie charts. 1 = top, 0 = bottom @@ -100,15 +100,14 @@ // they are drawn at graph plotting time, by Draw*DataLabel(), called by DrawLines(), etc. // Draw*DataLabel() also draws H/V lines to datapoints depending on draw_*_data_label_lines // Tick Labels - // x_tick_label_pos and x_data_label_pos are not initialized, because PHPlot needs - // to determine if they were defaulted or set by the user. See CheckLabels(). - // public $x_tick_label_pos = 'plotdown'; // plotdown, plotup, both, xaxis, none - public $y_tick_label_pos = 'plotleft'; // plotleft, plotright, both, yaxis, none + // Tick and Data label positions are not initialized, because PHPlot needs to tell if they + // defaulted or are set by the user. See CheckLabels() for details. The variables and + // effective defaults are shown here in comments (but CheckLabe... [truncated message content] |
From: <tim...@us...> - 2010-07-22 12:15:03
|
Revision: 3656 http://web-erp.svn.sourceforge.net/web-erp/?rev=3656&view=rev Author: tim_schofield Date: 2010-07-22 12:14:57 +0000 (Thu, 22 Jul 2010) Log Message: ----------- Corrections to depreciation calculation layout changes, and sql quoting Modified Paths: -------------- trunk/FixedAssetJournal.php trunk/doc/Change.log.html Modified: trunk/FixedAssetJournal.php =================================================================== --- trunk/FixedAssetJournal.php 2010-07-22 09:11:32 UTC (rev 3655) +++ trunk/FixedAssetJournal.php 2010-07-22 12:14:57 UTC (rev 3656) @@ -1,7 +1,6 @@ <?php /* $Revision: 1.1 $ */ -/* $Id$*/ include('includes/DefineJournalClass.php'); @@ -59,7 +58,7 @@ $typerow=DB_fetch_array($typeresult); $assetarray[$i]['DepreciationType']=$typerow['value']; - // Find the depreciation rate + // Find the depreciation rate $ratesql='SELECT stockitemproperties.value FROM stockitemproperties LEFT JOIN stockcatproperties @@ -71,18 +70,18 @@ $assetarray[$i]['DepreciationRate']=$raterow['value']; - $bsnamesql='SELECT accountname FROM chartmaster WHERE accountcode='.$assetarray[$i]['bsdepn']; + $bsnamesql='SELECT accountname FROM chartmaster WHERE accountcode="'.$assetarray[$i]['bsdepn'].'"'; $bsnameresult=DB_query($bsnamesql, $db); $bsnamerow=DB_fetch_array($bsnameresult); $assetarray[$i]['bsdepnaccount']=$bsnamerow['accountname']; - $plnamesql='SELECT accountname FROM chartmaster WHERE accountcode='.$assetarray[$i]['pldepn']; + $plnamesql='SELECT accountname FROM chartmaster WHERE accountcode="'.$assetarray[$i]['pldepn'].'"'; $plnameresult=DB_query($plnamesql, $db); $plnamerow=DB_fetch_array($plnameresult); $assetarray[$i]['pldepnaccount']=$plnamerow['accountname']; - - /* Need a method to correctly enter the journal date, + + /* Need a method to correctly enter the journal date, * and for it to be available to the depn calculation - Tim - */ + */ if (isset($_POST['JournalProcessDate'])) { $_SESSION['JournalDetail']->JnlDate=$_POST['JournalProcessDate']; @@ -92,7 +91,7 @@ $_SESSION['JournalDetail']->JnlDate = Date($_SESSION['DefaultDateFormat'],mktime(0,0,0,date('m'),0,date('Y'))); } - $NoOfMonths=DateDiff($_SESSION['JournalDetail']->JnlDate,FormatDateForSQL($assetarray[$i]['datepurchased']), 'm'); + $NoOfMonths=DateDiff($_SESSION['JournalDetail']->JnlDate,ConvertSQLDate($assetarray[$i]['datepurchased']), 'm'); if ($assetarray[$i]['DepreciationType']==_('Straight Line')) { $TotalDepnAmount=round(($NoOfMonths/12)*($assetarray[$i]['DepreciationRate']/100)*$assetarray[$i]['cost'],2); } else { @@ -107,18 +106,18 @@ ' - '.$assetarray[$i]['serialno'].' - '.$assetarray[$i]['locationdescription']; $_SESSION['JournalDetail']->Add_To_GLAnalysis( - -($TotalDepnAmount-$assetarray[$i]['depn']), - $assetarray[$i]['narrative'], - $assetarray[$i]['bsdepn'], - $assetarray[$i]['bsdepnaccount'], + -($TotalDepnAmount-$assetarray[$i]['depn']), + $assetarray[$i]['narrative'], + $assetarray[$i]['bsdepn'], + $assetarray[$i]['bsdepnaccount'], 0, $assetarray[$i]['id']); $_SESSION['JournalDetail']->Add_To_GLAnalysis( - $TotalDepnAmount-$assetarray[$i]['depn'], - $assetarray[$i]['narrative'], - $assetarray[$i]['pldepn'], - $assetarray[$i]['pldepnaccount'], + $TotalDepnAmount-$assetarray[$i]['depn'], + $assetarray[$i]['narrative'], + $assetarray[$i]['pldepn'], + $assetarray[$i]['pldepnaccount'], 0, $assetarray[$i]['id']); $i++; @@ -137,7 +136,6 @@ $_SESSION['JournalDetail']->JournalType = $_POST['JournalType']; } $msg=''; - if (isset($_POST['CommitBatch']) and $_POST['CommitBatch']==_('Accept and Process Journal')){ /* once the GL analysis of the journal is entered @@ -151,58 +149,40 @@ $result = DB_Txn_Begin($db); $TransNo = GetNextTransNo( 0, $db); - + $BSorPL=1; // Balance sheet or P&L indicator + foreach ($_SESSION['JournalDetail']->GLEntries as $JournalItem) { - if ($JournalItem->Amount>0) { - $sql='UPDATE assetmanager SET depn=depn+'.$JournalItem->Amount.' WHERE id='.$JournalItem->assetid; + $odd=$BSorPL%2; + if ($odd==0) { + $sql='UPDATE assetmanager SET depn=depn+"'.$JournalItem->Amount.'" WHERE id="'.$JournalItem->assetid.'"'; + $ErrMsg = _('Cannot update the asset manager for this amount because'); + $DbgMsg = _('The SQL that failed to update the asset manger record was'); $result=DB_query($sql, $db,$ErrMsg,$DbgMsg,true); } + $BSorPL++; } foreach ($_SESSION['JournalDetail']->GLEntries as $JournalItem) { - $SQL = 'INSERT INTO gltrans (type, + $SQL = "INSERT INTO gltrans (type, typeno, trandate, periodno, account, narrative, amount, - tag) '; - $SQL= $SQL . 'VALUES (0, - ' . $TransNo . ", + tag) "; + $SQL= $SQL . "VALUES (0, + '" . $TransNo . "', '" . FormatDateForSQL($_SESSION['JournalDetail']->JnlDate) . "', - " . $PeriodNo . ", - " . $JournalItem->GLCode . ", + '" . $PeriodNo . "', + '" . $JournalItem->GLCode . "', '" . $JournalItem->Narrative . "', - " . $JournalItem->Amount . - ",'".$JournalItem->tag."')"; + '" . $JournalItem->Amount ."', + '" . $JournalItem->tag."' + )"; $ErrMsg = _('Cannot insert a GL entry for the journal line because'); $DbgMsg = _('The SQL that failed to insert the GL Trans record was'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - - if ($_POST['JournalType']==_('Reversing')){ - $SQL = 'INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount, - tag) '; - $SQL= $SQL . 'VALUES (0, - ' . $TransNo . ", - '" . FormatDateForSQL($_SESSION['JournalDetail']->JnlDate) . "', - " . ($PeriodNo + 1) . ", - " . $JournalItem->GLCode . ", - 'Reversal - " . $JournalItem->Narrative . "', - " . -($JournalItem->Amount) . - ",'".$JournalItem->tag."')"; - - $ErrMsg =_('Cannot insert a GL entry for the reversing journal because'); - $DbgMsg = _('The SQL that failed to insert the GL Trans record was'); - $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - - } } @@ -217,9 +197,10 @@ unset($_SESSION['JournalDetail']); /*Set up a newy in case user wishes to enter another */ - echo "<br><a href='" . $_SERVER['PHP_SELF'] . '?' . SID . "&NewJournal=Yes'>"._('Enter Another General Ledger Journal').'</a>'; + echo "<br><a href='index.php" . '?' . SID . "'>"._('Return to main menu').'</a>'; /*And post the journal too */ include ('includes/GLPostings.inc'); + include ('includes/footer.inc'); exit; } elseif (isset($_GET['Delete'])){ @@ -330,14 +311,11 @@ echo '<form action=' . $_SERVER['PHP_SELF'] . '?' . SID . ' method=post name="form">'; +echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/maintenance.png" title="' . _('Search') . '" alt="">' . ' ' . $title.'</p>'; -echo '<p><table border=0 width=100%> - <p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/maintenance.png" title="' . _('Search') . '" alt="">' . ' ' . $title.'<tr><hr></tr>'; - // A new table in the first column of the main table -echo '<tr> - <td colspan=5><table border=0 width=30%><tr><td>'._('Date to Process Journal').":</td> +echo '<table class=selection width=30%><tr><td>'._('Date to Process Journal').":</td> <td><input type='text' class='date' alt='".$_SESSION['DefaultDateFormat']. "' name='JournalProcessDate' maxlength=10 size=11 value='" . $_SESSION['JournalDetail']->JnlDate . "'></td>"; @@ -348,7 +326,7 @@ /* close off the table in the first column */ -echo "<table border =1 width=85%><tr><td><table width=100%> +echo "<table class=selection width=85%> <tr> <th>"._('GL Tag')."</th> <th>"._('GL Account')."</th> @@ -368,7 +346,7 @@ echo '<tr class="EvenTableRows">'; $j++; } - $sql='SELECT tagdescription + $sql='SELECT tagdescription FROM tags WHERE tagref='.$JournalItem->tag; $result=DB_query($sql, $db); @@ -407,7 +385,7 @@ echo ' Debit'; } -echo '</b></td></tr></table></td></tr></table>'; +echo '</b></td></tr></table>'; if (ABS($_SESSION['JournalDetail']->JournalTotal)<0.001 AND $_SESSION['JournalDetail']->GLItemCounter > 0){ echo "<br><br><div class='centre'><input type=submit name='CommitBatch' value='"._('Accept and Process Journal')."'></div>"; @@ -424,4 +402,4 @@ echo '</form>'; include('includes/footer.inc'); -?> +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-22 09:11:32 UTC (rev 3655) +++ trunk/doc/Change.log.html 2010-07-22 12:14:57 UTC (rev 3656) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<p>22/07/10 Tim: FixedAssetJournal.php - Corrections to depreciation calculation layout changes, and sql quoting</p> <p>22/07/10 Tim: SalesGraph.php - Update to latest phplot, add in choice of graph types layout changes, and sql quoting</p> <p>20/07/10 Tim: PcAuthoriseExpenses.php - Layout changes, and sql quoting</p> <p>20/07/10 Tim: FixedAssetRegister.php - Layout changes, correctly export to csv, and sql quoting</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-22 12:15:31
|
Revision: 3657 http://web-erp.svn.sourceforge.net/web-erp/?rev=3657&view=rev Author: tim_schofield Date: 2010-07-22 12:15:25 +0000 (Thu, 22 Jul 2010) Log Message: ----------- New script that provides a simple list of assets and their properties. Modified Paths: -------------- trunk/doc/Change.log.html trunk/index.php Added Paths: ----------- trunk/FixedAssetList.php Added: trunk/FixedAssetList.php =================================================================== --- trunk/FixedAssetList.php (rev 0) +++ trunk/FixedAssetList.php 2010-07-22 12:15:25 UTC (rev 3657) @@ -0,0 +1,46 @@ +<?php +$PageSecurity = 11; + +include('includes/session.inc'); +$title = _('Fixed Asset Properties List'); +include('includes/header.inc'); +echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/maintenance.png" title="' . + _('Search') . '" alt="">' . ' ' . $title; + +$sql='SELECT stockmaster.stockid, + assetmanager.serialno, + stockmaster.description, + stockcatproperties.label, + stockitemproperties.value + FROM assetmanager + LEFT JOIN stockmaster + ON assetmanager.stockid=stockmaster.stockid + LEFT JOIN stockcatproperties + ON stockmaster.categoryid=stockcatproperties.categoryid + LEFT JOIN stockitemproperties + ON stockcatproperties.stkcatpropid=stockitemproperties.stkcatpropid + WHERE stockmaster.stockid=stockitemproperties.stockid + ORDER BY assetmanager.serialno,stockmaster.stockid'; + +$result=DB_query($sql, $db); +echo '<table class=selection>'; +echo '<tr>'; +echo '<th>'._('Asset Type').'</th>'; +echo '<th>'._('Asset Reference').'</th>'; +echo '<th>'._('Description').'</th>'; +echo '<th>'._('Depreciation %').'</th>'; +echo '</tr>'; +while ($myrow=DB_fetch_array($result)) { + if ($myrow['value']!='Straight Line') { + echo '<tr>'; + echo '<td>'.$myrow['description'].'</td> + <td>'.$myrow['serialno'].'</td> + <td>'.$myrow['label'].'</td> + <td class=number>'.$myrow['value'].'%</td>'; + echo '</tr>'; + } +} +echo '</table>'; + +include('includes/footer.inc'); +?> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-22 12:14:57 UTC (rev 3656) +++ trunk/doc/Change.log.html 2010-07-22 12:15:25 UTC (rev 3657) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></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> <p>22/07/10 Tim: SalesGraph.php - Update to latest phplot, add in choice of graph types layout changes, and sql quoting</p> <p>20/07/10 Tim: PcAuthoriseExpenses.php - Layout changes, and sql quoting</p> Modified: trunk/index.php =================================================================== --- trunk/index.php 2010-07-22 12:14:57 UTC (rev 3656) +++ trunk/index.php 2010-07-22 12:15:25 UTC (rev 3657) @@ -1285,6 +1285,11 @@ </tr> <tr> <td class="menu_group_item"> + <?php echo '<p>• <a href="' . $rootpath . '/FixedAssetList.php?' . sid . '">' . _('List Asset properties') . '</a></p>'; ?> + </td> + </tr> + <tr> + <td class="menu_group_item"> <?php echo GetRptLinks('fa'); ?> </td> </tr> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tim...@us...> - 2010-07-22 15:32:01
|
Revision: 3658 http://web-erp.svn.sourceforge.net/web-erp/?rev=3658&view=rev Author: tim_schofield Date: 2010-07-22 15:31:55 +0000 (Thu, 22 Jul 2010) Log Message: ----------- Add in running balance. Cumulative for BS account, and period for PL accounts. Modified Paths: -------------- trunk/GLAccountInquiry.php trunk/doc/Change.log.html Modified: trunk/GLAccountInquiry.php =================================================================== --- trunk/GLAccountInquiry.php 2010-07-22 12:15:25 UTC (rev 3657) +++ trunk/GLAccountInquiry.php 2010-07-22 15:31:55 UTC (rev 3658) @@ -146,7 +146,7 @@ echo '<br><table class=selection>'; - echo '<tr><th colspan=7><b>' ._('Transactions for account').' '.$SelectedAccount. ' - '. $SelectedAccountName.'</b></th></tr>'; + echo '<tr><th colspan=8><b>' ._('Transactions for account').' '.$SelectedAccount. ' - '. $SelectedAccountName.'</b></th></tr>'; $TableHeader = "<tr> <th>" . _('Type') . "</th> <th>" . _('Number') . "</th> @@ -154,6 +154,7 @@ <th>" . _('Debit') . "</th> <th>" . _('Credit') . "</th> <th>" . _('Narrative') . "</th> + <th>" . _('Balance') . "</th> <th>" . _('Tag') . "</th> </tr>"; @@ -162,7 +163,7 @@ if ($PandLAccount==True) { $RunningTotal = 0; } else { - // added to fix bug with Brought Forward Balance always being zero + // added to fix bug with Brought Forward Balance always being zero $sql = "SELECT bfwd, actual, period @@ -198,7 +199,6 @@ $k=0; //row colour counter $IntegrityReport=''; while ($myrow=DB_fetch_array($TransResult)) { - if ($myrow['periodno']!=$PeriodNo){ if ($PeriodNo!=-9999){ //ie its not the first time around /*Get the ChartDetails balance b/fwd and the actual movement in the account for the period as recorded in the chart details - need to ensure integrity of transactions to the chart detail movements. Also, for a balance sheet account it is the balance carried forward that is important, not just the transactions*/ @@ -217,11 +217,17 @@ echo "<tr bgcolor='#FDFEEF'> <td colspan=3><b>" . _('Total for period') . ' ' . $PeriodNo . '</b></td>'; if ($PeriodTotal < 0 ){ //its a credit balance b/fwd + if ($PandLAccount==True) { + $RunningTotal = 0; + } echo '<td></td> <td class=number><b>' . number_format(-$PeriodTotal,2) . '</b></td> <td></td> </tr>'; } else { //its a debit balance b/fwd + if ($PandLAccount==True) { + $RunningTotal = 0; + } echo '<td class=number><b>' . number_format($PeriodTotal,2) . '</b></td> <td colspan=2></td> </tr>'; @@ -268,6 +274,7 @@ <td class=number>%s</td> <td class=number>%s</td> <td>%s</td> + <td class=number><b>%s</b></td> <td>%s</td> </tr>", $myrow['typename'], @@ -277,6 +284,7 @@ $DebitAmount, $CreditAmount, $myrow['narrative'], + number_format($RunningTotal,2), $tagrow['tagdescription']); } Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-07-22 12:15:25 UTC (rev 3657) +++ trunk/doc/Change.log.html 2010-07-22 15:31:55 UTC (rev 3658) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p></p> +<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> <p>22/07/10 Tim: SalesGraph.php - Update to latest phplot, add in choice of graph types layout changes, and sql quoting</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |