Пример #1
0
 public function search($params)
 {
     $query = Cashbook::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['date' => SORT_DESC]], 'pagination' => ['pageSize' => 100]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'type_id' => $this->type_id, 'value' => $this->value, 'inc_datetime' => $this->inc_datetime, 'edit_datetime' => $this->edit_datetime, 'user_id' => Yii::$app->user->identity->id]);
     $query->andFilterWhere(['between', 'date', $this->start_date, $this->end_date]);
     $query->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'attachment', $this->attachment]);
     //$query->andFilterWhere(['user_id' => 2]);
     return $dataProvider;
 }
Пример #2
0
if ($flash = Yii::$app->session->getFlash("Entry-success")) {
    ?>

        <div class="alert text-success">
            <p><em><?php 
    echo $flash;
    ?>
</em></p>
        </div>

    <?php 
}
?>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'tableOptions' => ['class' => 'table table-striped table-hover'], 'emptyText' => '</br><p class="text-danger">' . Yii::t('app', 'No entries found!') . '</p>', 'summary' => '', 'showFooter' => true, 'showOnEmpty' => false, 'footerRowOptions' => ['style' => 'font-weight:bold;'], 'columns' => [['attribute' => 'date', 'enableSorting' => true, 'value' => function ($model) {
    return $model->date != '' ? Yii::$app->formatter->asDate($model->date, 'short') : Yii::$app->formatter->asDate($model->date, 'short');
}, 'contentOptions' => ['style' => 'width: 10%;text-align:left']], ['attribute' => 'category_id', 'format' => 'raw', 'enableSorting' => true, 'value' => function ($model) {
    return $model->description != '' ? '<span style="color:' . $model->category->hexcolor_category . '">' . $model->category->desc_category . '</span>' . ' <em class="text-muted">(' . $model->description . ')</em>' : '<span style="color:' . $model->category->hexcolor_category . '">' . $model->category->desc_category . '</span>';
}, 'contentOptions' => ['style' => 'width: 35%;text-align:left'], 'footer' => 'Total', 'footerOptions' => ['style' => 'text-align:letf']], ['attribute' => 'account.description', 'header' => Yii::t('app', 'Account')], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{pending} {attachment} {view} {update} {delete}', 'buttons' => ['pending' => function ($url, $model) {
    return $model->is_pending != 0 ? Html::a('<span class="glyphicon glyphicon-alert text-danger" ></span>', $url, ['title' => Yii::t('app', 'Pending')]) : '';
}, 'attachment' => function ($url, $model) {
    return $model->attachment != '' ? Html::a('<span class="glyphicon glyphicon-paperclip"></span>', $url, ['title' => Yii::t('app', 'Receipt')]) : '';
}], 'contentOptions' => ['style' => 'width: 25%;text-align:right']], ['label' => '', 'attribute' => 'value', 'format' => 'raw', 'value' => function ($model) {
    return '<strong style="color:' . $model->type->hexcolor_type . '">' . (isset($model->account) ? $model->account->currency->iso_code : Yii::t('app', '$')) . ' ' . $model->value . '</strong>';
}, 'enableSorting' => true, 'contentOptions' => ['style' => 'width: 25%;text-align:right'], 'footer' => Cashbook::pageTotal($dataProvider->models, 'value'), 'footerOptions' => ['style' => 'text-align:right']]]]);
?>

</div>

        </div>
    </div>
Пример #3
0
 public function getCashbooks()
 {
     return $this->hasMany(Cashbook::className(), ['category_id' => 'id_category']);
 }
Пример #4
0
 protected function findModel($id)
 {
     if (($model = Cashbook::findOne($id)) !== null && $model->user_id == Yii::$app->user->id) {
         return $model;
     } else {
         throw new NotFoundHttpException('The page you requested is not available or does not exist.');
     }
 }
Пример #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCashbooks()
 {
     return $this->hasMany(Cashbook::className(), ['type_id' => 'id_type']);
 }