add transfer#list pdf download, fix helper#fixascii function
This commit is contained in:
parent
932f071c13
commit
39ae361505
@ -14,6 +14,7 @@ use backend\models\TransferListSearch;
|
|||||||
use backend\models\TransferSaleSearch;
|
use backend\models\TransferSaleSearch;
|
||||||
use common\models\ProductCategory;
|
use common\models\ProductCategory;
|
||||||
use common\models\Product;
|
use common\models\Product;
|
||||||
|
use backend\models\TransferListUserGroupedSearch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TransferController implements the CRUD actions for Transfer model.
|
* TransferController implements the CRUD actions for Transfer model.
|
||||||
@ -28,7 +29,7 @@ class TransferController extends \backend\controllers\BackendController
|
|||||||
'rules' => [
|
'rules' => [
|
||||||
// allow authenticated users
|
// allow authenticated users
|
||||||
[
|
[
|
||||||
'actions' => [ 'index','view','summary','list',"sale","sale-pdf" ],
|
'actions' => [ 'index','view','summary','list',"sale","sale-pdf" ,'list-user-grouped'],
|
||||||
'allow' => true,
|
'allow' => true,
|
||||||
'roles' => ['admin','employee','reception'],
|
'roles' => ['admin','employee','reception'],
|
||||||
],
|
],
|
||||||
@ -75,7 +76,75 @@ class TransferController extends \backend\controllers\BackendController
|
|||||||
$searchModel->search(Yii::$app->request->queryParams);
|
$searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
|
||||||
|
|
||||||
return $this->render('list', [
|
if ( $searchModel->output == 'pdf'){
|
||||||
|
$user = User::findOne(\Yii::$app->user->id);
|
||||||
|
$mpdf=new \mPDF('utf-8', 'A4-L');
|
||||||
|
$fn = "";
|
||||||
|
$ov = '_total_content_pdf';
|
||||||
|
$dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username;
|
||||||
|
$interval="";
|
||||||
|
$account = "";
|
||||||
|
$currentUser= "";
|
||||||
|
if ( isset($searchModel->currentAccount) ){
|
||||||
|
$account =( "_kassza_".$searchModel->currentAccount->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset($searchModel->currentUser) ){
|
||||||
|
$currentUser = ( "_felhasznalo_".$searchModel->currentUser->username);
|
||||||
|
}
|
||||||
|
if ( isset($searchModel->timestampStart) ){
|
||||||
|
$interval .="_tol_". \Yii::$app->formatter->asDatetime($searchModel->timestampStart,'yyyyMMdd_HHmm');
|
||||||
|
}
|
||||||
|
if ( isset($searchModel->timestampEnd) ){
|
||||||
|
$interval .="_ig_". \Yii::$app->formatter->asDatetime($searchModel->timestampEnd,'yyyyMMdd_HHmm');
|
||||||
|
}
|
||||||
|
if ( $searchModel->outputView == 'easy'){
|
||||||
|
$ov = '_total_easy';
|
||||||
|
$fn="napi_bevetelek_egyszeru";
|
||||||
|
}else if ( $searchModel->outputView == 'medium'){
|
||||||
|
$ov = '_total_medium';
|
||||||
|
$fn="napi_bevetelek_kozepes";
|
||||||
|
}else if ( $searchModel->outputView == 'detailed'){
|
||||||
|
$ov = '_total_detailed';
|
||||||
|
$fn="napi_bevetelek_reszletes";
|
||||||
|
}else{
|
||||||
|
$ov = '_total_content_pdf';
|
||||||
|
$fn="napi_bevetelek.teljes";
|
||||||
|
}
|
||||||
|
$fn = $fn. $interval . $dt .$account .$currentUser. ".pdf";
|
||||||
|
|
||||||
|
$mpdf->useSubstitutions=false;
|
||||||
|
$mpdf->simpleTables = true;
|
||||||
|
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
|
||||||
|
$mpdf->setFooter('{PAGENO} / {nb}');
|
||||||
|
$mpdf->WriteHTML($this->renderPartial($ov, [
|
||||||
|
'searchModel' => $searchModel,
|
||||||
|
]));
|
||||||
|
$mpdf->Output($fn, 'D');
|
||||||
|
exit;
|
||||||
|
}else{
|
||||||
|
return $this->render('list', [
|
||||||
|
'searchModel' => $searchModel,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all Transfer models.
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionListUserGrouped()
|
||||||
|
{
|
||||||
|
$searchModel = new TransferListUserGroupedSearch();
|
||||||
|
$searchModel->accounts = Account::read();
|
||||||
|
$searchModel->users = User::read();
|
||||||
|
|
||||||
|
$searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
|
||||||
|
|
||||||
|
return $this->render('list_user_grouped', [
|
||||||
'searchModel' => $searchModel,
|
'searchModel' => $searchModel,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -88,6 +157,7 @@ class TransferController extends \backend\controllers\BackendController
|
|||||||
public function actionSale()
|
public function actionSale()
|
||||||
{
|
{
|
||||||
$searchModel = new TransferSaleSearch();
|
$searchModel = new TransferSaleSearch();
|
||||||
|
$searchModel->mode = 'admin';
|
||||||
$searchModel->accounts = Account::read();
|
$searchModel->accounts = Account::read();
|
||||||
$searchModel->users = User::read();
|
$searchModel->users = User::read();
|
||||||
$searchModel->productCategories = ProductCategory::read();
|
$searchModel->productCategories = ProductCategory::read();
|
||||||
@ -104,6 +174,7 @@ class TransferController extends \backend\controllers\BackendController
|
|||||||
|
|
||||||
public function actionSalePdf(){
|
public function actionSalePdf(){
|
||||||
$searchModel = new TransferSaleSearch();
|
$searchModel = new TransferSaleSearch();
|
||||||
|
$searchModel->mode = 'admin';
|
||||||
$searchModel->accounts = Account::read();
|
$searchModel->accounts = Account::read();
|
||||||
$searchModel->users = User::read();
|
$searchModel->users = User::read();
|
||||||
$searchModel->productCategories = ProductCategory::read();
|
$searchModel->productCategories = ProductCategory::read();
|
||||||
|
|||||||
@ -12,17 +12,23 @@ use common\models\Account;
|
|||||||
class TransferListSearch extends \common\models\TransferListSearch
|
class TransferListSearch extends \common\models\TransferListSearch
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function init(){
|
||||||
|
parent::init();
|
||||||
|
$this->mode = 'admin';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function addAccountConstraint($query){
|
protected function addAccountConstraint($query){
|
||||||
if ( !RoleDefinition::isAdmin() ){
|
// if ( !RoleDefinition::isAdmin() ){
|
||||||
$query->innerJoin("user_account_assignment",'transfer.id_account = user_account_assignment.id_account' );
|
// $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(['user_account_assignment.id_user' => Yii::$app->user->id ]);
|
||||||
$query->andWhere(['account.type' => Account::TYPE_ALL ]);
|
// $query->andWhere(['account.type' => Account::TYPE_ALL ]);
|
||||||
|
|
||||||
if ( RoleDefinition::isReception()){
|
// if ( RoleDefinition::isReception()){
|
||||||
$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
// $query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
43
backend/models/TransferListUserGroupedSearch.php
Normal file
43
backend/models/TransferListUserGroupedSearch.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use common\models\Transfer;
|
||||||
|
use common\components\RoleDefinition;
|
||||||
|
use common\models\Account;
|
||||||
|
use common\components\DailyListing;
|
||||||
|
/**
|
||||||
|
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
||||||
|
*/
|
||||||
|
class TransferListUserGroupedSearch extends \common\models\TransferListSearch
|
||||||
|
{
|
||||||
|
|
||||||
|
public $ticketMoneyByUser;
|
||||||
|
|
||||||
|
public function init(){
|
||||||
|
parent::init();
|
||||||
|
$this->mode = 'admin';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function search($params)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->load($params);
|
||||||
|
|
||||||
|
if (!$this->validate()) {
|
||||||
|
}
|
||||||
|
|
||||||
|
$listing = new DailyListing();
|
||||||
|
$listing->mode = $this->mode;
|
||||||
|
$listing->loadFilters($this);
|
||||||
|
|
||||||
|
$this->ticketMoneyByUser = $listing->readTicketMoneyByUser();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -16,7 +16,7 @@ use yii\helpers\Html;
|
|||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div class="navbar-header">
|
<div class="navbar-header">
|
||||||
<a class="navbar-brand" href="#">Web Recepció</a>
|
<a class="navbar-brand" href="#">Adminisztráció</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="navbar-custom-menu">
|
<div class="navbar-custom-menu">
|
||||||
|
|||||||
61
backend/views/transfer/_list_pdf_head.php
Normal file
61
backend/views/transfer/_list_pdf_head.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
use common\components\RoleDefinition;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\helpers\Url;
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if ( $searchModel->output == 'pdf'){
|
||||||
|
?>
|
||||||
|
<link rel='stylesheet' href='<?php echo \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')?>'>
|
||||||
|
<style>
|
||||||
|
|
||||||
|
.item-transfer {
|
||||||
|
border: 1px solid #b4b4b4;
|
||||||
|
margin-top: 12px;
|
||||||
|
padding-top: 6px;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table td{
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.count, td.money{
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.name{
|
||||||
|
/* width: 600px; */
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-category-product td.name{
|
||||||
|
/* width: 600px; */
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-category-product td.count{
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-category-product td.money{
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<?php if ( isset($searchModel->outputView ) || $type == 'full' ){?>
|
||||||
|
<h1><?php echo $label ?></h1>
|
||||||
|
<?php }?>
|
||||||
|
<?php
|
||||||
|
if ( $searchModel->outputView == 'easy'){
|
||||||
|
echo $this->render('_view_search_list',['searchModel'=>$searchModel]);
|
||||||
|
}
|
||||||
|
else if ( $searchModel->outputView == 'medium'){
|
||||||
|
echo $this->render('_view_search_list',['searchModel'=>$searchModel]);
|
||||||
|
}
|
||||||
|
else if ( $searchModel->outputView == 'detailed'){
|
||||||
|
echo $this->render('_view_search_list',['searchModel'=>$searchModel]);
|
||||||
|
}else if ( $type == 'full'){
|
||||||
|
echo $this->render('_view_search_list',['searchModel'=>$searchModel]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
63
backend/views/transfer/_search_list_user_grouped.php
Normal file
63
backend/views/transfer/_search_list_user_grouped.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
use kartik\widgets\DatePicker;
|
||||||
|
use frontend\components\HtmlHelper;
|
||||||
|
use common\models\Transfer;
|
||||||
|
use kartik\widgets\DateTimePicker;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model common\models\TransferSearch */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$accountOptions = ['' =>'Mind']+ HtmlHelper::mkAccountOptions( $model->accounts );
|
||||||
|
$userOptions = ['' => 'Mind'] + HtmlHelper::mkOptions($model->users,'id','username');
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="transfer-search">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin([
|
||||||
|
'action' => ['list'],
|
||||||
|
'method' => 'get',
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'start')->widget(DateTimePicker::classname(), [
|
||||||
|
'pluginOptions' => [
|
||||||
|
'autoclose'=>true,
|
||||||
|
'format' => 'yyyy.mm.dd hh:ii'
|
||||||
|
]
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'end') ->widget(DateTimePicker::classname(), [
|
||||||
|
'pluginOptions' => [
|
||||||
|
'autoclose'=>true,
|
||||||
|
'format' => 'yyyy.mm.dd hh:ii'
|
||||||
|
]
|
||||||
|
]) ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'id_account')->dropDownList($accountOptions) ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'id_user')->dropDownList($userOptions) ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton(Yii::t('frontend/transfer', 'Search'), ['class' => 'btn btn-primary']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
9
backend/views/transfer/_total_content.php
Normal file
9
backend/views/transfer/_total_content.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<div role="tabpanel" class="tab-pane active" id="easy">
|
||||||
|
<?php echo $this->render('_total_easy', ['searchModel' => $searchModel]); ?>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane" id="medium">
|
||||||
|
<?php echo $this->render('_total_medium', ['searchModel' => $searchModel]); ?>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane" id="detailed">
|
||||||
|
<?php echo $this->render('_total_detailed', ['searchModel' => $searchModel]); ?>
|
||||||
|
</div>
|
||||||
8
backend/views/transfer/_total_content_pdf.php
Normal file
8
backend/views/transfer/_total_content_pdf.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
echo $this->render('_list_pdf_head',[ 'searchModel' =>$searchModel, 'label' => 'Napi bevételek','type' =>'full']);
|
||||||
|
?>
|
||||||
|
<?php echo $this->render('_total_easy', ['searchModel' => $searchModel]); ?>
|
||||||
|
<pagebreak />
|
||||||
|
<?php echo $this->render('_total_medium', ['searchModel' => $searchModel]); ?>
|
||||||
|
<pagebreak />
|
||||||
|
<?php echo $this->render('_total_detailed', ['searchModel' => $searchModel]); ?>
|
||||||
175
backend/views/transfer/_total_detailed.php
Normal file
175
backend/views/transfer/_total_detailed.php
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
<?php
|
||||||
|
use common\components\RoleDefinition;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\helpers\Url;
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
echo $this->render('_list_pdf_head',[ 'searchModel' =>$searchModel, 'label' => 'Napi bevételek - Rézsletes','type' =>'detailed']);
|
||||||
|
?>
|
||||||
|
<h2>Részletes összesítés</h2>
|
||||||
|
<?php
|
||||||
|
//////////////////////////
|
||||||
|
// Bérletek
|
||||||
|
////////////////////////
|
||||||
|
?>
|
||||||
|
<h3>Bérletek</h3>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if ( !isset($searchModel->output) ){
|
||||||
|
$pdfUrl = Url::current([ Html::getInputName($searchModel, 'output') => 'pdf']);
|
||||||
|
echo Html::a("Teljes PDF letöltése", $pdfUrl,['class' => 'btn btn-primary btn-all' ]);
|
||||||
|
|
||||||
|
$pdfUrl = Url::current([ Html::getInputName($searchModel, 'output') => 'pdf', Html::getInputName($searchModel, 'outputView') => 'detailed']);
|
||||||
|
echo Html::a("Egyszerű összesítő Pdf", $pdfUrl,['class' => 'btn btn-primary' ]);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<table class="table table-bordered table-striped table-summary">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Kiadva</th>
|
||||||
|
<th>Fizetve</th>
|
||||||
|
<th>Kassza</th>
|
||||||
|
<th>Felhasználó</th>
|
||||||
|
<th>Bérlet típus</th>
|
||||||
|
<th>Egység ár</th>
|
||||||
|
<th>Mennyiség</th>
|
||||||
|
<th>Összeg</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($searchModel->tickets as $t ){?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $t['ticket_created_at']?> </td>
|
||||||
|
<td><?php echo $t['ticket_paid_at']?> </td>
|
||||||
|
<td><?php echo $t['account_name']?> </td>
|
||||||
|
<td><?php echo $t['user_name']?> </td>
|
||||||
|
<td><?php echo $t['ticket_type_name'] ?></td>
|
||||||
|
<td class='money'><?php echo $t['ticket_item_price']?> Ft</td>
|
||||||
|
<td class='count'><?php echo $t['ticket_count']?> Db</td>
|
||||||
|
<td class='money'><?php echo $t['ticket_money']?> FT</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php if ( count($searchModel->tickets ) == 0 ) {
|
||||||
|
?>
|
||||||
|
Nincs találat
|
||||||
|
<?php
|
||||||
|
}else{?>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
||||||
|
Összesen: <?php echo $searchModel->ticketMoney; ?> Ft
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<pagebreak />
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
//////////////////////////
|
||||||
|
// Termék eladás
|
||||||
|
////////////////////////
|
||||||
|
?>
|
||||||
|
<h3>Termék eladások</h3>
|
||||||
|
<table class="table table-bordered table-striped table-summary">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Kiadva</th>
|
||||||
|
<th>Fizetve</th>
|
||||||
|
<th>Kassza</th>
|
||||||
|
<th>Felhasználó</th>
|
||||||
|
<th>Kategória</th>
|
||||||
|
<th>Termék</th>
|
||||||
|
<th>Egység ár</th>
|
||||||
|
<th>Mennyiség</th>
|
||||||
|
<th>Összeg</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($searchModel->products as $p ){?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $p['product_created_at']?> </td>
|
||||||
|
<td><?php echo $p['product_paid_at']?> </td>
|
||||||
|
<td><?php echo $p['account_name']?> </td>
|
||||||
|
<td><?php echo $p['user_name']?> </td>
|
||||||
|
<td><?php echo $p['product_category_name'] ?></td>
|
||||||
|
<td><?php echo $p['product_name'] ?></td>
|
||||||
|
<td class='money'><?php echo $p['product_item_price']?> Ft</td>
|
||||||
|
<td class='count'><?php echo $p['product_count']?> Db</td>
|
||||||
|
<td class='money'><?php echo $p['product_money']?> FT</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php if ( count($searchModel->products ) == 0 ) {
|
||||||
|
?>
|
||||||
|
Nincs találat
|
||||||
|
<?php
|
||||||
|
}else{?>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
||||||
|
Összesen: <?php echo $searchModel->productMoney; ?> Ft
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<pagebreak />
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
//////////////////////////
|
||||||
|
// Pénzmozgások
|
||||||
|
////////////////////////
|
||||||
|
?>
|
||||||
|
<h3>Pénzmozgások</h3>
|
||||||
|
<table class="table table-bordered table-striped table-summary">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Dátum</th>
|
||||||
|
<th>Kassza</th>
|
||||||
|
<th>Felhasználó</th>
|
||||||
|
<th>Név</th>
|
||||||
|
<th>Típus</th>
|
||||||
|
<th>Összeg</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($searchModel->moneyMovements as $p ){?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $p['money_movement_created_at']?> </td>
|
||||||
|
<td><?php echo $p['account_name']?> </td>
|
||||||
|
<td><?php echo $p['user_name']?> </td>
|
||||||
|
<td><?php echo $p['money_movement_name'] ?></td>
|
||||||
|
<td><?php echo $p['money_movement_type_name'] ?></td>
|
||||||
|
<td class='money'><?php echo $p['signed_money']?> Ft</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php if ( count($searchModel->moneyMovements ) == 0 ) {
|
||||||
|
?>
|
||||||
|
Nincs találat
|
||||||
|
<?php
|
||||||
|
}else{?>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
||||||
|
Összesen: <?php echo $searchModel->moneyMovementMoneis; ?> Ft
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 text-right" style="text-decoration: underline; font-weight: bold;">
|
||||||
|
Végösszeg: <?php echo $searchModel->total; ?> Ft
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
69
backend/views/transfer/_total_easy.php
Normal file
69
backend/views/transfer/_total_easy.php
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
use common\components\RoleDefinition;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\helpers\Url;
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
echo $this->render('_list_pdf_head',[ 'searchModel' =>$searchModel, 'label' => 'Napi bevételek - Egyszerű','type' =>'easy']);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<h2>Egyszerű összesítés</h2>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if ( !isset($searchModel->output) ){
|
||||||
|
|
||||||
|
$pdfUrl = Url::current([ Html::getInputName($searchModel, 'output') => 'pdf']);
|
||||||
|
echo Html::a("Teljes PDF letöltése", $pdfUrl,['class' => 'btn btn-primary btn-all' ]);
|
||||||
|
|
||||||
|
$pdfUrl = Url::current([ Html::getInputName($searchModel, 'output') => 'pdf', Html::getInputName($searchModel, 'outputView') => 'easy']);
|
||||||
|
echo Html::a("Egyszerű összesítő Pdf", $pdfUrl,['class' => 'btn btn-primary' ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
<h3>Bruttó</h3>
|
||||||
|
<table class="table table-bordered table-striped table-summary">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>Bérletek</th>
|
||||||
|
<td class="money"><?php echo $searchModel->ticketMoney?> FT</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Termékek</th>
|
||||||
|
<td class="money"><?php echo $searchModel->productMoney?> FT</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Pénzmozgások</th>
|
||||||
|
<td class="money"><?php echo $searchModel->moneyMovementMoneis?> FT</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Végösszeg bruttó</th>
|
||||||
|
<td class="money"><span style='border-bottom: 1px solid black'><?php echo $searchModel->total?> FT</span></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<?php if( RoleDefinition::isAdmin() ) {?>
|
||||||
|
<h3>Nettó</h3>
|
||||||
|
<table class="table table-bordered table-striped table-summary">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>Bérletek</th>
|
||||||
|
<td class="money"><?php echo $searchModel->ticketMoney?> FT</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Termékek</th>
|
||||||
|
<td class="money"><?php echo $searchModel->productMoneyNetto?> FT</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Pénzmozgások</th>
|
||||||
|
<td class="money"><?php echo $searchModel->moneyMovementMoneis?> FT</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Végösszeg nettó</th>
|
||||||
|
<td class="money"><span style='border-bottom: 1px solid black'><?php echo $searchModel->totalNetto?> FT</span></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php }?>
|
||||||
158
backend/views/transfer/_total_medium.php
Normal file
158
backend/views/transfer/_total_medium.php
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
<?php
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\helpers\Url;
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
echo $this->render('_list_pdf_head',[ 'searchModel' =>$searchModel, 'label' => 'Napi bevételek - Közepes', 'type' =>'medium']);
|
||||||
|
?>
|
||||||
|
<h2>Közepes összesítés</h2>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if ( !isset($searchModel->output) ){
|
||||||
|
$pdfUrl = Url::current([ Html::getInputName($searchModel, 'output') => 'pdf']);
|
||||||
|
echo Html::a("Teljes PDF letöltése", $pdfUrl,['class' => 'btn btn-primary btn-all' ]);
|
||||||
|
$pdfUrl = Url::current([ Html::getInputName($searchModel, 'output') => 'pdf', Html::getInputName($searchModel, 'outputView') => 'medium']);
|
||||||
|
echo Html::a("Közepes összesítő Pdf", $pdfUrl,['class' => 'btn btn-primary' ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<h3>Bérletek típus szerint</h3>
|
||||||
|
<table class="table table-bordered table-striped table-summary">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Bérlet típus</th>
|
||||||
|
<th>Mennyiség</th>
|
||||||
|
<th>Összeg</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
foreach ( $searchModel->ticketStats as $ticketStat ) {
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td class="name"><?php echo $ticketStat['ticket_type_name'] ?></td>
|
||||||
|
<td class="count"><?php echo $ticketStat['ticket_count']?> Db</td>
|
||||||
|
<td class="money"><?php echo $ticketStat['ticket_money']?> FT</td>
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
||||||
|
Összesen: <?php echo $searchModel->ticketMoney; ?> Ft
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h3>Termékek kategória szerint</h3>
|
||||||
|
<table class="table table-bordered table-striped table-summary">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Termék kategória</th>
|
||||||
|
<th>Mennyiség</th>
|
||||||
|
<th>Összeg</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
foreach ( $searchModel->productMoneies as $pm ) {
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td class="name"><?php echo $pm['category_name'] ?></td>
|
||||||
|
<td class="count"><?php echo $pm['category_count']?> Db</td>
|
||||||
|
<td class="money"><?php echo $pm['product_money']?> FT</td>
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
||||||
|
Összesen: <?php echo $searchModel->productMoney; ?> Ft
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>Termékek kategória szerint részletes</h3>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
foreach($searchModel->productsByCategory['categories'] as $categoryHolder ){
|
||||||
|
|
||||||
|
$products = $categoryHolder['products'];
|
||||||
|
?>
|
||||||
|
<h4><?php echo $categoryHolder['category']['name']?></h4>
|
||||||
|
|
||||||
|
<table class="table table-bordered table-striped table-summary table-category-product">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Termék</th>
|
||||||
|
<th>Mennyiség</th>
|
||||||
|
<th>Összeg</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ( $products as $p){?>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class='name'><?php echo $p['product_name'] ?></td>
|
||||||
|
<td class='count'><?php echo $p['product_count'] ?> Db</td>
|
||||||
|
<td class='money'><?php echo $p['product_money']?> FT</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<?php }?>
|
||||||
|
<tr class="warning">
|
||||||
|
<td><?php echo "Összesen" ?></td>
|
||||||
|
<td><?php ?></td>
|
||||||
|
<td class='money'><?php echo $categoryHolder['total']?> FT</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
||||||
|
Összesen:
|
||||||
|
<?php
|
||||||
|
echo $searchModel->productsByCategory['total'];
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>Pénzmozgások típus szerint</h3>
|
||||||
|
<table class="table table-bordered table-striped table-summary">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Pénzmozgás típus</th>
|
||||||
|
<th>Mennyiség</th>
|
||||||
|
<th>Összeg</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
foreach ( $searchModel->moneyMovementsByType as $mmStat ) {
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td class="name"><?php echo $mmStat['name'] ?></td>
|
||||||
|
<td class="count"><?php echo $mmStat['money_movement_count']?> Db</td>
|
||||||
|
<td class="money"><?php echo $mmStat['money_movement_money']?> FT</td>
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
||||||
|
Összesen: <?php echo $searchModel->moneyMovementMoneis; ?> Ft
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 text-right" style="text-decoration: underline; font-weight: bold;">
|
||||||
|
Végösszeg: <?php echo $searchModel->total; ?> Ft
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
21
backend/views/transfer/_view_easy_total.php
Normal file
21
backend/views/transfer/_view_easy_total.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<table class="table table-bordered table-striped table-summary">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>Bérletek</th>
|
||||||
|
<td class="money"><?php echo $ticketMoney?> FT
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Termékek</th>
|
||||||
|
<td class="money"><?php echo $productMoney?> FT</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Pénzmozgások</th>
|
||||||
|
<td class="money"><?php echo $moneyMovementMoneis?> FT</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Végösszeg bruttó</th>
|
||||||
|
<td class="money"><span style='border-bottom: 1px solid black'><?php echo $total?> FT</span></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
45
backend/views/transfer/_view_search_list.php
Normal file
45
backend/views/transfer/_view_search_list.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<table class="table table-bordered">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Időszak kezdete
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<?php echo $searchModel->start?>
|
||||||
|
</td>
|
||||||
|
<th>
|
||||||
|
Időszak vége
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<?php echo $searchModel->end?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Kassza
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
if ( isset($searchModel->currentAccount)){
|
||||||
|
echo $searchModel->currentAccount->name;
|
||||||
|
}else{
|
||||||
|
echo "Mind";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
<th>
|
||||||
|
Felhasználó
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
if ( isset($searchModel->currentUser)){
|
||||||
|
echo $searchModel->currentUser->username;
|
||||||
|
}else{
|
||||||
|
echo "Mind";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
</table>
|
||||||
@ -3,9 +3,11 @@ use yii\helpers\Html;
|
|||||||
use yii\grid\GridView;
|
use yii\grid\GridView;
|
||||||
use yii\widgets\ListView;
|
use yii\widgets\ListView;
|
||||||
use yii\base\Widget;
|
use yii\base\Widget;
|
||||||
|
use common\components\RoleDefinition;
|
||||||
|
use yii\helpers\Url;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $searchModel common\models\TransferSearch */
|
/* @var $searchModel common\models\TransferListSearch */
|
||||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
|
||||||
$this->title = Yii::t ( 'frontend/transfer', 'Daily transfers' );
|
$this->title = Yii::t ( 'frontend/transfer', 'Daily transfers' );
|
||||||
@ -42,6 +44,10 @@ td.name{
|
|||||||
.table-category-product td.money{
|
.table-category-product td.money{
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-all{
|
||||||
|
margin-right: 6px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="transfer-index">
|
<div class="transfer-index">
|
||||||
@ -49,347 +55,43 @@ td.name{
|
|||||||
<h1><?= Html::encode($this->title) ?></h1>
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
<?php echo $this->render('_search_list', ['model' => $searchModel]); ?>
|
<?php echo $this->render('_search_list', ['model' => $searchModel]); ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if ( isset($searchModel->currentUser) ){
|
||||||
|
?>
|
||||||
|
|
||||||
|
<table class='table table-striped'>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Felhasználó:
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<?php echo $searchModel->currentUser->username?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<!-- Nav tabs -->
|
<!-- Nav tabs -->
|
||||||
<ul class="nav nav-tabs" role="tablist">
|
<ul class="nav nav-tabs" role="tablist">
|
||||||
<li role="presentation" class="active"><a href="#big"
|
<li role="presentation" class="active"><a href="#easy"
|
||||||
aria-controls="big" role="tab" data-toggle="tab">Egyszerű összesítő</a></li>
|
aria-controls="easy" role="tab" data-toggle="tab">Egyszerű összesítő</a></li>
|
||||||
<li role="presentation"><a href="#medium" aria-controls="medium"
|
<li role="presentation"><a href="#medium" aria-controls="medium"
|
||||||
role="tab" data-toggle="tab">Közepes összesítő</a></li>
|
role="tab" data-toggle="tab">Közepes összesítő</a></li>
|
||||||
<li role="presentation"><a href="#detailed" aria-controls="detailed"
|
<li role="presentation"><a href="#detailed" aria-controls="detailed"
|
||||||
role="tab" data-toggle="tab">Részletes összesítő</a></li>
|
role="tab" data-toggle="tab">Részletes összesítő</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
<!-- Tab panes -->
|
<!-- Tab panes -->
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div role="tabpanel" class="tab-pane active" id="big">
|
<?php echo $this->render('_total_content', ['searchModel' => $searchModel]); ?>
|
||||||
<h2>Egyszerű összesítés</h2>
|
|
||||||
<table class="table table-bordered table-striped table-summary">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<th>Bérletek</th>
|
|
||||||
<td class="money"><?php echo $searchModel->ticketMoney?> FT</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>Termékek</th>
|
|
||||||
<td class="money"><?php echo $searchModel->productMoney?> FT</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>Pénzmozgások</th>
|
|
||||||
<td class="money"><?php echo $searchModel->moneyMovementMoneis?> FT</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>Végösszeg</th>
|
|
||||||
<td class="money"><span style='border-bottom: 1px solid black'><?php echo $searchModel->total?> FT</span></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div role="tabpanel" class="tab-pane" id="medium">
|
|
||||||
<h2>Közepes összesítés</h2>
|
|
||||||
|
|
||||||
<h3>Bérletek típus szerint</h3>
|
|
||||||
<table class="table table-bordered table-striped table-summary">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Bérlet típus</th>
|
|
||||||
<th>Mennyiség</th>
|
|
||||||
<th>Összeg</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php
|
|
||||||
foreach ( $searchModel->ticketStats as $ticketStat ) {
|
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
<td class="name"><?php echo $ticketStat['ticket_type_name'] ?></td>
|
|
||||||
<td class="count"><?php echo $ticketStat['ticket_count']?> Db</td>
|
|
||||||
<td class="money"><?php echo $ticketStat['ticket_money']?> FT</td>
|
|
||||||
</tr>
|
|
||||||
<?php } ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
|
||||||
Összesen: <?php echo $searchModel->ticketMoney; ?> Ft
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<h3>Termékek kategória szerint</h3>
|
|
||||||
<table class="table table-bordered table-striped table-summary">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Termék kategória</th>
|
|
||||||
<th>Mennyiség</th>
|
|
||||||
<th>Összeg</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php
|
|
||||||
foreach ( $searchModel->productMoneies as $pm ) {
|
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
<td class="name"><?php echo $pm['category_name'] ?></td>
|
|
||||||
<td class="count"><?php echo $pm['category_count']?> Db</td>
|
|
||||||
<td class="money"><?php echo $pm['product_money']?> FT</td>
|
|
||||||
</tr>
|
|
||||||
<?php } ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
|
||||||
Összesen: <?php echo $searchModel->productMoney; ?> Ft
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h3>Termékek kategória szerint részletes</h3>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
foreach($searchModel->productsByCategory['categories'] as $categoryHolder ){
|
|
||||||
|
|
||||||
$products = $categoryHolder['products'];
|
|
||||||
?>
|
|
||||||
<h4><?php echo $categoryHolder['category']['name']?></h4>
|
|
||||||
|
|
||||||
<table class="table table-bordered table-striped table-summary table-category-product">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Termék</th>
|
|
||||||
<th>Mennyiség</th>
|
|
||||||
<th>Összeg</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ( $products as $p){?>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td class='name'><?php echo $p['product_name'] ?></td>
|
|
||||||
<td class='count'><?php echo $p['product_count'] ?> Db</td>
|
|
||||||
<td class='money'><?php echo $p['product_money']?> FT</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<?php }?>
|
|
||||||
<tr class="warning">
|
|
||||||
<td><?php echo "Összesen" ?></td>
|
|
||||||
<td><?php ?></td>
|
|
||||||
<td class='money'><?php echo $categoryHolder['total']?> FT</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
|
||||||
Összesen:
|
|
||||||
<?php
|
|
||||||
echo $searchModel->productsByCategory['total'];
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h3>Pénzmozgások típus szerint</h3>
|
|
||||||
<table class="table table-bordered table-striped table-summary">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Pénzmozgás típus</th>
|
|
||||||
<th>Mennyiség</th>
|
|
||||||
<th>Összeg</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php
|
|
||||||
foreach ( $searchModel->moneyMovementsByType as $mmStat ) {
|
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
<td class="name"><?php echo $mmStat['name'] ?></td>
|
|
||||||
<td class="count"><?php echo $mmStat['money_movement_count']?> Db</td>
|
|
||||||
<td class="money"><?php echo $mmStat['money_movement_money']?> FT</td>
|
|
||||||
</tr>
|
|
||||||
<?php } ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
|
||||||
Összesen: <?php echo $searchModel->moneyMovementMoneis; ?> Ft
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12 text-right" style="text-decoration: underline; font-weight: bold;">
|
|
||||||
Végösszeg: <?php echo $searchModel->total; ?> Ft
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div role="tabpanel" class="tab-pane" id="detailed">
|
|
||||||
<h2>Részletes összesítés</h2>
|
|
||||||
<?php
|
|
||||||
//////////////////////////
|
|
||||||
// Bérletek
|
|
||||||
////////////////////////
|
|
||||||
?>
|
|
||||||
<h3>Bérletek</h3>
|
|
||||||
<table class="table table-bordered table-striped table-summary">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Kiadva</th>
|
|
||||||
<th>Fizetve</th>
|
|
||||||
<th>Kassza</th>
|
|
||||||
<th>Felhasználó</th>
|
|
||||||
<th>Bérlet típus</th>
|
|
||||||
<th>Egység ár</th>
|
|
||||||
<th>Mennyiség</th>
|
|
||||||
<th>Összeg</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($searchModel->tickets as $t ){?>
|
|
||||||
<tr>
|
|
||||||
<td><?php echo $t['ticket_created_at']?> </td>
|
|
||||||
<td><?php echo $t['ticket_paid_at']?> </td>
|
|
||||||
<td><?php echo $t['account_name']?> </td>
|
|
||||||
<td><?php echo $t['user_name']?> </td>
|
|
||||||
<td><?php echo $t['ticket_type_name'] ?></td>
|
|
||||||
<td class='money'><?php echo $t['ticket_item_price']?> Ft</td>
|
|
||||||
<td class='count'><?php echo $t['ticket_count']?> Db</td>
|
|
||||||
<td class='money'><?php echo $t['ticket_money']?> FT</td>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<?php } ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<?php if ( count($searchModel->tickets ) == 0 ) {
|
|
||||||
?>
|
|
||||||
Nincs találat
|
|
||||||
<?php
|
|
||||||
}else{?>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
|
||||||
Összesen: <?php echo $searchModel->ticketMoney; ?> Ft
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<?php
|
|
||||||
//////////////////////////
|
|
||||||
// Termék eladás
|
|
||||||
////////////////////////
|
|
||||||
?>
|
|
||||||
<h3>Termék eladások</h3>
|
|
||||||
<table class="table table-bordered table-striped table-summary">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Kiadva</th>
|
|
||||||
<th>Fizetve</th>
|
|
||||||
<th>Kassza</th>
|
|
||||||
<th>Felhasználó</th>
|
|
||||||
<th>Kategória</th>
|
|
||||||
<th>Termék</th>
|
|
||||||
<th>Egység ár</th>
|
|
||||||
<th>Mennyiség</th>
|
|
||||||
<th>Összeg</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($searchModel->products as $p ){?>
|
|
||||||
<tr>
|
|
||||||
<td><?php echo $p['product_created_at']?> </td>
|
|
||||||
<td><?php echo $p['product_paid_at']?> </td>
|
|
||||||
<td><?php echo $p['account_name']?> </td>
|
|
||||||
<td><?php echo $p['user_name']?> </td>
|
|
||||||
<td><?php echo $p['product_category_name'] ?></td>
|
|
||||||
<td><?php echo $p['product_name'] ?></td>
|
|
||||||
<td class='money'><?php echo $p['product_item_price']?> Ft</td>
|
|
||||||
<td class='count'><?php echo $p['product_count']?> Db</td>
|
|
||||||
<td class='money'><?php echo $p['product_money']?> FT</td>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<?php } ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<?php if ( count($searchModel->products ) == 0 ) {
|
|
||||||
?>
|
|
||||||
Nincs találat
|
|
||||||
<?php
|
|
||||||
}else{?>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
|
||||||
Összesen: <?php echo $searchModel->productMoney; ?> Ft
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<?php
|
|
||||||
//////////////////////////
|
|
||||||
// Pénzmozgások
|
|
||||||
////////////////////////
|
|
||||||
?>
|
|
||||||
<h3>Pénzmozgások</h3>
|
|
||||||
<table class="table table-bordered table-striped table-summary">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Dátum</th>
|
|
||||||
<th>Kassza</th>
|
|
||||||
<th>Felhasználó</th>
|
|
||||||
<th>Név</th>
|
|
||||||
<th>Típus</th>
|
|
||||||
<th>Összeg</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($searchModel->moneyMovements as $p ){?>
|
|
||||||
<tr>
|
|
||||||
<td><?php echo $p['money_movement_created_at']?> </td>
|
|
||||||
<td><?php echo $p['account_name']?> </td>
|
|
||||||
<td><?php echo $p['user_name']?> </td>
|
|
||||||
<td><?php echo $p['money_movement_name'] ?></td>
|
|
||||||
<td><?php echo $p['money_movement_type_name'] ?></td>
|
|
||||||
<td class='money'><?php echo $p['signed_money']?> Ft</td>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<?php } ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<?php if ( count($searchModel->moneyMovements ) == 0 ) {
|
|
||||||
?>
|
|
||||||
Nincs találat
|
|
||||||
<?php
|
|
||||||
}else{?>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
|
||||||
Összesen: <?php echo $searchModel->moneyMovementMoneis; ?> Ft
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12 text-right" style="text-decoration: underline; font-weight: bold;">
|
|
||||||
Végösszeg: <?php echo $searchModel->total; ?> Ft
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
66
backend/views/transfer/list_user_grouped.php
Normal file
66
backend/views/transfer/list_user_grouped.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\grid\GridView;
|
||||||
|
use yii\widgets\ListView;
|
||||||
|
use yii\base\Widget;
|
||||||
|
use common\components\RoleDefinition;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $searchModel backend\models\TransferListUserGroupedSearch */
|
||||||
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
|
||||||
|
$this->title = Yii::t ( 'frontend/transfer', 'Daily transfers' );
|
||||||
|
$this->params ['breadcrumbs'] [] = $this->title;
|
||||||
|
?>
|
||||||
|
<style>
|
||||||
|
.dl-transfer {
|
||||||
|
margin-bottom: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-transfer {
|
||||||
|
border: 1px solid #b4b4b4;
|
||||||
|
margin-top: 12px;
|
||||||
|
padding-top: 6px;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.count, td.money{
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.name{
|
||||||
|
width: 600px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-category-product td.name{
|
||||||
|
width: 600px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-category-product td.count{
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-category-product td.money{
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="transfer-index">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
<?php echo $this->render('_search_list_user_grouped', ['model' => $searchModel]); ?>
|
||||||
|
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
foreach ($searchModel->ticketMoneyByUser as $user){
|
||||||
|
echo "<h3>".$user['username']."</h3>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
@ -1,3 +1,6 @@
|
|||||||
|
-0.0.17
|
||||||
|
- fix helper::fixascii function
|
||||||
|
- admin pdf download
|
||||||
-0.0.16
|
-0.0.16
|
||||||
- add paid_by to transfer
|
- add paid_by to transfer
|
||||||
- customer/user cart post instead of ajax
|
- customer/user cart post instead of ajax
|
||||||
|
|||||||
532
common/components/DailyListing.php
Normal file
532
common/components/DailyListing.php
Normal file
@ -0,0 +1,532 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace common\components;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use common\models\Transfer;
|
||||||
|
use yii\db\Query;
|
||||||
|
use common\models\Account;
|
||||||
|
|
||||||
|
use common\models\MoneyMovement;
|
||||||
|
use common\components\RoleDefinition;
|
||||||
|
/**
|
||||||
|
* TransferListSearch represents the model behind the search form about `common\models\Transfer`.
|
||||||
|
*/
|
||||||
|
class DailyListing
|
||||||
|
{
|
||||||
|
|
||||||
|
public $mode = "reception";//reception or admin
|
||||||
|
/**
|
||||||
|
* string start date , inclusive
|
||||||
|
* */
|
||||||
|
public $start;
|
||||||
|
/**
|
||||||
|
* string end date, exclusive
|
||||||
|
* */
|
||||||
|
public $end;
|
||||||
|
/**
|
||||||
|
* date start date, inclusive
|
||||||
|
* */
|
||||||
|
public $timestampStart;
|
||||||
|
/**
|
||||||
|
* date end date , exlusive
|
||||||
|
* */
|
||||||
|
public $timestampEnd;
|
||||||
|
|
||||||
|
public $totals;
|
||||||
|
/**available accounts*/
|
||||||
|
public $accounts;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* */
|
||||||
|
public $types;
|
||||||
|
|
||||||
|
public $users;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* all money gained with ticket sell
|
||||||
|
* */
|
||||||
|
public $ticketMoney;
|
||||||
|
/**
|
||||||
|
* all money gained with ticket sell gruped by user
|
||||||
|
* */
|
||||||
|
public $ticketMoneyByUser;
|
||||||
|
/**
|
||||||
|
* all money gained with product sell
|
||||||
|
* */
|
||||||
|
public $productMoney;
|
||||||
|
|
||||||
|
public $productMoneyMoney;
|
||||||
|
/**
|
||||||
|
* all money gained with product sell
|
||||||
|
* */
|
||||||
|
public $productMoneyNetto;
|
||||||
|
/**
|
||||||
|
* all money gained with product sell grouped by category
|
||||||
|
* */
|
||||||
|
public $productMoneies;
|
||||||
|
/**
|
||||||
|
* all money lost by money movement
|
||||||
|
* */
|
||||||
|
public $moneyMovementMoneis;
|
||||||
|
public $moneyMovementMoney;
|
||||||
|
public $moneyMovementMoneisByUser;
|
||||||
|
public $moneyMovementMoneyByUser;
|
||||||
|
/**
|
||||||
|
* total gained money brutto
|
||||||
|
* */
|
||||||
|
public $total;
|
||||||
|
/**
|
||||||
|
* total gained money netto
|
||||||
|
* */
|
||||||
|
public $totalNetto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ticket sale statisitc
|
||||||
|
* */
|
||||||
|
public $ticketStats;
|
||||||
|
|
||||||
|
public $ticketStatsByUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* money movements by type
|
||||||
|
* */
|
||||||
|
public $moneyMovementsByType;
|
||||||
|
|
||||||
|
public $tickets;
|
||||||
|
/**
|
||||||
|
* all product transfer
|
||||||
|
* */
|
||||||
|
public $products;
|
||||||
|
public $moneyMovements;
|
||||||
|
|
||||||
|
public $productsByCategory;
|
||||||
|
|
||||||
|
public $id_account;
|
||||||
|
public $id_user;
|
||||||
|
public $type;
|
||||||
|
|
||||||
|
|
||||||
|
public function loadFilters($transfer){
|
||||||
|
$this->start = $transfer->start;
|
||||||
|
$this->end = $transfer->end;
|
||||||
|
$this->id_account = $transfer->id_account;
|
||||||
|
$this->id_user = $transfer->id_user;
|
||||||
|
$this->types = $transfer->types;
|
||||||
|
$this->type = $transfer->type;
|
||||||
|
$this->timestampStart = $transfer->timestampStart;
|
||||||
|
$this->timestampEnd = $transfer->timestampEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isModeAdmin(){
|
||||||
|
return $this->mode == 'admin';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function calcTotal(){
|
||||||
|
$this->total = 0;
|
||||||
|
$this->total += $this->ticketMoney;
|
||||||
|
$this->total += $this->productMoney;
|
||||||
|
$this->total += $this->moneyMovementMoneis;
|
||||||
|
}
|
||||||
|
public function calcTotalNetto(){
|
||||||
|
$this->totalNetto = 0;
|
||||||
|
$this->totalNetto += $this->ticketMoney;
|
||||||
|
$this->totalNetto += $this->productMoneyNetto;
|
||||||
|
$this->totalNetto += $this->moneyMovementMoneis;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function addAccountConstraint($query){
|
||||||
|
if (!$this->isModeAdmin() || !RoleDefinition::isAdmin() ){
|
||||||
|
$query->innerJoin("user_account_assignment",'transfer.id_account = user_account_assignment.id_account' );
|
||||||
|
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]);
|
||||||
|
|
||||||
|
if ( RoleDefinition::isReception() || !$this->isModeAdmin()){
|
||||||
|
$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$query->andWhere(['account.type' => Account::TYPE_ALL ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add common transfer conditions.
|
||||||
|
* mode and role will be used to build to correct condition
|
||||||
|
* */
|
||||||
|
public 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,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$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]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public 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->groupBy(['ticket_type.id_ticket_type','ticket_type.name']);
|
||||||
|
$this->addQueryFilters($query);
|
||||||
|
|
||||||
|
|
||||||
|
$this->ticketStats = $query->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public 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");
|
||||||
|
$this->addQueryFilters($query);
|
||||||
|
$this->ticketMoney = $query->scalar();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function readTicketStasByUser(){
|
||||||
|
|
||||||
|
$query = (new \yii\db\Query());
|
||||||
|
$query->select([ 'user.id as user_id','user.username as user_username','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("user", "transfer.id_user = user.id");
|
||||||
|
|
||||||
|
$query->groupBy([ 'user.id as user_id','user.username as user_username','ticket_type.id_ticket_type','ticket_type.name']);
|
||||||
|
$this->addQueryFilters($query);
|
||||||
|
|
||||||
|
$this->ticketStatsByUser = $query->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function readTicketMoneyByUser(){
|
||||||
|
|
||||||
|
$query = (new \yii\db\Query());
|
||||||
|
$query->select(['user.id as user_id','user.username as user_username',' 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("user", "transfer.id_user = user.id");
|
||||||
|
$query->orderBy(['user.username' => SORT_ASC]);
|
||||||
|
$this->addQueryFilters($query);
|
||||||
|
$this->ticketMoneyByUser = $query->all();
|
||||||
|
$this->ticketMoneyByUser = $this->toArrayByUser($this->ticketMoneyByUser);
|
||||||
|
return $this->ticketMoneyByUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public 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();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public 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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public 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");
|
||||||
|
$this->addQueryFilters($query);
|
||||||
|
|
||||||
|
$this->productMoney = $query->scalar();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function readProductsMoneyByUser(){
|
||||||
|
|
||||||
|
|
||||||
|
$query = (new \yii\db\Query());
|
||||||
|
$query->select(['user.id as user_id','user.username as user_username','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("user", "transfer.id_user = user.id");
|
||||||
|
$query->groupBy([ 'user.id as user_id','user.username as user_username','ticket_type.id_ticket_type','transfer.money']);
|
||||||
|
$this->addQueryFilters($query);
|
||||||
|
|
||||||
|
$this->productMoneyByUser = $query->all();
|
||||||
|
|
||||||
|
}
|
||||||
|
public function readProductsMoneyNetto(){
|
||||||
|
|
||||||
|
|
||||||
|
$query = (new \yii\db\Query());
|
||||||
|
$query->select(['coalesce(sum(transfer.count * GREATEST(( product.sale_price - coalesce(product.purchase_price,0)),0)),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");
|
||||||
|
$this->addQueryFilters($query);
|
||||||
|
|
||||||
|
$this->productMoneyNetto = $query->scalar();
|
||||||
|
|
||||||
|
}
|
||||||
|
public function readProductsMoneyNettoByUser(){
|
||||||
|
|
||||||
|
|
||||||
|
$query = (new \yii\db\Query());
|
||||||
|
$query->select(['coalesce(sum(transfer.count * GREATEST(( product.sale_price - coalesce(product.purchase_price,0)),0)),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("user", "transfer.id_user = user.id");
|
||||||
|
$query->groupBy([ 'user.id as user_id','user.username as user_username','ticket_type.id_ticket_type','transfer.count' ,'product.sale_price','product.purchase_price']);
|
||||||
|
$this->addQueryFilters($query);
|
||||||
|
|
||||||
|
$this->productMoneyNetto = $query->all();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function readMoneyMovementMoney(){
|
||||||
|
$query = (new \yii\db\Query());
|
||||||
|
$query->select([' coalesce(sum( case when transfer.direction = ' . Transfer::DIRECTION_IN. ' then transfer.money else -1 * transfer.money end ),0) AS money_movement_money']);
|
||||||
|
$query->from('transfer');
|
||||||
|
$query->andWhere(['transfer.type' => Transfer::TYPE_MONEY_MOVEMENT_OUT]);
|
||||||
|
$query->innerJoin("money_movement", "money_movement.id_money_movement = transfer.id_object");
|
||||||
|
$this->addQueryFilters($query);
|
||||||
|
|
||||||
|
$this->moneyMovementMoneis = $query->scalar();
|
||||||
|
}
|
||||||
|
public function readMoneyMovementsStats(){
|
||||||
|
$query = (new \yii\db\Query());
|
||||||
|
$query->select([ 'money_movement.type as money_movement_type', ' coalesce(count(transfer.id_transfer),0) AS money_movement_count', 'coalesce(sum( case when transfer.direction = ' . Transfer::DIRECTION_IN. ' then transfer.money else -1 * transfer.money end ),0) AS money_movement_money']);
|
||||||
|
$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->groupBy(['money_movement.type']);
|
||||||
|
$this->addQueryFilters($query);
|
||||||
|
|
||||||
|
$this->moneyMovementsByType = $query->all();
|
||||||
|
for ($i = 0; $i < count($this->moneyMovementsByType) ;$i++ ){
|
||||||
|
$this->moneyMovementsByType[$i]['name'] = MoneyMovement::typeName($this->moneyMovementsByType[$i]['money_movement_type']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function readMoneyMovementMoneyByUser(){
|
||||||
|
$query = (new \yii\db\Query());
|
||||||
|
$query->select(['user.id as user_id','user.username as user_username',' coalesce(sum( case when transfer.direction = ' . Transfer::DIRECTION_IN. ' then transfer.money else -1 * transfer.money end ),0) AS money_movement_money']);
|
||||||
|
$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("user", "transfer.id_user = user.id");
|
||||||
|
$query->groupBy([ 'user.id as user_id','user.username as user_username' ]);
|
||||||
|
|
||||||
|
$this->addQueryFilters($query);
|
||||||
|
|
||||||
|
$this->moneyMovementMoneisByUser = $query->scalar();
|
||||||
|
}
|
||||||
|
public function readMoneyMovementsStatsByUser(){
|
||||||
|
$query = (new \yii\db\Query());
|
||||||
|
$query->select([ 'user.id as user_id','user.username as user_username','money_movement.type as money_movement_type', ' coalesce(count(transfer.id_transfer),0) AS money_movement_count', 'coalesce(sum( case when transfer.direction = ' . Transfer::DIRECTION_IN. ' then transfer.money else -1 * transfer.money end ),0) AS money_movement_money']);
|
||||||
|
$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("user", "transfer.id_user = user.id");
|
||||||
|
$query->groupBy([ 'user.id as user_id','user.username as user_username','money_movement.type']);
|
||||||
|
$this->addQueryFilters($query);
|
||||||
|
|
||||||
|
$this->moneyMovementsByTypeByUser = $query->all();
|
||||||
|
for ($i = 0; $i < count($this->moneyMovementsByTypeByUser) ;$i++ ){
|
||||||
|
$this->moneyMovementsByTypeByUser[$i]['name'] = MoneyMovement::typeName($this->moneyMovementsByTypeByUser[$i]['money_movement_type']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->moneyMovementsByTypeByUser = $this->toArrayByUser($this->moneyMovementsByTypeByUser);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public 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');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function readProducts(){
|
||||||
|
|
||||||
|
$query = (new \yii\db\Query());
|
||||||
|
$query->select([ '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->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');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function readMoneyMovements(){
|
||||||
|
$query = (new \yii\db\Query());
|
||||||
|
$query->select([ 'user.username as user_name','account.name as account_name', 'transfer.direction as transfer_direction' ,'money_movement.type as money_movement_type', 'transfer.money AS money_movement_money', 'money_movement.name as money_movement_name','transfer.created_at as money_movement_created_at', ]);
|
||||||
|
$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("user", "transfer.id_user = user.id");
|
||||||
|
$query->orderBy(['transfer.created_at' => SORT_ASC]);
|
||||||
|
$this->addQueryFilters($query);
|
||||||
|
|
||||||
|
$this->moneyMovements = $query->all();
|
||||||
|
|
||||||
|
for ($i = 0; $i < count($this->moneyMovements) ;$i++ ){
|
||||||
|
$this->moneyMovements[$i]['money_movement_type_name'] = MoneyMovement::typeName($this->moneyMovements[$i]['money_movement_type']);
|
||||||
|
$this->moneyMovements[$i]['money_movement_created_at'] = Yii::$app->formatter->asDatetime($this->moneyMovements[$i]['money_movement_created_at'], 'yyyy.MM.dd HH:mm:ss');
|
||||||
|
$this->moneyMovements[$i]['signed_money'] = Transfer::toSignedMoney($this->moneyMovements[$i]['transfer_direction'],$this->moneyMovements[$i]['money_movement_money']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function toArrayByUser($flat, $totalField = null){
|
||||||
|
$result = [];
|
||||||
|
$id_user_prev = null;
|
||||||
|
$id_user = null;
|
||||||
|
$arr;
|
||||||
|
|
||||||
|
foreach ( $flat as $item){
|
||||||
|
$id_user = $item['user_id'];
|
||||||
|
|
||||||
|
if ($id_user_prev == null || $id_user != $id_user_prev){
|
||||||
|
if ($id_user_prev != null ){
|
||||||
|
$result[] = $arr;
|
||||||
|
}
|
||||||
|
$arr =[];
|
||||||
|
$arr['username'] = $item['user_username'];
|
||||||
|
$arr['items'] = [];
|
||||||
|
$arr['user_id'] = $id_user;
|
||||||
|
$arr['total'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$id_user_prev = $id_user;
|
||||||
|
|
||||||
|
$arr['items'][] = $item;
|
||||||
|
if ( isset($totalField)){
|
||||||
|
$arr['total'] += $item[$totalField];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset($arr ) && count($arr) > 0 ){
|
||||||
|
$result[] = $arr;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -87,9 +87,15 @@ class Helper
|
|||||||
|
|
||||||
public static function fixAsciiChars($in){
|
public static function fixAsciiChars($in){
|
||||||
$out = str_replace("ö", "0", $in);
|
$out = str_replace("ö", "0", $in);
|
||||||
$out = str_replace("Ö", "0", $in);
|
$out = str_replace("Ö", "0", $out);
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isCompanyMovar(){
|
||||||
|
return \Yii::$app->params['company'] == 'movar';
|
||||||
|
}
|
||||||
|
public static function isProductVisibilityAccount(){
|
||||||
|
return \Yii::$app->params['product_visiblity'] == 'account';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -3,5 +3,8 @@ 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.16'
|
'version' => 'v0.0.17',
|
||||||
|
'company' => 'movar',//gyor
|
||||||
|
'company_name' => "Freimann Kft.",
|
||||||
|
'product_visiblity' => 'account',// on reception which products to display. account or global
|
||||||
];
|
];
|
||||||
|
|||||||
@ -68,7 +68,8 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
|||||||
|
|
||||||
public function validateAscii($attribute,$params){
|
public function validateAscii($attribute,$params){
|
||||||
if ( !$this->hasErrors($this->$attribute)){
|
if ( !$this->hasErrors($this->$attribute)){
|
||||||
$this->attribute = Helper::fixAsciiChars($this->attributes);
|
$this->$attribute = Helper::fixAsciiChars($this->$attribute);
|
||||||
|
Yii::info(" $attribute converted to: " . $this->$attribute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,6 +50,10 @@ class Product extends \common\models\BaseFitnessActiveRecord {
|
|||||||
[['description'], 'string', 'max' => 255],
|
[['description'], 'string', 'max' => 255],
|
||||||
[['product_number'], 'unique' ],
|
[['product_number'], 'unique' ],
|
||||||
[['barcode'], 'unique' ],
|
[['barcode'], 'unique' ],
|
||||||
|
// a1 and a2 need to be unique together, only a1 will receive error message
|
||||||
|
// ['a1', 'unique', 'targetAttribute' => ['a1', 'a2']]
|
||||||
|
['barcode', 'unique', 'targetAttribute' => ['id_account', 'barcode']],
|
||||||
|
['product_number', 'unique', 'targetAttribute' => ['id_account', 'product_number']],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,13 +147,13 @@ class Product extends \common\models\BaseFitnessActiveRecord {
|
|||||||
|
|
||||||
if ( $forceIncludeObjectWithId == null){
|
if ( $forceIncludeObjectWithId == null){
|
||||||
$query = Product::find()->andWhere(['status' => Product::STATUS_ACTIVE])->orderBy(['product.name' => SORT_ASC]);
|
$query = Product::find()->andWhere(['status' => Product::STATUS_ACTIVE])->orderBy(['product.name' => SORT_ASC]);
|
||||||
if ( $account )
|
if ( Helper::isProductVisibilityAccount() && $account )
|
||||||
$query->andWhere(["product.id_account" => $account]);
|
$query->andWhere(["product.id_account" => $account]);
|
||||||
|
|
||||||
$result = $query->all();
|
$result = $query->all();
|
||||||
}else{
|
}else{
|
||||||
$query = Product::find()->andWhere( ['or', ['status' => Product::STATUS_ACTIVE], ['id_product' => $forceIncludeObjectWithId ] ])->orderBy(['product.name' => SORT_ASC]);
|
$query = Product::find()->andWhere( ['or', ['status' => Product::STATUS_ACTIVE], ['id_product' => $forceIncludeObjectWithId ] ])->orderBy(['product.name' => SORT_ASC]);
|
||||||
if ( $account )
|
if ( Helper::isProductVisibilityAccount() && $account )
|
||||||
$query->andWhere(["product.id_account" => $account]);
|
$query->andWhere(["product.id_account" => $account]);
|
||||||
|
|
||||||
$result = $query->all();
|
$result = $query->all();
|
||||||
@ -163,16 +167,20 @@ class Product extends \common\models\BaseFitnessActiveRecord {
|
|||||||
$result = [];
|
$result = [];
|
||||||
$product = null;
|
$product = null;
|
||||||
|
|
||||||
$products = Product::find()
|
$query = Product::find()
|
||||||
->andWhere(
|
->andWhere(
|
||||||
['or',
|
['or',
|
||||||
['product_number' => $query ],
|
['product_number' => $query ],
|
||||||
['barcode' => $query ],
|
['barcode' => $query ],
|
||||||
]
|
]
|
||||||
)->andWhere(['status' =>Product::STATUS_ACTIVE])
|
)->andWhere(['status' =>Product::STATUS_ACTIVE]);
|
||||||
->andFilterWhere(['product.id_account' => $account])
|
|
||||||
->all();
|
|
||||||
|
|
||||||
|
if ( Helper::isProductVisibilityAccount() && $account ){
|
||||||
|
$query->andFilterWhere(['product.id_account' => $account]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$products = $query->all();
|
||||||
|
|
||||||
if ( count($products) == 1 ){
|
if ( count($products) == 1 ){
|
||||||
$product = $products[0];
|
$product = $products[0];
|
||||||
|
|||||||
@ -722,4 +722,8 @@ class Transfer extends \common\models\BaseFitnessActiveRecord
|
|||||||
|
|
||||||
return $query->scalar();
|
return $query->scalar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,12 +13,15 @@ use common\models\Account;
|
|||||||
|
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
use common\models\MoneyMovement;
|
use common\models\MoneyMovement;
|
||||||
|
use common\components\RoleDefinition;
|
||||||
/**
|
/**
|
||||||
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
* TransferListSearch represents the model behind the search form about `common\models\Transfer`.
|
||||||
*/
|
*/
|
||||||
class TransferListSearch extends Transfer
|
class TransferListSearch extends Transfer
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public $mode = "reception";//reception or admin
|
||||||
|
|
||||||
public $start;
|
public $start;
|
||||||
public $end;
|
public $end;
|
||||||
|
|
||||||
@ -51,6 +54,10 @@ class TransferListSearch extends Transfer
|
|||||||
* all money gained with product sell
|
* all money gained with product sell
|
||||||
* */
|
* */
|
||||||
public $productMoney;
|
public $productMoney;
|
||||||
|
/**
|
||||||
|
* all money gained with product sell
|
||||||
|
* */
|
||||||
|
public $productMoneyNetto;
|
||||||
/**
|
/**
|
||||||
* all money gained with product sell grouped by category
|
* all money gained with product sell grouped by category
|
||||||
* */
|
* */
|
||||||
@ -61,9 +68,13 @@ class TransferListSearch extends Transfer
|
|||||||
public $moneyMovementMoneis;
|
public $moneyMovementMoneis;
|
||||||
public $moneyMovementMoney;
|
public $moneyMovementMoney;
|
||||||
/**
|
/**
|
||||||
* total gained money
|
* total gained money brutto
|
||||||
* */
|
* */
|
||||||
public $total;
|
public $total;
|
||||||
|
/**
|
||||||
|
* total gained money netto
|
||||||
|
* */
|
||||||
|
public $totalNetto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ticket sale statisitc
|
* ticket sale statisitc
|
||||||
@ -84,6 +95,13 @@ class TransferListSearch extends Transfer
|
|||||||
|
|
||||||
public $productsByCategory;
|
public $productsByCategory;
|
||||||
|
|
||||||
|
public $currentUser;
|
||||||
|
public $currentAccount;
|
||||||
|
|
||||||
|
public $output;
|
||||||
|
|
||||||
|
public $outputView;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
@ -97,10 +115,15 @@ class TransferListSearch extends Transfer
|
|||||||
|
|
||||||
[ [ 'id_account','id_user' ] , 'integer'],
|
[ [ 'id_account','id_user' ] , 'integer'],
|
||||||
['types', 'each', 'rule' => ['integer']],
|
['types', 'each', 'rule' => ['integer']],
|
||||||
|
['output', 'safe' ],
|
||||||
|
['outputView', 'safe' ],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function isModeAdmin(){
|
||||||
|
return $this->mode == 'admin';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates data provider instance with search query applied
|
* Creates data provider instance with search query applied
|
||||||
@ -126,7 +149,6 @@ class TransferListSearch extends Transfer
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->readTicketMoney();
|
$this->readTicketMoney();
|
||||||
$this->readProductsMoney();
|
$this->readProductsMoney();
|
||||||
$this->readMoneyMovementMoney();
|
$this->readMoneyMovementMoney();
|
||||||
@ -142,6 +164,19 @@ class TransferListSearch extends Transfer
|
|||||||
$this->readProducts();
|
$this->readProducts();
|
||||||
$this->readMoneyMovements();
|
$this->readMoneyMovements();
|
||||||
|
|
||||||
|
if ( $this->isModeAdmin() && RoleDefinition::isAdmin()){
|
||||||
|
|
||||||
|
if ( $this->id_user){
|
||||||
|
$this->currentUser = User::findOne($this->id_user);
|
||||||
|
}
|
||||||
|
if ( $this->id_account){
|
||||||
|
$this->currentAccount = Account::findOne($this->id_account);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->readProductsMoneyNetto();
|
||||||
|
$this->calcTotalNetto();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function calcTotal(){
|
protected function calcTotal(){
|
||||||
@ -150,18 +185,33 @@ class TransferListSearch extends Transfer
|
|||||||
$this->total += $this->productMoney;
|
$this->total += $this->productMoney;
|
||||||
$this->total += $this->moneyMovementMoneis;
|
$this->total += $this->moneyMovementMoneis;
|
||||||
}
|
}
|
||||||
|
protected function calcTotalNetto(){
|
||||||
|
$this->totalNetto = 0;
|
||||||
|
$this->totalNetto += $this->ticketMoney;
|
||||||
|
$this->totalNetto += $this->productMoneyNetto;
|
||||||
|
$this->totalNetto += $this->moneyMovementMoneis;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function addAccountConstraint($query){
|
protected function addAccountConstraint($query){
|
||||||
$query->innerJoin("user_account_assignment",'transfer.id_account = user_account_assignment.id_account' );
|
if (!$this->isModeAdmin() || !RoleDefinition::isAdmin() ){
|
||||||
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]);
|
$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 ]);
|
if ( RoleDefinition::isReception() || !$this->isModeAdmin()){
|
||||||
|
$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
||||||
|
}
|
||||||
|
|
||||||
$query->andWhere(['account.type' => Account::TYPE_ALL ]);
|
|
||||||
|
$query->andWhere(['account.type' => Account::TYPE_ALL ]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add common transfer conditions.
|
||||||
|
* mode and role will be used to build to correct condition
|
||||||
|
* */
|
||||||
protected function addQueryFilters($query){
|
protected function addQueryFilters($query){
|
||||||
$query->innerJoin("account", "transfer.id_account = account.id_account");
|
$query->innerJoin("account", "transfer.id_account = account.id_account");
|
||||||
|
|
||||||
@ -195,6 +245,7 @@ class TransferListSearch extends Transfer
|
|||||||
$query->innerJoin("ticket_type", "ticket.id_ticket_type = ticket_type.id_ticket_type");
|
$query->innerJoin("ticket_type", "ticket.id_ticket_type = ticket_type.id_ticket_type");
|
||||||
|
|
||||||
$query->groupBy(['ticket_type.id_ticket_type','ticket_type.name']);
|
$query->groupBy(['ticket_type.id_ticket_type','ticket_type.name']);
|
||||||
|
$query->orderBy(['ticket_type.name' => SORT_ASC]);
|
||||||
$this->addQueryFilters($query);
|
$this->addQueryFilters($query);
|
||||||
|
|
||||||
|
|
||||||
@ -298,6 +349,20 @@ class TransferListSearch extends Transfer
|
|||||||
$this->productMoney = $query->scalar();
|
$this->productMoney = $query->scalar();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
protected function readProductsMoneyNetto(){
|
||||||
|
|
||||||
|
|
||||||
|
$query = (new \yii\db\Query());
|
||||||
|
$query->select(['coalesce(sum(transfer.count * GREATEST(( product.sale_price - coalesce(product.purchase_price,0)),0)),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");
|
||||||
|
$this->addQueryFilters($query);
|
||||||
|
|
||||||
|
$this->productMoneyNetto = $query->scalar();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function readMoneyMovementMoney(){
|
protected function readMoneyMovementMoney(){
|
||||||
|
|||||||
@ -13,12 +13,15 @@ use common\models\Account;
|
|||||||
|
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
use common\models\MoneyMovement;
|
use common\models\MoneyMovement;
|
||||||
|
use common\components\RoleDefinition;
|
||||||
/**
|
/**
|
||||||
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
||||||
*/
|
*/
|
||||||
class TransferSaleSearch extends Transfer
|
class TransferSaleSearch extends Transfer
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public $mode = "reception";//reception or admin
|
||||||
|
|
||||||
public $start;
|
public $start;
|
||||||
public $end;
|
public $end;
|
||||||
|
|
||||||
@ -84,6 +87,10 @@ class TransferSaleSearch extends Transfer
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isModeAdmin(){
|
||||||
|
return $this->mode == 'admin';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates data provider instance with search query applied
|
* Creates data provider instance with search query applied
|
||||||
@ -113,8 +120,6 @@ class TransferSaleSearch extends Transfer
|
|||||||
$this->readProductsMoney();
|
$this->readProductsMoney();
|
||||||
$this->calcTotal();
|
$this->calcTotal();
|
||||||
|
|
||||||
// $this->readProductsByCategory();
|
|
||||||
// $this->readProductsByCategoryDetailed();
|
|
||||||
|
|
||||||
|
|
||||||
$this->readProducts();
|
$this->readProducts();
|
||||||
@ -128,12 +133,18 @@ class TransferSaleSearch extends Transfer
|
|||||||
|
|
||||||
|
|
||||||
protected function addAccountConstraint($query){
|
protected function addAccountConstraint($query){
|
||||||
|
|
||||||
|
if ( !$this->isModeAdmin() || !RoleDefinition::isAdmin()){
|
||||||
|
|
||||||
$query->innerJoin("user_account_assignment",'transfer.id_account = user_account_assignment.id_account' );
|
$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(['user_account_assignment.id_user' => Yii::$app->user->id ]);
|
||||||
|
|
||||||
$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
if ( RoleDefinition::isReception()){
|
||||||
|
$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
||||||
|
}
|
||||||
|
|
||||||
$query->andWhere(['account.type' => Account::TYPE_ALL ]);
|
$query->andWhere(['account.type' => Account::TYPE_ALL ]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ use common\models\Account;
|
|||||||
|
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
use common\models\MoneyMovement;
|
use common\models\MoneyMovement;
|
||||||
|
use common\components\RoleDefinition;
|
||||||
/**
|
/**
|
||||||
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
||||||
*/
|
*/
|
||||||
@ -135,7 +136,9 @@ class TransferTicketSearch extends Transfer
|
|||||||
$query->innerJoin("user_account_assignment",'transfer.id_account = user_account_assignment.id_account' );
|
$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(['user_account_assignment.id_user' => Yii::$app->user->id ]);
|
||||||
|
|
||||||
$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
if ( RoleDefinition::isReception()){
|
||||||
|
$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
||||||
|
}
|
||||||
|
|
||||||
$query->andWhere(['account.type' => Account::TYPE_ALL ]);
|
$query->andWhere(['account.type' => Account::TYPE_ALL ]);
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ use yii\db\Query;
|
|||||||
use common\models\AccountState;
|
use common\models\AccountState;
|
||||||
use backend\models\AccountSearch;
|
use backend\models\AccountSearch;
|
||||||
use common\models\Account;
|
use common\models\Account;
|
||||||
|
use common\components\Helper;
|
||||||
|
|
||||||
class FrontendMenuStructure{
|
class FrontendMenuStructure{
|
||||||
|
|
||||||
@ -68,17 +69,22 @@ class FrontendMenuStructure{
|
|||||||
['label' => Yii::t('frontend/account-state', 'Account states'), 'url' => ['/account-state/index'] ],
|
['label' => Yii::t('frontend/account-state', 'Account states'), 'url' => ['/account-state/index'] ],
|
||||||
['label' => Yii::t('frontend/account-state','Open account state'), 'url' => ['/account-state/open'] ],
|
['label' => Yii::t('frontend/account-state','Open account state'), 'url' => ['/account-state/open'] ],
|
||||||
['label' => Yii::t('frontend/account-state','Close account state'), 'url' => ['/account-state/close'] ],
|
['label' => Yii::t('frontend/account-state','Close account state'), 'url' => ['/account-state/close'] ],
|
||||||
|
|
||||||
['label' => Yii::t('frontend/money-movement','Money movements'), 'url' => [ '/money-movement/index', 'MoneyMovementSearch[start]' => $this->start, 'MoneyMovementSearch[end]' => $this->tomorrow ] ],
|
['label' => Yii::t('frontend/money-movement','Money movements'), 'url' => [ '/money-movement/index', 'MoneyMovementSearch[start]' => $this->start, 'MoneyMovementSearch[end]' => $this->tomorrow ] ],
|
||||||
['label' => Yii::t('frontend/transfer','Daily transfers'), 'url' => [ '/transfer/list', 'TransferListSearch[id_account]' => Account::readDefault(), 'TransferListSearch[start]' => $this->start, 'TransferListSearch[end]' => $this->tomorrow ] ],
|
|
||||||
['label' => Yii::t('frontend/transfer','Sales detailed'), 'url' => [ '/transfer/sale', 'TransferSaleSearch[id_user]' =>\Yii::$app->user->id, 'TransferSaleSearch[id_account]' => Account::readDefault(), 'TransferSaleSearch[start]' => $this->start, 'TransferSaleSearch[end]' => $this->tomorrow ] ],
|
|
||||||
['label' => Yii::t('frontend/transfer','Ticket sale detailed'), 'url' => [ '/transfer/tickets','TransferTicketSearch[id_user]' =>\Yii::$app->user->id, 'TransferTicketSearch[id_account]' => Account::readDefault(), 'TransferTicketSearch[start]' => $this->start, 'TransferTicketSearch[end]' => $this->tomorrow ] ],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ( Helper::isCompanyMovar() ){
|
||||||
|
$items[] = ['label' => Yii::t('frontend/transfer','Daily transfers'), 'url' => [ '/transfer/list', 'TransferListSearch[id_account]' => Account::readDefault(), 'TransferListSearch[start]' => $this->start, 'TransferListSearch[end]' => $this->tomorrow ] ];
|
||||||
|
$items[] = ['label' => Yii::t('frontend/transfer','Sales detailed'), 'url' => [ '/transfer/sale', 'TransferSaleSearch[id_user]' =>\Yii::$app->user->id, 'TransferSaleSearch[id_account]' => Account::readDefault(), 'TransferSaleSearch[start]' => $this->start, 'TransferSaleSearch[end]' => $this->tomorrow ] ];
|
||||||
|
$items[] = ['label' => Yii::t('frontend/transfer','Ticket sale detailed'), 'url' => [ '/transfer/tickets','TransferTicketSearch[id_user]' =>\Yii::$app->user->id, 'TransferTicketSearch[id_account]' => Account::readDefault(), 'TransferTicketSearch[start]' => $this->start, 'TransferTicketSearch[end]' => $this->tomorrow ] ];
|
||||||
|
}
|
||||||
|
|
||||||
if ( $isadmin || Yii::$app->user->can('reception.transfers') ){
|
if ( $isadmin || Yii::$app->user->can('reception.transfers') ){
|
||||||
$items[] = ['label' => Yii::t('frontend/transfer','Transfers'), 'url' => ['/transfer/index', 'TransferSearch[id_user]' =>\Yii::$app->user->id, 'TransferSearch[id_account]' => Account::readDefault(), 'TransferSearch[start]' => $this->start, 'TransferSearch[end]' => $this->tomorrow ] ];
|
$items[] = ['label' => Yii::t('frontend/transfer','Transfers'), 'url' => ['/transfer/index', 'TransferSearch[id_user]' =>\Yii::$app->user->id, 'TransferSearch[id_account]' => Account::readDefault(), 'TransferSearch[start]' => $this->start, 'TransferSearch[end]' => $this->tomorrow ] ];
|
||||||
|
$items[] = ['label' => Yii::t('frontend/collection','Collections'), 'url' => ['/collection/index' , 'CollectionSearch[start]' =>$this->start,'CollectionSearch[end]' => $this->tomorrow ] ];
|
||||||
}
|
}
|
||||||
|
|
||||||
$items[] = ['label' => Yii::t('frontend/collection','Collections'), 'url' => ['/collection/index' , 'CollectionSearch[start]' =>$this->start,'CollectionSearch[end]' => $this->tomorrow ] ];
|
|
||||||
|
|
||||||
$this->menuItems[] = ['label' => Yii::t('frontend/account', 'Account'),
|
$this->menuItems[] = ['label' => Yii::t('frontend/account', 'Account'),
|
||||||
'items' => $items
|
'items' => $items
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
use frontend\components\ReceptionMenuWidget;
|
|
||||||
use frontend\components\ReceptionCardNumberWidget;
|
|
||||||
use yii\base\Widget;
|
|
||||||
use frontend\components\ReceptionWidget;
|
use frontend\components\ReceptionWidget;
|
||||||
?>
|
?>
|
||||||
|
<?php
|
||||||
|
\frontend\assets\AppAsset::register($this);
|
||||||
|
?>
|
||||||
<h1>Recepció</h1>
|
<h1>Recepció</h1>
|
||||||
<?php echo ReceptionWidget::widget( ['form' => $model, 'route' => ['customer/reception'] ] )?>
|
<?php echo ReceptionWidget::widget( ['form' => $model, 'route' => ['customer/reception'] ] )?>
|
||||||
|
|||||||
@ -30,6 +30,14 @@ function AccountState(o){
|
|||||||
moneyInput = $(app.defaults.selector_money);
|
moneyInput = $(app.defaults.selector_money);
|
||||||
notes.change(runNote);
|
notes.change(runNote);
|
||||||
moneyInput.change(run);
|
moneyInput.change(run);
|
||||||
|
moneyInput.focus(function(){
|
||||||
|
$(this).select().one('mouseup', function (e) {
|
||||||
|
$(this).off('keyup');
|
||||||
|
e.preventDefault();
|
||||||
|
}).one('keyup', function () {
|
||||||
|
$(this).select().off('mouseup');
|
||||||
|
});
|
||||||
|
});
|
||||||
if ( app.defaults.open ){
|
if ( app.defaults.open ){
|
||||||
ddAccount = $(app.defaults.selector_dd_account);
|
ddAccount = $(app.defaults.selector_dd_account);
|
||||||
ddAccount.change(run);
|
ddAccount.change(run);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user