Finish version/v.0.0.3
This commit is contained in:
commit
e84dca1e1b
@ -9,7 +9,7 @@ class AdminMenuStructure{
|
|||||||
|
|
||||||
public $menuItems;
|
public $menuItems;
|
||||||
|
|
||||||
public function AdminMenu(){
|
public function __construct(){
|
||||||
$this->menuItems = [];
|
$this->menuItems = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +31,6 @@ class AdminMenuStructure{
|
|||||||
$items = [];
|
$items = [];
|
||||||
if (!Yii::$app->user->isGuest) {
|
if (!Yii::$app->user->isGuest) {
|
||||||
|
|
||||||
|
|
||||||
//$today = \Yii::$app->formatter->asDate( time() );
|
//$today = \Yii::$app->formatter->asDate( time() );
|
||||||
$today = \Yii::$app->formatter->asDate( strtotime('today UTC') );
|
$today = \Yii::$app->formatter->asDate( strtotime('today UTC') );
|
||||||
$tomorrow = \Yii::$app->formatter->asDate( ( 60 *60 *24 + time()));
|
$tomorrow = \Yii::$app->formatter->asDate( ( 60 *60 *24 + time()));
|
||||||
@ -40,39 +39,63 @@ class AdminMenuStructure{
|
|||||||
$tomorrowDatetime = \Yii::$app->formatter->asDatetime( strtotime('tomorrow UTC') );
|
$tomorrowDatetime = \Yii::$app->formatter->asDatetime( strtotime('tomorrow UTC') );
|
||||||
|
|
||||||
|
|
||||||
// if ( $this->can('backend.user.index')){
|
/////////////////////////////
|
||||||
$items[] = ['label' => 'Felhasználók', 'url' =>['/user/index']];
|
// Beállítások
|
||||||
// }
|
/////////////////////////////
|
||||||
|
$items[] = ['label' => 'Felhasználók', 'url' =>['/user/index']];
|
||||||
|
$this->menuItems[] = ['label' => 'Beállítások', 'url' => null,
|
||||||
|
'items' => $items
|
||||||
|
];
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
// Törszadatok
|
||||||
|
/////////////////////////////
|
||||||
|
$items = [];
|
||||||
$items[] = ['label' => 'Raktárak', 'url' =>['/warehouse/index']];
|
$items[] = ['label' => 'Raktárak', 'url' =>['/warehouse/index']];
|
||||||
$items[] = ['label' => 'Kasszák', 'url' =>['/account/index']];
|
$items[] = ['label' => 'Kasszák', 'url' =>['/account/index']];
|
||||||
$items[] = ['label' => 'Kedvezmények', 'url' => ['/discount/index'] ];
|
$items[] = ['label' => 'Kedvezmények', 'url' => ['/discount/index'] ];
|
||||||
$items[] = ['label' => 'Termék kategóriák', 'url' => ['/product-category/index'] ];
|
$items[] = ['label' => 'Termék kategóriák', 'url' => ['/product-category/index'] ];
|
||||||
$items[] = ['label' => 'Bérlet típusok', 'url' => ['/ticket-type/index'] ];
|
$items[] = ['label' => 'Bérlet típusok', 'url' => ['/ticket-type/index'] ];
|
||||||
$items[] = ['label' => 'Termékek', 'url' => ['/product/index'] ];
|
// $items[] = ['label' => 'Pénznem', 'url' => ['/currency/index'] ];
|
||||||
$items[] = ['label' => 'Beszerzések', 'url' => ['/procurement/index'] ];
|
$this->menuItems[] = ['label' => 'Törszadatok', 'url' => null,
|
||||||
|
'items' => $items
|
||||||
|
];
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
// BÉRLETEK
|
||||||
|
/////////////////////////////
|
||||||
|
$items = [];
|
||||||
$items[] = ['label' => 'Vendégek', 'url' => ['/customer/index'] ];
|
$items[] = ['label' => 'Vendégek', 'url' => ['/customer/index'] ];
|
||||||
$items[] = ['label' => 'Bérletkártyák', 'url' => ['/card/index'] ];
|
$items[] = ['label' => 'Bérletkártyák', 'url' => ['/card/index'] ];
|
||||||
// $items[] = ['label' => 'Pénznem', 'url' => ['/currency/index'] ];
|
$items[] = ['label' => 'Bérletek', 'url' => ['/ticket/index' , 'TicketSearch[start]' =>$today,'TicketSearch[end]' => $tomorrow ] ];
|
||||||
|
$this->menuItems[] = ['label' => 'Bérletek/Vendégek', 'url' => null,
|
||||||
|
'items' => $items
|
||||||
|
];
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
// Termékek
|
||||||
|
/////////////////////////////
|
||||||
|
$items = [];
|
||||||
|
$items[] = ['label' => 'Termékek', 'url' => ['/product/index'] ];
|
||||||
|
$items[] = ['label' => 'Beszerzések', 'url' => ['/procurement/index'] ];
|
||||||
|
$this->menuItems[] = ['label' => 'Termékek', 'url' => null,
|
||||||
|
'items' => $items
|
||||||
|
];
|
||||||
|
/////////////////////////////
|
||||||
|
// Pénzügy
|
||||||
|
/////////////////////////////
|
||||||
|
$items = [];
|
||||||
$items[] = ['label' => 'Tranzakciók', 'url' => ['/transfer/index' , 'TransferSearch[start]' =>$today,'TransferSearch[end]' => $tomorrow ] ];
|
$items[] = ['label' => 'Tranzakciók', 'url' => ['/transfer/index' , 'TransferSearch[start]' =>$today,'TransferSearch[end]' => $tomorrow ] ];
|
||||||
$items[] = ['label' => 'Kassza müveletek', 'url' => ['/account-state/index'] ];
|
$items[] = ['label' => 'Kassza müveletek', 'url' => ['/account-state/index'] ];
|
||||||
$items[] = ['label' => 'Zárások', 'url' => ['/collection/index' , 'CollectionSearch[start]' =>$todayDatetime,'CollectionSearch[end]' => $tomorrowDatetime ] ];
|
$items[] = ['label' => 'Zárások', 'url' => ['/collection/index' , 'CollectionSearch[start]' =>$todayDatetime,'CollectionSearch[end]' => $tomorrowDatetime ] ];
|
||||||
|
$this->menuItems[] = ['label' => 'Pénzügy', 'url' => null,
|
||||||
|
'items' => $items
|
||||||
|
];
|
||||||
|
|
||||||
if ( count($items) > 0 ){
|
|
||||||
$userMainMenu = ['label' => 'Beállítások', 'url' => null,
|
|
||||||
'items' => $items
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( isset($userMainMenu)){
|
|
||||||
$this->menuItems[] = $userMainMenu;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function addLoginMainMenu(){
|
protected function addLoginMainMenu(){
|
||||||
if (Yii::$app->user->isGuest) {
|
if (Yii::$app->user->isGuest) {
|
||||||
$mainMenuItem= ['label' => 'Login', 'url' => ['/site/login']];
|
$mainMenuItem= ['label' => 'Login', 'url' => ['/site/login']];
|
||||||
|
|||||||
@ -11,6 +11,9 @@ use yii\filters\VerbFilter;
|
|||||||
use common\models\Discount;
|
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\Customer;
|
||||||
|
use common\models\Card;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TicketController implements the CRUD actions for Ticket model.
|
* TicketController implements the CRUD actions for Ticket model.
|
||||||
@ -18,6 +21,25 @@ use common\models\Account;
|
|||||||
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
|
||||||
@ -26,12 +48,55 @@ class TicketController extends \backend\controllers\BackendController
|
|||||||
{
|
{
|
||||||
$searchModel = new TicketSearch();
|
$searchModel = new TicketSearch();
|
||||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
$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', [
|
return $this->render('index', [
|
||||||
'searchModel' => $searchModel,
|
'searchModel' => $searchModel,
|
||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
|||||||
@ -6,20 +6,42 @@ use Yii;
|
|||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
use yii\data\ActiveDataProvider;
|
use yii\data\ActiveDataProvider;
|
||||||
use common\models\Ticket;
|
use common\models\Ticket;
|
||||||
|
use common\components\Helper;
|
||||||
|
use yii\db\ActiveRecord;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TicketSearch represents the model behind the search form about `common\models\Ticket`.
|
* TicketSearch represents the model behind the search form about `common\models\Ticket`.
|
||||||
*/
|
*/
|
||||||
class TicketSearch extends Ticket
|
class TicketSearch extends Ticket
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public $timestampStart;
|
||||||
|
public $timestampEnd;
|
||||||
|
|
||||||
|
public $users;
|
||||||
|
public $accounts;
|
||||||
|
public $ticketTypes;
|
||||||
|
|
||||||
|
public $valid_in_interval;
|
||||||
|
public $created_in_interval;
|
||||||
|
public $expire_in_interval;
|
||||||
|
|
||||||
|
public $statistics;
|
||||||
|
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', 'end', 'comment', 'created_at', 'updated_at'], 'safe'],
|
[[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||||
|
[[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||||
|
[['valid_in_interval','created_in_interval','expire_in_interval'],'boolean'] ,
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +53,29 @@ class TicketSearch extends Ticket
|
|||||||
// bypass scenarios() implementation in the parent class
|
// bypass scenarios() implementation in the parent class
|
||||||
return Model::scenarios();
|
return Model::scenarios();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function attributeLabels(){
|
||||||
|
return ArrayHelper::merge(parent::attributeLabels(), [
|
||||||
|
'start' => Yii::t('backend/ticket','Start of interval'),
|
||||||
|
'end' => Yii::t('backend/ticket','End of interval'),
|
||||||
|
'valid_in_interval' => Yii::t('backend/ticket','Valid in interval'),
|
||||||
|
'created_in_interval' => Yii::t('backend/ticket','Created in interval'),
|
||||||
|
'expire_in_interval' => Yii::t('backend/ticket','Expire in interval'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afterValidate(){
|
||||||
|
|
||||||
|
if ( !isset($this->timestampStart)) {
|
||||||
|
$this->timestampStart ='1900-01-01';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !isset($this->timestampEnd)) {
|
||||||
|
$this->timestampEnd ='3000-01-01';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates data provider instance with search query applied
|
* Creates data provider instance with search query applied
|
||||||
*
|
*
|
||||||
@ -43,36 +87,137 @@ class TicketSearch extends Ticket
|
|||||||
{
|
{
|
||||||
$query = Ticket::find();
|
$query = Ticket::find();
|
||||||
|
|
||||||
|
Helper::queryAccountConstraint($query, 'ticket.id_account');
|
||||||
|
|
||||||
|
$query->with('ticketType' );
|
||||||
|
$query->with('user');
|
||||||
|
$query->with('customer');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$dataProvider = new ActiveDataProvider([
|
$dataProvider = new ActiveDataProvider([
|
||||||
'query' => $query,
|
'query' => $query,
|
||||||
|
'sort' =>[
|
||||||
|
'defaultOrder' => ['end' => SORT_DESC],
|
||||||
|
'attributes' => ['end']
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->load($params);
|
$this->load($params);
|
||||||
|
|
||||||
|
|
||||||
if (!$this->validate()) {
|
if (!$this->validate()) {
|
||||||
// uncomment the following line if you do not want to return any records when validation fails
|
$query->where('0=1');
|
||||||
// $query->where('0=1');
|
return $query;
|
||||||
return $dataProvider;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$query->andFilterWhere([
|
$query->andFilterWhere([
|
||||||
'id_ticket' => $this->id_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_discount' => $this->id_discount,
|
'id_card' => $this->id_card,
|
||||||
'start' => $this->start,
|
|
||||||
'end' => $this->end,
|
|
||||||
'max_usage_count' => $this->max_usage_count,
|
|
||||||
'usage_count' => $this->usage_count,
|
|
||||||
'status' => $this->status,
|
|
||||||
'price_brutto' => $this->price_brutto,
|
|
||||||
'created_at' => $this->created_at,
|
|
||||||
'updated_at' => $this->updated_at,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$query->andFilterWhere(['like', 'comment', $this->comment]);
|
|
||||||
|
|
||||||
|
$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);
|
||||||
|
|
||||||
|
$dateConditions = [];
|
||||||
|
$start = $this->timestampStart;
|
||||||
|
$end = $this->timestampEnd;
|
||||||
|
|
||||||
|
if( $all || $this->created_in_interval ){
|
||||||
|
$dateConditions[] = Helper::queryInIntervalRule('ticket.created_at', $start, $end);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $all || $this->valid_in_interval ){
|
||||||
|
$dateConditions[] = Helper::queryValidRule('ticket.start', 'ticket.end', $start, $end);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $all || $this->expire_in_interval ){
|
||||||
|
$dateConditions[] = Helper::queryExpireRule('ticket.start', 'ticket.end', $start, $end);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( count($dateConditions) == 1 ){
|
||||||
|
$query->andWhere($dateConditions[0]);
|
||||||
|
}else if ( count($dateConditions) > 1 ){
|
||||||
|
$cond = ['or'];
|
||||||
|
foreach ($dateConditions as $c){
|
||||||
|
$cond[] = $c;
|
||||||
|
}
|
||||||
|
$query->andWhere($cond);
|
||||||
|
}
|
||||||
|
|
||||||
return $dataProvider;
|
return $dataProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function searchTotals(){
|
||||||
|
$query = Ticket::mkStatisticQuery($this->timestampStart, $this->timestampEnd,$this->id_card);
|
||||||
|
$this->statistics = $query->all();
|
||||||
|
|
||||||
|
$this->statisticsTotal =[
|
||||||
|
'valid' => 0,
|
||||||
|
'created' => 0,
|
||||||
|
'created_at_money' => 0,
|
||||||
|
'expired' => 0,
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->statisticsTotal['valid'] = array_sum(array_column($this->statistics, 'valid'));
|
||||||
|
$this->statisticsTotal['created'] = array_sum(array_column($this->statistics, 'created'));
|
||||||
|
$this->statisticsTotal['created_money'] = array_sum(array_column($this->statistics, 'created_money'));
|
||||||
|
$this->statisticsTotal['expired'] = array_sum(array_column($this->statistics, 'expired'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function mkSearchCondition( $timestampStart, $timestampEnd, $id_user,$id_ticket_tpye,$id_account,$valid_in_interval ,$expire_in_interval,$created_in_interval ){
|
||||||
|
$query = Ticket::find();
|
||||||
|
|
||||||
|
Helper::queryAccountConstraint($query, 'ticket.id_account');
|
||||||
|
|
||||||
|
$query->with('ticketType' );
|
||||||
|
$query->with('user');
|
||||||
|
$query->with('customer');
|
||||||
|
|
||||||
|
$query->andFilterWhere([
|
||||||
|
'id_user' => $id_user,
|
||||||
|
'id_ticket_type' => $id_ticket_type,
|
||||||
|
'id_account' => $id_account,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$all = (!($valid_in_interval) && !($expire_in_interval) && !($created_in_interval) )
|
||||||
|
||
|
||||||
|
($valid_in_interval == true && $expire_in_interval == true && $created_in_interval);
|
||||||
|
|
||||||
|
$dateConditions = [];
|
||||||
|
$start = $timestampStart;
|
||||||
|
$end = $timestampEnd;
|
||||||
|
|
||||||
|
if( $all || $created_in_interval ){
|
||||||
|
$dateConditions[] = Helper::queryInIntervalRule('ticket.created_at', $start, $end);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $all || $valid_in_interval ){
|
||||||
|
$dateConditions[] = Helper::queryValidRule('ticket.start', 'ticket.end', $start, $end);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $all || $expire_in_interval ){
|
||||||
|
$dateConditions[] = Helper::queryExpireRule('ticket.start', 'ticket.end', $start, $end);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( count($dateConditions) == 1 ){
|
||||||
|
$query->andWhere($dateConditions[0]);
|
||||||
|
}else if ( count($dateConditions) > 1 ){
|
||||||
|
$cond = ['or'];
|
||||||
|
foreach ($dateConditions as $c){
|
||||||
|
$cond[] = $c;
|
||||||
|
}
|
||||||
|
$query->andWhere($cond);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|||||||
@ -2,12 +2,21 @@
|
|||||||
|
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\widgets\ActiveForm;
|
use yii\widgets\ActiveForm;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
use kartik\widgets\DatePicker;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $model backend\models\TicketSearch */
|
/* @var $model backend\models\TicketSearch */
|
||||||
/* @var $form yii\widgets\ActiveForm */
|
/* @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">
|
<div class="ticket-search">
|
||||||
|
|
||||||
<?php $form = ActiveForm::begin([
|
<?php $form = ActiveForm::begin([
|
||||||
@ -15,37 +24,51 @@ use yii\widgets\ActiveForm;
|
|||||||
'method' => 'get',
|
'method' => 'get',
|
||||||
]); ?>
|
]); ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'id_ticket') ?>
|
|
||||||
|
|
||||||
<?= $form->field($model, 'id_user') ?>
|
<div class='row'>
|
||||||
|
<div class='col-md-4'>
|
||||||
<?= $form->field($model, 'id_ticket_type') ?>
|
<?= $form->field($model, 'id_user')->dropDownList($userOptions) ?>
|
||||||
|
</div>
|
||||||
<?= $form->field($model, 'id_account') ?>
|
<div class='col-md-4'>
|
||||||
|
<?= $form->field($model, 'id_ticket_type')->dropDownList($ticketTypeOptions) ?>
|
||||||
<?= $form->field($model, 'id_discount') ?>
|
</div>
|
||||||
|
<div class='col-md-4'>
|
||||||
<?php // echo $form->field($model, 'start') ?>
|
<?= $form->field($model, 'id_account')->dropDownList($accountOptions) ?>
|
||||||
|
</div>
|
||||||
<?php // echo $form->field($model, 'end') ?>
|
</div>
|
||||||
|
|
||||||
<?php // echo $form->field($model, 'max_usage_count') ?>
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
<?php // echo $form->field($model, 'usage_count') ?>
|
<?= $form->field($model, 'start')->widget(DatePicker::classname(), [
|
||||||
|
'pluginOptions' => [
|
||||||
<?php // echo $form->field($model, 'status') ?>
|
'autoclose'=>true,
|
||||||
|
'format' => 'yyyy.mm.dd'
|
||||||
<?php // echo $form->field($model, 'price_brutto') ?>
|
]
|
||||||
|
]) ?>
|
||||||
<?php // echo $form->field($model, 'comment') ?>
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
<?php // echo $form->field($model, 'created_at') ?>
|
<?= $form->field($model, 'end') ->widget(DatePicker::classname(), [
|
||||||
|
'pluginOptions' => [
|
||||||
<?php // echo $form->field($model, 'updated_at') ?>
|
'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">
|
<div class="form-group">
|
||||||
<?= Html::submitButton(Yii::t('common/ticket', 'Search'), ['class' => 'btn btn-primary']) ?>
|
<?= Html::submitButton(Yii::t('common/ticket', 'Search'), ['class' => 'btn btn-primary']) ?>
|
||||||
<?= Html::resetButton(Yii::t('common/ticket', 'Reset'), ['class' => 'btn btn-default']) ?>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php ActiveForm::end(); ?>
|
<?php ActiveForm::end(); ?>
|
||||||
|
|||||||
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>
|
||||||
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\grid\GridView;
|
use yii\grid\GridView;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
use yii\data\ArrayDataProvider;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $searchModel backend\models\TicketSearch */
|
/* @var $searchModel backend\models\TicketSearch */
|
||||||
@ -9,38 +11,100 @@ use yii\grid\GridView;
|
|||||||
|
|
||||||
$this->title = Yii::t('common/ticket', 'Tickets');
|
$this->title = Yii::t('common/ticket', 'Tickets');
|
||||||
$this->params['breadcrumbs'][] = $this->title;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="ticket-index">
|
<div class="ticket-index">
|
||||||
|
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||||
|
|
||||||
<p>
|
|
||||||
<?= Html::a(Yii::t('common/ticket', 'Create Ticket'), ['create'], ['class' => 'btn btn-success']) ?>
|
|
||||||
</p>
|
<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([
|
<?= GridView::widget([
|
||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
'filterModel' => $searchModel,
|
|
||||||
'columns' => [
|
'columns' => [
|
||||||
['class' => 'yii\grid\SerialColumn'],
|
[
|
||||||
|
'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',
|
||||||
|
|
||||||
'id_ticket',
|
['class' => 'yii\grid\ActionColumn',
|
||||||
'id_user',
|
'template' => '{view}'
|
||||||
'id_ticket_type',
|
],
|
||||||
'id_account',
|
|
||||||
'id_discount',
|
|
||||||
// 'start',
|
|
||||||
// 'end',
|
|
||||||
// 'max_usage_count',
|
|
||||||
// 'usage_count',
|
|
||||||
// 'status',
|
|
||||||
// 'price_brutto',
|
|
||||||
// 'comment',
|
|
||||||
// 'created_at',
|
|
||||||
// 'updated_at',
|
|
||||||
|
|
||||||
['class' => 'yii\grid\ActionColumn'],
|
|
||||||
],
|
],
|
||||||
]); ?>
|
]); ?>
|
||||||
|
|
||||||
|
|||||||
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>
|
||||||
@ -14,16 +14,6 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
|
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
<p>
|
|
||||||
<?= Html::a(Yii::t('common/ticket', 'Update'), ['update', 'id' => $model->id_ticket], ['class' => 'btn btn-primary']) ?>
|
|
||||||
<?= Html::a(Yii::t('common/ticket', 'Delete'), ['delete', 'id' => $model->id_ticket], [
|
|
||||||
'class' => 'btn btn-danger',
|
|
||||||
'data' => [
|
|
||||||
'confirm' => Yii::t('common/ticket', 'Are you sure you want to delete this item?'),
|
|
||||||
'method' => 'post',
|
|
||||||
],
|
|
||||||
]) ?>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<?= DetailView::widget([
|
<?= DetailView::widget([
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
-0.0.3
|
||||||
|
admin oldal bérlet statisztika
|
||||||
|
admin oldal módosított menü
|
||||||
|
admin oldal vendég bérlet történet
|
||||||
-0.0.2
|
-0.0.2
|
||||||
alpha verzió
|
alpha verzió
|
||||||
-0.0.1
|
-0.0.1
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace common\components;
|
namespace common\components;
|
||||||
|
|
||||||
|
use \Yii;
|
||||||
|
|
||||||
class Helper
|
class Helper
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -23,6 +25,39 @@ class Helper
|
|||||||
$query->andFilterWhere([ '<' , $field , $end ] );
|
$query->andFilterWhere([ '<' , $field , $end ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function queryInIntervalRule( $field , $start,$end ){
|
||||||
|
return ['and',[ '>=', $field , $start ] , [ '<' , $field , $end ] ];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function queryExpireRule( $field_start,$field_end , $start,$end ){
|
||||||
|
|
||||||
|
return ['and' ,['<',$field_start, $end], ['>=' , $field_end , $start ], ['<=' , $field_end , $end ] ];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function queryValidRule( $field_start ,$field_end , $start,$end ){
|
||||||
|
return ['and' ,['<',$field_start, $end], ['>=' , $field_end , $start ] ];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sqlInIntervalRule( $field , $paramStart,$paramEnd ){
|
||||||
|
return ' ' .$field . ' >= ' . $paramStart . ' and ' . $field . ' < ' . $paramEnd ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sqlExpireRule( $field_start,$field_end , $paramStart,$paramEnd ){
|
||||||
|
return ' ' .$field_start . ' < ' . $paramEnd . ' and ' . $field_end . ' < ' . $paramEnd ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sqlValidRule( $field_start ,$field_end , $paramStart,$paramEnd ){
|
||||||
|
return ' ' .$field_start . ' < ' . $paramEnd . ' and ' . $field_end . ' >=' . $paramStart ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function queryAccountConstraint($query,$field){
|
||||||
|
if ( !RoleDefinition::isAdmin() ){
|
||||||
|
$query->innerJoin("user_account_assignment", $field . ' = user_account_assignment.id_account' );
|
||||||
|
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function roleLabels(){
|
public static function roleLabels(){
|
||||||
return [
|
return [
|
||||||
'reception' => Yii::t('common/role' ,'Reception'),
|
'reception' => Yii::t('common/role' ,'Reception'),
|
||||||
|
|||||||
@ -3,5 +3,5 @@ return [
|
|||||||
'adminEmail' => 'rocho02@gmail.com',
|
'adminEmail' => 'rocho02@gmail.com',
|
||||||
'supportEmail' => 'rocho02@gmail.com',
|
'supportEmail' => 'rocho02@gmail.com',
|
||||||
'user.passwordResetTokenExpire' => 3600,
|
'user.passwordResetTokenExpire' => 3600,
|
||||||
'version' => 'v0.0.2'
|
'version' => 'v0.0.3'
|
||||||
];
|
];
|
||||||
|
|||||||
27
common/messages/hu/backend/ticket.php
Normal file
27
common/messages/hu/backend/ticket.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Message translations.
|
||||||
|
*
|
||||||
|
* This file is automatically generated by 'yii message' command.
|
||||||
|
* It contains the localizable messages extracted from source code.
|
||||||
|
* You may modify this file by translating the extracted messages.
|
||||||
|
*
|
||||||
|
* Each array element represents the translation (value) of a message (key).
|
||||||
|
* If the value is empty, the message is considered as not translated.
|
||||||
|
* Messages that no longer need translation will have their translations
|
||||||
|
* enclosed between a pair of '@@' marks.
|
||||||
|
*
|
||||||
|
* Message string can be used with plural forms format. Check i18n section
|
||||||
|
* of the guide for details.
|
||||||
|
*
|
||||||
|
* NOTE: this file must be saved in UTF-8 encoding.
|
||||||
|
*/
|
||||||
|
return [
|
||||||
|
'Card' => 'Bérlet kártya',
|
||||||
|
'Customer' => 'Vendég',
|
||||||
|
'Created in interval' => 'Kiadva az időszakban',
|
||||||
|
'End of interval' => 'Időszak vége',
|
||||||
|
'Expire in interval' => 'Lejár az időszakban',
|
||||||
|
'Start of interval' => 'Idászak kezdete',
|
||||||
|
'Valid in interval' => 'Érvényes az időszakban',
|
||||||
|
];
|
||||||
@ -17,13 +17,11 @@
|
|||||||
* NOTE: this file must be saved in UTF-8 encoding.
|
* NOTE: this file must be saved in UTF-8 encoding.
|
||||||
*/
|
*/
|
||||||
return [
|
return [
|
||||||
'Reset' => 'Reset',
|
'{customer} Tickets' => '{customer} bérlet történet',
|
||||||
'Are you sure you want to delete this item?' => 'Biztosan törölni szeretné a bérletet?',
|
|
||||||
'Comment' => 'Megjegyzés',
|
'Comment' => 'Megjegyzés',
|
||||||
'Create' => 'Mentés',
|
'Create' => 'Mentés',
|
||||||
'Create Ticket' => 'Új bérlet',
|
'Create Ticket' => 'Új bérlet',
|
||||||
'Created At' => 'Hozzáadva',
|
'Created At' => 'Hozzáadva',
|
||||||
'Delete' => 'Törlés',
|
|
||||||
'End' => 'Érvényesség vége',
|
'End' => 'Érvényesség vége',
|
||||||
'Id Account' => 'Kassza',
|
'Id Account' => 'Kassza',
|
||||||
'Id Discount' => 'Kedvezmény',
|
'Id Discount' => 'Kedvezmény',
|
||||||
@ -32,6 +30,7 @@ return [
|
|||||||
'Id User' => 'Felhasználó',
|
'Id User' => 'Felhasználó',
|
||||||
'Max Usage Count' => 'Max alkalmak',
|
'Max Usage Count' => 'Max alkalmak',
|
||||||
'Price Brutto' => 'Bruttó ár',
|
'Price Brutto' => 'Bruttó ár',
|
||||||
|
'Reset' => 'Reset',
|
||||||
'Search' => 'Keresés',
|
'Search' => 'Keresés',
|
||||||
'Start' => 'Érvényesség kezdete',
|
'Start' => 'Érvényesség kezdete',
|
||||||
'Status' => 'Státusz',
|
'Status' => 'Státusz',
|
||||||
|
|||||||
@ -4,6 +4,9 @@ namespace common\models;
|
|||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\db\ActiveRecord;
|
use yii\db\ActiveRecord;
|
||||||
|
use yii\db\Query;
|
||||||
|
use yii\db\Expression;
|
||||||
|
use common\components\Helper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the model class for table "ticket".
|
* This is the model class for table "ticket".
|
||||||
@ -13,6 +16,7 @@ use yii\db\ActiveRecord;
|
|||||||
* @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
|
||||||
@ -69,6 +73,8 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
|||||||
'comment' => Yii::t('common/ticket', 'Comment'),
|
'comment' => Yii::t('common/ticket', 'Comment'),
|
||||||
'created_at' => Yii::t('common/ticket', 'Created At'),
|
'created_at' => Yii::t('common/ticket', 'Created At'),
|
||||||
'updated_at' => Yii::t('common/ticket', 'Updated At'),
|
'updated_at' => Yii::t('common/ticket', 'Updated At'),
|
||||||
|
'id_card' => Yii::t('backend/ticket','Card'),
|
||||||
|
'id_customer' => Yii::t('backend/ticket','Customer'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +82,27 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
|||||||
public function getCard(){
|
public function getCard(){
|
||||||
return $this->hasOne( Card::className(), ["id_card" =>"id_card" ] );
|
return $this->hasOne( Card::className(), ["id_card" =>"id_card" ] );
|
||||||
}
|
}
|
||||||
|
public function getCardNumber(){
|
||||||
|
$result = "";
|
||||||
|
$card = $this->card;
|
||||||
|
if ( isset($card)){
|
||||||
|
$result = $card->number;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCustomer(){
|
||||||
|
return $this->hasOne( Customer::className(), ["id_customer_card" =>"id_card" ] )->via('card');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCustomerName(){
|
||||||
|
$result = "";
|
||||||
|
$customer = $this->customer;
|
||||||
|
if ( isset($customer)){
|
||||||
|
$result = $customer->name;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
public function getUser(){
|
public function getUser(){
|
||||||
return $this->hasOne( User::className(), ["id" =>"id_user" ] );
|
return $this->hasOne( User::className(), ["id" =>"id_user" ] );
|
||||||
@ -148,4 +175,60 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function mkStatisticQuery($start,$end,$id_card = null){
|
||||||
|
// $sql = "select
|
||||||
|
// ticket_type.name,
|
||||||
|
// count(ticket.id_ticket) as total ,
|
||||||
|
// sum(case when ticket.end > '2015-11-05' and ticket.start <= '2015-11-05' then 1 else 0 end) as valid,
|
||||||
|
// sum(case when ticket.created_at < '2015-11-06' and ticket.created_at >= '2015-11-05' then 1 else 0 end) as created,
|
||||||
|
// sum(case when ticket.created_at < '2015-11-06' and ticket.created_at >= '2015-11-05' then transfer.money else 0 end) as created_money,
|
||||||
|
// sum(case when ticket.created_at < '2015-11-06' and ticket.created_at >= '2015-11-05' and transfer.paid_at is not null then transfer.money else 0 end) as created_money_paid,
|
||||||
|
// sum(case when ticket.created_at < '2015-11-06' and ticket.created_at >= '2015-11-05' and transfer.paid_at is null then transfer.money else 0 end) as created_money_not_paid,
|
||||||
|
// sum(case when ticket.created_at >= '2015-11-06' and ticket.created_at < '2015-11-05' and transfer.paid_at < '2015-11-06' and transfer.paid_at >= '2015-11-05' then transfer.money else 0 end) as dept_paid,
|
||||||
|
// sum(case when ticket.end < '2015-11-06' and ticket.created_at >= '2015-11-05' then 1 else 0 end) as expired
|
||||||
|
// from ticket_type
|
||||||
|
// inner join ticket on ticket.id_ticket_type = ticket_type.id_ticket_type
|
||||||
|
// inner join transfer on ticket.id_ticket = transfer.id_object and transfer.type = 20
|
||||||
|
// group by ticket_type.name;";
|
||||||
|
|
||||||
|
$query = new Query();
|
||||||
|
$query->addSelect( [
|
||||||
|
new Expression( 'ticket_type.id_ticket_type as id'),
|
||||||
|
new Expression( 'ticket_type.name as name'),
|
||||||
|
new Expression( 'coalesce( count(ticket.id_ticket),0) as total'),
|
||||||
|
|
||||||
|
new Expression( "coalesce( sum( case when ". Helper::sqlValidRule('ticket.start', 'ticket.end', ':start', ':end') . " then 1 else 0 end) , 0) as valid" ), //valid
|
||||||
|
new Expression( "coalesce( sum( case when ". Helper::sqlInIntervalRule('ticket.created_at', ':start', ':end') . " then 1 else 0 end) , 0) as created" ),//created
|
||||||
|
new Expression( "coalesce( sum( case when ". Helper::sqlInIntervalRule('ticket.created_at', ':start', ':end') . " then transfer.money else 0 end) , 0) as created_money" ),//created_money
|
||||||
|
new Expression( "coalesce( sum( case when " . Helper::sqlExpireRule('ticket.start', 'ticket.end', ':start', ":end") . " then 1 else 0 end) , 0) as expired" ),
|
||||||
|
|
||||||
|
|
||||||
|
]);
|
||||||
|
|
||||||
|
$query->from('ticket_type');
|
||||||
|
$query->innerJoin('ticket', 'ticket.id_ticket_type = ticket_type.id_ticket_type');
|
||||||
|
$query->innerJoin('transfer', 'ticket.id_ticket = transfer.id_object and transfer.type = '. Transfer::TYPE_TICKET );
|
||||||
|
|
||||||
|
Helper::queryAccountConstraint($query, 'ticket.id_account');
|
||||||
|
|
||||||
|
$query->andFilterWhere(['id_card' =>$id_card]);
|
||||||
|
|
||||||
|
$query->andWhere(
|
||||||
|
[
|
||||||
|
'or',
|
||||||
|
Helper::queryInIntervalRule('ticket.created_at', $start, $end),
|
||||||
|
Helper::queryValidRule('ticket.start', 'ticket.end', $start, $end),
|
||||||
|
Helper::queryExpireRule('ticket.start', 'ticket.end', $start, $end),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$query->groupBy("ticket_type.id_ticket_type, ticket_type.name");
|
||||||
|
|
||||||
|
$query->params([':start' => $start, ':end' => $end]);
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user