add card.flag implementation

This commit is contained in:
Roland Schneider 2016-03-09 20:16:19 +01:00
parent 1d3c476476
commit 42c326f407
25 changed files with 497 additions and 80 deletions

View File

@ -13,6 +13,7 @@ use backend\models\CardImportRfidForm;
use yii\web\UploadedFile;
use common\components\Helper;
use backend\models\CardInsertForm;
use common\models\Ticket;
/**
* CardController implements the CRUD actions for Card model.
@ -32,7 +33,8 @@ class CardController extends \backend\controllers\BackendController {
'update',
'list' ,
'import-rfid',
'insert'
'insert',
'recalculate',
],
'allow' => true,
'roles' => [
@ -349,4 +351,21 @@ class CardController extends \backend\controllers\BackendController {
}
public function actionRecalculate(){
if (Yii::$app->request->isPost) {
$connection = \Yii::$app->db;
$command = $connection->createCommand( Ticket::$SQL_UPDATE );
$result = $command->execute();
\Yii::info("Tickets updated: " . $result );
\Yii::$app->session->setFlash('success', 'Módosított bérletek száma: ' . $result);
}
return $this->render("recalculate");
}
}

View File

@ -8,6 +8,15 @@ use backend\models\InventorySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\InventoryItem;
use yii\data\ActiveDataProvider;
use common\components\Helper;
use common\models\User;
use common\models\Product;
use common\models\InventoryGroup;
use yii\db\Expression;
use yii\db\Query;
use backend\models\InventoryItemSearch;
/**
* InventoryController implements the CRUD actions for Inventory model.
@ -48,8 +57,17 @@ class InventoryController extends Controller
*/
public function actionView($id)
{
$inventory = $this->findModel($id);
$searchModel = new InventoryItemSearch(['inventory' => $inventory]);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$query = new Query();
return $this->render('view', [
'model' => $this->findModel($id),
'model' => $inventory,
'dataProvider' => $dataProvider
]);
}

View File

@ -9,6 +9,7 @@ use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use backend\models\InventoryItemForm;
use common\models\Inventory;
/**
* InventoryItemController implements the CRUD actions for InventoryItem model.
@ -31,12 +32,19 @@ class InventoryItemController extends Controller
* Lists all InventoryItem models.
* @return mixed
*/
public function actionIndex()
public function actionIndex($id)
{
$searchModel = new InventoryItemSearch();
$inventory = Inventory::findOne($id);
if ( !isset($inventory)){
throw new NotFoundHttpException("Leltár nem található");
}
$searchModel = new InventoryItemSearch(['inventory' => $inventory]);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'model' => $inventory,
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
@ -68,7 +76,7 @@ class InventoryItemController extends Controller
$model->read();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_inventory_item]);
return $this->redirect(['inventory-item/index', 'id' => $model->inventory->id_inventory]);
} else {
return $this->render('create', [
'model' => $model,
@ -103,9 +111,11 @@ class InventoryItemController extends Controller
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
$item = $this->findModel($id);
$id_inventory = $item->id_inventory;
$item->delete();
return $this->redirect(['index']);
return $this->redirect(['index', 'id' => $id_inventory]);
}
/**

View File

@ -82,7 +82,8 @@ class DoorLogSearch extends DoorLog
'door_log.direction as door_log_direction',
'door_log.created_at as door_log_created_at',
'door_log.source_app as door_log_source_app',
'account.name as account_name'
'account.name as account_name',
'door_log.card_flag as door_log_card_flag',
]);
$query->from('door_log');
$query->innerJoin('card','card.id_card = door_log.id_card');
@ -131,6 +132,10 @@ class DoorLogSearch extends DoorLog
'account_name' =>[
'asc' => ['account.name' => SORT_ASC ],
'desc' => ['account.name' => SORT_DESC],
],
'door_log_card_flag' =>[
'asc' => ['door_log_card_flag' => SORT_ASC ],
'desc' => ['door_log_card_flag' => SORT_DESC],
]
],
]

View File

@ -17,6 +17,7 @@ use common\models\InventoryItem;
use yii\db\Query;
use common\models\Procurement;
use common\models\Transfer;
use common\models\Sale;
/**
* ContactForm is the model behind the contact form.
@ -32,7 +33,7 @@ class InventoryItemForm extends Model{
/**common data*/
public $inventory;
public $lastInventory;
public $last_inventory;
public $id_inventory;
public $products;
public $inventoryGroups;
@ -48,6 +49,8 @@ class InventoryItemForm extends Model{
public $product_in;
public $product_out;
public $product_stock;
public $last_inventory_item;
public $inventory_item;
public function rules(){
return [
@ -98,9 +101,9 @@ class InventoryItemForm extends Model{
$item->count_sold = $this->product_out;
$item->count = $this->product_stock;
if ( isset( $this->lastInventoryItem ) ){
$item->id_inventory_item_prev = $this->lastInventoryItem->id_inventory_item;
$item->count_prev = $this->lastInventoryItem->count;
if ( isset( $this->last_inventory_item ) ){
$item->id_inventory_item_prev = $this->last_inventory_item->id_inventory_item;
$item->count_prev = $this->last_inventory_item->count;
}else{
$item->count_prev = 0;
}
@ -112,11 +115,13 @@ class InventoryItemForm extends Model{
}else{
$item->id_inventory_group = $this->inventoryGroup->id_inventory_group;
}
$item->id_inventory = $this->inventory->id_inventory;
if ( !$item->save() ){
throw new \Exception("Nem sikerült a leltár végrehajtása");
}
$this->inventory_item = $item;
return true;
}
return false;
@ -128,8 +133,8 @@ class InventoryItemForm extends Model{
$query->from(Procurement::tableName());
$query->innerJoin(Product::tableName(),"product.id_product = procurement.id_product");
if ( isset($this->lastInventoryItem ) ){
$query->andWhere([ '>', 'procurement.created_at' ,$this->lastInventoryItem->created_at]);
if ( isset($this->last_inventory_item ) ){
$query->andWhere([ '>', 'procurement.created_at' ,$this->last_inventory_item->created_at]);
}
if ( $this->type == 'product') {
@ -147,7 +152,8 @@ class InventoryItemForm extends Model{
$query = new Query();
$query->select(['sum(transfer.count) as total_sold']);
$query->from(Transfer::tableName());
$query->innerJoin(Product::tableName(),"product.id_product = transfer.id_object and transfer.type = " .Transfer::TYPE_PRODUCT);
$query->innerJoin(Sale::tableName(),"sale.id_sale = transfer.id_object and transfer.type = " .Transfer::TYPE_PRODUCT);
$query->innerJoin(Product::tableName(),"product.id_product = sale.id_product ");
$query->andWhere(['in', 'transfer.status' ,[Transfer::STATUS_PAID ,Transfer::STATUS_NOT_PAID ] ]);
$query->andWhere(['transfer.type' => Transfer::TYPE_PRODUCT]);
@ -190,9 +196,9 @@ class InventoryItemForm extends Model{
* Load previous inventory item, if exists
* */
protected function loadLastInventoryItem( ){
if ( isset( $this->lastInventory ) ){
if ( isset( $this->last_inventory ) ){
$query = InventoryItem::find();
$query->andWhere(['id_inventory' => $this->lastInventory->id_inventory]);
$query->andWhere(['id_inventory' => $this->last_inventory->id_inventory]);
if ( $this->type == 'product'){
$query->andWhere(['id_product' => $this->product->id_product]);
@ -200,7 +206,7 @@ class InventoryItemForm extends Model{
$query->andWhere(['id_inventory_group' => $this->inventoryGroup->id_inventory_group]);
}
$this->lastInventoryItem = $query->one();
$this->last_inventory_item = $query->one();
}
}
@ -223,10 +229,9 @@ class InventoryItemForm extends Model{
}
public function loadLastInventory(){
$query = Inventory::find();
$query->andWhere('<', 'inventory.created_at' , $this->inventory->created_at);
$query->andWhere(['<', 'inventory.created_at' , $this->inventory->created_at]);
$query->orderBy(['created_at' => SORT_DESC ]);
//$this->lastInventory =
$query->limit(1)->all();
$this->last_inventory =$query->limit(1)->one();
}
public function loadProducts(){

View File

@ -6,12 +6,20 @@ use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\InventoryItem;
use yii\db\Query;
use yii\db\Expression;
use common\models\User;
use common\models\Product;
use common\models\InventoryGroup;
use common\components\Helper;
/**
* InventoryItemSearch represents the model behind the search form about `common\models\InventoryItem`.
*/
class InventoryItemSearch extends InventoryItem
{
public $inventory;
/**
* @inheritdoc
*/
@ -19,7 +27,6 @@ class InventoryItemSearch extends InventoryItem
{
return [
[['id_inventory_item', 'id_inventory', 'count_in', 'count_sold', 'count', 'type', 'id_product', 'id_inventory_group', 'id_user'], 'integer'],
[['last_inventroy_at', 'created_at', 'updated_at'], 'safe'],
];
}
@ -41,12 +48,45 @@ class InventoryItemSearch extends InventoryItem
*/
public function search($params)
{
$query = InventoryItem::find();
$query = new Query();
$query->select([
'inventory_item.id_inventory_item as item_id_inventory_item',
'inventory_item.created_at as item_created_at',
new Expression('case when inventory_item.id_product is null then inventory_group.name else product.name end as item_name'),
'user.username as user_username',
'coalesce(inventory_item.count_prev ,0)as item_count_prev',
'coalesce(inventory_item.count_in,0) as item_count_in',
'coalesce(inventory_item.count_sold,0) as item_count_sold',
'coalesce(inventory_item.count,0) as item_count',
new Expression('(inventory_item.count - ( inventory_item.count_prev + inventory_item.count_in - inventory_item.count_sold )) as item_difference'),
]);
$query->from(InventoryItem::tableName());
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$query->innerJoin(User::tableName(), "user.id = inventory_item.id_user");
$query->leftJoin(Product::tableName(), "product.id_product = inventory_item.id_product");
$query->leftJoin(InventoryGroup::tableName(), "inventory_group.id_inventory_group = inventory_item.id_inventory_group");
$query->andWhere( ['id_inventory' => $this->inventory->id_inventory] );
$dataProvider = new ActiveDataProvider(
['query' => $query ,
'sort' => [
'attributes' => Helper::mkYiiSortItems([
['item_created_at', 'item_created_at'],
['item_name', 'item_name'],
['user_username', 'user_username'],
['item_count_prev', 'item_count_prev'],
['item_count_sold', 'item_count_sold'],
['item_count_in', 'item_count_in'],
['item_count', 'item_count'],
['item_count', 'item_count'],
['item_difference', 'item_difference'],
])
,
]
]
);
$this->load($params);
if (!$this->validate()) {
@ -65,7 +105,6 @@ class InventoryItemSearch extends InventoryItem
'id_product' => $this->id_product,
'id_inventory_group' => $this->id_inventory_group,
'id_user' => $this->id_user,
'last_inventroy_at' => $this->last_inventroy_at,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);

View File

@ -0,0 +1,15 @@
<?php
use yii\helpers\Html;
?>
<p>
Bérletek kapu flag -jének újraszámolása
</p>
<?php
echo Html::a("Újra számolás", ['recalculate'], [
'class' => 'btn btn-danger',
'data' => [
'method' => 'post',
],
]) ?>

View File

@ -61,6 +61,13 @@ $this->params['breadcrumbs'][] = $this->title;
'value' => function ($model, $key, $index, $column){
return Helper::getArrayValue(DoorLog::getDirectionTypes(), $model['door_log_direction'],"-" );
}
],
[
'attribute' => 'door_log_card_flag',
'label' => 'Info',
'value' => function ($model, $key, $index, $column){
return Helper::getArrayValue(DoorLog::getCardFlagTexts(), $model['door_log_card_flag'],"-" );
}
],
[
'attribute' => 'door_log_source_app',

View File

@ -33,7 +33,6 @@ use yii\widgets\ActiveForm;
<?php // echo $form->field($model, 'id_user') ?>
<?php // echo $form->field($model, 'last_inventroy_at') ?>
<?php // echo $form->field($model, 'created_at') ?>

View File

@ -2,44 +2,102 @@
use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\DetailView;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\InventoryItemSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('common/inventory-item', 'Inventory Items');
$this->title = Yii::t('common/inventory-item', 'Leltár részletei');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="inventory-item-index">
<h1><?= Html::encode($this->title) ?></h1>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id_inventory',
['attribute'=>'id_user',
'value'=>$model->userName
],
'created_at:datetime',
],
]) ?>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('common/inventory-item', 'Create Inventory Item'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
<p>
<?= Html::a(Yii::t('common/inventory', 'Új termék'), ['inventory-item/create','id' =>$model->id_inventory], ['class' => 'btn btn-success']) ?>
</p>
'id_inventory_item',
'id_inventory',
'count_in',
'count_sold',
'count',
// 'type',
// 'id_product',
// 'id_inventory_group',
// 'id_user',
// 'last_inventroy_at',
// 'created_at',
// 'updated_at',
<?php
echo GridView::widget( [
'dataProvider' => $dataProvider,
'columns' =>[
[
'attribute' => 'item_created_at',
'label' => 'Létrehozva',
'format' => 'datetime'
],
[
'attribute' => 'item_name',
'label' => 'Név',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
],
[
'attribute' => 'user_username',
'label' => 'Felhasználó',
],
[
'attribute' => 'item_count_prev',
'label' => 'Előzö leltár (db)'
],
[
'attribute' => 'item_count_in',
'label' => 'Beszerzett mennyiség (db)'
],
[
'attribute' => 'item_count_sold',
'label' => 'Eladott mennyiség (db)',
],
[
'attribute' => 'item_count',
'label' => 'Leltározott mennyiség (db)',
],
[
'attribute' => 'item_difference',
'label' => 'Különbség (db)',
],
['class' => 'yii\grid\ActionColumn',
'template' => '{delete}',
'urlCreator' => function ($action, $model, $key, $index){
return Url::to(['inventory-item/delete', 'id' => $model['item_id_inventory_item' ] ]) ;
},
'buttons' =>[
'delete' =>function ($url, $model, $key) {
return Html::a('Törlés', $url,['class' => 'btn btn-xs btn-danger',
'data' => [
'confirm' => Yii::t('common/inventory-item', 'Biztosan törlöd ezt az elemet?'),
'method' => 'post',
],
]) ;
}
]
]
]
]);
?>
</div>

View File

@ -37,7 +37,6 @@ $this->params['breadcrumbs'][] = $this->title;
'id_product',
'id_inventory_group',
'id_user',
'last_inventroy_at',
'created_at',
'updated_at',
],

View File

@ -2,6 +2,7 @@
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\InventorySearch */
@ -28,7 +29,13 @@ $this->params['breadcrumbs'][] = $this->title;
'created_at:datetime',
['class' => 'yii\grid\ActionColumn',
'template' => '{view}'
'template' => '{view}',
'urlCreator' => function( $action, $model, $key, $index ){
if ( $action == 'view' ){
return Url::to(['inventory-item/index' , 'id'=> $model->id_inventory]);
}
}
],
],
]); ?>

View File

@ -2,6 +2,8 @@
use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\grid\GridView;
use yii\base\Widget;
/* @var $this yii\web\View */
/* @var $model common\models\Inventory */
@ -34,3 +36,53 @@ $this->params['breadcrumbs'][] = "Leltár";
<?= Html::a(Yii::t('common/inventory', 'Új termék'), ['inventory-item/create','id' =>$model->id_inventory], ['class' => 'btn btn-success']) ?>
</p>
<?php
echo GridView::widget( [
'dataProvider' => $dataProvider,
'columns' =>[
[
'attribute' => 'item_created_at',
'label' => 'Létrehozva',
'format' => 'datetime'
],
[
'attribute' => 'item_name',
'label' => 'Név',
],
[
'attribute' => 'user_username',
'label' => 'Felhasználó',
],
[
'attribute' => 'item_count_prev',
'label' => 'Előzö leltár (db)'
],
[
'attribute' => 'item_count_in',
'label' => 'Beszerzett mennyiség (db)'
],
[
'attribute' => 'item_count_sold',
'label' => 'Eladott mennyiség (db)',
],
[
'attribute' => 'item_count',
'label' => 'Leltározott mennyiség (db)',
],
[
'attribute' => 'item_difference',
'label' => 'Különbség (db)',
],
]
]);
?>

View File

@ -166,4 +166,10 @@ class Card extends \common\models\BaseFitnessActiveRecord
]);
}
public static function updateCardFlagTicket($id){
$db = \Yii::$app->db;
$command = $db->createCommand(Ticket::$SQL_UPDATE_CARD,[':id' => $id]);
$command->execute();
}
}

View File

@ -140,4 +140,13 @@ class DoorLog extends \yii\db\ActiveRecord
19 => "Bérlet érvényességi időn kívüli BE olvastatás (nem enged)",
];
}
public static function getCardFlagTexts( ){
return [
0 => "Kártya ok",
1 => "Nincs érvényes bérlet",
];
}
}

View File

@ -3,6 +3,9 @@
namespace common\models;
use Yii;
use yii\helpers\ArrayHelper;
use common\components\UserAwareBehavior;
use common\components\Helper;
/**
* This is the model class for table "inventory_item".
@ -24,6 +27,9 @@ use Yii;
*/
class InventoryItem extends BaseFitnessActiveRecord
{
public static $TYPE_PRODUCT = 10;
public static $TYPE_INVENTORY_GROUP = 20;
/**
* @inheritdoc
*/
@ -56,10 +62,74 @@ class InventoryItem extends BaseFitnessActiveRecord
'id_product' => Yii::t('common/inventory_item', 'Id Product'),
'id_inventory_group' => Yii::t('common/inventory_item', 'Id Inventory Group'),
'id_user' => Yii::t('common/inventory_item', 'Id User'),
'last_inventroy_at' => Yii::t('common/inventory_item', 'Last Inventroy At'),
'created_at' => Yii::t('common/inventory_item', 'Created At'),
'updated_at' => Yii::t('common/inventory_item', 'Updated At'),
];
}
public function behaviors()
{
return ArrayHelper::merge( [
[
'class' => UserAwareBehavior::className(),
]
], parent::behaviors());
}
public static function creqteQueryInventoryItems($id_inventory ) {
$query = InventoryItem::find();
$query->andWhere(['inventory_item.id_inventory' => $id_inventory]);
return $query;
}
public function getProduct(){
return $this->hasOne( Product::className() , [ 'id_product' => 'id_product' ]);
}
public function getInventoryGroup(){
return $this->hasOne( Product::className() , [ 'id_inventory_group' => 'id_inventory_group' ]);
}
public function getProductName(){
$result = "";
$product = $this->product;
if ( isset($product)){
$result = $product->name;
}
return $result;
}
public function getInventoryGroupName(){
$result = "";
$product = $this->inventoryGroup;
if ( isset($product)){
$result = $product->name;
}
return $result;
}
public function getName(){
$name = "";
if ( isset($this->id_product )){
$name = $this->getProductName();
}else{
$name = $this->getInventoryGroupName();
}
return $name;
}
public function getDifference(){
$diff = $this->count - ( $this->count_prev + $this->count_in - $this->count_sold );
return $diff;
}
}

View File

@ -36,6 +36,20 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
const STATUS_ACTIVE = 10;
const STATUS_INACTIVE = 20;
public static $SQL_UPDATE = "UPDATE card as c1
left JOIN ( select distinct ticket.id_card as id_card from ticket
where ticket.start <= CURDATE() and ticket.end >= curdate() and ticket.status = 10 ) as t
on t.id_card = c1.id_card
SET c1.flag = case when t.id_card is null then ( c1.flag | 1 << 0 ) else ( c1.flag & ~(1 << 0) ) end";
public static $SQL_UPDATE_CARD = "UPDATE card as c1
left JOIN ( select distinct ticket.id_card as id_card from ticket
where ticket.start <= CURDATE() and ticket.end >= curdate() and ticket.status = 10 ) as t
on t.id_card = c1.id_card
SET c1.flag = case when t.id_card is null then ( c1.flag | 1 << 0 ) else ( c1.flag & ~(1 << 0) ) end
WHERE c1.id_card = :id";
/**
* @inheritdoc
*/
@ -312,4 +326,13 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
}
}
}
public function afterSave($insert, $changedAttributes) {
Card::updateCardFlagTicket($this->id_card);;
}
public function afterDelete(){
Card::updateCardFlagTicket($this->id_card);;
}
}

View File

@ -927,6 +927,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
] );
}
// storno contract
} else if ($this->type == Transfer::TYPE_PRODUCT) {

View File

@ -16,7 +16,7 @@ return [
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
'levels' => ['error', 'warning','info'],
],
],
],

View File

@ -0,0 +1,21 @@
<?php
namespace console\controllers;
use Yii;
use common\models;
use yii\console\Controller;
use common\models\Ticket;
class TicketController extends Controller{
public function actionIndex()
{
$connection = \Yii::$app->db;
$command = $connection->createCommand( Ticket::$SQL_UPDATE );
$result = $command->execute();
\Yii::info("Tickets updated: " . $result );
echo "Tickets updated: " . $result ;
}
}

View File

@ -0,0 +1,31 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160308_201451_add_door_flag extends Migration
{
public function up()
{
$this->addColumn("door_log", "card_flag", "int default 0");
$this->addColumn("card", "flag", "int default 0");
}
public function down()
{
echo "m160308_201451_add_door_flag cannot be reverted.\n";
return false;
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}

2
cutler_daily.sh Normal file
View File

@ -0,0 +1,2 @@
php yii ticket/index

View File

@ -115,6 +115,8 @@ class ReceptionForm extends Model
$dlog->id_account = Account::readDefault();
$dlog->card_flag = $this->card->flag;
$dlog->created_at = date('Y-m-d H:i:s');
$dlog->save(false);
}

View File

@ -12,6 +12,7 @@ use yii\base\Object;
use common\models\TicketInstallmentRequest;
use common\models\Contract;
use common\components\Helper;
use common\models\Card;
/**
* @property $cart string name of cart, into we put the ticket
@ -158,9 +159,14 @@ class TicketCreate extends Ticket{
$this->appendToUserCart();
$this->appendToCustomerCart();
$this->addContract($insert);
$this->updateCardFlag();
}
protected function updateCardFlag(){
Card::updateCardFlagTicket($this->id_card);
}
public function addContract($insert){
if ($insert){
$ticketType = TicketType::findOne($this->id_ticket_type);

View File

@ -5,6 +5,9 @@ use frontend\model\ReceptionForm;
use yii\helpers\Html;
use yii\helpers\Url;
use common\models\Contract;
use common\components\Helper;
use common\models\Card;
use common\models\DoorLog;
/* @var $this yii\web\View */
/* @var $model frontend\model\ReceptionForm */
@ -19,28 +22,38 @@ if ( count($model->tickets) > 0 ){
if ( isset($model->card)){
if ( isset($model->customer)){
if ( isset($ticket)){
echo Html::beginTag("div",['class'=>"alert alert-success" , "role"=>"alert"]);
echo Html::beginTag("strong",[ ]);
echo "Érvényes bérlet!" ;
echo Html::endTag("strong");
echo Html::tag("br");
echo Html::beginTag("strong",[ ]);
echo "Típus: " ;
echo Html::endTag("strong");
echo $ticket->ticketTypeName ;
echo Html::tag("br");
echo Html::beginTag("strong",[ ]);
echo "Érvényes: " ;
echo Html::endTag("strong");
echo Yii::$app->formatter->asDate($ticket->start);
echo "&nbsp;-&nbsp;";
echo Yii::$app->formatter->asDate($ticket->end);
echo Html::endTag("div");
}else{
if ( $model->card->flag == 0 ){
if ( isset($ticket)){
echo Html::beginTag("div",['class'=>"alert alert-success" , "role"=>"alert"]);
echo Html::beginTag("strong",[ ]);
echo "Érvényes bérlet!" ;
echo Html::endTag("strong");
echo Html::tag("br");
echo Html::beginTag("strong",[ ]);
echo "Típus: " ;
echo Html::endTag("strong");
echo $ticket->ticketTypeName ;
echo Html::tag("br");
echo Html::beginTag("strong",[ ]);
echo "Érvényes: " ;
echo Html::endTag("strong");
echo Yii::$app->formatter->asDate($ticket->start);
echo "&nbsp;-&nbsp;";
echo Yii::$app->formatter->asDate($ticket->end);
echo Html::endTag("div");
}else{
echo Html::beginTag("div",['class'=>"alert alert-danger", "role"=>"alert"]);
echo Html::beginTag("strong",[ ]);
echo "Bérlet lejárt vagy nem érvényes!";
echo Html::endTag("strong");
echo Html::endTag("div");
}
} else{
echo Html::beginTag("div",['class'=>"alert alert-danger", "role"=>"alert"]);
echo "Kártya korlátozás:";
echo "<br>";
echo Html::beginTag("strong",[ ]);
echo "Bérlet lejárt vagy nem érvényes!";
echo Helper::getArrayValue(DoorLog::getCardFlagTexts(), $model->card->flag, "Ismeretlen ok") ;
echo Html::endTag("strong");
echo Html::endTag("div");
}