require_once 'File/Convert.php';
$fc = new File_Convert($img->getStoreName(), $img->mimetype );
$csv = $fc->convert('text/csv');
- $this->importCsv($csv);
+ $data = $this->importCsv($csv);
+ $this->jdata($data);
+
}
function importCsv($csv)
$this->jerr("invalid file");
}
- $req = array(
- 'LINE', 'ITEM CODE', 'DESCRIPTION', 'QUANTITY'
- );
-
+
$cols = false;
$header = false;
$rows = array();
continue;
}
- foreach($req as $r) {
- if (!in_array($r,$cols)) {
- $cols = false;
- break;
- }
- }
+
continue;
}
}
- if (empty($cols)) {
- $this->jerr("could not find a row with " . implode(' / ', $req));
- }
+
fclose($fh);
$lc = DB_DataObject::factory('location');
- if($lc->get('location_name', $ret['From'])){
+ if(!$lc->get('location_name', $ret['From'])){
$this->jerr('error occur on getting location with reference ' . $ret['From']);
}
$ret['invhist_transfer_from'] = $lc->pid();
$ret['invhist_transfer_from_location_name'] = $lc->location_name;
$lt = DB_DataObject::factory('location');
- if($lt->get('location_name', $ret['To'])){
+ if(!$lt->get('location_name', $ret['To'])){
$this->jerr('error occur on getting location with reference ' . $ret['From']);
}
$ret['invhist_transfer_to'] = $lt->pid();
'itemsite_qty' => $r['QUANTITY']
);
}
-
- $this->jok($ret);
-
+ return $ret;
- exit;
}
}