add feature clear card
This commit is contained in:
parent
ee4ae54e6f
commit
5ff974c717
@ -14,6 +14,7 @@ use yii\web\UploadedFile;
|
||||
use common\components\Helper;
|
||||
use backend\models\CardInsertForm;
|
||||
use common\models\Ticket;
|
||||
use frontend\components\HtmlHelper;
|
||||
|
||||
/**
|
||||
* CardController implements the CRUD actions for Card model.
|
||||
@ -25,6 +26,16 @@ class CardController extends \backend\controllers\BackendController {
|
||||
'class' => \yii\filters\AccessControl::className (),
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'actions' => [
|
||||
'clear',
|
||||
|
||||
],
|
||||
'allow' => true,
|
||||
'roles' => [
|
||||
'admin'
|
||||
]
|
||||
],
|
||||
[
|
||||
'actions' => [
|
||||
'create',
|
||||
@ -40,7 +51,8 @@ class CardController extends \backend\controllers\BackendController {
|
||||
'roles' => [
|
||||
'@'
|
||||
]
|
||||
]
|
||||
] ,
|
||||
|
||||
]
|
||||
// everything else is denied
|
||||
|
||||
@ -48,6 +60,23 @@ class CardController extends \backend\controllers\BackendController {
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function actionClear($id){
|
||||
|
||||
$model = $this->findModel ( $id );
|
||||
|
||||
$customer = $model->customer;
|
||||
|
||||
$customer->id_customer_card = null;
|
||||
$customer->save(false);
|
||||
|
||||
Ticket::updateAll(['id_card' => null],['id_card' => $model->id_card]);
|
||||
|
||||
Helper::flash('success', "Vendég törölve a kártyáról");
|
||||
|
||||
$this->redirect(['card/update','id' =>$id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Card models.
|
||||
*
|
||||
|
||||
@ -33,7 +33,7 @@ class KeyController extends Controller {
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'actions' => ['create','index','view','update','import'],
|
||||
'actions' => ['create','index','view','update','import','index-customer'],
|
||||
'allow' => true,
|
||||
'roles' => ['admin','employee','reception'],
|
||||
],
|
||||
|
||||
@ -137,7 +137,7 @@ class TicketController extends \backend\controllers\BackendController {
|
||||
$searchModel = new TicketSearchCustomer(['customer' => $customer]);
|
||||
$searchModel->id_card = $customer->id_customer_card;
|
||||
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
|
||||
$searchModel->searchTotals ();
|
||||
//$searchModel->searchTotals ();
|
||||
|
||||
$searchModel->users = User::read ();
|
||||
$searchModel->accounts = Account::read ();
|
||||
|
||||
@ -63,7 +63,6 @@ class TransferController extends \backend\controllers\BackendController
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
|
||||
echo "output:".$searchModel->output;
|
||||
|
||||
if ( $searchModel->output =='pdf'){
|
||||
$this->downloadPaymentLater($dataProvider);
|
||||
|
||||
@ -62,21 +62,6 @@ class CustomerSearch extends Customer
|
||||
];
|
||||
|
||||
|
||||
// $dataProvider->setSort(
|
||||
|
||||
|
||||
// [
|
||||
// 'attributes' => [
|
||||
// 'id',
|
||||
// 'fullName' => [
|
||||
// 'asc' => ['first_name' => SORT_ASC, 'last_name' => SORT_ASC],
|
||||
// 'desc' => ['first_name' => SORT_DESC, 'last_name' => SORT_DESC],
|
||||
// 'label' => 'Full Name',
|
||||
// 'default' => SORT_ASC
|
||||
// ],
|
||||
// 'country_id'
|
||||
// ]
|
||||
// ]);
|
||||
|
||||
|
||||
$this->load($params);
|
||||
@ -89,18 +74,7 @@ class CustomerSearch extends Customer
|
||||
|
||||
$query->leftJoin(Card::tableName(), " customer.id_customer_card = card.id_card" );
|
||||
|
||||
// $query->andFilterWhere([
|
||||
// 'id_customer' => $this->id_customer,
|
||||
// 'id_customer_card' => $this->id_customer_card,
|
||||
// 'id_user' => $this->id_user,
|
||||
// 'id_partner_card' => $this->id_partner_card,
|
||||
// 'id_proposer' => $this->id_proposer,
|
||||
// 'sex' => $this->sex,
|
||||
// 'date_stundent_card_expire' => $this->date_stundent_card_expire,
|
||||
// 'birthdate' => $this->birthdate,
|
||||
// 'created_at' => $this->created_at,
|
||||
// 'updated_at' => $this->updated_at,
|
||||
// ]);
|
||||
|
||||
|
||||
$query->andFilterWhere(['like', 'customer.name', $this->name])
|
||||
->andFilterWhere(['like', 'customer.email', $this->email])
|
||||
|
||||
@ -11,9 +11,11 @@ use yii\db\ActiveRecord;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\db\Query;
|
||||
use common\models\Transfer;
|
||||
use yii\helpers\VarDumper;
|
||||
|
||||
/**
|
||||
* TicketSearch represents the model behind the search form about `common\models\Ticket`.
|
||||
* @property commom\models\Customer $customer
|
||||
*/
|
||||
class TicketSearchCustomer extends Ticket
|
||||
{
|
||||
@ -32,7 +34,9 @@ class TicketSearchCustomer extends Ticket
|
||||
public $statistics;
|
||||
public $statisticsTotal;
|
||||
|
||||
public $customer;
|
||||
public $customer; //constructor param
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -41,7 +45,7 @@ class TicketSearchCustomer extends Ticket
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[[ 'id_ticket', 'id_user', 'id_ticket_type', 'id_account','status'], 'integer'],
|
||||
[[ 'id_ticket', 'id_user', 'id_ticket_type', 'id_account','status' ], 'integer'],
|
||||
[[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||
[[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||
[['valid_in_interval','created_in_interval','expire_in_interval'],'boolean'] ,
|
||||
@ -113,7 +117,8 @@ class TicketSearchCustomer extends Ticket
|
||||
$query->innerJoin('user', 'user.id = transfer.id_user');
|
||||
$query->leftJoin('user as paid_by', 'paid_by.id = transfer.paid_by');
|
||||
$query->leftJoin('card', 'ticket.id_card = card.id_card');
|
||||
$query->leftJoin('customer', 'customer.id_customer_card = card.id_card');
|
||||
$query->leftJoin('customer', 'customer.id_customer= transfer.id_customer');
|
||||
|
||||
|
||||
Helper::queryAccountConstraint($query, 'ticket.id_account');
|
||||
|
||||
@ -177,11 +182,12 @@ class TicketSearchCustomer extends Ticket
|
||||
|
||||
|
||||
if (!$this->validate()) {
|
||||
$query->where('0=1');
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
$query->andWhere( ['transfer.id_customer' => $this->customer->id_customer ]);
|
||||
|
||||
$query->andFilterWhere([
|
||||
'ticket.id_user' => $this->id_user,
|
||||
'ticket.id_ticket_type' => $this->id_ticket_type,
|
||||
@ -191,7 +197,7 @@ class TicketSearchCustomer extends Ticket
|
||||
'ticket.status' => $this->status
|
||||
]);
|
||||
|
||||
$query->andWhere(['customer.id_customer' => $this->customer->id_customer]);
|
||||
// $query->andWhere(['customer.id_customer' => $this->customer->id_customer]);
|
||||
|
||||
|
||||
$all = (!($this->valid_in_interval) && !($this->expire_in_interval) && !($this->created_in_interval) )
|
||||
@ -230,7 +236,8 @@ class TicketSearchCustomer extends Ticket
|
||||
|
||||
|
||||
public function searchTotals(){
|
||||
$query = Ticket::mkStatisticQuery($this->timestampStart, $this->timestampEnd,$this->id_card);
|
||||
$query = Ticket::mkStatisticQuery($this->timestampStart, $this->timestampEnd);
|
||||
$query->andWhere(["transfer.id_customer" => $this->id ]);
|
||||
$this->statistics = $query->all();
|
||||
|
||||
$this->statisticsTotal =[
|
||||
|
||||
@ -23,7 +23,7 @@ use common\models\Card;
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/card', 'Create') : Yii::t('common/card', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
|
||||
<?= Html::submitButton( Yii::t('common/card', 'Create/Next') ,['class' => 'btn btn-primary','name'=>'create_next']) ?>
|
||||
<?php //echo Html::submitButton( Yii::t('common/card', 'Create/Next') ,['class' => 'btn btn-primary','name'=>'create_next']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
@ -1,23 +1,56 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
use yii\base\Widget;
|
||||
use common\components\Helper;
|
||||
use common\components\RoleDefinition;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Card */
|
||||
|
||||
$this->title = Yii::t('common/card', 'Update {modelClass}: ', [
|
||||
'modelClass' => 'Card',
|
||||
]) . ' ' . $model->id_card;
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/card', 'Cards'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->number, 'url' => ['view', 'id' => $model->id_card]];
|
||||
$this->params['breadcrumbs'][] = Yii::t('common/card', 'Update');
|
||||
$this->title = Yii::t ( 'common/card', 'Bérletkártya módosítása' );
|
||||
$this->params ['breadcrumbs'] [] = [
|
||||
'label' => Yii::t ( 'common/card', 'Cards' ),
|
||||
'url' => [
|
||||
'index'
|
||||
]
|
||||
];
|
||||
$this->params ['breadcrumbs'] [] = [
|
||||
'label' => $model->number,
|
||||
'url' => [
|
||||
'view',
|
||||
'id' => $model->id_card
|
||||
]
|
||||
];
|
||||
$this->params ['breadcrumbs'] [] = Yii::t ( 'common/card', 'Update' );
|
||||
?>
|
||||
<div class="card-update">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
<?php
|
||||
$customer = $model->customer;
|
||||
|
||||
if (isset ( $customer )) {
|
||||
echo DetailView::widget ( [
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
[
|
||||
'label' => 'Vendég',
|
||||
'value' => $model->customer->name
|
||||
]
|
||||
]
|
||||
] );
|
||||
if ( RoleDefinition::isAdmin() ){
|
||||
echo Html::a ( "Vendég törlése a kártyáról!", ['card/clear','id' =>$model->id_card], [
|
||||
'class' => 'btn btn-danger' ,
|
||||
'data-confirm' => "Figyelem, a kártyához tartozó összes bérlet el fog veszni!",
|
||||
'data-method' => 'post',
|
||||
] );
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?=$this->render ( '_form', [ 'model' => $model ] )?>
|
||||
|
||||
</div>
|
||||
|
||||
@ -48,6 +48,6 @@ $items = [
|
||||
|
||||
<?php if ( !empty($title)) {?>
|
||||
<h1><?php echo $title?></h1>
|
||||
<p>Vendég: <?php echo $card->customer->name ?></p>
|
||||
<p>Kártyaszám: <?php echo $card->number ?></p>
|
||||
<p>Vendég: <?php echo $customer->name ?></p>
|
||||
<p>Kártyaszám: <?php echo isset($card) ? $card->number : "Törölt kártya!" ?></p>
|
||||
<?php }?>
|
||||
@ -6,6 +6,7 @@ use yii\helpers\ArrayHelper;
|
||||
use yii\data\ArrayDataProvider;
|
||||
use backend\components\AdminCustomerTabWidget;
|
||||
use common\models\Ticket;
|
||||
use yii\helpers\Url;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\models\TicketSearch */
|
||||
@ -29,7 +30,7 @@ $this->params['breadcrumbs'][] = "Befizetések";
|
||||
<?php echo $this->render('_search_customer', ['model' => $searchModel]); ?>
|
||||
|
||||
|
||||
|
||||
<?php /*?>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Bérlet statisztika</div>
|
||||
<div class="panel-body">
|
||||
@ -80,7 +81,7 @@ $this->params['breadcrumbs'][] = "Befizetések";
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<?php */?>
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'columns' => [
|
||||
@ -133,7 +134,13 @@ $this->params['breadcrumbs'][] = "Befizetések";
|
||||
// 'usage_count',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{view}'
|
||||
'template' => '{view}' ,
|
||||
'urlCreator' => function($action, $model, $key, $index){
|
||||
if ( $action == 'view' ){
|
||||
return Url::toRoute( [ 'ticket/view' , 'id' => $model['ticket_id_ticket' ] ] );
|
||||
}
|
||||
return null;
|
||||
},
|
||||
],
|
||||
],
|
||||
]); ?>
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
-0.0.57
|
||||
- add feature clear card
|
||||
- add changeable payment date to ugiro
|
||||
-0.0.56
|
||||
- inventory to admin
|
||||
- update procurement
|
||||
|
||||
@ -4,7 +4,7 @@ return [
|
||||
'supportEmail' => 'rocho02@gmail.com',
|
||||
'infoEmail' => 'info@rocho-net.hu',
|
||||
'user.passwordResetTokenExpire' => 3600,
|
||||
'version' => 'v0.0.56',
|
||||
'version' => 'v0.0.57',
|
||||
'company' => 'movar',//gyor
|
||||
'company_name' => "Freimann Kft.",
|
||||
'product_visiblity' => 'account',// on reception which products to display. account or global
|
||||
|
||||
Loading…
Reference in New Issue
Block a user