Merge pull request #4054 from eileenmcnaughton/CRM-15237
[civicrm-core.git] / CRM / Upgrade / Incremental / sql / 3.3.4.mysql.tpl
1 -- CRM-7455
2 UPDATE civicrm_report_instance
3 SET title = '{ts escape="sql"}Grant Report (Detail){/ts}',
4 report_id = 'grant/detail',
5 description = '{ts escape="sql"}Grant Report Detail{/ts}',
6 form_values = '{literal}a:37:{s:6:"fields";a:2:{s:12:"display_name";s:1:"1";s:25:"application_received_date";s:1:"1";}s:15:"display_name_op";s:3:"has";s:18:"display_name_value";s:0:"";s:12:"gender_id_op";s:2:"in";s:15:"gender_id_value";a:0:{}s:13:"country_id_op";s:2:"in";s:16:"country_id_value";a:0:{}s:20:"state_province_id_op";s:2:"in";s:23:"state_province_id_value";a:0:{}s:13:"grant_type_op";s:2:"in";s:16:"grant_type_value";a:0:{}s:12:"status_id_op";s:2:"in";s:15:"status_id_value";a:0:{}s:18:"amount_granted_min";s:0:"";s:18:"amount_granted_max";s:0:"";s:17:"amount_granted_op";s:3:"lte";s:20:"amount_granted_value";s:0:"";s:20:"amount_requested_min";s:0:"";s:20:"amount_requested_max";s:0:"";s:19:"amount_requested_op";s:3:"lte";s:22:"amount_requested_value";s:0:"";s:34:"application_received_date_relative";s:1:"0";s:30:"application_received_date_from";s:0:"";s:28:"application_received_date_to";s:0:"";s:28:"money_transfer_date_relative";s:1:"0";s:24:"money_transfer_date_from";s:0:"";s:22:"money_transfer_date_to";s:0:"";s:23:"grant_due_date_relative";s:1:"0";s:19:"grant_due_date_from";s:0:"";s:17:"grant_due_date_to";s:0:"";s:11:"description";s:19:"Grant Report Detail";s:13:"email_subject";s:0:"";s:8:"email_to";s:0:"";s:8:"email_cc";s:0:"";s:10:"permission";s:16:"access CiviGrant";s:6:"groups";s:0:"";s:9:"domain_id";i:1;}{/literal}'
7 WHERE report_id = 'grant';
8
9 {if $multilingual}
10 UPDATE civicrm_option_value
11 SET value = 'grant/detail',
12 name = 'CRM_Report_Form_Grant_Detail'
13 WHERE value = 'grant'
14 AND name = 'CRM_Report_Form_Grant';
15
16 {foreach from=$locales item=loc}
17 UPDATE civicrm_option_value
18 SET label_{$loc} = '{ts escape="sql"}Grant Report (Detail){/ts}',
19 description_{$loc} = '{ts escape="sql"}Grant Report Detail{/ts}'
20 WHERE value = 'grant/detail'
21 AND name = 'CRM_Report_Form_Grant_Detail';
22 {/foreach}
23
24 {else}
25
26 UPDATE civicrm_option_value
27 SET label = '{ts escape="sql"}Grant Report (Detail){/ts}',
28 value = 'grant/detail',
29 name = 'CRM_Report_Form_Grant_Detail',
30 description = '{ts escape="sql"}Grant Report Detail{/ts}'
31 WHERE value = 'grant'
32 AND name = 'CRM_Report_Form_Grant';
33 {/if}
34
35 UPDATE civicrm_navigation
36 SET label = '{ts escape="sql"}Grant Report (Detail){/ts}',
37 name = '{ts escape="sql"}Grant Report (Detail){/ts}'
38 WHERE name = '{ts escape="sql"}Grant Report{/ts}';
39
40
41 SELECT @domainID := MIN(id) FROM civicrm_domain;
42 SELECT @reportlastID := id FROM civicrm_navigation WHERE name = 'Reports';
43 SELECT @ogrID := MAX(id) FROM civicrm_option_group WHERE name = 'report_template';
44 SELECT @nav_max_weight := MAX(ROUND(weight)) FROM civicrm_navigation WHERE parent_id = @reportlastID;
45 SELECT @grantCompId := MAX(id) FROM civicrm_component WHERE name = 'CiviGrant';
46 SELECT @max_weight := MAX(ROUND(weight)) FROM civicrm_option_value WHERE option_group_id = @ogrID;
47
48 INSERT INTO civicrm_option_value
49 (option_group_id, {localize field='label'}label{/localize}, value, name, grouping, filter, is_default, weight,{localize field='description'} description{/localize}, is_optgroup,is_reserved, is_active, component_id, visibility_id )
50 VALUES
51 (@ogrID , {localize}'{ts escape="sql"}Grant Report (Statistics){/ts}'{/localize}, 'grant/statistics', 'CRM_Report_Form_Grant_Statistics', NULL, 0, 0, @max_weight+1, {localize}'{ts escape="sql"}Shows statistics for Grants{/ts}'{/localize}, 0, 0, 1, @grantCompId, NULL);
52
53 INSERT INTO `civicrm_report_instance`
54 ( `domain_id`, `title`, `report_id`, `description`, `permission`, `form_values`)
55 VALUES
56 ( @domainID, 'Grant Report (Statistics)', 'grant/statistics', 'Shows statistics for Grants', 'access CiviGrant', '{literal}a:45:{s:6:"fields";a:3:{s:18:"summary_statistics";s:1:"1";s:9:"gender_id";s:1:"1";s:12:"contact_type";s:1:"1";}s:34:"application_received_date_relative";s:1:"0";s:30:"application_received_date_from";s:0:"";s:28:"application_received_date_to";s:0:"";s:22:"decision_date_relative";s:1:"0";s:18:"decision_date_from";s:0:"";s:16:"decision_date_to";s:0:"";s:28:"money_transfer_date_relative";s:1:"0";s:24:"money_transfer_date_from";s:0:"";s:22:"money_transfer_date_to";s:0:"";s:23:"grant_due_date_relative";s:1:"0";s:19:"grant_due_date_from";s:0:"";s:17:"grant_due_date_to";s:0:"";s:13:"grant_type_op";s:2:"in";s:16:"grant_type_value";a:1:{i:0;s:1:"1";}s:12:"status_id_op";s:2:"in";s:15:"status_id_value";a:0:{}s:20:"amount_requested_min";s:0:"";s:20:"amount_requested_max";s:0:"";s:19:"amount_requested_op";s:3:"lte";s:22:"amount_requested_value";s:0:"";s:18:"amount_granted_min";s:0:"";s:18:"amount_granted_max";s:0:"";s:17:"amount_granted_op";s:3:"lte";s:20:"amount_granted_value";s:0:"";s:24:"grant_report_received_op";s:2:"eq";s:27:"grant_report_received_value";s:0:"";s:13:"country_id_op";s:2:"in";s:16:"country_id_value";a:0:{}s:12:"region_id_op";s:2:"in";s:15:"region_id_value";a:0:{}s:11:"custom_7_op";s:2:"in";s:14:"custom_7_value";a:0:{}s:11:"custom_9_op";s:3:"has";s:14:"custom_9_value";s:0:"";s:11:"custom_8_op";s:4:"mhas";s:14:"custom_8_value";a:0:{}s:11:"description";s:28:"Shows statistics for Grants.";s:13:"email_subject";s:0:"";s:8:"email_to";s:0:"";s:8:"email_cc";s:0:"";s:10:"permission";s:16:"access CiviGrant";s:9:"parent_id";s:0:"";s:6:"groups";s:0:"";s:9:"domain_id";i:1;}{/literal}');
57
58 SET @instanceID:=LAST_INSERT_ID();
59 INSERT INTO civicrm_navigation
60 ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
61 VALUES
62 ( @domainID, CONCAT('civicrm/report/instance/', @instanceID,'&reset=1'), '{ts escape="sql"}Grant Report (Statistics){/ts}', '{ts}Grant Report (Statistics){/ts}', 'access CiviGrant', '',@reportlastID, '1', NULL, @nav_max_weight+1 );
63
64 UPDATE civicrm_report_instance SET navigation_id = LAST_INSERT_ID() WHERE id = @instanceID;