public static function fetchAll($where = null, $order = null, $limit = null, $offset = null) { $resultSet = self::getDbTable()->fetchAll($where, $order, $limit, $offset); $entries = array(); foreach ($resultSet as $row) { $entry = new Application_Model_O_GlobalConsultationApply(); $entry->setId($row->id)->setDepartment_category_id($row->department_category_id)->setDepartment_id($row->department_id)->setEmail($row->email)->setMobile($row->mobile)->setAge($row->age)->setSex($row->sex)->setLocation($row->location)->setTreatment_time($row->treatment_time)->setOpinion($row->opinion)->setReport($row->report)->setCtime($row->ctime)->setUtime($row->utime)->setStatus($row->status); $entry->setNew(false); $entries[] = $entry; } return $entries; }
public static function fetchAllPage($page = 1, $perpage = 30) { $select = self::select(); $adapter = new Zend_Paginator_Adapter_DbTableSelect($select); $paginator = new Zend_Paginator($adapter); $paginator->setItemCountPerPage($perpage)->setCurrentPageNumber($page); $data = $paginator->getCurrentItems(); $pages = $paginator->count(); $applys = array(); if (count($data) > 0) { foreach ($data as $da) { $applyModel = new Application_Model_O_GlobalConsultationApply(); $applyModel->setId($da->id)->setDepartment_category_id($da->department_category_id)->setDepartment_id($da->department_id)->setEmail($da->email)->setMobile($da->mobile)->setAge($da->age)->setSex($da->sex)->setLocation($da->location)->setTreatment_time($da->treatment_time)->setOpinion($da->opinion)->setReport($da->report)->setCtime($da->ctime)->setUtime($da->utime)->setStatus($da->status); array_push($applys, $applyModel); } } $res = array('applys' => $applys, 'pages' => $pages); return $res; }
public function applyAction() { $category = $this->_getParam('category'); $department = $this->_getParam('department'); $email = $this->_getParam('email'); $mobile = $this->_getParam('mobile'); $age = $this->_getParam('age'); $sex = $this->_getParam('sex'); $location = $this->_getParam('location'); $treatment_time = $this->_getParam('treatment_time'); $opinion = $this->_getParam('opinion'); $report = $this->_getParam('report'); $apply = new Application_Model_O_GlobalConsultationApply(); $apply->setDepartment_category_id($category)->setDepartment_id($department)->setEmail($email)->setMobile($mobile)->setAge($age)->setSex($sex)->setLocation($location)->setTreatment_time($treatment_time)->setOpinion($opinion)->setCtime(date('Y-m-d H:i:s')); try { $out['errno'] = '0'; $apply->save(); //保存病例报告 $adapter = new Zend_File_Transfer_Adapter_Http(); $wrdir = Yy_Utils::getWriteDir(); $adapter->setDestination($wrdir); if (!$adapter->receive()) { $messages = $adapter->getMessages(); //echo implode("\n", $messages); } $filename = $adapter->getFileName(); if (is_string($filename)) { $handle = fopen($filename, 'rb'); $report = addslashes(fread($handle, filesize($filename))); fclose($handle); Application_Model_M_GlobalConsultationApply::updateReport($apply->getId(), $report); } } catch (Zend_Db_Exception $e) { $out['errno'] = '1'; //echo $e->getMessage(); } $out['msg'] = Yy_ErrMsg_Diagnosis::getMsg('apply', $out['errno']); Yy_Utils::jsonOut($out); }