Merge pull request #14077 from pradpnayak/AutoComplete
[civicrm-core.git] / CRM / Event / Form / ManageEvent / ScheduleReminders.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 *
31 * @package CRM
32 * @copyright CiviCRM LLC (c) 2004-2019
33 * $Id$
34 *
35 */
36
37 /**
38 * This class generates form components for scheduling reminders for Event
39 *
40 */
41 class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_ManageEvent {
42
43 /**
44 * Set variables up before form is built.
45 *
46 * @return void
47 */
48 public function preProcess() {
49 parent::preProcess();
50 $this->assign('selectedChild', 'reminder');
51 $setTab = CRM_Utils_Request::retrieve('setTab', 'Int', $this, FALSE, 0);
52
53 $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings([
54 'id' => ($this->_isTemplate ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID),
55 ]));
56 $reminderList = CRM_Core_BAO_ActionSchedule::getList(FALSE, $mapping, $this->_id);
57 if ($reminderList && is_array($reminderList)) {
58 // Add action links to each of the reminders
59 foreach ($reminderList as & $format) {
60 $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE;
61 if ($format['is_active']) {
62 $action += CRM_Core_Action::DISABLE;
63 }
64 else {
65 $action += CRM_Core_Action::ENABLE;
66 }
67 $scheduleReminder = new CRM_Admin_Page_ScheduleReminders();
68 $links = $scheduleReminder->links();
69 $links[CRM_Core_Action::DELETE]['qs'] .= "&context=event&compId={$this->_id}";
70 $links[CRM_Core_Action::UPDATE]['qs'] .= "&context=event&compId={$this->_id}";
71 $format['action'] = CRM_Core_Action::formLink(
72 $links,
73 $action,
74 ['id' => $format['id']],
75 ts('more'),
76 FALSE,
77 'actionSchedule.manage.action',
78 'ActionSchedule',
79 $this->_id
80 );
81 }
82 }
83
84 $this->assign('rows', $reminderList);
85 $this->assign('setTab', $setTab);
86 $this->assign('component', 'event');
87
88 // Update tab "disabled" css class
89 $this->ajaxResponse['tabValid'] = is_array($reminderList) && (count($reminderList) > 0);
90 $this->setPageTitle(ts('Scheduled Reminder'));
91 }
92
93 /**
94 * @return string
95 */
96 public function getTemplateFileName() {
97 return 'CRM/Admin/Page/ScheduleReminders.tpl';
98 }
99
100 }