From 55afb5de62b516d9c0610381c131ead8bc6c82ee Mon Sep 17 00:00:00 2001 From: Roland Schneider Date: Mon, 27 Apr 2020 08:01:41 +0200 Subject: [PATCH 1/2] fix update card --- common/models/Ticket.php | 13 ++++++++++++- frontend/models/SingleCustomerActivateForm.php | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/common/models/Ticket.php b/common/models/Ticket.php index 3ea89c0..f87ccc7 100644 --- a/common/models/Ticket.php +++ b/common/models/Ticket.php @@ -90,7 +90,18 @@ class Ticket extends \common\models\BaseFitnessActiveRecord where c.status = 20 and c.inactivated_at is not null - and ((t.start <= c.inactivated_at and t.end >= c.inactivated_at) or (t.start >= c.inactivated_at)) ;"; + and ((t.start <= c.inactivated_at and t.end >= c.inactivated_at) ) "; + + public static $SQL_UPDATE_TICKETS_END_DATE_ON_CARD_ACTIVATION_SINGLE_CARD = "UPDATE ticket t + inner join card c on t.id_card = c.id_card + SET end = date_add( end, INTERVAL datediff(current_date, c.inactivated_at) DAY ) + where + c.status = 20 + and c.inactivated_at is not null + and ((t.start <= c.inactivated_at and t.end >= c.inactivated_at) ) and c.id_card = :id_card "; + + + public static function SQL_UPDATE_DOOR_ALLOWED_FLAG(){ return " diff --git a/frontend/models/SingleCustomerActivateForm.php b/frontend/models/SingleCustomerActivateForm.php index 0b623f2..d3526f2 100644 --- a/frontend/models/SingleCustomerActivateForm.php +++ b/frontend/models/SingleCustomerActivateForm.php @@ -11,6 +11,8 @@ use Yii; use yii\base\Model; use yii\data\ArrayDataProvider; use yii\db\Query; +use yii\web\HttpException; +use yii\web\ServerErrorHttpException; /** * Class SingleCustomerActivateForm @@ -68,13 +70,10 @@ class SingleCustomerActivateForm extends Model{ ->innerJoin(Card::tableName(), 'card.id_card = ticket.id_card') ->andWhere(['ticket.id_card' => $this->card->id_card]) ->andWhere( - ['or', ['and', ['<=','ticket.start',$this->card->inactivated_at ], ['>=','ticket.end',$this->card->inactivated_at ] - ], - ['>=','ticket.start',$this->card->inactivated_at ], - ] + ] ) ->orderBy( [ @@ -107,12 +106,19 @@ class SingleCustomerActivateForm extends Model{ return false; } + + if ( !isset($this->card) || !isset($this->card->id_card) || empty($this->card->id_card)){ + throw new ServerErrorHttpException("Hiba történt: nics kártya megadva"); + } + $tx = Yii::$app->db->beginTransaction(); assert(isset($tx)); try { - Yii::$app->db->createCommand(Ticket::$SQL_UPDATE_TICKETS_END_DATE_ON_CARD_ACTIVATION - . " AND id_card = '" . $this->card->id_card . "'")->execute(); + $command = Yii::$app->db->createCommand(Ticket::$SQL_UPDATE_TICKETS_END_DATE_ON_CARD_ACTIVATION_SINGLE_CARD,[':id_card' => $this->card->id_card]); + + $command->execute(); + Card::updateAll( [ 'status' => Card::STATUS_ACTIVE, From 0f6051e48b870d34e8d6c32d70d3ef5eb40b0d57 Mon Sep 17 00:00:00 2001 From: Roland Schneider Date: Mon, 27 Apr 2020 08:03:10 +0200 Subject: [PATCH 2/2] change version to v0.1.25 --- changelog.txt | 2 ++ common/config/params.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 89216df..21a645b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,5 @@ +-0.1.25 + - fix update inactive card -0.1.24 - add activate/incativate card for coronavirus -0.1.23 diff --git a/common/config/params.php b/common/config/params.php index f6acb14..3aa0477 100644 --- a/common/config/params.php +++ b/common/config/params.php @@ -5,7 +5,7 @@ return [ 'supportEmail' => 'rocho02@gmail.com', 'infoEmail' => 'info@rocho-net.hu', 'user.passwordResetTokenExpire' => 3600, - 'version' => 'v0.1.24', + 'version' => 'v0.1.25', 'company' => 'movar',//gyor 'company_name' => "Freimann Kft.", 'product_visiblity' => 'account',// on reception which products to display. account or global