add frontend ticket translations

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

View File

@@ -22,11 +22,15 @@ class FrontendMenuStructure{
}
protected function isLogged(){
return Yii::$app->user->isGuest;
}
protected function addUserMainMenu(){
$this->menuItems[] = ['label' => 'Recepcio', 'url' => ['/customer/reception'] ];
protected function addRecepcio(){
if ( $this->isLogged() ){
$this->menuItems[] = ['label' => 'Recepcio', 'url' => ['/customer/reception'] ];
}
}
@@ -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();
}
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);
}