Beispiel #1
0
 /**
  * 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);
 }
Beispiel #2
0
            })           
        }
    }
    $(function(){
        $('select.'+resultStepSelectClassName).bind('change',function(){syncResultStep($(this));});
    })
</script>
<div class="form">

<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'result-info-form', 'enableAjaxValidation' => false, 'htmlOptions' => array('enctype' => 'multipart/form-data')));
if (ResultInfo::ACTION_BATCH_OPEN != $actionType) {
    if (!empty($_GET['step_run'])) {
        $model->result_step = ResultStepService::handleResultStep($model->result_step);
    } elseif (!empty($model->id)) {
        $model->result_step = ResultStepService::getWithResultStep($model->result_step);
    }
}
?>
	<?php 
echo $form->errorSummary($model);
?>
        <?php 
echo $form->hiddenField($model, 'deleted_file_id', array('value' => '', 'class' => 'deleted_file_id_class'));
?>
        <?php 
//lock_version should be the keyword to check if this record has been modified by other action
echo $form->hiddenField($model, 'lock_version', array('value' => $model->lock_version));
echo $form->hiddenField($model, 'product_id');
echo $form->hiddenField($model, 'result_step');
echo CHtml::hiddenField('templateTitle');