public function actiongetPreNextId() { $preId = ''; $nextId = ''; $preDisabled = ''; $nextDisabled = ''; $needToConfirmStr = '$needToConfirm = false;'; $id = (int) $_GET['id']; $infoType = $_GET['type']; $productId = (int) $_GET['product_id']; $preNextSql = Yii::app()->user->getState($productId . '_' . $infoType . '_prenextsql'); if (isset($id) && isset($preNextSql)) { $idSearchResult = Yii::app()->db->createCommand($preNextSql)->queryAll(); list($preId, $nextId) = InfoService::getPreNextValue($idSearchResult, $id); } if ('' == $preId) { $preDisabled = 'disabled'; } if ('' == $nextId) { $nextDisabled = 'disabled'; } $listStr = CHtml::button(Yii::t('Common', 'Previous') . '(P)', array('onclick' => $needToConfirmStr . 'location.href="' . Yii::app()->createUrl('info/edit', array('type' => $infoType, 'id' => $preId)) . '"', 'class' => 'btn', 'disabled' => $preDisabled, 'accesskey' => 'P')); $listStr .= CHtml::button(Yii::t('Common', 'Next') . '(N)', array('onclick' => $needToConfirmStr . 'location.href="' . Yii::app()->createUrl('info/edit', array('type' => $infoType, 'id' => $nextId)) . '"', 'class' => 'btn', 'disabled' => $nextDisabled, 'accesskey' => 'N')); echo $listStr; }
public static function getSearchableField($productId) { $searchAbleArr = self::getBasicSearchFieldConfig($productId); if (!empty($productId)) { $searchAbleArr['solution'] = array('label' => BugInfo::model()->getAttributeLabel('solution'), 'type' => Info::$InputType['option'], 'isBasic' => true, 'value' => InfoService::getBugSolutionOptions($productId)); $customSearchAbleFieldArr = ProductService::getSearchableCostomField('bug', $productId); $searchAbleArr = array_merge($searchAbleArr, $customSearchAbleFieldArr); } return $searchAbleArr; }
public static function getActionCleanContent($actionInfo, $type, $id) { $actionStr = $actionInfo['created_at'] . ' '; if ('bug' == $type && BugInfo::ACTION_RESOLVE == $actionInfo['action_type']) { $mixedInfo = InfoService::loadModel($type, $id); $bugInfo = $mixedInfo->getBasicInfo(); $actionStr .= '<strong>' . Yii::t('BugInfo', $actionInfo['action_type']) . '</strong> as <strong>' . $bugInfo['solution'] . '</strong> by <strong>' . CommonService::getUserRealName($actionInfo['created_by']) . '</strong>'; } else { $actionStr .= '<strong>' . Yii::t('BugInfo', $actionInfo['action_type']) . '</strong> by <strong>' . CommonService::getUserRealName($actionInfo['created_by']) . '</strong>'; } return $actionStr; }
public function actionIndex() { $this->layout = '//layouts/index'; $expandClass = $this->getExpandClassName(); $infoType = $this->getInfoType(); $productId = $this->getProductId($infoType); $accessProductIdNameArr = Yii::app()->user->getState('visit_product_list'); $productName = $accessProductIdNameArr[$productId]; $defaultShowFieldArr = SearchService::getDefaultShowFieldArr($infoType); $showFieldArr = $this->getShowFieldArr($defaultShowFieldArr, $infoType, $productId); $queryTitle = $this->getQueryTitle($productId, $infoType); $productModuleId = $this->getModuleId($productId, $infoType); $searchRowArr = InfoService::getBlankSearchRowArr($productName, $productModuleId, $infoType); $searchFieldConfig = SearchService::getSearchableFields($infoType, $productId); $defaultSelectFieldOptionStr = SearchService::getSelectFieldsOption($searchFieldConfig, $defaultShowFieldArr); $defaultShowFieldOptionStr = SearchService::getShowFieldsOption($searchFieldConfig, $defaultShowFieldArr); $templateStr = InfoService::getTemplateStr($productId, $infoType, Yii::app()->user->id); $leftMenu = UserQueryService::getQueryLinkStr($productId, $infoType, Yii::app()->user->id); //not request from post query, save query and reset query $filterSql = ''; $filterColumn = ''; if (!empty($_POST['queryaction'])) { Yii::app()->user->setState($productId . '_' . $infoType . '_filterSql', null); Yii::app()->user->setState($productId . '_' . $infoType . '_filterColumn', null); if (!empty($_POST['reset'])) { Yii::app()->user->setState($productId . '_' . $infoType . '_showField', null); Yii::app()->user->setState($productId . '_' . $infoType . '_search', null); } else { if (!empty($_POST['saveQuery'])) { $result = UserQueryService::editUserQuery($queryTitle, $productId, $infoType, $_POST[Info::QUERY_GROUP_NAME]); if (CommonService::$ApiResult['FAIL'] == $result['status']) { CommonService::jsAlert(Yii::t('Common', 'save query fail')); } CommonService::testRefreshSelf(); } if (isset($_POST[Info::QUERY_GROUP_NAME])) { $searchCondition = $_POST[Info::QUERY_GROUP_NAME]; $searchRowArr = SearchService::getSearchConditionArr($searchCondition); } } } else { if (isset($_GET['query_id'])) { $searchRowArr = $this->getSavedSearchRow($productId, $infoType, $_GET['query_id']); Yii::app()->user->setState($productId . '_' . $infoType . '_filterSql', null); Yii::app()->user->setState($productId . '_' . $infoType . '_filterColumn', null); $productModuleId = $this->getSavedQueryModuleId($searchRowArr, $productId, $infoType); } else { $sessionSearchRowArr = Yii::app()->user->getState($productId . '_' . $infoType . '_search'); if ($sessionSearchRowArr !== null) { $searchRowArr = $sessionSearchRowArr; } } if (!empty($_GET['filter'])) { $filterArr = CommonService::splitStringToArray('|', $_GET['filter']); if (Info::$InputType['date'] == $searchFieldConfig[$filterArr[0]]['type']) { $filterSql = $filterArr[0] . " like '" . addslashes($filterArr[1]) . "%'"; } else { $filterSql = $filterArr[0] . " = '" . addslashes($filterArr[1]) . "'"; } $filterColumn = $filterArr[0]; Yii::app()->user->setState($productId . '_' . $infoType . '_filterSql', $filterSql); Yii::app()->user->setState($productId . '_' . $infoType . '_filterColumn', $filterArr[0]); } else { $sessionFilterColumn = Yii::app()->user->getState($productId . '_' . $infoType . '_filterColumn'); if ($sessionFilterColumn !== null) { $filterSql = Yii::app()->user->getState($productId . '_' . $infoType . '_filterSql'); $filterColumn = $sessionFilterColumn; } } } if (isset($_GET['productmodule_id'])) { $searchRowArr[0]['leftParenthesesName'] = ''; $searchRowArr[0]['field'] = 'module_name'; $searchRowArr[0]['rightParenthesesName'] = ''; $searchRowArr[0]['operator'] = 'UNDER'; $searchRowArr[0]['andor'] = 'And'; $searchRowArr[0]['value'] = ''; $selectedModuleInfo = ProductModule::model()->findByPk($_GET['productmodule_id']); if ($selectedModuleInfo !== null) { $searchRowArr[0]['value'] = $productName . '/' . $selectedModuleInfo->full_path_name; } else { $searchRowArr[0]['value'] = $productName; } } $searchRowArr = $this->setSpecialModuleCondiftion($searchRowArr, $productName); Yii::app()->user->setState($productId . '_' . $infoType . '_search', $searchRowArr); $getSqlResult = SqlService::baseGetGroupQueryStr($searchFieldConfig, $infoType, $searchRowArr); if (CommonService::$ApiResult['FAIL'] == $getSqlResult['status']) { $whereStr = ' 1<>1 '; } else { $whereStr = $getSqlResult['detail']; } if ('' != $filterSql) { $whereStr .= ' and ' . $filterSql; } $selectFieldOptionStr = SearchService::getSelectFieldsOption($searchFieldConfig, $showFieldArr); $showFieldOptionStr = SearchService::getShowFieldsOption($searchFieldConfig, $showFieldArr); $defaultSelectFieldOptionStr = addslashes($defaultSelectFieldOptionStr); $defaultSelectFieldOptionStr = str_replace(array("\r\n", "\r", "\n"), "", $defaultSelectFieldOptionStr); $defaultShowFieldOptionStr = addslashes($defaultShowFieldOptionStr); $defaultShowFieldOptionStr = str_replace(array("\r\n", "\r", "\n"), "", $defaultShowFieldOptionStr); $jsValueStr = SearchService::getJsValueOption($this, $searchFieldConfig); $jsOperatorStr = SearchService::getJsOperatorOption($searchFieldConfig); $searchConditionHtml = SearchService::getSearchHtml($infoType, $searchFieldConfig, $searchRowArr); $searchConditionHtmlTemplate = SearchService::getSearchConditionRowHtml(Info::TEMPLATE_NUMBER, $searchFieldConfig, InfoService::getTemplateSearchRowArr()); $searchConditionHtmlTemplate = addslashes($searchConditionHtmlTemplate); $searchConditionHtmlTemplate = str_replace(array("\r\n", "\r", "\n"), "", $searchConditionHtmlTemplate); $showType = Yii::app()->user->getState($productId . '_' . $infoType . '_showtype'); if (empty($showType)) { $showType = Info::SHOW_TYPE_GRID; } $relatedFields = $this->getRelatedFields($searchRowArr, $showFieldArr); $isAllBasicField = SearchService::isAllBasicField(SearchService::getBasicFieldArr($infoType), $relatedFields); $renderArr = array('expandClass' => $expandClass, 'productId' => $productId, 'productModuleId' => $productModuleId, 'infoType' => $infoType, 'searchFieldConfig' => $searchFieldConfig, 'selectFieldOptionStr' => $selectFieldOptionStr, 'showFieldOptionStr' => $showFieldOptionStr, 'defaultSelectFieldOptionStr' => $defaultSelectFieldOptionStr, 'defaultShowFieldOptionStr' => $defaultShowFieldOptionStr, 'searchConditionHtml' => $searchConditionHtml, 'searchConditionHtmlTemplate' => $searchConditionHtmlTemplate, 'queryTitle' => $queryTitle, 'jsValueStr' => $jsValueStr, 'jsOperatorStr' => $jsOperatorStr, 'leftMenu' => $leftMenu, 'templateStr' => $templateStr, 'showType' => $showType, 'showMyQueryDiv' => Yii::app()->user->getState('my_query_div')); if ($showType == Info::SHOW_TYPE_GRID) { $renderArr = array_merge($renderArr, $this->getGridShowContent($searchFieldConfig, $showFieldArr, $infoType, $productId, $filterColumn, $whereStr, $isAllBasicField)); $renderArr['rowCssClassExpressionStr'] = InfoService::getRowCssClassExpressionStr($infoType); } $this->render('index', $renderArr); }
/** * This is save info function, use it whatever saving or updating * * @param string $lowerItem * @param array $fields * @param array $systemFields * @param string $actionType * @return array */ public function saveInfo($lowerItem, $fields, $systemFields, $actionType, $compatible = false) { $item = ucfirst($lowerItem); $modelName = $item . 'InfoView'; $model = new $modelName(); $basicInfoFields = array_keys($model->attributes); $basicInfoFields[] = 'action_note'; $basicInfo = array(); $customInfo = array(); $isNeedBBCodeTransfer = true; if (isset($fields['no_bbcode_transfer']) && !empty($fields['no_bbcode_transfer'])) { $isNeedBBCodeTransfer = false; } foreach ($fields as $key => $field) { if (in_array($key, $systemFields)) { continue; } if ($compatible) { if ('AssignedTo' == $key || 'ScriptedBy' == $key) { $field = $this->getRealNameByName($field); } else { if ('MailTo' == $key) { $field = $this->getRealNamesByMailTo($field); } } $key = $this->fieldOld2New($key, $lowerItem); } if ($isNeedBBCodeTransfer && in_array($key, array('action_note', 'repeat_step', 'case_step', 'result_step'))) { $field = BBCode::bbcode2html($field); } if ('no_bbcode_transfer' != $key && !in_array($key, $basicInfoFields)) { $customInfo[$key] = $field; continue; } $basicInfo[$key] = $field; } if (Info::ACTION_OPEN == $actionType && isset($basicInfo['id'])) { unset($basicInfo['id']); } if (Info::ACTION_OPEN_EDIT == $actionType && 'bug' == $lowerItem && isset($basicInfo['id'])) { $bug = BugInfo::model()->findByPk($basicInfo['id']); if (!isset($basicInfo['bug_status'])) { $basicInfo['bug_status'] = $bug->bug_status; } if (null !== $bug) { switch ($basicInfo['bug_status']) { case BugInfo::STATUS_ACTIVE: if (BugInfo::STATUS_ACTIVE !== $bug->bug_status) { $actionType = BugInfo::ACTION_ACTIVATE; } else { $actionType = BugInfo::ACTION_OPEN_EDIT; } break; case BugInfo::STATUS_RESOLVED: if (BugInfo::STATUS_RESOLVED !== $bug->bug_status) { $actionType = BugInfo::ACTION_RESOLVE; } else { $actionType = BugInfo::ACTION_RESOLVE_EDIT; } break; case BugInfo::STATUS_CLOSED: if (BugInfo::STATUS_CLOSED !== $bug->bug_status) { $actionType = BugInfo::ACTION_CLOSE; } else { $actionType = BugInfo::ACTION_CLOSE_EDIT; } break; default: break; } } } $code = API::ERROR_NONE; $attachmentFile = CUploadedFile::getInstancesByName('attachment_file'); $result = InfoService::saveInfo($lowerItem, $actionType, $basicInfo, $customInfo, $attachmentFile); $info = $result['detail']; if (CommonService::$ApiResult['FAIL'] === $result['status']) { $code = API::ERROR_SAVE_INFO; } return array($code, $info); }
echo empty($customfield['result_related']) ? '' : $customfield['result_related']; ?> <div class="row"> <?php echo $form->label($model, 'related_case_id'); ?> <?php echo InfoService::getRelatedIdHtml('case', $model->related_case_id); ?> </div> <div class="row"> <?php echo $form->label($model, 'related_bug'); ?> <?php echo InfoService::getRelatedIdHtml('bug', $model->related_bug); ?> </div> </fieldset> <fieldset> <legend><?php echo Yii::t('Common', 'Attachments'); ?> </legend> <?php echo $model->attachment_file; ?> </fieldset> </div> </div>
/** * 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); }
<div class="row"> <?php echo $form->label($model, 'related_case'); ?> <?php echo $form->textField($model, 'related_case', array('class' => 'info_input', 'maxlength' => 255)); ?> </div> <div class="row"> <?php echo $form->label($model, 'related_result'); ?> <?php echo InfoService::getRelatedIdHtml('result', $model->related_result); ?> </div> </fieldset> <fieldset> <legend> <?php echo Yii::t('Common', 'Attachments') . '(' . TestFileService::getFileSize(CommonService::getMaxFileSize()) . ')'; ?> </legend> <?php echo $model->attachment_file; ?> <?php $this->widget('CMultiFileUpload', array('model' => $model, 'name' => 'attachment_file', 'accept' => '', 'htmlOptions' => array('size' => 16), 'remove' => '<img src="' . Yii::app()->theme->baseUrl . '/assets/images/deletefile.gif" alt="remove" />', 'options' => array()));
<?php echo empty($customfield['bug_related']) ? '' : $customfield['bug_related']; ?> <div class="row"> <?php echo $form->labelEx($model, 'related_bug'); ?> <?php echo InfoService::getRelatedIdHtml('bug', $model->related_bug); ?> </div> <?php $isShowCaseResultTab = Yii::app()->params['showCaseResultTab']; if ($isShowCaseResultTab) { $caseResultStr = '<div class="row">' . $form->label($model, 'related_case') . InfoService::getRelatedIdHtml('case', $model->related_case) . '</div>'; $caseResultStr .= '<div class="row">' . $form->label($model, 'related_result') . InfoService::getRelatedIdHtml('result', $model->related_result) . '</div>'; echo $caseResultStr; } ?> </fieldset> <fieldset> <legend><?php echo Yii::t('Common', 'Attachments'); ?> </legend> <?php echo $model->attachment_file; ?> </fieldset>
/** * import sheet data to bugfree * * @param mixed $sheet file or string * @param string $infoType */ public function import($sheet, $productId, $infoType, $productModuleId) { $sheetConv = new SheetConv(); $data = $sheetConv->xml2array($sheet); $results = array(); // sheet index foreach ($data as $sidx => $items) { $sheetResult = array(); // item index foreach ($items as $iidx => $item) { // hard code for product_id $basicInfo = array('product_id' => $productId, 'productmodule_id' => $productModuleId); $customInfo = array(); $isEmpty = true; foreach ($item as $key => $val) { unset($item[$key]); list($field, $isBasic) = $this->fieldConv($key, $productId, $infoType); if ($field) { if ($isBasic) { $basicInfo[$field] = $val; } else { $customInfo[$field] = $val; } } if ('' != $val) { $isEmpty = false; } } if (!$isEmpty) { $action = Info::ACTION_IMPORT; if (isset($basicInfo['id']) && '' != trim($basicInfo['id'])) { if (Info::TYPE_BUG == $infoType) { $sheetResult[] = array('status' => CommonService::$ApiResult['FAIL'], 'detail' => array(Yii::t('Common', 'can not update bug by import'))); continue; } else { $existedCaseInfo = CaseInfo::model()->findByPk((int) $basicInfo['id']); $resultInfo = array(); if (empty($existedCaseInfo)) { $resultInfo['status'] = CommonService::$ApiResult['FAIL']; $resultInfo['detail']['id'] = '[id:' . $basicInfo['id'] . ']' . Yii::t('Common', 'Requested object does not exist'); $sheetResult[] = $resultInfo; continue; } else { $basicInfo['action_note'] = ''; //import action_note only when doing new action if ($productId != $existedCaseInfo['product_id']) { $resultInfo['status'] = CommonService::$ApiResult['FAIL']; $resultInfo['detail']['id'] = Yii::t('Common', 'product is different'); $sheetResult[] = $resultInfo; continue; } } } } $basicInfo = $this->basicInfoConv($basicInfo, $infoType); $sheetResult[] = InfoService::saveInfo($infoType, $action, $basicInfo, $customInfo, array(), array()); } } $results[$sidx] = $sheetResult; } return $this->getResultMsg($results); }
protected function beforeSave() { if ($this->isNewRecord) { $this->reopen_count = 0; } else { if (BugInfo::ACTION_ACTIVATE == $this->scenario) { $this->reopen_count += 1; } } if (!$this->isNewRecord && self::DUPLICATE_SOLUTION == $this->solution) { $oldRecord = self::model()->findByPk($this->id); $oldDuplicatedIdArr = CommonService::splitStringToArray(',', $oldRecord->duplicate_id); $duplicatedIdArr = CommonService::splitStringToArray(',', $this->duplicate_id); $diffDuplicatedIdArr = array_diff($duplicatedIdArr, $oldDuplicatedIdArr); foreach ($diffDuplicatedIdArr as $dupId) { $basicInfo = new BugInfo(); $basicInfo->id = $dupId; $basicInfo->action_note = 'Bug #<a href="Bug.php?BugID=' . $this->id . '" target="_blank">' . $this->id . '</a> is resolved as duplicate to this bug.'; $addActionResult = InfoService::addActionNotes(Info::TYPE_BUG, Info::ACTION_OPEN_EDIT, $basicInfo, array('basic' => array(), 'custom' => array())); } } return parent::beforeSave(); }
<img id="create_div_more" src="<?php echo Yii::app()->theme->baseUrl . '/assets/images/create_down.gif'; ?> "> </div> <div id="create_template_div" class="createtemplate" style="display:none;" onmouseover="inNewDiv = true;"> <?php echo $templateStr; ?> </div> <div id="leftindex" class="<?php echo $expandClass; ?> "> <?php echo '<div class="leftmenu">' . InfoService::getProductSelect($productId, $infoType) . '</div>'; ?> <div id="product_module_tree" class="leftmenu" style="overflow-y:scroll;overflow-x: auto;padding-top: 0px;margin-top: 0px;"></div> <?php $this->widget('application.extensions.ztree.ZTreeWidget', array('name' => 'product_module_tree', 'id' => 'product_module_tree', 'value' => 0, 'zNodes' => '[]', 'setting' => '{ showIcon: false, showLine: true, treeNodeKey: "id", expandSpeed: "", async: true, asyncUrl: "' . Yii::app()->createUrl('search/getProductModule') . '", asyncParam: ["id"], asyncParamOther : ["product_id", ' . $productId . ',"productmodule_id",' . $productModuleId . '], callback: { click:reloadPage, asyncSuccess:zTreeOnAsyncSuccess