add hidden account, cart insert/delete
add hidden account support add delete/payout buttons to carts add backend product sales with pdf export add frontend product sales with pdf export add frontend ticket sales with pdf export
This commit is contained in:
@@ -24,7 +24,7 @@ return [
|
||||
'datetimeFormat' => 'yyyy.MM.dd HH:mm',
|
||||
'timeFormat' => 'HH:mm',
|
||||
'locale' => 'hu-Hu',
|
||||
'timeZone' => 'UTC',
|
||||
'timeZone' => 'Europe/Budapest',
|
||||
'defaultTimeZone' => 'UTC',
|
||||
'nullDisplay' => "-",
|
||||
],
|
||||
|
||||
@@ -44,6 +44,7 @@ return [
|
||||
'Reset' => 'Reset',
|
||||
'Sale Price' => 'Eladási ár',
|
||||
'Search' => 'Keresés',
|
||||
'Sell' => 'Fizetve',
|
||||
'Sell product' => 'Termék eladás',
|
||||
'Stock' => 'Raktáron',
|
||||
'Stock {stock} lower then {count}!' => 'Raktáron {stock} kevesebb mint {count}!',
|
||||
|
||||
@@ -29,5 +29,8 @@ return [
|
||||
'Update {modelClass}: ' => '{modelClass} módosítás: ',
|
||||
'pieces' => 'db',
|
||||
'Transfers Summary' => 'Bevétel',
|
||||
'Daily transfers' => 'Napi bevételek'
|
||||
'Daily transfers' => 'Napi bevételek',
|
||||
'Ticket sale detailed' => 'Bérlet eladás részletes',
|
||||
'Product sale detailed' => 'Termék eladás részletes',
|
||||
'Sales detailed' => 'Termék eladás részletes',
|
||||
];
|
||||
|
||||
@@ -96,7 +96,7 @@ class Account extends \yii\db\ActiveRecord
|
||||
static function types() {
|
||||
return [
|
||||
self::TYPE_ALL => Yii::t('common/account', 'Account'),
|
||||
// self::TYPE_VALUE_HIDDEN => Yii::t('common/account', 'Only the name is visible'),
|
||||
self::TYPE_VALUE_HIDDEN => Yii::t('common/account', 'Only the name is visible'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -355,6 +355,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord
|
||||
|
||||
$transfer->status = $status;
|
||||
$transfer->type = Transfer::TYPE_TICKET;
|
||||
$transfer->direction = Transfer::DIRECTION_IN;
|
||||
|
||||
$transfer->id_object = $ticket->id_ticket;
|
||||
|
||||
|
||||
@@ -157,10 +157,14 @@ class TransferListSearch extends Transfer
|
||||
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]);
|
||||
|
||||
$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
||||
|
||||
$query->andWhere(['account.type' => Account::TYPE_ALL ]);
|
||||
|
||||
}
|
||||
|
||||
protected function addQueryFilters($query){
|
||||
|
||||
$query->innerJoin("account", "transfer.id_account = account.id_account");
|
||||
|
||||
$this->addAccountConstraint($query);
|
||||
|
||||
$query->andFilterWhere([
|
||||
@@ -323,12 +327,12 @@ class TransferListSearch extends Transfer
|
||||
|
||||
protected function readTickets(){
|
||||
$query = (new \yii\db\Query());
|
||||
$query->select(['user.username as user_name', 'account.name as account_name','ticket_type.name as ticket_type_name' , 'transfer.count AS ticket_count', 'transfer.money AS ticket_money','transfer.item_price AS ticket_item_price', 'transfer.created_at as ticket_created_at','transfer.paid_at as ticket_paid_at']);
|
||||
$query->select([ 'customer.name as customer_name', 'user.username as user_name', 'account.name as account_name','ticket_type.name as ticket_type_name' , 'transfer.count AS ticket_count', 'transfer.money AS ticket_money','transfer.item_price AS ticket_item_price', 'transfer.created_at as ticket_created_at','transfer.paid_at as ticket_paid_at']);
|
||||
$query->from('transfer');
|
||||
$query->andWhere(['transfer.type' => Transfer::TYPE_TICKET]);
|
||||
$query->innerJoin("ticket", "ticket.id_ticket = transfer.id_object");
|
||||
$query->innerJoin("customer","customer.id_customer = transfer.id_customer");
|
||||
$query->innerJoin("ticket_type", "ticket.id_ticket_type = ticket_type.id_ticket_type");
|
||||
$query->innerJoin("account", "transfer.id_account = account.id_account");
|
||||
$query->innerJoin("user", "transfer.id_user = user.id");
|
||||
$query->orderBy(['transfer.created_at' => SORT_ASC]);
|
||||
$this->addQueryFilters($query);
|
||||
@@ -352,7 +356,7 @@ class TransferListSearch extends Transfer
|
||||
$query->innerJoin("sale", "sale.id_sale = transfer.id_object");
|
||||
$query->innerJoin("product", "sale.id_product = product.id_product");
|
||||
$query->innerJoin("product_category", "product.id_product_category = product_category.id_product_category");
|
||||
$query->innerJoin("account", "transfer.id_account = account.id_account");
|
||||
|
||||
$query->innerJoin("user", "transfer.id_user = user.id");
|
||||
$query->orderBy(['transfer.created_at' => SORT_ASC]);
|
||||
$this->addQueryFilters($query);
|
||||
@@ -372,7 +376,6 @@ class TransferListSearch extends Transfer
|
||||
$query->from('transfer');
|
||||
$query->andWhere(['transfer.type' => Transfer::TYPE_MONEY_MOVEMENT_OUT]);
|
||||
$query->innerJoin("money_movement", "money_movement.id_money_movement = transfer.id_object");
|
||||
$query->innerJoin("account", "transfer.id_account = account.id_account");
|
||||
$query->innerJoin("user", "transfer.id_user = user.id");
|
||||
$query->orderBy(['transfer.created_at' => SORT_ASC]);
|
||||
$this->addQueryFilters($query);
|
||||
|
||||
286
common/models/TransferSaleSearch.php
Normal file
286
common/models/TransferSaleSearch.php
Normal file
@@ -0,0 +1,286 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\Transfer;
|
||||
use yii\base\Object;
|
||||
use yii\db\Query;
|
||||
use yii\db\Expression;
|
||||
use common\models\Account;
|
||||
|
||||
use yii\helpers\ArrayHelper;
|
||||
use common\models\MoneyMovement;
|
||||
/**
|
||||
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
||||
*/
|
||||
class TransferSaleSearch extends Transfer
|
||||
{
|
||||
|
||||
public $start;
|
||||
public $end;
|
||||
|
||||
public $timestampStart;
|
||||
public $timestampEnd;
|
||||
|
||||
public $totals;
|
||||
|
||||
public $accounts;
|
||||
|
||||
public $types;
|
||||
|
||||
public $users;
|
||||
|
||||
public $productCategories;
|
||||
|
||||
public $productOptions;
|
||||
/**
|
||||
* all money gained with product sell
|
||||
* */
|
||||
public $productMoney;
|
||||
/**
|
||||
* all money gained with product sell grouped by category
|
||||
* */
|
||||
public $productMoneies;
|
||||
|
||||
/**
|
||||
* total gained money
|
||||
* */
|
||||
public $total;
|
||||
|
||||
/**
|
||||
* all product transfer
|
||||
* */
|
||||
public $products;
|
||||
|
||||
public $productsByCategory;
|
||||
|
||||
public $category;
|
||||
public $status;
|
||||
public $id_product;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
|
||||
[[ 'start', ], 'date', 'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
|
||||
[[ 'end' , ], 'date' ,'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
|
||||
|
||||
[ [ 'id_account','id_user' ,'category','status','id_product' ] , 'integer'],
|
||||
['types', 'each', 'rule' => ['integer']],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function attributeLabels(){
|
||||
$result = parent::attributeLabels();
|
||||
$result['category'] = "Termék kategória";
|
||||
$result['id_product'] = "Termék";
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Transfer::find();
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
|
||||
|
||||
$this->load($params);
|
||||
|
||||
|
||||
if (!$this->validate()) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->readProductsMoney();
|
||||
$this->calcTotal();
|
||||
|
||||
// $this->readProductsByCategory();
|
||||
// $this->readProductsByCategoryDetailed();
|
||||
|
||||
|
||||
$this->readProducts();
|
||||
|
||||
}
|
||||
|
||||
protected function calcTotal(){
|
||||
$this->total = 0;
|
||||
$this->total += $this->productMoney;
|
||||
}
|
||||
|
||||
|
||||
protected function addAccountConstraint($query){
|
||||
$query->innerJoin("user_account_assignment",'transfer.id_account = user_account_assignment.id_account' );
|
||||
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]);
|
||||
|
||||
$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
||||
|
||||
$query->andWhere(['account.type' => Account::TYPE_ALL ]);
|
||||
|
||||
}
|
||||
|
||||
protected function addQueryFilters($query){
|
||||
$query->innerJoin("account", "transfer.id_account = account.id_account");
|
||||
|
||||
$this->addAccountConstraint($query);
|
||||
|
||||
$query->andFilterWhere([
|
||||
'transfer.id_account' => $this->id_account,
|
||||
'transfer.id_user' => $this->id_user,
|
||||
'transfer.type' => $this->type,
|
||||
'transfer.id_user' => $this->id_user,
|
||||
'product_category.id_product_category' => $this->category,
|
||||
'transfer.status' => $this->status,
|
||||
'product.id_product' => $this->id_product,
|
||||
]);
|
||||
|
||||
$created_condition = ['and',[ '>=', 'transfer.created_at', $this->timestampStart ] ,[ '<', 'transfer.created_at', $this->timestampEnd ] ];
|
||||
$paid_condition = ['and',[ '>=', 'transfer.paid_at', $this->timestampStart ] ,[ '<', 'transfer.paid_at', $this->timestampEnd ] ];
|
||||
|
||||
|
||||
$query->andFilterWhere(['or' , $created_condition , $paid_condition]);
|
||||
|
||||
// $query->andWhere(['transfer.status' => Transfer::STATUS_PAID]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function readProductsByCategory(){
|
||||
|
||||
|
||||
$query = (new \yii\db\Query());
|
||||
$query->select(['coalesce(sum(transfer.money),0) AS product_money', 'coalesce(sum(transfer.count),0) as category_count', 'product_category.name as category_name']);
|
||||
$query->from('transfer');
|
||||
$query->groupBy(['product_category.id_product_category','product_category.name']);
|
||||
$query->andWhere(['transfer.type' => Transfer::TYPE_PRODUCT]);
|
||||
$query->innerJoin("sale", "sale.id_sale = transfer.id_object");
|
||||
$query->innerJoin("product", "sale.id_product = product.id_product");
|
||||
$query->innerJoin("product_category", "product.id_product_category = product_category.id_product_category");
|
||||
$this->addQueryFilters($query);
|
||||
|
||||
$this->productMoneies = $query->all();
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function readProductsByCategoryDetailed(){
|
||||
|
||||
$formatted = [];
|
||||
$formatted['categories'] = [];
|
||||
$formatted['total'] = 0;
|
||||
$prevCategory = null;
|
||||
$curCategory = null;
|
||||
|
||||
$category = null;
|
||||
|
||||
$query = (new \yii\db\Query());
|
||||
$query->select(['product_category.id_product_category as product_category_id','product_category.name as product_category_name', 'product.name as product_name' ,'coalesce(sum(transfer.money),0) AS product_money', 'coalesce(sum(transfer.count),0) as product_count']);
|
||||
$query->from('transfer');
|
||||
$query->groupBy(['product.id_product','product.name','product_category.id_product_category','product_category.name']);
|
||||
$query->andWhere(['transfer.type' => Transfer::TYPE_PRODUCT]);
|
||||
$query->innerJoin("sale", "sale.id_sale = transfer.id_object");
|
||||
$query->innerJoin("product", "sale.id_product = product.id_product");
|
||||
$query->innerJoin("product_category", "product.id_product_category = product_category.id_product_category");
|
||||
$query->orderBy(['product_category.name' => SORT_ASC,'product.name' => SORT_ASC]);
|
||||
$this->addQueryFilters($query);
|
||||
|
||||
$result = $query->all();
|
||||
|
||||
foreach ($result as $row){
|
||||
$curCategory = $row['product_category_id'];
|
||||
if ( $curCategory != $prevCategory ){
|
||||
//store last category
|
||||
if ( $category != null ){
|
||||
$formatted['categories'][] = $category;
|
||||
}
|
||||
$prevCategory = $curCategory;
|
||||
//create new category
|
||||
$category = [];
|
||||
$category['category'] = [];
|
||||
$category['category']['name'] = $row['product_category_name'];
|
||||
$category['category']['id'] = $row['product_category_id'];
|
||||
$category['products'] = [];
|
||||
$category['total'] = 0;
|
||||
|
||||
}
|
||||
$category['products'][] = $row;
|
||||
$category['total'] += $row['product_money'];
|
||||
$formatted['total'] += $row['product_money'];
|
||||
|
||||
}
|
||||
|
||||
if ( $category != null ){
|
||||
$formatted['categories'][]= $category;
|
||||
}
|
||||
|
||||
$this->productsByCategory = $formatted;
|
||||
|
||||
}
|
||||
|
||||
protected function readProductsMoney(){
|
||||
|
||||
|
||||
$query = (new \yii\db\Query());
|
||||
$query->select(['coalesce(sum(transfer.money),0) AS product_money' ]);
|
||||
$query->from('transfer');
|
||||
$query->andWhere(['transfer.type' => Transfer::TYPE_PRODUCT]);
|
||||
$query->innerJoin("sale", "sale.id_sale = transfer.id_object");
|
||||
$query->innerJoin("product", "sale.id_product = product.id_product");
|
||||
$query->innerJoin("product_category", "product.id_product_category = product_category.id_product_category");
|
||||
$this->addQueryFilters($query);
|
||||
|
||||
$this->productMoney = $query->scalar();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
protected function readProducts(){
|
||||
|
||||
$query = (new \yii\db\Query());
|
||||
$query->select([ 'transfer.id_transfer as id_transfer', 'customer.name as customer_name' ,'user.username as user_name','account.name as account_name' , 'product_category.name as product_category_name', 'product.name as product_name', 'transfer.money AS product_money', 'transfer.count AS product_count', 'transfer.money AS product_money','transfer.item_price AS product_item_price', 'transfer.created_at as product_created_at','transfer.paid_at as product_paid_at']);
|
||||
$query->from('transfer');
|
||||
$query->andWhere(['transfer.type' => Transfer::TYPE_PRODUCT]);
|
||||
$query->innerJoin("sale", "sale.id_sale = transfer.id_object");
|
||||
$query->innerJoin("product", "sale.id_product = product.id_product");
|
||||
$query->innerJoin("product_category", "product.id_product_category = product_category.id_product_category");
|
||||
$query->leftJoin("customer", "transfer.id_customer = customer.id_customer");
|
||||
$query->innerJoin("user", "transfer.id_user = user.id");
|
||||
$query->orderBy(['transfer.created_at' => SORT_ASC]);
|
||||
$this->addQueryFilters($query);
|
||||
|
||||
$this->products = $query->all();
|
||||
|
||||
for ($i = 0; $i < count($this->products) ;$i++ ){
|
||||
$this->products[$i]['product_created_at'] = Yii::$app->formatter->asDatetime($this->products[$i]['product_created_at'], 'yyyy.MM.dd HH:mm:ss');
|
||||
$this->products[$i]['product_paid_at'] = empty($this->products[$i]['product_paid_at'] ) ? '-' : Yii::$app->formatter->asDatetime($this->products[$i]['product_paid_at'], 'yyyy.MM.dd HH:mm:ss');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
230
common/models/TransferTicketSearch.php
Normal file
230
common/models/TransferTicketSearch.php
Normal file
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\Transfer;
|
||||
use yii\base\Object;
|
||||
use yii\db\Query;
|
||||
use yii\db\Expression;
|
||||
use common\models\Account;
|
||||
|
||||
use yii\helpers\ArrayHelper;
|
||||
use common\models\MoneyMovement;
|
||||
/**
|
||||
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
||||
*/
|
||||
class TransferTicketSearch extends Transfer
|
||||
{
|
||||
|
||||
public $start;
|
||||
public $end;
|
||||
|
||||
public $timestampStart;
|
||||
public $timestampEnd;
|
||||
|
||||
|
||||
|
||||
// public $totalsCreatedAt = ['total' => 0, 'accounts' =>[] ];
|
||||
// public $totalsCreatedAtNotPaid= ['total' => 0, 'accounts' =>[]];
|
||||
// public $totalsCreatedAtPaid= ['total' => 0, 'accounts' =>[]];
|
||||
// public $totalsPaidAt= ['total' => 0, 'accounts' =>[]];
|
||||
// public $totalsPaidAtNotCreatedAt= ['total' => 0, 'accounts' =>[]];
|
||||
|
||||
|
||||
public $totals;
|
||||
|
||||
public $accounts;
|
||||
|
||||
public $types;
|
||||
|
||||
public $users;
|
||||
|
||||
|
||||
/**
|
||||
* all money gained with ticket sell
|
||||
* */
|
||||
public $ticketMoney;
|
||||
/**
|
||||
* total gained money
|
||||
* */
|
||||
public $total;
|
||||
|
||||
/**
|
||||
* ticket sale statisitc
|
||||
* */
|
||||
public $ticketStats;
|
||||
|
||||
public $tickets;
|
||||
|
||||
public $customer;
|
||||
|
||||
public $ticketTypes;
|
||||
public $id_ticket_type;
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
|
||||
[[ 'start', ], 'date', 'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
|
||||
[[ 'end' , ], 'date' ,'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
|
||||
|
||||
[ [ 'id_account','id_user' ,'id_ticket_type' ] , 'integer'],
|
||||
['types', 'each', 'rule' => ['integer']],
|
||||
[['customer' ] , 'string' , 'max' => 200 ]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function attributeLabels(){
|
||||
$result = parent::attributeLabels();
|
||||
$result['id_ticket_type'] = 'Bérlet típus';
|
||||
$result['customer'] = 'Vendég';
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Transfer::find();
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
|
||||
|
||||
$this->load($params);
|
||||
|
||||
|
||||
if (!$this->validate()) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->readTicketMoney();
|
||||
$this->calcTotal();
|
||||
|
||||
$this->readTicketStas();
|
||||
|
||||
|
||||
$this->readTickets();
|
||||
|
||||
}
|
||||
|
||||
protected function calcTotal(){
|
||||
$this->total = 0;
|
||||
$this->total += $this->ticketMoney;
|
||||
}
|
||||
|
||||
|
||||
protected function addAccountConstraint($query){
|
||||
$query->innerJoin("user_account_assignment",'transfer.id_account = user_account_assignment.id_account' );
|
||||
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]);
|
||||
|
||||
$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
||||
|
||||
$query->andWhere(['account.type' => Account::TYPE_ALL ]);
|
||||
|
||||
}
|
||||
|
||||
protected function addQueryFilters($query){
|
||||
$query->innerJoin("account", "transfer.id_account = account.id_account");
|
||||
|
||||
$this->addAccountConstraint($query);
|
||||
|
||||
$query->andFilterWhere([
|
||||
'transfer.id_account' => $this->id_account,
|
||||
'transfer.id_user' => $this->id_user,
|
||||
'transfer.type' => $this->type,
|
||||
'transfer.id_user' => $this->id_user,
|
||||
'ticket_type.id_ticket_type' => $this->id_ticket_type,
|
||||
]);
|
||||
|
||||
$created_condition = ['and',[ '>=', 'transfer.created_at', $this->timestampStart ] ,[ '<', 'transfer.created_at', $this->timestampEnd ] ];
|
||||
$paid_condition = ['and',[ '>=', 'transfer.paid_at', $this->timestampStart ] ,[ '<', 'transfer.paid_at', $this->timestampEnd ] ];
|
||||
|
||||
|
||||
$query->andFilterWhere(['or' , $created_condition , $paid_condition]);
|
||||
$query->andFilterWhere(['like' , 'LOWER(customer.name)' , strtolower( $this->customer ) ]);
|
||||
|
||||
$query->andWhere(['transfer.status' => Transfer::STATUS_PAID]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function readTicketStas(){
|
||||
|
||||
$query = (new \yii\db\Query());
|
||||
$query->select(['ticket_type.name as ticket_type_name' , 'coalesce(sum(abs(transfer.count)),0) AS ticket_count', 'coalesce(sum(abs(transfer.money)),0) AS ticket_money']);
|
||||
$query->from('transfer');
|
||||
$query->andWhere(['transfer.type' => Transfer::TYPE_TICKET]);
|
||||
$query->innerJoin("ticket", "ticket.id_ticket = transfer.id_object");
|
||||
$query->innerJoin("ticket_type", "ticket.id_ticket_type = ticket_type.id_ticket_type");
|
||||
$query->innerJoin("customer","customer.id_customer = transfer.id_customer");
|
||||
$query->groupBy(['ticket_type.id_ticket_type','ticket_type.name']);
|
||||
$this->addQueryFilters($query);
|
||||
|
||||
|
||||
$this->ticketStats = $query->all();
|
||||
}
|
||||
|
||||
|
||||
protected function readTicketMoney(){
|
||||
|
||||
$query = (new \yii\db\Query());
|
||||
$query->select([' coalesce(sum(abs(transfer.money)),0) AS ticket_money']);
|
||||
$query->from('transfer');
|
||||
$query->andWhere(['transfer.type' => Transfer::TYPE_TICKET]);
|
||||
$query->innerJoin("ticket", "ticket.id_ticket = transfer.id_object");
|
||||
$query->innerJoin("ticket_type", "ticket.id_ticket_type = ticket_type.id_ticket_type");
|
||||
$query->innerJoin("customer","customer.id_customer = transfer.id_customer");
|
||||
$this->addQueryFilters($query);
|
||||
$this->ticketMoney = $query->scalar();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
protected function readTickets(){
|
||||
$query = (new \yii\db\Query());
|
||||
$query->select([ 'customer.name as customer_name', 'user.username as user_name', 'account.name as account_name','ticket_type.name as ticket_type_name' , 'transfer.count AS ticket_count', 'transfer.money AS ticket_money','transfer.item_price AS ticket_item_price', 'transfer.created_at as ticket_created_at','transfer.paid_at as ticket_paid_at']);
|
||||
$query->from('transfer');
|
||||
$query->andWhere(['transfer.type' => Transfer::TYPE_TICKET]);
|
||||
$query->innerJoin("ticket", "ticket.id_ticket = transfer.id_object");
|
||||
$query->innerJoin("customer","customer.id_customer = transfer.id_customer");
|
||||
$query->innerJoin("ticket_type", "ticket.id_ticket_type = ticket_type.id_ticket_type");
|
||||
$query->innerJoin("user", "transfer.id_user = user.id");
|
||||
$query->orderBy(['transfer.created_at' => SORT_ASC]);
|
||||
$this->addQueryFilters($query);
|
||||
|
||||
|
||||
$this->tickets = $query->all();
|
||||
|
||||
for ($i = 0; $i < count($this->tickets) ;$i++ ){
|
||||
$this->tickets[$i]['ticket_created_at'] = Yii::$app->formatter->asDatetime($this->tickets[$i]['ticket_created_at'], 'yyyy.MM.dd HH:mm:ss');
|
||||
$this->tickets[$i]['ticket_paid_at'] = empty($this->tickets[$i]['ticket_paid_at'] ) ? '-' : Yii::$app->formatter->asDatetime($this->tickets[$i]['ticket_paid_at'], 'yyyy.MM.dd HH:mm:ss');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user