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 @@ -= $this->paginator; ?>添加新的特色数据集 +添加新的特色数据集= $this->paginator; ?> paginator)): ?>
= $item['datalist']; ?> | = date('Y-m-d',strtotime($item['ts_created'])); ?> | - 查看 | + 编辑 | 删除
msg; ?>
+messages): foreach($this->messages as $msg): ?> + + +