diff --git a/backend/controllers/CardController.php b/backend/controllers/CardController.php index 78b57de..717359b 100644 --- a/backend/controllers/CardController.php +++ b/backend/controllers/CardController.php @@ -130,7 +130,7 @@ class CardController extends \backend\controllers\BackendController { ] ); } } else { - return $this->render ( 'create', [ + return $this->render ( 'create', [ 'model' => $model ] ); } @@ -269,7 +269,7 @@ class CardController extends \backend\controllers\BackendController { $i++; }else{ // $failed [] = $item; - $sql = "insert into card (number,status,type,created_at,updated_at, rfid_key) values("; + $sql = "insert into card (number,status,type,created_at,updated_at, rfid_key) values( "; $sql .= " '" .$item['number'] . "'" ; $sql .= " ," . Card::STATUS_ACTIVE ; $sql .= " ," . Card::TYPE_RFID; @@ -383,7 +383,6 @@ class CardController extends \backend\controllers\BackendController { public function actionRecalculate(){ - if (Yii::$app->request->isPost) { $connection = \Yii::$app->db; $command = $connection->createCommand( Ticket::$SQL_UPDATE ); @@ -395,14 +394,18 @@ class CardController extends \backend\controllers\BackendController { $result = $command->execute(); \Yii::info("Door flag cleared: " . $result ); - $command = $connection->createCommand( Card::$SQL_FIX_KEY_STATUS ); - $result = $command->execute(); - \Yii::info("Key flag fixed: " . $result ); - - - + if ( Helper::isKeyRequired()){ + \Yii::info("Fixing flag key " ); + $command = $connection->createCommand( Card::$SQL_FIX_KEY_STATUS ); + $result = $command->execute(); + \Yii::info("Fixing flag key ready: " . $result ); + }else{ + \Yii::info("Clearing flag key " ); + $command = $connection->createCommand( Card::$SQL_CLEAR_KEY_STATUS ); + $result = $command->execute(); + \Yii::info("Clearing flag key ready: " . $result ); + } } - return $this->render("recalculate"); } diff --git a/common/models/Card.php b/common/models/Card.php index 9e7f654..9286ba3 100644 --- a/common/models/Card.php +++ b/common/models/Card.php @@ -58,7 +58,7 @@ class Card extends \common\models\BaseFitnessActiveRecord "; public static $SQL_CLEAR_KEY_STATUS = " - UPDATE card set flag = ( flag & ~(1 << 2 ) ) WHERE card.type <> 50 and card.id_card = :id + UPDATE card set flag = ( flag & ~(1 << 2 ) ) WHERE card.type <> 50 "; public static $SQL_CLEARS_STATUS_DOOR_IN = "