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)); }