Esempio n. 1
0
 /**
  * Finds the Subcategory model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Subcategory the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Subcategory::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 2
0
 public function actionGetSubcat($id)
 {
     $countSubcats = Subcategory::find()->where(['category_id' => $id])->count();
     $subcats = Subcategory::find()->where(['category_id' => $id])->orderBy('id ASC')->all();
     if ($countSubcats > 0) {
         foreach ($subcats as $subcat) {
             echo "<option value='" . $subcat->id . "'>" . $subcat->name . "</option>";
         }
     } else {
         echo "<option>-</option>";
     }
     //        echo Json::encode(['output'=>'', 'selected'=>'']);
 }
Esempio n. 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Subcategory::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     $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, 'category_id' => $this->category_id, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
Esempio n. 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSubcategories()
 {
     return $this->hasMany(Subcategory::className(), ['category_id' => 'id'])->where('status="ACTIVE"');
 }
Esempio n. 5
0
                <a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
                    Search
                </a>
            </h4>
        </div>
        <div id="collapseOne" class="panel-collapse collapse">
            <div class="panel-body">
                <div class="ad-search">

                    <?php 
$form = ActiveForm::begin(['action' => ['index'], 'method' => 'get']);
?>
                    
                    <div class="col-sm-4 col-md-4 col-lg-4">
                        <?php 
echo $form->field($model, 'subcategory_id')->label('Subcategory')->dropDownList(['' => ''] + Subcategory::getList());
?>

                        <?php 
echo $form->field($model, 'user_id')->label('User')->dropDownList(['' => ''] + User::getList());
?>
                        
                        <?php 
echo $form->field($model, 'location_id')->label('Location')->dropDownList(['' => ''] + Location::getList());
?>

                        <?php 
echo $form->field($model, 'title');
?>

                        <?php 
Esempio n. 6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSubcategory()
 {
     return $this->hasOne(Subcategory::className(), ['id' => 'subcategory_id']);
 }
Esempio n. 7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSubcategories()
 {
     return $this->hasMany(Subcategory::className(), ['category_id' => 'id']);
 }
Esempio n. 8
0
});
JS;
$this->registerJs($script, View::POS_END);
?>

<div class="product-form">

    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>
    <?php 
echo $form->field($model, 'auction')->dropDownList(['YES' => 'SI', 'NO' => 'NO'], ['prompt' => '¿Producto como subasta?']);
?>

    <?php 
echo $form->field($model, 'subcategory_id')->DropDownList(ArrayHelper::map(Subcategory::find()->all(), 'id', 'name'), ['prompt' => 'Selecciona una subcategoría.']);
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 150]);
?>

    <?php 
echo $form->field($model, 'description')->textarea(['rows' => 6]);
?>

    <?php 
echo $form->field($model, 'stock')->textInput();
?>

    <?php 
Esempio n. 9
0
echo $form->field($model, 'title')->label(false)->textInput(['maxlength' => true, 'class' => 'submitInput']);
?>
                    </div>
                    <div class="labelDiv">
                    <label>Price*</label><?php 
echo $form->field($model, 'price')->label(false)->textInput(['maxlength' => true, 'class' => 'submitInput']);
?>
                    </div>
                    <div class="refineHeadingSpan">
                         <span>Category*</span>
                    </div>
                    <div id="sortContainer">
                                    <div tabindex="0" class="onclick-menu">
                                        <ul class="onclick-menu-content">
                                            <?php 
$subCategories = Subcategory::getList();
?>
                                            <?php 
foreach ($subCategories as $id => $title) {
    ?>
                                            <li data-field="ad-subcategory_id" data-id="<?php 
    echo $id;
    ?>
"><?php 
    echo $title;
    ?>
</li></a>
                                            <?php 
}
?>
                                        </ul>