/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Warehouse::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(['warehouse_id' => $this->warehouse_id, 'restaurant_id' => $this->restaurant_id, 'product_id' => $this->product_id, 'price' => $this->price]); $query->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Warehouse::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])->andFilterWhere(['like', 'location', $this->location]); return $dataProvider; }
public function exportRestaurantMenuToCsv($id) { $restaurantName = Restaurant::findOne(['restaurant_id' => $id])->name; Yii::$app->params['uploadPath'] = Yii::$app->basePath . '/web/upload/'; $string = "name, description, price \n"; $product = null; foreach (Warehouse::find()->where(['restaurant_id' => $id])->batch(1) as $warehouse) { try { $product = Product::findOne(['product_id' => $warehouse[0]->product_id]); $string .= '"' . $product->name . '","' . $product->description . '","' . $warehouse[0]->price . '"'; $string .= "\n"; } catch (Exception $e) { } } $path = $this->saveStringToCsvFile($string, $restaurantName); $this->giveUserFile($path); }
</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 echo $form->field($model, 'buy_price', ['addon' => ['prepend' => ['content' => '₱'], 'append' => ['content' => '.00']]])->textInput(['class' => 'text-align-right'])->hint('Buy price per item'); ?> </div> <div class="col-sm-3"> <?php
<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> <div class="clearfix"></div> <div class="col-sm-6"> <div class="form-group"> <label for="products_select" class="control-label">Select Products</label> <div class=""> <?php echo Select2::widget(['name' => 'products_select', 'value' => isset($posted_data['products_select']) ? $posted_data['products_select'] : 0, 'data' => ['0' => 'All'] + ArrayHelper::map(Products::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'Select Products ...', 'class' => 'form-control', 'id' => 'products_select']]); ?> </div> </div>
private function getAllWarehouse() { $warehouse = Warehouse::find()->where(['uid' => Yii::$app->user->id])->all(); $warehouse_array = array(); foreach ($warehouse as $item) { $name = $item->getAttribute('name'); $warehouse_array[$name] = $name; } return $warehouse_array; }
protected function findModel($id) { Yii::$app->response->format = Response::FORMAT_JSON; if (($model = Warehouse::find()->where(['warehouse_id' => $id])->one()) !== null) { return $model; } else { echo json_encode(array('status' => 0, 'error_code' => Codes::$BAD_REQUEST, 'message' => StatusCodeMessage::$BAD_REQUEST), JSON_PRETTY_PRINT); exit; // throw new NotFoundHttpException('The requested page does not exist.'); } }