CREATE TRIGGER `before_insert_accounting_accounts` BEFORE INSERT ON `accounting_accounts` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_accounting_accounts` BEFORE UPDATE ON `accounting_accounts` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_accounting_journal` BEFORE INSERT ON `accounting_journal` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_accounting_journal` BEFORE UPDATE ON `accounting_journal` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_charity_members` BEFORE INSERT ON `charity_members` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_charity_members` BEFORE UPDATE ON `charity_members` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_charity_plans` BEFORE INSERT ON `charity_plans` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_charity_plans` BEFORE UPDATE ON `charity_plans` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_committee_plans` BEFORE INSERT ON `committee_plans` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_committee_plans` BEFORE UPDATE ON `committee_plans` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_committees` BEFORE INSERT ON `committees` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_committees` BEFORE UPDATE ON `committees` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_expense_categories` BEFORE INSERT ON `expense_categories` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_expense_categories` BEFORE UPDATE ON `expense_categories` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_expenses` BEFORE INSERT ON `expenses` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_expenses` BEFORE UPDATE ON `expenses` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_hr_attendance` BEFORE INSERT ON `hr_attendance` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_hr_attendance` BEFORE UPDATE ON `hr_attendance` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_hr_employees` BEFORE INSERT ON `hr_employees` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_hr_employees` BEFORE UPDATE ON `hr_employees` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_hr_holidays` BEFORE INSERT ON `hr_holidays` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_hr_holidays` BEFORE UPDATE ON `hr_holidays` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_hr_leaves` BEFORE INSERT ON `hr_leaves` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_hr_leaves` BEFORE UPDATE ON `hr_leaves` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_hr_payroll` BEFORE INSERT ON `hr_payroll` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_hr_payroll` BEFORE UPDATE ON `hr_payroll` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_inbound_mail` BEFORE INSERT ON `inbound_mail` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN IF NEW.created_by IS NULL THEN SET NEW.created_by = @app_user_id; END IF; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_inbound_mail` BEFORE UPDATE ON `inbound_mail` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_internal_mail` BEFORE INSERT ON `internal_mail` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN IF NEW.created_by IS NULL THEN SET NEW.created_by = @app_user_id; END IF; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_internal_mail` BEFORE UPDATE ON `internal_mail` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_meetings` BEFORE INSERT ON `meetings` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN IF NEW.created_by IS NULL THEN SET NEW.created_by = @app_user_id; END IF; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_meetings` BEFORE UPDATE ON `meetings` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_outbound_mail` BEFORE INSERT ON `outbound_mail` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN IF NEW.created_by IS NULL THEN SET NEW.created_by = @app_user_id; END IF; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_outbound_mail` BEFORE UPDATE ON `outbound_mail` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_stock_categories` BEFORE INSERT ON `stock_categories` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_stock_categories` BEFORE UPDATE ON `stock_categories` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_stock_items` BEFORE INSERT ON `stock_items` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_stock_items` BEFORE UPDATE ON `stock_items` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_stock_lending` BEFORE INSERT ON `stock_lending` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_stock_lending` BEFORE UPDATE ON `stock_lending` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_stock_stores` BEFORE INSERT ON `stock_stores` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_stock_stores` BEFORE UPDATE ON `stock_stores` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_stock_transactions` BEFORE INSERT ON `stock_transactions` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_stock_transactions` BEFORE UPDATE ON `stock_transactions` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_insert_users` BEFORE INSERT ON `users` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.created_by = @app_user_id; SET NEW.updated_by = @app_user_id; END IF; END;
CREATE TRIGGER `before_update_users` BEFORE UPDATE ON `users` FOR EACH ROW BEGIN IF @app_user_id IS NOT NULL THEN SET NEW.updated_by = @app_user_id; END IF; END;
