Project

General

Profile

Statistics
| Branch: | Revision:

root / docs / www / colonyscout / internal / inventory_add_csv.php @ f59acf11

History | View | Annotate | Download (1.32 KB)

1
<?php
2

    
3
include_once(getenv("DOCUMENT_ROOT")."/internal/do_login.php");
4
include_once("inventoryFunctions.php");
5
doDB("colony_scout");
6

    
7
//temp script to parse output from the unified EE BOM (ONLY)
8

    
9
$row = 1;
10
if (($handle = fopen("eeBOM.csv", "r")) !== FALSE) {
11
    while (($d= fgetcsv($handle, 1000, ",")) !== FALSE) {
12
        
13
                $vendorID = getVendorID($d[5]);
14
                if($vendorID==-1) {
15
                        $vendorID = getVendorID("Unknown"); //placeholder
16
                }
17
                
18
                for ($c=11; $c < 16; $c++) {
19
            if($d[$c]==""){
20
                                $d[$c]=0;
21
                        }
22
        }
23
                
24
                $add_item_sql = "INSERT INTO inventory (name,manufacturername,manufacturerpartno,dateadded,active,
25
                tags,qty,vendorid,vendorpartno,cost_1,cost_10,cost_25,cost_50,cost_100,description) 
26
                VALUES ('".$d[2]."','".$d[1]."','".$d[3]."',now(),true,'".$d[0]."',".$d[16].",".$vendorID.",'".
27
                $d[6]."',".$d[11].",".$d[12].",".$d[13].",".$d[14].",".$d[15].",'".$d[4]."');";
28
                
29
                echo $add_item_sql."<br/><br/>";
30
                
31
                $add_item_res = mysqli_query($mysqli, $add_item_sql) or die(mysqli_error($mysqli));                
32
    }
33
    fclose($handle);
34
}
35

    
36
//close connection to MySQL
37
mysqli_close($mysqli);
38

    
39
/* column order
40
0 - tags
41
1 - manufact
42
2 - part name
43
3 - manufact num
44
4 - description
45
5 - Look up in vendor table
46
6 - vendor part num
47
11 - price/1
48
12 - price/10
49
13 - price/25
50
14 - price/50
51
15 - price/100
52
16 - qty
53
        
54
header("Location:/index/");
55

56
*/
57
?>