public function addPost($request, $response)
 {
     /*{{{*/
     if (!$this->myProjectOperator->checkAuth('insert')) {
         throw new BizException("您没有权限新增答案");
     }
     $response->projectInterview = $projectInterview = DAL::get()->find("ProjectInterview", $request->projectInterviewId);
     $followupCustomer = $projectInterview->followupCustomer;
     $projectOperatorId = $this->myProjectOperator->id;
     $questionSheetId = $request->questionSheetId;
     $answerData = array();
     foreach ($request->qid as $qid => $q) {
         if ($q['sourcetype'] == 'RadioQuestion' || "MutipleChoiceQuestion" == $q['sourcetype']) {
             if (isset($q['optionIdArr']) && $q['optionIdArr']) {
                 if (is_array($q['optionIdArr'])) {
                     $answerData[$qid]['optionIdArr'] = $q['optionIdArr'];
                 } else {
                     $answerData[$qid]['optionIdArr'] = array($q['optionIdArr']);
                 }
                 $answerData[$qid]['answerContent'] = '';
             }
         } else {
             if ("TextQuestion" == $q['sourcetype'] || "NumericQuestion" == $q['sourcetype']) {
                 $answerData[$qid]['optionIdArr'] = array();
                 if (isset($q['content']) && $q['content']) {
                     $answerData[$qid]['answerContent'] = $q['content'];
                 } else {
                     $answerData[$qid]['answerContent'] = '';
                 }
             }
         }
     }
     $dotime = XDateTime::now();
     $projectAnswerSheetId = ProjectInterviewClient::getInstance()->addProjectAnswerSheet($projectInterview->id, $questionSheetId, $answerData, $dotime, $projectOperatorId);
     $remark = $request->remark;
     ProjectAnswerSheetClient::getInstance()->updateRemark($remark, $projectAnswerSheetId);
     //        if (!$projectInterview->isMaster())
     //        {
     //            $this->synchronousToMasterProjectInterview($projectInterview, $questionSheetId);
     //        }
     ProjectInterviewLogClient::getInstance()->addLog($projectOperatorId, $projectInterview->id, '录入资料', json_encode($answerData));
     $preMsg = $projectAnswerSheetId . "添加成功";
     $response->setRedirect("/projectanswersheetmgr/modify?projectAnswerSheetId=" . $projectAnswerSheetId . "&preMsg=" . $preMsg);
 }
 public function uploadAttachment($request, $response)
 {
     /*{{{*/
     $file = $_FILES['file'];
     $projectOperator = $this->myProjectOperator;
     $followupCustomer = DAL::get()->find("FollowupCustomer", $request->followupCustomerId);
     $user = $followupCustomer->getBindUser();
     $receivetime = $request->receivetime;
     $content = $request->content;
     //        $file['name'] = $content;
     $description = "接收时间:{$receivetime};<br/>资料内容:{$content}";
     $projectInterviewId = $request->projectInterviewId;
     if (isset($projectInterviewId)) {
         $projectInterview = DAL::get()->find("ProjectInterview", $projectInterviewId);
         if (false == $projectInterview instanceof ProjectInterview) {
             throw new BizException("没有找到该次访视!");
         }
         $sourceId = $projectInterview->id;
         $sourceType = get_class($projectInterview);
     } else {
         $sourceId = $followupCustomer->id;
         $sourceType = get_class($followupCustomer);
     }
     $filePath = '';
     $type = $request->type;
     if ($file['error'] == 0) {
         $suffixName = TuClient::getInstance()->getSuffix($file['name']);
         $attach = Uploader::file2attach($user, $file, $suffixName, $sourceId, $sourceType);
         if ($attach instanceof Attachment) {
             $filePath = $attach->filePath;
         }
         AttachClient::getInstance()->modifyDescription($attach->id, $description);
         ProjectInterviewLogClient::getInstance()->addLog($projectOperator->id, $request->projectInterviewId, '接收资料', $content);
         echo "<div style='margin:60px auto auto 140px;'> 上传成功! </div>";
     } else {
         echo "<div style='margin:60px auto auto 140px;'> 上传失败! </div>";
     }
     return parent::DIRECT_OUTPUT;
 }