r70510 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70509‎ | r70510 | r70511 >
Date:17:15, 5 August 2010
Author:kaldari
Status:deferred
Tags:
Comment:
updating synchronize and trigger sql scripts
Modified paths:
  • /civicrm/trunk/sites/all/bin/public_reporting/synchronize.sql (modified) (history)
  • /civicrm/trunk/sites/all/bin/public_reporting/triggers.sql (modified) (history)

Diff [purge]

Index: civicrm/trunk/sites/all/bin/public_reporting/triggers.sql
@@ -5,20 +5,23 @@
66 DROP TRIGGER IF EXISTS public_reporting_insert;
77 DROP TRIGGER IF EXISTS public_reporting_update;
88 DROP TRIGGER IF EXISTS public_reporting_contact_update;
9 -DROP TRIGGER IF EXISTS public_reporting_note_insert;
109 DROP TRIGGER IF EXISTS public_reporting_note_update;
1110 DELIMITER //
12 -CREATE TRIGGER public_reporting_insert AFTER INSERT ON civicrm_contribution FOR EACH ROW
 11+CREATE TRIGGER public_reporting_insert AFTER INSERT ON civicrm_value_1_note_11 FOR EACH ROW
1312 BEGIN
 13+ DECLARE cc_payment_instrument_id INT(10) unsigned DEFAULT NULL;
 14+ DECLARE cc_contact_id INT(10) unsigned;
1415 DECLARE public_name VARCHAR(128) charset utf8;
15 - IF SUBSTRING(NEW.source, 1, 3) != 'RFD' THEN -- don't trigger for refunds
16 - SET public_name := (SELECT IF(do_not_trade = 1 or NEW.payment_instrument_id = 4, NULL, SUBSTRING_INDEX(display_name, "@", 1))
17 - FROM civicrm_contact WHERE id = NEW.contact_id);
18 - INSERT INTO public_reporting (contribution_id, contact_id, name, converted_amount, original_currency,
19 - original_amount, note, received)
20 - VALUES (NEW.id, NEW.contact_id, public_name, NEW.total_amount, SUBSTRING(NEW.source, 1, 3),
21 - SUBSTRING(NEW.source, 5), NEW.note, UNIX_TIMESTAMP(NEW.receive_date));
22 - END IF;
 16+ SET cc_payment_instrument_id := (SELECT payment_instrument_id FROM civicrm_contribution WHERE id = NEW.entity_id);
 17+ SET cc_contact_id := (SELECT contact_id FROM civicrm_contribution WHERE id = NEW.entity_id);
 18+ IF SUBSTRING((SELECT source FROM civicrm_contribution WHERE id = NEW.entity_id LIMIT 1), 1, 3) != 'RFD' THEN -- don't trigger for refunds
 19+ SET public_name := (SELECT IF(do_not_trade = 1 or cc_payment_instrument_id = 4, NULL, SUBSTRING_INDEX(display_name, "@", 1))
 20+ FROM civicrm_contact WHERE id = cc_contact_id);
 21+ INSERT INTO public_reporting (contribution_id, contact_id, name, converted_amount, original_currency, original_amount, note, received)
 22+ SELECT cc.id, cc.contact_id, public_name, cc.total_amount,
 23+ SUBSTRING(cc.source, 1, 3), SUBSTRING(cc.source, 5), NEW.donor_comment, UNIX_TIMESTAMP(cc.receive_date)
 24+ FROM civicrm_contribution cc WHERE cc.id = NEW.entity_id;
 25+ END IF;
2326 END
2427 //
2528 CREATE TRIGGER public_reporting_update AFTER UPDATE ON civicrm_contribution FOR EACH ROW
@@ -47,11 +50,6 @@
4851 UPDATE public_reporting pr SET pr.name = public_name WHERE pr.contact_id = NEW.id;
4952 END
5053 //
51 -CREATE TRIGGER public_reporting_note_insert AFTER INSERT ON civicrm_value_1_note_11 FOR EACH ROW
52 -BEGIN
53 - UPDATE public_reporting pr SET pr.note = NEW.donor_comment WHERE pr.contribution_id = NEW.entity_id;
54 -END
55 -//
5654 CREATE TRIGGER public_reporting_note_update AFTER UPDATE ON civicrm_value_1_note_11 FOR EACH ROW
5755 BEGIN
5856 UPDATE public_reporting pr SET pr.note = NEW.donor_comment WHERE pr.contribution_id = NEW.entity_id;
Index: civicrm/trunk/sites/all/bin/public_reporting/synchronize.sql
@@ -3,14 +3,14 @@
44 INSERT INTO public_reporting (contribution_id, contact_id, name, converted_amount, original_currency,
55 original_amount, note, received)
66 SELECT cn.id, ct.id, IF(ct.do_not_trade, NULL, SUBSTRING_INDEX(ct.display_name, "@", 1)), cn.total_amount,
7 - SUBSTRING(cn.source, 1, 3), CONVERT(SUBSTRING(cn.source, 5), DECIMAL(20,2)), nt.note, UNIX_TIMESTAMP(cn.receive_date)
 7+ SUBSTRING(cn.source, 1, 3), CONVERT(SUBSTRING(cn.source, 5), DECIMAL(20,2)), nt.donor_comment, UNIX_TIMESTAMP(cn.receive_date)
88 FROM civicrm_contribution cn
99 INNER JOIN civicrm_contact ct ON cn.contact_id = ct.id
1010 LEFT JOIN civicrm_value_1_note_11 nt ON cn.id = nt.entity_id
1111 WHERE cn.total_amount >= 1;
1212 COMMIT;
1313
14 -/* Use if donor comments are stored in notes table instead of custom field
 14+/* Use if donor comments are stored in notes table instead of custom data field
1515 BEGIN;
1616 DELETE FROM public_reporting;
1717 CREATE TEMPORARY TABLE temp_notes (

Status & tagging log