add reception key changes, add money movent storno, status display

This commit is contained in:
Roland Schneider 2016-01-22 19:10:30 +01:00
parent a2a6b1f240
commit 027a96790a
24 changed files with 220 additions and 25 deletions

View File

@ -5,6 +5,7 @@ use Yii;
use common\models\Order;
use yii\helpers\Html;
use common\components\RoleDefinition;
use common\components\Helper;
class AdminMenuStructure{
@ -112,13 +113,15 @@ class AdminMenuStructure{
$items[] = ['label' => 'GIRO köteg létrehozás', 'url' => ['/ticket-installment-request/download-giro' ] ];
$items[] = ['label' => 'GIRO kötegek', 'url' => ['/ugiro/index' ] ];
$items[] = ['label' => 'Detsta feltöltés', 'url' => ['/ugiro/upload' ] ];
$items[] = ['label' => 'Részletek aktiválása', 'url' => ['/ugiro/parts' ] ];
// $items[] = ['label' => 'Részletek aktiválása', 'url' => ['/ugiro/parts' ] ];
// $items[] = ['label' => 'Bevétel', 'url' => ['/transfer/summary' , 'TransferSummarySearch[start]' =>$today,'TransferSummarySearch[end]' => $tomorrow ] ];
// $items[] = ['label' => 'Napi bevételek', 'url' => ['/transfer/list', 'TransferListSearch[start]' =>$todayDatetime,'TransferListSearch[end]' => $tomorrowDatetime ] ];
// $items[] = ['label' => 'Kassza müveletek', 'url' => ['/account-state/index'] ];
if ( RoleDefinition::isAdmin() || RoleDefinition::isEmployee() ){
$this->menuItems[] = ['label' => 'Tartós megbízások', 'url' => $this->emptyUrl,
'items' => $items
];
}
}

View File

@ -28,6 +28,23 @@ class TicketInstallmentRequestController extends Controller
'accept' => ['post'],
],
],
'access' => [
'class' => \yii\filters\AccessControl::className (),
'rules' => [
// allow authenticated users
[
'actions' => [],
'allow' => true,
'roles' => [
'admin',
'employee',
'reception'
]
]
]
// everything else is denied
]
];
}

View File

@ -26,6 +26,23 @@ class UgiroController extends Controller
'delete' => ['post'],
],
],
'access' => [
'class' => \yii\filters\AccessControl::className (),
'rules' => [
// allow authenticated users
[
'actions' => [],
'allow' => true,
'roles' => [
'admin',
'employee',
'reception'
]
]
]
// everything else is denied
]
];
}

View File

@ -40,7 +40,7 @@ class TransferSearch extends Transfer
public function rules()
{
return [
[[ 'id_account','id_user', 'type'], 'integer'],
[[ 'id_account','id_user', 'type','status'], 'integer'],
// [[ 'searchObjectName' ], 'string'],
[[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
[[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
@ -101,6 +101,7 @@ class TransferSearch extends Transfer
'transfer.id_account' => $this->id_account,
'transfer.type' => $this->type,
'transfer.id_user' => $this->id_user,
'transfer.status' => $this->status
]);
$query->andFilterWhere(['in' ,'transfer.type', $this->types]);

View File

@ -190,6 +190,24 @@ $this->params['breadcrumbs'][] = $this->title;
<?php echo $model->ticket->part_paid ;?>
</td>
</tr>
<tr>
<th>
DetSta válasz kód
</th>
<td>
<?php echo $model->detsta_answer ;?>
</td>
<th>
DetSta válasz szöveg
</th>
<td>
<?php echo $model->comment ;?>
</td>
<th>
</th>
<td>
</td>
</tr>
</table>
<?php

View File

@ -92,6 +92,7 @@ $this->params['breadcrumbs'][] = $this->title;
],
'start:date',
'end:date',
'created_at:date',
[
'attribute' => 'id_user',
'value' => 'userName'

View File

@ -22,15 +22,18 @@ use kartik\widgets\DatePicker;
]); ?>
<div class='row'>
<div class='col-md-4'>
<div class='col-md-3'>
<?= $form->field($model, 'id_account')->dropDownList( ['' => Yii::t('common/transfer', 'All')] +HtmlHelper::mkAccountOptions($accounts) ) ?>
</div>
<div class='col-md-4'>
<div class='col-md-3'>
<?php echo $form->field($model, 'types')->checkboxList( Transfer::types()) ?>
</div>
<div class='col-md-4'>
<div class='col-md-3'>
<?= $form->field($model, 'id_user')->dropDownList( ['' => Yii::t('common/transfer', 'All')] +ArrayHelper::map($users,'id' , 'username') ) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'status')->dropDownList( ['' => "Mind"] + Transfer::statuses() ) ?>
</div>
</div>
<div class="row">

View File

@ -75,6 +75,10 @@ $this->params['breadcrumbs'][] = $this->title;
'attribute' => 'money',
'value' => 'signedMoney'
],
[
'attribute' => 'status',
'value' => 'statusName'
],
'created_at:datetime',
'paid_at:datetime',

View File

@ -5,6 +5,11 @@ namespace common\components;
use \Yii;
class Helper {
public static function getDateTimeString(){
return date("Y-m-d H:i:s");
}
public static function hufRound($m) {
$result = round ( $m / 5, 0 ) * 5;
return $result;

View File

@ -60,6 +60,8 @@ class CardSearch extends Card
$query->select(['card.id_card as card_id_card', 'card.number as card_number' , 'customer.name as customer_name', 'customer.email as customer_email','customer.phone as customer_phone']);
$query->from('card');
$query->innerJoin('customer','card.id_card = customer.id_customer_card');
$query->leftJoin("card_key_assignment", 'card.id_card = card_key_assignment.id_card');
$query->leftJoin("key", 'key.id_key = card_key_assignment.id_key');
$query->orderBy(['customer.name' => SORT_ASC]);
@ -77,9 +79,18 @@ class CardSearch extends Card
return $dataProvider;
}
$query->andFilterWhere([
// 'lower(customer.name)' => $this->customerName
// $query->andFilterWhere([
// 'lower(card.number)' => $this->customerName
// ]);
if ( !empty($this->number)){
$query->andWhere(['or',
['and',[ 'in','card.number' , [$this->number]],"trim(coalesce(card.number, '')) <>'' " ],
['and', ['in','card.rfid_key' ,[ $this->number] ],"trim(coalesce(card.rfid_key, '')) <>'' "],
['and',[ 'in','key.number' , [$this->number]],"trim(coalesce(key.number, '')) <>'' " ],
['and', ['in','key.rfid_key' ,[ $this->number] ],"trim(coalesce(key.rfid_key, '')) <>'' "]
]);
}
$query->andFilterWhere(['like', 'customer.name', $this->customerName]);

View File

@ -152,7 +152,7 @@ class MoneyMovement extends \yii\db\ActiveRecord
public static function toStatusName($id_status){
$result = "Ismeretlen";
$statuses = Ticket::statuses();
$statuses = MoneyMovement::statuses();
if ( array_key_exists($id_status, $statuses)){
$result = $statuses[$id_status];
}

View File

@ -5,6 +5,7 @@ namespace common\models;
use Yii;
use yii\helpers\ArrayHelper;
use yii\behaviors\TimestampBehavior;
use common\components\Helper;
/**
* This is the model class for table "ticket_installment_request".
@ -25,6 +26,9 @@ use yii\behaviors\TimestampBehavior;
* @property string $request_target_time_at
* @property string $created_at
* @property string $updated_at
* @property string $detsta_answer
* @property string $comment
* @property string $updated_at
* @property common\components\giro\GiroDETSTATetel $detstaTetel GiroDetstaTetel record a DetSta fájlból
*/
class TicketInstallmentRequest extends \yii\db\ActiveRecord
@ -144,6 +148,7 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
$this->status = $status;
$tranfer = $this->addTransfer();
$this->id_transfer = $tranfer->id_transfer;
$this->request_processed_at = Helper::getDateTimeString();
$this->save(false);
$this->applyNewTicketState($partRequired);
return true;
@ -152,6 +157,9 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
}
}else{
$this->status = $status;
$this->detsta_answer = $visszajelzes;
$this->comment = $comment;
$this->request_processed_at = Helper::getDateTimeString();
$this->save(false);
$this->applyNewTicketState($partRequired);
return true;

View File

@ -580,6 +580,8 @@ class Transfer extends \common\models\BaseFitnessActiveRecord
$query->andFilterWhere(['in' ,'transfer.type', $types]);
$query->andWhere(['not in','transfer.status', Transfer::STATUS_STORNO]);
if ( $mode == 'created_at'){
self::inInterval($query, 'transfer.created_at', $start, $end);

View File

@ -207,7 +207,7 @@ class TransferTicketSearch extends Transfer
protected function readTickets(){
$query = (new \yii\db\Query());
$query->select([ 'customer.name as customer_name', 'user.username as user_name', 'account.name as account_name','ticket_type.name as ticket_type_name' , 'transfer.count AS ticket_count', 'transfer.money AS ticket_money','transfer.item_price AS ticket_item_price', 'transfer.created_at as ticket_created_at','transfer.paid_at as ticket_paid_at']);
$query->select([ 'ticket.id_ticket as ticket_id_ticket', 'customer.name as customer_name', 'user.username as user_name', 'account.name as account_name','ticket_type.name as ticket_type_name' ,'ticket.status as ticket_status', '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");

View File

@ -0,0 +1,31 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160122_135105_alter__table__ticket_installment_request__add__column__detsta_code__and__comment extends Migration
{
public function up()
{
$this->addColumn("ticket_installment_request", "detsta_answer", "string");
$this->addColumn("ticket_installment_request", "comment", "string");
}
public function down()
{
echo "m160122_135105_alter__table__ticket_installment_request__add__column__detsta_code__and__comment cannot be reverted.\n";
return false;
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}

View File

@ -9,6 +9,7 @@ use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\Account;
use common\models\Transfer;
/**
* MoneyMovementController implements the CRUD actions for MoneyMovement model.
@ -66,6 +67,7 @@ class MoneyMovementController extends Controller
$model->id_user = Yii::$app->user->id;
$model->type = MoneyMovement::TYPE_OUT;
$model->id_account = Account::readDefault();
$model->status = MoneyMovement::STATUS_PAID;
$accounts = Account::read();
@ -107,9 +109,13 @@ class MoneyMovementController extends Controller
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
$model = $this->findModel($id);
$transfer = Transfer::find()->andWhere([ 'type' => Transfer::TYPE_MONEY_MOVEMENT_OUT ,'id_object' => $model->id_money_movement])->one();
return $this->redirect(['index']);
$transfer->storno();
// $this->findModel($id)->delete();
return $this->redirect(Yii::$app->request->referrer);
// return $this->redirect(['index']);
}
/**

View File

@ -51,7 +51,24 @@ class ReceptionForm extends Model
$this->number = str_replace("ö", "0", $this->number);
$this->card = Card::find()->andWhere(['or', ['and',[ 'in','number' , [$this->number]],"trim(coalesce(number, '')) <>'' " ], ['and', ['in','rfid_key' ,[ $this->number] ],"trim(coalesce(rfid_key, '')) <>'' "]])->one();
$query = Card::find();
$query->leftJoin("card_key_assignment", 'card.id_card = card_key_assignment.id_card');
$query->leftJoin("key", 'key.id_key = card_key_assignment.id_key');
$query->andWhere(['or',
['and',[ 'in','card.number' , [$this->number]],"trim(coalesce(card.number, '')) <>'' " ],
['and', ['in','card.rfid_key' ,[ $this->number] ],"trim(coalesce(card.rfid_key, '')) <>'' "],
['and',[ 'in','key.number' , [$this->number]],"trim(coalesce(key.number, '')) <>'' " ],
['and', ['in','key.rfid_key' ,[ $this->number] ],"trim(coalesce(key.rfid_key, '')) <>'' "]
]);
$this->card = $query->one();
if ( $this->card == null ){
}
if ( $this->card != null ){
$this->customer = $this->card->customer;
$this->readValidTickets();

View File

@ -25,7 +25,7 @@ use yii\widgets\ActiveForm;
<?php echo $form->field($model, 'customerName') ?>
</div>
<div class="col-md-4">
<?php echo $form->field($model, 'number') ?>
<?php echo $form->field($model, 'number')->label("Kártya/kulcs szám") ?>
</div>
</div>

View File

@ -37,10 +37,15 @@ use yii\helpers\Html;
<?php echo Html::textInput('CardSearch[customerName]','',['class'=>"form-control", 'placeholder' =>'Vendég neve']) ?>
</div>
<div class='col-md-3'>
<?= Html::submitButton(Yii::t('frontend/collection', 'Search'), ['class' => 'btn btn-primary']) ?>
<div class='col-md-2'>
<?= Html::submitButton(Yii::t('frontend/collection', 'Search'), ['class' => 'btn btn-primary btn-block']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<?php /* ?>
<div class="row" style="margin-bottom: 6px;">
<div class='col-md-4'>
</div>
<?php $form = ActiveForm::begin([
'action' => ['key/toggle', 'number' => $model->getCardNumber()],
'method' => 'post',
@ -50,12 +55,13 @@ use yii\helpers\Html;
<?php echo Html::textInput('KeyToggleForm[key]','',['class'=>"form-control", 'placeholder' =>'Kulcs']) ?>
</div>
<div class='col-md-3'>
<?= Html::submitButton(Yii::t('frontend/collection', 'Ki/Be'), ['class' => 'btn btn-primary']) ?>
<div class='col-md-2'>
<?= Html::submitButton(Yii::t('frontend/collection', 'Ki/Be'), ['class' => 'btn btn-primary btn-block']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<?php */ ?>
<div class='row'>
<div class='col-md-3'>
<?php echo ReceptionMenuWidget::widget( [ 'model' => $model ] ) ?>

View File

@ -34,7 +34,7 @@ if ( isset($model->card)){
]); ?>
<div class="row" >
<div class='col-md-12'>
<?php echo Html::textInput("number", $number ,['class' => 'form-control', 'placeholder' => 'Kártyaszám'])?>
<?php echo Html::textInput("number", $number ,['class' => 'form-control', 'placeholder' => 'Kártya/kulcs szám'])?>
</div>
</div>
<div class="row" >

View File

@ -54,6 +54,30 @@ $card = $model->card;
<?php echo HtmlHelper::mkReceptionBtn($model, Yii::t( 'frontend/transfer', 'Termékeladás'), 'product/sale')?>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
&nbsp;
</div>
</div>
<?php $form = ActiveForm::begin([
'action' => ['key/toggle', 'number' => $model->getCardNumber()],
'method' => 'post',
]); ?>
<div class="row" style="margin-bottom: 6px;">
<div class='col-md-12'>
<?php echo Html::hiddenInput('number', $model->getCardNumber())?>
<?php echo Html::textInput('KeyToggleForm[key]','',['class'=>"form-control", 'placeholder' =>'Kulcs']) ?>
</div>
</div>
<div class="row">
<div class='col-md-12'>
<?= Html::submitButton(Yii::t('frontend/collection', 'Kulcs Ki/Be'), ['class' => 'btn btn-primary btn-block']) ?>
</div>
</div>
<?php ActiveForm::end(); ?>

View File

@ -2,6 +2,7 @@
use yii\helpers\Html;
use yii\grid\GridView;
use common\models\MoneyMovement;
/* @var $this yii\web\View */
/* @var $searchModel frontend\models\MoneyMovementSearch */
@ -10,6 +11,11 @@ use yii\grid\GridView;
$this->title = Yii::t('backend/money-movement', 'Money Movements');
$this->params['breadcrumbs'][] = $this->title;
?>
<style>
.table .btn{ margin-right: 6px;}
</style>
<div class="money-movement-index">
<h1><?= Html::encode($this->title) ?></h1>
@ -43,7 +49,17 @@ $this->params['breadcrumbs'][] = $this->title;
],
['class' => 'yii\grid\ActionColumn',
'template' => '{view}'
'template' => '{view}{delete}',
'buttons' => [
'view' => function($url, $model, $key){
return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url,
[ 'title' => "Pénzmozgás részletei", 'class'=>'btn btn-success btn-xs', ]) ;
},
'delete' => function($url, $model, $key){
return $model->status == MoneyMovement::STATUS_STORNO ? "" : Html::a('<span class="glyphicon glyphicon-trash"></span>', $url,
[ 'title' => "Bérlet módosítása", 'class'=>'btn btn-danger btn-xs', 'data-method' =>'post']) ;
},
],
],
],
]); ?>

View File

@ -74,11 +74,11 @@ $this->params['breadcrumbs'][] = $this->title;
'buttons' => [
'update' => function($url, $model, $key){
return $model->status == Ticket::STATUS_DELETED ? "" : Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url,
[ 'title' => "Bérlet törlése", 'class'=>'btn btn-primary btn-xs', ]) ;
[ 'title' => "Bérlet módosítása", 'class'=>'btn btn-primary btn-xs', ]) ;
},
'delete' => function($url, $model, $key){
return $model->status == Ticket::STATUS_DELETED ? "" : Html::a('<span class="glyphicon glyphicon-trash"></span>', $url,
[ 'title' => "Bérlet módosítása", 'class'=>'btn btn-primary btn-xs', 'data-method' =>'post']) ;
[ 'title' => "Bérlet törlése", 'class'=>'btn btn-primary btn-xs', 'data-method' =>'post']) ;
},
],
// 'buttons ' => [

View File

@ -3,6 +3,7 @@ use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\ListView;
use yii\base\Widget;
use common\models\Ticket;
/* @var $this yii\web\View */
/* @var $searchModel common\models\TransferSearch */
@ -66,12 +67,14 @@ td.name {
<table class="table table-bordered table-striped table-summary">
<thead>
<tr>
<th>B. Azon</th>
<th>Kiadva</th>
<th>Fizetve</th>
<th>Kassza</th>
<th>Felhasználó</th>
<th>Vendég</th>
<th>Bérlet típus</th>
<th>Státusz</th>
<th>Egység ár</th>
<th>Mennyiség</th>
<th>Összeg</th>
@ -80,12 +83,14 @@ td.name {
<tbody>
<?php foreach ($searchModel->tickets as $t ){?>
<tr>
<td><?php echo $t['ticket_id_ticket']?> </td>
<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><?php echo Ticket::toStatusName( $t['ticket_status'] ) ?></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>