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());
     }
 }
 public function updateAction()
 {
     $name = $this->_getParam('name');
     $avatar = $this->_getParam('avatar');
     $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');
     $phone = $this->_getParam('phone');
     $introduction = $this->_getParam('introduction');
     $longitude = $this->_getParam('longitude');
     $latitude = $this->_getParam('latitude');
     if ($this->_auth->userid && $this->_auth->role == 3) {
         $hospital = Application_Model_M_Hospital::find($this->_auth->userid);
         if ($hospital) {
             if ($name) {
                 $hospital->setName($name);
             }
             //         	    if($avatar){
             //         	    	$hospital->setAvatar($avatar);
             //         	    }
             if ($departments) {
                 $hospital->setDepartments($departments);
             }
             if ($type) {
                 $hospital->setType($type);
             }
             if ($city) {
                 $hospital->setCity($city);
             }
             if ($label) {
                 $hospital->setLabel($label);
             }
             if ($country) {
                 $hospital->setCountry($country);
             }
             if ($area) {
                 $hospital->setArea($area);
             }
             if ($passwd) {
                 $hospital->setPasswd(md5($passwd));
             }
             if ($phone) {
                 $hospital->setPhone($phone);
             }
             if ($introduction) {
                 $hospital->setIntroduction($introduction);
             }
             if ($longitude) {
                 $hospital->setLongitude($longitude);
             }
             if ($latitude) {
                 $hospital->setLatitude($latitude);
             }
             try {
                 $out['errno'] = '0';
                 $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);
                 }
             } catch (Zend_Db_Exception $e) {
                 $out['errno'] = '1';
             }
         } else {
             $out['errno'] = '1';
         }
     } else {
         $out['errno'] = '200';
     }
     $out['msg'] = Yy_ErrMsg_Hospital::getMsg('update', $out['errno']);
     Yy_Utils::jsonOut($out);
 }