ExcelToJson.php
[Pman.Core] / ExcelToJson.php
index a2e1245..9724807 100644 (file)
@@ -43,20 +43,21 @@ 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;
         
         while(false !== ($n = fgetcsv($fh,10000, ',', '"'))) {
             if(!array_filter($n)){
                 $header = true;
+                continue;
             }
             
             if(!$header){
-               $rows[$n[0]] = $n[1];
+               $rows[strtoupper($n[0])] = $n[1];
                continue;
             }
             
@@ -65,10 +66,11 @@ class Pman_Core_ExcelToJson extends Pman_Roo
                 foreach($n as $k) {
                     $cols[] = strtoupper(trim($k));
                 }
-
+                
                 if (empty($cols)) {
                     continue;
                 }
+               
                 foreach($req as $r) {
                     if (!in_array($r,$cols)) {
                         $cols = false;
@@ -77,20 +79,29 @@ class Pman_Core_ExcelToJson extends Pman_Roo
                 }
                 continue;
             }
-            print_r('run');exit;
+            
             foreach($cols as $i=>$k) {
                 $row[$k] = $n[$i];
             }
-            $rows[] = $row;
+            $rows['TRANSFER ITEMS'][] = $row;
             
         }
-        print_r($cols);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;
     }