Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Tech::find()->joinWith('contact');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['username'] = ['asc' => [Contact::tableName() . '.email' => SORT_ASC], 'desc' => [Contact::tableName() . '.email' => SORT_DESC]];
     $dataProvider->sort->attributes['name'] = ['asc' => [Contact::tableName() . '.name' => SORT_ASC], 'desc' => [Contact::tableName() . '.name' => SORT_DESC]];
     $dataProvider->sort->defaultOrder = ['name' => SORT_ASC];
     $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([Tech::tableName() . '.contact_id' => $this->id]);
     $query->andFilterWhere(['like', Contact::tableName() . '.email', $this->username])->andFilterWhere(['like', Contact::tableName() . '.name', $this->name]);
     return $dataProvider;
 }
Пример #2
0
 /**
  * Lists all Schedule models.
  * @return mixed
  */
 public function actionIndex()
 {
     Url::remember();
     return $this->render('index', ['techs' => Tech::find()->hasCalendar()->contact()->all()]);
 }
Пример #3
0
<div class="reimbursement-form">

    <?php 
$form = ActiveForm::begin(['layout' => 'horizontal', 'options' => ['enctype' => 'multipart/form-data']]);
?>

    <div>
        <?php 
echo $form->errorSummary($model);
?>
        <?php 
$this->beginBlock('main');
?>
        <p>
            <?php 
echo $form->field($model, 'tech_id')->dropDownList(\yii\helpers\ArrayHelper::map(\common\models\Tech::find()->contact()->all(), 'contact_id', 'contact.name'), ['prompt' => '']);
?>

            <?php 
echo $form->field($model, 'amount')->textInput(['maxlength' => true]);
?>

            <?php 
echo $form->field($model, 'receiptImg')->widget(\kartik\file\FileInput::className(), ['options' => ['accept' => 'image/*,text/*,application/pdf'], 'pluginOptions' => ['browseClass' => 'btn btn-info btn-xs', 'showCaption' => false, 'showRemove' => false, 'showUpload' => false, 'initialPreview' => [$model->isNewRecord ? null : Yii::$app->formatter->asFile($model, ['receipt', 'id' => $model->id])]]]);
?>

        </p>
        <?php 
$this->endBlock();
?>