/**
  * Finds the ProductCategories model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ProductCategories the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ProductCategories::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function actionView($categoryslug, $productslug)
 {
     $categoryData = ProductCategories::find()->where(["slug" => $categoryslug])->asArray()->one();
     $productData = Products::find()->where(["slug" => $productslug])->with(["productToppings", "productImages"])->asArray()->one();
     $tagData = ProductTagProducts::find()->where(["product_id" => $productData["id"]])->with(["tag"])->asArray()->all();
     $orderProducts = new OrderProducts();
     return $this->render("view", ["categoryData" => $categoryData, "productData" => $productData, "tagData" => $tagData, "topSelling" => $orderProducts->getTopSellingProducts(9)]);
 }
 public function actionView($justcategory, $tipus = "lista")
 {
     $categoryData = ProductCategories::find()->where(["slug" => $justcategory])->asArray()->one();
     $sort = new Sort(['attributes' => ['ar' => ['asc' => ['price' => SORT_ASC], 'desc' => ['price' => SORT_DESC], 'default' => SORT_DESC, 'label' => 'Ár'], 'termeknev' => ['asc' => ['products.title' => SORT_ASC], 'desc' => ['products.title' => SORT_DESC], 'default' => SORT_DESC, 'label' => 'Név']]]);
     $sort->sortParam = 'rendezes';
     $dataProvider = new ActiveDataProvider(['query' => Products::find()->where(["products.category" => $categoryData["id"]])->with(["productImages", "productToppings", "productCategory"])->orderBy($sort->orders)]);
     if ($tipus == "lista") {
         return $this->render('category_list', ['categoryData' => $categoryData, 'dataProvider' => $dataProvider, 'sort' => $sort, 'type' => $tipus]);
     } else {
         return $this->render('category_grid', ['categoryData' => $categoryData, 'dataProvider' => $dataProvider, 'sort' => $sort, 'type' => $tipus]);
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProductCategories::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
 public function init()
 {
     $categories = ProductCategories::find()->where("parent_id IS NULL")->with("childrens")->asArray()->orderBy("order ASC, title ASC")->all();
     $this->catTree = $categories;
     $cats = [];
     if ($categories) {
         $cats[] = Html::beginTag('div', ['class' => 'absolute container']);
         foreach ($categories as $row) {
             $cats[] = ['label' => $row["title"], 'url' => \Yii::$app->urlManager->createAbsoluteUrl(["/category/view", "justcategory" => $row["slug"]])];
         }
         $cats[] = Html::endTag('div');
         $this->categories = $cats;
     }
     return parent::init();
 }
 public function get($tree = 0, $createQuery = 0, $array = [], $selected = 0)
 {
     $categories = $array;
     if ($createQuery) {
         $query = ProductCategories::query();
         $query->select('ACTIVE as active', 'WEB_ACTIVE as web_active', 'CATEGORY as category', 'DESCRIPT as name', 'PARENTCAT as parent_cat');
         $query->where('ACTIVE', 'T');
         $query->where('WEB_ACTIVE', 'T');
         $categories = $query->get()->toArray();
     }
     if ($tree) {
         return $this->getTree($categories);
     }
     return $this->getCategories($categories, 'parent_cat', null, $selected);
 }
 public function actionIndex()
 {
     $orderProducts = new OrderProducts();
     $productCategories = new ProductCategories();
     return $this->render('index', ["slider" => Slider::find()->orderBy('ordering ASC')->asArray()->all(), "topSelling" => $orderProducts->getTopSellingProducts(9), "categoryProducts" => $productCategories->getCatLowCostProducts()]);
 }
Ejemplo n.º 8
0
        </div>
        <div class="col-sm-4">
            <?php 
echo $form->field($model, 'barcode')->textInput(['maxlength' => true])->hint('Barcode Value of the item');
?>
        </div>
        <div class="col-sm-8">
            <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true])->hint('Name of the item');
?>
        </div>
        <div class="clearfix"></div>

        <div class="col-sm-4">
            <?php 
echo $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(ProductCategories::find()->all(), 'id', 'name'))->hint('Category of the item');
?>
        </div>
        <div class="col-sm-4">
            <?php 
echo $form->field($model, 'warehouse_id')->dropDownList(ArrayHelper::map(Warehouse::find()->all(), 'id', 'name'))->hint('Warehouse Location');
?>
        </div>
        <div class="col-sm-4">
            <?php 
echo $form->field($model, 'status')->dropDownList(HelperComponents::getStatus())->hint('Serve as a tag if the product is available for purchase');
?>
        </div>
        <div class="clearfix"></div>
        <div class="col-sm-3">
            <?php 
 /**
  * Updates an existing Products model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $imageModel = new ProductImages(['scenario' => 'update']);
     $images = $imageModel->getProductImage($id);
     $imageModel->image = $images["image"];
     $tagsModel = new ProductTags();
     $tagsModel->tag_name = $tagsModel->getTagNames($id);
     $toppingsModel = new ProductToppings();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         if (!is_dir($this->imagePath . DIRECTORY_SEPARATOR . $model->slug)) {
             mkdir($this->imagePath . DIRECTORY_SEPARATOR . $model->slug, 0755, true);
         }
         $imageModel->load(\Yii::$app->request->getBodyParams());
         $file = UploadedFile::getInstance($imageModel, 'image');
         if (!is_null($file)) {
             $fileDir = $this->imagePath . DIRECTORY_SEPARATOR . $model->slug . DIRECTORY_SEPARATOR;
             $file->saveAs($fileDir . $file->getBaseName() . "." . $file->getExtension());
             $save = Image::open($fileDir . $file->getBaseName() . "." . $file->getExtension())->zoomCrop(365, 365)->merge(Image::open($this->defaultImagePath . "/logo.png")->cropResize(100, 100), 10, 10)->save($fileDir . $file->getBaseName() . "_thumb." . $file->getExtension(), $file->getExtension(), 80);
             $imageModel->saveImages($model->slug . "/" . $file->getBaseName() . "." . $file->getExtension(), $model->slug . "/" . $file->getBaseName() . "_thumb." . $file->getExtension(), $model->id);
         }
         $tagsModel->saveTags($_POST["ProductTags"]["tag_name"], $model->id);
         $toppingsModel->saveToppings($_POST["ProductToppings"], $model->id);
         return $this->redirect(['index']);
     } else {
         return $this->render('update', ['categories' => ArrayHelper::map(ProductCategories::find()->orderBy('title')->all(), 'id', 'title'), 'model' => $model, 'imageModel' => $imageModel, 'tagsModel' => $tagsModel, 'toppingsModel' => $toppingsModel, 'toppings' => ProductToppings::find()->where(["product_id" => $id])->asArray()->all(), "images" => $images]);
     }
 }
Ejemplo n.º 10
0
                <div class="form-group">
                    <label for="player_select" class="control-label">Select Cashier</label>
                    <div class="">
                        <?php 
echo Html::dropDownList('player_select', isset($posted_data['player_select']) ? $posted_data['player_select'] : null, ['0' => 'All'] + ArrayHelper::map(UserAccounts::find()->all(), 'id', 'name'), ['class' => 'form-control', 'id' => 'player_select']);
?>
                    </div>
                </div>
            </div>
            <div class="clearfix"></div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label for="category_select" class="control-label">Select Category</label>
                    <div class="">
                        <?php 
echo Html::dropDownList('category_select', isset($posted_data['category_select']) ? $posted_data['category_select'] : null, ['0' => 'All'] + ArrayHelper::map(ProductCategories::find()->all(), 'id', 'name'), ['class' => 'form-control', 'id' => 'category_select']);
?>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label for="warehouse_select" class="control-label">Select Warehouse</label>
                    <div class="">
                        <?php 
echo Html::dropDownList('warehouse_select', isset($posted_data['warehouse_select']) ? $posted_data['warehouse_select'] : null, ['0' => 'All'] + ArrayHelper::map(Warehouse::find()->all(), 'id', 'name'), ['class' => 'form-control', 'id' => 'warehouse_select']);
?>
                    </div>
                </div>
            </div>
Ejemplo n.º 11
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProductCategory()
 {
     return $this->hasOne(ProductCategories::className(), ['id' => 'category']);
 }
Ejemplo n.º 12
0
 public function storeCategories()
 {
     return ProductCategories::orderBy('display_order')->lists('name', 'id');
 }