public function actionCreate()
 {
     self::validateAdmin();
     $platformList = Platform::getPlatformListByAdmin();
     $genreList = Genre::getGenresListByAdmin();
     if (isset($_POST['submit'])) {
         $option['code'] = $_POST['code'];
         $option['name'] = $_POST['name'];
         $option['price'] = $_POST['price'];
         $option['platform_id'] = $_POST['platform_id'];
         $option['genre_id'] = $_POST['genre_id'];
         $option['brand'] = $_POST['brand'];
         $option['description'] = $_POST['description'];
         $option['availability'] = $_POST['availability'];
         $option['is_recomend'] = $_POST['is_recomend'];
         $option['is_new'] = $_POST['is_new'];
         $option['status'] = $_POST['status'];
         $errors = false;
         if (!isset($option['name']) || empty($option['name'])) {
             $errors[] = "Введите имя товара";
             print_r($errors);
         }
         if ($errors == false) {
             $id = Products::createProduct($option);
             if ($id) {
                 if (is_uploaded_file($_FILES['image']['tmp_name'])) {
                     move_uploaded_file($_FILES['image']['tmp_name'], $_SERVER["DOCUMENT_ROOT"] . "/upload/images/products/(" . $id . ").png");
                 }
             }
             header("Location: /evkazolinAdminka/product/");
         }
     }
     require_once ROOT . '/views/admin_product/create.php';
     return true;
 }
예제 #2
0
 /**
  * 商品规格
  */
 public function actionSpec()
 {
     $goods_id = $this->get('goods_id');
     $goods_row = Goods::model()->find('goods_id = :goods_id', array(':goods_id' => $goods_id));
     if ($_POST) {
         $product_attributes = $this->post('Product');
         $Product = new Products();
         $result = $Product->createProduct($goods_id, $goods_row, $product_attributes);
         if ($result) {
             $this->message('success', '编辑成功', $this->createUrl('index'));
         } else {
             $this->message('error', '编辑失败', $this->createUrl('index'));
         }
     }
     //商品规格
     $GoodsTypeSpec = new GoodsTypeSpec();
     $items = $GoodsTypeSpec->TypeSpecValue($goods_row['type_id']);
     $spec_list_t = $GoodsTypeSpec->ProductSpecList($goods_id);
     $spec_list = array();
     foreach ($spec_list_t as $v) {
         $spec_list[$v['spec_id']] = $v;
     }
     //货品列表
     $product_list = Products::model()->findAll('goods_id = :goods_id AND spec_desc <> :spec_desc AND disabled = :disabled', array(':goods_id' => $goods_id, ':spec_desc' => '', ':disabled' => 'false'));
     echo $this->render('spec', array('items' => $items, 'spec_list' => $spec_list, 'goods_row' => $goods_row, 'product_list' => $product_list));
 }