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:
2016-01-03 18:29:39 +01:00
parent 62bcb7ff27
commit 595f663820
43 changed files with 2154 additions and 24 deletions

View File

@@ -69,6 +69,8 @@ class FrontendMenuStructure{
['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/transfer','Daily transfers'), 'url' => [ '/transfer/list', 'TransferListSearch[start]' => $this->start, 'TransferListSearch[end]' => $this->tomorrow ] ],
['label' => Yii::t('frontend/transfer','Sales detailed'), 'url' => [ '/transfer/sale', 'TransferSaleSearch[start]' => $this->start, 'TransferSaleSearch[end]' => $this->tomorrow ] ],
['label' => Yii::t('frontend/transfer','Ticket sale detailed'), 'url' => [ '/transfer/tickets', 'TransferTicketSearch[start]' => $this->start, 'TransferTicketSearch[end]' => $this->tomorrow ] ],
];
if ( $isadmin || Yii::$app->user->can('reception.transfers') ){

View File

@@ -11,6 +11,14 @@ use yii\filters\VerbFilter;
use frontend\models\TransferMoneyMovementSearch;
use common\models\Account;
use frontend\models\TransferListSearch;
use common\models\ShoppingCart;
use common\models\UserSoldItem;
use common\models\TransferSaleSearch;
use common\models\User;
use common\models\ProductCategory;
use common\models\Product;
use common\models\TransferTicketSearch;
use common\models\TicketType;
/**
* TransferController implements the CRUD actions for Transfer model.
@@ -24,8 +32,21 @@ class TransferController extends Controller
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
'payout' => ['post'],
],
],
'access' => [
'class' => \yii\filters\AccessControl::className(),
'rules' => [
// allow authenticated users
[
// 'actions' => [ 'index','view','summary','list',"sale","sale-pdf" ],
'allow' => true,
'roles' => ['admin','employee','reception'],
],
// everything else is denied
],
],
];
}
@@ -154,6 +175,38 @@ class TransferController extends Controller
}
*/
/**
* Deletes an existing Transfer model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionPayout($id)
{
$transfer = $this->findModel($id);
$connection = \Yii::$app->db;
$transaction = $connection->beginTransaction();
try {
$transfer->status = Transfer::STATUS_PAID;
$transfer->paid_at = date('Y-m-d H:i:s' ) ;
ShoppingCart::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
UserSoldItem::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
if ( $transfer->save() ){
\Yii::$app->session->setFlash( 'success','Tranzakció kifizetve' );
$transaction->commit();
}else{
throw new \Exception("Failed to save");
}
} catch(Exception $e) {
$transaction->rollback();
\Yii::$app->session->setFlash( 'danger','Tranzakció kifizetése nem sikerült' );
}
return $this->redirect(Yii::$app->request->referrer);
}
/**
* Deletes an existing Transfer model.
* If deletion is successful, the browser will be redirected to the 'index' page.
@@ -166,6 +219,8 @@ class TransferController extends Controller
$connection = \Yii::$app->db;
$transaction = $connection->beginTransaction();
try {
ShoppingCart::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
UserSoldItem::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
if ( $transfer->delete() ){
\Yii::$app->session->setFlash( 'success','Tranzakció törölve' );
$transaction->commit();
@@ -181,4 +236,103 @@ class TransferController extends Controller
return $this->redirect(Yii::$app->request->referrer);
}
protected function delete($id){
$transfer = $this->findModel($id);
$connection = \Yii::$app->db;
$transaction = $connection->beginTransaction();
try {
if ( $transfer->delete() ){
\Yii::$app->session->setFlash( 'success','Tranzakció törölve' );
$transaction->commit();
}else{
throw new \Exception("Failed to save");
}
} catch(Exception $e) {
$transaction->rollback();
\Yii::$app->session->setFlash( 'danger','Tranzakció törlése nem sikerült' );
}
}
/**
* 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('eladasaim.pdf', 'D');
exit;
}
/**
* Lists all Transfer models.
* @return mixed
*/
public function actionTickets()
{
$searchModel = new TransferTicketSearch();
$searchModel->accounts = Account::read();
$searchModel->users = User::read();
$searchModel->ticketTypes = TicketType::read(null, Account::readDefault());
$searchModel->search(Yii::$app->request->queryParams);
return $this->render('tickets', [
'searchModel' => $searchModel,
]);
}
public function actionTicketsPdf(){
$searchModel = new TransferTicketSearch();
$searchModel->accounts = Account::read();
$searchModel->users = User::read();
$searchModel->ticketTypes = TicketType::read(null, Account::readDefault());
$searchModel->search(Yii::$app->request->queryParams);
$mpdf=new \mPDF('utf-8', 'A4-L');
$mpdf->WriteHTML($this->renderPartial('_result_ticket', [
'searchModel' => $searchModel,
]));
$mpdf->Output('eladdot_berletek_'. \Yii::$app->formatter->asDatetime(time()).'.pdf', 'D');
exit;
}
}

View File

@@ -187,18 +187,27 @@ class ProductSaleForm extends Model
protected function saveTransfer(){
$customer = null;
$paid_at;
$status = Transfer::STATUS_PAID;
if ( $this->isAppendToUserCart() ){
$status = Transfer::STATUS_NOT_PAID;
}else if ( $this->isAppendToCustomerCart() ){
$status = Transfer::STATUS_NOT_PAID;
$customer = $this->customer;
}else{
$paid_at = date('Y-m-d H:i:s' ) ;
}
$this->transfer = Transfer::createProductTransfer($this->sale,$this->account, $this->discount, $this->currency, $this->count, $this->product,$status,$customer);
if ( isset($this->comment)){
$this->transfer->comment = $this->comment;
}
if ( isset($paid_at)){
$this->transfer->paid_at = $paid_at;
}
$this->transfer->id_user = Yii::$app->user->id;
$this->transfer->save();
}

View File

@@ -44,7 +44,7 @@ class ReceptionForm extends Model
$this->number = str_replace("ö", "0", $this->number);
$this->card = Card::find()->andWhere(['or',[ 'in','number' , [$this->number]], ['in','rfid_key' ,[ $this->number]]])->one();
$this->card = Card::find()->andWhere(['or', [ 'in','number' , [$this->number]], ['and', ['in','rfid_key' ,[ $this->number] ],"trim(coalesce(rfid_key, '')) <>'' "]])->one();
if ( $this->card != null ){
$this->customer = $this->card->customer;
$this->readValidTickets();

View File

@@ -110,11 +110,25 @@ class TicketCreate extends Ticket{
protected function addTransfer(){
$transfer = Transfer::createTicketTransfer($this->_account, $this->_discount, null, 1, $this);
// $transfer->status = Transfer::STATUS_PAID;
$status = Transfer::STATUS_PAID;
if ( $this->isAppendToUserCart() ){
$status = Transfer::STATUS_NOT_PAID;
}else if ( $this->isAppendToCustomerCart() ){
$status = Transfer::STATUS_NOT_PAID;
$customer = $this->customer;
}else {
$status = Transfer::STATUS_PAID;
$transfer->paid_at = date('Y-m-d H:i:s' ) ;
}
$transfer->status = $status;
if ( isset($this->comment)){
$transfer->comment = $this->comment;
}
$transfer->id_user = \Yii::$app->user->id;
$transfer->id_customer = $this->customer->id_customer;
$transfer->save();
$this->_transfer = $transfer;
}

View File

@@ -100,10 +100,13 @@ $discountOptions = mkOptions( ArrayHelper::map($discounts, 'id_discount', 'name'
</div>
</div>
<div class="row">
<div class='col-md-6'>
<div class='col-md-4'>
<?php echo Html::a(Yii::t("frontend/product","Sell"),null,['class' => 'btn btn-danger btn-block', 'id' => 'btn_sell'] );?>
</div>
<div class='col-md-4'>
<?php echo Html::a(Yii::t("frontend/product","To cart"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_sell_append'] );?>
</div>
<div class='col-md-6'>
<div class='col-md-4'>
<?php
if ( $receptionForm->isCardWithCustomer() ){
echo Html::a(Yii::t("frontend/product","Write up"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_add_to_customer_cart'] );

View File

@@ -26,6 +26,9 @@ use kartik\widgets\ActiveForm;
<th>
<?php echo Yii::t('frontend/product', 'Total Price')?>
</th>
<th>
<?php echo "";?>
</th>
</tr>
</thead>
<tbody>

View File

@@ -19,6 +19,8 @@ $options = [];
$options['lookup_product_url'] = Url::toRoute(['product/lookup']);
$options['find_product_url'] = Url::toRoute(['product/find']);
$options['url_pay_user_cart'] = Url::toRoute(['product/payout-user-cart']);
$options['url_delete_transaction'] = Url::toRoute(['transfer/delete']);
$options['url_pay_transaction'] = Url::toRoute(['transfer/payout']);
$options['user_cart'] = $userTransfers;
$options['products'] = $model->products;
if ( isset($model->card) ){

View File

@@ -67,10 +67,13 @@ use common\models\Account;
<?= $form->field($model, 'comment')->textarea(['maxlength' => true]) ?>
<div class="row">
<div class='col-md-6'>
<div class='col-md-4'>
<?php echo Html::a(Yii::t("frontend/ticket","Sell"),null,['class' => 'btn btn-danger btn-block', 'id' => 'btn_sell'] );?>
</div>
<div class='col-md-4'>
<?php echo Html::a(Yii::t("frontend/ticket","To cart"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_add_to_user_cart'] );?>
</div>
<div class='col-md-6'>
<div class='col-md-4'>
<?php
if ( $receptionForm->isCardWithCustomer() ){
echo Html::a(Yii::t("frontend/ticket","Write up"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_add_to_customer_cart'] );

View File

@@ -31,6 +31,8 @@ $options['types'] = TicketType::modelsToArray($ticketTypes);
$options['user_cart'] = $model->userCart;
$options['customer_cart'] = $model->customerCart;
$options['selected_type'] = count($ticketTypes) > 0 ? $ticketTypes[0]->id_ticket_type : 0;
$options['url_delete_transaction'] = Url::toRoute(['transfer/delete']);
$options['url_pay_transaction'] = Url::toRoute(['transfer/payout']);
$this->registerJs ( 'new TicketSell( '. json_encode($options).');' );
?>

View 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'])
?>

View 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(['tickets-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, "status") => Html::getAttributeValue($model, "status"),
Html::getInputName($model, "customer") => Html::getAttributeValue($model, "customer"),
Html::getInputName($model, "id_ticket_type") => Html::getAttributeValue($model, "id_ticket_type"),
] ),
['class' => 'btn btn-primary'])
?>

View 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>

View File

@@ -0,0 +1,136 @@
<?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;
use common\models\TicketType;
?>
<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('id_ticket_type')) ?></th>
<td><?php if ( empty($searchModel->id_ticket_type) ){
echo"Mind" ;
}else{
$ticketType = TicketType::findOne($searchModel->id_ticket_type) ;
if ( $ticketType != null ){
echo $ticketType->name;
}
}?></td>
<th><?php echo Html::encode($searchModel->getAttributeLabel('customer')) ?></th>
<td><?php if ( empty($searchModel->customer) ){
echo"" ;
}else{
echo Html::encode($searchModel->customer) ;
}?></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->ticketMoney; ?> Ft
</div>
</div>
<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>Vendég</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['customer_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
}
?>
</div>

View 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>

View File

@@ -0,0 +1,78 @@
<?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');
$transferStatusOptions = ['' => 'Mind'] + Transfer::statuses();
$ticketTypeOptions = ['' => 'Mind'] + HtmlHelper::mkOptions($model->ticketTypes,'id_ticket_type','name');
?>
<div class="transfer-search">
<?php $form = ActiveForm::begin([
'action' => ['tickets'],
'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, 'id_ticket_type')->dropDownList($ticketTypeOptions) ?>
</div>
<div class="col-md-4">
<?= $form->field($model, 'status')->dropDownList($transferStatusOptions) ?>
</div>
</div>
<div class="row">
<div class="col-md-4">
<?= $form->field($model, 'customer')->textInput() ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('frontend/transfer', 'Search'), ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@@ -245,6 +245,7 @@ td.name{
<th>Fizetve</th>
<th>Kassza</th>
<th>Felhasználó</th>
<th>Vendég</th>
<th>Bérlet típus</th>
<th>Egység ár</th>
<th>Mennyiség</th>
@@ -258,6 +259,7 @@ td.name{
<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['customer_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>

View 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>

View 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>

View File

@@ -0,0 +1,111 @@
<?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', 'Ticket 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_ticket', ['model' => $searchModel]); ?>
<?php echo $this->render('_export_btn_ticket', ['model' => $searchModel]); ?>
<div>
<?php
// ////////////////////////
// Termék eladás
// //////////////////////
?>
<h3>Bérlet eladások</h3>
<div class="row">
<div class="col-md-12 text-right" style="text-decoration: underline;">
Összesen: <?php echo $searchModel->ticketMoney; ?> Ft
</div>
</div>
<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>Vendég</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['customer_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
}
?>
</div>
</div>

View File

@@ -30,6 +30,8 @@ function ProductSell(o){
customer_cart: [],
id_account: null,
products : [],
url_delete_transaction : '',
url_pay_transaction : '',
};
@@ -55,6 +57,13 @@ function ProductSell(o){
// addDocumentKeypressedListener();
initAutocomplete();
disalbeMousewheelSpinOnNumberInput();
}
function disalbeMousewheelSpinOnNumberInput(){
$(':input[type=number]').on('mousewheel', function(e){
e.preventDefault();
});
}
/**
@@ -199,7 +208,7 @@ function ProductSell(o){
if ( event.which == 13 ) {
event.preventDefault();
event.stopImmediatePropagation();
$('#productsaleform-id_currency').focus();
submitSellAndAppend();
}
});
}
@@ -477,12 +486,16 @@ function ProductSell(o){
function createUserCartTable(){
$(app.defaults.selector_user_cart).transferList({
'transfers' : app.defaults.user_cart
'transfers' : app.defaults.user_cart,
'url_delete' : app.defaults.url_delete_transaction,
'url_pay' : app.defaults.url_pay_transaction,
});
}
function createCustomerCartTable(){
$(app.defaults.selector_customer_cart).transferList({
'transfers' : app.defaults.customer_cart
'transfers' : app.defaults.customer_cart,
'url_delete' : app.defaults.url_delete_transaction,
'url_pay' : app.defaults.url_pay_transaction,
});
}

View File

@@ -45,6 +45,8 @@ function TicketSell(o){
/**mark list paid url*/
url_pay_customer_card: '-',
url_pay_user_cart: '',
url_delete_transaction: '',
url_pay_transaction: '',
};
@@ -91,18 +93,23 @@ function TicketSell(o){
function createUserCartTable(){
$(app.defaults.selector_user_cart).transferList({
'transfers' : app.defaults.user_cart
'transfers' : app.defaults.user_cart,
'url_delete' : app.defaults.url_delete_transaction,
'url_pay' : app.defaults.url_pay_transaction,
});
}
function createCustomerCartTable(){
$(app.defaults.selector_customer_cart).transferList({
'transfers' : app.defaults.customer_cart
'transfers' : app.defaults.customer_cart,
'url_delete' : app.defaults.url_delete_transaction,
'url_pay' : app.defaults.url_pay_transaction,
});
}
function addSellButtons(){
addBehaviourBtnSellAndAppendToUserCart();
addBehaviourBtnAddToCustomerCart();
addBehaviourBtnSell();
}
function addBehaviourBtnSellAndAppendToUserCart(){
@@ -113,6 +120,10 @@ function TicketSell(o){
$('#btn_add_to_customer_cart').on('click',submitAddTicketToCustomerCart);
}
function submitSell(){
$('#ticketcreate-cart').val('');
$('#ticket_form').submit();
}
function submitAddTicketToUserCart(){
$('#ticketcreate-cart').val('user');
$('#ticket_form').submit();
@@ -123,6 +134,9 @@ function TicketSell(o){
$('#ticket_form').submit();
}
function addBehaviourBtnSell(){
$('#btn_sell').on('click',submitSell);
}
function addBehaviourPayoutUserCart( ){
// $( app.defaults.selector_btn_pay_user_cart ).on('click',function(){

View File

@@ -1,6 +1,8 @@
$.widget( "fitness.transferList", {
options: {
transfers: [],
url_delete : '',
url_pay : '',
columns: [
{ 'label' : 'Idő' },
@@ -8,6 +10,7 @@ $.widget( "fitness.transferList", {
{ 'label' : 'Ár' },
{ 'label' : 'Db' },
{ 'label' : 'Összesen' },
{ 'label' : '' },
],
footers: [
{
@@ -100,6 +103,14 @@ $.widget( "fitness.transferList", {
s += '<td class=\'product-money\' >';
s += transfer.money;
s += '</td>';
s += '<td class=\'product-action\' style="width: 110px;" >';
s += '<form action="'+this.options.url_pay +"&id="+ transfer.id_transfer +'" method="POST" >';
s += "<button type='submit' class='btn btn-success pull-left' style='margin-right: 3px;' title='Tranzakció kifizetve' ><span style='font-size: 10px;' class= 'glyphicon glyphicon-eur\'></span></button>";
s += '</form>';
s += '<form action="'+this.options.url_delete +"&id="+ transfer.id_transfer +'" method="POST">';
s += "<button type='submit' class='btn btn-danger pull-left' title='Tranzakció törlése' ><span style='font-size: 10px;' class= 'glyphicon glyphicon-trash\'></span></button>";
s += '</form>';
s += '</td>';
s += '</tr>';
break;
case 'footer':
@@ -120,6 +131,9 @@ $.widget( "fitness.transferList", {
s += "<td class=\'product-money\' >";
s += footer.total( params.transfers );
s += "</td>";
s += "<td >";
s += "";
s += "</td>";
s += "</tr>";
}
s += "</tfoot>";