Example #1
0
 /**
  * 品牌
  */
 public function actionOct()
 {
     $brand_id = 24;
     $type_brand_list = TypeBrand::model()->findAll('brand_id = :brand_id', array(':brand_id' => $brand_id));
     $TypeBrand = new TypeBrand();
     $type_ids = implode(',', $TypeBrand->getFindAllids($type_brand_list, 'type_id'));
     //类型列表
     $type_list = GoodsType::model()->findAllBySql('SELECT * FROM car_b2c_goods_type WHERE type_id IN (' . $type_ids . ')');
     //价格区间
     $type_price_item = array();
     foreach ($type_list as $v) {
         $price = unserialize($v->price);
         if (empty($price)) {
             continue;
         }
         $type_price_item = $price;
     }
     //商品属性值
     $goods_type_props_list = GoodsTypeProps::model()->findAllBySql('SELECT * FROM car_b2c_goods_type_props WHERE type_id IN (' . $type_ids . ')');
     $Goodstypeprops = new GoodsTypeProps();
     $props_ids = implode(',', $Goodstypeprops->getFindAllids($goods_type_props_list, 'props_id'));
     //商品属性值数据
     $goods_type_props_value_list = GoodsTypePropsValue::model()->findAllBySql('SELECT * FROM car_b2c_goods_type_props_value WHERE props_id IN (' . $props_ids . ')');
     $goods_type_props_value_item = array();
     foreach ($goods_type_props_value_list as $v) {
         $goods_type_props_value_item[$v->props_id][] = $v;
     }
     //规格
     /*提交数据到页面*/
     $data = array('type_list' => $type_list, 'goods_type_props_list' => $goods_type_props_list, 'goods_type_props_value_item' => $goods_type_props_value_item, 'type_price_item' => $type_price_item);
     $this->render('oct', $data);
 }
Example #2
0
 /**
  * 分类添加
  */
 public function actionCreate()
 {
     $GoodsCat = new GoodsCat();
     if ($_POST) {
         $cat_attributes = $this->post('Cat');
         $cat_attributes['parent_id'] = $cat_attributes['parent_id'] ? $cat_attributes['parent_id'] : 0;
         $cat_path = ',';
         if ($cat_attributes['parent_id']) {
             $parent_row = GoodsCat::model()->find('cat_id = :cat_id', array(':cat_id' => $cat_attributes['parent_id']));
             $cat_path = $parent_row['cat_path'];
         }
         $cat_attributes['cat_path'] = $cat_attributes['parent_id'] ? $cat_path . $cat_attributes['parent_id'] . ',' : ',';
         $GoodsCat->attributes = $cat_attributes;
         if ($GoodsCat->save()) {
             $this->referrer();
         } else {
             $this->message('error', CHtml::errorSummary($GoodsCat), $this->createUrl('index'));
         }
     }
     $result = $GoodsCat->CatList(0, $this->pagesize);
     $model['parent'] = $result['item'];
     //商品类型
     $type_list = GoodsType::model()->findAll();
     $type_arr = array();
     if ($type_list) {
         foreach ($type_list as $v) {
             $type_arr[$v['type_id']] = $v['name'];
         }
     }
     $model['type'] = $type_arr;
     if ($this->get('parent_id')) {
         $model['cat_row']['parent_id'] = $this->get('parent_id');
     }
     $this->render('create', array('model' => $model));
 }
Example #3
0
 /**
  * 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 GoodsType the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = GoodsType::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #4
0
 /**
  * 品牌创建
  */
 public function actionCreate()
 {
     if ($_POST) {
         $Brand = new Brand();
         $Brand->attributes = $this->post('Brand');
         $type_attributes = $this->post('GoodsType');
         if (!$Brand->save()) {
             $Brand = new Brand();
             $this->message('error', CHtml::errorSummary($Brand), $this->createUrl('index'));
         }
         if ($type_attributes) {
             $brand_id = Yii::app()->db->getLastInsertID();
             $TypeBrand = new TypeBrand();
             $result = $TypeBrand->type_brand_insert($brand_id, $type_attributes);
             if (!$result) {
                 $this->message('error', CHtml::errorSummary($TypeBrand), $this->createUrl('index'));
             }
         }
         $this->referrer();
     }
     $model['type_list'] = GoodsType::model()->findAll('disabled = :disabled', array(':disabled' => 'false'));
     $this->render('create', array('model' => $model));
 }
 /**
  * Manages all models.
  */
 public function actionAdmin()
 {
     $type_id = Yii::app()->request->getParam("type_id");
     $model_type = GoodsType::model()->findByPk($type_id);
     $model = new GoodsCategory('search');
     $model->unsetAttributes();
     // clear any default values
     if (!is_null($type_id)) {
         $model->type_id = $type_id;
     }
     if (isset($_GET['GoodsCategory'])) {
         $model->attributes = $_GET['GoodsCategory'];
     }
     $this->render('admin', array('model' => $model, 'model_type' => $model_type));
 }
Example #6
0
 /**
  * 类型删除
  */
 public function actionDelete()
 {
     $type_id = $this->get('type_id');
     //商品类型主表修改
     $type_attributes['disabled'] = 'true';
     $type_attributes['lastmodify'] = time();
     $result = GoodsType::model()->updatebypk($type_id, $type_attributes);
     if (!$result) {
         $GoodsType = new GoodsType();
         $this->message('error', CHtml::errorSummary($GoodsType), $this->createUrl('index'));
     }
     //类型-品牌
     $result = TypeBrand::model()->deleteAll('type_id = :type_id', array(':type_id' => $type_id));
     if (!$result) {
         $TypeBrand = new TypeBrand();
         $this->message('error', CHtml::errorSummary($TypeBrand), $this->createUrl('index'));
     }
     //类型-扩展属性
     $result = GoodsTypePropsRelation::model()->deleteAll('type_id = :type_id', array(':type_id' => $type_id));
     if (!$result) {
         $GoodsTypePropsRelation = new GoodsTypePropsRelation();
         $this->message('error', CHtml::errorSummary($GoodsTypePropsRelation), $this->createUrl('index'));
     }
     //类型-规格
     $result = GoodsTypeSpec::model()->deleteAll('type_id = :type_id', array(':type_id' => $type_id));
     if (!$result) {
         $GoodsTypeSpec = new GoodsTypeSpec();
         $this->message('error', CHtml::errorSummary($GoodsTypeSpec), $this->createUrl('index'));
     }
     $this->message('success', '删除成功', $this->createUrl('index'));
 }
 /**
  * 商品添加
  */
 public function actionCreate()
 {
     if ($_POST) {
         $Goods = new Goods();
         $ImageImage = new ImageImage();
         $goods_attributes = $this->post('Goods');
         //判断货号是否存在
         $bn_goods = Goods::model()->find('bn = :bn', array(':bn' => $goods_attributes['bn']));
         if ($bn_goods) {
             $this->message('error', '货号冲突', $this->createUrl('index'));
         }
         $goods_attributes['update_time'] = time();
         $Goods->attributes = $goods_attributes;
         if (!$Goods->save()) {
             $this->message('error', CHtml::errorSummary($Goods), $this->createUrl('index'));
         }
         $goods_id = Yii::app()->db->getLastInsertID();
         //商品图片
         $image_attributes = $this->post('Image');
         $image_attach_attributes = $this->post('ImageAttach');
         $image_ids = $this->post('ImageId');
         $result = $ImageImage->imageList($image_attributes, $image_attach_attributes, $image_ids, $goods_id);
         if (!$result) {
             $this->message('error', CHtml::errorSummary($ImageImage), $this->createUrl('index'));
         }
         //创建货品
         $product_attributes = array('goods_id' => $goods_id, 'bn' => $goods_attributes['bn'], 'price' => $goods_attributes['price'], 'cost' => $goods_attributes['cost'], 'mktprice' => $goods_attributes['mktprice'], 'name' => $goods_attributes['name'], 'weight' => $goods_attributes['weight'], 'unit' => $goods_attributes['unit'], 'store' => $goods_attributes['store'], 'freez' => 0, 'goods_type' => 'normal', 'is_default' => 'true', 'uptime' => time(), 'marketable' => 'true');
         $Product = new Products();
         $Product->attributes = $product_attributes;
         if (!$Product->save()) {
             $this->message('error', CHtml::errorSummary($Product), $this->createUrl('index'));
         }
         $this->referrer();
     }
     //商品类型
     $type_list = GoodsType::model()->findAll();
     $type_arr = array();
     if ($type_list) {
         foreach ($type_list as $v) {
             $type_arr[$v->type_id] = $v->name;
         }
     }
     //品牌
     $TypeBrand = new TypeBrand();
     $model['brand'] = $TypeBrand->type_brand();
     $model['type'] = $type_arr;
     $this->render('create', array('model' => $model));
 }