/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Spheres::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, 'date_post' => $this->date_post, 'date_update' => $this->date_update]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Пример #2
0
		<?php 
$list_projects = ArrayHelper::map($projects, 'id', 'name');
echo $form->field($model, 'id_project')->dropDownList($list_projects);
?>

	    <?php 
echo $form->field($model, 'name')->textinput();
?>

	    <?php 
echo $form->field($model, 'about')->textarea(['rows' => 6]);
?>

		<?php 
$sphere = Spheres::find()->all();
$list_sphere = ArrayHelper::map($sphere, 'id', 'name');
echo $form->field($model, 'id_sphere')->dropDownList($list_sphere, ['prompt' => 'Выберите из списка']);
?>

		<?
	    	// usage without model
			echo '<label>Дата старта кампании</label>';
			echo DatePicker::widget([
			    'name' => 'date_begin',
				'value' => $time_begin,
			    'pluginOptions' => [
			        'autoclose' => true,
					'format' => 'yyyy-mm-dd',
			        'todayHighlight' => true
			    ],
 /**
  * Updates an existing Campaigns model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $projects = Projects::all_users_projects_one(Yii::$app->user->identity->id, $model->id_project);
     // проекты пользователя
     $spheres = Spheres::all_spheres();
     // список сфер деятельности
     $time = Yii::$app->request->get();
     if (!empty($time['analytics'])) {
         $time_end = $time['analytics'] / 1000;
         $time_end = $time_end + 10 * 24 * 3600;
         $time_end = date('Y-m-d', $time_end);
     } else {
         $time_begin = $model->date_begin;
         $time_begin = date('Y-m-d', $time_begin);
         $time_end = $model->date_end;
         $time_end = date('Y-m-d', $time_end);
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('flashupdate', constant('FLASH_UPDATE'));
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'projects' => $projects, 'spheres' => $spheres, 'time_begin' => $time_begin, 'time_end' => $time_end]);
     }
 }
Пример #4
0
 public function getSpheres()
 {
     return $this->hasOne(Spheres::className(), ['id' => 'id_sphere']);
 }