CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($this);
- if (!$parent->get('unscheduled')) {
- $statusVals = array('Scheduled', 'Complete', 'Running', 'Canceled');
- $parent->set('allStatuses', $statusVals);
- foreach ($statusVals as $status) {
- $this->addElement('checkbox', "mailing_status[$status]", NULL, $status);
- }
- $this->addElement('checkbox', 'all_status', NULL, 'All Statuses');
+ $statusVals = array('Scheduled', 'Complete', 'Running', 'Canceled');
+ foreach ($statusVals as $status) {
+ $this->addElement('checkbox', "mailing_status[$status]", NULL, $status);
}
+ $this->addElement('checkbox', 'status_unscheduled', NULL, 'Draft / Unscheduled');
+ $this->addYesNo('is_archived', ts('Mailing is Archived'));
+
if ($parent->_sms) {
$this->addElement('hidden', 'sms', $parent->_sms);
}
$defaults = array();
$parent = $this->controller->getParent();
- $statusVals = array('Scheduled', 'Complete', 'Running', 'Canceled');
- foreach ($statusVals as $status) {
- $defaults['mailing_status'][$status] = 1;
+ if ($parent->get('unscheduled')) {
+ $defaults['status_unscheduled'] = 1;
+ }
+
+ if ($parent->get('scheduled')) {
+ $statusVals = array('Scheduled', 'Complete', 'Running', 'Canceled');
+ foreach ($statusVals as $status) {
+ $defaults['mailing_status'][$status] = 1;
+ }
+ $defaults['is_archived'] = 0;
+ }
+
+ if ($parent->get('archived')) {
+ $defaults['is_archived'] = 1;
}
if ($parent->_sms) {
$parent = $this->controller->getParent();
if (!empty($params)) {
- $fields = array('mailing_name', 'mailing_from', 'mailing_to', 'sort_name', 'campaign_id', 'mailing_status', 'sms', 'all_status');
+ $fields = array('mailing_name', 'mailing_from', 'mailing_to', 'sort_name',
+ 'campaign_id', 'mailing_status', 'sms', 'status_unscheduled', 'is_archived');
foreach ($fields as $field) {
if (isset($params[$field]) &&
!CRM_Utils_System::isNull($params[$field])
$urlString .= '/unscheduled';
$urlParams .= '&scheduled=false';
$this->assign('unscheduled', TRUE);
-
- if ($this->get('sms')) {
- CRM_Utils_System::setTitle(ts('Draft and Unscheduled Mass SMS'));
- }
- else {
- CRM_Utils_System::setTitle(ts('Draft and Unscheduled Mailings'));
- }
}
elseif (CRM_Utils_Array::value(3, $newArgs) == 'archived') {
$urlString .= '/archived';
$this->assign('archived', TRUE);
-
- if ($this->get('sms')) {
- CRM_Utils_System::setTitle(ts('Archived Mass SMS'));
- }
- else {
- CRM_Utils_System::setTitle(ts('Archived Mailings'));
- }
}
elseif (CRM_Utils_Array::value(3, $newArgs) == 'scheduled') {
$urlString .= '/scheduled';
$urlParams .= '&scheduled=true';
-
- if ($this->get('sms')) {
- CRM_Utils_System::setTitle(ts('Scheduled and Sent Mass SMS'));
- }
- else {
- CRM_Utils_System::setTitle(ts('Scheduled and Sent Mailings'));
- }
}
- else {
- if ($this->get('sms')) {
- CRM_Utils_System::setTitle(ts('Find Mass SMS'));
- }
- else {
- CRM_Utils_System::setTitle(ts('Find Mailings'));
- }
+ if ($this->get('sms')) {
+ CRM_Utils_System::setTitle(ts('Find Mass SMS'));
}
$crmRowCount = CRM_Utils_Request::retrieve('crmRowCount', 'Integer', CRM_Core_DAO::$_nullObject);
function whereClause(&$params, $sortBy = TRUE) {
$values = $clauses = array();
-
$title = $this->_parent->get('mailing_name');
if ($title) {
}
}
+ $dateClause1 = $dateClause2 = array();
$from = $this->_parent->get('mailing_from');
if (!CRM_Utils_System::isNull($from)) {
if ($this->_parent->get('unscheduled')) {
$params[3] = array($to, 'String');
}
- $addtlStatuses = $this->_parent->get('archived') ? ", 'Canceled'" : '';
+ $dateClauses = array();
if (!empty($dateClause1)) {
- if (!$this->_parent->get('unscheduled')) {
- $dateClause1[] = "civicrm_mailing_job.status IN ('Complete', 'Running' $addtlStatuses)";
- $dateClause2[] = "civicrm_mailing_job.status IN ('Scheduled' $addtlStatuses)";
- }
-
- if (!empty($dateClause1)) {
- $dateClause1 = implode(' AND ', $dateClause1);
- }
- if (!empty($dateClause2)) {
- $dateClause2 = implode(' AND ', $dateClause2);
- }
-
- $dateC = NULL;
- if (!empty($dateClause1)) {
- $dateC = " ({$dateClause1}) ";
- }
- if (!empty($dateClause2)) {
- if ($dateC) {
- $dateC .= " OR ({$dateClause2}) ";
- }
- else {
- $dateC = " ({$dateClause2}) ";
- }
- }
- $clauses[] = " ({$dateC}) ";
+ $dateClauses[] = implode(' AND ', $dateClause1);
+ }
+ if (!empty($dateClause2)) {
+ $dateClauses[] = implode(' AND ', $dateClause2);
+ }
+ $dateClauses = implode(' OR ', $dateClauses);
+ if (!empty($dateClauses)) {
+ $clauses[] = "({$dateClauses})";
}
- if ($this->_parent->get('unscheduled')) {
- $clauses[] = "civicrm_mailing_job.status is null";
+ if ($this->_parent->get('status_unscheduled')) {
+ $clauses[] = "civicrm_mailing_job.status IS NULL";
$clauses[] = "civicrm_mailing.scheduled_id IS NULL";
}
if ($this->_parent->get('sms')) {
- $clauses[] = "(civicrm_mailing.sms_provider_id IS NOT NULL)";
+ $clauses[] = "civicrm_mailing.sms_provider_id IS NOT NULL";
}
else {
- $clauses[] = "(civicrm_mailing.sms_provider_id IS NULL)";
+ $clauses[] = "civicrm_mailing.sms_provider_id IS NULL";
}
+ $mailingStatus = $this->_parent->get('mailing_status');
+
// CRM-4290, do not show archived or unscheduled mails
// on 'Scheduled and Sent Mailing' page selector
- if ($this->_parent->get('scheduled')) {
+ if (!empty($mailingStatus)) {
$clauses[] = "civicrm_mailing.scheduled_id IS NOT NULL";
- $clauses[] = "( civicrm_mailing.is_archived IS NULL OR civicrm_mailing.is_archived = 0 )";
+ $clauses[] = "civicrm_mailing.scheduled_id IN ('" . implode("', '", array_keys($mailingStatus)) . "')";
}
- if (!$this->_parent->get('unscheduled')) {
-
- // all status filter implementation
- if ($status = $this->_parent->get('mailing_status')) {
- $status = array_keys($status);
- }
- if ($this->_parent->get('all_status')) {
- $status = $this->_parent->get('allStatuses');
- }
- if ($this->_parent->get('all_status') && $this->_parent->get('scheduled')) {
- $status = array('Scheduled', 'Complete', 'Running');
- }
- if (!empty($status)) {
- $status = implode("','", $status);
- $clauses[] = "civicrm_mailing_job.status IN ('$status')";
+ $isArchived = $this->_parent->get('is_archived');
+ if (isset($isArchived)) {
+ if ($isArchived) {
+ // CRM-6446: archived view should also show cancelled mailings
+ $clauses[] = "(civicrm_mailing.is_archived = 1 OR civicrm_mailing_job.status = 'Canceled')";
+ } else {
+ $clauses[] = "(civicrm_mailing.is_archived IS NULL OR civicrm_mailing.is_archived = 0)";
}
- elseif ($this->_parent->get('scheduled')) {
- $clauses[] = "civicrm_mailing_job.status IN ('Scheduled', 'Complete', 'Running')";
- }
- }
- if ($this->_parent->get('archived')) {
- // CRM-6446: archived view should also show cancelled mailings
- $clauses[] = "(civicrm_mailing.is_archived = 1 OR civicrm_mailing_job.status = 'Canceled')";
}
if ($sortBy &&
</item>
<item>
<path>civicrm/mailing/browse/scheduled</path>
- <title>Scheduled and Sent Mailings</title>
+ <title>Find Mailings</title>
<path_arguments>scheduled=true</path_arguments>
<page_callback>CRM_Mailing_Page_Browse</page_callback>
<access_arguments>access CiviMail;approve mailings;create mailings;schedule mailings</access_arguments>
</item>
<item>
<path>civicrm/mailing/browse/unscheduled</path>
- <title>Draft and Unscheduled Mailings</title>
+ <title>Find Mailings</title>
<path_arguments>scheduled=false</path_arguments>
<page_callback>CRM_Mailing_Page_Browse</page_callback>
<access_arguments>access CiviMail;create mailings;schedule mailings</access_arguments>
</item>
<item>
<path>civicrm/mailing/browse/archived</path>
- <title>Archived Mailings</title>
+ <title>Find Mailings</title>
<page_callback>CRM_Mailing_Page_Browse</page_callback>
<access_arguments>access CiviMail;create mailings</access_arguments>
<page_type>1</page_type>
<tr>
<td colspan="1">{$form.sort_name.label}<br />
{$form.sort_name.html|crmAddClass:big} {help id="id-create_sort_name"}
+ <br/><br/>
+ {$form.is_archived.label}<br/>
+ {$form.is_archived.html}
</td>
{if $form.mailing_status}
<td width="100%"><label>{if $sms eq 1}{ts}SMS Status{/ts}{else}{ts}Mailing Status{/ts}{/if}</label><br />
</div>
{/foreach}
<div class='odd-row'>
- {$form.all_status.html}
+ {$form.status_unscheduled.html}
</div>
</div><br />
</td>