-
Notifications
You must be signed in to change notification settings - Fork 0
/
items.php
executable file
·65 lines (52 loc) · 1.92 KB
/
items.php
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
<?php
/*
Popualte item and supplier list from databse. May show errors and info to user.
*/
# Redirect if User has invalid approval level
if($_SESSION['approval_level'] != 0) {
header('Location: index.php');
}
# Initialize variables
$error = '';
$info = '';
$list_suppliers = Array('Please Select');
$list_items = Array();
$forward_list = Array('Please Select');
require('connect.php');
if(!$conn) { # Unable to connect
$error = 'Unable to connect to database. Please try again in some time.';
} else { # Connection successful
# Getting supplier list
$raw_sql_suppliers = 'select SUPP_ID, SUPP_NAME from can_supplier_mast'; # SQL query
$result_suppliers = odbc_exec($conn, $raw_sql_suppliers); # Execute
# Put results in the string
while(odbc_fetch_row($result_suppliers)) {
$supplier_id = odbc_result($result_suppliers, 1);
$supplier_name = odbc_result($result_suppliers, 2);
$supplier = $supplier_name." - ".$supplier_id;
array_push($list_suppliers, $supplier);
}
# Getting item list
$raw_sql_items = 'select ITEM_ID, ITEM_NAME from can_item_mast'; # SQL query
$result_items = odbc_exec($conn, $raw_sql_items); # Execute
# Put results in string
while(odbc_fetch_row($result_items)) {
$item_id = odbc_result($result_items, 1);
$item_name = odbc_result($result_items, 2);
$item = $item_name." - ".$item_id;
array_push($list_items, $item);
}
# Getting forward list
$raw_sql_forward = 'select user_id, user_name from can_user_mast where approval_level=1'; # SQL query
$result_forward = odbc_exec($conn, $raw_sql_forward); # Execute
# Append to forward list
while(odbc_fetch_row($result_forward)) {
$user_id = odbc_result($result_forward, 1);
$user_name = odbc_result($result_forward, 2);
$user = $user_name." - ".$user_id;
array_push($forward_list, $user);
}
# Close connection
odbc_close($conn);
}
?>