Finish version/v0.0.68
This commit is contained in:
commit
77657390c3
@ -14,6 +14,7 @@ use yii\web\UploadedFile;
|
||||
use yii\data\ArrayDataProvider;
|
||||
use yii\db\Query;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\MessageDetsta;
|
||||
|
||||
/**
|
||||
* UgiroController implements the CRUD actions for Ugiro model.
|
||||
@ -97,6 +98,7 @@ class UgiroController extends Controller {
|
||||
'koteg' => $model
|
||||
] );
|
||||
$processor->run ();
|
||||
$this->redirect(['view', 'id' => $model->id_ugiro]);
|
||||
} else {
|
||||
\Yii::$app->session->setFlash ( 'danger', 'Nem lehet futtatni a fájlt' );
|
||||
\Yii::error ( "a koteg státusza nem STATUS_RECIEVED. A koteg azonosíótja:" . $model->id_ugiro );
|
||||
@ -111,8 +113,19 @@ class UgiroController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
$query = MessageDetsta::find();
|
||||
$query->andWhere(['id_ugiro' => $model->id_ugiro]);
|
||||
$query->orderBy([ 'created_at' => SORT_ASC ]);
|
||||
|
||||
$detstaDp = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
'pagination' => false,
|
||||
'sort' => false
|
||||
]);
|
||||
|
||||
return $this->render ( 'view', [
|
||||
'model' => $this->findModel ( $id )
|
||||
'model' => $this->findModel ( $id ) ,
|
||||
'detstaDp' => $detstaDp
|
||||
] );
|
||||
}
|
||||
protected function downloadUgiro($model) {
|
||||
|
||||
@ -6,6 +6,8 @@ use yii\base\Model;
|
||||
use yii\web\UploadedFile;
|
||||
use common\components\giro\GiroDETSTA;
|
||||
use common\models\Ugiro;
|
||||
use common\components\DetStatProcessor;
|
||||
use common\components\Helper;
|
||||
|
||||
class DestaUploadForm extends Model
|
||||
{
|
||||
@ -41,26 +43,62 @@ class DestaUploadForm extends Model
|
||||
$this->koteg = $koteg;
|
||||
if (!isset($koteg)){
|
||||
$this->addError($attribute,"Nincs ilyen köteg! ( Datum: $datum, Sorszam: $number )");
|
||||
}else{
|
||||
if ( $koteg->status != Ugiro::$STATUS_SENT ){
|
||||
$idKoteg = $this->koteg->id_ugiro;
|
||||
$this->addError($attribute,"A köteg detsta fájl-ja már fel van töltve !( Köteg azonosító: $idKoteg )");
|
||||
}
|
||||
}
|
||||
|
||||
// else{
|
||||
// if ( $koteg->status != Ugiro::$STATUS_SENT ){
|
||||
// $idKoteg = $this->koteg->id_ugiro;
|
||||
// $this->addError($attribute,"A köteg detsta fájl-ja már fel van töltve !( Köteg azonosító: $idKoteg )");
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// public function saveMessageDetsta($filename){
|
||||
// $uzenetSzoveg = $this->readDetstaUzenet($filename);
|
||||
// $saver = new DetStaDBSave(
|
||||
// [
|
||||
// 'giroDETSTA' => $this->detstatUzenet,
|
||||
// 'koteg' => $this->koteg,
|
||||
// 'idUser' =>\Yii::$app->user->id
|
||||
// ]);
|
||||
// $saver->run();
|
||||
// }
|
||||
|
||||
|
||||
// public function readDetstaUzenet($filename){
|
||||
|
||||
// // $filename = \Yii::getAlias("@webroot") ."/" .$this->koteg->desta_path;
|
||||
// $content = file_get_contents($filename);
|
||||
// return GiroDETSTA::parse($content);
|
||||
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
public function upload()
|
||||
{
|
||||
if ($this->validate()) {
|
||||
$path = 'giro/valasz/' . $this->destaFile->baseName . '.' . $this->destaFile->extension;
|
||||
$this->destaFile->saveAs( $path );
|
||||
$this->koteg->desta_path = $path;
|
||||
$this->koteg->status = Ugiro::$STATUS_RECIEVED;
|
||||
$this->koteg->save(false);
|
||||
|
||||
|
||||
set_time_limit ( 1200 ); // 20 perc
|
||||
$processor = new DetStatProcessor( [
|
||||
'koteg' => $this->koteg,
|
||||
'path' => $path
|
||||
] );
|
||||
$processor->run ();
|
||||
|
||||
Helper::flash("success", "Detsta fájl feldolgozva!");
|
||||
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@ -5,6 +5,9 @@ use yii\widgets\DetailView;
|
||||
use yii\helpers\Url;
|
||||
use common\models\Ugiro;
|
||||
use yii\widgets\ActiveForm;
|
||||
use yii\grid\GridView;
|
||||
use yii\base\Widget;
|
||||
use yii\grid\ActionColumn;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Ugiro */
|
||||
@ -68,14 +71,14 @@ $attributes = [
|
||||
|
||||
|
||||
|
||||
if ( $model->status == Ugiro::$STATUS_RECIEVED || $model->status == Ugiro::$STATUS_FINISHED ){
|
||||
$attributes[] = [
|
||||
'attribute' => 'desta_path',
|
||||
'label' => 'Detsta Fájl',
|
||||
'value' => Html::a( "Letöltés" , Url::base() ."/". $model->desta_path , ['target' =>'_blank' ,'download' =>'CS-BESZED.' .$model->id_ugiro ] ),
|
||||
'format' => 'raw'
|
||||
];
|
||||
}
|
||||
// if ( $model->status == Ugiro::$STATUS_RECIEVED || $model->status == Ugiro::$STATUS_FINISHED ){
|
||||
// $attributes[] = [
|
||||
// 'attribute' => 'desta_path',
|
||||
// 'label' => 'Detsta Fájl',
|
||||
// 'value' => Html::a( "Letöltés" , Url::base() ."/". $model->desta_path , ['target' =>'_blank' ,'download' =>'CS-BESZED.' .$model->id_ugiro ] ),
|
||||
// 'format' => 'raw'
|
||||
// ];
|
||||
// }
|
||||
|
||||
?>
|
||||
|
||||
@ -85,11 +88,41 @@ $attributes = [
|
||||
'attributes' => $attributes,
|
||||
]) ?>
|
||||
|
||||
|
||||
<h1>Detsta válaszok</h1>
|
||||
<?php
|
||||
echo GridView::widget(
|
||||
[
|
||||
'dataProvider' => $detstaDp,
|
||||
'columns' =>[
|
||||
[
|
||||
'attribute' => 'created_at',
|
||||
'label' => 'Létrehozva'
|
||||
],
|
||||
[
|
||||
'class' => ActionColumn::className() ,
|
||||
'template' =>'{view}',
|
||||
'urlCreator' => function ($action, $model, $key, $index){
|
||||
if ($action == 'view' ){
|
||||
return Url::toRoute(['message-detsta/view','id' => $model->id_message]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
</div>
|
||||
<div class="btns">
|
||||
<?php
|
||||
if ( $model->status == Ugiro::$STATUS_RECIEVED ){
|
||||
echo Html::a("DetSta Fájl Feldoglozás",['view', 'id' => $model->id_ugiro] ,['data-method' =>'post', 'class' => 'btn btn-danger']);
|
||||
//echo Html::a("DetSta Fájl Feldoglozás",['view', 'id' => $model->id_ugiro] ,['data-method' =>'post', 'class' => 'btn btn-danger']);
|
||||
}
|
||||
echo Html::a("Megbízások a kötegben",['ticket-installment-request/index', 'TicketInstallmentRequestSearch[id_ugiro]' => $model->id_ugiro] ,[ 'class' => 'btn btn-primary']);
|
||||
echo Html::a("PDF", Url::current(['output' => 'pdf']) ,[ 'class' => 'btn btn-primary']);
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
-0.0.68
|
||||
- add multi detsta upload
|
||||
- add doorlog console changes
|
||||
-0.0.67
|
||||
- payment later - add customer description
|
||||
-0.0.66
|
||||
|
||||
@ -36,6 +36,8 @@ class DetStaDBSave extends Object
|
||||
/**messagedetsta lab*/
|
||||
public $messageLab;
|
||||
|
||||
public $path;
|
||||
|
||||
/**messagedetsta tetelek*/
|
||||
public $messageTetelek = [];
|
||||
|
||||
@ -56,6 +58,7 @@ class DetStaDBSave extends Object
|
||||
protected function saveMessageDetsta( ) {
|
||||
$this->message = new MessageDetsta();
|
||||
$this->message->id_user = $this->idUser;
|
||||
$this->message->path = $this->path;
|
||||
if ( isset( $this->koteg ) ){
|
||||
$this->message->id_ugiro = $this->koteg->id_ugiro;
|
||||
}
|
||||
|
||||
@ -24,6 +24,8 @@ class DetStatProcessor extends Object{
|
||||
|
||||
/**aktuális koteg, config paraméterként kapju*/
|
||||
public $koteg;
|
||||
public $path;
|
||||
|
||||
public $idKoteg;
|
||||
public $detstatUzenet;
|
||||
public $megbizasok;
|
||||
@ -44,6 +46,7 @@ class DetStatProcessor extends Object{
|
||||
$saver = new DetStaDBSave(
|
||||
[
|
||||
'giroDETSTA' => $this->detstatUzenet,
|
||||
'path' => $this->path,
|
||||
'koteg' => $this->koteg,
|
||||
'idUser' =>\Yii::$app->user->id
|
||||
]);
|
||||
@ -71,7 +74,7 @@ class DetStatProcessor extends Object{
|
||||
|
||||
public function readDetstaUzenet(){
|
||||
|
||||
$filename = \Yii::getAlias("@webroot") ."/" .$this->koteg->desta_path;
|
||||
$filename = \Yii::getAlias("@webroot") ."/" .$this->path;
|
||||
$content = file_get_contents($filename);
|
||||
$this->detstatUzenet = GiroDETSTA::parse($content);
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ return [
|
||||
'supportEmail' => 'rocho02@gmail.com',
|
||||
'infoEmail' => 'info@rocho-net.hu',
|
||||
'user.passwordResetTokenExpire' => 3600,
|
||||
'version' => 'v0.0.67',
|
||||
'version' => 'v0.0.68',
|
||||
'company' => 'movar',//gyor
|
||||
'company_name' => "Freimann Kft.",
|
||||
'product_visiblity' => 'account',// on reception which products to display. account or global
|
||||
|
||||
@ -3,6 +3,7 @@ namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\helpers\VarDumper;
|
||||
|
||||
/**
|
||||
* Login form
|
||||
@ -68,6 +69,8 @@ class LoginForm extends Model
|
||||
if ($this->validate()) {
|
||||
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
|
||||
} else {
|
||||
\Yii::error("Belépés - validáció sikertelen");
|
||||
\Yii::error( $this->getErrors());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -80,10 +83,12 @@ class LoginForm extends Model
|
||||
protected function getUser()
|
||||
{
|
||||
if ($this->_user === null) {
|
||||
\Yii::info("admin login - find user by name...");
|
||||
$this->_user = User::findByUsername($this->username);
|
||||
}
|
||||
|
||||
if ( $this->_user != null ){
|
||||
\Yii::info("Felhasználónév rendben...");
|
||||
if ( $this->roles != null ){
|
||||
$canLogin = false;
|
||||
foreach ($this->roles as $role){
|
||||
@ -91,10 +96,14 @@ class LoginForm extends Model
|
||||
}
|
||||
|
||||
if ( !$canLogin ){
|
||||
\Yii::info("user ".$this->_user->username." has no permission to login to administration area!");
|
||||
\Yii::error("user ".$this->_user->username." has no permission to login to administration area!");
|
||||
$this->_user = null;
|
||||
}else{
|
||||
\Yii::info("user ".$this->_user->username." has permission to login to administration area!");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
\Yii::error("Felhasználó nem található: " .$this->username);
|
||||
}
|
||||
|
||||
return $this->_user;
|
||||
|
||||
@ -59,4 +59,6 @@ class MessageDetsta extends BaseFitnessActiveRecord
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -93,6 +93,11 @@ class Ugiro extends \yii\db\ActiveRecord
|
||||
->viaTable('ugiro_request_assignment', ['id_ugiro' => 'id_ugiro']);
|
||||
}
|
||||
|
||||
public function getDetstaUzenetek()
|
||||
{
|
||||
return $this->hasMany(MessageDetsta::className(), ['id_ugiro' => 'id_ugiro']);
|
||||
}
|
||||
|
||||
|
||||
public static function statuses() {
|
||||
return [
|
||||
|
||||
@ -6,22 +6,39 @@ use common\models;
|
||||
use yii\console\Controller;
|
||||
use common\models\Ticket;
|
||||
use common\models\DoorLog;
|
||||
use yii\helpers\VarDumper;
|
||||
use common\models\Customer;
|
||||
use common\models\Log;
|
||||
|
||||
class DoorlogController extends Controller{
|
||||
|
||||
|
||||
public $ticket;
|
||||
|
||||
|
||||
// public function options($actionID)
|
||||
// {
|
||||
// return ['ticket'];
|
||||
// }
|
||||
|
||||
// public function optionAliases()
|
||||
// {
|
||||
// return ['t' => 'ticket'];
|
||||
// }
|
||||
|
||||
|
||||
|
||||
public function actionIn()
|
||||
public function actionIn($ticket)
|
||||
{
|
||||
$log = new DoorLog();
|
||||
|
||||
$log = new DoorLog();
|
||||
//5559 9719
|
||||
|
||||
$log->id_card = 9719;
|
||||
$log->id_customer = 5559;
|
||||
$log->id_ticket_current = 10430;
|
||||
$log->id_ticket_current = $ticket;
|
||||
$log->direction = 7;
|
||||
$log->id_key = null;
|
||||
$log->id_key = 1;
|
||||
$log->type = 0;
|
||||
$log->source_app = DoorLog::$SOURCE_APP_FITNESS_ADMIN;
|
||||
$log->id_account = null;
|
||||
@ -33,14 +50,14 @@ class DoorlogController extends Controller{
|
||||
$log->save(false);
|
||||
}
|
||||
|
||||
public function actionOut()
|
||||
public function actionOut($ticket)
|
||||
{
|
||||
$log = new DoorLog();
|
||||
|
||||
|
||||
$log->id_card = 9719;
|
||||
$log->id_customer = 5559;
|
||||
$log->id_ticket_current = 10430;
|
||||
$log->id_ticket_current = $ticket;
|
||||
$log->direction = 5;
|
||||
$log->id_key = null;
|
||||
$log->type = 0;
|
||||
@ -52,5 +69,102 @@ class DoorlogController extends Controller{
|
||||
|
||||
$log->save(false);
|
||||
}
|
||||
|
||||
protected function log($ticket){
|
||||
$subject = Ticket::find()->andWhere( ["id_ticket" => intval($ticket)])->one();
|
||||
|
||||
|
||||
$card = $subject->card;
|
||||
echo "in:" . $subject->usage_count. " | out:" . $subject->count_move_out . " | max: " .$subject->max_usage_count. " | card flag: " . $card->flag ."\n";
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function actionVisit($ticket) {
|
||||
$this->log($ticket);
|
||||
$this->actionIn($ticket);
|
||||
$this->log($ticket);
|
||||
$this->actionOut($ticket);
|
||||
$this->log($ticket);
|
||||
}
|
||||
|
||||
|
||||
public function actionFixmissing(){
|
||||
|
||||
$tickets = Ticket::find()->andWhere(['in','id_ticket_type' ,[54,55,56,57]])->all();
|
||||
|
||||
|
||||
|
||||
foreach ($tickets as $ticket){
|
||||
$cache = [];
|
||||
|
||||
$doorlogs = DoorLog::find()->andWhere( [ 'id_ticket_current' => $ticket->id_ticket, 'direction' => 7 ])->all();
|
||||
|
||||
|
||||
foreach ($doorlogs as $doorlog ){
|
||||
//echo VarDumper::dump($doorlogs);
|
||||
|
||||
$keydate = substr($doorlog->created_at,0,10 );
|
||||
|
||||
$d1 = strtotime($keydate);
|
||||
$d2 = $d1 + 60 *60 *24;
|
||||
|
||||
$d1 = date("Y-m-d H:i:s",$d1);
|
||||
$d2 = date("Y-m-d H:i:s",$d2);
|
||||
|
||||
$logs = Log::find()->andWhere(['id_ticket' => $ticket->id_ticket, 'type' => 30])->andWhere(['>=','created_at',$d1])->andWhere(['<','created_at',$d2])->all();
|
||||
|
||||
|
||||
if ( count($logs) == 0 ){
|
||||
|
||||
if ( array_key_exists($keydate, $cache) ){
|
||||
$cache[$keydate]['count'] = $cache[$keydate]['count'] + 1;
|
||||
}else{
|
||||
$cache[$keydate]['count'] = 1;
|
||||
$cache[$keydate]['id'] = $doorlog->id_door_log;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( count($cache) > 0 ){
|
||||
|
||||
foreach ($cache as $item){
|
||||
|
||||
echo $item['id'];
|
||||
echo "/";
|
||||
echo $item['count'];
|
||||
echo "\r\n";
|
||||
|
||||
$t = Ticket::findOne($ticket->id_ticket);
|
||||
|
||||
|
||||
$elotte = $t->usage_count;
|
||||
$t->usage_count = $t->usage_count + 1;
|
||||
$t->count_move_out = $t->usage_count;
|
||||
|
||||
$t->save(false);
|
||||
|
||||
$log = new Log();
|
||||
$log->type = 30;
|
||||
$log->id_ticket = $ticket->id_ticket;
|
||||
$log->app = 'trigger_inc_ticket';
|
||||
$log->id_door_log = $item['id'];
|
||||
$log->message = "FixMissing: Bérlet használat (elotte: " . $elotte ." > utana: " . $t->usage_count . " max: ". $t->max_usage_count .")";
|
||||
$log->save(false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
111
trigger_out.sql
Normal file
111
trigger_out.sql
Normal file
@ -0,0 +1,111 @@
|
||||
DROP TRIGGER IF EXISTS trigger_inc_ticket_usage_count;
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER trigger_inc_ticket_usage_count
|
||||
AFTER INSERT ON `door_log` FOR EACH ROW
|
||||
begin
|
||||
/*DECLARE p_usage_count Integer;*/
|
||||
DECLARE p_count_all Integer;
|
||||
DECLARE p_count_all_2 Integer;
|
||||
DECLARE p_from DATETIME;
|
||||
DECLARE p_usage_count Integer;
|
||||
DECLARE p_max_usage_count Integer;
|
||||
|
||||
delete from devlog;
|
||||
/** van vendég*/
|
||||
IF NEW.id_customer is not null
|
||||
/*van kártya*/
|
||||
and NEW.id_card is not null
|
||||
/**van bérlet*/
|
||||
and NEW.id_ticket_current is not null
|
||||
/**bemozgás volt*/
|
||||
|
||||
then
|
||||
|
||||
if NEW.direction = 7 then
|
||||
insert into devlog ( msg) values('direction = in');
|
||||
select count(*) into @p_count_all from door_log where created_at >= CURDATE() and id_ticket_current = New.id_ticket_current and direction = 7;
|
||||
|
||||
insert into devlog ( msg) values( concat( 'count all' ,@p_count_all ) );
|
||||
|
||||
IF @p_count_all = 1
|
||||
THEN
|
||||
select usage_count, max_usage_count into @p_usage_count ,@p_max_usage_count from ticket where id_ticket = NEW.id_ticket_current;
|
||||
update ticket set usage_count = usage_count +1 where id_ticket = NEW.id_ticket_current;
|
||||
insert into log (type,message, app, id_ticket, id_door_log,created_at, updated_at)
|
||||
values(
|
||||
30, concat('Bérlet használat (elotte: ',@p_usage_count, ' > utana: ' , @p_usage_count +1 , ' max: ', @p_max_usage_count, ')' ), ' trigger_inc_ticket',New.id_ticket_current, New.id_door_log,now(),now());
|
||||
else
|
||||
/**
|
||||
Innentől kezdve biztos, hogy nem ez az első belépés az aktuális napon.
|
||||
Ki kell számolnunk hányadik 3 órás intervallumban vagyunk az első belépéstől számítva.
|
||||
Pl. ha 06:00 kor volt az első belépés, akkor 07: 30 még nem von le újabb használatot,
|
||||
de a 09:00 már igen
|
||||
*/
|
||||
|
||||
select min(created_at) + INTERVAL (3 * FLOOR( ( ( HOUR(TIMEDIFF(min(created_at) , now() )) /3 ) ) ) ) hour as last_date
|
||||
into @p_from
|
||||
from door_log
|
||||
where created_at > CURDATE() and id_customer is not null;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
-- select count(*) into @p_count_all_2 from door_log where created_at >= p_from and id_ticket_current ;
|
||||
select count(*) into @p_count_all_2 from door_log where created_at >= @p_from and id_ticket_current = New.id_ticket_current and direction = 7;
|
||||
|
||||
-- insert into devlog ( msg) values(CONCAT( 'ticket count since last period begin: ', @p_count_all_2) );
|
||||
/**
|
||||
Ha az első belépéstől számítot aktuális 3 órás intervallumban ez az elős belépés, akkor növeljük a használatot
|
||||
*/
|
||||
IF @p_count_all_2 = 1
|
||||
THEN
|
||||
-- insert into devlog ( msg) values( 'need to increase usage count multiple intervals ' );
|
||||
select usage_count, max_usage_count into @p_usage_count ,@p_max_usage_count from ticket where id_ticket = NEW.id_ticket_current;
|
||||
update ticket set usage_count = usage_count +1 where id_ticket = New.id_ticket_current;
|
||||
|
||||
insert into log (type,message, app, id_ticket, id_door_log,created_at, updated_at)
|
||||
values(
|
||||
40, concat('Bérlet használat/egy nap tobbszori (elotte: ',@p_usage_count, ' > utana: ' , @p_usage_count +1 , ' max: ', @p_max_usage_count, ')' ), ' trigger_inc_ticket',New.id_ticket_current, New.id_door_log,now(),now());
|
||||
|
||||
END IF; -- end @p_count_all_2 = 1
|
||||
|
||||
END IF;
|
||||
|
||||
End IF; -- end type == 7 ( move in )
|
||||
|
||||
|
||||
|
||||
IF NEW.direction = 5 -- type move out
|
||||
then
|
||||
insert into devlog ( msg) values('bérlet kilépés...');
|
||||
update ticket set count_move_out = usage_count where id_ticket = NEW.id_ticket_current;
|
||||
END IF; -- end type move out
|
||||
|
||||
/**
|
||||
Van e érvényes bérlet státusz frissítése a bérletkártyán
|
||||
update card.flag and card.id_ticket_current
|
||||
|
||||
*/
|
||||
-- insert into devlog ( msg) values( 'updateing card state' );
|
||||
UPDATE card as c1
|
||||
left JOIN ( select ticket.id_card as id_card , max(ticket.id_ticket) as id_ticket
|
||||
from ticket
|
||||
where ticket.start <= CURDATE()
|
||||
and ticket.end >= curdate()
|
||||
and ticket.status = 10
|
||||
and ticket.count_move_out < ticket.max_usage_count
|
||||
and ticket.id_card = New.id_card
|
||||
group by id_card
|
||||
order by id_card desc ) as t
|
||||
on t.id_card = c1.id_card
|
||||
SET c1.flag = case 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.type <> 50 and c1.id_card = New.id_card;
|
||||
|
||||
|
||||
END IF;
|
||||
|
||||
END;
|
||||
$$
|
||||
DELIMITER ;
|
||||
Loading…
Reference in New Issue
Block a user