-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload_bag.php
54 lines (45 loc) · 1.21 KB
/
load_bag.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
<pre>
<?php
include_once('include/config.inc.php');
include_once('library/mysql.lib.php');
include_once('library/inventory.lib.php');
include_once('library/bag.lib.php');
include_once('library/util.lib.php');
sql_wrap();
global $bagid;
$row = 1;
if (($handle = fopen("bagdb.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
// Skip blank rows
if($data[0] == '') continue;
// Get title from CSV and Create Bag
if($row == 3) {
$name = $data[0];
echo "Create Bag: " . $name."<br/>";
$bagid = create_bag($name);
if(!$bagid) {
$bag = get_bag_by_name($name);
$bagid = $bag['bagid'];
}
}
// Skip Title Row
if($row < 4) continue;
// Add Product to Bag (Create or Find Existing Product from inventory)
import_bag_content(
$bagid,
$data[0],
$data[2],
$data[3]);
echo "Product: " . $data[0] . " | Quantity: " . $data[2] . " | Notes: " . $data[3] . "<br/>";
/*
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />\n";
}*/
}
fclose($handle);
}
?>
</pre>