Skip to content

Commit

Permalink
30/10/15 Exson: Allow user input supplier's delivery note during good…
Browse files Browse the repository at this point in the history
…s receiving and make the inquiry script for it. So users can search corresponding GRN, PO and invoice with it.

git-svn-id: http://svn.code.sf.net/p/web-erp/code/trunk@7373 09516a42-71f9-43be-811f-9b821cf0d246
  • Loading branch information
exsonqu committed Oct 30, 2015
1 parent f645f79 commit 8df6548
Show file tree
Hide file tree
Showing 11 changed files with 190 additions and 17 deletions.
42 changes: 37 additions & 5 deletions GoodsReceived.php
Expand Up @@ -71,21 +71,40 @@

echo '<p class="page_title_text">
<img src="'.$RootPath.'/css/'.$Theme.'/images/supplier.png" title="' . _('Receive') . '" alt="" />' . ' ' . _('Receive Purchase Order') . ' : '. $_SESSION['PO'.$identifier]->OrderNo .' '. _('from'). ' ' . $_SESSION['PO'.$identifier]->SupplierName . '</p>';
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?identifier=' . $identifier . '" method="post">';
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?identifier=' . $identifier . '" id="form1" method="post">';
echo '<div>';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';

if (!isset($_POST['ProcessGoodsReceived'])) {
if (!isset($_POST['DefaultReceivedDate'])){
if (!isset($_POST['DefaultReceivedDate']) AND !isset($_SESSION['PO' . $identifier]->DefaultReceivedDate)){
/* This is meant to be the date the goods are received - it does not make sense to set this to the date that we requested delivery in the purchase order - I have not applied your change here Tim for this reason - let me know if I have it wrong - Phil */
$_POST['DefaultReceivedDate'] = Date($_SESSION['DefaultDateFormat']);
$_SESSION['PO' . $identifier]->DefaultReceivedDate = $_POST['DefaultReceivedDate'];
} else {
if (isset($_POST['DefaultReceivedDate']) AND is_date($_POST['DefaultReceivedDate'])) {
$_SESSION['PO' . $identifier]->DefaultReceivedDate = $_POST['DefaultReceivedDate'];
} elseif(isset($_POST['DefaultReceivedDate']) AND !is_date($_POST['DefaultReceivedDate'])) {
prnMsg(_('The default received date is not a date format'),'error');
$_POST['DefaultReceivedDate'] = Date($_SESSION['DefaultDateFormat']);
}
}
if (!isset($_POST['SupplierReference'])) {
$_POST['SupplierReference'] = '';
} else {
if (isset($_POST['SupplierReference']) AND mb_strlen(trim($_POST['SupplierReference']))>30) {
prnMsg(_('The supplier\'s delivery note no should not be more than 30 characters'),'error');
} else {
$_SESSION['PO' . $identifier]->SupplierReference = $_POST['SupplierReference'];
}
}

echo '<table class="selection">
<tr>
<td>' . _('Date Goods/Service Received'). ':</td>
<td><input type="text" class="date" alt="'. $_SESSION['DefaultDateFormat'] .'" maxlength="10" size="10" onchange="return isDate(this, this.value, '."'".
$_SESSION['DefaultDateFormat']."'".')" name="DefaultReceivedDate" value="' . $_POST['DefaultReceivedDate'] . '" /></td>
$_SESSION['DefaultDateFormat']."'".')" name="DefaultReceivedDate" value="' . $_SESSION['PO' . $identifier]->DefaultReceivedDate . '" /></td>
<td>' . _("Supplier's Reference") . ':</td>
<td><input type="text" name="SupplierReference" value="' . $_SESSION['PO' . $identifier]->SupplierReference. '" maxlength="30" size="20" onchange="ReloadForm(form1.Update)"/></td>
</tr>
</table>
<br />';
Expand Down Expand Up @@ -228,6 +247,17 @@
$NegativesFound = false;
$InputError = false;

if (isset($_POST['DefaultReceivedDate']) AND !is_date($_POST['DefaultReceivedDate'])) {
$InputError = true;
prnMsg(_('The goods received date is not a date format'),'error');

} else {
}

if (isset($_POST['SupplierReference']) AND mb_strlen(trim($_POST['SupplierReference']))>30) {
$InputError = true;
prnMsg(_('The delivery note of suppliers should not be more than 30 characters'),'error');
}
if (count($_SESSION['PO'.$identifier]->LineItems)>0){

foreach ($_SESSION['PO'.$identifier]->LineItems as $OrderLine) {
Expand Down Expand Up @@ -474,15 +504,17 @@
deliverydate,
qtyrecd,
supplierid,
stdcostunit)
stdcostunit,
supplierref)
VALUES ('" . $GRN . "',
'" . $OrderLine->PODetailRec . "',
'" . $OrderLine->StockID . "',
'" . DB_escape_string($OrderLine->ItemDescription) . "',
'" . $_POST['DefaultReceivedDate'] . "',
'" . $OrderLine->ReceiveQty . "',
'" . $_SESSION['PO'.$identifier]->SupplierID . "',
'" . $CurrentStandardCost . "')";
'" . $CurrentStandardCost . "',
'" . trim($_POST['SupplierReference']) ."')";

$ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('A GRN record could not be inserted') . '. ' . _('This receipt of goods has not been processed because');
$DbgMsg = _('The following SQL to insert the GRN record was used');
Expand Down
4 changes: 4 additions & 0 deletions PDFGrn.php
Expand Up @@ -46,6 +46,7 @@
grns.itemdescription,
grns.qtyrecd,
grns.supplierid,
grns.supplierref,
purchorderdetails.suppliersunit,
purchorderdetails.conversionfactor,
stockmaster.units,
Expand Down Expand Up @@ -77,6 +78,9 @@
}
} // get data to print
if ($NoOfGRNs >0){
$SupplierRef = DB_fetch_array($GRNResult);
$SupplierRef = $SupplierRef['supplierref'];
DB_data_seek($GRNResult,0);
include ('includes/PDFGrnHeader.inc'); //head up the page

$FooterPrintedInPage= 0;
Expand Down
5 changes: 5 additions & 0 deletions ReverseGRN.php
Expand Up @@ -39,6 +39,7 @@
grns.itemcode,
grns.itemdescription,
grns.deliverydate,
grns.supplierref,
purchorderdetails.glcode,
purchorderdetails.assetid,
grns.qtyrecd,
Expand Down Expand Up @@ -370,6 +371,7 @@
grns.itemcode,
grns.itemdescription,
grns.deliverydate,
grns.supplierref,
qtyrecd,
quantityinv,
qtyrecd-quantityinv AS qtytoreverse
Expand All @@ -393,6 +395,7 @@
$TableHeader = '<tr>
<th>' . _('GRN') . ' #</th>
<th>' . _('GRN Batch') . '</th>
<th>' . _('Supplier\' Ref') . '</th>
<th>' . _('Item Code') . '</th>
<th>' . _('Description') . '</th>
<th>' . _('Date') . '<br />' . _('Received') . '</th>
Expand Down Expand Up @@ -426,13 +429,15 @@
<td>%s</td>
<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>%s</td>
</tr>',
$myrow['grnno'],
$myrow['grnbatch'],
$myrow['supplierref'],
$myrow['itemcode'],
$myrow['itemdescription'],
$DisplayDateDel,
Expand Down
2 changes: 2 additions & 0 deletions SelectSupplier.php
Expand Up @@ -169,6 +169,8 @@
</tr>';
echo '<tr><td valign="top" class="select">'; /* Inquiry Options */
echo '<a href="' . $RootPath . '/SupplierInquiry.php?SupplierID=' . $_SESSION['SupplierID'] . '">' . _('Supplier Account Inquiry') . '</a>
<br />
<a href="' . $RootPath . '/SupplierGRNAndInvoiceInquiry.php?SelectedSupplier=' . $_SESSION['SupplierID'] . '&amp;SupplierName='.urlencode($SupplierName).'">' . _('Supplier Delivery Note AND GRN inquiry') . '</a>
<br />
<br />';

Expand Down
11 changes: 9 additions & 2 deletions SuppInvGRNs.php
Expand Up @@ -95,7 +95,8 @@
$_SESSION['SuppTrans']->GRNs[$_POST['GRNNo'.$i]]->ShiptRef,
$_SESSION['SuppTrans']->GRNs[$_POST['GRNNo'.$i]]->JobRef,
$_SESSION['SuppTrans']->GRNs[$_POST['GRNNo'.$i]]->GLCode,
$Hold);
$Hold,
$_SESSION['SuppTrans']->GRNs[$_POST['GRNNo'.$i]]->SupplierRef);
}
}
}
Expand All @@ -116,6 +117,7 @@
</tr>
<tr>
<th>' . _('Sequence') . ' #</th>
<th>' . _("Supplier's Ref") . '</th>
<th>' . _('Item Code') . '</th>
<th>' . _('Description') . '</th>
<th>' . _('Quantity Yet To Inv') . '</th>
Expand All @@ -137,6 +139,7 @@

echo '<tr>
<td>' . $EnteredGRN->GRNNo . '</td>
<td>' . $EnteredGRN->SupplierRef . '</td>
<td>' . $EnteredGRN->ItemCode . '</td>
<td>' . $EnteredGRN->ItemDescription . '</td>
<td class="number">' . locale_number_format($EnteredGRN->QtyRecd - $EnteredGRN->Prev_QuantityInv,'Variable') . '</td>
Expand Down Expand Up @@ -177,6 +180,7 @@
grns.qtyrecd,
grns.quantityinv,
grns.stdcostunit,
grns.supplierref,
purchorderdetails.glcode,
purchorderdetails.shiptref,
purchorderdetails.jobref,
Expand Down Expand Up @@ -235,7 +239,8 @@
$myrow['assetid'],
0,
$myrow['decimalplaces'],
$myrow['grnbatch']);
$myrow['grnbatch'],
$myrow['supplierref']);
}
}
}
Expand All @@ -253,6 +258,7 @@
<th class="ascending">' . _('Select') . '</th>
<th class="ascending">' . _('Sequence') . ' #</th>
<th class="ascending">' . _('GRN Number') . '</th>
<th class="ascending">' . _('Supplier\'s Ref') . '</th>
<th class="ascending">' . _('Order') . '</th>
<th class="ascending">' . _('Item Code') . '</th>
<th class="ascending">' . _('Description') . '</th>
Expand Down Expand Up @@ -285,6 +291,7 @@
}
echo '<td>' . $GRNTmp->GRNNo . '</td>
<td>' . $GRNTmp->GRNBatchNo . '</td>
<td>' . $GRNTmp->SupplierRef . '</td>
<td>' . $GRNTmp->PONo . '</td>
<td>' . $GRNTmp->ItemCode . '</td>
<td>' . $GRNTmp->ItemDescription . '</td>
Expand Down
97 changes: 97 additions & 0 deletions SupplierGRNAndInvoiceInquiry.php
@@ -0,0 +1,97 @@
<?php
include('includes/session.inc');
$Title = _('Supplier Invoice and GRN inquiry');
include('includes/header.inc');
if (isset($_GET['SelectedSupplier'])) {
$SupplierID= $_GET['SelectedSupplier'];
} elseif (isset($_POST['SelectedSupplier'])){
$SupplierID = $_POST['SelectedSupplier'];
} else {
prnMsg(_('The page must be called from suppliers selected interface, please click following link to select the supplier'),'error');
echo '<a href="' . $RootPath . '/SelectSupplier.php">'. _('Select Supplier') . '</a>';
include('includes/footer.inc');
exit;
}
if (isset($_GET['SupplierName'])) {
$SupplierName = $_GET['SupplierName'];
}
if (!isset($_POST['SupplierRef']) OR trim($_POST['SupplierRef'])=='') {
$_POST['SupplierRef'] = '';
if (empty($_POST['GRNBatchNo']) AND empty($_POST['InvoiceNo'])) {
$_POST['GRNBatchNo'] = '';
$_POST['InvoiceNo'] = '';
} elseif (!empty($_POST['GRNBatchNo']) AND !empty($_POST['InvoiceNo'])) {
$_POST['InvoiceNo'] = '';
}
} elseif (isset($_POST['GRNBatchNo']) OR isset($_POST['InvoiceNo'])) {
$_POST['GRNBatchNo'] = '';
$_POST['InvoiceNo'] = '';
}
echo '<p class="page_title_text">' . _('Supplier Invoice and Delivery Note Inquiry') . '<img src="' . $RootPath . '/css/' . $Theme . '/images/transactions.png" alt="" />' . _('Supplier') . ': ' . $SupplierName . '</p>';
echo '<div class="page_help_text">' . _('The supplier\'s delivery note is prefer to GRN No, and GRN No is prefered to Invoice No').'</div>';
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">
<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />
<input type="hidden" name="SelectedSupplier" value="' . $SupplierID . '" />';

echo '<table class="selection">
<tr>
<td class="label">' . _('Part of Supplier\'s Delivery Note') . ':</td><td><input type="text" name="SupplierRef" value="' . $_POST['SupplierRef'] . '" size="20" maxlength="30" ></td>
<td class="label">' . _('GRN No') . ':</td><td><input type="text" name="GRNBatchNo" value="' . $_POST['GRNBatchNo'] . '" size="6" maxlength="6" /></td>
<td class="label">' . _('Invoice No') . ':</td><td><input type="text" name="InvoiceNo" value="' . $_POST['InvoiceNo'] . '" size="11" maxlength="11" /></td>
</tr>
</table>';
echo '<div class="center">
<input type="submit" name="Submit" value="' . _('Submit') . '" />
</div>';
if (isset($_POST['Submit'])) {
$Where = '';
if (isset($_POST['SupplierRef']) AND trim($_POST['SupplierRef']) != '') {
$SupplierRef = trim($_POST['SupplierRef']);
$WhereSupplierRef = " AND grns.supplierref LIKE '%" . $SupplierRef . "%'";
$Where .= $WhereSupplierRef;
} elseif (isset($_POST['GRNBatchNo']) AND trim($_POST['GRNBatchNo']) != '') {
$GRNBatchNo = trim($_POST['GRNBatchNo']);
$WhereGRN = " AND grnbatch LIKE '%" . $GRNBatchNo . "%'";
$Where .= $WhereGRN;
} elseif (isset($_POST['InvoiceNo']) AND (trim($_POST['InvoiceNo']) != '')) {
$InvoiceNo = trim($_POST['InvoiceNo']);
$WhereInvoiceNo = " AND suppinv LIKE '%" . $InvoiceNo . "%'";
$Where .= $WhereInvoiceNo;
}
$sql = "SELECT grnbatch, grns.supplierref, suppinv,purchorderdetails.orderno
FROM grns INNER JOIN purchorderdetails ON grns.podetailitem=purchorderdetails.podetailitem
LEFT JOIN suppinvstogrn ON grns.grnno=suppinvstogrn.grnno
WHERE supplierid='" . $SupplierID . "'" . $Where;
$ErrMsg = _('Failed to retrieve supplier invoice and grn data');
$result = DB_query($sql,$ErrMsg);
if (DB_num_rows($result)>0) {
echo '<table class="selection">
<tr>
<th>' . _('Supplier Delivery Note') . '</th>
<th>' . _('GRN Batch No') . '</th>
<th>' . _('PO No') . '</th>
<th>' . _('Invoice No') . '</th>
</tr>';
$k = 0;
while ($myrow = DB_fetch_array($result)){
if ($k == 0) {
echo '<tr class="EvenTableRows">';
$k = 1;
} else{
echo '<tr class="OddTableRows">';
$k = 0;
}
echo '<td class="ascending">' . $myrow['supplierref'] . '</td>
<td class="ascending"><a href="' . $RootPath .'/PDFGrn.php?GRNNo=' . $myrow['grnbatch'] . '&amp;PONo=' . $myrow['orderno'] . '">' . $myrow['grnbatch']. '</td>
<td class="ascending">' . $myrow['orderno'] . '</td>
<td class="ascending">' . $myrow['suppinv'] . '</td></tr>';

}
echo '</table><br/>';

}

}
include('includes/footer.inc');
?>
7 changes: 6 additions & 1 deletion SupplierInvoice.php
Expand Up @@ -662,6 +662,8 @@
</tr>';
$tableheader = '<tr style="background-color:#800000">
<th>' . _('Seq') . ' #</th>
<th>' . _('GRN Batch') . '</th>
<th>' . _('Supplier Ref') . '</th>
<th>' . _('Item Code') . '</th>
<th>' . _('Description') . '</th>
<th>' . _('Quantity Charged') . '</th>
Expand All @@ -674,6 +676,8 @@

echo '<tr>
<td>' . $EnteredGRN->GRNNo . '</td>
<td>' . $EnteredGRN->GRNBatchNo . '</td>
<td>' . $EnteredGRN->SupplierRef . '</td>
<td>' . $EnteredGRN->ItemCode . '</td>
<td>' . $EnteredGRN->ItemDescription . '</td>
<td class="number">' . locale_number_format($EnteredGRN->This_QuantityInv,$EnteredGRN->DecimalPlaces) . '</td>
Expand Down Expand Up @@ -1547,7 +1551,8 @@
$Result = DB_query($SQL, $ErrMsg, $DbgMsg, True);

$SQL = "INSERT INTO suppinvstogrn VALUES ('" . $InvoiceNo . "',
'" .$EnteredGRN->GRNNo . "')";
'" . $EnteredGRN->GRNNo . "',
'" . $EnteredGRN->SupplierRef . "')";
$ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The invoice could not be mapped to the
goods received record because');
$DbgMsg = _('The following SQL to map the invoice to the GRN was used');
Expand Down
7 changes: 6 additions & 1 deletion companies/weberpdemo/FormDesigns/GoodsReceived.xml
Expand Up @@ -53,10 +53,15 @@
<x>625</x>
<y>48</y>
</GRNNumber>
<SupplierRef type="SimpleText" name="Supplier's Ref" id="SupplierRef">
<FontSize>10</FontSize>
<x>625</x>
<y>60</y>
</SupplierRef>
<OrderNumber type="SimpleText" name="Order Number" id="OrderNumber">
<FontSize>10</FontSize>
<x>625</x>
<y>66</y>
<y>72</y>
</OrderNumber>
<PrintDate type="SimpleText" name="Date Printed" id="PrintDate">
<FontSize>10</FontSize>
Expand Down

0 comments on commit 8df6548

Please sign in to comment.