Example #1
0
 /**
  * 规格删除
  */
 public function actionDelete()
 {
     $spec_id = $this->get('spec_id');
     $result = Specification::model()->deleteAll('spec_id = :spec_id', array(':spec_id' => $spec_id));
     if (!$result) {
         $Specification = new Specification();
         $this->message('error', CHtml::errorSummary($Specification), $this->createUrl('index'));
     }
     $result = SpecValues::model()->deleteAll('spec_id = :spec_id', array(':spec_id' => $spec_id));
     if ($result) {
         $this->message('success', '删除成功', $this->createUrl('index'));
     } else {
         $SpecValues = new SpecValues();
         $this->message('error', CHtml::errorSummary($SpecValues), $this->createUrl('index'));
     }
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Specification the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Specification::model()->findByPk($id);
     // if($model===null)
     // 	throw new CHttpException(404,'The requested page does not exist.');
     return $model;
 }
Example #3
0
 /**
  * 类型添加
  */
 public function actionCreate()
 {
     if ($_POST) {
         $GoodsType = new GoodsType();
         $GoodsType->attributes = $this->post('Type');
         $type_brand_attributes = $this->post('TypeBrand');
         //商品类型主表修改
         $result = $GoodsType->save();
         if (!$result) {
             $GoodsType = new GoodsType();
             $this->message('error', CHtml::errorSummary($GoodsType), $this->createUrl('index'));
         }
         $type_id = Yii::app()->db->getLastInsertID();
         //类型-品牌
         if ($type_brand_attributes) {
             $TypeBrand = new TypeBrand();
             $result = $TypeBrand->brand_type_update($type_id, $type_brand_attributes);
             if (!$result) {
                 $this->message('error', CHtml::errorSummary($TypeBrand), $this->createUrl('index'));
             }
         }
         //类型-扩展属性
         $type_props_attributes = $this->post('TypeProps');
         if (isset($type_props_attributes['props_id']) && $type_props_attributes['props_id']) {
             $GoodsTypePropsRelation = new GoodsTypePropsRelation();
             $result = $GoodsTypePropsRelation->props_update($type_id, $type_props_attributes['props_id']);
             if (!$result) {
                 $this->message('error', CHtml::errorSummary($GoodsTypePropsRelation), $this->createUrl('index'));
             }
         }
         //类型-规格
         $type_props_spec = $this->post('Spec');
         if (isset($type_props_spec['spec_id']) && $type_props_spec['spec_id']) {
             $GoodsTypeSpec = new GoodsTypeSpec();
             $result = $GoodsTypeSpec->spec_update($type_id, $type_props_spec['spec_id']);
             if (!$result) {
                 $this->message('error', CHtml::errorSummary($GoodsTypeSpec), $this->createUrl('index'));
             }
         }
         $this->message('success', '创建成功', $this->createUrl('index'));
     }
     //品牌列表
     $model['brand_list'] = Brand::model()->findAll('disabled = :disabled', array(':disabled' => 'false'));
     //规格
     $model['spec_list'] = Specification::model()->findAll('disabled = :disabled', array(':disabled' => 'false'));
     $this->render('create', array('model' => $model));
 }