implement ticket_type comment in frontend/backend
This commit is contained in:
parent
8d98f510d1
commit
176d42ea76
@ -9,7 +9,7 @@ use yii\helpers\ArrayHelper;
|
|||||||
/* @var $model common\models\TicketType */
|
/* @var $model common\models\TicketType */
|
||||||
/* @var $form yii\widgets\ActiveForm */
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
?>
|
?>
|
||||||
<?php
|
<?php
|
||||||
function mkTitle($name){
|
function mkTitle($name){
|
||||||
$s = "";
|
$s = "";
|
||||||
$tag = "h4";
|
$tag = "h4";
|
||||||
@ -25,12 +25,15 @@ use yii\helpers\ArrayHelper;
|
|||||||
<div class="ticket-type-form">
|
<div class="ticket-type-form">
|
||||||
|
|
||||||
<?php $form = ActiveForm::begin(); ?>
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
|
|
||||||
<?= mkTitle("Általános")?>
|
<?= mkTitle("Általános")?>
|
||||||
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
|
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'type')->dropDownList(TicketType::ticketTypes() ) ?>
|
<?= $form->field($model, 'type')->dropDownList(TicketType::ticketTypes() ) ?>
|
||||||
|
|
||||||
|
<?= mkTitle("Megjegyzés")?>
|
||||||
|
<?= $form->field($model, 'comment')->textInput()->label("Megjegyzés") ?>
|
||||||
|
|
||||||
<?= mkTitle("Alkalmak")?>
|
<?= mkTitle("Alkalmak")?>
|
||||||
<?= $form->field($model, 'max_usage_count')->textInput() ?>
|
<?= $form->field($model, 'max_usage_count')->textInput() ?>
|
||||||
<?= $form->field($model, 'max_reservation_count')->textInput() ?>
|
<?= $form->field($model, 'max_reservation_count')->textInput() ?>
|
||||||
@ -53,7 +56,7 @@ use yii\helpers\ArrayHelper;
|
|||||||
<?= $form->field($model, 'id_account')->dropDownList($account_options) ?>
|
<?= $form->field($model, 'id_account')->dropDownList($account_options) ?>
|
||||||
|
|
||||||
<?= mkTitle("További beállítások")?>
|
<?= mkTitle("További beállítások")?>
|
||||||
|
|
||||||
<?= $form->field($model, 'status')->checkbox( ['value' => 10, 'label' => Yii::t('common/ticket_type', "Active") ]) ?>
|
<?= $form->field($model, 'status')->checkbox( ['value' => 10, 'label' => Yii::t('common/ticket_type', "Active") ]) ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'flag_student')->checkbox( ['value' => 1, 'label' => Yii::t('common/ticket_type', "Student") ]) ?>
|
<?= $form->field($model, 'flag_student')->checkbox( ['value' => 1, 'label' => Yii::t('common/ticket_type', "Student") ]) ?>
|
||||||
|
|||||||
@ -31,6 +31,10 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'value' => $model->typeHuman
|
'value' => $model->typeHuman
|
||||||
],
|
],
|
||||||
'max_usage_count',
|
'max_usage_count',
|
||||||
|
[
|
||||||
|
'attribute' => 'comment',
|
||||||
|
'label' => "Megjegyzés"
|
||||||
|
],
|
||||||
'max_reservation_count',
|
'max_reservation_count',
|
||||||
[
|
[
|
||||||
'attribute' => 'time_unit_count',
|
'attribute' => 'time_unit_count',
|
||||||
|
|||||||
@ -43,23 +43,23 @@ class TicketType extends BaseFitnessActiveRecord
|
|||||||
CONST TIME_UNIT_MONTH_REFERENCE = 30;
|
CONST TIME_UNIT_MONTH_REFERENCE = 30;
|
||||||
const TYPE_NORMAL = 10;
|
const TYPE_NORMAL = 10;
|
||||||
const TYPE_DEFAULT = self::TYPE_NORMAL;
|
const TYPE_DEFAULT = self::TYPE_NORMAL;
|
||||||
|
|
||||||
const FLAG_STUDENT_OFF = 0;
|
const FLAG_STUDENT_OFF = 0;
|
||||||
const FLAG_STUDENT_ON = 1;
|
const FLAG_STUDENT_ON = 1;
|
||||||
|
|
||||||
const INSTALLMENT_OFF = 0;
|
const INSTALLMENT_OFF = 0;
|
||||||
const INSTALLMENT_ON = 1;
|
const INSTALLMENT_ON = 1;
|
||||||
|
|
||||||
const FLAG_DOOR_ALLOWED_OFF = 0;
|
const FLAG_DOOR_ALLOWED_OFF = 0;
|
||||||
const FLAG_DOOR_ALLOWED_ON = 1;
|
const FLAG_DOOR_ALLOWED_ON = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
public static function tableName() {
|
public static function tableName() {
|
||||||
return 'ticket_type';
|
return 'ticket_type';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @formatter:off
|
* @formatter:off
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
@ -113,13 +113,13 @@ class TicketType extends BaseFitnessActiveRecord
|
|||||||
////////////////
|
////////////////
|
||||||
[['id_account',], 'integer'],
|
[['id_account',], 'integer'],
|
||||||
[['id_account',], 'validateIdAccount'],
|
[['id_account',], 'validateIdAccount'],
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
//INSTALLMENT ENABLED
|
//INSTALLMENT ENABLED
|
||||||
/////////////////////
|
/////////////////////
|
||||||
[['installment_enabled',], 'integer'],
|
[['installment_enabled',], 'integer'],
|
||||||
[['installment_enabled',], 'in', 'range' => [ self::INSTALLMENT_ON, self::INSTALLMENT_OFF ]],
|
[['installment_enabled',], 'in', 'range' => [ self::INSTALLMENT_ON, self::INSTALLMENT_OFF ]],
|
||||||
|
|
||||||
[['installment_money',], 'integer'],
|
[['installment_money',], 'integer'],
|
||||||
[['installment_count',], 'integer'],
|
[['installment_count',], 'integer'],
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ class TicketType extends BaseFitnessActiveRecord
|
|||||||
////////////////
|
////////////////
|
||||||
[['door_allowed',], 'integer'],
|
[['door_allowed',], 'integer'],
|
||||||
[['door_allowed',], 'in', 'range' => [ self::FLAG_DOOR_ALLOWED_OFF, self::FLAG_DOOR_ALLOWED_ON ]],
|
[['door_allowed',], 'in', 'range' => [ self::FLAG_DOOR_ALLOWED_OFF, self::FLAG_DOOR_ALLOWED_ON ]],
|
||||||
|
[['comment'], 'string' ],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,14 +157,14 @@ class TicketType extends BaseFitnessActiveRecord
|
|||||||
'max_reservation_count' => Yii::t('common/ticket_type', 'Max Reservation Count'),
|
'max_reservation_count' => Yii::t('common/ticket_type', 'Max Reservation Count'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @formatter:on
|
* @formatter:on
|
||||||
*/
|
*/
|
||||||
static function statuses() {
|
static function statuses() {
|
||||||
return [
|
return [
|
||||||
self::STATUS_ACTIVE => Yii::t ( 'common/ticket_type', 'Active' ),
|
self::STATUS_ACTIVE => Yii::t ( 'common/ticket_type', 'Active' ),
|
||||||
self::STATUS_DELETED => Yii::t ( 'common/ticket_type', 'Inactive' )
|
self::STATUS_DELETED => Yii::t ( 'common/ticket_type', 'Inactive' )
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
public function getStatusHuman() {
|
public function getStatusHuman() {
|
||||||
@ -176,10 +176,10 @@ class TicketType extends BaseFitnessActiveRecord
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
static function timeUnitTypes() {
|
static function timeUnitTypes() {
|
||||||
return [
|
return [
|
||||||
self::TIME_UNIT_DAY => Yii::t ( 'common/ticket_type', 'Day' ),
|
self::TIME_UNIT_DAY => Yii::t ( 'common/ticket_type', 'Day' ),
|
||||||
self::TIME_UNIT_MONTH => Yii::t ( 'common/ticket_type', 'Month' ),
|
self::TIME_UNIT_MONTH => Yii::t ( 'common/ticket_type', 'Month' ),
|
||||||
self::TIME_UNIT_MONTH_REFERENCE => Yii::t ( 'common/ticket_type', 'Reference month' )
|
self::TIME_UNIT_MONTH_REFERENCE => Yii::t ( 'common/ticket_type', 'Reference month' )
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
public function getTimeUnitHuman() {
|
public function getTimeUnitHuman() {
|
||||||
@ -191,8 +191,8 @@ class TicketType extends BaseFitnessActiveRecord
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
static function ticketTypes() {
|
static function ticketTypes() {
|
||||||
return [
|
return [
|
||||||
self::TYPE_NORMAL => Yii::t ( 'common/ticket_type', 'Normal' )
|
self::TYPE_NORMAL => Yii::t ( 'common/ticket_type', 'Normal' )
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
public function getTypeHuman() {
|
public function getTypeHuman() {
|
||||||
@ -204,14 +204,14 @@ class TicketType extends BaseFitnessActiveRecord
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
public function getAccount() {
|
public function getAccount() {
|
||||||
return $this->hasOne ( Account::className (), [
|
return $this->hasOne ( Account::className (), [
|
||||||
'id_account' => 'id_account'
|
'id_account' => 'id_account'
|
||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
public function getAccountName() {
|
public function getAccountName() {
|
||||||
return $this->account->name;
|
return $this->account->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isStudent(){
|
public function isStudent(){
|
||||||
return $this->flag_student == ( self::FLAG_STUDENT_ON);
|
return $this->flag_student == ( self::FLAG_STUDENT_ON);
|
||||||
}
|
}
|
||||||
@ -223,13 +223,13 @@ class TicketType extends BaseFitnessActiveRecord
|
|||||||
public function isInstallment(){
|
public function isInstallment(){
|
||||||
return $this->installment_enabled == ( self::INSTALLMENT_ON);
|
return $this->installment_enabled == ( self::INSTALLMENT_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function validateIdAccount($attribute){
|
public function validateIdAccount($attribute){
|
||||||
$account = null;
|
$account = null;
|
||||||
if ( !$this->hasErrors("id_account")){
|
if ( !$this->hasErrors("id_account")){
|
||||||
$account = Account::findOne($this->$attribute);
|
$account = Account::findOne($this->$attribute);
|
||||||
|
|
||||||
if ( !isset($account)){
|
if ( !isset($account)){
|
||||||
$this->addError($attribute,Yii::t('common/ticket_type','Invalid account!'));
|
$this->addError($attribute,Yii::t('common/ticket_type','Invalid account!'));
|
||||||
}else{
|
}else{
|
||||||
@ -256,7 +256,7 @@ class TicketType extends BaseFitnessActiveRecord
|
|||||||
*/
|
*/
|
||||||
public static function read($forceIncludeObjectWithId = null, $account = null){
|
public static function read($forceIncludeObjectWithId = null, $account = null){
|
||||||
$ticketTypes = null;
|
$ticketTypes = null;
|
||||||
|
|
||||||
if ( $forceIncludeObjectWithId == null){
|
if ( $forceIncludeObjectWithId == null){
|
||||||
$ticketTypes = TicketType::find()->andWhere(['status' => self::STATUS_ACTIVE ])
|
$ticketTypes = TicketType::find()->andWhere(['status' => self::STATUS_ACTIVE ])
|
||||||
->andWhere([ '<>', 'installment_enabled' , '1']) ->andFilterWhere(['ticket_type.id_account' => $account])->all();
|
->andWhere([ '<>', 'installment_enabled' , '1']) ->andFilterWhere(['ticket_type.id_account' => $account])->all();
|
||||||
@ -264,17 +264,17 @@ class TicketType extends BaseFitnessActiveRecord
|
|||||||
$ticketTypes = TicketType::find()->andWhere( ['or', ['status' => self::STATUS_ACTIVE], ['id_ticket_type' => $forceIncludeObjectWithId ] ])
|
$ticketTypes = TicketType::find()->andWhere( ['or', ['status' => self::STATUS_ACTIVE], ['id_ticket_type' => $forceIncludeObjectWithId ] ])
|
||||||
->andWhere([ '<>', 'installment_enabled' , '1'])->andFilterWhere(['ticket_type.id_account' => $account])->all();
|
->andWhere([ '<>', 'installment_enabled' , '1'])->andFilterWhere(['ticket_type.id_account' => $account])->all();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ticketTypes;
|
return $ticketTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function modelsToArray($models,$default = []){
|
public static function modelsToArray($models,$default = []){
|
||||||
|
|
||||||
if ( $models == null ){
|
if ( $models == null ){
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ArrayHelper::toArray($models, [
|
return ArrayHelper::toArray($models, [
|
||||||
'common\models\TicketType' => [
|
'common\models\TicketType' => [
|
||||||
'name',
|
'name',
|
||||||
@ -287,7 +287,7 @@ class TicketType extends BaseFitnessActiveRecord
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,90 +16,99 @@ use common\components\Helper;
|
|||||||
/* @var $form yii\widgets\ActiveForm */
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$accountOptions = [];
|
$accountOptions = [];
|
||||||
$discountOptions= [];
|
$discountOptions= [];
|
||||||
$ticketTypeOptions= [];
|
$ticketTypeOptions= [];
|
||||||
|
|
||||||
$accountOptions = HtmlHelper::mkAccountOptions($accounts);
|
$accountOptions = HtmlHelper::mkAccountOptions($accounts);
|
||||||
$discountOptions = ['' => ''] + HtmlHelper::mkDiscountOptions($discounts, [ 'emptyOption' => true] );
|
$discountOptions = ['' => ''] + HtmlHelper::mkDiscountOptions($discounts, [ 'emptyOption' => true] );
|
||||||
$ticketTypeOptions = HtmlHelper::mkTicketTypeOptions($ticketTypes);
|
$ticketTypeOptions = HtmlHelper::mkTicketTypeOptions($ticketTypes);
|
||||||
|
$ticketTypeOptions = [];
|
||||||
|
foreach ($ticketTypes as $ticketType){
|
||||||
|
$comment = "";
|
||||||
|
if ( isset($ticketType->comment)){
|
||||||
|
$comment = " (" . $ticketType->comment .")";
|
||||||
|
}
|
||||||
|
$ticketTypeOptions[$ticketType->id_ticket_type] = $ticketType->name . $comment;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// echo "default kassza: " . Account::readDefault();
|
// echo "default kassza: " . Account::readDefault();
|
||||||
// echo " kassza: " . $model->id_account;
|
// echo " kassza: " . $model->id_account;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="row" >
|
<div class="row" >
|
||||||
<div class="col-md-12" >
|
<div class="col-md-12" >
|
||||||
<div class="ticket-form">
|
<div class="ticket-form">
|
||||||
|
|
||||||
<?php $form = ActiveForm::begin([
|
<?php $form = ActiveForm::begin([
|
||||||
'id' => 'ticket_form',
|
'id' => 'ticket_form',
|
||||||
]); ?>
|
]); ?>
|
||||||
|
|
||||||
<?= Html::activeHiddenInput($model, 'cart')?>
|
<?= Html::activeHiddenInput($model, 'cart')?>
|
||||||
|
|
||||||
<?= $form->field($model, 'id_ticket_type')->dropDownList($ticketTypeOptions) ?>
|
<?= $form->field($model, 'id_ticket_type')->dropDownList($ticketTypeOptions) ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'id_account')->dropDownList($accountOptions) ?>
|
<?= $form->field($model, 'id_account')->dropDownList($accountOptions) ?>
|
||||||
|
|
||||||
<?php echo $form->field($model,'payment_method')->dropDownList(Transfer::paymentMethods()) ?>
|
<?php echo $form->field($model,'payment_method')->dropDownList(Transfer::paymentMethods()) ?>
|
||||||
|
|
||||||
<?php echo $form->field($model, 'id_discount')->dropDownList($discountOptions) ?>
|
<?php echo $form->field($model, 'id_discount')->dropDownList($discountOptions) ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'start')->widget(DatePicker::classname(), [
|
<?= $form->field($model, 'start')->widget(DatePicker::classname(), [
|
||||||
'pluginOptions' => [
|
'pluginOptions' => [
|
||||||
'autoclose'=>true,
|
'autoclose'=>true,
|
||||||
'format' => 'yyyy.mm.dd'
|
'format' => 'yyyy.mm.dd'
|
||||||
]
|
]
|
||||||
]) ?>
|
]) ?>
|
||||||
|
|
||||||
|
|
||||||
<?= $form->field($model, 'end')->widget(DatePicker::classname(), [
|
<?= $form->field($model, 'end')->widget(DatePicker::classname(), [
|
||||||
'pluginOptions' => [
|
'pluginOptions' => [
|
||||||
'autoclose'=>true,
|
'autoclose'=>true,
|
||||||
'format' => 'yyyy.mm.dd'
|
'format' => 'yyyy.mm.dd'
|
||||||
]
|
]
|
||||||
]) ?>
|
]) ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'max_usage_count')->input('number') ?>
|
<?= $form->field($model, 'max_usage_count')->input('number') ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ( Helper::isTicketCreatePriceEditable()){
|
if ( Helper::isTicketCreatePriceEditable()){
|
||||||
echo $form->field($model, 'price_brutto')->input('number' );
|
echo $form->field($model, 'price_brutto')->input('number' );
|
||||||
}else{
|
}else{
|
||||||
echo $form->field($model, 'price_brutto')->input('number' ,['readonly' => true] );
|
echo $form->field($model, 'price_brutto')->input('number' ,['readonly' => true] );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?= $form->field($model, 'comment')->textarea(['maxlength' => true]) ?>
|
<?= $form->field($model, 'comment')->textarea(['maxlength' => true]) ?>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class='col-md-4'>
|
<div class='col-md-4'>
|
||||||
<?php echo Html::a(Yii::t("frontend/ticket","Fizetve"),null,['class' => 'btn btn-danger btn-block', 'id' => 'btn_sell'] );?>
|
<?php echo Html::a(Yii::t("frontend/ticket","Fizetve"),null,['class' => 'btn btn-danger btn-block', 'id' => 'btn_sell'] );?>
|
||||||
</div>
|
</div>
|
||||||
<div class='col-md-4'>
|
<div class='col-md-4'>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ( Helper::isUserCartOn()){
|
if ( Helper::isUserCartOn()){
|
||||||
echo Html::a(Yii::t("frontend/ticket","To cart"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_add_to_user_cart'] );
|
echo Html::a(Yii::t("frontend/ticket","To cart"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_add_to_user_cart'] );
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
<div class='col-md-4'>
|
<div class='col-md-4'>
|
||||||
<?php
|
<?php
|
||||||
if ( $receptionForm->isCardWithCustomer() ){
|
if ( $receptionForm->isCardWithCustomer() ){
|
||||||
echo Html::a(Yii::t("frontend/ticket","Write up"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_add_to_customer_cart'] );
|
echo Html::a(Yii::t("frontend/ticket","Write up"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_add_to_customer_cart'] );
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php ActiveForm::end(); ?>
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
Loading…
Reference in New Issue
Block a user