add some key_required property related fix

This commit is contained in:
Roland Schneider 2017-03-23 18:29:29 +01:00
parent 57e578540c
commit 2b5f5f60fd
2 changed files with 14 additions and 11 deletions

View File

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

View File

@ -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 = "