/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProductCategory::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'cat_title', $this->cat_title])->andFilterWhere(['like', 'cat_desc', $this->cat_desc]);
     return $dataProvider;
 }
Esempio n. 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProductCategory::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $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, 'parent_id' => $this->parent_id, 'position' => $this->position, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status, 'is_active' => $this->is_active, 'is_hot' => $this->is_hot]);
     $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'old_slugs', $this->old_slugs])->andFilterWhere(['like', 'image_path', $this->image_path])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'banner', $this->banner])->andFilterWhere(['like', 'created_by', $this->created_by])->andFilterWhere(['like', 'updated_by', $this->updated_by])->andFilterWhere(['like', 'link', $this->link]);
     return $dataProvider;
 }
Esempio n. 3
0
 public function init()
 {
     parent::init();
     $this->languages_codeToName = ArrayHelper::map(Language::find()->all(), 'code', 'name');
     $this->languages_idToName = ArrayHelper::map(Language::find()->all(), 'id', 'name');
     $this->currencies_idToName = ArrayHelper::map(Currency::find()->all(), 'id', 'name');
     $this->parent_productCategories_idToSlug = ArrayHelper::map(ProductCategory::find()->where(['parent_id' => null])->all(), 'id', 'slug');
     foreach ($this->parent_productCategories_idToSlug as $id => $slug) {
         $this->productCategories_idToSlug[$slug] = ArrayHelper::map(ProductCategory::find()->where(['parent_id' => $id])->all(), 'id', 'slug');
     }
     is_array($this->productCategories_idToSlug) or $this->productCategories_idToSlug = array();
     $this->productCollections_idToSlug = ArrayHelper::map(ProductCollection::find()->all(), 'id', 'slug');
     I18n::$currency_params = ['exchange_rate' => 1, 'prefix' => '', 'suffix' => 'đ', 'thousand_separator' => '.', 'decimal_point' => ',', 'number_digits_after_decimal_point' => 0];
 }
Esempio n. 4
0
 public static function get_subcategory_list($parent)
 {
     $html = '';
     $child_pages = ProductCategory::find()->joinWith('cat_rel')->where(['category_self_rel.parent_cat_id' => $parent])->all();
     if (!empty($child_pages)) {
         $html .= '<ul>';
         foreach ($child_pages as $key => $value) {
             $html .= '<li><a href="#" data_cat_id="' . $value->id . '">' . $value->cat_title . '</a></li>';
             self::get_subcategory_list($value->id, $html);
         }
         $html .= '</ul>';
     }
     return $html;
 }
Esempio n. 5
0
	                <a class="btn btn-default btn-xs full-box" href="javascript:;">
	                  <i class="fa fa-expand fa-compress"></i>
	                </a> 
	                <a class="btn btn-danger btn-xs close-box" href="javascript:;">
	                  <i class="fa fa-times"></i>
	                </a> 
	              </nav>
	            </div><!-- /.toolbar -->
	          </header>
	          <div class="body full-screen-box collapse in" id="div-1" aria-expanded="true" style="">
	            <form class="form-horizontal">
	              <div class="form-group">
	                <label class="control-label col-lg-12" style="text-align:left; padding-bottom:5px;">Select Category</label>
	                <div class="col-lg-12">
	                  	<?php 
$data = ArrayHelper::map(ProductCategory::find()->joinWith('cat_rel')->where(['product_category_self_rel.parent_cat_id' => 0])->all(), 'id', 'cat_title');
echo Select2::widget(['model' => $ProductCategorySelfRel, 'attribute' => 'parent_cat_id', 'data' => ProductCategory::getHierarchy_cat(), 'options' => ['placeholder' => 'Select Category ...', 'multiple' => false], 'pluginOptions' => ['allowClear' => true]]);
?>
	                </div>
	              </div><!-- /.form-group -->
	              
	            </form>
	          </div>
	        </div>
	    </div>

	    <div class="col-md-12">

	        <div class="box dark full-screen-box">
	          <header>
	            <div class="icons">
Esempio n. 6
0
 public function actionGet_product_sub_cat()
 {
     if (Yii::$app->request->isAjax) {
         $id = $_POST['id'];
         $child_categories_q = ProductCategory::find()->joinWith('cat_rel')->where(['product_category_self_rel.parent_cat_id' => $id])->all();
         $html = '';
         if (!empty($child_categories_q)) {
             $html .= '<ul>';
             foreach ($child_categories_q as $key) {
                 $html .= '<li><a href="#" data_cat_id="' . $key->id . '">' . $key->cat_title . '</a></li>';
                 $html .= ProductCategory::get_subcategory_list($key->id);
             }
             $html .= '</ul>';
             $response['files'] = ['msg' => $html];
         } else {
             $response['files'] = ['msg' => 'Sorry no subcategory found.'];
         }
         return json_encode($response);
     }
 }
 public function actionProductcat()
 {
     $user = new AdminUser();
     if (!$user->checkUserIsLogin()) {
         $this->redirect(Variable::$home_url);
         return;
     }
     $query = ProductCategory::find();
     $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
     $countries = $query->orderBy('addTime DESC')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render(Variable::$productCat_view, ['countries' => $countries, 'pagination' => $pagination]);
 }
Esempio n. 8
0
 /**
  * Displays a single Settings model.
  * @param integer $id
  * @return mixed
  */
 public function actionTabular_input()
 {
     $model = new ProductCategory();
     $query = ProductCategory::find()->indexBy('id');
     // where `id` is your primary key
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pagesize' => 5]]);
     $models = $dataProvider->getModels();
     if (Yii::$app->request->isAjax) {
         if (isset($_POST['ProductCategory']) && isset($_POST['ProductCategory']['cat_create'])) {
             $model = new ProductCategory();
             $model->attributes = $_POST['ProductCategory'];
             if ($model->save()) {
                 $response['files'] = ['ok'];
                 $response['result'] = 'success';
                 $model_uu = new ProductCategory();
                 $query = ProductCategory::find()->indexBy('id');
                 // where `id` is your primary key
                 $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pagesize' => 5]]);
                 $models = $dataProvider->getModels();
                 $response['post_list'] = $this->renderAjax('ajax_cont', ['dataProvider' => $dataProvider, 'model' => $model_uu]);
                 return json_encode($response);
             } else {
                 $response['result'] = 'error';
                 $response['files'] = Html::errorSummary($model);
                 return json_encode($response);
             }
         } else {
             if (ProductCategory::loadMultiple($models, Yii::$app->request->post()) && ProductCategory::validateMultiple($models)) {
                 $count = 0;
                 foreach ($models as $index => $model) {
                     // populate and save records for each model
                     if ($model->save()) {
                         $count++;
                     }
                 }
                 Yii::$app->session->setFlash('success', "Processed {$count} records successfully.");
                 $response['files'] = "Processed {$count} records successfully.";
                 $response['result'] = 'success';
                 return json_encode($response);
             }
         }
     }
     return $this->render('tabular_input', ['dataProvider' => $dataProvider, 'model' => $model]);
 }