예제 #1
0
 public function registerAction()
 {
     $name = $this->_getParam('name');
     $avatar = $this->_getParam('avatar');
     $email = $this->_getParam('email');
     $phone = $this->_getParam('phone');
     $departments = $this->_getParam('departments');
     $type = $this->_getParam('type');
     $city = $this->_getParam('city');
     $label = $this->_getParam('label');
     $country = $this->_getParam('country');
     $area = $this->_getParam('area');
     $passwd = $this->_getParam('passwd');
     $introduction = $this->_getParam('introduction');
     $longitude = $this->_getParam('longitude');
     $latitude = $this->_getParam('latitude');
     if (!$passwd) {
         $out['errno'] = '3';
         $out['msg'] = Yy_ErrMsg_Hospital::getMsg('register', $out['errno']);
         Yy_Utils::jsonOut($out);
         return;
     }
     $validatorEmail = new Zend_Validate_EmailAddress();
     if ($validatorEmail->isValid($email)) {
         $bool = Application_Model_M_Hospital::fetchByEmail($email);
         if ($bool) {
             //已注册
             $out['errno'] = '1';
         } else {
             $out['errno'] = '0';
             $hospital = new Application_Model_O_Hospital();
             $hospital->setName($name)->setEmail($email)->setPasswd(md5($passwd))->setPhone($phone)->setDepartments($departments)->setType($type)->setCity($city)->setLabel($label)->setCountry($country)->setArea($area)->setIntroduction($introduction)->setLongitude($longitude)->setLatitude($latitude);
             $certified = ceil(count($hospital->getModifiedFields()) / 3);
             $hospital->setCertified($certified);
             $hospital->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_Hospital::updateAvatar($hospital->getId(), $avatar);
             }
         }
     } else {
         $out['errno'] = '2';
     }
     $out['msg'] = Yy_ErrMsg_Hospital::getMsg('register', $out['errno']);
     Yy_Utils::jsonOut($out);
 }
예제 #2
0
 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_Hospital();
         $entry->setId($row->id)->setName($row->name)->setAvatar($row->avatar)->setEmail($row->email)->setDepartments($row->departments)->setType($row->type)->setCertified($row->certified)->setCity($row->city)->setLabel($row->label)->setCountry($row->country)->setPoint($row->point)->setArea($row->area)->setPasswd($row->passwd)->setPhone($row->phone)->setIntroduction($row->introduction)->setLongitude($row->longitude)->setLatitude($row->latitude)->setCtime($row->ctime)->setUtime($row->utime)->setStatus($row->status);
         $entry->setNew(false);
         $entries[] = $entry;
     }
     return $entries;
 }
예제 #3
0
 public function asyncajaxAction()
 {
     $this->getResponse()->setHeader('Content-Type', 'application/json');
     $this->_helper->viewRenderer->setNoRender(true);
     $this->_helper->layout()->disableLayout();
     $params = $this->_getAllParams();
     $hospital = new Application_Model_O_Hospital();
     $validate = new Yy_Validate_Value();
     if ($validate->isValid($params['id'])) {
         $hospital->setId($params['id']);
     } else {
         $hospital->setCtime(date('Y-m-d H:i:s'));
     }
     if ($validate->isValid($params['name'])) {
         $hospital->setName($params['name']);
     }
     if ($validate->isValid($params['email'])) {
         $hospital->setEmail($params['email']);
     }
     if ($validate->isValid($params['departments'])) {
         $hospital->setDepartments($params['departments']);
     }
     if ($validate->isValid($params['passwd'])) {
         $hospital->setPasswd(md5($params['passwd']));
     }
     if ($validate->isValid($params['type'])) {
         $hospital->setType($params['type']);
     }
     if ($validate->isValid($params['certified'])) {
         $hospital->setCertified($params['certified']);
     }
     if ($validate->isValid($params['city'])) {
         $hospital->setCity($params['city']);
     }
     if ($validate->isValid($params['label'])) {
         $hospital->setLabel($params['label']);
     }
     if ($validate->isValid($params['country'])) {
         $hospital->setCountry($params['country']);
     }
     if ($validate->isValid($params['point'])) {
         $hospital->setPoint($params['point']);
     }
     if ($validate->isValid($params['area'])) {
         $hospital->setArea($params['area']);
     }
     if ($validate->isValid($params['introduction'])) {
         $hospital->setIntroduction($params['introduction']);
     }
     if ($validate->isValid($params['longitude'])) {
         $hospital->setLongitude($params['longitude']);
     }
     if ($validate->isValid($params['latitude'])) {
         $hospital->setLatitude($params['latitude']);
     }
     if ($validate->isValid($params['status'])) {
         $hospital->setStatus($params['status']);
     }
     try {
         $hospital->save();
         $id = $hospital->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_Hospital::updateAvatar($id, $avatar);
         }
         $url = '/hospital/view?id=' . $id . '&from=update';
         $this->redirect($url);
     } catch (Zend_Db_Exception $e) {
         //$this->redirect('/error');
         $this->redirect('/error?message=' . $e->getMessage());
     }
 }