public function updatePercentPost($request, $response)
 {
     /*{{{*/
     if ($request->percent) {
         $ticketid = DZoneClient::getInstance()->updatePercent($this->space->id, $request->percent, $this->space);
         if ($ticketid) {
             $this->message('修改成功,请等待审核!', $response);
         }
     }
 }
	public function index($request, $response) {
		$photoAlbumList = DZoneClient::getInstance()->getPhotoAlbumList($this->_newSpace->id);
		foreach($photoAlbumList as $photoAlbum)
		{
			$logoList[$photoAlbum->id] = array_pop(AttachClient::getInstance()->getAlbumAttach($photoAlbum->id, 1));
		}
		
		$response->photoAlbumList = $photoAlbumList;
		$response->logoList = $logoList;
		$response->title = '相册首页_'.$response->title;
	}
    public function updatePercent($request, $response)
    {/*{{{*/
        if (false == $this->_newSpace->isFundOpened())
        {
            $response->setRedirect($response->router->urlfor('index/fundApply'));
        }

        $auditingApply = DAL::get()->find_by_spaceid_and_status('FundApply', $this->_newSpace->id, FundApply::STATUS_AUDITING);

        if (false == $auditingApply->isNull())
        {
            $this->message('您的申请正在审核,请耐心等待!', $response, array ('forward' => $this->_newSpace->getUrl()));
            return;
        }
        $response->currentPercent = $this->_newSpace->getFundAttribute()->percent * 100;
        
        if ($request->percent)
        {
            $ticketid = DZoneClient::getInstance()->updatePercent($this->_newSpace->id, $request->percent, $this->_newSpace);
            if ($ticketid)
            {
                $this->message('修改成功,请等待审核!', $response, array('forward' => 'module'));
            }
        }
    }/*}}}*/
 private function statistics($request, $response)
 {
     /*{{{*/
     $thankLetterCount = 0;
     if ($this->space->isDoctor()) {
         $thankLetterCount = $this->space->host->getCureThankLetterCount();
     }
     $response->thankLetterCount = $thankLetterCount;
     $spaceRepliedCount = SpaceClient::getInstance()->getCountOfRepliedFlowsCount($this->space->id, $this->user->id);
     $response->spaceRepliedCount = $spaceRepliedCount != 0 ? $spaceRepliedCount : $this->space->caseCount;
     $doctorVoteCnt = 0;
     $diseaseList = DiseaseClient::getInstance()->getDiseaseDoctorList(array($this->space->host->primaryId));
     foreach ($diseaseList as $idx => $diseaseDoctor) {
         if ($diseaseDoctor->goodVoteCount > 0) {
             $doctorVoteCnt += $diseaseDoctor->goodVoteCount;
         }
     }
     $response->doctorVoteCnt = $doctorVoteCnt;
     //礼物数
     $response->presentCnt = PresentClient::getInstance()->getCntOfPresent($this->space->id);
     //昨日诊后报到
     $time = XDateTime::yesterday();
     $startTime = $time->toShortString();
     $endTime = $startTime . ' 23:59:59';
     $yesterdaySigninCnt = DAL::get()->querySubsidyCntByTimeSpan('SubsidyOrder', $this->space->id, $startTime, $endTime);
     $totalSigninCnt = DAL::get()->queryCntByTimeSpan('PatientSignin', $this->space->id);
     $response->totalSigninCnt = $totalSigninCnt;
     $response->yesterdaySigninCnt = $yesterdaySigninCnt;
     //诊后报到患者
     $response->yesterdayCnt = DZoneClient::getInstance()->getYesterdayHits('spacehit', $this->space->id);
     $response->yesterdayDate = date("y-m-d", time() - 3600 * 24);
     $response->docLastOnlineTime = $this->space->getLastOnlineTimeStr();
     $response->openSpaceTime = date("Y-m-d H:i", $this->space->ctime->getTime());
 }
 public function closeNotice($request, $response)
 {
     /*{{{*/
     $uname = $request->uname;
     $space = DAL::get()->find_by_username('Space', $uname);
     DZoneClient::getInstance()->setSpaceFundAttributeNoticed($space);
 }
 public function updateDoctorPoolInfo($request, Response $response)
 {
     /*{{{*/
     $spaceId = $request->spaceuserid;
     $params = array();
     $params['allowAnswerDayNumber'] = $request->dayNumber;
     $params['allowAnswerTodayRemainNumber'] = $request->TodayRemainNumber;
     $params['todayRecommend'] = $request->TodayRecommend;
     $spacePoolinfo = DAL::get()->find('SpaceModuleCase', $spaceId);
     if (!$spacePoolinfo->isNull()) {
         DZoneClient::getInstance()->updateSpacePoolInfo($spaceId, $this->curInspector->user->id, $params);
         //更新问题池限制信息
     }
     $response->setRedirect($response->router->urlfor('threadcate/recommendAuditDetail', array('space_user_id' => $spaceId, 'poolInfo' => '更新成功!', 'spaceuserid' => $spaceId)));
 }
	public function updatePhotoCount($id) {
		if(empty($id)){
			$this->message('相册ID不可为空', $response);
			return false;
		}
		$photoAlbum = DAL::get()->find('photoAlbum', $id);
		$count = AttachClient::getInstance()->getAlbumCount($id);
		DZoneClient::getInstance()->modifyPhotoAlbum($id, array('photoCount'=>$count));
	}
    /**
        * @brief 根据spaceid 设置网站咨询范围
        * @author zhb
        * @exampleUrl http://dev.mobile-api.haodf.com/doctorapi/flowref_setaskintentioncondition?userId=309570&commonCaseNote=北京本地&xdoc=1
        *
        * @Param $userId 医生userId
        * @Param $num 新患者数量
        * @Param $condition 咨询范围
        *
     */
    public function setAskIntentionCondition($userId, $commonCaseNote)
    {/*{{{*/
        $space = DAL::get()->find('space', $userId);
        if($space->isNull())
        {
            $this->setErrorCode(328);
            return 0;
        }
        $lastCommonCaseNote = $space->commonCaseNote;
        SpaceClient::getInstance()->setProperties($userId, array('commonCaseNote'=>$commonCaseNote));
        if($lastCommonCaseNote != $commonCaseNote)
        {
            $type = SpaceLog::$type[SpaceLog::SPACE_LOG_TYPE_CASE];
            SpaceChangeLogClient::getInstance()->addLog($userId, $type, $lastCommonCaseNote);
            RecommendThreadCategoryClient::getInstance()->pushUserLog($space->id, $userId,
                RecommendThreadCategoryLog::$remark[RecommendThreadCategoryLog::TYPE_WAP_CASE_SET],
                RecommendThreadCategoryLog::TYPE_WAP_CASE_SET);
        }
		DZoneClient::getInstance()->replaceSpaceAttribute($userId, Space::ATTR_RECOMMEND_COMMONCASENOTE_UPDATED, 1);
    }/*}}}*/
 public function searchFund($request, $response)
 {
     /*{{{*/
     $nowPage = (int) $request->getRequest('p', 1);
     $pageSize = 25;
     $total = 500;
     $options = array();
     $res = array();
     if ($request->keyword) {
         $spaces = SpaceClient::getInstance()->getSpacesByName($request->keyword);
         $spaceIds = array_keys($spaces);
         if ($spaceIds) {
             $res = DZoneClient::getInstance()->getFoundAccountListBySpace($spaceIds);
         }
         $response->pagelink = '';
     } else {
         $res = AccountClient::getInstance()->getFoundAccountList($nowPage, $pageSize);
         $response->pagelink = PageNav::getNavLink(PageNav::getPageNavTemplate("/present/searchfund?showContent=1&p="), $nowPage, $pageSize, $total);
     }
     $response->res = $res;
 }
    public function addFundApply($request, $response)
    {/*{{{*/
        $percent = $request->percent;
        DBC::requireTrue($percent <= 100 && $percent >0, '请输入0至100之间的有效数字!');
        $auditingApply = DAL::get()->find_by_spaceid_and_status('FundApply', $this->_newSpace->id, FundApply::STATUS_AUDITING);

        if (false == $auditingApply->isNull())
        {
            $this->message('您的申请正在审核,请耐心等待!', $response, array ('forward' => $this->_newSpace->getUrl()));
            return;
        }

        $options = array();
        $options['age'] = $request->age;
        $options['city'] = $request->city;
        $options['percent'] = $percent;
        $options['description'] = ('对于您的救助金,还有什么要求请告诉我们' == $request->description)?'':$request->description;
        $type = $request->type;

        $applyId = DZoneClient::getInstance()->addFundApply($this->_newSpace->id, $type, $options);
        if ($applyId)
        {
            $this->message('提交成功!', $response, array('forward' => $response->router->urlfor('adminpayment/index')));
        }
        else
        {
            $this->message('系统繁忙,请稍后重试!', $response, array('forward' => $this->_newSpace->getUrl()));
        }
        DZoneClient::getInstance()->setSpaceFundAttributeNoticed($this->_newSpace);
    }/*}}}*/
 public function doctorGid($request, $response)
 {
     /*{{{*/
     $nowPage = $request->getRequest('page', 1);
     $pageSize = 50;
     $gid = $request->gid;
     $userId = $request->userid;
     $options = array();
     if (!empty($gid)) {
         $options['gid'] = $gid;
         $response->tit = 'GID';
     }
     if (!empty($userId)) {
         $options['userId'] = $userId;
         $response->tit = '用户';
     }
     $res = DZoneClient::getInstance()->getSpaceByGid($options, $nowPage, $pageSize);
     $response->spaceLoginList = $res['list'];
     $response->pageLink = PageNav::getNavLink(PageNav::getPageNavTemplate("/doctorcomment/doctorgid?gid={$gid}&userid={$userId}&page="), $res['pageInfo']['nowpage'], $res['pageInfo']['pagesize'], $res['pageInfo']['total']);
     $spaceIds = array();
     if ($response->spaceLoginList) {
         foreach ($response->spaceLoginList as $spaceLogin) {
             $spaceIds[] = $spaceLogin->userId;
         }
     }
     $response->spaceList = DAL::get()->find('Space', $spaceIds);
 }
 /** 允许一个被我禁止的用户 */
 public function allowUser($request, $response)
 {
     $userId = (int)$request->user_id;
     $userObject = DAL::get()->find('user',$userId);
     $threadId = (int)$request->case_id;
     $userId = $this->_newSpace->user->id;
     $user = DAL::get()->find('user', $userId);
     $thread = DAL::get()->find('thread', $threadId);
     DZoneClient::getInstance()->removeForbidPatient($this->_newSpace->id,$thread->patient->id);
     
     /** 允许的时候同时开启问题 */
     ThreadClient::getInstance()->open($user, $threadId);
      $this->message('用户' . $userObject->name . '已经恢复了向您提问的资格', $response, array(
         'buttons' => array(
             array('text' => '返回问题', 'url' => $thread->getUrl())
         ),
     ));
 }
		/** 彻底删除患者 */
		public function destroy($request, $response) {
				$patient_id = $request->getRequest('patient_id', 0);
				DZoneClient::getInstance()->realDelete($patient_id);
				$this->message('患者已经被彻底删除', $response);

		}
 private function getIndexRight($response)
 {/*{{{*/
     $response->rightFacultyList = DZoneClient::getInstance()->getSpaceProperty('Disease', $this->disease->id);
     $response->articleList = $this->disease->getArticleListBySearch();
 }/*}}}*/
 private function detailForSpace($response, Proposal $proposal, $diseaseName)
 {
     /*{{{*/
     $response->buttons = '';
     $response->disease = DAL::get()->find_by_name('Disease', $diseaseName);
     //是否审核后进入下一条
     $spaceAttr = DAL::get()->find_by_fld_spaceuserid_and_name('spaceAttribute', $this->space->id, Space::ATTR_FLOW_PROCESS);
     $flowProcess = $spaceAttr->isNull() ? SpaceAttribute::FLOW_PROCESS_FORWARD : $spaceAttr->value;
     $response->isFirstTime4FlowProcess = $spaceAttr->isNull();
     $response->flowProcess = $flowProcess;
     /** 医生查看,标志Case为已读 */
     ProposalClient::getInstance()->markRead($proposal);
     extract(FlowClient::getInstance()->getNextUnread4Thread($this->space));
     $response->nextUrl = $nextUrl;
     $response->nextList = $nextList;
     $response->nextNeedAlert = $nextNeedAlert;
     $response->nextTip = $nextTip;
     $response->editPost = new NullEntity();
     $response->spaceTip = DZoneClient::getInstance()->getSpaceAndPatientTip($this->space->id, SpaceTip::OBJECT_SPACE);
     /** 用户对其他大夫的咨询 */
     $response->userOtherCaseList = array();
     if (false == empty($this->user->patientList)) {
         $response->userOtherCaseList = DAL::get()->find_all_by_patient_otherSpace('DoctorPatientRef', array_keys($this->user->patientList), $this->space, 8);
     }
     list($groups, $isResidentEvil, $categoryPairs) = $this->getPatientInfoForDoctor($proposal);
     $response->groups = $groups;
     $response->isResidentEvil = $isResidentEvil;
     $response->categoryPairs = $categoryPairs;
     $doctorOwner = DAL::get()->find_by_userid('doctorOwner', $this->space->id);
     $response->patientCase = DAL::get()->find_byDoctorOwnerIdAndPatientId('patientcase', $doctorOwner->id, $proposal->patient->id);
     $response->patient = $proposal->patient;
     $response->recordPatientIds = DAL::get()->queryRecordListByPatientIds('PatientHealthRecord', $proposal->patient->id);
 }
 /**
  * @brief 展示给老患者的咨询规则声明"大夫在休息时间亲自给病友提供医疗指导blablabla",
  * @author lhl
  * @version branches/v2.14.23
  * @date 2013-07-25
  */
 public function setShowOldPatientPop($request, $response)
 {
     /*{{{*/
     $refId = $request->refid;
     $ref = DAL::get()->find('DoctorPatientRef', $refId);
     $tip = DZoneClient::getInstance()->getSpaceAndPatientTip($ref->user->id, SpaceTip::OBJECT_PATIENT);
     DZoneClient::getInstance()->setSpaceShowInsertPop($tip->id);
     $response->setRedirect($ref->url);
 }
 private function diseaseThread($request, $response)
 {
     /*{{{*/
     $lastCommonCaseNote = $this->space->commonCaseNote;
     $diseasesGbk = XString::convertToGbk($request->diseases);
     SpaceClient::getInstance()->setProperties($this->space->id, array('commonCaseNote' => $diseasesGbk));
     if ($lastCommonCaseNote != $diseasesGbk) {
         SpaceChangeLogClient::getInstance()->addLog($this->space->id, SpaceLog::$type[SpaceLog::SPACE_LOG_TYPE_CASE], $lastCommonCaseNote);
     }
     DZoneClient::getInstance()->replaceSpaceAttribute($this->space->id, Space::ATTR_RECOMMEND_COMMONCASENOTE_UPDATED, 1);
     $diseasesGbk = strlen($diseasesGbk) > 0 ? $diseasesGbk : '暂无';
     return $diseasesGbk;
 }
 public function ajaxGetAllProvinceRecommend($request, $response)
 {
     /*{{{*/
     $categoryId = $request->categoryId;
     $spaceProvinceCodes = $this->getSpaceProvince($this->space->id);
     if (isset($spaceProvinceCodes[$categoryId])) {
         unset($spaceProvinceCodes[$categoryId]);
     }
     $spaceProvinceCodesSer = serialize($spaceProvinceCodes);
     DZoneClient::getInstance()->replaceSpaceAttribute($this->space->id, SpaceAttribute::NAME_PROVINCE, $spaceProvinceCodesSer);
     $provincesNames = Area::areaList2();
     $threadCategory = DAL::get()->find('ThreadCategory', $request->categoryId);
     if ($request->categoryId == self::RECOMMEND_THREADCATEGORY_ALL) {
         list($threadCategoryId, $threadCategory, $threadCategories) = $this->getCategoryInfo($this->space, null);
         $this->getRecommendByCondition($threadCategories, $response, $provincesNames, self::RECOMMEND_THREADCATEGORY_ALL);
     } else {
         $this->getRecommendByCondition(array($threadCategory), $response, $provincesNames, $threadCategory->id);
     }
     return 'success';
 }
    private function detailForSpace($response, $request, Thread $thread)
    {/*{{{*/
        $response->posts = $thread->posts;
        $response->patientapply = $thread->getLastPatientApply();
        $response->buttons = '';
        $response->disease = DAL::get()->find_by_name('Disease', $thread->disease);

        //是否审核后进入下一条
        $spaceAttr = DAL::get()->find_by_fld_spaceuserid_and_name('spaceAttribute', 
            $this->_newSpace->id, Space::ATTR_FLOW_PROCESS);
        $flowProcess = $spaceAttr->isNull() ? SpaceAttribute::FLOW_PROCESS_FORWARD: $spaceAttr->value;
        $response->isFirstTime4FlowProcess = $spaceAttr->isNull()? true: false;
        $response->flowProcess = $flowProcess;

        /** 医生查看,标志Case为已读 */
        ThreadClient::getInstance()->markRead($this->_newUser, $thread);

        extract(FlowClient::getInstance()->getNextUnread4Thread($this->_newSpace));
        $response->nextUrl = $nextUrl;
        $response->nextList = $nextList;
        $response->nextNeedAlert = $nextNeedAlert;
        $response->nextTip = $nextTip;
        $response->editPost = new NullEntity();
        $response->spaceTip = DZoneClient::getInstance()->getSpaceAndPatientTip($this->_newSpace->id, SpaceTip::OBJECT_SPACE);

        /** 用户对其他大夫的咨询 */
        $response->userOtherCaseList = $this->getUserThreads($thread);
        $response->patientAttachments =  $this->_newUser->attachments;

        List($groups, $isResidentEvil, $categoryPairs) = $this->getPatientInfoForDoctor($thread);
        $response->groups = $groups;
        $response->isResidentEvil = $isResidentEvil;
        $response->categoryPairs = $categoryPairs;
    }/*}}}*/
 public function deleteSpaceProperty($request, $response)
 {
     $result = DZoneClient::getInstance()->deleteSpaceProperty($request->ids);
     $response->result = $result;
     $response->actionDesc = "删除";
     $response->id = implode(' ', $request->ids);
     return 'deleteSpacePropertyProcess';
 }