public function indexAction() { $categories = Categories::find(); echo "TESTING"; $this->logger->info('INDEX'); $this->view->categories = $categories; }
public function actionCategories() { $model = new Categories(); $categories = Categories::find()->all(); $categories_roots = Categories::find()->roots()->all(); if ($model->load(Yii::$app->request->post())) { if (Yii::$app->user->can('createPost') && $model->addCategory()) { Yii::$app->getSession()->addFlash('success', '<b>Категория успешно добавлена!</b>'); } else { Yii::$app->getSession()->addFlash('error', '<b>Произошла ошибка. Запись не добавлена</b>'); } } return $this->render('categories', ['categories' => $categories, 'roots' => $categories_roots, 'model' => $model]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Categories::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(['categoryId' => $this->categoryId, 'createdDate' => $this->createdDate, 'updatedDate' => $this->updatedDate]); $query->andFilterWhere(['like', 'categoryName', $this->categoryName])->andFilterWhere(['like', 'status', $this->status]); return $dataProvider; }
?> </td> <td id="productId<?php echo $model['Saleid']; ?> " contentEditable="true"><?php echo $model['productId']; ?> </td> <td contentEditable="true"><?php echo Html::activeDropDownList($model, 'Brand', ArrayHelper::map(Brandsmaster::find()->all(), 'brandName', 'brandName'), ['id' => 'brand' . $model['Saleid']]); ?> </td> <td contentEditable="true"><?php echo Html::activeDropDownList($model, 'categoryName', ArrayHelper::map(Categories::find()->all(), 'categoryName', 'categoryName'), ['id' => 'categoryId' . $model['Saleid']]); ?> </td> <td id="quntity<?php echo $model['Saleid']; ?> " contentEditable="true"><?php echo $model['Quantity']; ?> </td> <td id="uom<?php echo $model['Saleid']; ?> " contentEditable="true"><?php echo $model['uom']; ?>
echo Html::submitButton('Добавить', ['class' => 'btn btn-primary', 'name' => 'signup-button']); ?> </div> <?php ActiveForm::end(); ?> </div> </div> <h1 style="text-align:center;">Список категорий</h1> <?php $categories = Categories::find()->orderBy('tree,lft, rgt')->all(); $level = 0; foreach ($categories as $n => $category) { if ($category->depth == $level) { echo "</li> \n"; } else { if ($category->depth > $level) { echo "<ul>\n"; } else { echo "</li>\n"; for ($i = $level - $category->depth; $i; $i--) { echo "</ul>\n"; echo "</li>\n"; } } }
<div id="imaginary_container"> <div class="input-group stylish-input-group"> <?php echo $form->field($searchModel, 'productId')->textInput(array('placeholder' => 'Product code'))->label(false); ?> </div> </div> </div> <div class="col-md-3"> <?php echo $form->field($searchModel, 'Brand')->dropDownList(ArrayHelper::map(Brandsmaster::find()->all(), 'brandName', 'brandName'), ['prompt' => 'Select Brand'])->label(false); ?> </div> <div class="col-md-3"> <?php echo $form->field($searchModel, 'categoryName')->dropDownList(ArrayHelper::map(Categories::find()->all(), 'categoryName', 'categoryName'), ['prompt' => 'Select Category'])->label(false); ?> </div> <?php ActiveForm::end(); ?> </div> <div class="row"> <div class="col-md-12"> <div class="student-form"> </div>
?> ">Brand</label> <?php echo Html::activeDropDownList($model, 'Brand', ArrayHelper::map(Brandsmaster::find()->all(), 'brandName', 'brandName'), ['prompt' => 'Select Brand', 'class' => 'form-control', 'id' => 'vendorproducts-brand' . $cnt]); ?> </div> </div> <div class="col-md-4"> <div class="form-group"> <label class="control-label" for="vendorproducts-categoryname<?php echo $cnt; ?> ">Category Name</label> <?php echo Html::activeDropDownList($model, 'categoryName', ArrayHelper::map(Categories::find()->all(), 'categoryName', 'categoryName'), ['prompt' => 'Select categoryName', 'class' => 'form-control', 'id' => 'vendorproducts-categoryname' . $cnt]); ?> </div> </div> </div> <!--row 1 end--> <div class="row"> <!--row 2--> <div class="col-md-4"> <div class="form-group"> <label class="control-label" for="vendorproducts-quantity">Qty</label> <?php echo Html::activeInput('text', $model, 'Quantity[]', ['class' => 'form-control', 'id' => 'vendorproducts-quantity']); ?> </div>
public static function getCategoryId($catName) { $categoryName = Categories::find()->select('categoryId')->where(['categoryName' => $catName])->one(); return $categoryName['categoryId']; }
<?php echo $form->field($model, 'productId')->dropDownList(ArrayHelper::map(Products::find()->all(), 'productCode', 'productName'), ['prompt' => 'Select Product']); ?> </div> </div> <div class="col-md-4"> <div class="form-group"> <?php echo $form->field($model, 'Brand')->dropDownList(ArrayHelper::map(Brandsmaster::find()->all(), 'brandName', 'brandName'), ['prompt' => 'Select Brand']); ?> </div> </div> <div class="col-md-4"> <div class="form-group"> <?php echo $form->field($model, 'categoryName')->dropDownList(ArrayHelper::map(Categories::find()->all(), 'categoryName', 'categoryName'), ['prompt' => 'categoryName']); ?> </div> </div> </div> <!--row 1 end--> <div class="row"> <!--row 2--> <div class="col-md-4"> <div class="form-group"> <?php echo $form->field($model, 'Quantity')->textInput(['maxlength' => true]); ?> </div>
?> <div class="form-group col-lg-6 col-sm-12"> <?php echo $form->field($model, 'productCode')->textInput(['maxlength' => true]); ?> </div> <div class="form-group col-lg-6 col-sm-12"> <?php echo $form->field($model, 'productName')->textInput(['maxlength' => true]); ?> </div> <div class="form-group col-lg-6 col-sm-12"> <?php echo $form->field($model, 'categoryId')->dropDownList(ArrayHelper::map(Categories::find()->orderBy(['categoryName' => SORT_ASC])->all(), 'categoryId', 'categoryName'), ['prompt' => 'categoryName']); ?> </div> <div class="form-group col-lg-6 col-sm-12"> <?php echo $form->field($model, 'status')->dropDownList(['Active' => 'Active', 'In-active' => 'In-active'], ['prompt' => 'Status']); ?> </div> <!-- image file upload process --> <div class="form-group col-lg-6 col-sm-12"> <?php
$form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'dname')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'description')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'price')->textInput(); ?> <?php echo $form->field($model, 'idcategory')->dropDownList(ArrayHelper::map(Categories::find()->all(), 'idcategory', 'cname'), ['prompt' => 'Select category']); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>