diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php index fac8c480..c5ba30b7 100755 --- a/application/admin/controllers/DataController.php +++ b/application/admin/controllers/DataController.php @@ -107,6 +107,68 @@ class Admin_DataController extends Zend_Controller_Action //离线数据服务记录 function offlineAction() { + $add=(int)$this->_getParam('add'); + $edit=(int)$this->_getParam('edit'); + $delete=(int)$this->_getParam('delete'); + if ($add) { + $form=new OfflinelogForm(); + $form->pdf->setDestination($this->view->config->offline->savepath); + if ($this->_request->isPost()) { + $formdata=$this->_request->getPost(); + if ($form->isValid($formdata)) { + $uploadedData = $form->getValues(); + $pdf = basename($form->pdf->getFileName()); + $sql="insert into offlineapp (username,email,unit,phone,address,postcode,project,pdflink,datalist,ts_approved) values(?,?,?,?,?,?,?,?,?,?)"; + $this->db->query($sql,array($formdata['username'],$formdata['email'],$formdata['unit'],$formdata['phone'],$formdata['address'],$formdata['postcode'],$formdata['project'],$pdf,$formdata['datalist'],$formdata['ts_approved'])); + $this->messenger->addMessage('提示信息:您已经成功添加该离线服务记录。'); + $this->_redirect('/admin/data/offline'); + } else { + $form->populate($formdata); + } + } + $this->view->form=$form; + $this->_helper->viewRenderer('offlineadd'); + } elseif ($edit){ + $form=new OfflinelogForm(); + $form->pdf->setRequired(false); + if ($this->_request->isPost()) { + $formdata=$this->_request->getPost(); + if ($form->isValid($formdata)) { + $uploadedData = $form->getValues(); + $pdf = basename($form->pdf->getFileName()); + $sql="update offlineapp set username=?,email=?,unit=?,phone=?,address=?,postcode=?,project=?,"; + if ($form->pdf->isUploaded()) $sql.="pdflink=?,"; + $sql.="datalist=?,ts_approved=? where id=?"; + $param=array($formdata['username'],$formdata['email'],$formdata['unit'],$formdata['phone'],$formdata['address'],$formdata['postcode'],$formdata['project']); + if ($form->pdf->isUploaded()) $param[]=$pdf; + $param[]=$formdata['datalist']; + $param[]=$formdata['ts_approved']; + $param[]=$edit; + $this->db->query($sql,$param); + $this->messenger->addMessage('提示信息:您已经编辑添加该记录。'); + $this->_redirect('/admin/data/offline'); + } else { + $form->populate($formdata); + } + } else { + $sql="select * from offlineapp where id=?"; + $formdata=$this->db->fetchRow($sql,array($edit)); + $form->submit->setLabel('保存'); + $form->populate($formdata); + } + $this->view->form=$form; + $this->_helper->viewRenderer('offlineadd'); + + } elseif ($delete) { + $sql="delete from offlineapp where id=?"; + try { + $this->db->query($sql,array($delete)); + $this->messenger->addMessage('提示信息:您已经成功删除该服务记录。'); + } catch (Exception $e) { + $this->messenger->addMessage($e->getMessage()); + } + $this->_redirect("/admin/data/offline"); + } $select=$this->db->select(); $select->from('offlineapp')->where('ts_approved is not null')->where('pdflink is not null')->order('id desc'); $paginator = Zend_Paginator::factory($select); diff --git a/application/admin/views/scripts/data/datasetcd.phtml b/application/admin/views/scripts/data/datasetcd.phtml index b1ef4d48..91bf8a1c 100644 --- a/application/admin/views/scripts/data/datasetcd.phtml +++ b/application/admin/views/scripts/data/datasetcd.phtml @@ -22,7 +22,7 @@ -paginator; ?>添加新的特色数据集 +添加新的特色数据集paginator; ?> paginator)): ?>
paginator as $item): ?> diff --git a/application/admin/views/scripts/data/offline.phtml b/application/admin/views/scripts/data/offline.phtml index d794726c..e45e550f 100644 --- a/application/admin/views/scripts/data/offline.phtml +++ b/application/admin/views/scripts/data/offline.phtml @@ -13,7 +13,6 @@ partial('data/left.phtml'); ?>
-paginator; ?> msg or $this->messages) :?>
msg) : ?> @@ -23,6 +22,8 @@
+添加新的离线服务记录 +paginator; ?> paginator)): ?> @@ -45,7 +46,7 @@ + 编辑 | 删除
- 查看
diff --git a/application/admin/views/scripts/data/offlineadd.phtml b/application/admin/views/scripts/data/offlineadd.phtml new file mode 100644 index 00000000..46560df2 --- /dev/null +++ b/application/admin/views/scripts/data/offlineadd.phtml @@ -0,0 +1,27 @@ +headTitle($this->config->title->site); + $this->headTitle('后台管理'); + $this->headTitle()->setSeparator(' - '); + $this->headLink()->appendStylesheet('/css/admin.css'); + $this->breadcrumb('首页'); + $this->breadcrumb('后台首页'); + $this->breadcrumb('数据管理'); + $this->breadcrumb('离线数据服务记录管理'); + $this->breadcrumb()->setSeparator(' > '); +?> +
+partial('data/left.phtml'); ?> +
+
+msg or $this->messages) :?> +
+msg) : ?> +

msg; ?>

+messages): foreach($this->messages as $msg): ?> +

+ +
+ +添加新的离线服务记录 +form; ?> +
\ No newline at end of file diff --git a/application/models/OfflinelogForm.php b/application/models/OfflinelogForm.php new file mode 100644 index 00000000..7ef2ca87 --- /dev/null +++ b/application/models/OfflinelogForm.php @@ -0,0 +1,47 @@ +setName('OfflinePdf'); + + + $email=new Zend_Form_Element_Text('email'); + $email->setLabel('E-Mail') + ->addFilter('StringTrim') + ->addValidator('NotEmpty') + ->addValidator('EmailAddress'); + + $username=new Zend_Form_Element_Text('username'); + $username->setLabel('真实姓名')->setRequired(true); + $phone=new Zend_Form_Element_Text('phone'); + $phone->setLabel('电话')->setRequired(true); + $unit=new Zend_Form_Element_Text('unit'); + $unit->setLabel('单位')->setRequired(true); + $postcode=new Zend_Form_Element_Text('postcode'); + $postcode->setLabel('邮编')->setRequired(true); + $address=new Zend_Form_Element_Text('address'); + $address->setLabel('联系地址')->setRequired(true); + $project=new Zend_Form_Element_Textarea('project'); + $project->setLabel('用途')->setRequired(true)->setAttrib('rows',2); + $datalist=new Zend_Form_Element_Textarea('datalist'); + $datalist->setLabel('数据清单')->setRequired(true)->setAttrib('rows',2); + $pdf=new Zend_Form_Element_File('pdf'); + $pdf->setLabel('离线服务记录(PDF)') + ->setRequired(true) + //->setDestination('../data/offlineapp') + ->addValidator('Count', false, 1) // ensure only 1 file + ->addValidator('Size', false, 1024000) // limit to 1M + ->addValidator('Extension', false, 'pdf,doc'); // only JPEG, PNG, and GIFs + $ts_approved=new Zend_Form_Element_Text('ts_approved'); + $ts_approved->setLabel('申请时间(格式:2008-12-20)')->setRequired(true); + $id = new Zend_Form_Element_Hidden('id'); + + $submit = new Zend_Form_Element_Submit('submit'); + $submit->setAttrib('id', 'submitbutton')->setLabel('添加'); + $this->setAttrib('enctype', 'multipart/form-data'); + $this->addElements(array($username,$email,$phone,$unit,$address,$postcode,$pdf,$ts_approved,$project,$datalist,$id,$submit)); + } +} \ No newline at end of file