3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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-2016
33 class CRM_Mailing_Form_Search
extends CRM_Core_Form
{
35 public function preProcess() {
39 public function buildQuickForm() {
40 $parent = $this->controller
->getParent();
41 $nameTextLabel = ($parent->_sms
) ?
ts('SMS Name') : ts('Mailing Name');
43 $this->add('text', 'mailing_name', $nameTextLabel,
44 CRM_Core_DAO
::getAttribute('CRM_Mailing_DAO_Mailing', 'title')
47 CRM_Core_Form_Date
::buildDateRange($this, 'mailing', 1, '_from', '_to', ts('From'), FALSE);
49 $this->add('text', 'sort_name', ts('Created or Sent by'),
50 CRM_Core_DAO
::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')
53 CRM_Campaign_BAO_Campaign
::addCampaignInComponentSearch($this);
55 // CRM-15434 - Fix mailing search by status in non-English languages
56 $statusVals = CRM_Core_SelectValues
::getMailingJobStatus();
57 foreach ($statusVals as $statusId => $statusName) {
58 $this->addElement('checkbox', "mailing_status[$statusId]", NULL, $statusName);
60 $this->addElement('checkbox', 'status_unscheduled', NULL, ts('Draft / Unscheduled'));
61 $this->addYesNo('is_archived', ts('Mailing is Archived'), TRUE);
64 $this->addElement('hidden', 'sms', $parent->_sms
);
66 $this->add('hidden', 'hidden_find_mailings', 1);
68 $this->addButtons(array(
71 'name' => ts('Search'),
80 public function setDefaultValues() {
81 $defaults = $statusVals = array();
82 $parent = $this->controller
->getParent();
84 if ($parent->get('unscheduled')) {
85 $defaults['status_unscheduled'] = 1;
87 if ($parent->get('scheduled')) {
88 $statusVals = array('Scheduled', 'Complete', 'Running', 'Canceled');
89 $defaults['is_archived'] = 0;
91 if ($parent->get('archived')) {
92 $defaults['is_archived'] = 1;
94 foreach ($statusVals as $status) {
95 $defaults['mailing_status'][$status] = 1;
104 public function postProcess() {
105 $params = $this->controller
->exportValues($this->_name
);
107 CRM_Contact_BAO_Query
::fixDateValues($params["mailing_relative"], $params['mailing_from'], $params['mailing_to']);
109 $parent = $this->controller
->getParent();
110 if (!empty($params)) {
119 'status_unscheduled',
121 'hidden_find_mailings',
123 foreach ($fields as $field) {
124 if (isset($params[$field]) &&
125 !CRM_Utils_System
::isNull($params[$field])
127 if (in_array($field, array(
130 )) && !$params["mailing_relative"]
132 $time = ($field == 'mailing_to') ?
'235959' : NULL;
133 $parent->set($field, CRM_Utils_Date
::processDate($params[$field], $time));
136 $parent->set($field, $params[$field]);
140 $parent->set($field, NULL);