/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = CsProperties::find(); // add conditions that should always apply here $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; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'type' => $this->type]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'class', $this->class]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getProperties() { return $this->hasMany(CsProperties::className(), ['unit_id' => 'id']); }
use kartik\select2\Select2; use yii\helpers\ArrayHelper; use kartik\widgets\FileInput; ?> <?php $form = kartik\widgets\ActiveForm::begin(['id' => 'form-horizontal', 'type' => ActiveForm::TYPE_HORIZONTAL, 'fullSpan' => 7, 'formConfig' => ['labelSpan' => 3, 'deviceSize' => ActiveForm::SIZE_MEDIUM], 'options' => ['enctype' => 'multipart/form-data']]); ?> <?php echo $form->field($model, 'object_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\common\models\CsObjects::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'Izaberite...'], 'language' => 'sr-Latn', 'changeOnReset' => false]); ?> <?php echo $form->field($model, 'property_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\common\models\CsProperties::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'Izaberite...'], 'language' => 'sr-Latn', 'changeOnReset' => false]); ?> <?php echo $form->field($model, 'property_unit_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\common\models\CsUnits::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'Izaberite...'], 'language' => 'sr-Latn', 'changeOnReset' => false]); ?> <?php echo $form->field($model, 'property_unit_imperial_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\common\models\CsUnits::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'Izaberite...'], 'language' => 'sr-Latn', 'changeOnReset' => false]); ?> <?php echo $form->field($model, 'property_class')->dropDownList(['public' => 'Public', 'private' => 'Private', 'protected' => 'Protected'], ['prompt' => '']); ?> <?php
/** * @return \yii\db\ActiveQuery */ public function getProperty() { return $this->hasOne(CsProperties::className(), ['id' => 'property_id']); }
/** * Finds the CsProperties model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return CsProperties the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = CsProperties::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @inheritdoc */ public function queryMethods() { if ($presMethods = Yii::$app->request->get('PresentationMethods') and $service = $this->service) { //echo '<pre>'; //print_r($presSpecs); die(); $arrMeth = ''; foreach ($presMethods as $key => $presMethod) { if (is_array($presMethod) and (isset($presMethod['value']) and $presMethod['value'] != '' or isset($presMethod['method_models']) and $presMethod['method_models'] != '')) { $property = \common\models\CsProperties::findOne($key); $arrMeth .= '(presentation_action_properties.action_property_id=' . $presMethod['method_id'] . ' AND '; if ($property->type == 1 or $property->type == 5) { if ($presMethod['value'] != '') { // ako je provajderov predmet, onda je range $arrMeth .= '(presentation_action_properties.value>' . $presMethod['value'] . ' OR presentation_action_properties.value IS NULL)'; } else { $arrMeth .= '1=1'; } } if ($property->type == 2 or $property->type == 21 or $property->type == 3 or $property->type == 4 or $property->type == 41) { if (isset($presMethod['method_models']) and $presMethod['method_models'] != '') { $arrMethPref = '('; foreach ($presMethod['method_models'] as $mth_mdl) { $arrMethPref .= 'presentation_action_property_values.property_value_id=' . $mth_mdl . ' OR '; } $arrMethPref = substr($arrMethPref, 0, -4); $arrMethPref .= ')'; $arrMeth .= $arrMethPref; } else { $arrMeth .= '1=1'; } } $arrMeth .= ') OR '; } } return $arrMeth != '' ? substr($arrMeth, 0, -4) : []; } return []; }
/** * Kreira Modele PresentationSpecs za sve izabrane specifikacije. */ public function loadPresentationSpecificationsIndex($model_object_properties) { if ($model_object_properties) { foreach ($model_object_properties as $key => $model_object_property) { $property = \common\models\CsProperties::findOne($key); $model_object_property->theObjectProperty = $model_object_property->objectProperty; $model_object_property->property = $property; $model_object_property->service = $this->pService; $model_object_property->checkUserObject = $this->checkUserObjectsExist($this->pService, $this->objectModels) ? 0 : 1; } return $model_object_properties; } return null; }
?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model_trans, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model_trans, 'name_akk')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'property_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\common\models\CsProperties::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'Izaberi svojstvo ...'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model_trans, 'hint')->textArea(['rows' => 4]); ?> <?php echo $form->field($model, 'type')->dropDownList(['1' => 'number', '2' => 'radio', '21' => 'radioButton', '22' => 'radio', '23' => 'radioButton', '3' => 'select', '31' => 'select2', '32' => 'select_media', '4' => 'multiselect', '41' => 'checkboxButton', '42' => 'multiselect_select', '43' => 'multiselect_select2', '44' => 'multiselect_media', '5' => 'checkbox', '6' => 'text', '7' => 'textarea', '8' => 'slider', '9' => 'range', '10' => 'date', '11' => 'time', '12' => 'datetime', '13' => 'email', '14' => 'url', '15' => 'color', '16' => 'date range'], ['prompt' => '']); ?> <?php echo $form->field($model, 'multiple_values')->widget(CheckboxX::classname(), ['pluginOptions' => ['size' => 'sm']]); ?> <?php