Skip to content

Commit

Permalink
Merge pull request #10 from TheDMSGroup/ENG-598
Browse files Browse the repository at this point in the history
[ENG-598] contact export issues
  • Loading branch information
heathdutton authored Dec 19, 2018
2 parents 8b2e47e + 2edc5f3 commit 555ea2d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
20 changes: 11 additions & 9 deletions Controller/ExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public function campaignContactsExportAction($campaignId, $dateFrom, $dateTo)
list($dateFrom, $dateTo) = $this->convertDateParams($dateFrom, $dateTo);
$contactIds = $this->getCampaignLeadIdsForExport($campaign->getId(), $dateFrom, $dateTo);

if (empty($contactIds)) {
return $this->notFound('mautic.campaignwatch.export.nocontacts');
}

// adjust $size for memory vs. speed
$batches = array_chunk($contactIds, 100);

Expand Down Expand Up @@ -112,8 +116,8 @@ public function getCampaignLeadIdsForExport($campaignId, $dateFrom, $dateTo)
->where(
$q->expr()->eq('cl.manually_removed', ':false'),
$q->expr()->eq('cl.campaign_id', ':campaign'),
$q->expr()->gte('cl.date_added', ':dateFrom'),
$q->expr()->lt('cl.date_added', ':dateTo')
$q->expr()->gte('cl.date_added', 'FROM_UNIXTIME(:dateFrom)'),
$q->expr()->lt('cl.date_added', 'FROM_UNIXTIME(:dateTo)')
)
->setParameter('false', false, 'boolean')
->setParameter('campaign', $campaignId)
Expand All @@ -136,16 +140,14 @@ public function getCampaignLeadIdsForExport($campaignId, $dateFrom, $dateTo)
*/
private function convertDateParams($dateFrom, $dateTo)
{
$timezone = new \DateTimeZone('UTC');

$dateFromConverted = new \DateTime($dateFrom, $timezone);
$dateFromConverted = new \DateTime($dateFrom);

$dateToConverted = new \DateTime($dateTo, $timezone);
$dateToConverted->modify('+1 day');
$dateToConverted = new \DateTime($dateTo);
$dateToConverted->modify('+1 day -1 second');

return [
$dateFromConverted->format('Y-m-d H:i:s'),
$dateToConverted->format('Y-m-d H:i:s'),
$dateFromConverted->getTimestamp(),
$dateToConverted->getTimestamp(),
];
}

Expand Down
1 change: 1 addition & 0 deletions Translations/en_US/messages.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ mautic.campaignwatch.export.notfound = "Cannot Export Contact List. The campaign
mautic.report.campaign.pending.actions = "Dropped Contacts and Pending Actions"
mautic.campaignwatch.stat_chart.toggle.label = "Exclude Campaign Details Stats Chart"
mautic.campaignwatch.stat_chart.toggle.tooltip = "Set to yes to improved perfomance of Campaign pages by excluding Campaign Statistics"
mautic.campaignwatch.export.nocontacts = "Cannot Export Contact List. There were no contacts to export."

0 comments on commit 555ea2d

Please sign in to comment.