Advertisement
fahmihilmansyah

trigger evan

Jul 2nd, 2014
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 2.35 KB | None | 0 0
  1. BEGIN
  2.     IF (UPPER((SUBSTRING(new.TextDecoded ,1,4)) =  "INFO"  ) ) THEN
  3.         #SET @PESAN = CONCAT(' Terima Kasih  ', char(13), ' Nomor anda ',new.SenderNumber,' Berlangganan') ;
  4.         SET @pilmob = (select GROUP_CONCAT('Nopol: ',no_polisi, ', Merk: ',merk) from ta_mobil where `status` = 0);
  5.         insert into outbox (DestinationNumber ,TextDecoded,MultiPart ) values ( new.SenderNumber  , @pilmob, true ) ;
  6.     #untuk input status posisi mobil
  7.     #elseif (UPPER(SUBSTRING_INDEX(new.TextDecoded, '#', 1)) = "STATUS") then
  8.     #   SET @PESAN1 = CONCAT('Terima Kasih ini STATUS', char(13),' coba') ;
  9.     #   insert into outbox (DestinationNumber ,TextDecoded ) values ( new.SenderNumber  , @PESAN1 ) ;
  10.     #untuk booking
  11.     elseif (UPPER(SUBSTRING_INDEX(new.TextDecoded, '#', 1))="BOOKING") then
  12.         SET @pel = (select user_id from ta_pelanggan where hp_p = new.SenderNumber limit 1);
  13.             SET @pbook= UPPER(SUBSTRING_INDEX(new.TextDecoded, '#', -1));
  14.         if (@pel is NOT NULL) then
  15.             INSERT INTO  `evanta`.`ta_peminjaman` (`kode_pinjam` ,`user_id` ,`no_polisi` ,`surat_dinas` ,`waktu_pinjam` ,`username_pinjam` ,`waktu_selesai` ,`username_selesai` ,`is_booking`)
  16.             VALUES (NULL ,  @pel,  @pbook,  '', CURRENT_TIMESTAMP ,  '',  '',  '',  '1');
  17.             UPDATE  `evanta`.`ta_mobil` SET  `status` =  '1' WHERE  `ta_mobil`.`no_polisi` =  @pbook;
  18.             SET @gagl = CONCAT('Nomor Anda: ',new.SenderNumber, char(13),' Telah Berhasil Memboking ',@pbook) ;
  19.                 insert into outbox (DestinationNumber ,TextDecoded ) values ( new.SenderNumber  , @gagl ) ;
  20.         ELSE
  21.                 SET @gagl = CONCAT('Maaf Anda Belum Terdaftar', char(13),' Silahkan Hubungin Admin') ;
  22.                 insert into outbox (DestinationNumber ,TextDecoded ) values ( new.SenderNumber  , @gagl ) ;
  23.         end if;
  24.         #LOKASI#B390NO#123,231
  25.     elseif (UPPER(SUBSTRING_INDEX(new.TextDecoded, '#', 1))="LOKASI") then
  26.         SET @plate= UPPER(SUBSTRING_INDEX(SUBSTRING_INDEX(new.TextDecoded, '#', -2),"#",1));
  27.         SET @koorX= SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(new.TextDecoded, '#', -2),"#",-1),",",1);
  28.         SET @koorY= SUBSTRING_INDEX(SUBSTRING_INDEX(new.TextDecoded, '#', -2),",",-1);
  29.         INSERT INTO  `evanta`.`ta_info_lokasi` (`id` ,`waktu` ,`no_polisi` ,`koor_x` ,`koor_y`)VALUES (NULL , CURRENT_TIMESTAMP ,  @plate,  @koorX,  @koorY);
  30.     else
  31.         insert into outbox (DestinationNumber ,TextDecoded ) values ( new.SenderNumber  , 'Maaf Format Salah' ) ;
  32.     END IF;
  33. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement