diff --git a/common/components/Helper.php b/common/components/Helper.php index 58039ed..54fc469 100644 --- a/common/components/Helper.php +++ b/common/components/Helper.php @@ -344,6 +344,10 @@ class Helper { public static function isUserCartOn() { return \Yii::$app->params ['user_cart_on'] == true; } + + public static function isKeyRequired() { + return \Yii::$app->params ['key_required'] == true; + } public static function getProductSaleDefaultFocus() { return \Yii::$app->params ['product_sale_default_focus'] ; diff --git a/common/config/params.php b/common/config/params.php index cc00494..77da009 100644 --- a/common/config/params.php +++ b/common/config/params.php @@ -58,6 +58,7 @@ return [ /** * if true, key in/out events will generate doorlog events */ - 'key_toggle_door_log_enabled' => false - + 'key_toggle_door_log_enabled' => false, + //if key required for entry trough the door + 'key_required' => true ]; diff --git a/common/models/Card.php b/common/models/Card.php index a484d8a..9e7f654 100644 --- a/common/models/Card.php +++ b/common/models/Card.php @@ -57,6 +57,10 @@ class Card extends \common\models\BaseFitnessActiveRecord WHERE c1.type <> 50 "; + public static $SQL_CLEAR_KEY_STATUS = " + UPDATE card set flag = ( flag & ~(1 << 2 ) ) WHERE card.type <> 50 and card.id_card = :id + "; + public static $SQL_CLEARS_STATUS_DOOR_IN = " UPDATE card set flag = ( flag & ~(1 << 1 ) ) WHERE card.type <> 50 and card.id_card = :id "; @@ -239,9 +243,14 @@ class Card extends \common\models\BaseFitnessActiveRecord } public function setFlagsHasKey($hasKey){ - $this->flag = $hasKey ? ( $this->flag & ~(1 << Card::$FLAG_KEY) ) : ( $this->flag | 1 << Card::$FLAG_KEY ); - $this->flag_out = $hasKey ? ( $this->flag_out | 1 << Card::$FLAG_KEY ) : ( $this->flag_out & ~(1 << Card::$FLAG_KEY) ); - /** @noinspection PhpUndefinedClassInspection */ + if (Helper::isKeyRequired()){ + $this->flag = $hasKey ? ( $this->flag & ~(1 << Card::$FLAG_KEY) ) : ( $this->flag | 1 << Card::$FLAG_KEY ); + $this->flag_out = $hasKey ? ( $this->flag_out | 1 << Card::$FLAG_KEY ) : ( $this->flag_out & ~(1 << Card::$FLAG_KEY) ); + /** @noinspection PhpUndefinedClassInspection */ + }else{ + $this->flag = ( $this->flag & ~(1 << Card::$FLAG_KEY) ); + $this->flag_out = ( $this->flag_out & ~(1 << Card::$FLAG_KEY) ); + } \Yii::info("flag has key: ".$this->flag .";".$this->flag_out); } diff --git a/console/controllers/TicketController.php b/console/controllers/TicketController.php index a063c97..cfe81ec 100644 --- a/console/controllers/TicketController.php +++ b/console/controllers/TicketController.php @@ -29,9 +29,17 @@ class TicketController extends Controller { $result = $command->execute (); \Yii::info ( "Tickets updated: " . $result ); - - $command = $connection->createCommand ( Card::$SQL_FIX_KEY_STATUS ); - $result = $command->execute (); + if ( Helper::isKeyRequired() ){ + \Yii::info ( "Fixing key status" ); + $command = $connection->createCommand ( Card::$SQL_FIX_KEY_STATUS ); + $result = $command->execute (); + \Yii::info ( "Fixing key status updated: " . $result ); + }else{ + \Yii::info ( "Clearing key status" ); + $command = $connection->createCommand ( Card::$SQL_CLEAR_KEY_STATUS ); + $result = $command->execute (); + \Yii::info ( "Clearing key status updated: ". $result ); + } } /** @@ -168,10 +176,8 @@ class TicketController extends Controller { \Yii::info("Hírlevél küldése " .count($subscribers) . " előfizetőnek!" ); - $i = 0; - + foreach ($newsletters as $newsletter ){ - $i = 0; Log::logC([ 'type' => Log::$TYPE_NEWSLETTER_SEND_START, 'message' => "Hírlevél küldés indítása[id_newsletter=" . $newsletter->id_newsletter ."]" @@ -217,8 +223,6 @@ class TicketController extends Controller { }catch (\Exception $ex){ \Yii::error("Nem sikerült hírlevelet kikülden: Hírlevél azonosító=" .$newsletter->id_newsletter. ";Előfizető azonosító ". $subscriber->id_subscriber ) ; } - - $i++; } $newsletter->sent = Newsletter::$SENT_TRUE; $newsletter->sent_at = Helper::getDateTimeString();