add app param 'key_required'

This commit is contained in:
Roland Schneider 2017-03-22 07:55:12 +01:00
parent 59f6b32e7c
commit 57e578540c
4 changed files with 31 additions and 13 deletions

View File

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

View File

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

View File

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

View File

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