add change card, add customer tab

This commit is contained in:
Roland Schneider 2016-01-25 23:09:43 +01:00
parent 8d29f47d49
commit 9fb349ee64
19 changed files with 241 additions and 38 deletions

View File

@ -5,9 +5,7 @@ use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Customer */
$this->title = Yii::t('common/customer', 'Update {modelClass}: ', [
'modelClass' => 'Customer',
]) . ' ' . $model->name;
$this->title = Yii::t('common/customer', 'Módosítás: ' ) . ' ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/customer', 'Customers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_customer]];
$this->params['breadcrumbs'][] = Yii::t('common/customer', 'Update');

View File

@ -1,3 +1,6 @@
-0.0.28
- Add change customer card to reception customer update
- Add customer tab to reception
-0.0.27
- Add contract (szerződés )
- Add door_log ( mozgások )

View File

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

View File

@ -116,8 +116,11 @@ class Card extends \common\models\BaseFitnessActiveRecord
public static function readCard($number,$free = null){
$card = null;
$query = Card::find()
->leftJoin(Customer::tableName(), 'card.id_card = customer.id_customer_card ' )
->andWhere(['number'=>$number ]);
->leftJoin(Customer::tableName(), 'card.id_card = customer.id_customer_card ' );
// ->andWhere(['number'=>$number ]);
Card::addCardNumberCondition($query, $number);
if ( isset($free) ){
if ( $free == true){
@ -149,4 +152,12 @@ class Card extends \common\models\BaseFitnessActiveRecord
return $name;
}
public static function addCardNumberCondition($query,$number, $field_number = "card.number",$field_rfid_key = "card.rfid_key"){
$query->andWhere(['or',
['and',[ 'in',$field_number , [$number]],"trim(coalesce(card.number, '')) <>'' " ],
['and', ['in',$field_rfid_key ,[ $number ] ],"trim(coalesce(card.rfid_key, '')) <>'' "],
]);
}
}

View File

@ -62,11 +62,34 @@ class CardSearch extends 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]);
// $query->orderBy(['customer.name' => SORT_ASC]);
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' =>[
'attributes' => [
'card_number' => [
'asc' => ['card.number' => SORT_ASC ],
'desc' => ['card.number' => SORT_DESC],
],
'customer_name' => [
'asc' => ['customer.name' => SORT_ASC ],
'desc' => ['customer.name' => SORT_DESC],
],
'customer_phone' => [
'asc' => ['customer.phone' => SORT_ASC ],
'desc' => ['customer.phone' => SORT_DESC],
],
'customer_email' => [
'asc' => ['customer.email' => SORT_ASC ],
'desc' => ['customer.email' => SORT_DESC],
],
],
'defaultOrder' =>[
'customer_name' => SORT_ASC,
]
]
]);

View File

@ -0,0 +1,26 @@
<?php
namespace frontend\components;
use yii\base\Widget;
class CustomerTabWidget extends Widget{
public $card;
public $title;
public $viewFile = '//common/_customer_tab';
public function init(){
parent::init();
}
public function run(){
echo $this->render($this->viewFile,[ 'card' => $this->card ,'title' => $this->title ]);
}
}

View File

@ -168,7 +168,12 @@ class CustomerController extends Controller
\Yii::$app->session->setFlash( 'success','Vendég módosításai elmentve' );
return $this->redirect(['update', 'number' => $card->number]);
$cardNumber = $card->number;
if ( isset( $model->replacementCard ) ){
$cardNumber = $model->replacementCard->number;
}
return $this->redirect(['update', 'number' => $cardNumber ]);
} else {

View File

@ -5,6 +5,7 @@ namespace frontend\models;
use Yii;
use common\models\Customer;
use common\models\Card;
use common\components\Helper;
/**
* This is the model class for table "customer".
@ -57,6 +58,7 @@ class CustomerCreate extends \common\models\Customer
return [
[['cardNumber'], 'required' ],
[['cardNumber'], 'string', 'max' => 10],
[['cardNumber'], 'filter', 'filter' => function($value){return Helper::fixAsciiChars($value);}],
[['cardNumber'], 'validateCustomerCard' ],
[['partnerCardNumber'], 'string', 'max' => 10],

View File

@ -4,6 +4,9 @@ namespace frontend\models;
use Yii;
use common\models\Customer;
use common\models\Card;
use common\components\Helper;
use common\models\Ticket;
/**
* This is the model class for table "customer".
@ -40,6 +43,12 @@ class CustomerUpdate extends \common\models\Customer
public $password_plain;
public $password_repeat;
public $replacementCardNumber;
public $replacementCard;
public $originalCard;
/**
* @inheritdoc
*/
@ -59,7 +68,9 @@ class CustomerUpdate extends \common\models\Customer
// [['cardNumber'], 'validateCustomerCard' ],
[['partnerCardNumber'], 'string', 'max' => 10],
[['partnerCardNumber'], 'validatePartnerCard' ],
// [['partnerCardNumber'], 'validatePartnerCard' ],
[['replacementCardNumber'], 'filter', 'filter' => function($value){return Helper::fixAsciiChars($value);}],
[['replacementCardNumber'], 'validateReplacementCard' ],
[['name'], 'required' ],
[['name'], 'string', 'max' => 128],
@ -115,6 +126,43 @@ class CustomerUpdate extends \common\models\Customer
public function validatePartnerCard($a,$p){
// Customer::find()->andWhere( [$this->cardNumber )
}
public function validateReplacementCard($a,$p){
$query = Card::find();
Card::addCardNumberCondition($query, $this->replacementCardNumber);
$rcard = $query->one();
if ( !isset($rcard) ){
\Yii::info("csere kártya nem található");
$this->addError($a,"Csere kártya nem található");
return;
}
\Yii::info("csere kártya megtalálva");
$customer = $rcard->customer;
if ( isset($customer) ){
\Yii::info("A csere kártyát már valaki használja!");
$this->addError($a ,"A csere kártya már használatban van");
return;
}
\Yii::info("A csere kártyát megfelel!");
$this->replacementCard = $rcard;
}
public function beforeSave($insert){
parent::beforeSave($insert);
if ( isset($this->replacementCard ) ){
$this->originalCard = $this->card;
$this->id_customer_card = $this->replacementCard->id_card;
}
return true;
}
public function afterSave($insert, $changedAttributes){
if ( isset($this->replacementCard)){
Ticket::updateAll( ['id_card' => $this->replacementCard->id_card ], ['id_card' => $this->originalCard->id_card] );
}
}
}

View File

@ -0,0 +1,51 @@
<?php
use yii\helpers\Url;
?>
<?php
$route = \Yii::$app->controller->id .'/'. \Yii::$app->controller->action->id;
$items = [
[ 'Recepció', ['customer/reception', 'number' => $card->number ]],
[ 'Termék eladás', ['product/sale', 'number' => $card->number ]],
[ 'Adatlap', ['customer/update', 'number' => $card->number ]],
[ 'Befizetések', ['ticket/index', 'number' => $card->number] ],
[ 'Kulcsok', ['key/index', 'id_card' => $card->id_card] ],
[ 'Szerződések', ['contract/index', 'id_card' => $card->id_card ]],
];
?>
<ul class="nav nav-tabs">
<?php foreach ($items as $item){?>
<?php
if ( empty($title)){
if ( $item[1][0] == $route) {
$title = $item[0];
}
}
?>
<li role="presentation" class="<?php echo $item[1][0] == $route ? 'active' : '' ?>"><a href="<?php echo Url::toRoute($item[1])?>"><?php echo $item[0] ?></a></li>
<?php }?>
</ul>
<?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>
<?php }?>

View File

@ -3,6 +3,7 @@
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
use frontend\components\CustomerTabWidget;
/* @var $this yii\web\View */
/* @var $searchModel frontend\models\ContractSearch */
@ -11,9 +12,11 @@ use yii\helpers\Url;
$this->title = $searchModel->customer->name . " szerződései";
$this->params['breadcrumbs'][] = $this->title;
?>
<?php echo CustomerTabWidget::widget(['card' => $searchModel->card])?>
<div class="contract-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>

View File

@ -3,6 +3,7 @@
use yii\helpers\Html;
use yii\widgets\DetailView;
use common\models\TicketInstallmentRequest;
use frontend\components\CustomerTabWidget;
/* @var $this yii\web\View */
/* @var $model common\models\Contract */
@ -11,11 +12,10 @@ $this->title = "Szerződés részletek" ;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/contract', 'Szerződések'), 'url' => ['index', 'id_card' => $card->id_card]];
$this->params['breadcrumbs'][] = $this->title;
?>
<?php echo CustomerTabWidget::widget(['card' => $model->customer->card,'title' => 'Szerződés részletek'])?>
<div class="contract-view">
<h1><?= Html::encode($this->title) ?></h1>
<?= DetailView::widget([
'model' => $model,
'attributes' => [

View File

@ -18,7 +18,7 @@ $this->registerJs ( 'new Customer( '. json_encode($options).');' );
}
</style>
<div class="row">
<div class="row" style='margin-top: 12px;' >
<div class="col-md-4">
<div id="my_camera" class='photo pull-left' style="width: 160px; height: 120px; margin-right: 12px;"></div>
<div id="my_result" class='photo pull-left' style="width: 160px; height: 120px;"></div>
@ -26,4 +26,4 @@ $this->registerJs ( 'new Customer( '. json_encode($options).');' );
<div class="col-md-4">
</div>
</div>
<a id="snap" class="btn btn-primary">Fénykép</a>
<a id="snap" class="btn btn-primary" style="margin-top: 6px;" >Fénykép</a>

View File

@ -19,6 +19,7 @@ use yii\base\Widget;
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'photo_data')->hiddenInput()->label(false) ?>
<div class='row'>
<div class='col-md-3'>
<?php //echo $form->field($model, 'cardNumber')->widget(CardNumberTypeahead::className(),[]) ?>
@ -28,7 +29,7 @@ use yii\base\Widget;
</div>
</div>
<div class='col-md-3'>
<?php //echo $form->field($model, 'partnerCardNumber')->textInput() ?>
<?php echo $form->field($model, 'replacementCardNumber')->textInput()->label("Csere új kártyára") ?>
</div>
</div>

View File

@ -1,45 +1,41 @@
<?php
use yii\helpers\Html;
use frontend\components\ReceptionMenuWidget;
use frontend\components\ReceptionCardNumberWidget;
use frontend\components\ReceptionWidget;
use common\assets\WebcamjsAsset;
use frontend\assets\CustomerAsset;
use common\components\Image;
use yii\helpers\Url;
use frontend\components\CustomerTabWidget;
/* @var $this yii\web\View */
/* @var $model common\models\Customer */
$this->title = Yii::t('common/customer', 'Update customer:' ) . ' ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/customer', 'Customers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_customer]];
$this->params['breadcrumbs'][] = Yii::t('common/customer', 'Update');
$customer = $model;
$card = $customer->card;
$this->title = Yii::t('common/customer', 'Update customer:' ) . ' ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => "Recepció", 'url' => ['customer/reception' ,'number' => $card->number]];
$this->params['breadcrumbs'][] = Yii::t('common/customer', 'Update');
?>
<div class="customer-update">
<?php // echo ReceptionWidget::widget( ['form' => $receptionForm, 'route' => ['customer/reception'] ] )?>
<?php echo ReceptionWidget::widget( ['form' => $receptionForm, 'route' => ['customer/reception'] ] )?>
<?php echo CustomerTabWidget::widget(['card' => $card])?>
<?php echo $this->render('_camera',['model' => $model]); ?>
<h1><?= Html::encode($this->title) ?></h1>
<div style='margin-top: 12px'>
<?php if ( $model->image1 ){
echo Html::img( Url::base( ) . Image::thumb( $model->image1->path,160,120 ));
}
?>
</div>
<?= $this->render('_form_update', [
'model' => $model,
]) ?>

View File

@ -3,6 +3,7 @@
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
use frontend\components\CustomerTabWidget;
/* @var $this yii\web\View */
/* @var $searchModel frontend\models\KeySearch */
@ -11,13 +12,13 @@ use yii\helpers\Url;
$this->title = Yii::t('frontend/key', 'Vendéghez rendelt kulcsok');
$this->params['breadcrumbs'][] = $this->title;
?>
<?php echo CustomerTabWidget::widget(['card' => $searchModel->card])?>
<div class="key-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<h2>Vendég: <?php echo $searchModel->card->customer->name ;?></h2>
<h2>Kártyaszám: <?php echo $searchModel->card->number ;?></h2>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [

View File

@ -7,6 +7,7 @@ use frontend\components\ReceptionCardNumberWidget;
use frontend\components\ReceptionWidget;
use yii\base\Widget;
use common\models\Ticket;
use frontend\components\CustomerTabWidget;
/* @var $this yii\web\View */
/* @var $searchModel frontend\models\TicketSearch */
@ -22,10 +23,11 @@ $this->params['breadcrumbs'][] = $this->title;
<div class="ticket-index">
<?php echo ReceptionWidget::widget( ['form' => $receptionForm, 'route' => ['customer/reception'] ] )?>
<?php // echo ReceptionWidget::widget( ['form' => $receptionForm, 'route' => ['customer/reception'] ] )?>
<h1><?= Html::encode($this->title) ?></h1>
<?php echo CustomerTabWidget::widget(['card' => $receptionForm->card])?>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>

View File

@ -1,18 +1,19 @@
<?php
use yii\helpers\Html;
use frontend\components\CustomerTabWidget;
/* @var $this yii\web\View */
/* @var $model common\models\Ticket */
$this->title = "Bérlet módosítása:" . ' ' . $model->id_ticket;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket', 'Tickets'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id_ticket, 'url' => ['view', 'id' => $model->id_ticket]];
$this->params['breadcrumbs'][] = ['label' =>'Befizetések', 'url' => ['index', 'number' =>$model->card->number]];
$this->params['breadcrumbs'][] = Yii::t('common/ticket', 'Update');
?>
<?php echo CustomerTabWidget::widget(['card' => $model->card,'title' => 'Bérlet módosítása'])?>
<p><?php echo "Bérlet azonosító: " . $model->id_ticket ?></p>
<div class="ticket-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form_update', [
'model' => $model,

View File

@ -27,6 +27,38 @@ function Customer(o){
$("#snap").click(snap);
preventSubmit( '#customerupdate-replacementcardnumber' );
preventSubmit( '#customercreate-cardnumber' );
}
function preventSubmit($selector){
$($selector).keydown(function(e) {
if(e.keyCode == 13) { // enter key was pressed
e.preventDefault();
// e.stopImmediatePropagation();
// e.stopPropagation();
// run own code
return false; // prevent execution of rest of the script + event propagation / event bubbling + prevent default behaviour
}
});
$($selector).keyup(function(e) {
if(e.keyCode == 13) { // enter key was pressed
e.preventDefault();
// e.stopImmediatePropagation();
// e.stopPropagation();
// run own code
return false; // prevent execution of rest of the script + event propagation / event bubbling + prevent default behaviour
}
});
$($selector).keypress(function(e) {
if(e.keyCode == 13) { // enter key was pressed
e.preventDefault();
// e.stopImmediatePropagation();
// e.stopPropagation();
// run own code
return false; // prevent execution of rest of the script + event propagation / event bubbling + prevent default behaviour
}
});
}
function snap(){