add changes to create ticket
This commit is contained in:
parent
2e906de8c2
commit
c3ae414bba
2
.gitignore
vendored
2
.gitignore
vendored
@ -28,3 +28,5 @@ composer.phar
|
|||||||
phpunit.phar
|
phpunit.phar
|
||||||
# local phpunit config
|
# local phpunit config
|
||||||
/phpunit.xml
|
/phpunit.xml
|
||||||
|
|
||||||
|
/node_modules
|
||||||
|
|||||||
@ -8,6 +8,9 @@ use backend\models\TicketSearch;
|
|||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
use yii\filters\VerbFilter;
|
use yii\filters\VerbFilter;
|
||||||
|
use common\models\Discount;
|
||||||
|
use common\models\TicketType;
|
||||||
|
use common\models\Account;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TicketController implements the CRUD actions for Ticket model.
|
* TicketController implements the CRUD actions for Ticket model.
|
||||||
@ -61,12 +64,20 @@ class TicketController extends Controller
|
|||||||
public function actionCreate()
|
public function actionCreate()
|
||||||
{
|
{
|
||||||
$model = new Ticket();
|
$model = new Ticket();
|
||||||
|
|
||||||
|
$discounts = Discount::read();
|
||||||
|
$ticketTypes = TicketType::read();
|
||||||
|
$accounts = Account::readAccounts();
|
||||||
|
|
||||||
|
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||||
return $this->redirect(['view', 'id' => $model->id_ticket]);
|
return $this->redirect(['view', 'id' => $model->id_ticket]);
|
||||||
} else {
|
} else {
|
||||||
return $this->render('create', [
|
return $this->render('create', [
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
|
'discounts' => $discounts,
|
||||||
|
'ticketTypes' => $ticketTypes,
|
||||||
|
'accounts' => $accounts,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
16
common/assets/MomentAsset.php
Normal file
16
common/assets/MomentAsset.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
namespace common\assets;
|
||||||
|
|
||||||
|
use yii\web\AssetBundle;
|
||||||
|
|
||||||
|
class MomentAsset extends AssetBundle
|
||||||
|
{
|
||||||
|
public $sourcePath = '@bower';
|
||||||
|
|
||||||
|
public $js = [
|
||||||
|
'moment/min/moment.min.js'
|
||||||
|
];
|
||||||
|
|
||||||
|
public $depends = [
|
||||||
|
];
|
||||||
|
}
|
||||||
@ -22,8 +22,11 @@ use Yii;
|
|||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
*/
|
*/
|
||||||
class Ticket extends \yii\db\ActiveRecord
|
class Ticket extends \common\models\BaseFitnessActiveRecord
|
||||||
{
|
{
|
||||||
|
const STATUS_DELETED = 0;
|
||||||
|
const STATUS_ACTIVE = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
namespace common\models;
|
namespace common\models;
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the model class for table "ticket_type".
|
* This is the model class for table "ticket_type".
|
||||||
@ -193,5 +194,42 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $param int $forceIncludeAccount id account, that should be included in list, even if it is inactive
|
||||||
|
* */
|
||||||
|
public static function read($forceIncludeObjectWithId = null){
|
||||||
|
$ticketTypes = null;
|
||||||
|
|
||||||
|
if ( $forceIncludeObjectWithId == null){
|
||||||
|
$ticketTypes = TicketType::find()->andWhere(['status' => self::STATUS_ACTIVE])->all();
|
||||||
|
}else{
|
||||||
|
$ticketTypes = TicketType::find()->andWhere( ['or', ['status' => self::STATUS_ACTIVE], ['id_ticket_type' => $forceIncludeObjectWithId ] ])->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ticketTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function modelsToArray($models,$default = []){
|
||||||
|
|
||||||
|
if ( $models == null ){
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ArrayHelper::toArray($models, [
|
||||||
|
'common\models\TicketType' => [
|
||||||
|
'name',
|
||||||
|
'id_ticket_type',
|
||||||
|
'max_usage_count',
|
||||||
|
'time_unit_type',
|
||||||
|
'time_unit_count',
|
||||||
|
'id_account',
|
||||||
|
'price_brutto',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,8 @@
|
|||||||
"kartik-v/yii2-widgets": "^3.4",
|
"kartik-v/yii2-widgets": "^3.4",
|
||||||
"kartik-v/yii2-widget-typeahead": "*",
|
"kartik-v/yii2-widget-typeahead": "*",
|
||||||
"bower-asset/remarkable-bootstrap-notify": "^3.1",
|
"bower-asset/remarkable-bootstrap-notify": "^3.1",
|
||||||
"yiisoft/yii2-jui": "^2.0"
|
"yiisoft/yii2-jui": "^2.0",
|
||||||
|
"bower-asset/moment": "^2.10"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"yiisoft/yii2-codeception": "*",
|
"yiisoft/yii2-codeception": "*",
|
||||||
|
|||||||
39
composer.lock
generated
39
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "7bff75eba2c88cda67ff49b95bda9644",
|
"hash": "ade53c29b13f5eaa8367e21defe51905",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "bower-asset/bootstrap",
|
"name": "bower-asset/bootstrap",
|
||||||
@ -176,6 +176,43 @@
|
|||||||
"plugins"
|
"plugins"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "bower-asset/moment",
|
||||||
|
"version": "2.10.6",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/moment/moment.git",
|
||||||
|
"reference": "f3fbef9d9875bbff340b527dbe3f1c447a942f69"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/moment/moment/zipball/f3fbef9d9875bbff340b527dbe3f1c447a942f69",
|
||||||
|
"reference": "f3fbef9d9875bbff340b527dbe3f1c447a942f69",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"type": "bower-asset-library",
|
||||||
|
"extra": {
|
||||||
|
"bower-asset-main": "moment.js",
|
||||||
|
"bower-asset-ignore": [
|
||||||
|
"**/.*",
|
||||||
|
"benchmarks",
|
||||||
|
"bower_components",
|
||||||
|
"meteor",
|
||||||
|
"node_modules",
|
||||||
|
"scripts",
|
||||||
|
"tasks",
|
||||||
|
"test",
|
||||||
|
"component.json",
|
||||||
|
"composer.json",
|
||||||
|
"CONTRIBUTING.md",
|
||||||
|
"ender.js",
|
||||||
|
"Gruntfile.js",
|
||||||
|
"Moment.js.nuspec",
|
||||||
|
"package.js",
|
||||||
|
"package.json"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "bower-asset/punycode",
|
"name": "bower-asset/punycode",
|
||||||
"version": "v1.3.2",
|
"version": "v1.3.2",
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m151008_065256_alter__table__ticket__add_columns extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m151008_065256_alter__table__ticket__add_columns cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
31
frontend/assets/TicketSellAsset.php
Normal file
31
frontend/assets/TicketSellAsset.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @link http://www.yiiframework.com/
|
||||||
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||||
|
* @license http://www.yiiframework.com/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace frontend\assets;
|
||||||
|
|
||||||
|
use yii\web\AssetBundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
class TicketSellAsset extends AssetBundle
|
||||||
|
{
|
||||||
|
public $basePath = '@webroot';
|
||||||
|
public $baseUrl = '@web';
|
||||||
|
public $css = [
|
||||||
|
];
|
||||||
|
public $js = [
|
||||||
|
'js/transferlist.js',
|
||||||
|
'js/ticket.sell.js',
|
||||||
|
];
|
||||||
|
public $depends = [
|
||||||
|
'frontend\assets\AppAsset',
|
||||||
|
'common\assets\MomentAsset',
|
||||||
|
'yii\jui\JuiAsset',
|
||||||
|
];
|
||||||
|
}
|
||||||
43
frontend/components/HtmlHelper.php
Normal file
43
frontend/components/HtmlHelper.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
namespace frontend\components;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use common\models\Order;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
|
||||||
|
class HtmlHelper{
|
||||||
|
|
||||||
|
|
||||||
|
private static function mkOptions( $models, $key, $value = 'name', $options = [] ){
|
||||||
|
$result = [];
|
||||||
|
$result = ArrayHelper::map($models, $key, $value);
|
||||||
|
return $result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var $models common\models\Account[]
|
||||||
|
* @return
|
||||||
|
* */
|
||||||
|
public static function mkAccountOptions( $models, $options = [] ){
|
||||||
|
return $result = self::mkOptions($models, 'id_account');
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @var $models common\models\Discount[]
|
||||||
|
* @return
|
||||||
|
* */
|
||||||
|
public static function mkDiscountOptions( $models, $options = [] ){
|
||||||
|
return $result = self::mkOptions($models, 'id_discount');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var $models common\models\TicketType[]
|
||||||
|
* @return
|
||||||
|
* */
|
||||||
|
public static function mkTicketTypeOptions( $models, $options = [] ){
|
||||||
|
return $result = self::mkOptions($models, 'id_ticket_type');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -5,9 +5,17 @@ namespace frontend\controllers;
|
|||||||
use Yii;
|
use Yii;
|
||||||
use common\models\Ticket;
|
use common\models\Ticket;
|
||||||
use frontend\models\TicketSearch;
|
use frontend\models\TicketSearch;
|
||||||
|
use frontend\models\ReceptionForm;
|
||||||
|
use frontend\models\TicketCreate;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
use yii\filters\VerbFilter;
|
use yii\filters\VerbFilter;
|
||||||
|
use common\models\Discount;
|
||||||
|
use common\models\TicketType;
|
||||||
|
use common\models\Account;
|
||||||
|
use yii\base\Object;
|
||||||
|
use common\models\Transfer;
|
||||||
|
use common\models\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TicketController implements the CRUD actions for Ticket model.
|
* TicketController implements the CRUD actions for Ticket model.
|
||||||
@ -58,15 +66,43 @@ class TicketController extends Controller
|
|||||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function actionCreate()
|
public function actionCreate($number = null)
|
||||||
{
|
{
|
||||||
$model = new Ticket();
|
|
||||||
|
$receptionForm = new ReceptionForm();
|
||||||
|
|
||||||
|
$receptionForm->number = $number;
|
||||||
|
|
||||||
|
$receptionForm->readCard();
|
||||||
|
|
||||||
|
$model = new TicketCreate();
|
||||||
|
|
||||||
|
$discounts = Discount::read();
|
||||||
|
|
||||||
|
$ticketTypes = TicketType::read();
|
||||||
|
|
||||||
|
$accounts = Account::readAccounts();
|
||||||
|
|
||||||
|
$user = User::findOne( [ 'id' => Yii::$app->user->id ] );
|
||||||
|
|
||||||
|
|
||||||
|
$model->id_user = \Yii::$app->user->id;
|
||||||
|
$model->status = Ticket::STATUS_ACTIVE;
|
||||||
|
$model->usage_count = 0;
|
||||||
|
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||||
return $this->redirect(['view', 'id' => $model->id_ticket]);
|
return $this->redirect(['view', 'id' => $model->id_ticket]);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
$userTransfers = Transfer::modelsToArray( Transfer::readUserSoldTransfers($user) );
|
||||||
|
|
||||||
return $this->render('create', [
|
return $this->render('create', [
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
|
'discounts' => $discounts,
|
||||||
|
'ticketTypes' => $ticketTypes,
|
||||||
|
'accounts' => $accounts,
|
||||||
|
'receptionForm' => $receptionForm,
|
||||||
|
'userTransfers' => $userTransfers,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
76
frontend/models/TicketCreate.php
Normal file
76
frontend/models/TicketCreate.php
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
namespace frontend\models;
|
||||||
|
|
||||||
|
use common\models\Ticket;
|
||||||
|
use common\models\TicketType;
|
||||||
|
use common\models\Account;
|
||||||
|
use common\models\Discount;
|
||||||
|
|
||||||
|
|
||||||
|
class TicketCreate extends Ticket{
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
/////////////////////
|
||||||
|
//ticket type
|
||||||
|
/////////////////////
|
||||||
|
[[ 'id_ticket_type'], 'required'],
|
||||||
|
[[ 'id_ticket_type'], 'integer'],
|
||||||
|
[[ 'id_ticket_type'], 'validateTicketType'],
|
||||||
|
/////////////////////
|
||||||
|
//id_account
|
||||||
|
/////////////////////
|
||||||
|
[[ 'id_account'], 'required'],
|
||||||
|
[[ 'id_account'], 'integer'],
|
||||||
|
[[ 'id_account'], 'validateAccount'],
|
||||||
|
/////////////////////
|
||||||
|
//id_discount
|
||||||
|
/////////////////////
|
||||||
|
[[ 'id_discount'], 'integer'],
|
||||||
|
[[ 'id_discount'], 'validateDiscount'],
|
||||||
|
/////////////////////
|
||||||
|
// start and end date
|
||||||
|
/////////////////////
|
||||||
|
[['start', 'end' ], 'required'],
|
||||||
|
[['start', 'end' ], 'date'],
|
||||||
|
/////////////////////
|
||||||
|
//id_account
|
||||||
|
/////////////////////
|
||||||
|
[[ 'max_usage_count'], 'required'],
|
||||||
|
[[ 'max_usage_count'], 'integer'],
|
||||||
|
/////////////////////
|
||||||
|
//price
|
||||||
|
/////////////////////
|
||||||
|
[[ 'price_brutto'], 'required'],
|
||||||
|
[[ 'price_brutto'], 'integer'],
|
||||||
|
/////////////////////
|
||||||
|
//comment
|
||||||
|
/////////////////////
|
||||||
|
[['comment'], 'required'],
|
||||||
|
[['comment'], 'string', 'max' => 255]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function validateTicketType($attribute,$params){
|
||||||
|
$type = TicketType::findOne($this->id_ticket_type);
|
||||||
|
if ( !isset($type)) {
|
||||||
|
$this->addError($attribute,Yii::t('frontend/ticket' , 'Invalid ticket type' ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function validateAccount($attribute,$params){
|
||||||
|
$acc = Account::findOne($this->id_account);
|
||||||
|
if ( !isset($acc)) {
|
||||||
|
$this->addError($attribute,Yii::t('frontend/ticket' , 'Invalid transfer' ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function validateDiscount($attribute,$params){
|
||||||
|
$discount = Discount::findOne($this->id_discount);
|
||||||
|
if ( !isset($discount)) {
|
||||||
|
$this->addError($attribute,Yii::t('frontend/ticket' , 'Invalid discount' ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -66,7 +66,7 @@ function mkBtn($card, $label,$route = null ){
|
|||||||
<?php echo mkCustomerBtn( $card, Yii::t( 'frontend/customer' , 'Befizetések') , 'ticket/index'); ?>
|
<?php echo mkCustomerBtn( $card, Yii::t( 'frontend/customer' , 'Befizetések') , 'ticket/index'); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class='col-md-4'>
|
<div class='col-md-4'>
|
||||||
<?php echo Html::a(Html::tag("i","", [ 'class' => 'glyphicon glyphicon-plus' ] ) , 'ticket/create' , ['class' => 'btn btn-primary btn-reception'] )?>
|
<?php echo Html::a(Html::tag("i","", [ 'class' => 'glyphicon glyphicon-plus' ] ) , Url::toRoute('ticket/create') , ['class' => 'btn btn-primary btn-reception'] ) ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class='row'>
|
<div class='row'>
|
||||||
|
|||||||
9
frontend/views/common/_transfer_list.php
Normal file
9
frontend/views/common/_transfer_list.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
use yii\bootstrap\Html;
|
||||||
|
?>
|
||||||
|
<div class="row">
|
||||||
|
<div class='col-md-12 '>
|
||||||
|
<div class="transfer-list-container">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@ -8,6 +8,8 @@ use frontend\components\ReceptionCardNumberWidget;
|
|||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $model common\models\Customer */
|
/* @var $model common\models\Customer */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->title = Yii::t('common/customer', 'Create Customer');
|
$this->title = Yii::t('common/customer', 'Create Customer');
|
||||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/customer', 'Customers'), 'url' => ['index']];
|
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/customer', 'Customers'), 'url' => ['index']];
|
||||||
$this->params['breadcrumbs'][] = $this->title;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
@ -16,6 +18,9 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
$customer = $model;
|
$customer = $model;
|
||||||
$card = $customer->card;
|
$card = $customer->card;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="customer-create">
|
<div class="customer-create">
|
||||||
|
|
||||||
|
|||||||
@ -2,46 +2,68 @@
|
|||||||
|
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\widgets\ActiveForm;
|
use yii\widgets\ActiveForm;
|
||||||
|
use frontend\components\HtmlHelper;
|
||||||
|
use kartik\widgets\DatePicker;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $model common\models\Ticket */
|
/* @var $model common\models\Ticket */
|
||||||
|
/* @var $accounts common\models\Account[] */
|
||||||
|
/* @var $ticketTypes common\models\TicketType[] */
|
||||||
|
/* @var $discounts common\models\Discount[] */
|
||||||
/* @var $form yii\widgets\ActiveForm */
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="ticket-form">
|
<?php
|
||||||
|
|
||||||
<?php $form = ActiveForm::begin(); ?>
|
$accountOptions = HtmlHelper::mkAccountOptions($accounts);
|
||||||
|
$discountOptions = HtmlHelper::mkDiscountOptions($discounts);
|
||||||
|
$ticketTypeOptions = HtmlHelper::mkTicketTypeOptions($ticketTypes);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
<?= $form->field($model, 'id_user')->textInput() ?>
|
<div class="row" >
|
||||||
|
<div class="col-md-12" >
|
||||||
<?= $form->field($model, 'id_ticket_type')->textInput() ?>
|
<div class="ticket-form">
|
||||||
|
|
||||||
<?= $form->field($model, 'id_account')->textInput() ?>
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'id_discount')->textInput() ?>
|
<?= $form->field($model, 'id_ticket_type')->dropDownList($ticketTypeOptions) ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'start')->textInput() ?>
|
<?= $form->field($model, 'id_account')->dropDownList($accountOptions) ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'end')->textInput() ?>
|
<?= $form->field($model, 'id_discount')->dropDownList($discountOptions) ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'max_usage_count')->textInput() ?>
|
|
||||||
|
<?= $form->field($model, 'start')->widget(DatePicker::classname(), [
|
||||||
<?= $form->field($model, 'usage_count')->textInput() ?>
|
'pluginOptions' => [
|
||||||
|
'autoclose'=>true,
|
||||||
<?= $form->field($model, 'status')->textInput() ?>
|
'format' => 'yyyy.mm.dd'
|
||||||
|
]
|
||||||
<?= $form->field($model, 'price_brutto')->textInput() ?>
|
]) ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'comment')->textInput(['maxlength' => true]) ?>
|
|
||||||
|
<?= $form->field($model, 'end')->widget(DatePicker::classname(), [
|
||||||
<?= $form->field($model, 'created_at')->textInput() ?>
|
'pluginOptions' => [
|
||||||
|
'autoclose'=>true,
|
||||||
<?= $form->field($model, 'updated_at')->textInput() ?>
|
'format' => 'yyyy.mm.dd'
|
||||||
|
]
|
||||||
<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']) ?>
|
|
||||||
</div>
|
<?= $form->field($model, 'max_usage_count')->input('number') ?>
|
||||||
|
|
||||||
<?php ActiveForm::end(); ?>
|
<?= $form->field($model, 'price_brutto')->input('number') ?>
|
||||||
|
|
||||||
</div>
|
<?= $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']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@ -1,21 +1,63 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
|
use frontend\components\ReceptionMenuWidget;
|
||||||
|
use frontend\components\ReceptionCardNumberWidget;
|
||||||
|
use frontend\assets\TicketSellAsset;
|
||||||
|
use common\models\TicketType;
|
||||||
|
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $model common\models\Ticket */
|
/* @var $model common\models\Ticket */
|
||||||
|
/* @var $receptionForm frotned\models\ReceptionForm */
|
||||||
|
|
||||||
|
TicketSellAsset::register($this);
|
||||||
|
|
||||||
$this->title = Yii::t('common/ticket', 'Create Ticket');
|
$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']];
|
||||||
$this->params['breadcrumbs'][] = $this->title;
|
$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['types'] = TicketType::modelsToArray($ticketTypes);
|
||||||
|
$options['transfer_list'] = $userTransfers;
|
||||||
|
|
||||||
|
$this->registerJs ( 'new TicketSell( '. json_encode($options).');' );
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="ticket-create">
|
<div class="ticket-create">
|
||||||
|
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
<div class='row'>
|
||||||
|
<div class='col-md-3'>
|
||||||
|
<?php echo ReceptionMenuWidget::widget( [ 'customer' => $customer, 'card' => $card] ) ?>
|
||||||
|
</div>
|
||||||
|
<div class='col-md-4'>
|
||||||
|
<?php echo ReceptionCardNumberWidget::widget( [ 'customer' => $customer, 'card' =>$card, 'route' => ['customer/reception'] ] )?>
|
||||||
|
</div>
|
||||||
|
<div class='col-md-4'>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?= $this->render('_form', [
|
|
||||||
'model' => $model,
|
<div class="row">
|
||||||
]) ?>
|
<div class="col-md-6">
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
<?= $this->render('_form', [
|
||||||
|
'model' => $model,
|
||||||
|
'discounts' => $discounts,
|
||||||
|
'ticketTypes' => $ticketTypes,
|
||||||
|
'accounts' => $accounts,
|
||||||
|
]) ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<h1><?php echo Yii::t('frontend/tciket', 'Cart')?></h1>
|
||||||
|
<?php echo $this->render( "//common/_transfer_list" ) ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
17
frontend/web/js/frontend.js
Normal file
17
frontend/web/js/frontend.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
(function() {
|
||||||
|
var KeypressListener;
|
||||||
|
|
||||||
|
KeypressListener = (function() {
|
||||||
|
function KeypressListener(name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
KeypressListener.prototype.listen = function() {};
|
||||||
|
|
||||||
|
return KeypressListener;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
}).call(this);
|
||||||
|
|
||||||
|
//# sourceMappingURL=frontend.js.map
|
||||||
10
frontend/web/js/frontend.js.map
Normal file
10
frontend/web/js/frontend.js.map
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"file": "frontend.js",
|
||||||
|
"sourceRoot": "../coffee/",
|
||||||
|
"sources": [
|
||||||
|
"keypresslistener.coffee"
|
||||||
|
],
|
||||||
|
"names": [],
|
||||||
|
"mappings": "AAAA;AAAA,MAAA;;EAAM;IAEQ,0BAAC,IAAD;MAAC,IAAC,CAAA,OAAD;IAAD;;+BAEb,MAAA,GAAQ,SAAA,GAAA;;;;;AAJT"
|
||||||
|
}
|
||||||
154
frontend/web/js/ticket.sell.js
Normal file
154
frontend/web/js/ticket.sell.js
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
function TicketSell(o){
|
||||||
|
|
||||||
|
/**reference for the instance*/
|
||||||
|
var app = this;
|
||||||
|
|
||||||
|
this.defaults = {
|
||||||
|
default_type: 0,
|
||||||
|
selected_type: 1,
|
||||||
|
time_unit_day : 10,
|
||||||
|
time_unit_month : 20,
|
||||||
|
time_unit_month_reference : 30,
|
||||||
|
/**id of filter text*/
|
||||||
|
types: [{
|
||||||
|
name :'Bérlet',
|
||||||
|
id_ticket_type: 0,
|
||||||
|
max_usage_count:0,
|
||||||
|
time_unit_type:1,
|
||||||
|
time_unit_count:1,
|
||||||
|
id_account:0,
|
||||||
|
price_brutto:1000,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
selector_type: '#ticketcreate-id_ticket_type',
|
||||||
|
selector_start: '#ticketcreate-start',
|
||||||
|
selector_end: '#ticketcreate-end',
|
||||||
|
selector_account: '#ticketcreate-id_account',
|
||||||
|
selector_price: '#ticketcreate-price_brutto',
|
||||||
|
selector_max_usage_count: '#ticketcreate-max_usage_count',
|
||||||
|
date_format_moment: 'YYYY.MM.DD',
|
||||||
|
ticket_type: null,
|
||||||
|
start_date: null,
|
||||||
|
end_date: null,
|
||||||
|
max_usage_count: null,
|
||||||
|
id_account: null,
|
||||||
|
price: null,
|
||||||
|
clear_list_url: '',
|
||||||
|
transfer_list: []
|
||||||
|
};
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
|
function init(){
|
||||||
|
$.extend(app.defaults, o );
|
||||||
|
addBehaviourTypeChangedListener();
|
||||||
|
useDefaults();
|
||||||
|
createUserSoldItemsTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
function useDefaults(){
|
||||||
|
if ( app.defaults.selected_type > 0){
|
||||||
|
$(app.defaults.selector_type).val( app.defaults.selected_type );
|
||||||
|
typeChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createUserSoldItemsTable(){
|
||||||
|
$('.transfer-list-container').transferList({
|
||||||
|
'transfers' : app.defaults.transfer_list
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshSoldUseritems(){
|
||||||
|
$('.transfer-list-container').transferList('option','transfers' , app.defaults.sold_items );
|
||||||
|
}
|
||||||
|
|
||||||
|
function addBehaviourTypeChangedListener(){
|
||||||
|
$(app.defaults.selector_type).change(change);
|
||||||
|
}
|
||||||
|
|
||||||
|
function change(event){
|
||||||
|
if ( '#'+event.target.id == app.defaults.selector_type ){
|
||||||
|
typeChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function typeChanged(){
|
||||||
|
validateTypeChanged();
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateTypeChanged(){
|
||||||
|
validateType();
|
||||||
|
validateStartDate();
|
||||||
|
validateEndDate();
|
||||||
|
validateMaxUsageCount();
|
||||||
|
validatePriceBrutto();
|
||||||
|
validateAccount();
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateType(){
|
||||||
|
var type;
|
||||||
|
type = +$(app.defaults.selector_type).val();
|
||||||
|
app.defaults.ticket_type = null;
|
||||||
|
for ( var i = 0; i < app.defaults.types.length; i++ ){
|
||||||
|
if ( app.defaults.types[i].id_ticket_type == type){
|
||||||
|
app.defaults.ticket_type = app.defaults.types[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateStartDate(){
|
||||||
|
app.defaults.start_date = moment( $( app.defaults.selector_start ).val(), app.defaults.date_format_moment) ;
|
||||||
|
|
||||||
|
if ( !app.defaults.start_date.isValid() ){
|
||||||
|
app.defaults.start_date = moment();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateEndDate(){
|
||||||
|
var units;
|
||||||
|
units = app.defaults.ticket_type.time_unit_count;
|
||||||
|
app.defaults.end_date = moment(app.defaults.start_date);
|
||||||
|
switch(app.defaults.ticket_type.time_unit_type){
|
||||||
|
case app.defaults.time_unit_day:
|
||||||
|
app.defaults.end_date.add( units, 'days');
|
||||||
|
app.defaults.end_date.subtract( 1, 'days');
|
||||||
|
break;
|
||||||
|
case app.defaults.time_unit_month:
|
||||||
|
app.defaults.end_date.add( units, 'month');
|
||||||
|
app.defaults.end_date.subtract( 1, 'days');
|
||||||
|
break;
|
||||||
|
case app.defaults.time_unit_month_reference:
|
||||||
|
if ( units > 1){
|
||||||
|
app.defaults.end_date.add( units -1, 'month');
|
||||||
|
}
|
||||||
|
app.defaults.end_date.endOf('month');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateMaxUsageCount(){
|
||||||
|
app.defaults.max_usage_count = app.defaults.ticket_type.max_usage_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
function validatePriceBrutto(){
|
||||||
|
app.defaults.price = app.defaults.ticket_type.price_brutto;
|
||||||
|
}
|
||||||
|
function validateAccount(){
|
||||||
|
app.defaults.id_account = app.defaults.ticket_type.id_account;
|
||||||
|
}
|
||||||
|
|
||||||
|
function refresh(){
|
||||||
|
console.info( app.defaults.start_date.toDate());
|
||||||
|
$(app.defaults.selector_start ).val( app.defaults.start_date.format( app.defaults.date_format_moment ) );
|
||||||
|
$(app.defaults.selector_end ).val( app.defaults.end_date.format( app.defaults.date_format_moment ) );
|
||||||
|
$(app.defaults.selector_account ).val(app.defaults.id_account);
|
||||||
|
$(app.defaults.selector_price ).val(app.defaults.price);
|
||||||
|
$(app.defaults.selector_max_usage_count ).val(app.defaults.max_usage_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
22
package.json
Normal file
22
package.json
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"author": "rocho",
|
||||||
|
"name": "coma",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"grunt": "~0.4.1",
|
||||||
|
"matchdep": "*",
|
||||||
|
|
||||||
|
"grunt-contrib-coffee": "*",
|
||||||
|
"grunt-contrib-compass": "*",
|
||||||
|
"grunt-contrib-watch": "*",
|
||||||
|
"grunt-contrib-imagemin": "*",
|
||||||
|
"grunt-contrib-clean": "*",
|
||||||
|
"grunt-concurrent": "*",
|
||||||
|
"grunt-jsmin-sourcemap": "*",
|
||||||
|
"grunt-notify": "*",
|
||||||
|
"grunt-newer": "*"
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user