|
From: <dai...@us...> - 2013-01-26 22:31:40
|
Revision: 5797
http://sourceforge.net/p/web-erp/reponame/5797
Author: daintree
Date: 2013-01-26 22:31:34 +0000 (Sat, 26 Jan 2013)
Log Message:
-----------
Sell through support work
Modified Paths:
--------------
trunk/AccountGroups.php
trunk/BankMatching.php
trunk/Currencies.php
trunk/CustomerReceipt.php
trunk/DailyBankTransactions.php
trunk/InternalStockRequest.php
trunk/PO_Items.php
trunk/PurchData.php
trunk/SelectSupplier.php
trunk/StockAdjustments.php
trunk/StockLocTransferReceive.php
trunk/SystemParameters.php
trunk/UpgradeDatabase.php
trunk/UserSettings.php
trunk/WWW_Users.php
trunk/doc/Change.log
trunk/doc/LICENSE.txt
trunk/doc/Manual/ManualContributors.html
trunk/doc/Manual/ManualInventory.html
trunk/doc/Manual/ManualOutline.php
trunk/doc/README.txt
trunk/doc/UPGRADING.txt
trunk/includes/ConnectDB.inc
trunk/includes/DateFunctions.inc
trunk/includes/DefineCartClass.php
trunk/includes/DefineReceiptClass.php
trunk/includes/MainMenuLinksArray.php
trunk/includes/MiscFunctions.php
trunk/includes/PDFTransPageHeader.inc
trunk/includes/PDFTransPageHeaderPortrait.inc
trunk/includes/SelectOrderItems_IntoCart.inc
trunk/includes/session.inc
trunk/install/save.php
trunk/locale/ar_EG.utf8/LC_MESSAGES/messages.mo
trunk/locale/ar_EG.utf8/LC_MESSAGES/messages.po
trunk/locale/cs_CZ.utf8/LC_MESSAGES/messages.mo
trunk/locale/cs_CZ.utf8/LC_MESSAGES/messages.po
trunk/locale/de_DE.utf8/LC_MESSAGES/messages.mo
trunk/locale/de_DE.utf8/LC_MESSAGES/messages.po
trunk/locale/el_GR.utf8/LC_MESSAGES/messages.mo
trunk/locale/el_GR.utf8/LC_MESSAGES/messages.po
trunk/locale/en_GB.utf8/LC_MESSAGES/messages.pot
trunk/locale/en_US.utf8/LC_MESSAGES/messages.mo
trunk/locale/en_US.utf8/LC_MESSAGES/messages.po
trunk/locale/es_ES.utf8/LC_MESSAGES/messages.mo
trunk/locale/es_ES.utf8/LC_MESSAGES/messages.po
trunk/locale/et_EE.utf8/LC_MESSAGES/messages.mo
trunk/locale/et_EE.utf8/LC_MESSAGES/messages.po
trunk/locale/fa_IR.utf8/LC_MESSAGES/messages.mo
trunk/locale/fa_IR.utf8/LC_MESSAGES/messages.po
trunk/locale/fr_CA.utf8/LC_MESSAGES/messages.po
trunk/locale/fr_FR.utf8/LC_MESSAGES/messages.mo
trunk/locale/fr_FR.utf8/LC_MESSAGES/messages.po
trunk/locale/hi_IN.utf8/LC_MESSAGES/messages.mo
trunk/locale/hi_IN.utf8/LC_MESSAGES/messages.po
trunk/locale/hr_HR.utf8/LC_MESSAGES/messages.mo
trunk/locale/hr_HR.utf8/LC_MESSAGES/messages.po
trunk/locale/hu_HU.utf8/LC_MESSAGES/messages.mo
trunk/locale/hu_HU.utf8/LC_MESSAGES/messages.po
trunk/locale/id_ID.utf8/LC_MESSAGES/messages.mo
trunk/locale/id_ID.utf8/LC_MESSAGES/messages.po
trunk/locale/it_IT.utf8/LC_MESSAGES/messages.mo
trunk/locale/it_IT.utf8/LC_MESSAGES/messages.po
trunk/locale/ja_JP.utf8/LC_MESSAGES/messages.mo
trunk/locale/ja_JP.utf8/LC_MESSAGES/messages.po
trunk/locale/lv_LV.utf8/LC_MESSAGES/messages.mo
trunk/locale/lv_LV.utf8/LC_MESSAGES/messages.po
trunk/locale/nl_NL.utf8/LC_MESSAGES/messages.mo
trunk/locale/nl_NL.utf8/LC_MESSAGES/messages.po
trunk/locale/pl_PL.utf8/LC_MESSAGES/messages.mo
trunk/locale/pl_PL.utf8/LC_MESSAGES/messages.po
trunk/locale/pt_BR.utf8/LC_MESSAGES/messages.mo
trunk/locale/pt_BR.utf8/LC_MESSAGES/messages.po
trunk/locale/pt_PT.utf8/LC_MESSAGES/messages.mo
trunk/locale/pt_PT.utf8/LC_MESSAGES/messages.po
trunk/locale/ro_RO.utf8/LC_MESSAGES/messages.mo
trunk/locale/ro_RO.utf8/LC_MESSAGES/messages.po
trunk/locale/ru_RU.utf8/LC_MESSAGES/messages.mo
trunk/locale/ru_RU.utf8/LC_MESSAGES/messages.po
trunk/locale/sq_AL.utf8/LC_MESSAGES/messages.mo
trunk/locale/sq_AL.utf8/LC_MESSAGES/messages.po
trunk/locale/sv_SE.utf8/LC_MESSAGES/messages.mo
trunk/locale/sv_SE.utf8/LC_MESSAGES/messages.po
trunk/locale/sw_KE.utf8/LC_MESSAGES/messages.mo
trunk/locale/sw_KE.utf8/LC_MESSAGES/messages.po
trunk/locale/tr_TR.utf8/LC_MESSAGES/messages.mo
trunk/locale/tr_TR.utf8/LC_MESSAGES/messages.po
trunk/locale/vi_VN.utf8/LC_MESSAGES/messages.mo
trunk/locale/vi_VN.utf8/LC_MESSAGES/messages.po
trunk/locale/zh_CN.utf8/LC_MESSAGES/messages.mo
trunk/locale/zh_CN.utf8/LC_MESSAGES/messages.po
trunk/locale/zh_HK.utf8/LC_MESSAGES/messages.mo
trunk/locale/zh_HK.utf8/LC_MESSAGES/messages.po
trunk/sql/mysql/upgrade4.09-4.10.sql
trunk/sql/mysql/weberp-demo.sql
trunk/sql/mysql/weberp-new.sql
Modified: trunk/AccountGroups.php
===================================================================
--- trunk/AccountGroups.php 2013-01-23 19:32:03 UTC (rev 5796)
+++ trunk/AccountGroups.php 2013-01-26 22:31:34 UTC (rev 5797)
@@ -64,7 +64,7 @@
$sql="SELECT count(groupname)
FROM accountgroups
- WHERE groupname='".$_POST['GroupName']."'";
+ WHERE groupname='" . $_POST['GroupName'] . "'";
$DbgMsg = _('The SQL that was used to retrieve the information was');
$ErrMsg = _('Could not check whether the group exists because');
@@ -72,7 +72,7 @@
$result=DB_query($sql, $db,$ErrMsg,$DbgMsg);
$myrow=DB_fetch_row($result);
- if ($myrow[0]!=0 AND $_POST['SelectedAccountGroup']=='') {
+ if ($myrow[0] != 0 AND $_POST['SelectedAccountGroup'] == '') {
$InputError = 1;
prnMsg( _('The account group name already exists in the database'),'error');
$Errors[$i] = 'GroupName';
@@ -138,7 +138,27 @@
if ($_POST['SelectedAccountGroup']!='' AND $InputError !=1) {
/*SelectedAccountGroup 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*/
+ if ($_POST['SelectedAccountGroup']!==$_POST['GroupName']) {
+ DB_IgnoreForeignKeys($db);
+
+ $sql = "UPDATE chartmaster
+ SET group_='" . $_POST['GroupName'] . "'
+ WHERE group_='" . $_POST['SelectedAccountGroup'] . "'";
+ $ErrMsg = _('An error occurred in renaming the account group');
+ $DbgMsg = _('The SQL that was used to rename the account group was');
+
+ $result = DB_query($sql, $db, $ErrMsg, $DbgMsg);
+
+ $sql = "UPDATE accountgroups
+ SET parentgroupname='" . $_POST['GroupName'] . "'
+ WHERE parentgroupname='" . $_POST['SelectedAccountGroup'] . "'";
+
+ $result = DB_query($sql, $db, $ErrMsg, $DbgMsg);
+
+ DB_ReinstateForeignKeys($db);
+ }
+
$sql = "UPDATE accountgroups SET groupname='" . $_POST['GroupName'] . "',
sectioninaccounts='" . $_POST['SectionInAccounts'] . "',
pandl='" . $_POST['PandL'] . "',
@@ -347,16 +367,8 @@
echo '<tr>
<th colspan="2">' . _('Edit Account Group Details') . '</th>
</tr>';
- echo '<tr>
- <td><input type="hidden" name="SelectedAccountGroup" value="' . $_GET['SelectedAccountGroup'] . '" /></td>
- <td><input type="hidden" name="GroupName" value="' . $_POST['GroupName'] . '" /></td>
- </tr>';
+ echo '<input type="hidden" name="SelectedAccountGroup" value="' . $_GET['SelectedAccountGroup'] . '" />';
- echo '<tr>
- <td>' . _('Account Group') . ':' . '</td>
- <td>' . $_POST['GroupName'] . '</td>
- </tr>';
-
} elseif (!isset($_POST['MoveGroup'])) { //end of if $_POST['SelectedAccountGroup'] only do the else when a new record is being entered
if (!isset($_POST['SelectedAccountGroup'])){
@@ -382,12 +394,12 @@
echo '<tr>
<td><input type="hidden" name="SelectedAccountGroup" value="' . $_POST['SelectedAccountGroup'] . '" /></td>
</tr>';
- echo '<tr>
- <td>' . _('Account Group Name') . ':' . '</td>
- <td><input tabindex="1" ' . (in_array('GroupName',$Errors) ? 'class="inputerror"' : '' ) .' type="text" name="GroupName" size="50" maxlength="50" value="' . $_POST['GroupName'] . '" /></td>
- </tr>';
}
echo '<tr>
+ <td>' . _('Account Group Name') . ':' . '</td>
+ <td><input tabindex="1" ' . (in_array('GroupName',$Errors) ? 'class="inputerror"' : '' ) .' type="text" name="GroupName" size="50" maxlength="50" value="' . $_POST['GroupName'] . '" /></td>
+ </tr>
+ <tr>
<td>' . _('Parent Group') . ':' . '</td>
<td><select tabindex="2" ' . (in_array('ParentGroupName',$Errors) ? 'class="selecterror"' : '' ) . ' name="ParentGroupName">';
@@ -407,10 +419,9 @@
echo '<option value="'.htmlspecialchars($grouprow['groupname'], ENT_QUOTES,'UTF-8').'">' .htmlspecialchars($grouprow['groupname'], ENT_QUOTES,'UTF-8').'</option>';
}
}
- echo '</select>';
- echo '</td></tr>';
-
- echo '<tr>
+ echo '</select></td>
+ </tr>
+ <tr>
<td>' . _('Section In Accounts') . ':' . '</td>
<td><select tabindex="3" ' . (in_array('SectionInAccounts',$Errors) ? 'class="selecterror"' : '' ) . ' name="SectionInAccounts">';
@@ -423,10 +434,9 @@
echo '<option value="'.$secrow['sectionid'].'">'.$secrow['sectionname'].' ('.$secrow['sectionid'].')</option>';
}
}
- echo '</select>';
- echo '</td></tr>';
-
- echo '<tr>
+ echo '</select></td>
+ </tr>
+ <tr>
<td>' . _('Profit and Loss') . ':' . '</td>
<td><select tabindex="4" name="PandL">';
@@ -441,22 +451,21 @@
echo '<option value="0">' . _('No').'</option>';
}
- echo '</select></td></tr>';
-
- echo '<tr>
+ echo '</select></td>
+ </tr>
+ <tr>
<td>' . _('Sequence In TB') . ':' . '</td>
<td><input tabindex="5" type="text" maxlength="4" name="SequenceInTB" class="number" value="' . $_POST['SequenceInTB'] . '" /></td>
- </tr>';
-
- echo '<tr>
+ </tr>
+ <tr>
<td colspan="2"><div class="centre"><input tabindex="6" type="submit" name="submit" value="' . _('Enter Information') . '" /></div></td>
- </tr>';
+ </tr>
+ </table>
+ <br />';
- echo '</table><br />';
-
echo '<script type="text/javascript">defaultControl(document.forms[0].GroupName);</script>';
- echo '</div>';
- echo '</form>';
+ echo '</div>
+ </form>';
} //end if record deleted no point displaying form to add record
include('includes/footer.inc');
Modified: trunk/BankMatching.php
===================================================================
--- trunk/BankMatching.php 2013-01-23 19:32:03 UTC (rev 5796)
+++ trunk/BankMatching.php 2013-01-26 22:31:34 UTC (rev 5797)
@@ -159,12 +159,14 @@
echo '</table>
<br />
<div class="centre">
- <input tabindex="6" type="submit" name="ShowTransactions" value="' . _('Show selected') . ' ' . $TypeName . '" />
- <p>
- <a href="' . $RootPath . '/BankReconciliation.php?Account=' . $_POST['BankAccount'] . '">' . _('Show reconciliation') . '</a>
- </p>
- </div>';
+ <input tabindex="6" type="submit" name="ShowTransactions" value="' . _('Show selected') . ' ' . $TypeName . '" />';
+if (isset($_POST['BankAccount'])) {
+ echo '<p><a href="' . $RootPath . '/BankReconciliation.php?Account=' . $_POST['BankAccount'] . '">' . _('Show reconciliation') . '</a></p>';
+}
+
+echo '</div>';
+
$InputError=0;
if (!Is_Date($_POST['BeforeDate'])){
$InputError =1;
Modified: trunk/Currencies.php
===================================================================
--- trunk/Currencies.php 2013-01-23 19:32:03 UTC (rev 5796)
+++ trunk/Currencies.php 2013-01-26 22:31:34 UTC (rev 5797)
@@ -47,7 +47,7 @@
$result=DB_query($sql, $db);
$myrow=DB_fetch_row($result);
- if ($myrow[0]!=0 and !isset($SelectedCurrency)) {
+ if ($myrow[0]!=0 AND !isset($SelectedCurrency)) {
$InputError = 1;
prnMsg( _('The currency already exists in the database'),'error');
$Errors[$i] = 'Abbreviation';
@@ -61,7 +61,7 @@
}
if (!is_numeric(filter_number_format($_POST['ExchangeRate']))){
$InputError = 1;
- prnMsg(_('The exchange rate must be numeric'),'error');
+ prnMsg(_('The exchange rate must be numeric'),'error');
$Errors[$i] = 'ExchangeRate';
$i++;
}
@@ -300,7 +300,8 @@
}
} //END WHILE LIST LOOP
- echo '</table><br />';
+ echo '</table>
+ <br />';
} //end of ifs and buts!
@@ -373,7 +374,7 @@
if (!isset($_POST['Country'])) {
$_POST['Country']='';
}
- echo '<input ' . (in_array('Country',$Errors) ? 'class="inputerror"' : '' ) .' type="text" name="Country" size="30" maxlength="50" value="' . $_POST['Country'] . '" /></td>
+ echo '<input ' . (in_array('Country',$Errors) ? 'class="inputerror"' : '' ) . ' type="text" name="Country" size="30" maxlength="50" value="' . $_POST['Country'] . '" /></td>
</tr>
<tr>
<td>'._('Hundredths Name').':</td>
@@ -381,7 +382,7 @@
if (!isset($_POST['HundredsName'])) {
$_POST['HundredsName']='';
}
- echo '<input ' . (in_array('HundredsName',$Errors) ? 'class="inputerror"' : '' ) .' type="text" name="HundredsName" size="10" maxlength="15" value="'. $_POST['HundredsName'].'" /></td>
+ echo '<input ' . (in_array('HundredsName',$Errors) ? 'class="inputerror"' : '' ) . ' type="text" name="HundredsName" size="10" maxlength="15" value="'. $_POST['HundredsName'].'" /></td>
</tr>
<tr>
<td>'._('Decimal Places to Display').':</td>
@@ -389,7 +390,7 @@
if (!isset($_POST['DecimalPlaces'])) {
$_POST['DecimalPlaces']='';
}
- echo '<input ' . (in_array('DecimalPlaces',$Errors) ? 'class="inputerror"' : 'class="number"' ) .' type="text" name="DecimalPlaces" size="2" maxlength="2" value="'. $_POST['DecimalPlaces'].'" /></td>
+ echo '<input ' . (in_array('DecimalPlaces',$Errors) ? 'class="inputerror"' : 'class="number"' ) . ' type="text" name="DecimalPlaces" size="2" maxlength="2" value="' . $_POST['DecimalPlaces'].'" /></td>
</tr>
<tr>
<td>'._('Exchange Rate').':</td>
@@ -397,13 +398,13 @@
if (!isset($_POST['ExchangeRate'])) {
$_POST['ExchangeRate']='';
}
- echo '<input ' . (in_array('ExchangeRate',$Errors) ? 'class="inputerror"' : '' ) .' type="text" class="number" name="ExchangeRate" size="10" maxlength="10" value="'. $_POST['ExchangeRate'].'" /></td>
+ echo '<input ' . (in_array('ExchangeRate',$Errors) ? 'class="inputerror"' : '' ) .' type="text" class="number" name="ExchangeRate" size="10" maxlength="10" value="' . $_POST['ExchangeRate'] . '" /></td>
</tr>
</table>';
echo '<br />
<div class="centre">
- <input type="submit" name="submit" value="'._('Enter Information').'" />
+ <input type="submit" name="submit" value="' . _('Enter Information') . '" />
</div>
</div>
</form>';
Modified: trunk/CustomerReceipt.php
===================================================================
--- trunk/CustomerReceipt.php 2013-01-23 19:32:03 UTC (rev 5796)
+++ trunk/CustomerReceipt.php 2013-01-26 22:31:34 UTC (rev 5797)
@@ -832,7 +832,7 @@
}
if ($_SESSION['ReceiptBatch']->ExRate==1 AND isset($SuggestedExRate)){
$_SESSION['ReceiptBatch']->ExRate = $SuggestedExRate;
- }elseif($_POST['Currency'] != $_POST['PreviousCurrency'] and isset($SuggestedExRate)){//the user has changed the currency, then we should revise suggested rate
+ }elseif($_POST['Currency'] != $_POST['PreviousCurrency'] AND isset($SuggestedExRate)){//the user has changed the currency, then we should revise suggested rate
$_SESSION['ReceiptBatch']->ExRate = $SuggestedExRate;
}
echo '<tr>
Modified: trunk/DailyBankTransactions.php
===================================================================
--- trunk/DailyBankTransactions.php 2013-01-23 19:32:03 UTC (rev 5796)
+++ trunk/DailyBankTransactions.php 2013-01-26 22:31:34 UTC (rev 5797)
@@ -62,6 +62,14 @@
<td>' . _('Transactions Dated To') . ':</td>
<td><input type="text" name="ToTransDate" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" maxlength="10" size="11" onchange="isDate(this, this.value, '."'".$_SESSION['DefaultDateFormat']."'".')" value="' . date($_SESSION['DefaultDateFormat']) . '" /></td>
</tr>
+ <tr>
+ <td>' . _('Show Transactions') . '</td>
+ <td><select name="ShowType">
+ <option value="All">' . _('All') . '</option>
+ <option value="Unmatched">' . _('Unmatched') . '</option>
+ <option value="Matched">' . _('Matched') . '</option>
+ </select></td>
+ </tr>
</table>
<br />
<div class="centre">
@@ -82,6 +90,7 @@
$sql="SELECT banktrans.currcode,
banktrans.amount,
+ banktrans.amountcleared,
banktrans.functionalexrate,
banktrans.exrate,
banktrans.banktranstype,
@@ -106,7 +115,7 @@
$BankDetailRow = DB_fetch_array($BankResult);
echo '<table class="selection">
<tr>
- <th colspan="8"><h3>' . _('Account Transactions For').' '.$BankDetailRow['bankaccountname'].' '._('Between').' '.$_POST['FromTransDate'] . ' ' . _('and') . ' ' . $_POST['ToTransDate'] . '</h3></th>
+ <th colspan="9"><h3>' . _('Account Transactions For').' '.$BankDetailRow['bankaccountname'].' '._('Between').' '.$_POST['FromTransDate'] . ' ' . _('and') . ' ' . $_POST['ToTransDate'] . '</h3></th>
</tr>
<tr>
<th>' . ('Date') . '</th>
@@ -117,6 +126,7 @@
<th>'._('Running Total').' '.$BankDetailRow['currcode'].'</th>
<th>'._('Amount in').' '.$_SESSION['CompanyRecord']['currencydefault'].'</th>
<th>'._('Running Total').' '.$_SESSION['CompanyRecord']['currencydefault'].'</th>
+ <th>'._('Cleared') . '</th>
</tr>';
$AccountCurrTotal=0;
@@ -126,28 +136,37 @@
$AccountCurrTotal += $myrow['amount'];
$LocalCurrTotal += $myrow['amount']/$myrow['functionalexrate']/$myrow['exrate'];
+
+ if ($myrow['amount']==$myrow['amountcleared']) {
+ $Matched=_('Yes');
+ } else {
+ $Matched=_('No');
+ }
echo '<tr>
<td>'. ConvertSQLDate($myrow['transdate']) . '</td>
<td>'.$myrow['typename'].'</td>
<td>'.$myrow['banktranstype'].'</td>
<td>'.$myrow['ref'].'</td>
- <td class="number">'.locale_number_format($myrow['amount'],$BankDetailRow['decimalplaces']).'</td>
- <td class="number">'.locale_number_format($AccountCurrTotal,$BankDetailRow['decimalplaces']).'</td>
- <td class="number">'.locale_number_format($myrow['amount']/$myrow['functionalexrate']/$myrow['exrate'],$_SESSION['CompanyRecord']['decimalplaces']).'</td>
- <td class="number">'.locale_number_format($LocalCurrTotal,$_SESSION['CompanyRecord']['decimalplaces']).'</td>
+ <td class="number">' . locale_number_format($myrow['amount'],$BankDetailRow['decimalplaces']) . '</td>
+ <td class="number">' . locale_number_format($AccountCurrTotal,$BankDetailRow['decimalplaces']) . '</td>
+ <td class="number">' . locale_number_format($myrow['amount']/$myrow['functionalexrate']/$myrow['exrate'],$_SESSION['CompanyRecord']['decimalplaces']) . '</td>
+ <td class="number">' . locale_number_format($LocalCurrTotal,$_SESSION['CompanyRecord']['decimalplaces']) . '</td>
+ <td class="number">' . $Matched . '</td>
</tr>';
}
echo '</table>';
} //end if no bank trans in the range to show
- echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">';
- echo '<div>';
- echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
- echo '<br /><div class="centre"><input type="submit" name="Return" value="' . _('Select Another Date'). '" /></div>';
- echo '</div>';
- echo '</form>';
+ echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">
+ <div>
+ <input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />
+ <br />
+ <div class="centre">
+ <input type="submit" name="Return" value="' . _('Select Another Date'). '" />
+ </div>
+ </div>
+ </form>';
}
include('includes/footer.inc');
-
?>
\ No newline at end of file
Modified: trunk/InternalStockRequest.php
===================================================================
--- trunk/InternalStockRequest.php 2013-01-23 19:32:03 UTC (rev 5796)
+++ trunk/InternalStockRequest.php 2013-01-26 22:31:34 UTC (rev 5797)
@@ -245,7 +245,6 @@
exit;
}
-//****************MUESTRO LA TABLA CON LOS REGISTROS DE LA TRANSFERENCIA*************************************
$i = 0; //Line Item Array pointer
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">';
echo '<div>';
@@ -383,7 +382,6 @@
WHERE stockmaster.categoryid=stockcategory.categoryid
AND stockcategory.categoryid = internalstockcatrole.categoryid
AND internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . "
- AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
AND stockmaster.mbflag <>'G'
AND stockmaster.description " . LIKE . " '" . $SearchString . "'
AND stockmaster.discontinued=0
@@ -399,7 +397,6 @@
WHERE stockmaster.categoryid=stockcategory.categoryid
AND stockcategory.categoryid = internalstockcatrole.categoryid
AND internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . "
- AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
AND stockmaster.mbflag <>'G'
AND stockmaster.discontinued=0
AND stockmaster.description " . LIKE . " '" . $SearchString . "'
@@ -423,7 +420,6 @@
WHERE stockmaster.categoryid=stockcategory.categoryid
AND stockcategory.categoryid = internalstockcatrole.categoryid
AND internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . "
- AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
AND stockmaster.stockid " . LIKE . " '" . $SearchString . "'
AND stockmaster.mbflag <>'G'
AND stockmaster.discontinued=0
@@ -439,7 +435,6 @@
WHERE stockmaster.categoryid=stockcategory.categoryid
AND stockcategory.categoryid = internalstockcatrole.categoryid
AND internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . "
- AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
AND stockmaster.stockid " . LIKE . " '" . $SearchString . "'
AND stockmaster.mbflag <>'G'
AND stockmaster.discontinued=0
@@ -459,7 +454,6 @@
WHERE stockmaster.categoryid=stockcategory.categoryid
AND stockcategory.categoryid = internalstockcatrole.categoryid
AND internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . "
- AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
AND stockmaster.mbflag <>'G'
AND stockmaster.discontinued=0
ORDER BY stockmaster.stockid";
@@ -474,7 +468,6 @@
WHERE stockmaster.categoryid=stockcategory.categoryid
AND stockcategory.categoryid = internalstockcatrole.categoryid
AND internalstockcatrole.secroleid= " . $_SESSION['AccessLevel'] . "
- AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D')
AND stockmaster.mbflag <>'G'
AND stockmaster.discontinued=0
AND stockmaster.categoryid='" . $_POST['StockCat'] . "'
Modified: trunk/PO_Items.php
===================================================================
--- trunk/PO_Items.php 2013-01-23 19:32:03 UTC (rev 5796)
+++ trunk/PO_Items.php 2013-01-26 22:31:34 UTC (rev 5797)
@@ -20,7 +20,7 @@
if (!isset($_SESSION['PO'.$identifier])){
header('Location:' . $RootPath . '/PO_Header.php');
exit;
-} //end if (!isset($_SESSION['PO'.$identifier]))
+}
/* webERP manual links before header.inc */
$ViewTopic= 'PurchaseOrdering';
@@ -43,12 +43,12 @@
if (!is_numeric(filter_number_format($_POST['SuppQty'.$POLine->LineNo]))){
prnMsg(_('The quantity in the supplier units is expected to be numeric. Please re-enter as a number'),'error');
} else { //ok to update the PO object variables
- $_SESSION['PO'.$identifier]->LineItems[$POLine->LineNo]->Quantity=filter_number_format(round(filter_number_format($_POST['SuppQty'.$POLine->LineNo])*filter_number_format($_SESSION['PO'.$identifier]->LineItems[$POLine->LineNo]->ConversionFactor),$_SESSION['PO'.$identifier]->LineItems[$POLine->LineNo]->DecimalPlaces));
+ $_SESSION['PO'.$identifier]->LineItems[$POLine->LineNo]->Quantity = filter_number_format(round(filter_number_format($_POST['SuppQty'.$POLine->LineNo])*filter_number_format($_SESSION['PO'.$identifier]->LineItems[$POLine->LineNo]->ConversionFactor),$_SESSION['PO'.$identifier]->LineItems[$POLine->LineNo]->DecimalPlaces));
}
if (!is_numeric(filter_number_format($_POST['SuppPrice'.$POLine->LineNo]))){
prnMsg(_('The supplier price is expected to be numeric. Please re-enter as a number'),'error');
} else { //ok to update the PO object variables
- $_SESSION['PO'.$identifier]->LineItems[$POLine->LineNo]->Price=filter_number_format($_POST['SuppPrice'.$POLine->LineNo])/$_SESSION['PO'.$identifier]->LineItems[$POLine->LineNo]->ConversionFactor;
+ $_SESSION['PO'.$identifier]->LineItems[$POLine->LineNo]->Price = filter_number_format($_POST['SuppPrice'.$POLine->LineNo])/$_SESSION['PO'.$identifier]->LineItems[$POLine->LineNo]->ConversionFactor;
}
$_SESSION['PO'.$identifier]->LineItems[$POLine->LineNo]->ReqDelDate=$_POST['ReqDelDate'.$POLine->LineNo];
$_SESSION['PO'.$identifier]->LineItems[$POLine->LineNo]->ItemDescription =$_POST['ItemDescription'.$POLine->LineNo];
@@ -521,7 +521,9 @@
//Add variables $_SESSION['PO_ItemsResubmitForm' . $identifier] and $_POST['PO_ItemsResubmitFormValue'] to prevent from page refreshing effect
$_SESSION['PO_ItemsResubmitForm' . $identifier] = (empty($_SESSION['PO_ItemsResubmitForm' . $identifier]))? '1' : $_SESSION['PO_ItemsResubmitForm' . $identifier];
-if (isset($_POST['NewItem']) and !empty($_POST['PO_ItemsResubmitFormValue']) and $_SESSION['PO_ItemsResubmitForm' . $identifier] == $_POST['PO_ItemsResubmitFormValue']){ //only submit values can be processed
+if (isset($_POST['NewItem'])
+ AND !empty($_POST['PO_ItemsResubmitFormValue'])
+ AND $_SESSION['PO_ItemsResubmitForm' . $identifier] == $_POST['PO_ItemsResubmitFormValue']){ //only submit values can be processed
/* 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
@@ -595,7 +597,32 @@
$PurchDataResult = DB_query($sql,$db,$ErrMsg,$DbgMsg);
if (DB_num_rows($PurchDataResult)>0){ //the purchasing data is set up
$PurchRow = DB_fetch_array($PurchDataResult);
- $PurchPrice = $PurchRow['price']/$PurchRow['conversionfactor'];
+
+ /* Now to get the applicable discounts */
+ $sql = "SELECT discountpercent,
+ discountamount
+ FROM supplierdiscounts
+ WHERE supplierno= '" . $_SESSION['PO'.$identifier]->SupplierID . "'
+ AND effectivefrom <='" . Date('Y-m-d') . "'
+ AND effectiveto >='" . Date('Y-m-d') . "'
+ AND stockid = '". $ItemCode . "'";
+
+ $ItemDiscountPercent = 0;
+ $ItemDiscountAmount = 0;
+ $ErrMsg = _('Could not retrieve the supplier discounts applicable to the item');
+ $DbgMsg = _('The SQL used to retrive the supplier discounts that failed was');
+ $DiscountResult = DB_query($sql,$db,$ErrMsg,$DbgMsg);
+ while ($DiscountRow = DB_fetch_array($DiscountResult)) {
+ $ItemDiscountPercent += $DiscountRow['discountpercent'];
+ $ItemDiscountAmount += $DiscountRow['discountamount'];
+ }
+ if ($ItemDiscountPercent != 0) {
+ prnMsg(_('Taken accumulated supplier percentage discounts of') . ' ' . locale_number_format($ItemDiscountPercent*100,2) . '%','info');
+ }
+ if ($ItemDiscountAmount != 0 ){
+ prnMsg(_('Taken accumulated round sum supplier discount of') . ' ' . $_SESSION['PO'.$identifier]->CurrCode . ' ' . locale_number_format($ItemDiscountAmount,$_SESSION['PO'.$identifier]->CurrDecimalPlaces) . ' (' . _('per supplier unit') . ')','info');
+ }
+ $PurchPrice = ($PurchRow['price']*(1-$ItemDiscountPercent) - $ItemDiscountAmount)/$PurchRow['conversionfactor'];
$ConversionFactor = $PurchRow['conversionfactor'];
$SupplierDescription = $PurchRow['suppliers_partno'] .' - ';
if (mb_strlen($PurchRow['supplierdescription'])>2){
@@ -680,7 +707,7 @@
<th>' . _('Description') . '</th>
<th>' . _('Quantity Our Units') . '</th>
<th>' . _('Our Unit') .'</th>
- <th>' . _('Price Our Units') .' ('.$_SESSION['PO'.$identifier]->CurrCode. ')</th>
+ <th>' . _('Price Our Units') .' (' . $_SESSION['PO'.$identifier]->CurrCode . ')</th>
<th>' . _('Unit Conversion Factor') . '</th>
<th>' . _('Order Quantity') . '<br />' . _('Supplier Units') . '</th>
<th>' . _('Supplier Unit') . '</th>
@@ -718,7 +745,7 @@
<td class="number">' . locale_number_format($POLine->Quantity,$POLine->DecimalPlaces) . '</td>
<td>' . $POLine->Units . '</td>
<td class="number">' . $DisplayPrice . '</td>
- <td><input type="text" class="number" name="ConversionFactor' . $POLine->LineNo .'" size="8" value="' . $POLine->ConversionFactor . '" /></td>
+ <td><input type="text" class="number" name="ConversionFactor' . $POLine->LineNo .'" size="8" value="' . locale_number_format($POLine->ConversionFactor,'Variable') . '" /></td>
<td><input type="text" class="number" name="SuppQty' . $POLine->LineNo .'" size="10" value="' . locale_number_format(round($POLine->Quantity/$POLine->ConversionFactor,$POLine->DecimalPlaces),$POLine->DecimalPlaces) . '" /></td>
<td>' . $POLine->SuppliersUnit . '</td>
<td><input type="text" class="number" name="SuppPrice' . $POLine->LineNo . '" size="10" value="' . locale_number_format(round(($POLine->Price *$POLine->ConversionFactor),$_SESSION['PO'.$identifier]->CurrDecimalPlaces),$_SESSION['PO'.$identifier]->CurrDecimalPlaces) .'" /></td>
@@ -824,6 +851,7 @@
ON stockmaster.stockid=purchdata.stockid
WHERE stockmaster.mbflag<>'D'
AND stockmaster.mbflag<>'K'
+ AND stockmaster.mbflag<>'A'
AND stockmaster.mbflag<>'G'
AND stockmaster.discontinued<>1
AND purchdata.supplierno='" . $_SESSION['PO'.$identifier]->SupplierID . "'
@@ -839,6 +867,7 @@
ON stockmaster.categoryid=stockcategory.categoryid
WHERE stockmaster.mbflag<>'D'
AND stockmaster.mbflag<>'K'
+ AND stockmaster.mbflag<>'A'
AND stockmaster.mbflag<>'G'
AND stockmaster.discontinued<>1
AND stockmaster.description " . LIKE . " '" . $SearchString ."'
@@ -855,6 +884,7 @@
INNER JOIN purchdata
ON stockmaster.stockid=purchdata.stockid
WHERE stockmaster.mbflag<>'D'
+ AND stockmaster.mbflag<>'A'
AND stockmaster.mbflag<>'K'
AND stockmaster.mbflag<>'G'
AND purchdata.supplierno='" . $_SESSION['PO'.$identifier]->SupplierID . "'
@@ -870,6 +900,7 @@
FROM stockmaster INNER JOIN stockcategory
ON stockmaster.categoryid=stockcategory.categoryid
WHERE stockmaster.mbflag<>'D'
+ AND stockmaster.mbflag<>'A'
AND stockmaster.mbflag<>'K'
AND stockmaster.mbflag<>'G'
AND stockmaster.discontinued<>1
@@ -895,6 +926,7 @@
ON stockmaster.stockid=purchdata.stockid
WHERE stockmaster.mbflag<>'D'
AND stockmaster.mbflag<>'K'
+ AND stockmaster.mbflag<>'A'
AND stockmaster.mbflag<>'G'
AND purchdata.supplierno='" . $_SESSION['PO'.$identifier]->SupplierID . "'
AND stockmaster.discontinued<>1
@@ -908,6 +940,7 @@
FROM stockmaster INNER JOIN stockcategory
ON stockmaster.categoryid=stockcategory.categoryid
WHERE stockmaster.mbflag<>'D'
+ AND stockmaster.mbflag<>'A'
AND stockmaster.mbflag<>'K'
AND stockmaster.mbflag<>'G'
AND stockmaster.discontinued<>1
@@ -925,6 +958,7 @@
INNER JOIN purchdata
ON stockmaster.stockid=purchdata.stockid
WHERE stockmaster.mbflag<>'D'
+ AND stockmaster.mbflag<>'A'
AND stockmaster.mbflag<>'K'
AND stockmaster.mbflag<>'G'
AND purchdata.supplierno='" . $_SESSION['PO'.$identifier]->SupplierID . "'
@@ -940,6 +974,7 @@
FROM stockmaster INNER JOIN stockcategory
ON stockmaster.categoryid=stockcategory.categoryid
WHERE stockmaster.mbflag<>'D'
+ AND stockmaster.mbflag<>'A'
AND stockmaster.mbflag<>'K'
AND stockmaster.mbflag<>'G'
and stockmaster.discontinued<>1
@@ -961,6 +996,7 @@
INNER JOIN purchdata
ON stockmaster.stockid=purchdata.stockid
WHERE stockmaster.mbflag<>'D'
+ AND stockmaster.mbflag<>'A'
AND stockmaster.mbflag<>'K'
AND stockmaster.mbflag<>'G'
AND purchdata.supplierno='" . $_SESSION['PO'.$identifier]->SupplierID . "'
@@ -974,6 +1010,7 @@
FROM stockmaster INNER JOIN stockcategory
ON stockmaster.categoryid=stockcategory.categoryid
WHERE stockmaster.mbflag<>'D'
+ AND stockmaster.mbflag<>'A'
AND stockmaster.mbflag<>'K'
AND stockmaster.mbflag<>'G'
AND stockmaster.discontinued<>1
@@ -990,6 +1027,7 @@
INNER JOIN purchdata
ON stockmaster.stockid=purchdata.stockid
WHERE stockmaster.mbflag<>'D'
+ AND stockmaster.mbflag<>'A'
AND stockmaster.mbflag<>'K'
AND stockmaster.mbflag<>'G'
AND purchdata.supplierno='" . $_SESSION['PO'.$identifier]->SupplierID . "'
@@ -1004,6 +1042,7 @@
FROM stockmaster INNER JOIN stockcategory
ON stockmaster.categoryid=stockcategory.categoryid
WHERE stockmaster.mbflag<>'D'
+ AND stockmaster.mbflag<>'A'
AND stockmaster.mbflag<>'K'
AND stockmaster.mbflag<>'G'
AND stockmaster.discontinued<>1
Modified: trunk/PurchData.php
===================================================================
--- trunk/PurchData.php 2013-01-23 19:32:03 UTC (rev 5796)
+++ trunk/PurchData.php 2013-01-26 22:31:34 UTC (rev 5797)
@@ -8,33 +8,56 @@
include ('includes/header.inc');
if (isset($_GET['SupplierID'])) {
- $SupplierID = trim(mb_strtoupper($_GET['SupplierID']));
+ $SupplierID = trim(mb_strtoupper($_GET['SupplierID']));
} elseif (isset($_POST['SupplierID'])) {
- $SupplierID = trim(mb_strtoupper($_POST['SupplierID']));
+ $SupplierID = trim(mb_strtoupper($_POST['SupplierID']));
}
if (isset($_GET['StockID'])) {
- $StockID = trim(mb_strtoupper($_GET['StockID']));
+ $StockID = trim(mb_strtoupper($_GET['StockID']));
} elseif (isset($_POST['StockID'])) {
- $StockID = trim(mb_strtoupper($_POST['StockID']));
+ $StockID = trim(mb_strtoupper($_POST['StockID']));
}
+if (isset($_GET['Edit'])) {
+ $Edit = true;
+} elseif (isset($_POST['Edit'])) {
+ $Edit = true;
+} else {
+ $Edit = false;
+}
+
+if (isset($_GET['EffectiveFrom'])) {
+ $EffectiveFrom = $_GET['EffectiveFrom'];
+} elseif ($Edit == true AND isset($_POST['EffectiveFrom'])) {
+ $EffectiveFrom = FormatDateForSQL($_POST['EffectiveFrom']);
+}
+
+
if (isset($_POST['StockUOM'])) {
$StockUOM=$_POST['StockUOM'];
}
+
+/*Deleting a supplier purchasing discount */
+if (isset($_GET['DeleteDiscountID'])){
+ $Result = DB_query("DELETE FROM supplierdiscounts WHERE id='" . intval($_GET['DeleteDiscountID']) . "'", $db);
+ prnMsg(_('Deleted the supplier discount record'),'success');
+}
+
+
$NoPurchasingData=0;
echo '<a href="' . $RootPath . '/SelectProduct.php">' . _('Back to Items') . '</a><br />';
if (isset($_POST['SupplierDescription'])) {
- $_POST['SupplierDescription'] = trim($_POST['SupplierDescription']);
+ $_POST['SupplierDescription'] = trim($_POST['SupplierDescription']);
}
if ((isset($_POST['AddRecord']) OR isset($_POST['UpdateRecord'])) AND isset($SupplierID)) { /*Validate Inputs */
$InputError = 0; /*Start assuming the best */
-if ($StockID == '' OR !isset($StockID)) {
+ if ($StockID == '' OR !isset($StockID)) {
$InputError = 1;
prnMsg(_('There is no stock item set up enter the stock code or select a stock item using the search page'), 'error');
}
@@ -42,8 +65,7 @@
$InputError = 1;
unset($_POST['Price']);
prnMsg(_('The price entered was not numeric and a number is expected. No changes have been made to the database'), 'error');
- }
- if ($_POST['Price'] == 0) {
+ } elseif ($_POST['Price'] == 0) {
prnMsg(_('The price entered is zero') . ' ' . _('Is this intentional?'), 'warn');
}
if (!is_numeric(filter_number_format($_POST['LeadTime']))) {
@@ -61,18 +83,18 @@
unset($_POST['ConversionFactor']);
prnMsg(_('The conversion factor entered was not numeric') . ' (' . _('a number is expected') . '). ' . _('The conversion factor is the number which the price must be divided by to get the unit price in our unit of measure') . '. <br />' . _('E.g.') . ' ' . _('The supplier sells an item by the tonne and we hold stock by the kg') . '. ' . _('The suppliers price must be divided by 1000 to get to our cost per kg') . '. ' . _('The conversion factor to enter is 1000') . '. <br /><br />' . _('No changes will be made to the database'), 'error');
}
- if ($InputError == 0 AND isset($_POST['AddRecord'])) {
- $sql = "INSERT INTO purchdata (supplierno,
- stockid,
- price,
- effectivefrom,
- suppliersuom,
- conversionfactor,
- supplierdescription,
- suppliers_partno,
- leadtime,
- minorderqty,
- preferred)
+ if ($InputError == 0 AND isset($_POST['AddRecord'])) {
+ $sql = "INSERT INTO purchdata (supplierno,
+ stockid,
+ price,
+ effectivefrom,
+ suppliersuom,
+ conversionfactor,
+ supplierdescription,
+ suppliers_partno,
+ leadtime,
+ minorderqty,
+ preferred)
VALUES ('" . $SupplierID . "',
'" . $StockID . "',
'" . filter_number_format($_POST['Price']) . "',
@@ -81,96 +103,166 @@
'" . filter_number_format($_POST['ConversionFactor']) . "',
'" . $_POST['SupplierDescription'] . "',
'" . $_POST['SupplierCode'] . "',
- '" . filter_number_format($_POST['LeadTime']) . "',
- '" . filter_number_format($_POST['MinOrderQty']) . "',
+ '" . filter_number_format($_POST['LeadTime']) . "', '" . filter_number_format($_POST['MinOrderQty']) . "',
'" . $_POST['Preferred'] . "')";
- $ErrMsg = _('The supplier purchasing details could not be added to the database because');
- $DbgMsg = _('The SQL that failed was');
- $AddResult = DB_query($sql, $db, $ErrMsg, $DbgMsg);
- prnMsg(_('This supplier purchasing data has been added to the database'), 'success');
- }
- if ($InputError == 0 AND isset($_POST['UpdateRecord'])) {
- $sql = "UPDATE purchdata SET price='" . filter_number_format($_POST['Price']) . "',
- effectivefrom='" . FormatDateForSQL($_POST['EffectiveFrom']) . "',
- suppliersuom='" . $_POST['SuppliersUOM'] . "',
- conversionfactor='" . filter_number_format($_POST['ConversionFactor']) . "',
- supplierdescription='" . $_POST['SupplierDescription'] . "',
- suppliers_partno='" . $_POST['SupplierCode'] . "',
- leadtime='" . filter_number_format($_POST['LeadTime']) . "',
- minorderqty='" . filter_number_format($_POST['MinOrderQty']) . "',
- preferred='" . $_POST['Preferred'] . "'
- WHERE purchdata.stockid='".$StockID."'
- AND purchdata.supplierno='".$SupplierID."'
- AND purchdata.effectivefrom='" . $_POST['WasEffectiveFrom'] . "'";
- $ErrMsg = _('The supplier purchasing details could not be updated because');
- $DbgMsg = _('The SQL that failed was');
- $UpdResult = DB_query($sql, $db, $ErrMsg, $DbgMsg);
- prnMsg(_('Supplier purchasing data has been updated'), 'success');
- }
- if ($InputError == 0 AND (isset($_POST['UpdateRecord']) OR isset($_POST['AddRecord']))) {
- /*update or insert took place and need to clear the form */
- unset($SupplierID);
- unset($_POST['Price']);
- unset($CurrCode);
- unset($_POST['SuppliersUOM']);
- unset($_POST['EffectiveFrom']);
- unset($_POST['ConversionFactor']);
- unset($_POST['SupplierDescription']);
- unset($_POST['LeadTime']);
- unset($_POST['Preferred']);
- unset($_POST['SupplierCode']);
- unset($_POST['MinOrderQty']);
- unset($SuppName);
- }
+ $ErrMsg = _('The supplier purchasing details could not be added to the database because');
+ $DbgMsg = _('The SQL that failed was');
+ $AddResult = DB_query($sql, $db, $ErrMsg, $DbgMsg);
+ prnMsg(_('This supplier purchasing data has been added to the database'), 'success');
+ }
+ if ($InputError == 0 AND isset($_POST['UpdateRecord'])) {
+ $sql = "UPDATE purchdata SET price='" . filter_number_format($_POST['Price']) . "',
+ effectivefrom='" . FormatDateForSQL($_POST['EffectiveFrom']) . "',
+ suppliersuom='" . $_POST['SuppliersUOM'] . "',
+ conversionfactor='" . filter_number_format($_POST['ConversionFactor']) . "',
+ supplierdescription='" . $_POST['SupplierDescription'] . "',
+ suppliers_partno='" . $_POST['SupplierCode'] . "',
+ leadtime='" . filter_number_format($_POST['LeadTime']) . "',
+ minorderqty='" . filter_number_format($_POST['MinOrderQty']) . "',
+ preferred='" . $_POST['Preferred'] . "'
+ WHERE purchdata.stockid='" . $StockID . "'
+ AND purchdata.supplierno='" . $SupplierID . "'
+ AND purchdata.effectivefrom='" . $_POST['WasEffectiveFrom'] . "'";
+ $ErrMsg = _('The supplier purchasing details could not be updated because');
+ $DbgMsg = _('The SQL that failed was');
+ $UpdResult = DB_query($sql, $db, $ErrMsg, $DbgMsg);
+ prnMsg(_('Supplier purchasing data has been updated'), 'success');
+
+ /*Now need to validate supplier purchasing discount records and update/insert as necessary */
+ $ErrMsg = _('The supplier purchasing discount details could not be updated because');
+ $DiscountInputError = false;
+ for ($i=0;$i<$_POST['NumberOfDiscounts'];$i++) {
+ if (mb_strlen($_POST['DiscountNarrative' . $i])==0 OR $_POST['DiscountNarrative' . $i]==''){
+ prnMsg(_('Supplier discount narrative cannot be empty. No changes will be made to this record'),'error');
+ $DiscountInputError = true;
+ } elseif (filter_number_format($_POST['DiscountPercent' . $i])>100 OR filter_number_format($_POST['DiscountPercent' . $i]) < 0) {
+ prnMsg(_('Supplier discount percent must be greater than zero but less than 100 percent. No changes will be made to this record'),'error');
+ $DiscountInputError = true;
+ } elseif (filter_number_format($_POST['DiscountPercent' . $i])<>0 AND filter_number_format($_POST['DiscountAmount' . $i]) <> 0) {
+ prnMsg(_('Both the supplier discount percent and discount amount are non-zero. Only one or the other can be used. No changes will be made to this record'),'error');
+ $DiscountInputError = true;
+ } elseif (Date1GreaterThanDate2($_POST['DiscountEffectiveFrom' . $i], $_POST['DiscountEffectiveTo' .$i])) {
+ prnMsg(_('The effective to date is prior to the effective from date. No changes will be made to this record'),'error');
+ $DiscountInputError = true;
+ }
+ if ($DiscountInputError == false) {
+ $sql = "UPDATE supplierdiscounts SET discountnarrative ='" . $_POST['DiscountNarrative' . $i] . "',
+ discountamount ='" . filter_number_format($_POST['DiscountAmount' . $i]) . "',
+ discountpercent = '" . filter_number_format($_POST['DiscountPercent' . $i])/100 . "',
+ effectivefrom = '" . FormatDateForSQL($_POST['DiscountEffectiveFrom' . $i]) . "',
+ effectiveto = '" . FormatDateForSQL($_POST['DiscountEffectiveTo' . $i]) . "'
+ WHERE id = " . intval($_POST['DiscountID' . $i]);
+ $UpdResult = DB_query($sql, $db, $ErrMsg, $DbgMsg);
+ }
+ } /*end loop through all supplier discounts */
+
+ /*Now check to see if a new Supplier Discount has been entered */
+ if (mb_strlen($_POST['DiscountNarrative'])==0 OR $_POST['DiscountNarrative']==''){
+ /* A new discount entry has not been entered */
+ } elseif (filter_number_format($_POST['DiscountPercent'])>100 OR filter_number_format($_POST['DiscountPercent']) < 0) {
+ prnMsg(_('Supplier discount percent must be greater than zero but less than 100 percent. This discount record cannot be added.'),'error');
+ } elseif (filter_number_format($_POST['DiscountPercent'])<>0 AND filter_number_format($_POST['DiscountAmount']) <> 0) {
+ prnMsg(_('Both the supplier discount percent and discount amount are non-zero. Only one or the other can be used. This discount record cannot be added.'),'error');
+ } elseif (Date1GreaterThanDate2($_POST['DiscountEffectiveFrom'], $_POST['DiscountEffectiveTo'])) {
+ prnMsg(_('The effective to date is prior to the effective from date. This discount record cannot be added.'),'error');
+ } elseif(filter_number_format($_POST['DiscountPercent'])==0 AND filter_number_format($_POST['DiscountAmount']) ==0) {
+ prnMsg(_('Some supplier discount narrative was entered but both the discount amount and the discount percent are zero. One of these must be none zero to create a valid supplier discount record. The supplier discount record was not added.'),'error');
+ } else {
+ /*It looks like a valid new discount entry has been entered - need to insert it into DB */
+ $sql = "INSERT INTO supplierdiscounts ( supplierno,
+ stockid,
+ discountnarrative,
+ discountamount,
+ discountpercent,
+ effectivefrom,
+ effectiveto )
+ VALUES ('" . $SupplierID . "',
+ '" . $StockID . "',
+ '" . $_POST['DiscountNarrative'] . "',
+ '" . floatval($_POST['DiscountAmount']) . "',
+ '" . floatval($_POST['DiscountPercent'])/100 . "',
+ '" . FormatDateForSQL($_POST['DiscountEffectiveFrom']) . "',
+ '" . FormatDateForSQL($_POST['DiscountEffectiveTo']) . "')";
+ $ErrMsg = _('Could not insert a new supplier discount entry because');
+ $DbgMsg = _('The SQL used to insert the supplier discount entry that failed was');
+ $InsertResult = DB_query($sql, $db, $ErrMsg, $DbgMsg);
+ prnMsg(_('A new supplier purchasing discount record was entered successfully'),'success');
+ }
+
+ }
+
+ if ($InputError == 0 AND isset($_POST['AddRecord'])) {
+ /* insert took place and need to clear the form */
+ unset($SupplierID);
+ unset($_POST['Price']);
+ unset($CurrCode);
+ unset($_POST['SuppliersUOM']);
+ unset($_POST['EffectiveFrom']);
+ unset($_POST['ConversionFactor']);
+ unset($_POST['SupplierDescription']);
+ unset($_POST['LeadTime']);
+ unset($_POST['Preferred']);
+ unset($_POST['SupplierCode']);
+ unset($_POST['MinOrderQty']);
+ unset($SuppName);
+ for ($i=0;$i<$_POST['NumberOfDiscounts'];$i++) {
+ unset($_POST['DiscountNarrative' . $i]);
+ unset($_POST['DiscountAmount' . $i]);
+ unset($_POST['DiscountPercent' . $i]);
+ unset($_POST['DiscountEffectiveFrom' . $i]);
+ unset($_POST['DiscountEffectiveTo' . $i]);
+ }
+ unset($_POST['NumberOfDiscounts']);
+
+ }
}
if (isset($_GET['Delete'])) {
- $sql = "DELETE FROM purchdata
- WHERE purchdata.supplierno='".$SupplierID."'
- AND purchdata.stockid='".$StockID."'
- AND purchdata.effectivefrom='" . $_GET['EffectiveFrom'] . "'";
- $ErrMsg = _('The supplier purchasing details could not be deleted because');
- $DelResult = DB_query($sql, $db, $ErrMsg);
- prnMsg(_('This purchasing data record has been successfully deleted'), 'success');
- unset($SupplierID);
+ $sql = "DELETE FROM purchdata
+ WHERE purchdata.supplierno='" . $SupplierID . "'
+ AND purchdata.stockid='" . $StockID . "'
+ AND purchdata.effectivefrom='" . $EffectiveFrom . "'";
+ $ErrMsg = _('The supplier purchasing details could not be deleted because');
+ $DelResult = DB_query($sql, $db, $ErrMsg);
+ prnMsg(_('This purchasing data record has been successfully deleted'), 'success');
+ unset($SupplierID);
}
-if (!isset($_GET['Edit'])) {
- echo '<p class="page_title_text"><img src="' . $RootPath . '/css/' . $Theme . '/images/maintenance.png" title="' . _('Search') . '" alt="" />' . ' ' . $Title . ' ' . _('For Stock Code') . ' - ' . $StockID . '</p><br />';
- $sql = "SELECT purchdata.supplierno,
- suppliers.suppname,
- purchdata.price,
- suppliers.currcode,
- purchdata.effectivefrom,
- purchdata.suppliersuom,
- purchdata.supplierdescription,
- purchdata.leadtime,
- purchdata.suppliers_partno,
- purchdata.minorderqty,
- purchdata.preferred,
- purchdata.conversionfactor,
- currencies.decimalplaces AS currdecimalplaces
- FROM purchdata
- INNER JOIN suppliers
- ON purchdata.supplierno=suppliers.supplierid
- INNER JOIN currencies
- ON suppliers.currcode=currencies.currabrev
- WHERE purchdata.stockid = '" . $StockID . "'
- ORDER BY supplierno, purchdata.effectivefrom DESC";
- $ErrMsg = _('The supplier purchasing details for the selected part could not be retrieved because');
- $PurchDataResult = DB_query($sql, $db, $ErrMsg);
- if (DB_num_rows($PurchDataResult) == 0 and $StockID != '') {
+
+if ($Edit == false) {
+
+ $ItemResult = DB_query("SELECT description FROM stockmaster WHERE stockid='" . $StockID . "'",$db);
+ $DescriptionRow = DB_fetch_array($ItemResult);
+ echo '<p class="page_title_text"><img src="' . $RootPath . '/css/' . $Theme . '/images/maintenance.png" title="' . _('Search') . '" alt="" />' . ' ' . $Title . ' ' . _('For Stock Code') . ' - ' . $StockID . ' - ' . $DescriptionRow['description'] . '</p><br />';
+
+ $sql = "SELECT purchdata.supplierno,
+ suppliers.suppname,
+ purchdata.price,
+ suppliers.currcode,
+ purchdata.effectivefrom,
+ purchdata.suppliersuom,
+ purchdata.supplierdescription,
+ purchdata.leadtime,
+ purchdata.suppliers_partno,
+ purchdata.minorderqty,
+ purchdata.preferred,
+ purchdata.conversionfactor,
+ currencies.decimalplaces AS currdecimalplaces
+ FROM purchdata INNER JOIN suppliers
+ ON purchdata.supplierno=suppliers.supplierid
+ INNER JOIN currencies
+ ON suppliers.currcode=currencies.currabrev
+ WHERE purchdata.stockid = '" . $StockID . "'
+ ORDER BY purchdata.effectivefrom DESC";
+ $ErrMsg = _('The supplier purchasing details for the selected part could not be retrieved because');
+ $PurchDataResult = DB_query($sql, $db, $ErrMsg);
+ if (DB_num_rows($PurchDataResult) == 0 and $StockID != '') {
prnMsg(_('There is no purchasing data set up for the part selected'), 'info');
- $sql="SELECT stockmaster.decimalplaces
- FROM stockmaster
- WHERE stockmaster.stockid = '" . $StockID . "'";
- $DecimalPlacesResult=DB_query($sql, $db);
- $DecimalPlacesRow=DB_fetch_array($DecimalPlacesResult);
- $StockDecimalPlaces=$DecimalPlacesRow['decimalplaces'];
$NoPurchasingData=1;
- } else if ($StockID != '') {
- echo '<table cellpadding="2" class="selection">';
- $TableHeader = '<tr>
+ } else if ($StockID != '') {
+
+ echo '<table cellpadding="2" class="selection">';
+ $TableHeader = '<tr>
<th>' . _('Supplier') . '</th>
<th>' . _('Price') . '</th>
<th>' . _('Supplier Unit') . '</th>
@@ -198,12 +290,11 @@
if ($myrow['preferred'] == 1) {
$DisplayPreferred = _('Yes');
$CountPreferreds++;
-
- } else {
+ } else {
$DisplayPreferred = _('No');
}
- $UPriceDecimalPlaces = max($myrow['currdecimalplaces'],$_SESSION['StandardCostDecimalPlaces']);
- printf('<td>%s</td>
+ $UPriceDecimalPlaces = max($myrow['currdecimalplaces'],$_SESSION['StandardCostDecimalPlaces']);
+ printf('<td>%s</td>
<td class="number">%s</td>
<td>%s</td>
<td class="number">%s</td>
@@ -213,9 +304,9 @@
<td>%s</td>
<td>%s ' . _('days') . '</td>
<td>%s</td>
- <td><a href="%s?StockID=%s&SupplierID=%s&Edit=1&EffectiveFrom=%s">' . _('Edit') . '</a></td>
- <td><a href="%s?StockID=%s&SupplierID=%s&Copy=1&EffectiveFrom=%s">' . _('Copy') . '</a></td>
- <td><a href="%s?StockID=%s&SupplierID=%s&Delete=1&EffectiveFrom=%s" onclick=\'return confirm("' . _('Are you sure you wish to delete this suppliers price?') . '");\'>' . _('Delete') . '</a></td>
+ <td><a href="%s?StockID=%s&SupplierID=%s&Edit=1&EffectiveFrom=%s">' . _('Edit') . '</a></td>
+ <td><a href="%s?StockID=%s&SupplierID=%s&Copy=1&EffectiveFrom=%s">' . _('Copy') . '</a></td>
+ <td><a href="%s?StockID=%s&SupplierID=%s&Delete=1&EffectiveFrom=%s" onclick=\'return confirm("' . _('Are you sure you wish to delete this suppliers price?') . '");\'>' . _('Delete') . '</a></td>
</tr>',
$myrow['suppname'],
locale_number_format($myrow['price'],$UPriceDecimalPlaces),
@@ -239,77 +330,82 @@
$StockID,
$myrow['supplierno'],
$myrow['effectivefrom']);
- } //end of while loop
- echo '</table><br/>';
- if ($CountPreferreds > 1) {
- prnMsg(_('There are now') . ' ' . $CountPreferreds . ' ' . _('preferred suppliers set up for') . ' ' . $StockID . ' ' . _('you should edit the supplier purchasing data to make only one supplier the preferred supplier'), 'warn');
- } elseif ($CountPreferreds == 0) {
- prnMsg(_('There are NO preferred suppliers set up for') . ' ' . $StockID . ' ' . _('you should make one supplier only the preferred supplier'), 'warn');
- }
- } // end of there are purchsing data rows to show
- echo '<br/>';
+ } //end of while loop
+ echo '</table><br/>';
+ if ($CountPreferreds > 1) {
+ prnMsg(_('There are now') . ' ' . $CountPreferreds . ' ' . _('preferred suppliers set up for') . ' ' . $StockID . ' ' . _('you should edit the supplier purchasing data to make only one supplier the preferred supplier'), 'warn');
+ } elseif ($CountPreferreds == 0) {
+ prnMsg(_('There are NO preferred suppliers set up for') . ' ' . $StockID . ' ' . _('you should make one supplier only the preferred supplier'), 'warn');
+ }
+ } // end of there are purchsing data rows to show
+ echo '<br/>';
} /* Only show the existing purchasing data records if one is not being edited */
-if (isset($SupplierID) AND $SupplierID != '' AND !isset($_POST['SearchSupplier'])) { /*NOT EDITING AN
- EXISTING BUT SUPPLIER selected OR ENTERED*/
- $sql = "SELECT suppliers.suppname,
+if (isset($SupplierID) AND $SupplierID != '' AND !isset($_POST['SearchSupplier'])) {
+ /*NOT EDITING AN EXISTING BUT SUPPLIER selected OR ENTERED*/
+
+ $sql = "SELECT suppliers.suppname,
suppliers.currcode,
currencies.decimalplaces AS currdecimalplaces
FROM suppliers
INNER JOIN currencies
ON suppliers.currcode=currencies.currabrev
WHERE supplierid='".$SupplierID."'";
- $ErrMsg = _('The supplier details for the selected supplier could not be retrieved because');
- $DbgMsg = _('The SQL that failed was');
- $SuppSelResult = DB_query($sql, $db, $ErrMsg, $DbgMsg);
- if (DB_num_rows($SuppSelResult) == 1) {
- $myrow = DB_fetch_array($SuppSelResult);
- $SuppName = $myrow['suppname'];
- $CurrCode = $myrow['currcode'];
- $CurrDecimalPlaces = $myrow['currdecimalplaces'];
- } else {
- prnMsg(_('The supplier code') . ' ' . $SupplierID . ' ' . _('is not an existing supplier in the database') . '. ' . _('You must enter an alternative supplier code or select a supplier using the search facility below'), 'error');
- unset($SupplierID);
- }
+ $ErrMsg = _('The supplier details for the selected supplier could not be retrieved because');
+ $DbgMsg = _('The SQL that failed was');
+ $SuppSelResult = DB_query($sql, $db, $ErrMsg, $DbgMsg);
+ if (DB_num_rows($SuppSelResult) == 1) {
+ $myrow = DB_fetch_array($SuppSelResult);
+ $SuppName = $myrow['suppname'];
+ $CurrCode = $myrow['currcode'];
+ $CurrDecimalPlaces = $myrow['currdecimalplaces'];
+ } else {
+ prnMsg(_('The supplier code') . ' ' . $SupplierID . ' ' . _('is not an existing supplier in the database') . '. ' . _('You must enter an alternative supplier code or select a supplier using the search facility below'), 'error');
+ unset($SupplierID);
+ }
} else {
if ($NoPurchasingData==0) {
echo '<p class="page_title_text"><img src="' . $RootPath . '/css/' . $Theme . '/images/maintenance.png" title="' . _('Search') . '" alt="" />' . ' ' . $Title . ' ' . _('For Stock Code') . ' - ' . $StockID . '</p><br />';
}
- if (!isset($_POST['SearchSupplier'])) {
- echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF']) . '" method="post">
+ if (!isset($_POST['SearchSupplier'])) {
+ echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">
<table cellpadding="3" colspan="4" class="selection">
- <tr>';
- echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
- echo '<input type="hidden" name="StockID" value="' . $StockID . '" />';
- echo '<td>' . _('Text in the Supplier') . ' <b>' . _('NAME') . '</b>:</td>';
- echo '<td><input type="text" name="Keywords" size="20" maxlength="25" /></td>';
- echo '<td><b>' . _('OR') . '</b></td>';
- echo '<td>' . _('Text in Supplier') . ' <b>' . _('CODE') . '</b>:</td>';
- echo '<td><input type="text" name="SupplierCode" size="20" maxlength="50" /></td>';
- echo '</tr></table><br />';
- echo '<div class="centre">
- <input type="submit" name="SearchSupplier" value="' . _('Find Suppliers Now') . '" />
- </div>
+ <tr>
+ <input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />
+ <input type="hidden" name="StockID" value="' . $StockID . '" />
+ <td>' . _('Text in the Supplier') . ' <b>' . _('NAME') . '</b>:</td>
+ <td><input type="text" name="Keywords" size="20" maxlength="25" /></td>
+ <td><b>' . _('OR') . '</b></td>
+ <td>' . _('Text in Supplier') . ' <b>' . _('CODE') . '</b>:</td>
+ <td><input type="text" name="SupplierCode" size="20" maxlength="50" /></td>
+ </tr>
+ </table>
+ <br />
+ <div class="centre">
+ <input type="submit" name="SearchSupplier" value="' . _('Find Suppliers Now') . '" />
+ </div>
</form>';
- include ('includes/footer.inc');
- exit;
- };
+ include ('includes/footer.inc');
+ exit;
+ };
}
-if (isset($_GET['Edit'])) {
- echo '<p class="page_title_text"><img src="' . $RootPath . '/css/' . $Theme . '/images/maintenance.png" title="' . _('Search') . '" alt="" />' . ' ' . $Title . ' ' . _('For Stock Code') . ' - ' . $StockID . '</p><br />';
+if ($Edit == true) {
+ $ItemResult = DB_query("SELECT description FROM stockmaster WHERE stockid='" . $StockID . "'",$db);
+ $DescriptionRow = DB_fetch_array($ItemResult);
+ echo '<p class="page_title_text"><img src="' . $RootPath . '/css/' . $Theme . '/images/maintenance.png" title="' . _('Search') . '" alt="" />' . ' ' . $Title . ' ' . _('For Stock Code') . ' - ' . $StockID . ' - ' . $DescriptionRow['description'] . '</p><br />';
}
if (isset($_POST['SearchSupplier'])) {
- if (isset($_POST['Keywords']) AND isset($_POST['SupplierCode'])) {
- prnMsg( _('Supplier Name keywords have been used in preference to the Supplier Code extract entered') . '.', 'info' );
- echo '<br />';
- }
- if ($_POST['Keywords'] == '' AND $_POST['SupplierCode'] == '') {
- $_POST['Keywords'] = ' ';
- }
- if (mb_strlen($_POST['Keywords']) > 0) {
- //insert wildcard characters in spaces
+ if (isset($_POST['Keywords']) AND isset($_POST['SupplierCode'])) {
+ prnMsg( _('Supplier Name keywords have been used in preference to the Supplier Code extract entered') . '.', 'info' );
+ echo '<br />';
+ }
+ if ($_POST['Keywords'] == '' AND $_POST['SupplierCode'] == '') {
+ $_POST['Keywords'] = ' ';
+ }
+ if (mb_strlen($_POST['Keywords']) > 0) {
+ //insert wildcard characters in spaces
$SearchString = '%' . str_replace(' ', '%', $_POST['Keywords']) . '%';
$SQL = "SELECT suppliers.supplierid,
@@ -321,8 +417,8 @@
FROM suppliers
WHERE suppliers.suppname " . LIKE . " '".$SearchString."'";
- } elseif (mb_strlen($_POST['SupplierCode']) > 0) {
- $SQL = "SELECT suppliers.supplierid,
+ } elseif (mb_strlen($_POST['SupplierCode']) > 0) {
+ $SQL = "SELECT suppliers.supplierid,
suppliers.suppname,
suppliers.currcode,
suppliers.address1,
@@ -331,15 +427,15 @@
FROM suppliers
WHERE suppliers.supplierid " . LIKE . " '%" . $_POST['SupplierCode'] . "%'";
- } //one of keywords or SupplierCode was more than a zero length string
- $ErrMsg = _('The suppliers matching the criteria entered could not be retrieved because');
- $DbgMsg = _('The SQL to retrieve supplier details that failed was');
- $SuppliersResult = DB_query($SQL, $db, $Er...
[truncated message content] |