1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<?php //item details for adding item to BOM
require_once "inc/configure.php";
$params = array();
if ($_REQUEST['custcode'] != '') { $custcode = $_REQUEST['custcode']; }
if ($_REQUEST['bomcategy'] == 'services') { $cat = 'service'; } else { $cat = $_REQUEST['bomcategy']; }
$previousItemSelect = isset($_REQUEST['previous_item_select']) ? $_REQUEST['previous_item_select'] : '';
if ($cat == 'product') { $sql = "SELECT * from inv_$cat WHERE verified='1'";
if (!empty($custcode) && $cat == 'product') { $sql .= " AND custcode = :custcode"; $params[':custcode'] = $custcode; } $sql .= " ORDER BY itemno"; } else {
$sql = " SELECT inv.itemno, inv.name_en FROM inv_$cat AS inv INNER JOIN ord_dtl_rm AS dtl ON inv.itemno = dtl.itemno INNER JOIN ord_main AS main ON dtl.main_refid = main.refid WHERE inv.verified = '1' ";
if (!empty($custcode)) { $sql .= " AND main.custcode = :custcode"; $params[':custcode'] = $custcode; }
$sql .= " GROUP BY inv.itemno, inv.name_en"; }
$sth = $dbh->prepare($sql); $sth->execute($params);
echo '<option value="">Select Item</option>';
while ($row = $sth->fetch()) { $selected = $row['itemno'] == $previousItemSelect ? 'selected' : ''; echo '<option value="' . $row['itemno'] . '" ' . $selected . '>' . $row['itemno'] . " - " . $row['name_en'] . '</option>'; } unset($sth);
|