TYPE=TRIGGERS
triggers='CREATE DEFINER=`root`@`%` TRIGGER `tbl_gl_after_ins_tr` AFTER INSERT ON `tbl_gl`
\nFOR EACH ROW
\nBEGIN
\nIF (@DISABLE_TRIGGERS IS NULL) then
\nIF NEW.gl_post=1 THEN
\nUPDATE tbl_account SET
\n`ac_current_credit`=`ac_current_credit`+(NEW.gl_credit*NEW.gl_currency_val),
\n`ac_current_debit`=`ac_current_debit`+(NEW.gl_debit*NEW.gl_currency_val)
\nWHERE ac_id IN (SELECT pa_ac_id_parent FROM tbl_account_parent WHERE pa_ac_id=NEW.gl_ac_id);
\n
\nIF NEW.gl_init=1 THEN
\nUPDATE tbl_account SET
\n`ac_begin_credit`=`ac_begin_credit`+(NEW.gl_credit*NEW.gl_currency_val),
\n`ac_begin_debit`=`ac_begin_debit`+(NEW.gl_debit*NEW.gl_currency_val)
\nWHERE ac_id IN (SELECT pa_ac_id_parent FROM tbl_account_parent WHERE pa_ac_id=NEW.gl_ac_id);
\nEND IF;
\n
\nEND IF;
\n
\nIF NEW.gl_note_id>0 THEN
\nCALL pro_update_note_val(NEW.gl_note_id);
\nEND IF;
\n
\nEND IF;
\nEND' 'CREATE DEFINER=``@`localhost` TRIGGER `tbl_gl_after_upd_tr` AFTER UPDATE ON `tbl_gl`
\nFOR EACH ROW
\nBEGIN
\nIF (@DISABLE_TRIGGERS IS NULL) then
\nIF NEW.gl_post<>OLD.gl_post THEN
\n
\nIF NEW.gl_post=1 THEN
\n
\nUPDATE tbl_account SET
\n`ac_current_credit`=`ac_current_credit`+(NEW.gl_credit*NEW.gl_currency_val),
\n`ac_current_debit`=`ac_current_debit`+(NEW.gl_debit*NEW.gl_currency_val)
\nWHERE ac_id IN (SELECT pa_ac_id_parent FROM tbl_account_parent WHERE pa_ac_id=NEW.gl_ac_id);
\n
\nIF NEW.gl_init=1 THEN
\nUPDATE tbl_account SET
\n`ac_begin_credit`=`ac_begin_credit`+(NEW.gl_credit*NEW.gl_currency_val),
\n`ac_begin_debit`=`ac_begin_debit`+(NEW.gl_debit*NEW.gl_currency_val)
\nWHERE ac_id IN (SELECT pa_ac_id_parent FROM tbl_account_parent WHERE pa_ac_id=NEW.gl_ac_id);
\nEND IF;
\n
\nELSE
\n
\nUPDATE tbl_account SET
\n`ac_current_credit`=`ac_current_credit`-(OLD.gl_credit*OLD.gl_currency_val),
\n`ac_current_debit`=`ac_current_debit`-(OLD.gl_debit*OLD.gl_currency_val)
\nWHERE ac_id IN (SELECT pa_ac_id_parent FROM tbl_account_parent WHERE pa_ac_id=OLD.gl_ac_id);
\n
\nIF OLD.gl_init=1 THEN
\nUPDATE tbl_account SET
\n`ac_begin_credit`=`ac_begin_credit`-(OLD.gl_credit*OLD.gl_currency_val),
\n`ac_begin_debit`=`ac_begin_debit`-(OLD.gl_debit*OLD.gl_currency_val)
\nWHERE ac_id IN (SELECT pa_ac_id_parent FROM tbl_account_parent WHERE pa_ac_id=OLD.gl_ac_id);
\nEND IF;
\n
\nEND IF;
\n
\nEND IF;
\nEND IF;
\nEND' 'CREATE DEFINER=`root`@`%` TRIGGER `tbl_gl_after_del_tr` AFTER DELETE ON `tbl_gl`
\nFOR EACH ROW
\nBEGIN
\nIF (@DISABLE_TRIGGERS IS NULL) then
\nIF OLD.gl_post=1 THEN
\nUPDATE tbl_account SET
\n`ac_current_credit`=`ac_current_credit`-(OLD.gl_credit*OLD.gl_currency_val),
\n`ac_current_debit`=`ac_current_debit`-(OLD.gl_debit*OLD.gl_currency_val)
\nWHERE ac_id IN (SELECT pa_ac_id_parent FROM tbl_account_parent WHERE pa_ac_id=OLD.gl_ac_id);
\n
\nIF OLD.gl_init=1 THEN
\nUPDATE tbl_account SET
\n`ac_begin_credit`=`ac_begin_credit`-(OLD.gl_credit*OLD.gl_currency_val),
\n`ac_begin_debit`=`ac_begin_debit`-(OLD.gl_debit*OLD.gl_currency_val)
\nWHERE ac_id IN (SELECT pa_ac_id_parent FROM tbl_account_parent WHERE pa_ac_id=OLD.gl_ac_id);
\nEND IF;
\nEND IF;
\n
\nIF OLD.gl_note_id>0 THEN
\nCALL pro_update_note_val(OLD.gl_note_id);
\nEND IF;
\nEND IF;
\nEND' 'CREATE DEFINER=`root`@`localhost` TRIGGER tbl_gl_before_ins_tr BEFORE INSERT ON tbl_gl FOR EACH ROW
\nBEGIN
\nIF (@DISABLE_TRIGGERS IS NULL) then
\nIF ISNULL(NEW.gl_id) OR (NEW.gl_id=0) THEN
\nSET NEW.gl_id=`func_get_uuid`();
\nEND IF;
\nEND IF;
\nEND'
sql_modes=1344274434 1344274434 1344274434 1344274434
definers='root@%' '@localhost' 'root@%' 'root@localhost'
client_cs_names='cp1256' 'cp1256' 'cp1256' 'cp1256'
connection_cl_names='cp1256_general_ci' 'cp1256_general_ci' 'cp1256_general_ci' 'cp1256_general_ci'
db_cl_names='cp1256_general_ci' 'cp1256_general_ci' 'cp1256_general_ci' 'cp1256_general_ci'
