diff --git a/common/models/Product.php b/common/models/Product.php index 3113161..6be0861 100644 --- a/common/models/Product.php +++ b/common/models/Product.php @@ -48,12 +48,14 @@ class Product extends \common\models\BaseFitnessActiveRecord { [['product_number', 'barcode'], 'string', 'max' => 20], [['name'], 'string', 'max' => 128], [['description'], 'string', 'max' => 255], - [['product_number'], 'unique' ], - [['barcode'], 'unique' ], +// [['product_number'], 'unique' ], +// [['barcode'], 'unique' ], // a1 and a2 need to be unique together, only a1 will receive error message // ['a1', 'unique', 'targetAttribute' => ['a1', 'a2']] + [['barcode','product_number'], 'filter', 'filter' => function($value){return Helper::fixAsciiChars($value);}], ['barcode', 'unique', 'targetAttribute' => ['id_account', 'barcode']], ['product_number', 'unique', 'targetAttribute' => ['id_account', 'product_number']], + ]; } diff --git a/common/models/Ticket.php b/common/models/Ticket.php index 0079d76..52357e9 100644 --- a/common/models/Ticket.php +++ b/common/models/Ticket.php @@ -165,10 +165,11 @@ class Ticket extends \common\models\BaseFitnessActiveRecord $query = Ticket::find(); $today = date('Y-m-d'); - $query->andWhere(['id_card' => $card->id_card]); - $query->andWhere( 'start <= :today' ,[ 'today' => $today] ); - $query->andWhere( 'end >= :today' ,[ 'today' => $today] ); - $query->orderBy([ "created_at" =>SORT_DESC] ); + $query->andWhere(['ticket.id_card' => $card->id_card]); + $query->andWhere( 'ticket.start <= :today' ,[ 'today' => $today] ); + $query->andWhere( 'ticket.end >= :today' ,[ 'today' => $today] ); + $query->andWhere( 'ticket.status = :status' ,[ 'status' => Ticket::STATUS_ACTIVE] ); + $query->orderBy([ "ticket.created_at" =>SORT_DESC] ); $result = $query->all(); return $result;