Skip to content

Commit

Permalink
Add ActionBox
Browse files Browse the repository at this point in the history
  • Loading branch information
tafid committed Aug 5, 2015
1 parent 6695253 commit 8102422
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 9 deletions.
13 changes: 13 additions & 0 deletions src/controllers/BillController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,21 @@

namespace hipanel\modules\finance\controllers;

use hipanel\models\Ref;
use Yii;

class BillController extends \hipanel\base\CrudController
{
public function actions()
{
return [
'index' => [
'class' => 'hipanel\actions\IndexAction',
'data' => function ($action) {
return [
'paymentType' => $action->controller->getPaymentType(),
];
}
],
'view' => [
'class' => 'hipanel\actions\ViewAction',
Expand All @@ -40,4 +48,9 @@ public function actions()
];
}

public function getPaymentType()
{
return Ref::getList('type,bill,deposit');
}

}
3 changes: 3 additions & 0 deletions src/models/Bill.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class Bill extends \hipanel\base\Model
{
use \hipanel\base\ModelTrait;

public $time_from;
public $time_till;

/**
* @inheritdoc
*/
Expand Down
25 changes: 25 additions & 0 deletions src/views/bill/_search.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use hipanel\modules\client\widgets\combo\ClientCombo;
use hipanel\modules\client\widgets\combo\SellerCombo;
use hiqdev\combo\StaticCombo;

?>

<div class="col-md-6">
<?= $search->field('descr') ?>
<?= $search->field('type')->widget(StaticCombo::classname(), [
'data' => $paymentType,
'hasId' => true,
'pluginOptions' => [
'select2Options' => [
'multiple' => false,
]
],
]) ?>
</div>

<div class="col-md-6">
<?= $search->field('client_id')->widget(ClientCombo::classname()) ?>
<?= $search->field('seller_id')->widget(SellerCombo::classname()) ?>
</div>
48 changes: 39 additions & 9 deletions src/views/bill/index.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,49 @@
<?php

use hipanel\modules\finance\grid\BillGridView;
use hipanel\widgets\ActionBox;

$this->title = Yii::t('app', 'Bills');
$this->params['breadcrumbs'][] = $this->title;
$this->params['subtitle'] = Yii::$app->request->queryParams ? 'filtered list' : 'full list';

?>

<?= billGridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
'checkbox',
'seller_id', 'client_id',
'time', 'sum', 'balance', 'gtype', 'description',
],
]) ?>
<?php $box = ActionBox::begin(['model' => $model, 'bulk' => Yii::$app->user->can('own'), 'options' => ['class' => 'box-info']]) ?>
<?php $box->beginActions() ?>
<?php
if (Yii::$app->user->can('support')) {
print $box->renderCreateButton(Yii::t('app', 'Add payment')) . '&nbsp;';
}
if (Yii::$app->user->can('own')) {
print $box->renderCreateButton(Yii::t('app', 'Edit')) . '&nbsp;';
print $box->renderCreateButton(Yii::t('app', 'Delete')) . '&nbsp;';
}
print $box->renderCreateButton(Yii::t('app', 'Recharge account'));
?>
<?= $box->renderSearchButton() ?>
<?php $box->endActions() ?>

<?php
if (Yii::$app->user->can('own')) {
print $box->renderBulkActions([
'items' => [
$box->renderBulkButton(Yii::t('app', 'Delete'), 'delete'),
],
]);
}
?>
<?= $box->renderSearchForm(compact('paymentType')) ?>
<?php $box::end() ?>

<?php $box->beginBulkForm() ?>
<?= billGridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
'checkbox',
'seller_id', 'client_id',
'time', 'sum', 'balance', 'gtype', 'description',
],
]) ?>
<?php $box::endBulkForm() ?>

0 comments on commit 8102422

Please sign in to comment.