1<?php
2
3include('includes/session.php');
4$Title=_('Reprint a GRN');
5include('includes/header.php');
6
7echo '<p class="page_title_text"><img src="'.$RootPath.'/css/'.$Theme.'/images/supplier.png" title="' . $Title . '" alt="" />' . ' ' . $Title . '</p>';
8
9if (!isset($_POST['PONumber'])) {
10	$_POST['PONumber']='';
11}
12
13echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '" method="post">';
14echo '<div>';
15echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
16echo '<table class="selection">
17		<tr>
18			<th colspan="2"><h3>' . _('Select a purchase order') . '</h3></th>
19		</tr>
20		<tr>
21			<td>' . _('Enter a Purchase Order Number') . '</td>
22			<td>' . '<input type="text" name="PONumber" class="number" size="7" value="'.$_POST['PONumber'].'" /></td>
23		</tr>
24		<tr>
25			<td colspan="2" class="centre"><input type="submit" name="Show" value="' . _('Show GRNs') . '" /></td>
26		</tr>
27	</table>
28    <br />
29    </div>
30	</form>';
31
32if (isset($_POST['Show'])) {
33	if ($_POST['PONumber']=='') {
34		echo '<br />';
35		prnMsg( _('You must enter a purchase order number in the box above'), 'warn');
36		include('includes/footer.php');
37		exit;
38	}
39	$sql="SELECT count(orderno)
40				FROM purchorders
41				WHERE orderno='" . $_POST['PONumber'] ."'";
42	$result=DB_query($sql);
43	$myrow=DB_fetch_row($result);
44	if ($myrow[0]==0) {
45		echo '<br />';
46		prnMsg( _('This purchase order does not exist on the system. Please try again.'), 'warn');
47		include('includes/footer.php');
48		exit;
49	}
50	$sql="SELECT grnbatch,
51				grns.grnno,
52				grns.podetailitem,
53				grns.itemcode,
54				grns.itemdescription,
55				grns.deliverydate,
56				grns.qtyrecd,
57				suppinvstogrn.suppinv,
58				suppliers.suppname,
59				stockmaster.decimalplaces
60			FROM grns INNER JOIN suppliers
61			ON grns.supplierid=suppliers.supplierid
62			LEFT JOIN suppinvstogrn ON grns.grnno=suppinvstogrn.grnno
63			INNER JOIN purchorderdetails
64			ON grns.podetailitem=purchorderdetails.podetailitem
65			INNER JOIN purchorders on purchorders.orderno=purchorderdetails.orderno
66			INNER JOIN locationusers ON locationusers.loccode=purchorders.intostocklocation AND locationusers.userid='" .  $_SESSION['UserID'] . "' AND locationusers.canview=1
67			LEFT JOIN stockmaster
68			ON grns.itemcode=stockmaster.stockid
69			WHERE purchorderdetails.orderno='" . $_POST['PONumber'] ."'";
70	$result=DB_query($sql);
71	if (DB_num_rows($result)==0) {
72		echo '<br />';
73		prnMsg( _('There are no GRNs for this purchase order that can be reprinted.'), 'warn');
74		include('includes/footer.php');
75		exit;
76	}
77
78	echo '<br />
79			<table class="selection">
80			<tr>
81				<th colspan="8"><h3>' . _('GRNs for Purchase Order No') .' ' . $_POST['PONumber'] . '</h3></th>
82			</tr>
83			<tr>
84				<th>' . _('Supplier') . '</th>
85				<th>' . _('PO Order line') . '</th>
86				<th>' . _('GRN Number') . '</th>
87				<th>' . _('Item Code') . '</th>
88				<th>' . _('Item Description') . '</th>
89				<th>' . _('Delivery Date') . '</th>
90				<th>' . _('Quantity Received') . '</th>
91				<th>' . _('Invoice No') . '</th>
92				<th>' . _('Action') . '</th>
93			</tr>';
94
95	while ($myrow=DB_fetch_array($result)) {
96		echo '<tr class="striped_row">
97			<td>' . $myrow['suppname'] . '</td>
98			<td class="number">' . $myrow['podetailitem'] . '</td>
99			<td class="number">' . $myrow['grnbatch'] . '</td>
100			<td>' . $myrow['itemcode'] . '</td>
101			<td>' . $myrow['itemdescription'] . '</td>
102			<td>' . $myrow['deliverydate'] . '</td>
103			<td class="number">' . locale_number_format($myrow['qtyrecd'], $myrow['decimalplaces']) . '</td>
104			<td>' . $myrow['suppinv'] . '</td>
105			<td><a href="PDFGrn.php?GRNNo=' . $myrow['grnbatch'] .'&PONo=' . $_POST['PONumber'] . '">' . _('Reprint GRN ') . '</a>
106			&nbsp;<a href="PDFQALabel.php?GRNNo=' . $myrow['grnbatch'] .'&PONo=' . $_POST['PONumber'] . '">' . _('Reprint Labels') . '</a></td>
107		</tr>';
108	}
109	echo '</table>';
110}
111
112include('includes/footer.php');
113
114?>
115