public static function fetchByDepartmentHospital($department, $hospital, $sort, $page) { $select = self::select(); if ($department) { $select->where("department like '%{$department}%'")->orWhere("special like '%{$department}%'"); } if ($hospital) { $select->where('hospital = ?', $hospital); } if ($sort == 1) { //asc $select->order('reservation_number asc'); } elseif ($sort == 2) { //desc $select->order('reservation_number desc'); } $select->where('status = 1'); $adapter = new Zend_Paginator_Adapter_DbTableSelect($select); $paginator = new Zend_Paginator($adapter); $paginator->setItemCountPerPage(10)->setCurrentPageNumber($page); $data = $paginator->getCurrentItems(); $pages = $paginator->count(); $doctors = array(); if (count($data) > 0) { foreach ($data as $da) { $doctorModel = new Application_Model_O_Doctor(); $doctorModel->setId($da->id)->setName($da->name)->setAvatar($da->avatar)->setSex($da->sex)->setBirthday($da->birthday)->setEmail($da->email)->setPasswd($da->passwd)->setPhone($da->phone)->setDepartment($da->department)->setPoint($da->point)->setCity($da->city)->setCertified($da->certified)->setSpecial($da->special)->setCountry($da->country)->setIntroduction($da->introduction)->setHospital($da->hospital)->setArea($da->area)->setQualification($da->qualification)->setReservation_fee($da->reservation_fee)->setReservation_number($da->reservation_number)->setCtime($da->ctime)->setUtime($da->utime)->setStatus($da->status); array_push($doctors, $doctorModel); } } $res = array('doctors' => $doctors, 'pages' => $pages); return $res; }
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_Doctor(); $entry->setId($row->id)->setName($row->name)->setAvatar($row->avatar)->setSex($row->sex)->setBirthday($row->birthday)->setEmail($row->email)->setPasswd($row->passwd)->setPhone($row->phone)->setDepartment($row->department)->setPoint($row->point)->setCity($row->city)->setCertified($row->certified)->setSpecial($row->special)->setCountry($row->country)->setIntroduction($row->introduction)->setHospital($row->hospital)->setArea($row->area)->setQualification($row->qualification)->setReservation_fee($row->reservation_fee)->setReservation_number($row->reservation_number)->setCtime($row->ctime)->setUtime($row->utime)->setStatus($row->status); $entry->setNew(false); $entries[] = $entry; } return $entries; }
public function updateajaxAction() { $this->getResponse()->setHeader('Content-Type', 'application/json'); $this->_helper->viewRenderer->setNoRender(true); $this->_helper->layout()->disableLayout(); $params = $this->_getAllParams(); // unset($params['controller']); // unset($params['action']); // unset($params['module']); //$id = $params['id']; $doctor = new Application_Model_O_Doctor(); $validate = new Yy_Validate_Value(); if ($validate->isValid($params['id'])) { $doctor->setId($params['id']); } else { $doctor->setCtime(date('Y-m-d H:i:s')); } if ($validate->isValid($params['name'])) { $doctor->setName($params['name']); } if ($validate->isValid($params['sex'])) { $doctor->setSex($params['sex']); } if ($validate->isValid($params['birthday'])) { $doctor->setBirthday($params['birthday']); } if ($validate->isValid($params['email'])) { $doctor->setEmail($params['email']); } if ($validate->isValid($params['passwd'])) { $doctor->setPasswd(md5($params['passwd'])); } if ($validate->isValid($params['department'])) { $doctor->setDepartment($params['department']); } if ($validate->isValid($params['point'])) { $doctor->setPoint($params['point']); } if ($validate->isValid($params['city'])) { $doctor->setCity($params['city']); } if ($validate->isValid($params['certified'])) { $doctor->setCertified($params['certified']); } if ($validate->isValid($params['special'])) { $doctor->setSpecial($params['special']); } if ($validate->isValid($params['country'])) { $doctor->setCountry($params['country']); } if ($validate->isValid($params['introduction'])) { $doctor->setIntroduction($params['introduction']); } if ($validate->isValid($params['hospital'])) { $doctor->setHospital($params['hospital']); } if ($validate->isValid($params['area'])) { $doctor->setArea($params['area']); } if ($validate->isValid($params['qualification'])) { $doctor->setQualification($params['qualification']); } if ($validate->isValid($params['reservation_fee'])) { $doctor->setReservation_fee($params['reservation_fee']); } if ($validate->isValid($params['reservation_number'])) { $doctor->setReservation_number($params['reservation_number']); } if ($validate->isValid($params['status'])) { $doctor->setStatus($params['status']); } try { $doctor->save(); $id = $doctor->getId(); //保存医生头像 $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'); $avatar = addslashes(fread($handle, filesize($filename))); fclose($handle); Application_Model_M_Doctor::updateAvatar($id, $avatar); } $url = '/doctor/view?id=' . $id; $this->redirect($url); } catch (Zend_Db_Exception $e) { //$this->redirect('/error'); $this->redirect('/error?message=' . $e->getMessage()); } }
public function registerAction() { $name = $this->_getParam('name'); $avatar = $this->_getParam('avatar'); $sex = $this->_getParam('sex'); $birthday = $this->_getParam('birthday'); $email = $this->_getParam('email'); $passwd = $this->_getParam('passwd'); $phone = $this->_getParam('phone'); $department = $this->_getParam('department'); $city = $this->_getParam('city'); //$certified = $this->_getParam('certified'); $special = $this->_getParam('special'); $country = $this->_getParam('country'); $introduction = $this->_getParam('introduction'); $hospital = $this->_getParam('hospital'); $area = $this->_getParam('area'); $qualification = $this->_getParam('qualification'); if (!$passwd) { $out['errno'] = '3'; $out['msg'] = Yy_ErrMsg_Doctor::getMsg('register', $out['errno']); Yy_Utils::jsonOut($out); return; } $validatorEmail = new Zend_Validate_EmailAddress(); if ($validatorEmail->isValid($email)) { $bool = Application_Model_M_Doctor::fetchByEmail($email); if ($bool) { //已注册 $out['errno'] = '1'; } else { $out['errno'] = '0'; $doctor = new Application_Model_O_Doctor(); $doctor->setName($name)->setSex($sex)->setBirthday($birthday)->setEmail($email)->setPasswd(md5($passwd))->setPhone($phone)->setDepartment($department)->setCity($city)->setSpecial($special)->setCountry($country)->setIntroduction($introduction)->setHospital($hospital)->setArea($area)->setQualification($qualification)->setCtime(date('Y-m-d H:i:s')); $certified = ceil(count($doctor->getModifiedFields()) / 3); $doctor->setCertified($certified); $doctor->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'); $avatar = addslashes(fread($handle, filesize($filename))); fclose($handle); Application_Model_M_Doctor::updateAvatar($doctor->getId(), $avatar); } } } else { $out['errno'] = '2'; } $out['msg'] = Yy_ErrMsg_Doctor::getMsg('register', $out['errno']); Yy_Utils::jsonOut($out); }