add customer ticket statistics
This commit is contained in:
parent
b3dd9f67e8
commit
2654a501db
@ -9,7 +9,7 @@ class AdminMenuStructure{
|
|||||||
|
|
||||||
public $menuItems;
|
public $menuItems;
|
||||||
|
|
||||||
public function AdminMenu(){
|
public function __construct(){
|
||||||
$this->menuItems = [];
|
$this->menuItems = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,8 @@ use common\models\Discount;
|
|||||||
use common\models\TicketType;
|
use common\models\TicketType;
|
||||||
use common\models\Account;
|
use common\models\Account;
|
||||||
use common\models\User;
|
use common\models\User;
|
||||||
|
use common\models\Customer;
|
||||||
|
use common\models\Card;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TicketController implements the CRUD actions for Ticket model.
|
* TicketController implements the CRUD actions for Ticket model.
|
||||||
@ -19,6 +21,25 @@ use common\models\User;
|
|||||||
class TicketController extends \backend\controllers\BackendController
|
class TicketController extends \backend\controllers\BackendController
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public function behaviors()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'access' => [
|
||||||
|
'class' => \yii\filters\AccessControl::className(),
|
||||||
|
'rules' => [
|
||||||
|
// allow authenticated users
|
||||||
|
[
|
||||||
|
'actions' => ['create','index','view','update','index-customer'],
|
||||||
|
'allow' => true,
|
||||||
|
'roles' => ['admin','employee','reception'],
|
||||||
|
],
|
||||||
|
// everything else is denied
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all Ticket models.
|
* Lists all Ticket models.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@ -41,6 +62,42 @@ class TicketController extends \backend\controllers\BackendController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all Ticket models.
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionIndexCustomer($id)
|
||||||
|
{
|
||||||
|
|
||||||
|
$customer = Customer::findOne($id);
|
||||||
|
$card = Card::findOne($id);
|
||||||
|
|
||||||
|
|
||||||
|
if ( $customer == null ){
|
||||||
|
throw new NotFoundHttpException('The requested page does not exist.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$searchModel = new TicketSearch();
|
||||||
|
$searchModel->id_card = $customer->id_customer_card;
|
||||||
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
$searchModel->searchTotals();
|
||||||
|
|
||||||
|
$searchModel->users = User::read();
|
||||||
|
$searchModel->accounts = Account::read();
|
||||||
|
$searchModel->ticketTypes = TicketType::read();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $this->render('index_customer', [
|
||||||
|
'searchModel' => $searchModel,
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'customer' => $customer,
|
||||||
|
'card' => $card
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a single Ticket model.
|
* Displays a single Ticket model.
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
|
|||||||
@ -30,16 +30,17 @@ class TicketSearch extends Ticket
|
|||||||
public $statistics;
|
public $statistics;
|
||||||
public $statisticsTotal;
|
public $statisticsTotal;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['id_ticket', 'id_user', 'id_ticket_type', 'id_account', 'id_discount', 'max_usage_count', 'usage_count', 'status', 'price_brutto'], 'integer'],
|
[[ 'id_user', 'id_ticket_type', 'id_account'], 'integer'],
|
||||||
[[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
[[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||||
[[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
[[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||||
[['valid_in_interval','created_in_interval','expire_in_interval'],'boolean']
|
[['valid_in_interval','created_in_interval','expire_in_interval'],'boolean'] ,
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -96,6 +97,10 @@ class TicketSearch extends Ticket
|
|||||||
|
|
||||||
$dataProvider = new ActiveDataProvider([
|
$dataProvider = new ActiveDataProvider([
|
||||||
'query' => $query,
|
'query' => $query,
|
||||||
|
'sort' =>[
|
||||||
|
'defaultOrder' => ['end' => SORT_DESC],
|
||||||
|
'attributes' => ['end']
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->load($params);
|
$this->load($params);
|
||||||
@ -111,9 +116,11 @@ class TicketSearch extends Ticket
|
|||||||
'id_user' => $this->id_user,
|
'id_user' => $this->id_user,
|
||||||
'id_ticket_type' => $this->id_ticket_type,
|
'id_ticket_type' => $this->id_ticket_type,
|
||||||
'id_account' => $this->id_account,
|
'id_account' => $this->id_account,
|
||||||
|
'id_card' => $this->id_card,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$all = (!($this->valid_in_interval) && !($this->expire_in_interval) && !($this->created_in_interval) )
|
$all = (!($this->valid_in_interval) && !($this->expire_in_interval) && !($this->created_in_interval) )
|
||||||
||
|
||
|
||||||
($this->valid_in_interval == true && $this->expire_in_interval == true && $this->created_in_interval);
|
($this->valid_in_interval == true && $this->expire_in_interval == true && $this->created_in_interval);
|
||||||
@ -150,7 +157,7 @@ class TicketSearch extends Ticket
|
|||||||
|
|
||||||
|
|
||||||
public function searchTotals(){
|
public function searchTotals(){
|
||||||
$query = Ticket::mkStatisticQuery($this->timestampStart, $this->timestampEnd);
|
$query = Ticket::mkStatisticQuery($this->timestampStart, $this->timestampEnd,$this->id_card);
|
||||||
$this->statistics = $query->all();
|
$this->statistics = $query->all();
|
||||||
|
|
||||||
$this->statisticsTotal =[
|
$this->statisticsTotal =[
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\grid\GridView;
|
use yii\grid\GridView;
|
||||||
|
use yii\helpers\Url;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $searchModel backend\models\CustomerSearch */
|
/* @var $searchModel backend\models\CustomerSearch */
|
||||||
@ -24,30 +25,31 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'columns' => [
|
'columns' => [
|
||||||
[
|
[
|
||||||
'attribute' => 'customerCardNumber' ,
|
'attribute' => 'customerCardNumber' ,
|
||||||
// 'value' => 'customerCardNumber'
|
|
||||||
],
|
],
|
||||||
// 'id_user',
|
|
||||||
// 'id_partner_card',
|
|
||||||
// 'id_proposer',
|
|
||||||
'name',
|
'name',
|
||||||
'email:email',
|
'email:email',
|
||||||
// 'password',
|
|
||||||
'phone',
|
'phone',
|
||||||
// 'sex',
|
|
||||||
// 'date_stundent_card_expire',
|
|
||||||
// 'birthdate',
|
|
||||||
// 'image',
|
|
||||||
// 'description',
|
|
||||||
// 'tax_number',
|
|
||||||
// 'country',
|
|
||||||
// 'zip',
|
|
||||||
// 'city',
|
|
||||||
// 'address',
|
|
||||||
'created_at:datetime',
|
'created_at:datetime',
|
||||||
// 'updated_at',
|
|
||||||
|
|
||||||
['class' => 'yii\grid\ActionColumn',
|
['class' => 'yii\grid\ActionColumn',
|
||||||
'template' =>'{view}{update}'
|
'template' =>'{view} {update} {ticket/index-customer}',
|
||||||
|
'buttons' => [
|
||||||
|
'ticket/index-customer' => function ($url) { return Html::a( '<span class="glyphicon glyphicon-list-alt"> </span>', $url, [ 'title' => 'Bérletek' ] ); }
|
||||||
|
],
|
||||||
|
'urlCreator' =>function ($action, $model, $key, $index){
|
||||||
|
$params = is_array($key) ? $key : ['id' => (string) $key];
|
||||||
|
if ( $action == 'ticket/index-customer' ){
|
||||||
|
$today = \Yii::$app->formatter->asDate( strtotime('today UTC') );
|
||||||
|
$tomorrow = \Yii::$app->formatter->asDate( strtotime( 'tomorrow UTC' ));
|
||||||
|
|
||||||
|
$params['TicketSearch[start]'] = $today;
|
||||||
|
$params['TicketSearch[end]'] = $tomorrow;
|
||||||
|
|
||||||
|
}
|
||||||
|
$params[0] = $action;
|
||||||
|
|
||||||
|
return Url::toRoute($params);
|
||||||
|
}
|
||||||
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|||||||
76
backend/views/ticket/_search_customer.php
Normal file
76
backend/views/ticket/_search_customer.php
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
use kartik\widgets\DatePicker;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\models\TicketSearch */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$ticketTypeOptions = ['' => 'Mind'] + ArrayHelper::map($model->ticketTypes, 'id_ticket_type', 'name');
|
||||||
|
$accountOptions = ['' => 'Mind'] + ArrayHelper::map($model->accounts, 'id_account', 'name');
|
||||||
|
$userOptions = ['' => 'Mind'] + ArrayHelper::map($model->users, 'id', 'username');
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="ticket-search">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin([
|
||||||
|
'action' => ['index'],
|
||||||
|
'method' => 'get',
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
|
||||||
|
<div class='row'>
|
||||||
|
<div class='col-md-4'>
|
||||||
|
<?= $form->field($model, 'id_user')->dropDownList($userOptions) ?>
|
||||||
|
</div>
|
||||||
|
<div class='col-md-4'>
|
||||||
|
<?= $form->field($model, 'id_ticket_type')->dropDownList($ticketTypeOptions) ?>
|
||||||
|
</div>
|
||||||
|
<div class='col-md-4'>
|
||||||
|
<?= $form->field($model, 'id_account')->dropDownList($accountOptions) ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'start')->widget(DatePicker::classname(), [
|
||||||
|
'pluginOptions' => [
|
||||||
|
'autoclose'=>true,
|
||||||
|
'format' => 'yyyy.mm.dd'
|
||||||
|
]
|
||||||
|
]) ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'end') ->widget(DatePicker::classname(), [
|
||||||
|
'pluginOptions' => [
|
||||||
|
'autoclose'=>true,
|
||||||
|
'format' => 'yyyy.mm.dd'
|
||||||
|
]
|
||||||
|
]) ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class='row'>
|
||||||
|
<div class='col-md-4'>
|
||||||
|
<?php echo $form->field($model, 'valid_in_interval')->checkbox( ) ?>
|
||||||
|
</div>
|
||||||
|
<div class='col-md-4'>
|
||||||
|
<?php echo $form->field($model, 'created_in_interval')->checkbox( ) ?>
|
||||||
|
</div>
|
||||||
|
<div class='col-md-4'>
|
||||||
|
<?php echo $form->field($model, 'expire_in_interval')->checkbox( ) ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton(Yii::t('common/ticket', 'Search'), ['class' => 'btn btn-primary']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
116
backend/views/ticket/index_customer.php
Normal file
116
backend/views/ticket/index_customer.php
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\grid\GridView;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
use yii\data\ArrayDataProvider;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $searchModel backend\models\TicketSearch */
|
||||||
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
|
||||||
|
$customer = $customer->name;
|
||||||
|
if ( isset($card)){
|
||||||
|
$customer .= " (" .$card->number . ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->title = Yii::t('common/ticket', '{customer} Tickets', ['customer'=>$customer]);
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="ticket-index">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
<?php echo $this->render('_search_customer', ['model' => $searchModel]); ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">Bérlet statisztika</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<p>Bérlet statisztika a kiválasztott időszakra</p>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
echo GridView::widget([
|
||||||
|
'dataProvider' => new ArrayDataProvider([
|
||||||
|
'allModels' => $searchModel->statistics,
|
||||||
|
'sort' => false,
|
||||||
|
'pagination' => false,
|
||||||
|
]),
|
||||||
|
'showFooter'=>TRUE,
|
||||||
|
'footerRowOptions'=>['style'=>'font-weight:bold; '],
|
||||||
|
'columns' =>[
|
||||||
|
[
|
||||||
|
'attribute' => 'name',
|
||||||
|
'label' => 'Bérlet',
|
||||||
|
'footer' => 'Összesen'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'created',
|
||||||
|
'label' => 'Kiadva (Db)',
|
||||||
|
'footer' => $searchModel->statisticsTotal['created']
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'created_money',
|
||||||
|
'label' => 'Kiadott érték (Ft)',
|
||||||
|
'footer' => $searchModel->statisticsTotal['created_money']
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'valid',
|
||||||
|
'label' => 'Érvényes (Db)',
|
||||||
|
'footer' => $searchModel->statisticsTotal['valid']
|
||||||
|
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'expired',
|
||||||
|
'label' => 'Lejár az adott időszakban (Db)',
|
||||||
|
'footer' => $searchModel->statisticsTotal['expired']
|
||||||
|
]
|
||||||
|
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?= GridView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'columns' => [
|
||||||
|
[
|
||||||
|
'attribute' => 'id_customer',
|
||||||
|
'value' => 'customerName'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'id_card',
|
||||||
|
'value' => 'cardNumber'
|
||||||
|
],
|
||||||
|
'start:date',
|
||||||
|
'end:date',
|
||||||
|
[
|
||||||
|
'attribute' => 'id_user',
|
||||||
|
'value' => 'userName'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'id_ticket_type',
|
||||||
|
'value' => 'ticketTypeName'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'id_account',
|
||||||
|
'value' => 'accountName'
|
||||||
|
],
|
||||||
|
// 'max_usage_count',
|
||||||
|
// 'usage_count',
|
||||||
|
|
||||||
|
['class' => 'yii\grid\ActionColumn',
|
||||||
|
'template' => '{view}'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
@ -19,7 +19,7 @@
|
|||||||
return [
|
return [
|
||||||
'Card' => 'Bérlet kártya',
|
'Card' => 'Bérlet kártya',
|
||||||
'Customer' => 'Vendég',
|
'Customer' => 'Vendég',
|
||||||
'Created in interval' => 'Létrehozva az időszakban',
|
'Created in interval' => 'Kiadva az időszakban',
|
||||||
'End of interval' => 'Időszak vége',
|
'End of interval' => 'Időszak vége',
|
||||||
'Expire in interval' => 'Lejár az időszakban',
|
'Expire in interval' => 'Lejár az időszakban',
|
||||||
'Start of interval' => 'Idászak kezdete',
|
'Start of interval' => 'Idászak kezdete',
|
||||||
|
|||||||
@ -16,6 +16,7 @@ use common\components\Helper;
|
|||||||
* @property integer $id_ticket_type
|
* @property integer $id_ticket_type
|
||||||
* @property integer $id_account
|
* @property integer $id_account
|
||||||
* @property integer $id_discount
|
* @property integer $id_discount
|
||||||
|
* @property integer $id_card
|
||||||
* @property string $start
|
* @property string $start
|
||||||
* @property string $end
|
* @property string $end
|
||||||
* @property integer $max_usage_count
|
* @property integer $max_usage_count
|
||||||
@ -175,7 +176,7 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function mkStatisticQuery($start,$end){
|
public static function mkStatisticQuery($start,$end,$id_card = null){
|
||||||
// $sql = "select
|
// $sql = "select
|
||||||
// ticket_type.name,
|
// ticket_type.name,
|
||||||
// count(ticket.id_ticket) as total ,
|
// count(ticket.id_ticket) as total ,
|
||||||
@ -211,6 +212,8 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
|||||||
|
|
||||||
Helper::queryAccountConstraint($query, 'ticket.id_account');
|
Helper::queryAccountConstraint($query, 'ticket.id_account');
|
||||||
|
|
||||||
|
$query->andFilterWhere(['id_card' =>$id_card]);
|
||||||
|
|
||||||
$query->andWhere(
|
$query->andWhere(
|
||||||
[
|
[
|
||||||
'or',
|
'or',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user