ExcelToJson.php
[Pman.Core] / ExcelToJson.php
index e14e1ab..9724807 100644 (file)
@@ -43,10 +43,10 @@ class Pman_Core_ExcelToJson extends Pman_Roo
         }
         
         $req = array(
-            'LINE', 'ITEM CODE', 'DESCRIPTION', 'QUANTITY', 'AA'
+            'LINE', 'ITEM CODE', 'DESCRIPTION', 'QUANTITY'
         );
         
-        $cols[] = false;
+        $cols = false;
         $rows = array();
         $header = false;
         
@@ -57,23 +57,22 @@ class Pman_Core_ExcelToJson extends Pman_Roo
             }
             
             if(!$header){
-               $rows[$n[0]] = $n[1];
+               $rows[strtoupper($n[0])] = $n[1];
                continue;
             }
-            print_r($n);exit;
+            
             if(!$cols){
                 $cols = array();
                 foreach($n as $k) {
                     $cols[] = strtoupper(trim($k));
                 }
-                print_r($cols);exit;
+                
                 if (empty($cols)) {
                     continue;
                 }
-                print_r($cols);exit;
+               
                 foreach($req as $r) {
                     if (!in_array($r,$cols)) {
-                        print_r($r);
                         $cols = false;
                         break;
                     }
@@ -84,16 +83,25 @@ class Pman_Core_ExcelToJson extends Pman_Roo
             foreach($cols as $i=>$k) {
                 $row[$k] = $n[$i];
             }
-            $rows[] = $row;
+            $rows['TRANSFER ITEMS'][] = $row;
             
         }
-         exit;
+        
         if (empty($cols)) {
             $this->jerr("could not find a row with " . implode(' / ', $req));
         }
         
         fclose($fh);
         
+        foreach ($rows['TRANSFER ITEMS'] as $r){
+            $itemsite = DB_DataObject::factory('itemsite');
+            $itemsite->autoJoin();
+            $itemsite->get('item_number', $r['ITEM CODE']);
+        }
+        
+        
+        
+        
         exit;
     }