From 5d847e25383816148a9a5688c93e5d9bebcc888c Mon Sep 17 00:00:00 2001 From: Roland Schneider Date: Mon, 20 Apr 2020 09:10:18 +0200 Subject: [PATCH 1/5] add coronavirus activate/inactivate --- backend/components/AdminMenuStructure.php | 12 ++ backend/controllers/CustomerController.php | 61 +++++++- backend/models/CustomerActivateForm.php | 65 +++++++++ backend/models/CustomerInactivateForm.php | 56 ++++++++ backend/views/customer/activate.php | 46 ++++++ backend/views/customer/inactivate.php | 57 ++++++++ common/models/Card.php | 18 ++- common/models/Ticket.php | 13 +- .../m200418_053358_add_active_fields.php | 43 ++++++ frontend/controllers/CustomerController.php | 21 ++- .../models/SingleCustomerActivateForm.php | 134 ++++++++++++++++++ frontend/views/common/_reception_ticket.php | 11 ++ frontend/views/customer/activate.php | 101 +++++++++++++ 13 files changed, 628 insertions(+), 10 deletions(-) create mode 100644 backend/models/CustomerActivateForm.php create mode 100644 backend/models/CustomerInactivateForm.php create mode 100644 backend/views/customer/activate.php create mode 100644 backend/views/customer/inactivate.php create mode 100644 console/migrations/m200418_053358_add_active_fields.php create mode 100644 frontend/models/SingleCustomerActivateForm.php create mode 100644 frontend/views/customer/activate.php diff --git a/backend/components/AdminMenuStructure.php b/backend/components/AdminMenuStructure.php index df3b8e2..cc46a7c 100644 --- a/backend/components/AdminMenuStructure.php +++ b/backend/components/AdminMenuStructure.php @@ -152,6 +152,18 @@ class AdminMenuStructure{ $this->menuItems[] = ['label' => 'Hírlevél', 'url' => $this->emptyUrl, 'items' => $items ]; + + + ///////////////////////////// + // Korona vírus + ///////////////////////////// + $items = []; + $items[] = ['label' => 'Inaktiválás', 'url' => ['/customer/inactivate' ] ]; + $items[] = ['label' => 'Aktiválás', 'url' => ['/customer/activate' ] ]; + $this->menuItems[] = ['label' => 'Koronavírus', 'url' => $this->emptyUrl, + 'items' => $items + ]; + ///////////////////////////// // Development ///////////////////////////// diff --git a/backend/controllers/CustomerController.php b/backend/controllers/CustomerController.php index 53d524a..5ad6930 100644 --- a/backend/controllers/CustomerController.php +++ b/backend/controllers/CustomerController.php @@ -2,10 +2,13 @@ namespace backend\controllers; +use backend\models\CustomerActivateForm; +use backend\models\CustomerInactivateForm; use Yii; use common\models\Customer; use backend\models\CustomerSearch; use backend\models\CustomerCreate; +use yii\filters\AccessControl; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; @@ -27,21 +30,71 @@ class CustomerController extends \backend\controllers\BackendController { return [ 'access' => [ - 'class' => \yii\filters\AccessControl::className(), + 'class' => AccessControl::className(), 'rules' => [ // allow authenticated users [ - 'actions' => ['create','index','view','update','mail'], + 'actions' => ['create','index','view','update','mail' ], 'allow' => true, 'roles' => ['admin','employee','reception'], + ],// allow authenticated users + [ + 'actions' => ['inactivate','activate'], + 'allow' => true, + 'roles' => ['admin','employee'], ], // everything else is denied ], ], ]; } - - + + + /** + * Inactivate all card: + * set card.status to 20 and update card.flag + * @return string + */ + public function actionInactivate(){ + + $form = new CustomerInactivateForm(); + + $form->loadActiveCardCount(); + + $form->inactivateDate = date('Y.m.d'); + + + if ( $form->load(Yii::$app->request->post()) && $form->inactivate() ){ + // redirect ? + } + + return $this->render('inactivate', [ + 'model' => $form + ]); + } + + /** + * Activate all inactive cards. + * Set + * ticket.end + * card.status and card.flag + * + * @return string + */ + public function actionActivate(){ + + $form = new CustomerActivateForm(); + + $form->loadActiveCardCount(); + if ( Yii::$app->request->isPost && $form->activate()){ + // redirect + } + + return $this->render('activate', [ + 'model' => $form + ]); + } + /** * Lists all Customer models. * @return mixed diff --git a/backend/models/CustomerActivateForm.php b/backend/models/CustomerActivateForm.php new file mode 100644 index 0000000..ed1bb73 --- /dev/null +++ b/backend/models/CustomerActivateForm.php @@ -0,0 +1,65 @@ +inactiveCardCount = Card::find()->andWhere( + ['status' => Card::STATUS_INACTIVE] + )->count(); + } + + /** + * @return bool + * @throws \Exception + */ + public function activate(){ + if ( !$this->validate()){ + return false; + } + + $tx = \Yii::$app->db->beginTransaction(); + assert(isset($tx)); + try{ + Yii::$app->db->createCommand(Ticket::$SQL_UPDATE_TICKETS_END_DATE_ON_CARD_ACTIVATION )->execute(); + Card::updateAll( + [ + 'status' => Card::STATUS_ACTIVE, + 'end' => 'date_add( end, INTERVAL datediff(current_date, c.inactivated_at) DAY )' + ], + [ + 'status' => Card::STATUS_INACTIVE + ] + ); + + + Card::updateFlagStatus(); + $tx->commit(); + }catch (\Exception $exception){ + $tx->rollBack(); + throw $exception; + } + $this->message = $this->inactiveCardCount ." kártya aktiválva" ; + return true; + } + +} diff --git a/backend/models/CustomerInactivateForm.php b/backend/models/CustomerInactivateForm.php new file mode 100644 index 0000000..6fe6053 --- /dev/null +++ b/backend/models/CustomerInactivateForm.php @@ -0,0 +1,56 @@ + 'timestampInactivate' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], + + ]; + } + + + public function loadActiveCardCount(){ + $this->activeCardCount = Card::find()->andWhere( + ['status' => Card::STATUS_ACTIVE] + )->count(); + } + + public function inactivate(){ + if ( !$this->validate()){ + return false; + } + Card::updateAll( + [ + 'status' => Card::STATUS_INACTIVE, + 'inactivated_at' => $this->timestampInactivate + ], + [ + 'status' => Card::STATUS_ACTIVE + ] + ); + Card::updateFlagStatus(); + \Yii::$app->session->setFlash ( 'success', 'Kártyák inaktiválva' ); + $this->message = $this->activeCardCount ." kártya inkatválva a köveztekző dátummal: " . $this->inactivateDate ; + return true; + } + +} diff --git a/backend/views/customer/activate.php b/backend/views/customer/activate.php new file mode 100644 index 0000000..e159246 --- /dev/null +++ b/backend/views/customer/activate.php @@ -0,0 +1,46 @@ + + +

Aktiválás

+ + +message) ) {?> + + +
+ + + +
+

+ inactiveCardCount ?> kártya aktiválása +

+ + +
+
+ 'btn btn-success']) ?> +
+
+ +
+ + + +
+ + + + diff --git a/backend/views/customer/inactivate.php b/backend/views/customer/inactivate.php new file mode 100644 index 0000000..bd04839 --- /dev/null +++ b/backend/views/customer/inactivate.php @@ -0,0 +1,57 @@ + + +

Inaktiválás

+ + +message) ) {?> + + +
+ + + +
+

+ activeCardCount ?> kártya inaktiválása +

+ +
+
+ field($model, 'inactivateDate') ->widget(\kartik\widgets\DatePicker::classname(), [ + 'pluginOptions' => [ + 'autoclose'=>true, + 'format' => 'yyyy.mm.dd' + ] + ])->label("Inaktiválási dátum") ?> +
+
+ + +
+
+ 'btn btn-danger']) ?> +
+
+ +
+ + + +
+ + + + diff --git a/common/models/Card.php b/common/models/Card.php index 9484821..03c2ca9 100644 --- a/common/models/Card.php +++ b/common/models/Card.php @@ -20,13 +20,15 @@ use common\components\Helper; * @property int flag_out * @property \common\models\Customer $customer relation * @property mixed validity + * @property string inactivated_at */ class Card extends \common\models\BaseFitnessActiveRecord { const STATUS_DELETED = 0; const STATUS_ACTIVE = 10; - + const STATUS_INACTIVE = 20; + const TYPE_RFID = 10; const TYPE_QRCODE = 20; const TYPE_BARCODE = 30; @@ -75,6 +77,11 @@ class Card extends \common\models\BaseFitnessActiveRecord } + public static $SQL_UPDATE_FLAG_STATUS_ACTIVE = ' + update card set flag = CASE WHEN status = 20 then (flag | 1 << 3) else ( flag & ~(1 << 3 ) ) end +'; + + /** * @inheritdoc */ @@ -128,8 +135,9 @@ class Card extends \common\models\BaseFitnessActiveRecord static function statuses() { /** @noinspection PhpUndefinedClassInspection */ return [ - self::STATUS_ACTIVE => Yii::t('common/card', 'Active'), - self::STATUS_DELETED => Yii::t('common/card', 'Inactive'), + self::STATUS_ACTIVE => 'Aktív', + self::STATUS_DELETED => 'Törölve', + self::STATUS_INACTIVE => 'Inaktív', ]; } @@ -305,4 +313,8 @@ class Card extends \common\models\BaseFitnessActiveRecord return Helper::isBitOn($this->flag,Card::$FLAG_DOOR_ALLOWED); } + public static function updateFlagStatus(){ + \Yii::$app->db->createCommand(self::$SQL_UPDATE_FLAG_STATUS_ACTIVE)->execute(); + } + } diff --git a/common/models/Ticket.php b/common/models/Ticket.php index c655af8..3ea89c0 100644 --- a/common/models/Ticket.php +++ b/common/models/Ticket.php @@ -62,7 +62,8 @@ class Ticket extends \common\models\BaseFitnessActiveRecord -- first bit is 0 when there is a ticket or 'employee' card 0000 0000 -- first bit is 1 when there is no ticket and card type is not 'employee' , c1.flag = case when c1.type = 50 then ( c1.flag & ~(1 << 0) ) when t.id_card is null then ( c1.flag | 1 << 0 ) else ( c1.flag & ~(1 << 0) ) end - , c1.id_ticket_current = case when t.id_ticket is null then null else t.id_ticket end"; + , c1.id_ticket_current = case when t.id_ticket is null then null else t.id_ticket end + where c1.status = 10"; public static $SQL_UPDATE_CARD = "UPDATE card as c1 left JOIN ( select ticket.id_card as id_card , max(ticket.id_ticket) as id_ticket @@ -79,10 +80,18 @@ class Ticket extends \common\models\BaseFitnessActiveRecord SET c1.validity = case when c1.type = 50 then ( c1.validity & ~(1 << 0) ) when t.id_card is null then ( c1.validity | 1 << 0 ) else ( c1.validity & ~(1 << 0) ) end ,c1.flag = case when c1.type = 50 then ( c1.flag & ~(1 << 0) ) when t.id_card is null then ( c1.flag | 1 << 0 ) else ( c1.flag & ~(1 << 0) ) end , c1.id_ticket_current = case when t.id_ticket is null then null else t.id_ticket end - WHERE c1.id_card = :id"; + WHERE c1.status = 10 and c1.id_card = :id"; + public static $SQL_UPDATE_TICKETS_END_DATE_ON_CARD_ACTIVATION = "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) or (t.start >= c.inactivated_at)) ;"; + public static function SQL_UPDATE_DOOR_ALLOWED_FLAG(){ return " UPDATE card c diff --git a/console/migrations/m200418_053358_add_active_fields.php b/console/migrations/m200418_053358_add_active_fields.php new file mode 100644 index 0000000..c46797c --- /dev/null +++ b/console/migrations/m200418_053358_add_active_fields.php @@ -0,0 +1,43 @@ +addColumn('card', 'inactivated_at',$this->date() ); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + echo "m200418_053358_add_active_fields cannot be reverted.\n"; + + return false; + } + + /* + // Use up()/down() to run migration code without a transaction. + public function up() + { + + } + + public function down() + { + echo "m200418_053358_add_active_fields cannot be reverted.\n"; + + return false; + } + */ +} diff --git a/frontend/controllers/CustomerController.php b/frontend/controllers/CustomerController.php index 8605438..89f5663 100644 --- a/frontend/controllers/CustomerController.php +++ b/frontend/controllers/CustomerController.php @@ -2,6 +2,8 @@ namespace frontend\controllers; +use backend\models\CustomerActivateForm; +use frontend\models\SingleCustomerActivateForm; use frontend\models\TowelForm; use Yii; use common\models\Customer; @@ -35,7 +37,7 @@ class CustomerController extends Controller ], 'access' => [ 'class' => \yii\filters\AccessControl::className(), - 'only' => ['create', 'update','reception','contract','towel'], + 'only' => ['create', 'update','reception','contract','towel','activate'], 'rules' => [ // allow authenticated users [ @@ -49,6 +51,23 @@ class CustomerController extends Controller ]; } + public function actionActivate($number = "") + { + $model = new ReceptionForm(); + $model->number = $number; + $model->readCard(); + + $form = new SingleCustomerActivateForm( ); + $form->number = $number; + $form->validate(); + $ticketsDataProvider = $form->loadTicketsDataProvider(); + + if (\Yii::$app->request->isPost && $form->activate()) { + return $this->redirect(['customer/activate', 'number' => $number]); + } + return $this->render('activate', ['model' => $model, 'formModel' => $form, 'ticketsDataProvider' => $ticketsDataProvider]); + } + public function actionReception($number = ""){ $model = new ReceptionForm(); diff --git a/frontend/models/SingleCustomerActivateForm.php b/frontend/models/SingleCustomerActivateForm.php new file mode 100644 index 0000000..e2fea27 --- /dev/null +++ b/frontend/models/SingleCustomerActivateForm.php @@ -0,0 +1,134 @@ +card = Card::readCard($this->number); + + $query = new Query(); + + $this->daysPassed = $query + ->select( + [ + 'datediff(current_date, card.inactivated_at ) ' + ] + ) + ->from(Card::tableName()) + ->andWhere(['id_card' => $this->card->id_card]) + ->scalar(); + + $query = new Query(); + $this->tickets = $query + ->select( + [ + 'ticket.id_ticket as id_ticket', + 'ticket.start as start', + 'ticket.end as end', + 'ticket.created_at as created_at', + 'ticket.usage_count as usage_count', + 'ticket.max_usage_count as max_usage_count', + 'date_add( ticket.end, INTERVAL datediff(current_date, card.inactivated_at) DAY ) as end2' + ] + ) + ->from(Ticket::tableName()) + ->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( + [ + 'ticket.start' => SORT_DESC + ] + ) + ->all(); + + } + + public function loadTicketsDataProvider() + { + $this->loadTicketsToActivate(); + return new ArrayDataProvider( + [ + 'allModels' => $this->tickets, + 'sort' => false, + 'pagination' => false + ] + ); + } + + /** + * @return bool + * @throws \Exception + */ + public function activate() + { + if (!$this->validate()) { + return false; + } + + $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(); + Card::updateAll( + [ + 'status' => Card::STATUS_ACTIVE, + ], + [ + 'status' => Card::STATUS_INACTIVE, + 'id_card' => $this->card->id_card + ] + ); + Card::updateFlagStatus(); + $tx->commit(); + } catch (\Exception $exception) { + $tx->rollBack(); + throw $exception; + } + Yii::$app->session->setFlash('success', 'Kártya aktiválva'); + return true; + } + +} diff --git a/frontend/views/common/_reception_ticket.php b/frontend/views/common/_reception_ticket.php index ce53b97..b6f260e 100644 --- a/frontend/views/common/_reception_ticket.php +++ b/frontend/views/common/_reception_ticket.php @@ -17,6 +17,17 @@ if (count($model->tickets) > 0) { $ticket = $model->tickets[0]; } +if ( isset($model,$model->card)){ + if ( $model->card->status == \common\models\Card::STATUS_INACTIVE ){ + echo Html::beginTag("div", ['class' => "alert alert-danger", "role" => "alert"]); + echo Html::beginTag("strong", []); + echo "A vendég inaktív!"; + echo Html::a("Aktiválás", ["customer/activate",'number' => $model->card->number ]); + echo Html::endTag("strong"); + echo Html::endTag("div"); + } +} + if (isset($model->card)) { if (isset($model->customer)) { if ($model->card->validity == 0) { diff --git a/frontend/views/customer/activate.php b/frontend/views/customer/activate.php new file mode 100644 index 0000000..90b5e32 --- /dev/null +++ b/frontend/views/customer/activate.php @@ -0,0 +1,101 @@ +

Recepció

+ + $model, 'route' => ['customer/reception']]) ?> +

Aktiválás

+ + +card->status == Card::STATUS_INACTIVE) { ?> +
+ + + +
+ +
+
+ Inaktiválási dátum: +
+
+ formatter->asDate($formModel->card->inactivated_at) ?> +
+ +
+
+
+ Eltelt napok: +
+
+ daysPassed ?> +
+ +
+ + $ticketsDataProvider, + 'columns' => [ + + [ + 'attribute' => 'id_ticket', + 'label' => 'Bérlet Azonosító' + ], + [ + 'attribute' => 'created_at', + 'label' => 'Vásárlás ideje', + 'format' => 'datetime' + ], + [ + 'attribute' => 'start', + 'label' => 'Érvényesség kezdete', + 'format' => 'date' + ], + [ + 'attribute' => 'end', + 'label' => 'Érvényesség vége', + 'format' => 'date' + ], + [ + 'attribute' => 'max_usage_count', + 'label' => 'Max alkalmak' + ], + [ + 'attribute' => 'usage_count', + 'label' => 'Felhasznált alkalmak' + ], + [ + 'attribute' => 'end2', + 'label' => 'Új Érvényesség vége', + 'format' => 'date' + ], + + ], + ]); ?> + + +
+
+ 'btn btn-success']) ?> +
+
+ +
+ + + +
+ + + + From 9d861a91940eeb5bd6f00414fd85f9a3f4296752 Mon Sep 17 00:00:00 2001 From: Roland Schneider Date: Mon, 20 Apr 2020 22:11:29 +0200 Subject: [PATCH 2/5] add coronavirus activate/inactivate --- backend/models/CustomerActivateForm.php | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/models/CustomerActivateForm.php b/backend/models/CustomerActivateForm.php index ed1bb73..b7a915a 100644 --- a/backend/models/CustomerActivateForm.php +++ b/backend/models/CustomerActivateForm.php @@ -44,7 +44,6 @@ class CustomerActivateForm extends Model{ Card::updateAll( [ 'status' => Card::STATUS_ACTIVE, - 'end' => 'date_add( end, INTERVAL datediff(current_date, c.inactivated_at) DAY )' ], [ 'status' => Card::STATUS_INACTIVE From 806501fbd638447245e42c97ce3da6041cc4ab43 Mon Sep 17 00:00:00 2001 From: Roland Schneider Date: Wed, 22 Apr 2020 22:13:36 +0200 Subject: [PATCH 3/5] update card after activate --- backend/models/CustomerActivateForm.php | 31 +++++++++---------- .../models/SingleCustomerActivateForm.php | 10 ++++-- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/backend/models/CustomerActivateForm.php b/backend/models/CustomerActivateForm.php index b7a915a..c888315 100644 --- a/backend/models/CustomerActivateForm.php +++ b/backend/models/CustomerActivateForm.php @@ -33,32 +33,29 @@ class CustomerActivateForm extends Model{ * @throws \Exception */ public function activate(){ - if ( !$this->validate()){ + if (!$this->validate()) { return false; } $tx = \Yii::$app->db->beginTransaction(); assert(isset($tx)); - try{ - Yii::$app->db->createCommand(Ticket::$SQL_UPDATE_TICKETS_END_DATE_ON_CARD_ACTIVATION )->execute(); - Card::updateAll( - [ - 'status' => Card::STATUS_ACTIVE, - ], - [ - 'status' => Card::STATUS_INACTIVE - ] - ); + try { + // update ticket end dates + Yii::$app->db->createCommand(Ticket::$SQL_UPDATE_TICKETS_END_DATE_ON_CARD_ACTIVATION)->execute(); + // update card.status + Card::updateAll([ 'status' => Card::STATUS_ACTIVE, ], [ 'status' => Card::STATUS_INACTIVE ] ); + // update card.flag + Card::updateFlagStatus(); + // update ticket + \Yii::$app->db->createCommand(Ticket::$SQL_UPDATE)->execute(); - - Card::updateFlagStatus(); - $tx->commit(); - }catch (\Exception $exception){ + $tx->commit(); + } catch (\Exception $exception) { $tx->rollBack(); throw $exception; } - $this->message = $this->inactiveCardCount ." kártya aktiválva" ; - return true; + $this->message = $this->inactiveCardCount . " kártya aktiválva"; + return true; } } diff --git a/frontend/models/SingleCustomerActivateForm.php b/frontend/models/SingleCustomerActivateForm.php index e2fea27..0b623f2 100644 --- a/frontend/models/SingleCustomerActivateForm.php +++ b/frontend/models/SingleCustomerActivateForm.php @@ -6,6 +6,7 @@ namespace frontend\models; use common\models\Card; use common\models\Ticket; +use Exception; use Yii; use yii\base\Model; use yii\data\ArrayDataProvider; @@ -98,7 +99,7 @@ class SingleCustomerActivateForm extends Model{ /** * @return bool - * @throws \Exception + * @throws Exception */ public function activate() { @@ -106,7 +107,7 @@ class SingleCustomerActivateForm extends Model{ return false; } - $tx = \Yii::$app->db->beginTransaction(); + $tx = Yii::$app->db->beginTransaction(); assert(isset($tx)); try { @@ -122,8 +123,11 @@ class SingleCustomerActivateForm extends Model{ ] ); Card::updateFlagStatus(); + + Card::updateCardFlagTicket( $this->card->id_card); + $tx->commit(); - } catch (\Exception $exception) { + } catch (Exception $exception) { $tx->rollBack(); throw $exception; } From 6befccd346dbcda36cb1eacc9a1e588a25759cf6 Mon Sep 17 00:00:00 2001 From: Roland Schneider Date: Wed, 22 Apr 2020 22:22:07 +0200 Subject: [PATCH 4/5] update card after activate --- changelog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.txt b/changelog.txt index a55fef1..89216df 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,5 @@ +-0.1.24 + - add activate/incativate card for coronavirus -0.1.23 - fix fingerprint frontend gui -0.1.22 From 6e3e711084335659c7324420b732866dabd832d8 Mon Sep 17 00:00:00 2001 From: Roland Schneider Date: Wed, 22 Apr 2020 22:22:26 +0200 Subject: [PATCH 5/5] change version to 1.24 --- common/config/params.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/config/params.php b/common/config/params.php index 5e7a7d2..f6acb14 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.23', + 'version' => 'v0.1.24', 'company' => 'movar',//gyor 'company_name' => "Freimann Kft.", 'product_visiblity' => 'account',// on reception which products to display. account or global