add hidden account, cart insert/delete
add hidden account support add delete/payout buttons to carts add backend product sales with pdf export add frontend product sales with pdf export add frontend ticket sales with pdf export
This commit is contained in:
@@ -81,6 +81,7 @@ class AdminMenuStructure{
|
||||
$items = [];
|
||||
$items[] = ['label' => 'Termékek', 'url' => ['/product/index'] ];
|
||||
$items[] = ['label' => 'Beszerzések', 'url' => ['/procurement/index'] ];
|
||||
$items[] = ['label' => 'Részletes eladások', 'url' => ['/transfer/sale' ,'TransferSaleSearch[start]' =>$todayDatetime,'TransferSaleSearch[end]' => $tomorrowDatetime ] ];
|
||||
$this->menuItems[] = ['label' => 'Termékek', 'url' => $this->emptyUrl,
|
||||
'items' => $items
|
||||
];
|
||||
|
||||
@@ -11,6 +11,9 @@ use common\models\Account;
|
||||
use common\models\User;
|
||||
use backend\models\TransferSummarySearch;
|
||||
use backend\models\TransferListSearch;
|
||||
use backend\models\TransferSaleSearch;
|
||||
use common\models\ProductCategory;
|
||||
use common\models\Product;
|
||||
|
||||
/**
|
||||
* TransferController implements the CRUD actions for Transfer model.
|
||||
@@ -25,7 +28,7 @@ class TransferController extends \backend\controllers\BackendController
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'actions' => [ 'index','view','summary','list' ],
|
||||
'actions' => [ 'index','view','summary','list',"sale","sale-pdf" ],
|
||||
'allow' => true,
|
||||
'roles' => ['admin','employee','reception'],
|
||||
],
|
||||
@@ -78,6 +81,46 @@ class TransferController extends \backend\controllers\BackendController
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Transfer models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionSale()
|
||||
{
|
||||
$searchModel = new TransferSaleSearch();
|
||||
$searchModel->accounts = Account::read();
|
||||
$searchModel->users = User::read();
|
||||
$searchModel->productCategories = ProductCategory::read();
|
||||
$searchModel->productOptions = Product::read();
|
||||
|
||||
$searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
return $this->render('sale', [
|
||||
'searchModel' => $searchModel,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function actionSalePdf(){
|
||||
$searchModel = new TransferSaleSearch();
|
||||
$searchModel->accounts = Account::read();
|
||||
$searchModel->users = User::read();
|
||||
$searchModel->productCategories = ProductCategory::read();
|
||||
$searchModel->productOptions = Product::read();
|
||||
|
||||
$searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
$mpdf=new \mPDF('utf-8', 'A4-L');
|
||||
$mpdf->WriteHTML($this->renderPartial('_result_sale', [
|
||||
'searchModel' => $searchModel,
|
||||
]));
|
||||
$mpdf->Output('MyPDF.pdf', 'D');
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Transfer models.
|
||||
* @return mixed
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace backend\models;
|
||||
use Yii;
|
||||
use common\models\Transfer;
|
||||
use common\components\RoleDefinition;
|
||||
use common\models\Account;
|
||||
/**
|
||||
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
||||
*/
|
||||
@@ -15,7 +16,13 @@ class TransferListSearch extends \common\models\TransferListSearch
|
||||
if ( !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 ]);
|
||||
$query->andWhere(['account.type' => Account::TYPE_ALL ]);
|
||||
|
||||
if ( RoleDefinition::isReception()){
|
||||
$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
43
backend/models/TransferSaleSearch.php
Normal file
43
backend/models/TransferSaleSearch.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\Transfer;
|
||||
use yii\base\Object;
|
||||
use yii\db\Query;
|
||||
use yii\db\Expression;
|
||||
use common\models\Account;
|
||||
|
||||
use yii\helpers\ArrayHelper;
|
||||
use common\models\MoneyMovement;
|
||||
use common\components\RoleDefinition;
|
||||
/**
|
||||
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
||||
*/
|
||||
class TransferSaleSearch extends \common\models\TransferSaleSearch
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected function addAccountConstraint($query){
|
||||
if ( !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()){
|
||||
$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
||||
}
|
||||
|
||||
$query->andWhere(['account.type' => Account::TYPE_ALL ]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -67,11 +67,19 @@ class TransferSearch extends Transfer
|
||||
public function search($params)
|
||||
{
|
||||
$query = Transfer::find();
|
||||
|
||||
$query->innerJoinWith('account');
|
||||
|
||||
|
||||
if ( !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 ]);
|
||||
|
||||
$query->andWhere(['account.type' => Account::TYPE_ALL ]);
|
||||
|
||||
if ( RoleDefinition::isReception()){
|
||||
$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
||||
}
|
||||
}
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
|
||||
29
backend/views/transfer/_export_btn_sale.php
Normal file
29
backend/views/transfer/_export_btn_sale.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
use yii\helpers\Url;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\TransferSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<?= Html::a(
|
||||
Yii::t('frontend/transfer', 'Export PDF'),
|
||||
Url::to(['sale-pdf' ,
|
||||
Html::getInputName($model, "start") => Html::getAttributeValue($model, "start"),
|
||||
Html::getInputName($model, "end") =>Html::getAttributeValue($model, "end"),
|
||||
Html::getInputName($model, "id_account") => Html::getAttributeValue($model, "id_account"),
|
||||
Html::getInputName($model, "id_user") => Html::getAttributeValue($model, "id_user"),
|
||||
Html::getInputName($model, "category") => Html::getAttributeValue($model, "category"),
|
||||
Html::getInputName($model, "id_product") => Html::getAttributeValue($model, "id_product"),
|
||||
Html::getInputName($model, "status") => Html::getAttributeValue($model, "status"),
|
||||
] ),
|
||||
['class' => 'btn btn-primary'])
|
||||
?>
|
||||
|
||||
|
||||
|
||||
142
backend/views/transfer/_result_sale.php
Normal file
142
backend/views/transfer/_result_sale.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
use yii\helpers\Html;
|
||||
use common\models\Account;
|
||||
use common\models\User;
|
||||
use common\models\ProductCategory;
|
||||
use common\models\Product;
|
||||
use common\models\Transfer;
|
||||
?>
|
||||
<style>
|
||||
td,th{
|
||||
padding: 3px;
|
||||
}
|
||||
.table-summary td.count {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.table-summary td.money {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.table-filter th{
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
<div class="container">
|
||||
<?php
|
||||
// ////////////////////////
|
||||
// Termék eladás
|
||||
// //////////////////////
|
||||
?>
|
||||
<h3>Termék eladások</h3>
|
||||
|
||||
<table class="table-filter">
|
||||
<tr>
|
||||
<th><?php echo Html::encode($searchModel->getAttributeLabel('start')) ?></th>
|
||||
<td><?php echo Html::getAttributeValue($searchModel, "start")?></td>
|
||||
<th><?php echo Html::encode($searchModel->getAttributeLabel('end')) ?></th>
|
||||
<td><?php echo Html::getAttributeValue($searchModel, "end")?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo Html::encode($searchModel->getAttributeLabel('id_account')) ?></th>
|
||||
<td><?php if ( empty($searchModel->id_account) ){
|
||||
echo"Mind" ;
|
||||
}else{
|
||||
$account = Account::findOne($searchModel->id_account) ;
|
||||
if ( $account != null ){
|
||||
echo $account->name;
|
||||
}
|
||||
}?></td>
|
||||
<th><?php echo Html::encode($searchModel->getAttributeLabel('id_user')) ?></th>
|
||||
<td><?php if ( empty($searchModel->id_user) ){
|
||||
echo"Mind" ;
|
||||
}else{
|
||||
$user = User::findOne($searchModel->id_user) ;
|
||||
if ( $user != null ){
|
||||
echo $user->username;
|
||||
}
|
||||
}?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo Html::encode($searchModel->getAttributeLabel('category')) ?></th>
|
||||
<td><?php if ( empty($searchModel->category) ){
|
||||
echo"Mind" ;
|
||||
}else{
|
||||
$category = ProductCategory::findOne($searchModel->category) ;
|
||||
if ( $category != null ){
|
||||
echo $category->name;
|
||||
}
|
||||
}?></td>
|
||||
|
||||
<th><?php echo Html::encode($searchModel->getAttributeLabel('id_product')) ?></th>
|
||||
<td><?php if ( empty($searchModel->id_product) ){
|
||||
echo"Mind" ;
|
||||
}else{
|
||||
$product = Product::findOne($searchModel->id_product) ;
|
||||
if ( $product != null ){
|
||||
echo $product->name;
|
||||
}
|
||||
}?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo Html::encode($searchModel->getAttributeLabel('status')) ?></th>
|
||||
<td><?php if ( empty($searchModel->status) ){
|
||||
echo"Mind" ;
|
||||
}else{
|
||||
$statuses = Transfer::statuses();
|
||||
$status = "";
|
||||
if (array_key_exists($searchModel->status, $statuses) ){
|
||||
echo $statuses[$searchModel->status];
|
||||
}
|
||||
}?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
||||
Összesen: <?php echo $searchModel->productMoney; ?> Ft
|
||||
</div>
|
||||
</div>
|
||||
<table class="table table-bordered table-striped table-summary">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>T</th>
|
||||
<th>Kiadva</th>
|
||||
<th>Fizetve</th>
|
||||
<th>Kassza</th>
|
||||
<th>Felhasználó</th>
|
||||
<!-- <th>Vásárló</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['id_transfer']?> </td>
|
||||
<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
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
77
backend/views/transfer/_search_sale.php
Normal file
77
backend/views/transfer/_search_sale.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?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');
|
||||
$productOptions = ['' => 'Mind'] + HtmlHelper::mkOptions($model->productOptions,'id_product','name');
|
||||
$productCategoryOptions = ['' => 'Mind'] + HtmlHelper::mkOptions($model->productCategories,'id_product_category','name');
|
||||
$transferStatusOptions = ['' => 'Mind'] + Transfer::statuses();
|
||||
?>
|
||||
|
||||
<div class="transfer-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['sale'],
|
||||
'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="row">
|
||||
<div class="col-md-4">
|
||||
<?= $form->field($model, 'category')->dropDownList($productCategoryOptions) ?>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<?= $form->field($model, 'id_product')->dropDownList($productOptions) ?>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<?= $form->field($model, 'status')->dropDownList($transferStatusOptions) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton(Yii::t('frontend/transfer', 'Search'), ['class' => 'btn btn-primary']) ?>
|
||||
</div>
|
||||
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
115
backend/views/transfer/sale.php
Normal file
115
backend/views/transfer/sale.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
use yii\widgets\ListView;
|
||||
use yii\base\Widget;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel common\models\TransferSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = Yii::t ( 'frontend/transfer', 'Product sale detailed' );
|
||||
$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_sale', ['model' => $searchModel]); ?>
|
||||
<?php echo $this->render('_export_btn_sale', ['model' => $searchModel]); ?>
|
||||
|
||||
|
||||
<div>
|
||||
<?php
|
||||
// ////////////////////////
|
||||
// Termék eladás
|
||||
// //////////////////////
|
||||
?>
|
||||
<h3>Termék eladások</h3>
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right" style="text-decoration: underline;">
|
||||
Összesen: <?php echo $searchModel->productMoney; ?> Ft
|
||||
</div>
|
||||
</div>
|
||||
<table class="table table-bordered table-striped table-summary">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Tranzakció</th>
|
||||
<th>Kiadva</th>
|
||||
<th>Fizetve</th>
|
||||
<th>Kassza</th>
|
||||
<th>Felhasználó</th>
|
||||
<th>Vásárló</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['id_transfer']?> </td>
|
||||
<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['customer_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
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user