/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = MaterialTypes::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, 'measurement_type' => $this->measurement_type]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'status', $this->status]); return $dataProvider; }
public function actionPrice() { //echo $id= $_GET['id'];exit; $searchModel = new MaterialTypesSearch(); $model = new CustomerDetails(); $customer_id = $_REQUEST['id']; $searchModel->customer = $customer_id; if (isset($_POST['price'])) { $selected = $_POST['price']; foreach ($selected as $key => $val) { $objMaterialPrice = new CustomerMaterialPrice(); $material_id = $key; $material_price = $val; $count = CustomerMaterialPrice::find()->where(['customer_id' => $customer_id, 'material_id' => $material_id])->count(); if ($count > 0) { $objMaterialPrice = CustomerMaterialPrice::findOne(['customer_id' => $customer_id, 'material_id' => $material_id]); } $objMaterialPrice->customer_id = $customer_id; $objMaterialPrice->material_id = $material_id; $objMaterialPrice->price = $material_price; $objMaterialPrice->status = 1; $objMaterialPrice->save(); // print_r($objMaterialPrice->getErrors()); // echo "<pre>";print_r($objMaterialPrice->attributes); // exit; } } $query = MaterialTypes::find(); //$query->joinWith(['milkProduction']); $dataProvider = new ActiveDataProvider(['query' => $query]); return $this->render('price', ['model' => $model, 'dataProvider' => $dataProvider, 'searchModel' => $searchModel]); }
/** * Finds the MaterialTypes model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return MaterialTypes the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = MaterialTypes::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
echo $form->field($model, 'buyer')->dropDownList(ArrayHelper::map(CustomerDetails::find()->where(['status' => 1, 'customer_type' => 2])->all(), 'id', 'name'), ['prompt' => 'Select Buyer', 'style' => 'width:500px', 'onChange' => 'buyerAmount();']); ?> <?php echo $form->field($model, 'vehicle_id')->dropDownList(ArrayHelper::map(VehicleDetails::find()->where(['status' => 1])->all(), 'id', 'name'), ['prompt' => 'Select Vehicle', 'style' => 'width:500px', 'id' => 'vehicle-id', 'onChange' => 'calculateKMA();']); ?> <?php echo $form->field($model, 'driver_id')->widget(DepDrop::classname(), ['options' => ['id' => 'driver_id', 'style' => 'width:500px'], 'data' => ArrayHelper::map(DriverDetails::find()->where(['status' => 1, 'customer_type' => 3])->all(), 'id', 'name'), 'pluginOptions' => ['depends' => ['vehicle-id'], 'placeholder' => 'Select driver', 'url' => Url::to(['/business/driver/driverlist'])]]); ?> <?php echo $form->field($model, 'material_id')->dropDownList(ArrayHelper::map(MaterialTypes::find()->where(['status' => 1])->all(), 'id', function ($model, $defaultValue) { return $model->name . ' - ' . MaterialTypes::$measurementType[$model->measurement_type]; }), ['prompt' => 'Select Material', 'style' => 'width:500px', 'onChange' => 'merchantAmount();buyerAmount();']); ?> <?php echo $form->field($model, 'size')->textInput(['maxlength' => 100, 'style' => 'width:500px', 'onChange' => 'merchantAmount();buyerAmount();']); ?> <?php echo $form->field($model, 'site_name')->textInput(['maxlength' => 250, 'style' => 'width:500px']); ?> <?php echo $form->field($model, 'site_place')->textInput(['maxlength' => 250, 'style' => 'width:500px']);