PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.11.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.11.1
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Controllers / FollowupsController.php

FollowupsController.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.11.1, at back/Controllers/FollowupsController.php

84 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\Controllers;
4
5 use AcyMailing\Classes\CampaignClass;
6 use AcyMailing\Classes\FollowupClass;
7 use AcyMailing\Classes\MailClass;
8 use AcyMailing\Classes\MailStatClass;
9 use AcyMailing\Classes\UrlClickClass;
10 use AcyMailing\Core\AcymController;
11
12 class FollowupsController extends AcymController
13 {
14 public function getEmailsListing(): void
15 {
16 $id = acym_getVar('int', 'id', 0);
17 if (empty($id)) {
18 acym_sendAjaxResponse(acym_translation('ACYM_FOLLOWUP_NOT_FOUND'), [], false);
19 }
20
21 $followupClass = new FollowupClass();
22 $emailIds = $followupClass->getEmailsByIds([$id]);
23 if (empty($emailIds)) {
24 acym_sendAjaxResponse(acym_translation('ACYM_NO_EMAIL_FOR_FOLLOWUP'), [], false);
25 }
26
27 $mailClass = new MailClass();
28 $mailStatClass = new MailStatClass();
29 $campaignClass = new CampaignClass();
30 $urlClickClass = new UrlClickClass();
31 $data = [];
32 foreach ($emailIds as $oneMailId) {
33 $mail = $mailClass->getOneById($oneMailId);
34 if (empty($mail)) continue;
35
36 $thisMailStats = [
37 'subject' => $mail->subject,
38 ];
39
40 $stats = $mailStatClass->getOneById($oneMailId);
41
42 if (empty($stats)) {
43 $thisMailStats['sent'] = '0';
44 $thisMailStats['open'] = '-';
45 $thisMailStats['click'] = '-';
46 $thisMailStats['income'] = '-';
47 } else {
48 $stats->subscribers = $stats->sent;
49 $campaignClass->getStatsCampaign($stats, $urlClickClass);
50
51 $trackingSale = empty($stats->tracking_sale) ? 0 : round($stats->tracking_sale, 2);
52
53 $thisMailStats['sent'] = empty($stats->sent) ? '0' : $stats->sent;
54 $thisMailStats['open'] = empty($stats->open) ? '0%' : $stats->open.'%';
55 $thisMailStats['click'] = empty($stats->click) ? '0%' : $stats->click.'%';
56 $thisMailStats['income'] = $trackingSale.' '.$stats->currency;
57 }
58
59 $data[] = $thisMailStats;
60 }
61
62 acym_sendAjaxResponse('', $data);
63 }
64
65 public function addQueueAjax(): void
66 {
67 acym_checkToken();
68
69 $emailId = acym_getVar('int', 'emailId', 0);
70 if (empty($emailId)) {
71 acym_sendAjaxResponse(acym_translation('ACYM_EMAIL_NOT_FOUND'), [], false);
72 }
73
74 $followupClass = new FollowupClass();
75 $queued = $followupClass->queueForSubscribers($emailId);
76
77 if ($queued === false) {
78 acym_sendAjaxResponse(acym_translation('ACYM_ERROR_ADD_QUEUE'), [], false);
79 }
80
81 acym_sendAjaxResponse(acym_translationSprintf('ACYM_EMAILS_ADDED_QUEUE', $queued));
82 }
83 }
84