civicrm_msg_template.tpl 5.39 KB
Newer Older
Pradeep Nayak's avatar
Pradeep Nayak committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
-- +--------------------------------------------------------------------+
-- | CiviCRM version 4.2                                                |
-- +--------------------------------------------------------------------+
-- | Copyright CiviCRM LLC (c) 2004-2012                                |
-- +--------------------------------------------------------------------+
-- | This file is a part of CiviCRM.                                    |
-- |                                                                    |
-- | CiviCRM is free software; you can copy, modify, and distribute it  |
-- | under the terms of the GNU Affero General Public License           |
-- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
-- |                                                                    |
-- | CiviCRM is distributed in the hope that it will be useful, but     |
-- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
-- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
-- | See the GNU Affero General Public License for more details.        |
-- |                                                                    |
-- | You should have received a copy of the GNU Affero General Public   |
-- | License and the CiviCRM Licensing Exception along                  |
-- | with this program; if not, contact CiviCRM LLC                     |
-- | at info[AT]civicrm[DOT]org. If you have questions about the        |
-- | GNU Affero General Public License or the licensing of CiviCRM,     |
-- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
-- +--------------------------------------------------------------------+
{* not sure how to define the below in Smarty, so doing it in PHP instead *}
{php}
  $ogNames = array(
    'grant'         => ts('Message Template Workflow for Grant',          array('escape' => 'sql')),
  );
  $ovNames = array(
    'grant' => array(
31
      'grant_allocation' => ts('Trial Allocation of Funds', array('escape' => 'sql')),
Mayur Jadhav's avatar
Mayur Jadhav committed
32
      'grant_eligible' => ts('Grants Eligible Receipt', array('escape' => 'sql')),
33
      'grant_awaiting_info' => ts('Grants Awaiting Information Receipt', array('escape' => 'sql')),
34
      'grant_ineligible' => ts('Grants Ineligible Receipt', array('escape' => 'sql')),
35
      'grant_paid' => ts('Grants Paid Receipt', array('escape' => 'sql')),
Mayur Jadhav's avatar
Mayur Jadhav committed
36
      'grant_approved' => ts('Grants Approved for Payment Receipt', array('escape' => 'sql')),
37 38
      'grant_submitted' => ts('Grants Submitted Receipt', array('escape' => 'sql')),
      'grant_withdrawn' => ts('Grants Withdrawn Receipt', array('escape' => 'sql')),
Mayur Jadhav's avatar
Mayur Jadhav committed
39 40
      'grant_payment_check' => ts('Grant Payment Check', array('escape' => 'sql')),
      'grant_payment_report' => ts('Grant Payment Report', array('escape' => 'sql')),
Pradeep Nayak's avatar
Pradeep Nayak committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
    ),
  );
  $smarty = CRM_Core_Smarty::singleton();
  $smarty->assign('ogNames',  $ogNames);
  $smarty->assign('ovNames',  $ovNames);
{/php}

INSERT INTO civicrm_option_group
  (name,                         {localize field='title'}title{/localize},            {localize field='description'}description{/localize},      is_reserved, is_active) VALUES
{foreach from=$ogNames key=name item=description name=for_groups}
    ('msg_tpl_workflow_{$name}', {localize}'{$description}'{/localize},               {localize}'{$description}'{/localize},                     1,           1) {if $smarty.foreach.for_groups.last};{else},{/if}
{/foreach}

{foreach from=$ogNames key=name item=description}
  SELECT @tpl_ogid_{$name} := MAX(id) FROM civicrm_option_group WHERE name = 'msg_tpl_workflow_{$name}';
{/foreach}

INSERT INTO civicrm_option_value
  (option_group_id,        name,       {localize field='label'}label{/localize},   value,                                  weight) VALUES
{foreach from=$ovNames key=gName item=ovs name=for_groups}
{foreach from=$ovs key=vName item=label name=for_values}
      (@tpl_ogid_{$gName}, '{$vName}', {localize}'{$label}'{/localize},            {$smarty.foreach.for_values.iteration}, {$smarty.foreach.for_values.iteration}) {if $smarty.foreach.for_groups.last and $smarty.foreach.for_values.last};{else},{/if}
{/foreach}
{/foreach}

{foreach from=$ovNames key=gName item=ovs}
{foreach from=$ovs key=vName item=label}
    SELECT @tpl_ovid_{$vName} := MAX(id) FROM civicrm_option_value WHERE option_group_id = @tpl_ogid_{$gName} AND name = '{$vName}';
{/foreach}
{/foreach}
71
INSERT IGNORE INTO civicrm_msg_template
Pradeep Nayak's avatar
Pradeep Nayak committed
72 73 74 75 76 77 78 79 80 81
  (msg_title,      msg_subject,                  msg_text,                  msg_html,                  workflow_id,        is_default, is_reserved) VALUES
{foreach from=$ovNames key=gName item=ovs name=for_groups}
{foreach from=$ovs key=vName item=title name=for_values}
      {fetch assign=subject file="`$config->extensionsDir`biz.jmaconsulting.grantprograms/sql/message_templates/`$vName`_subject.tpl"}
      {fetch assign=text    file="`$config->extensionsDir`biz.jmaconsulting.grantprograms/sql/message_templates/`$vName`_text.tpl"}
      {fetch assign=html    file="`$config->extensionsDir`biz.jmaconsulting.grantprograms/sql/message_templates/`$vName`_html.tpl"}
      ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 1,          0),
      ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 0,          1) {if $smarty.foreach.for_groups.last and $smarty.foreach.for_values.last};{else},{/if}
{/foreach}
{/foreach}