add feature clear card

This commit is contained in:
Roland Schneider 2016-04-03 10:44:12 +02:00
parent ee4ae54e6f
commit 5ff974c717
12 changed files with 108 additions and 56 deletions

View File

@ -14,6 +14,7 @@ use yii\web\UploadedFile;
use common\components\Helper; use common\components\Helper;
use backend\models\CardInsertForm; use backend\models\CardInsertForm;
use common\models\Ticket; use common\models\Ticket;
use frontend\components\HtmlHelper;
/** /**
* CardController implements the CRUD actions for Card model. * CardController implements the CRUD actions for Card model.
@ -25,6 +26,16 @@ class CardController extends \backend\controllers\BackendController {
'class' => \yii\filters\AccessControl::className (), 'class' => \yii\filters\AccessControl::className (),
'rules' => [ 'rules' => [
// allow authenticated users // allow authenticated users
[
'actions' => [
'clear',
],
'allow' => true,
'roles' => [
'admin'
]
],
[ [
'actions' => [ 'actions' => [
'create', 'create',
@ -40,7 +51,8 @@ class CardController extends \backend\controllers\BackendController {
'roles' => [ 'roles' => [
'@' '@'
] ]
] ] ,
] ]
// everything else is denied // 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. * Lists all Card models.
* *

View File

@ -33,7 +33,7 @@ class KeyController extends Controller {
'rules' => [ 'rules' => [
// allow authenticated users // allow authenticated users
[ [
'actions' => ['create','index','view','update','import'], 'actions' => ['create','index','view','update','import','index-customer'],
'allow' => true, 'allow' => true,
'roles' => ['admin','employee','reception'], 'roles' => ['admin','employee','reception'],
], ],

View File

@ -137,7 +137,7 @@ class TicketController extends \backend\controllers\BackendController {
$searchModel = new TicketSearchCustomer(['customer' => $customer]); $searchModel = new TicketSearchCustomer(['customer' => $customer]);
$searchModel->id_card = $customer->id_customer_card; $searchModel->id_card = $customer->id_customer_card;
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams ); $dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
$searchModel->searchTotals (); //$searchModel->searchTotals ();
$searchModel->users = User::read (); $searchModel->users = User::read ();
$searchModel->accounts = Account::read (); $searchModel->accounts = Account::read ();

View File

@ -63,7 +63,6 @@ class TransferController extends \backend\controllers\BackendController
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
echo "output:".$searchModel->output;
if ( $searchModel->output =='pdf'){ if ( $searchModel->output =='pdf'){
$this->downloadPaymentLater($dataProvider); $this->downloadPaymentLater($dataProvider);

View File

@ -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); $this->load($params);
@ -89,18 +74,7 @@ class CustomerSearch extends Customer
$query->leftJoin(Card::tableName(), " customer.id_customer_card = card.id_card" ); $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]) $query->andFilterWhere(['like', 'customer.name', $this->name])
->andFilterWhere(['like', 'customer.email', $this->email]) ->andFilterWhere(['like', 'customer.email', $this->email])

View File

@ -11,9 +11,11 @@ use yii\db\ActiveRecord;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use yii\db\Query; use yii\db\Query;
use common\models\Transfer; use common\models\Transfer;
use yii\helpers\VarDumper;
/** /**
* TicketSearch represents the model behind the search form about `common\models\Ticket`. * TicketSearch represents the model behind the search form about `common\models\Ticket`.
* @property commom\models\Customer $customer
*/ */
class TicketSearchCustomer extends Ticket class TicketSearchCustomer extends Ticket
{ {
@ -32,7 +34,9 @@ class TicketSearchCustomer extends Ticket
public $statistics; public $statistics;
public $statisticsTotal; public $statisticsTotal;
public $customer; public $customer; //constructor param
/** /**
@ -41,7 +45,7 @@ class TicketSearchCustomer extends Ticket
public function rules() public function rules()
{ {
return [ 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' ], [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
[[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], [[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
[['valid_in_interval','created_in_interval','expire_in_interval'],'boolean'] , [['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->innerJoin('user', 'user.id = transfer.id_user');
$query->leftJoin('user as paid_by', 'paid_by.id = transfer.paid_by'); $query->leftJoin('user as paid_by', 'paid_by.id = transfer.paid_by');
$query->leftJoin('card', 'ticket.id_card = card.id_card'); $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'); Helper::queryAccountConstraint($query, 'ticket.id_account');
@ -177,11 +182,12 @@ class TicketSearchCustomer extends Ticket
if (!$this->validate()) { if (!$this->validate()) {
$query->where('0=1');
return $query; return $query;
} }
$query->andWhere( ['transfer.id_customer' => $this->customer->id_customer ]);
$query->andFilterWhere([ $query->andFilterWhere([
'ticket.id_user' => $this->id_user, 'ticket.id_user' => $this->id_user,
'ticket.id_ticket_type' => $this->id_ticket_type, 'ticket.id_ticket_type' => $this->id_ticket_type,
@ -191,7 +197,7 @@ class TicketSearchCustomer extends Ticket
'ticket.status' => $this->status '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) ) $all = (!($this->valid_in_interval) && !($this->expire_in_interval) && !($this->created_in_interval) )
@ -230,7 +236,8 @@ class TicketSearchCustomer extends Ticket
public function searchTotals(){ 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->statistics = $query->all();
$this->statisticsTotal =[ $this->statisticsTotal =[

View File

@ -23,7 +23,7 @@ use common\models\Card;
<div class="form-group"> <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($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> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>

View File

@ -1,23 +1,56 @@
<?php <?php
use yii\helpers\Html; 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 $this yii\web\View */
/* @var $model common\models\Card */ /* @var $model common\models\Card */
$this->title = Yii::t('common/card', 'Update {modelClass}: ', [ $this->title = Yii::t ( 'common/card', 'Bérletkártya módosítása' );
'modelClass' => 'Card', $this->params ['breadcrumbs'] [] = [
]) . ' ' . $model->id_card; 'label' => Yii::t ( 'common/card', 'Cards' ),
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/card', 'Cards'), 'url' => ['index']]; 'url' => [
$this->params['breadcrumbs'][] = ['label' => $model->number, 'url' => ['view', 'id' => $model->id_card]]; 'index'
$this->params['breadcrumbs'][] = Yii::t('common/card', 'Update'); ]
];
$this->params ['breadcrumbs'] [] = [
'label' => $model->number,
'url' => [
'view',
'id' => $model->id_card
]
];
$this->params ['breadcrumbs'] [] = Yii::t ( 'common/card', 'Update' );
?> ?>
<div class="card-update"> <div class="card-update">
<h1><?= Html::encode($this->title) ?></h1> <h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [ <?php
$customer = $model->customer;
if (isset ( $customer )) {
echo DetailView::widget ( [
'model' => $model, '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> </div>

View File

@ -48,6 +48,6 @@ $items = [
<?php if ( !empty($title)) {?> <?php if ( !empty($title)) {?>
<h1><?php echo $title?></h1> <h1><?php echo $title?></h1>
<p>Vendég: <?php echo $card->customer->name ?></p> <p>Vendég: <?php echo $customer->name ?></p>
<p>Kártyaszám: <?php echo $card->number ?></p> <p>Kártyaszám: <?php echo isset($card) ? $card->number : "Törölt kártya!" ?></p>
<?php }?> <?php }?>

View File

@ -6,6 +6,7 @@ use yii\helpers\ArrayHelper;
use yii\data\ArrayDataProvider; use yii\data\ArrayDataProvider;
use backend\components\AdminCustomerTabWidget; use backend\components\AdminCustomerTabWidget;
use common\models\Ticket; use common\models\Ticket;
use yii\helpers\Url;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $searchModel backend\models\TicketSearch */ /* @var $searchModel backend\models\TicketSearch */
@ -29,7 +30,7 @@ $this->params['breadcrumbs'][] = "Befizetések";
<?php echo $this->render('_search_customer', ['model' => $searchModel]); ?> <?php echo $this->render('_search_customer', ['model' => $searchModel]); ?>
<?php /*?>
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading">Bérlet statisztika</div> <div class="panel-heading">Bérlet statisztika</div>
<div class="panel-body"> <div class="panel-body">
@ -80,7 +81,7 @@ $this->params['breadcrumbs'][] = "Befizetések";
</div> </div>
<?php */?>
<?= GridView::widget([ <?= GridView::widget([
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'columns' => [ 'columns' => [
@ -133,7 +134,13 @@ $this->params['breadcrumbs'][] = "Befizetések";
// 'usage_count', // 'usage_count',
['class' => 'yii\grid\ActionColumn', ['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;
},
], ],
], ],
]); ?> ]); ?>

View File

@ -1,3 +1,6 @@
-0.0.57
- add feature clear card
- add changeable payment date to ugiro
-0.0.56 -0.0.56
- inventory to admin - inventory to admin
- update procurement - update procurement

View File

@ -4,7 +4,7 @@ return [
'supportEmail' => 'rocho02@gmail.com', 'supportEmail' => 'rocho02@gmail.com',
'infoEmail' => 'info@rocho-net.hu', 'infoEmail' => 'info@rocho-net.hu',
'user.passwordResetTokenExpire' => 3600, 'user.passwordResetTokenExpire' => 3600,
'version' => 'v0.0.56', 'version' => 'v0.0.57',
'company' => 'movar',//gyor 'company' => 'movar',//gyor
'company_name' => "Freimann Kft.", 'company_name' => "Freimann Kft.",
'product_visiblity' => 'account',// on reception which products to display. account or global 'product_visiblity' => 'account',// on reception which products to display. account or global