add frontend ticket translations

This commit is contained in:
rocho 2015-10-09 08:12:39 +02:00
parent 11e7c85cf3
commit fda450b801
21 changed files with 227 additions and 57 deletions

View File

@ -43,6 +43,7 @@ return [
'.hgignore',
'.hgkeep',
'/messages',
'node_modules'
],
// 'php' output format is for saving messages to php files.

View File

@ -19,7 +19,7 @@
return [
'Bérlet kártya nem üres vagy hibás kártyaszám' => 'Bérlet kártya nem üres vagy hibás kártyaszám',
'Password' => 'Jelszó',
'Update customer:' => 'Jelszó újra',
'Update customer:' => 'Vendég módosítása:',
'Address' => 'Cím',
'Birthdate' => 'Születésnap',
'Card number' => 'Kártyaszám',

View File

@ -0,0 +1,44 @@
<?php
/**
* Message translations.
*
* This file is automatically generated by 'yii message' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
* Each array element represents the translation (value) of a message (key).
* If the value is empty, the message is considered as not translated.
* Messages that no longer need translation will have their translations
* enclosed between a pair of '@@' marks.
*
* Message string can be used with plural forms format. Check i18n section
* of the guide for details.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Are you sure you want to delete this item?' => 'Biztosan törölni szeretné a bérletet?',
'Comment' => 'Megjegyzés',
'Create' => 'Mentés',
'Create Ticket' => 'Új bérlet',
'Create and add to cart' => 'Mentés és kosárba helyezés',
'Created At' => 'Hozzáadva',
'Delete' => 'Törlés',
'End' => 'Érvényesség vége',
'Id Account' => 'Kassza',
'Id Discount' => 'Kedvezmény',
'Id Ticket' => 'Bérlet',
'Id Ticket Type' => 'Bérlet típus',
'Id User' => 'Felhasználó',
'Max Usage Count' => 'Max alkalmak',
'Price Brutto' => 'Bruttó ár',
'Reset' => '',
'Search' => 'Keresés',
'Start' => 'Érvényesség kezdete',
'Status' => 'Státusz',
'Tickets' => 'Bérletek',
'Update' => 'Módosítás',
'Update {modelClass}: ' => '{modelClass} módosítva: ',
'Updated At' => 'Módosítás',
'Usage Count' => 'Felhasznált alkalmak',
];

View File

@ -0,0 +1,21 @@
<?php
/**
* Message translations.
*
* This file is automatically generated by 'yii message' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
* Each array element represents the translation (value) of a message (key).
* If the value is empty, the message is considered as not translated.
* Messages that no longer need translation will have their translations
* enclosed between a pair of '@@' marks.
*
* Message string can be used with plural forms format. Check i18n section
* of the guide for details.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Search' => 'Keresés',
];

View File

@ -0,0 +1,27 @@
<?php
/**
* Message translations.
*
* This file is automatically generated by 'yii message' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
* Each array element represents the translation (value) of a message (key).
* If the value is empty, the message is considered as not translated.
* Messages that no longer need translation will have their translations
* enclosed between a pair of '@@' marks.
*
* Message string can be used with plural forms format. Check i18n section
* of the guide for details.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Cart' => 'Kosár',
'Invalid discount' => 'Érvénytelen kedvezmény',
'Invalid ticket type' => 'Érvénytelen bérlet típus',
'Invalid transfer' => 'Érvénytelen transfer',
'The requested card does not exist.' => 'A megadott bérlet kártya nem található',
'Ticket added to customer' => 'Bérlet hozzárendelve vendéghez',
'Update ticket' => 'Bérlet módosítása',
];

View File

@ -17,11 +17,12 @@
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'Are you sure you want to delete this item?' => '',
'Are you sure you want to delete this item?' => 'Biztosan törölni szeretné a bérletet?',
'Reset' => '',
'Ticket' => 'Bérlet',
'Create' => 'Mentés',
'Create Transfer' => 'Új pénzmozgás',
'Delete' => 'Törlés',
'Reset' => '',
'Search' => 'Keresés',
'Termékeladás' => 'Termékeladás',
'Transfers' => 'Pénzmozgások',

View File

@ -92,6 +92,7 @@ class Customer extends \yii\db\ActiveRecord
'created_at' => Yii::t('common/customer', 'Created At'),
'updated_at' => Yii::t('common/customer', 'Updated At'),
'customerCardNumber' => Yii::t('common/customer', 'Card number'),
'cardNumber' => Yii::t('common/customer', 'Card number'),
];
}

View File

@ -82,9 +82,12 @@ class Transfer extends \yii\db\ActiveRecord
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 getAccount(){
return $this->hasOne( Account::className(), ["id_account" =>"id_account" ] );
return $this->hasOne( Account::className(), ["id_account" =>"id_account" ] ) ;
}
public function getCurrency(){
@ -206,14 +209,18 @@ class Transfer extends \yii\db\ActiveRecord
'product_name' => function ($transfer) {
$result = "";
if ( $transfer->type == Transfer::TYPE_TICKET ){
$result = $transfer->ticket->type->name;
$result = $transfer->ticket->ticketTypeName;
}else{
$result = $transfer->product->name;
}
return $result;
},
'category' => function ($transfer) {
if ( $transfer->type == Transfer::TYPE_TICKET ){
return Yii::t('frontend/transfer','Ticket');
}else{
return $transfer->product->productCategoryName;
}
},
],
]);
@ -225,8 +232,8 @@ class Transfer extends \yii\db\ActiveRecord
$query = Transfer::find();
// $query->innerJoinWith('userSoldItem');
$query->andWhere(['transfer.id_user' => $user->id ]);
$query->innerJoinWith('userSoldItem');
$query->andWhere(['user_sold_item.id_user' => $user->id ]);
$transfers = $query->all();
return $transfers;

View File

@ -16,9 +16,9 @@ class m151008_065256_alter__table__ticket__add_columns extends Migration
public function down()
{
echo "m151008_065256_alter__table__ticket__add_columns cannot be reverted.\n";
// echo "m151008_065256_alter__table__ticket__add_columns cannot be reverted.\n";
return false;
// return false;
}
/*

View File

@ -22,12 +22,16 @@ class FrontendMenuStructure{
}
protected function isLogged(){
return Yii::$app->user->isGuest;
}
protected function addUserMainMenu(){
protected function addRecepcio(){
if ( $this->isLogged() ){
$this->menuItems[] = ['label' => 'Recepcio', 'url' => ['/customer/reception'] ];
}
}
protected function addLoginMainMenu(){
@ -45,7 +49,7 @@ class FrontendMenuStructure{
public function run(){
$this->addUserMainMenu();
$this->addRecepcio();
$this->addLoginMainMenu();
return $this->menuItems;
}

View File

@ -31,6 +31,19 @@ class CustomerController extends Controller
'delete' => ['post'],
],
],
'access' => [
'class' => \yii\filters\AccessControl::className(),
'only' => ['create', 'update','reception'],
'rules' => [
// allow authenticated users
[
'allow' => true,
'roles' => ['@'],
],
// everything else is denied
],
],
];
}
@ -51,6 +64,7 @@ class CustomerController extends Controller
* Lists all Customer models.
* @return mixed
*/
/*
public function actionIndex()
{
$searchModel = new CustomerSearch();
@ -61,19 +75,20 @@ class CustomerController extends Controller
'dataProvider' => $dataProvider,
]);
}
*/
/**
* Displays a single Customer model.
* @param integer $id
* @return mixed
*/
/*
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
*/
/**
* Creates a new Customer model.
* If creation is successful, the browser will be redirected to the 'view' page.
@ -147,13 +162,14 @@ class CustomerController extends Controller
* @param integer $id
* @return mixed
*/
/*
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
*/
/**
* Finds the Customer model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.

View File

@ -107,7 +107,7 @@ class TicketController extends Controller
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->session->setFlash('success', Yii::t('frontend/ticket', 'Ticket added to customer') );
return $this->redirect(['index', 'number' => $receptionForm->card->number]);
return $this->redirect(['product/sale', 'number' => $receptionForm->card->number]);
} else {
$userTransfers = Transfer::modelsToArray( Transfer::readUserSoldTransfers($user) );

View File

@ -6,12 +6,17 @@ use common\models\TicketType;
use common\models\Account;
use common\models\Discount;
use common\models\Transfer;
use common\models\UserSoldItem;
use yii\base\Object;
class TicketCreate extends Ticket{
public $_currency;
public $_account;
public $_discount;
public $_transfer;
public $cart;
public function rules()
{
@ -51,7 +56,11 @@ class TicketCreate extends Ticket{
/////////////////////
//comment
/////////////////////
[['comment'], 'string', 'max' => 255]
[['comment'], 'string', 'max' => 255],
/////////////////////
//cart
/////////////////////
[['cart'], 'string', 'max' => 10]
];
}
@ -78,10 +87,39 @@ class TicketCreate extends Ticket{
}
public function afterSave($insert, $changedAttributes){
$this->addTransfer();
$this->addToCart();
$transfer = Transfer::createTicketTransfer($this->_account, $this->_discount, null, 1, $this);
}
protected function addTransfer(){
$transfer = Transfer::createTicketTransfer($this->_account, $this->_discount, null, 1, $this);
$transfer->status = Transfer::STATUS_PAID;
if ( isset($this->comment)){
$transfer->comment = $this->comment;
}
$transfer->id_user = \Yii::$app->user->id;
$transfer->save();
$this->_transfer = $transfer;
}
protected function addToCart(){
if ( $this->isAddToCart()){
$item = new UserSoldItem();
$item->id_transfer = $this->_transfer->id_transfer;
$item->id_user = \Yii::$app->user->id;
$item->save(false);
}
}
public function isAddToCart(){
$result = false;
if ( isset( $this->cart ) && $this->cart == 'add' ){
$result = true;
}
return $result;
}
}

View File

@ -33,7 +33,7 @@ if ( isset($customer) ){
<?php echo $customername; ?>
</div>
<div class='col-md-12'>
<?php echo Html::submitButton("search",[ 'class' => 'btn btn-primary']); ?>
<?php echo Html::submitButton( Yii::t('frontend/card', "Search"),[ 'class' => 'btn btn-primary']); ?>
</div>
</div>
<?php ActiveForm::end(); ?>

View File

@ -23,7 +23,7 @@ use kartik\widgets\DatePicker;
<?php echo $form->field($model, 'cardNumber')->widget(CardNumberTypeahead::className(),[]) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'partnerCardNumber')->textInput() ?>
<?php //echo $form->field($model, 'partnerCardNumber')->textInput() ?>
</div>
</div>
@ -40,7 +40,7 @@ use kartik\widgets\DatePicker;
</div>
<?php /*?>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'password_plain')->passwordInput(['maxlength' => true]) ?>
@ -49,7 +49,7 @@ use kartik\widgets\DatePicker;
<?= $form->field($model, 'password_repeat')->passwordInput(['maxlength' => true]) ?>
</div>
</div>
<?php */?>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'sex')->dropDownList(Customer::sexes()) ?>

View File

@ -22,13 +22,13 @@ use yii\base\Widget;
<div class='row'>
<div class='col-md-3'>
<?php //echo $form->field($model, 'cardNumber')->widget(CardNumberTypeahead::className(),[]) ?>
<label><?php echo $model->getAttributeLabel('id_customer_card')?></label>
<label><?php echo $model->getAttributeLabel('cardNumber')?></label>
<div>
<?php echo $model->customerCardNumber ?>
</div>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'partnerCardNumber')->textInput() ?>
<?php //echo $form->field($model, 'partnerCardNumber')->textInput() ?>
</div>
</div>
@ -55,19 +55,6 @@ use yii\base\Widget;
'format' => 'yyyy.mm.dd'
]
]) ?>
<?php
/*echo DatePicker::widget(
[
'name' => 'CustomerUpdate[birthdate]',
'value' => Yii::$app->formatter->asDate($model->birthdate),
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
]
);
*/
?>
</div>
</div>

View File

@ -8,19 +8,13 @@ use frontend\components\ReceptionCardNumberWidget;
/* @var $this yii\web\View */
/* @var $model common\models\Customer */
$this->title = Yii::t('common/customer', 'Create Customer');
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/customer', 'Customers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$customer = $model;
$card = $customer->card;
?>
<div class="customer-create">

View File

@ -35,14 +35,14 @@ AppAsset::register($this);
echo AlertBlock::widget([
'useSessionFlash' => true,
'type' => AlertBlock::TYPE_GROWL,
'delay' => '3000'
'delay' => '1'
]);
$menuStruct = new FrontendMenuStructure();
$items = $menuStruct->run();
NavBar::begin([
'brandLabel' => 'My Company',
'brandLabel' => 'Web Recepció',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',

View File

@ -31,11 +31,13 @@ use kartik\widgets\DatePicker;
<?php $form = ActiveForm::begin(); ?>
<?= Html::activeHiddenInput($model, 'cart')?>
<?= $form->field($model, 'id_ticket_type')->dropDownList($ticketTypeOptions) ?>
<?= $form->field($model, 'id_account')->dropDownList($accountOptions) ?>
<?= $form->field($model, 'id_discount')->dropDownList($discountOptions) ?>
<?php //echo $form->field($model, 'id_discount')->dropDownList($discountOptions) ?>
<?= $form->field($model, 'start')->widget(DatePicker::classname(), [
'pluginOptions' => [
@ -59,7 +61,8 @@ use kartik\widgets\DatePicker;
<?= $form->field($model, 'comment')->textarea(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/ticket', 'Create') : Yii::t('common/ticket', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
<?= Html::submitButton( Yii::t('common/ticket', 'Create') , [ 'onclick' => ' $(\'#ticketcreate-cart\').val(\'\');','class' => 'btn btn-success' ]) ?>
<?= Html::submitButton( Yii::t('common/ticket', 'Create and add to cart') , [ 'onclick' => ' $(\'#ticketcreate-cart\').val(\'add\');', 'class' => 'btn btn-success' ]) ?>
</div>
<?php ActiveForm::end(); ?>

View File

@ -5,25 +5,27 @@ use frontend\components\ReceptionMenuWidget;
use frontend\components\ReceptionCardNumberWidget;
use frontend\assets\TicketSellAsset;
use common\models\TicketType;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model common\models\Ticket */
/* @var $receptionForm frotned\models\ReceptionForm */
$card = $receptionForm->card;
$customer = $receptionForm->customer;
TicketSellAsset::register($this);
$this->title = Yii::t('common/ticket', 'Create Ticket');
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket', 'Tickets'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket', 'Tickets'), 'url' => ['index' , 'number' => $card->number ]];
$this->params['breadcrumbs'][] = $this->title;
$card = $receptionForm->card;
$customer = $receptionForm->customer;
$options = [];
// $options['lookup_product_url'] = Url::toRoute(['product/lookup']);
// $options['clear_list_url'] = Url::toRoute(['product/clear-list']);
$options['clear_cart_url'] = Url::toRoute(['product/clear-list']);
$options['types'] = TicketType::modelsToArray($ticketTypes);
$options['transfer_list'] = $userTransfers;
@ -55,8 +57,9 @@ $this->registerJs ( 'new TicketSell( '. json_encode($options).');' );
]) ?>
</div>
<div class="col-md-6">
<h1><?php echo Yii::t('frontend/tciket', 'Cart')?></h1>
<h1><?php echo Yii::t('frontend/ticket', 'Cart')?></h1>
<?php echo $this->render( "//common/_transfer_list" ) ?>
<?php echo Html::a(Yii::t('frontend/product', "Paid"),null,[ 'id' => 'btn_paid', 'class' => 'btn btn-primary' ]) ?>
</div>
</div>

View File

@ -33,8 +33,10 @@ function TicketSell(o){
max_usage_count: null,
id_account: null,
price: null,
clear_list_url: '',
transfer_list: []
clear_cart_url: '',
cart_paid_message: 'Tételek fizetve',
transfer_list: [],
};
init();
@ -44,6 +46,7 @@ function TicketSell(o){
addBehaviourTypeChangedListener();
useDefaults();
createUserSoldItemsTable();
addBehaviourBtnCartPaid();
}
function useDefaults(){
@ -59,10 +62,30 @@ function TicketSell(o){
});
}
function refreshSoldUseritems(){
function refreshCart(){
$('.transfer-list-container').transferList('option','transfers' , app.defaults.sold_items );
}
function addBehaviourBtnCartPaid( ){
$('#btn_paid').on('click',function(){
$.ajax({
url: app.defaults.clear_cart_url,
type: 'post',
data: {},
success: function (response) {
if ( response.code == 'success'){
app.defaults.sold_items= response.transfers;
refreshCart();
$.notify(app.defaults.cart_paid_message, { 'type' : 'success' });
}
}
}
);
});
}
function addBehaviourTypeChangedListener(){
$(app.defaults.selector_type).change(change);
}