add backend transfer list changes
This commit is contained in:
parent
fda450b801
commit
b04cbda645
@ -8,6 +8,8 @@ use backend\models\TransferSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use common\models\Account;
|
||||
use common\models\User;
|
||||
|
||||
/**
|
||||
* TransferController implements the CRUD actions for Transfer model.
|
||||
@ -35,9 +37,19 @@ class TransferController extends Controller
|
||||
$searchModel = new TransferSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
$accounts = Account::readAccounts();
|
||||
$users = User::read();
|
||||
|
||||
$searchModel->totals(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
'accounts' => $accounts,
|
||||
'users' => $users,
|
||||
// 'totals' =>$totals
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ class ProcurementSearch extends Procurement
|
||||
'id_product' => $this->id_product,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere([ '>=', 'created_at', $this->date_start ] );
|
||||
$query->andFilterWhere([ '>=', 'created_at', $this->timestampStart ] );
|
||||
$query->andFilterWhere([ '<', 'created_at', $this->timestampEnd ] );
|
||||
|
||||
|
||||
|
||||
@ -6,20 +6,39 @@ use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\Transfer;
|
||||
use yii\db\Expression;
|
||||
use yii\base\Object;
|
||||
use yii\db\Query;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use common\models\Account;
|
||||
|
||||
/**
|
||||
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
||||
*/
|
||||
class TransferSearch extends Transfer
|
||||
{
|
||||
public $searchObjectName;
|
||||
public $searchTypeName;
|
||||
public $searchUserName;
|
||||
public $start;
|
||||
public $end;
|
||||
|
||||
public $timestampStart;
|
||||
public $timestampEnd;
|
||||
|
||||
public $accountTotals;
|
||||
public $fullTotal;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id_transfer', 'id_discount', 'id_currency', 'id_object', 'status', 'type', 'item_price', 'count', 'money', 'money_currency', 'rate', 'id_user'], 'integer'],
|
||||
[['comment', 'created_at', 'updated_at'], 'safe'],
|
||||
[[ 'id_account','id_user', 'type'], 'integer'],
|
||||
[[ 'searchObjectName' ], 'string'],
|
||||
[[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||
[[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||
];
|
||||
}
|
||||
|
||||
@ -47,33 +66,108 @@ class TransferSearch extends Transfer
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
$selectObjectName = "";
|
||||
$selectObjectName .= " case when transfer.type = " .self::TYPE_PRODUCT ." then product.name else ticket_type.name end as object_name";
|
||||
|
||||
$query->addSelect( ['*', new Expression($selectObjectName) ]);
|
||||
$query->joinWith('ticket');
|
||||
$query->joinWith('ticketType');
|
||||
$query->joinWith('product');
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
$query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
$query->andFilterWhere([
|
||||
'id_transfer' => $this->id_transfer,
|
||||
'id_discount' => $this->id_discount,
|
||||
'id_currency' => $this->id_currency,
|
||||
'id_object' => $this->id_object,
|
||||
'status' => $this->status,
|
||||
'type' => $this->type,
|
||||
'item_price' => $this->item_price,
|
||||
'count' => $this->count,
|
||||
'money' => $this->money,
|
||||
'money_currency' => $this->money_currency,
|
||||
'rate' => $this->rate,
|
||||
'id_user' => $this->id_user,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
'transfer.id_account' => $this->id_account,
|
||||
'transfer.type' => $this->type,
|
||||
'transfer.id_user' => $this->id_user,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'comment', $this->comment]);
|
||||
$query->andFilterWhere([ '>=', 'transfer.created_at', $this->timestampStart ] );
|
||||
$query->andFilterWhere([ '<', 'transfer.created_at', $this->timestampEnd ] );
|
||||
|
||||
if ( isset($this->searchObjectName))
|
||||
$query->andWhere( new Expression(" case when transfer.type = " .self::TYPE_PRODUCT ." then product.name else ticket_type.name end like '%" . $this->searchObjectName ."%'"));
|
||||
|
||||
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
public function totals($params){
|
||||
$query = new Query();
|
||||
|
||||
$result = [ ];
|
||||
|
||||
$accountTotals = [];
|
||||
$fullTotal = [
|
||||
'label' => Yii::t('common/transfer', 'Total'),
|
||||
'money' => 0
|
||||
];
|
||||
|
||||
$query->addSelect( [ new Expression( 'transfer.id_account as account'), new Expression( ' COALESCE(sum( transfer.money ),0) as money' )]);
|
||||
$query->from('transfer');
|
||||
$query->leftJoin('ticket', 'transfer.type = ' .self::TYPE_TICKET .' and transfer.id_object = ticket.id_ticket ' );
|
||||
$query->leftJoin('ticket_type', 'ticket.id_ticket_type = ticket_type.id_ticket_type ' );
|
||||
$query->leftJoin('product', 'product.id_product = ' .self::TYPE_TICKET .' and transfer.id_object = ticket.id_ticket ' );
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
return ;
|
||||
}
|
||||
|
||||
$query->andFilterWhere([
|
||||
'transfer.id_account' => $this->id_account,
|
||||
'transfer.type' => $this->type,
|
||||
'transfer.id_user' => $this->id_user,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere([ '>=', 'transfer.created_at', $this->timestampStart ] );
|
||||
$query->andFilterWhere([ '<', 'transfer.created_at', $this->timestampEnd ] );
|
||||
|
||||
|
||||
if ( isset($this->searchObjectName) && !empty($this->searchObjectName)){
|
||||
$query->andWhere( new Expression(" case when transfer.type = " .self::TYPE_PRODUCT ." then product.name else ticket_type.name end like '%" . $this->searchObjectName ."%'"));
|
||||
}
|
||||
|
||||
$query->groupBy('transfer.id_account');
|
||||
|
||||
$command = $query->createCommand();
|
||||
// $command->sql returns the actual SQL
|
||||
$result = $command->queryAll();
|
||||
|
||||
|
||||
$accounts = Account::find()->orderBy("name asc")->all();
|
||||
$accountMap = ArrayHelper::map( $accounts ,'id_account','name' );
|
||||
|
||||
|
||||
|
||||
foreach ($result as $item){
|
||||
$account = "";
|
||||
if ( array_key_exists($item['account'], $accountMap)){
|
||||
$account = $accountMap[$item['account']];
|
||||
}
|
||||
|
||||
$accountTotal = [
|
||||
'label' => $account,
|
||||
'money' => $item['money']
|
||||
];
|
||||
|
||||
$accountTotals[] = $accountTotal;
|
||||
|
||||
$fullTotal['money'] += $item['money'];
|
||||
}
|
||||
|
||||
$this->accountTotals = $accountTotals;
|
||||
$this->fullTotal = $fullTotal;
|
||||
|
||||
// return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,12 +2,18 @@
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
use frontend\components\HtmlHelper;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use common\models\Transfer;
|
||||
use kartik\widgets\DatePicker;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\models\TransferSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
<?php
|
||||
|
||||
?>
|
||||
<div class="transfer-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
@ -15,39 +21,49 @@ use yii\widgets\ActiveForm;
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id_transfer') ?>
|
||||
<div class='row'>
|
||||
<div class='col-md-4'>
|
||||
<?= $form->field($model, 'id_account')->dropDownList( ['' => Yii::t('common/transfer', 'All')] +HtmlHelper::mkAccountOptions($accounts) ) ?>
|
||||
</div>
|
||||
<div class='col-md-4'>
|
||||
<?= $form->field($model, 'type')->dropDownList( ['' => Yii::t('common/transfer', 'All')] + Transfer::types() ) ?>
|
||||
</div>
|
||||
<div class='col-md-4'>
|
||||
<?= $form->field($model, 'id_user')->dropDownList( ['' => Yii::t('common/transfer', 'All')] +ArrayHelper::map($users,'id' , 'username') ) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= $form->field($model, 'id_discount') ?>
|
||||
|
||||
<?= $form->field($model, 'id_currency') ?>
|
||||
|
||||
<?= $form->field($model, 'id_object') ?>
|
||||
|
||||
<?= $form->field($model, 'status') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'type') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'item_price') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'count') ?>
|
||||
<div class="row">
|
||||
<div class='col-md-4'>
|
||||
<?php echo $form->field($model, 'searchObjectName') ?>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<?= $form->field($model, 'start')->widget(DatePicker::classname(), [
|
||||
'pluginOptions' => [
|
||||
'autoclose'=>true,
|
||||
'format' => 'yyyy.mm.dd'
|
||||
]
|
||||
]) ?>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<?= $form->field($model, 'end') ->widget(DatePicker::classname(), [
|
||||
'pluginOptions' => [
|
||||
'autoclose'=>true,
|
||||
'format' => 'yyyy.mm.dd'
|
||||
]
|
||||
]) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php // echo $form->field($model, 'money') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'money_currency') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'rate') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'id_user') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'comment') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'created_at') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'updated_at') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton(Yii::t('frontend/transfer', 'Search'), ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton(Yii::t('frontend/transfer', 'Reset'), ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
@ -2,6 +2,10 @@
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
use yii\widgets\DetailView;
|
||||
use yii\base\Widget;
|
||||
use yii\base\Object;
|
||||
use yii\data\ArrayDataProvider;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\models\TransferSearch */
|
||||
@ -13,30 +17,68 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
<div class="transfer-index">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a(Yii::t('frontend/transfer', 'Create Transfer'), ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
<?php echo $this->render('_search', ['model' => $searchModel, 'accounts' => $accounts,'users' => $users,]); ?>
|
||||
|
||||
<?php
|
||||
?>
|
||||
<h2>Összesen</h2>
|
||||
<?php
|
||||
echo DetailView::widget([
|
||||
'model' => $searchModel->fullTotal,
|
||||
'attributes' => [
|
||||
[
|
||||
'value' => $searchModel->fullTotal['money'],
|
||||
'label' => $searchModel->fullTotal['label'],
|
||||
],
|
||||
]
|
||||
])
|
||||
?>
|
||||
<h2>Kasszák összesen</h2>
|
||||
<?php
|
||||
echo GridView::widget([
|
||||
'dataProvider' => new ArrayDataProvider([
|
||||
'allModels' => $searchModel->accountTotals,
|
||||
'sort' => false,
|
||||
'pagination' => false,
|
||||
]) ,
|
||||
'columns' => [
|
||||
[
|
||||
'label' => Yii::t('common/transfer','Account'),
|
||||
'value' => 'label'
|
||||
],
|
||||
[
|
||||
'label' => Yii::t('common/transfer','Money total'),
|
||||
'value' => 'money'
|
||||
],
|
||||
]
|
||||
]
|
||||
);
|
||||
?>
|
||||
<h2>Pénzmozgások</h2>
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'columns' => [
|
||||
|
||||
'id_discount',
|
||||
'id_currency',
|
||||
'id_object',
|
||||
'status',
|
||||
// 'type',
|
||||
// 'item_price',
|
||||
// 'count',
|
||||
// 'money',
|
||||
// 'money_currency',
|
||||
// 'rate',
|
||||
// 'id_user',
|
||||
// 'comment',
|
||||
[
|
||||
'attribute' => 'type',
|
||||
'value' => 'transferTypeName'
|
||||
],
|
||||
[
|
||||
'attribute' => 'id_object',
|
||||
'value' => 'objectName'
|
||||
],
|
||||
[
|
||||
'attribute' => 'id_user',
|
||||
'value' => 'userName'
|
||||
],
|
||||
[
|
||||
'attribute' => 'id_account',
|
||||
'value' => 'accountName'
|
||||
],
|
||||
'item_price',
|
||||
'count',
|
||||
'money',
|
||||
'created_at:datetime',
|
||||
'updated_at:datetime',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{view}'
|
||||
|
||||
@ -14,35 +14,33 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<p>
|
||||
<?= Html::a(Yii::t('frontend/transfer', 'Update'), ['update', 'id' => $model->id_transfer], ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::a(Yii::t('frontend/transfer', 'Delete'), ['delete', 'id' => $model->id_transfer], [
|
||||
'class' => 'btn btn-danger',
|
||||
'data' => [
|
||||
'confirm' => Yii::t('frontend/transfer', 'Are you sure you want to delete this item?'),
|
||||
'method' => 'post',
|
||||
],
|
||||
]) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id_transfer',
|
||||
'id_discount',
|
||||
'id_currency',
|
||||
'id_object',
|
||||
'status',
|
||||
'type',
|
||||
[
|
||||
'attribute' => 'id_transfer',
|
||||
],
|
||||
[
|
||||
'attribute' => 'id_account',
|
||||
'value' => $model->accountName
|
||||
],
|
||||
[
|
||||
'attribute' => 'type',
|
||||
'value' => $model->transferTypeName,
|
||||
],
|
||||
[
|
||||
'attribute' => 'id_object',
|
||||
'value' => $model->objectName,
|
||||
],
|
||||
[
|
||||
'attribute' => 'id_user',
|
||||
'value' => $model->userName,
|
||||
],
|
||||
'item_price',
|
||||
'count',
|
||||
'money',
|
||||
'money_currency',
|
||||
'rate',
|
||||
'id_user',
|
||||
'comment',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
|
||||
@ -124,4 +124,27 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param common\models\Card $card the card to which we are looking for
|
||||
* */
|
||||
public static function readActive($card){
|
||||
|
||||
if ( $card == null )
|
||||
return [];
|
||||
|
||||
$query = Ticket::find();
|
||||
$today = date('Y-m-d');
|
||||
|
||||
$query->andWhere(['id_card' => $card->id_card]);
|
||||
$query->andWhere( 'start <= :today' ,[ 'today' => $today] );
|
||||
$query->andWhere( 'end >= :today' ,[ 'today' => $today] );
|
||||
|
||||
$result = $query->all();
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -79,13 +79,22 @@ class Transfer extends \yii\db\ActiveRecord
|
||||
];
|
||||
}
|
||||
|
||||
public function getUser(){
|
||||
return $this->hasOne( User::className(), ["id" =>"id_user" ] );
|
||||
}
|
||||
|
||||
public function getProduct(){
|
||||
return $this->hasOne( Product::className(), ["id_product" =>"id_object" ] );
|
||||
}
|
||||
|
||||
public function getTicket(){
|
||||
return $this->hasOne( Ticket::className(), ["id_ticket" =>"id_object" ] );
|
||||
}
|
||||
|
||||
public function getTicketType(){
|
||||
return $this->hasOne( TicketType::className(), ["id_ticket_type" =>"id_ticket_type" ] )->via('ticket') ;
|
||||
}
|
||||
|
||||
public function getAccount(){
|
||||
return $this->hasOne( Account::className(), ["id_account" =>"id_account" ] ) ;
|
||||
}
|
||||
@ -102,6 +111,65 @@ class Transfer extends \yii\db\ActiveRecord
|
||||
return $this->hasOne( UserSoldItem::className(), ["id_transfer" =>"id_transfer" ] );
|
||||
}
|
||||
|
||||
public function getObjectName(){
|
||||
$result = "";
|
||||
if ( $this->type == Transfer::TYPE_TICKET ){
|
||||
$result = $this->ticketName;
|
||||
}else{
|
||||
$result = $this->productName;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
public function getUserName(){
|
||||
$result = "";
|
||||
$user = $this->user;
|
||||
if (isset($this->user)){
|
||||
$result = $user->username;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getProductName(){
|
||||
$result = "";
|
||||
$product = $this->product;
|
||||
if (isset($product)){
|
||||
$result = $product->name;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getTicketName(){
|
||||
$result = "";
|
||||
$ticket = $this->ticket;
|
||||
if (isset($ticket)){
|
||||
$result = $this->ticket->ticketTypeName;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
public function getAccountName(){
|
||||
$result = "";
|
||||
$account = $this->account;
|
||||
if (isset($account)){
|
||||
$result = $account->name;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getTransferTypeName(){
|
||||
$result = "";
|
||||
if ( $this->type == Transfer::TYPE_TICKET ){
|
||||
$result = Yii::t('common/transfer','Ticket');
|
||||
}else{
|
||||
$result = Yii::t('common/transfer','Product');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function toProductSoldString(){
|
||||
$s = "";
|
||||
@ -239,4 +307,11 @@ class Transfer extends \yii\db\ActiveRecord
|
||||
return $transfers;
|
||||
}
|
||||
|
||||
public static function types( ) {
|
||||
return [
|
||||
self::TYPE_PRODUCT => Yii::t('common/transfer','Product'),
|
||||
self::TYPE_TICKET => Yii::t('common/transfer','Ticket'),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,6 +9,39 @@ use yii\helpers\ArrayHelper;
|
||||
class HtmlHelper{
|
||||
|
||||
|
||||
/**
|
||||
* Mehtod used in reception widgets to render card dependent buttons
|
||||
*
|
||||
* @see ReceptionCardNumberTicketsWidget
|
||||
* @see ReceptionCardNumberWidget
|
||||
* @see ReceptionMenuWidget
|
||||
* */
|
||||
public static function mkReceptionCardBtn($card, $label,$route = null ){
|
||||
|
||||
$url = null;
|
||||
$classes = 'btn btn-primary btn-reception';
|
||||
if ( $card == null ){
|
||||
$classes .= ' disabled';
|
||||
}
|
||||
if ( isset($route)){
|
||||
$url = [$route, 'number' => ( isset( $card ) ? $card->number : '' )];
|
||||
}
|
||||
return Html::a( $label , $url, ['class' => $classes ] );
|
||||
}
|
||||
|
||||
public static function mkReceptionBtn($card, $label,$route = null ){
|
||||
|
||||
$url = null;
|
||||
$classes = 'btn btn-primary btn-reception';
|
||||
|
||||
if ( isset($route)){
|
||||
$url = [$route, 'number' => ( isset( $card ) ? $card->number : '' )];
|
||||
}
|
||||
|
||||
return Html::a( $label , $url, ['class' => $classes ] );
|
||||
}
|
||||
|
||||
|
||||
public static function mkOptions( $models, $key, $value = 'name' ){
|
||||
$result = [];
|
||||
$result = ArrayHelper::map( $models, $key, $value );
|
||||
|
||||
24
frontend/components/ReceptionCardNumberTicketsWidget.php
Normal file
24
frontend/components/ReceptionCardNumberTicketsWidget.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace frontend\components;
|
||||
|
||||
use yii\base\Widget;
|
||||
|
||||
class ReceptionCardNumberTicketsWidget extends Widget{
|
||||
|
||||
public $number;
|
||||
public $route;
|
||||
|
||||
public $customer;
|
||||
public $card;
|
||||
|
||||
public $tickets;
|
||||
|
||||
public $viewFile = '//common/_card_number_tickets';
|
||||
|
||||
|
||||
public function run(){
|
||||
echo $this->render($this->viewFile,[ 'tickets' => $this->tickets, 'card' => $this->card, 'customer' =>$this->customer , 'route' => $this->route ]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
36
frontend/components/ReceptionWidget.php
Normal file
36
frontend/components/ReceptionWidget.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace frontend\components;
|
||||
|
||||
use yii\base\Widget;
|
||||
|
||||
class ReceptionWidget extends Widget{
|
||||
|
||||
public $form;
|
||||
|
||||
public $number;
|
||||
public $route;
|
||||
|
||||
public $customer;
|
||||
public $card;
|
||||
|
||||
public $tickets;
|
||||
|
||||
public $viewFile = '//common/_reception';
|
||||
|
||||
public function init(){
|
||||
parent::init();
|
||||
if ( isset($this->form)){
|
||||
$this->card = $this->form->card;
|
||||
$this->customer = $this->form->customer;
|
||||
$this->tickets = $this->form->tickets;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function run(){
|
||||
echo $this->render($this->viewFile,['card' => $this->card, 'customer' =>$this->customer, 'tickets' => $this->tickets ]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -39,6 +39,18 @@ class ProductController extends Controller
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className(),
|
||||
'only' => [ 'sale','clear-list', 'lookup'],
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -126,82 +138,8 @@ class ProductController extends Controller
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lists all Product models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new ProductSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single Product model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Product model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new Product();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id_product]);
|
||||
} else {
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing Product model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id_product]);
|
||||
} else {
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing Product model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -250,4 +188,86 @@ class ProductController extends Controller
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Product models.
|
||||
* @return mixed
|
||||
*/
|
||||
/*
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new ProductSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Displays a single Product model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
/*
|
||||
public function actionView($id)
|
||||
{
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Updates an existing Product model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
/*
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id_product]);
|
||||
} else {
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Deletes an existing Product model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
/*
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Creates a new Product model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
/*
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new Product();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id_product]);
|
||||
} else {
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@ -31,6 +31,18 @@ class TicketController extends Controller
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className(),
|
||||
'only' => ['create', 'index' ],
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -59,18 +71,6 @@ class TicketController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single Ticket model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Ticket model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
@ -123,38 +123,6 @@ class TicketController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing Ticket model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id_ticket]);
|
||||
} else {
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing Ticket model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the Ticket model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
@ -170,4 +138,51 @@ class TicketController extends Controller
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Displays a single Ticket model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
/*
|
||||
public function actionView($id)
|
||||
{
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Deletes an existing Ticket model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
/*
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Updates an existing Ticket model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
/*
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id_ticket]);
|
||||
} else {
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ use Yii;
|
||||
use yii\base\Model;
|
||||
use common\models\Card;
|
||||
use common\models\Customer;
|
||||
use common\models\Ticket;
|
||||
|
||||
/**
|
||||
* ContactForm is the model behind the contact form.
|
||||
@ -15,6 +16,7 @@ class ReceptionForm extends Model
|
||||
public $number;
|
||||
public $card;
|
||||
public $customer;
|
||||
public $tickets;
|
||||
|
||||
|
||||
/**
|
||||
@ -39,10 +41,18 @@ class ReceptionForm extends Model
|
||||
}
|
||||
|
||||
public function readCard(){
|
||||
|
||||
$this->card = Card::findOne(['number' => $this->number]);
|
||||
if ( $this->card != null ){
|
||||
$this->customer = $this->card->customer;
|
||||
$this->readValidTickets();
|
||||
}
|
||||
}
|
||||
|
||||
public function readValidTickets(){
|
||||
$this->tickets = Ticket::readActive($this->card);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ class TicketSearch extends Ticket
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
'sort'=> ['defaultOrder' => ['end'=>SORT_DESC]]
|
||||
'sort'=> ['defaultOrder' => ['created_at'=>SORT_DESC]]
|
||||
]);
|
||||
|
||||
|
||||
|
||||
41
frontend/views/common/_card_number_tickets.php
Normal file
41
frontend/views/common/_card_number_tickets.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
use yii\base\Object;
|
||||
use common\models\Ticket;
|
||||
?>
|
||||
<style>
|
||||
.reception-tickets-container{
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
<div class="reception-tickets-container">
|
||||
<table class="table table-bordered table-striped">
|
||||
<?php $model = new Ticket() ;?>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php echo $model->getAttributeLabel('id_ticket_type') ?></th>
|
||||
<th><?php echo $model->getAttributeLabel('start') ?></th>
|
||||
<th><?php echo $model->getAttributeLabel('end') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<?php if (isset($tickets) && count($tickets) ) {?>
|
||||
<tbody>
|
||||
<?php foreach ($tickets as $ticket){ ?>
|
||||
<tr>
|
||||
<td>
|
||||
<?php echo $ticket->ticketTypeName ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo Yii::$app->formatter->asDate( $ticket->start ) ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo Yii::$app->formatter->asDate( $ticket->end ) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
</tbody>
|
||||
<?php }?>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
@ -3,6 +3,7 @@
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
use yii\helpers\Url;
|
||||
use frontend\components\HtmlHelper;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $card common\models\Card */
|
||||
@ -25,7 +26,7 @@ if ( isset($customer ) ){
|
||||
$customername = $customer->name;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
function mkCustomerBtn($card, $label,$route = null ){
|
||||
|
||||
$url = null;
|
||||
@ -38,7 +39,6 @@ function mkCustomerBtn($card, $label,$route = null ){
|
||||
}
|
||||
return Html::a( $label , $url, ['class' => $classes ] );
|
||||
}
|
||||
|
||||
function mkBtn($card, $label,$route = null ){
|
||||
|
||||
$url = null;
|
||||
@ -50,12 +50,13 @@ function mkBtn($card, $label,$route = null ){
|
||||
|
||||
return Html::a( $label , $url, ['class' => $classes ] );
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
?>
|
||||
<div class='row'>
|
||||
<div class='col-md-8'>
|
||||
<?php echo mkCustomerBtn( $card, Yii::t( 'frontend/customer' , 'Adatlap') , 'customer/update' ); ?>
|
||||
<?php echo HtmlHelper::mkReceptionCardBtn( $card, Yii::t( 'frontend/customer' , 'Adatlap') , 'customer/update' ); ?>
|
||||
</div>
|
||||
<div class='col-md-4'>
|
||||
<?php echo Html::a(Html::tag("i","", [ 'class' => 'glyphicon glyphicon-plus' ] ) , Url::toRoute('customer/create') , ['class' => 'btn btn-primary btn-reception'] )?>
|
||||
@ -63,15 +64,15 @@ function mkBtn($card, $label,$route = null ){
|
||||
</div>
|
||||
<div class='row'>
|
||||
<div class='col-md-8'>
|
||||
<?php echo mkCustomerBtn( $card, Yii::t( 'frontend/customer' , 'Befizetések') , 'ticket/index'); ?>
|
||||
<?php echo HtmlHelper::mkReceptionCardBtn( $card, Yii::t( 'frontend/customer' , 'Befizetések') , 'ticket/index'); ?>
|
||||
</div>
|
||||
<div class='col-md-4'>
|
||||
<?php echo mkCustomerBtn( $card, Html::tag("i","", [ 'class' => 'glyphicon glyphicon-plus' ] ) , 'ticket/create' ); ?>
|
||||
<?php echo HtmlHelper::mkReceptionCardBtn( $card, Html::tag("i","", [ 'class' => 'glyphicon glyphicon-plus' ] ) , 'ticket/create' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class='row'>
|
||||
<div class='col-md-12'>
|
||||
<?php echo mkBtn($card, Yii::t( 'frontend/transfer', 'Termékeladás'), 'product/sale')?>
|
||||
<?php echo HtmlHelper::mkReceptionBtn($card, Yii::t( 'frontend/transfer', 'Termékeladás'), 'product/sale')?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
18
frontend/views/common/_reception.php
Normal file
18
frontend/views/common/_reception.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
use frontend\components\ReceptionCardNumberWidget;
|
||||
use frontend\components\ReceptionMenuWidget;
|
||||
use frontend\models\ReceptionForm;
|
||||
use frontend\components\ReceptionCardNumberTicketsWidget;
|
||||
use yii\base\Widget;
|
||||
?>
|
||||
<div class='row'>
|
||||
<div class='col-md-3'>
|
||||
<?php echo ReceptionMenuWidget::widget( [ 'customer' => $customer, 'card' => $card] ) ?>
|
||||
</div>
|
||||
<div class='col-md-4'>
|
||||
<?php echo ReceptionCardNumberWidget::widget( [ 'customer' => $customer, 'card' =>$card, 'route' => ['customer/reception'] ] )?>
|
||||
</div>
|
||||
<div class='col-md-4'>
|
||||
<?php echo ReceptionCardNumberTicketsWidget::widget([ 'tickets' => $tickets, 'customer' => $customer, 'card' =>$card, 'route' => ['customer/reception'] ] ) ?>
|
||||
</div>
|
||||
</div>
|
||||
@ -78,7 +78,7 @@ $discountOptions = mkOptions( ArrayHelper::map($discounts, 'id_discount', 'name'
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class='col-md-12'>
|
||||
<?php echo $form->field($model,'id_currency')->dropDownList($currencyOptions) ?>
|
||||
<?php //echo $form->field($model,'id_currency')->dropDownList($currencyOptions) ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
@ -4,6 +4,8 @@ use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
use frontend\components\ReceptionMenuWidget;
|
||||
use frontend\components\ReceptionCardNumberWidget;
|
||||
use frontend\components\ReceptionWidget;
|
||||
use yii\base\Widget;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel frontend\models\TicketSearch */
|
||||
@ -18,16 +20,8 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="ticket-index">
|
||||
|
||||
<div class='row'>
|
||||
<div class='col-md-3'>
|
||||
<?php echo ReceptionMenuWidget::widget( [ 'customer' => $customer, 'card' => $card] ) ?>
|
||||
</div>
|
||||
<div class='col-md-4'>
|
||||
<?php echo ReceptionCardNumberWidget::widget( [ 'customer' => $customer, 'card' =>$card, 'route' => ['customer/reception'] ] )?>
|
||||
</div>
|
||||
<div class='col-md-4'>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php echo ReceptionWidget::widget( ['form' => $receptionForm, 'route' => ['customer/reception'] ] )?>
|
||||
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
@ -57,16 +51,19 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'attribute' => 'id_user',
|
||||
'value' => 'userName'
|
||||
],
|
||||
/*
|
||||
[
|
||||
'attribute' => 'id_discount',
|
||||
'value' => 'discountName'
|
||||
],
|
||||
*/
|
||||
'price_brutto',
|
||||
'created_at:datetime',
|
||||
|
||||
/*
|
||||
['class' => 'yii\grid\ActionColumn',
|
||||
'template' =>'{view} {update}',
|
||||
],
|
||||
*/
|
||||
],
|
||||
]); ?>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user