From 119978c5a0b1c62e94fc31402fdbcd894b84e5d0 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Thu, 29 Jan 2015 15:22:49 +0000 Subject: [PATCH] add checkTableField function in csv-dataimport,perfection the processing interface --- .../admin/controllers/DataController.php | 20 +++++++-- .../scripts/data/dataimport-target.phtml | 44 ++++++++++++------- .../admin/views/scripts/data/dataimport.phtml | 10 ++--- .../Westdc/Dataimport/Processing/Csv.php | 34 +++++++++++++- .../Westdc/Dataimport/ProcessingInterface.php | 13 ++++++ .../module/Westdc/Visual/DataTableControl.php | 6 +-- 6 files changed, 98 insertions(+), 29 deletions(-) diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php index 657511e6..e6382621 100755 --- a/application/admin/controllers/DataController.php +++ b/application/admin/controllers/DataController.php @@ -4267,18 +4267,30 @@ class Admin_DataController extends Zend_Controller_Action //检查能否写入数据表 if($ac == "checktables"){ + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + $table = $this->_getParam('table'); - if(empty($table)){ + $schema = $this->_getParam('schema'); + $file = $this->_getParam('file'); + if(empty($table) || empty($schema) || empty($file)){ $this->_helper->json(['error'=>'參數錯誤']); return true; } $tableControl = new Visual\DataTableControl; - $fields = $tableControl->readFields($table); + $fields = $tableControl->readFields($schema . "." .$table); - foreach($fields as $k=>$v){ + $fileHandle = new Dataimport\File; + $realFile = $fileHandle->getRealName($file); - } + $processing = Dataimport\ProcessFactory::Bootstrap($fileHandle->getFileTextExt($file)); + /** @var \Westdc\Dataimport\Processing\Csv $processing */ + $processing->init($realFile); + + $status = $processing->checkTableField($fields); + + //$this->_helper->json($status); return true; } diff --git a/application/admin/views/scripts/data/dataimport-target.phtml b/application/admin/views/scripts/data/dataimport-target.phtml index 141bdda7..1f44727b 100644 --- a/application/admin/views/scripts/data/dataimport-target.phtml +++ b/application/admin/views/scripts/data/dataimport-target.phtml @@ -36,16 +36,21 @@ $this->headTitle()->setSeparator(' - ');
-
+ - - + +