Beispiel #1
0
 public function actionEdit()
 {
     $actionName = Yii::t('Product', 'Add Product');
     $this->breadcrumbs = array(Yii::t('Product', 'Back To Product List') => array('index'));
     if (isset($_GET['id'])) {
         $model = ProductService::loadModel($_GET['id']);
         $actionName = Yii::t('Product', 'Edit Product');
         $this->breadcrumbs[] = $model->name;
     } elseif (isset($_GET['source_id'])) {
         $model = ProductService::loadModel($_GET['source_id']);
         $model->name = '';
         $model->display_order = '';
         $model->product_manager = '';
         $model->group_name = '';
         $actionName = Yii::t('Product', 'Copy Product');
     } else {
         $model = new Product();
         $model->solution_value = "By Design,Duplicate,External,Fixed,Not Repro,Postponed,Won't Fix";
     }
     self::checkEditable($model->id);
     if (isset($_POST['Product'])) {
         $model->attributes = $_POST['Product'];
         $productInfo = $_POST['Product'];
         if (isset($_GET['id'])) {
             $productInfo['id'] = $_GET['id'];
         }
         if (isset($_GET['source_id'])) {
             $editResult = ProductService::copyProduct($_GET['source_id'], $productInfo);
         } else {
             $editResult = ProductService::editProduct($productInfo);
         }
         $returnJson['status'] = $editResult['status'];
         $returnJson['detail'] = $editResult['detail'];
         if ($editResult['status'] == CommonService::$ApiResult['SUCCESS']) {
             if (isset($_GET['id'])) {
                 $returnJson['detail'] = Yii::t('Product', 'Product edited successfully');
             } elseif (isset($_GET['source_id'])) {
                 $returnJson['detail'] = Yii::t('Product', 'Product copied successfully');
             } else {
                 $returnJson['detail'] = Yii::t('Product', 'Product added successfully');
             }
         }
         echo json_encode($returnJson);
         return;
     }
     $this->render('edit', array('model' => $model, 'actionName' => $actionName));
 }
Beispiel #2
0
 /**
  * get bug's solution options
  *
  * @author                                  youzhao.zxw<*****@*****.**>
  * @param   int     $productId              product id
  * @return  array                           bug's solution array
  */
 public static function getBugSolutionOptions($productId)
 {
     $productInfo = ProductService::loadModel($productId);
     $solutionValueStr = $productInfo->solution_value;
     $solutionArr = CommonService::splitStringToArray(',', $solutionValueStr);
     $optionArr = array();
     $optionArr[''] = '';
     foreach ($solutionArr as $solution) {
         $optionArr[$solution] = $solution;
     }
     return $optionArr;
 }
Beispiel #3
0
 /**
  * Get project module List, including the root module '/'
  *
  * @author                      Yupeng Lee<*****@*****.**>
  * @param   int    $ProjectID
  * @param   string $ModuleType  Bug or Case
  * @return  array  $ModuleList
  */
 private static function getProductModuleList($productId)
 {
     $ProjectInfo = ProductService::loadModel($productId);
     $ParentID = '0';
     $LastModuleID = '0';
     $ModuleList = array('0' => array('ModuleID' => 0, 'ParentID' => '', 'name' => $ProjectInfo['name'], 'IDPath' => '0', 'NamePath' => '/', 'IsLeaf' => true, 'IsLastLeaf' => true, 'grade' => '0', 'ChildIDs' => '0'));
     $ProductModuleList = self::getModuleList($productId);
     $ModuleList += $ProductModuleList;
     foreach ($ModuleList as $ModuleID => $ModuleInfo) {
         if ($ModuleID == '0') {
             continue;
         }
         $ModuleList[$ModuleID]['IsLastLeaf'] = true;
         if ($ParentID == $ModuleInfo['parent_id']) {
             $ModuleList[$LastModuleID]['IsLastLeaf'] = false;
         }
         $ParentID = $ModuleInfo['parent_id'];
         $ParentIDPath = $ModuleList[$ParentID]['IDPath'];
         $ParentNamePath = $ModuleList[$ParentID]['NamePath'];
         if ($ParentIDPath == '') {
             $ParentIDPath = '0';
         }
         $ModuleList[$ModuleID]['IDPath'] = $ParentIDPath . ',' . $ModuleID;
         if ($ParentNamePath == '/') {
             $ParentNamePath = '';
         }
         $ModuleList[$ModuleID]['NamePath'] = $ParentNamePath . '/' . $ModuleInfo['name'];
         $ModuleList[$ModuleID]['IsLeaf'] = true;
         if ($ParentID != '') {
             $ModuleList[$ParentID]['IsLeaf'] = false;
             $ModuleList[$ParentID]['IsLastLeaf'] = false;
         }
         $ModuleList[$LastModuleID]['NextTreeModuleID'] = $ModuleID;
         $LastModuleID = $ModuleID;
     }
     return $ModuleList;
 }