TYPE=TRIGGERS
triggers='CREATE DEFINER=`root`@`localhost` TRIGGER tbl_invoice_det_ser_after_del_tr AFTER DELETE ON tbl_invoice_det_ser FOR EACH ROW
\nBEGIN
\nIF (@DISABLE_TRIGGERS IS NULL) then
\nIF OLD.in_ser_in_out=1 THEN
\nUPDATE tbl_invoice_det_ser_list SET ser_in_count=ser_in_count-1
\nWHERE
\nser_item_id=OLD.in_ser_item_id AND
\nser_unit_id=OLD.in_ser_unit_id AND
\nser_store_id=OLD.in_ser_store_id AND
\nser_serial=OLD.in_ser_serial;
\nELSEIF OLD.in_ser_in_out=2 THEN
\nUPDATE tbl_invoice_det_ser_list SET ser_out_count=ser_out_count-1
\nWHERE
\nser_item_id=OLD.in_ser_item_id AND
\nser_unit_id=OLD.in_ser_unit_id AND
\nser_store_id=OLD.in_ser_store_id AND
\nser_serial=OLD.in_ser_serial;
\nEND IF;
\nEND IF;
\nEND' 'CREATE DEFINER=`root`@`localhost` TRIGGER tbl_invoice_det_ser_after_ins_tr AFTER INSERT ON tbl_invoice_det_ser FOR EACH ROW
\nBEGIN
\nIF (@DISABLE_TRIGGERS IS NULL) then
\nIF NEW.in_ser_in_out=1 THEN
\nINSERT IGNORE INTO
\n`tbl_invoice_det_ser_list`
\nSET
\n`ser_in_count`=0,
\n`ser_out_count`=0,
\n`ser_serial`=NEW.in_ser_serial,
\n`ser_item_id`=NEW.in_ser_item_id,
\n`ser_unit_id`=NEW.in_ser_unit_id,
\n`ser_store_id`=NEW.in_ser_store_id;
\nUPDATE tbl_invoice_det_ser_list SET ser_in_count=ser_in_count+1
\nWHERE
\nser_item_id=NEW.in_ser_item_id AND
\nser_unit_id=NEW.in_ser_unit_id AND
\nser_store_id=NEW.in_ser_store_id AND
\nser_serial=NEW.in_ser_serial;
\nELSEIF NEW.in_ser_in_out=2 THEN
\nUPDATE tbl_invoice_det_ser_list SET ser_out_count=ser_out_count+1
\nWHERE
\nser_item_id=NEW.in_ser_item_id AND
\nser_unit_id=NEW.in_ser_unit_id AND
\nser_store_id=NEW.in_ser_store_id AND
\nser_serial=NEW.in_ser_serial;
\nEND IF;
\nEND IF;
\nEND' 'CREATE DEFINER=`root`@`%` TRIGGER `tbl_invoice_det_ser_before_ins_tr` BEFORE INSERT ON `tbl_invoice_det_ser`
\n  FOR EACH ROW
\nBEGIN
\nIF (@DISABLE_TRIGGERS IS NULL) then
\nIF ISNULL(NEW.in_ser_id) OR (NEW.in_ser_id=0) THEN
\n SET NEW.in_ser_id=`func_get_uuid`();
\nEND IF;
\n SET NEW.in_ser_serial = TRIM(UPPER(NEW.in_ser_serial));
\nEND IF;
\nEND'
sql_modes=1344274434 1344274434 1344274434
definers='root@localhost' 'root@localhost' 'root@%'
client_cs_names='cp1256' 'cp1256' 'cp1256'
connection_cl_names='cp1256_general_ci' 'cp1256_general_ci' 'cp1256_general_ci'
db_cl_names='cp1256_general_ci' 'cp1256_general_ci' 'cp1256_general_ci'
