projects
/
Pman.Core
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix mysqli type connection
[Pman.Core]
/
ExcelToJson.php
diff --git
a/ExcelToJson.php
b/ExcelToJson.php
index
ffda332
..
e981d32
100644
(file)
--- a/
ExcelToJson.php
+++ b/
ExcelToJson.php
@@
-12,7
+12,7
@@
class Pman_Core_ExcelToJson extends Pman_Roo
return parent::getAuth();
}
return parent::getAuth();
}
- function post()
+ function post(
$v
)
{
$this->transObj = DB_DataObject::Factory('invhist_transfer');
{
$this->transObj = DB_DataObject::Factory('invhist_transfer');
@@
-29,9
+29,12
@@
class Pman_Core_ExcelToJson extends Pman_Roo
require_once 'File/Convert.php';
$fc = new File_Convert($img->getStoreName(), $img->mimetype );
require_once 'File/Convert.php';
$fc = new File_Convert($img->getStoreName(), $img->mimetype );
- $csv = $fc->convert('text/csv');
- $data = $this->importCsv($csv);
- $this->jdata($data);
+ $csv = $fc->convert('text/csv');
+ $ret = $this->importCsv($csv);
+
+
+
+ $this->jdata($ret['data'], false, isset($ret['extra']) ? $ret['extra'] : array() );
}
}
@@
-48,10
+51,12
@@
class Pman_Core_ExcelToJson extends Pman_Roo
$cols = false;
$header = false;
$rows = array();
$cols = false;
$header = false;
$rows = array();
- $
ret
= array();
+ $
extra
= array();
while(false !== ($n = fgetcsv($fh,10000, ',', '"'))) {
while(false !== ($n = fgetcsv($fh,10000, ',', '"'))) {
- if(!array_filter($n)){
+
+
+ if(!strlen(trim(implode('', $n)))){ // blank line;
if ($header) {
continue;
}
if ($header) {
continue;
}
@@
-60,7
+65,7
@@
class Pman_Core_ExcelToJson extends Pman_Roo
}
if(!$header){
}
if(!$header){
- $
ret
[preg_replace(array('/\s/', '/\:/'), '', $n[0])] = $n[1];
+ $
extra
[preg_replace(array('/\s/', '/\:/'), '', $n[0])] = $n[1];
continue;
}
continue;
}
@@
-86,6
+91,8
@@
class Pman_Core_ExcelToJson extends Pman_Roo
}
fclose($fh);
}
fclose($fh);
- return array('ret' => $ret, 'rows' => $rows);;
+
+
+ return array('extra' => $extra, 'data' => $rows);;
}
}
\ No newline at end of file
}
}
\ No newline at end of file