/** * Save info page * * @author youzhao.zxw<*****@*****.**> * @param String $infoType bug,case or result * @param Object $model basic info attributes * @param array $customInfo custom information * @param array $attachmentFile attachment information * @param CController $controller save info related controller * @param String $actionType edit action type * @param array $request user requested info * @return array save result info */ public static function saveInfoPage($infoType, $model, $customInfo, $attachmentFile, $controller, $actionType, $request) { $basicModelName = ucfirst(strtolower($infoType)) . 'InfoView'; $basicInfo = $request->getParam($basicModelName); if (Info::TYPE_RESULT == $infoType) { $basicInfo['result_step'] = ResultStepService::removeSelectFromResultStep($basicInfo['result_step']); } $model->attributes = $basicInfo; $productId = $basicInfo['product_id']; if (!empty($model->id)) { $basicInfo['id'] = $model->id; } $postedCustomInfo = $request->getParam('Custom'); if (isset($postedCustomInfo)) { $customInfo = self::filterCustomInfo($infoType, $customInfo, $postedCustomInfo); } //save to template $templateTitleTmp = $request->getParam('templateTitle'); if (isset($templateTitleTmp) && '' != trim($templateTitleTmp)) { $result = InfoService::saveTemplate($basicInfo, $customInfo, $infoType, $templateTitleTmp); if (CommonService::$ApiResult['SUCCESS'] == $result['status']) { CommonService::testRefreshParent(); Yii::app()->user->setFlash('successMessage', $result['detail']['id']); } else { Yii::app()->user->setFlash('failMessage', $result['detail']['id']); } } else { $requestIdArr = array(); $resultId = $request->getParam('result_id'); $caseId = $request->getParam('case_id'); if (isset($resultId)) { $requestIdArr['result_id'] = $resultId; } if (isset($caseId)) { $requestIdArr['case_id'] = $caseId; } if (Info::TYPE_RESULT == $infoType && ResultInfo::ACTION_BATCH_OPEN == $actionType) { $getBatchCaseIdResult = self::getBatchCaseId($basicInfo['product_id']); if (CommonService::$ApiResult['FAIL'] == $getBatchCaseIdResult['status']) { $result = $getBatchCaseIdResult; } else { $caseIdArr = $getBatchCaseIdResult['detail']; $result = self::batchCreateResult($caseIdArr, $actionType, $basicInfo, $customInfo, $attachmentFile); } } else { $result = self::saveInfo($infoType, $actionType, $basicInfo, $customInfo, $attachmentFile, $requestIdArr); } if (CommonService::$ApiResult['SUCCESS'] == $result['status']) { CommonService::testRefreshParent(); CommonService::sysObFlush(CommonService::jsGoto(Yii::app()->createUrl('info/edit', array('type' => $infoType, 'id' => $result['detail']['id'])), 'parent')); // $controller->redirect(array('edit', 'type' => $infoType, 'id' => $result['detail']['id'])); } } if (CommonService::$ApiResult['FAIL'] == $result['status']) { $model->addErrors($result['detail']); $customFieldArr = FieldConfigService::getCustomFieldConfig($productId, $infoType, $controller, $actionType, $result['detail'], $customInfo); } else { $customFieldArr = FieldConfigService::getCustomFieldConfig($productId, $infoType, $controller, $actionType, array(), $customInfo); } return array($model, $customFieldArr); }