fix update card
This commit is contained in:
parent
409532b664
commit
55afb5de62
@ -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 "
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user