public function writeprojectdetailAction() { try { $manager = $this->session->get('Manager'); $project_id = $manager->project_id; #添加项目判断,是否有被试答题,若有答题则不能更新配置的模块 $result = $this->modelsManager->createBuilder()->columns(array('COUNT(Examinee.id) as count'))->from('Examinee')->join('QuestionAns', 'Examinee.id = QuestionAns.examinee_id AND Examinee.project_id = ' . $project_id)->getQuery()->execute(); $result = $result->toArray(); if ($result[0]['count'] > 0) { $this->dataReturn(array('error' => '已有被试答题,项目模块不可再修改!')); return; } if ($manager) { $module_names = array(); $checkeds = $this->request->getpost('checkeds'); $values = $this->request->getpost('values'); $i = 0; foreach ($checkeds as $value) { if ($value == 'true') { $module_names[] = PmDB::getModuleName($values[$i]); } $i++; } #全选情况 $project_detail_info = array(); $index_names = array(); if (count($module_names) == 10) { $index = Index::find(); foreach ($index as $index_record) { $index_names[] = $index_record->name; } $factor = Factor::find(); $factor_names = array(); foreach ($factor as $factor_record) { $factor_names[] = $factor_record->name; } $question = Question::find(); $examination = array(); foreach ($question as $question_record) { $paper_name = Paper::findFirst($question_record->paper_id)->name; $examination[$paper_name][] = $question_record->number; } $project_detail_info['exam_json'] = json_encode($examination, JSON_UNESCAPED_UNICODE); } else { #所有相关指标名数组 $index_names = PmDB::getIndexName($module_names); #所有相关因子名数组 $factor_names = PmDB::getFactorName($index_names); #所有相关试卷下题目的数组 $examination = PmDB::getQuestionName($factor_names); $project_detail_info['exam_json'] = json_encode($examination, JSON_UNESCAPED_UNICODE); } #因子分类 以及寻找子因子 $factors = PmDB::getAllDividedFactors($factor_names); $project_detail_info['factor_names'] = json_encode($factors, JSON_UNESCAPED_UNICODE); $project_detail_info['module_names'] = implode(',', $module_names); $project_detail_info['index_names'] = implode(',', $index_names); $project_detail_info['project_id'] = $project_id; #插入到project_detail 并更新状态 PmDB::insertProjectDetail($project_detail_info); #模块配置的类型设为true #需求量表的上传设为false $this->dataReturn(array('success' => true)); return; } else { $this->dataBack(array('error' => "您的身份验证出错!请重新登录!")); return; } } catch (Exception $e) { $this->dataReturn(array('error' => $e->getMessage())); return; } }