Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Leshoz::find();
     $query->joinWith(['region']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     // Add extended sorts for related tables
     $dataProvider->sort->attributes['region.nazva'] = ['asc' => [Oblasti::tableName() . '.nazva' => SORT_ASC], 'desc' => [Oblasti::tableName() . '.nazva' => SORT_DESC]];
     $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, 'id_obl' => $this->id_obl, 'Data_dogovora' => $this->Data_dogovora, 'post_index' => $this->post_index, 'post_obl' => $this->post_obl, 'post_region' => $this->post_region]);
     $query->andFilterWhere(['like', 'nazva', $this->nazva])->andFilterWhere(['like', 'N_dogovora', $this->N_dogovora])->andFilterWhere(['like', 'kerivnyk', $this->kerivnyk])->andFilterWhere(['like', 'post_town', $this->post_town])->andFilterWhere(['like', 'post_address', $this->post_address])->andFilterWhere(['like', 'email', $this->email]);
     // ->andFilterWhere(['like', 'region.nazva', $this->region]);
     return $dataProvider;
 }
Esempio n. 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $filter)
 {
     $query = Journal::find();
     $query->joinWith(['company', 'kind', 'type']);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['N_year' => SORT_ASC]]]);
     // Add extended sorts for related tables
     $dataProvider->sort->attributes['company.nazva'] = ['asc' => [Leshoz::tableName() . '.nazva' => SORT_ASC], 'desc' => [Leshoz::tableName() . '.nazva' => SORT_DESC]];
     $dataProvider->sort->attributes['kind.nazva_short'] = ['asc' => [Poroda::tableName() . '.nazva_short' => SORT_ASC], 'desc' => [Poroda::tableName() . '.nazva_short' => SORT_DESC]];
     $dataProvider->sort->attributes['type.type'] = ['asc' => [TestType::tableName() . '.type' => SORT_ASC], 'desc' => [TestType::tableName() . '.type' => SORT_DESC]];
     $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, 'N_total' => $this->N_total, 'N_year' => $this->N_year, 'id_leshoz' => $this->id_leshoz, 'id_poroda' => $this->id_poroda, 'date_start' => $this->date_start, 'date_end' => $this->date_end, 'date_pasport' => $this->date_pasport, 'masa' => $this->masa, 'masa_zrazka' => $this->masa_zrazka, 'energy' => $this->energy, 'shozh' => $this->shozh, 'chistota' => $this->chistota, 'masa_1000' => $this->masa_1000, 'klass' => $this->klass, 'date_doc' => $this->date_doc, 'id_type' => $this->id_type, 'N_prev' => $this->N_prev, 'v_rahunok' => $this->v_rahunok, 'id_bill' => $this->id_bill, 'id_koef' => $this->id_koef]);
     $query->andFilterWhere(['like', 'N_pasport', $this->N_pasport])->andFilterWhere(['like', 'zagotiv', $this->zagotiv]);
     if (empty($params['date_start']) && isset($filter['year'])) {
         $query->andFilterWhere(['between', 'date_start', $filter['year'] . '-01-01', $filter['year'] . '-12-31']);
     }
     return $dataProvider;
 }
Esempio n. 3
0
<div class="journal-form">

    <?php 
$form = ActiveForm::begin();
?>

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

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

    <?php 
echo $form->field($model, 'id_leshoz')->dropDownList(ArrayHelper::map(Leshoz::find()->all(), 'id', 'nazva'))->label(Yii::t('company', 'Nazva'));
?>

    <?php 
echo $form->field($model, 'id_poroda')->dropDownList(ArrayHelper::map(Poroda::find()->all(), 'id', 'nazva_short'))->label(Yii::t('kind', 'Nazva Short'));
?>

    <?php 
echo $form->field($model, 'date_start')->widget(DatePicker::classname(), ['value' => $model->date_start ? $model->date_start : (new DateTime())->format('Y-m-d'), 'dateFormat' => 'php:Y-m-d', 'options' => ['class' => 'form-control']]);
?>

    <?php 
echo $form->field($model, 'date_end')->widget(DatePicker::classname(), ['value' => $model->date_end ? $model->date_end : (new DateTime())->format('Y-m-d'), 'dateFormat' => 'php:Y-m-d', 'options' => ['class' => 'form-control']]);
?>

    <?php 
Esempio n. 4
0
 /**
  * Speciment-to-Company relation
  */
 public function getCompany()
 {
     return $this->hasOne(Leshoz::className(), ['id' => 'id_leshoz']);
 }
 /**
  * Finds the Leshoz model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Leshoz the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Leshoz::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }