3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
35 class CRM_Mailing_Form_Search
extends CRM_Core_Form
{
37 public function preProcess() {
41 public function buildQuickForm() {
42 $parent = $this->controller
->getParent();
43 $nameTextLabel = ($parent->_sms
) ?
ts('SMS Name') : ts('Mailing Name');
45 $this->add('text', 'mailing_name', $nameTextLabel,
46 CRM_Core_DAO
::getAttribute('CRM_Mailing_DAO_Mailing', 'title')
49 CRM_Core_Form_Date
::buildDateRange($this, 'mailing', 1, '_from', '_to', ts('From'), FALSE);
51 $this->add('text', 'sort_name', ts('Created or Sent by'),
52 CRM_Core_DAO
::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')
55 CRM_Campaign_BAO_Campaign
::addCampaignInComponentSearch($this);
57 // CRM-15434 - Fix mailing search by status in non-English languages
58 $statusVals = CRM_Core_SelectValues
::getMailingJobStatus();
59 foreach ($statusVals as $statusId => $statusName) {
60 $this->addElement('checkbox', "mailing_status[$statusId]", NULL, $statusName);
62 $this->addElement('checkbox', 'status_unscheduled', NULL, ts('Draft / Unscheduled'));
63 $this->addYesNo('is_archived', ts('Mailing is Archived'), TRUE);
66 $this->addElement('hidden', 'sms', $parent->_sms
);
68 $this->add('hidden', 'hidden_find_mailings', 1);
70 $this->addButtons(array(
73 'name' => ts('Search'),
82 function setDefaultValues() {
83 $defaults = $statusVals = array();
84 $parent = $this->controller
->getParent();
86 if ($parent->get('unscheduled')) {
87 $defaults['status_unscheduled'] = 1;
89 if ($parent->get('scheduled')) {
90 $statusVals = array('Scheduled', 'Complete', 'Running', 'Canceled');
91 $defaults['is_archived'] = 0;
93 if ($parent->get('archived')) {
94 $defaults['is_archived'] = 1;
96 foreach ($statusVals as $status) {
97 $defaults['mailing_status'][$status] = 1;
101 $defaults['sms'] = 1;
106 function postProcess() {
107 $params = $this->controller
->exportValues($this->_name
);
109 CRM_Contact_BAO_Query
::fixDateValues($params["mailing_relative"], $params['mailing_from'], $params['mailing_to']);
111 $parent = $this->controller
->getParent();
112 if (!empty($params)) {
113 $fields = array('mailing_name', 'mailing_from', 'mailing_to', 'sort_name',
114 'campaign_id', 'mailing_status', 'sms', 'status_unscheduled', 'is_archived', 'hidden_find_mailings');
115 foreach ($fields as $field) {
116 if (isset($params[$field]) &&
117 !CRM_Utils_System
::isNull($params[$field])
119 if (in_array($field, array(
120 'mailing_from', 'mailing_to')) && !$params["mailing_relative"]) {
121 $time = ($field == 'mailing_to') ?
'235959' : NULL;
122 $parent->set($field, CRM_Utils_Date
::processDate($params[$field], $time));
125 $parent->set($field, $params[$field]);
129 $parent->set($field, NULL);