fix barcodue uniqe on admin , ticket use status=active , when checking

This commit is contained in:
2016-01-16 19:02:06 +01:00
parent fbb2d7e5dc
commit 614de5ff1b
2 changed files with 9 additions and 6 deletions

View File

@@ -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']],
];
}

View File

@@ -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;