Beispiel #1
0
 /**
  * Finds the Userdata model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Userdata the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Userdata::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #2
0
 /**
  * Updates an existing Trip 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);
     if ($model->idusers == Yii::$app->user->id) {
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('update', ['model' => $model, 'userdata' => Userdata::find()->all(), 'direction' => Direction::find()->asArray()->all(), 'project' => Project::find()->asArray()->all(), 'prikaz' => Prikaz::find()->asArray()->all()]);
         }
     } else {
         throw new NotFoundHttpException('РЕДАКТИРОВАТЬ МОЖЕТ ТОЛЬКО РЕГИСТРАТОР ДАННОЙ КОМАНДИРОВКИ');
     }
 }
Beispiel #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Userdata::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['pib' => SORT_ASC]]]);
     $dataProvider->pagination->pageSize = 10;
     $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_depart' => $this->id_depart, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'pib', $this->pib])->andFilterWhere(['like', 'position', $this->position])->andFilterWhere(['like', 'pasport', $this->pasport]);
     return $dataProvider;
 }
Beispiel #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUserdata1()
 {
     return $this->hasOne(Userdata::className(), ['id' => 'iduserdata']);
 }
Beispiel #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUserdatas()
 {
     return $this->hasMany(Userdata::className(), ['id_depart' => 'id']);
 }
Beispiel #6
0
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Добавить командировку', ['create'], ['class' => 'btn btn-success']);
?>
    </p>



    <?php 
$gridColumns = [['class' => 'yii\\grid\\ActionColumn'], ['attribute' => 'numbertrip', 'label' => '№ Командировки'], ['attribute' => 'iduserdata', 'filter' => ArrayHelper::map(\app\models\Userdata::find()->orderBy('pib')->asArray()->all(), 'id', 'pib'), 'label' => 'Фамилия Имя Отчество', 'value' => function ($data) {
    return $data->userdata1->pib;
}], ['attribute' => 'depart', 'filter' => ArrayHelper::map(\app\models\Depart::find()->orderBy('name_depart')->asArray()->all(), 'id', 'name_depart'), 'value' => function ($data) {
    return $data->userdata1->idDepart->name_depart;
}], ['attribute' => 'test', 'value' => function ($data) {
    return $data->client1->directions->sity;
}], ['attribute' => 'idclient', 'label' => 'Предприятие для командировки ', 'headerOptions' => ['width' => '380'], 'filter' => ArrayHelper::map(\app\models\Client::find()->orderBy('nameclient')->asArray()->all(), 'id', 'nameclient'), 'width' => '150px', 'value' => function ($data) {
    return $data->client1->nameclient;
}], ['attribute' => 'idproject', 'label' => 'Проект/Клиент для командировки', 'filter' => ArrayHelper::map(\app\models\Project::find()->orderBy('name_project')->asArray()->all(), 'id', 'name_project'), 'value' => function ($data) {
    return $data->project1->name_project;
}], ['attribute' => 'date_otpr', 'label' => 'Дата отправления', 'format' => 'datetime'], ['attribute' => 'date_pr', 'label' => 'Дата прибытия.', 'format' => 'datetime'], ['attribute' => 'date_otpr1', 'label' => 'Дата отправления', 'format' => 'datetime'], ['attribute' => 'date_pr1', 'label' => 'Дата прибытия.', 'format' => 'datetime'], ['label' => 'Количество дней', 'value' => function ($data) {
    $datetime1 = new DateTime(date('Y-m-d', $data->date_otpr));
    $datetime2 = new DateTime(date('Y-m-d', $data->date_pr1));
    $interval = $datetime1->diff($datetime2);
    $interval = $interval->format('%R%a');
    $interval = $interval + 1;