| @@ -1,77 +1,0 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace AcyMailing\Controllers\Queue; | |
| 4 | - | |
| 5 | -use AcyMailing\Classes\CampaignClass; | |
| 6 | -use AcyMailing\Classes\QueueClass; | |
| 7 | -use AcyMailing\Classes\TagClass; | |
| 8 | -use AcyMailing\Helpers\PaginationHelper; | |
| 9 | -use AcyMailing\Helpers\ToolbarHelper; | |
| 10 | -use AcyMailing\Helpers\WorkflowHelper; | |
| 11 | - | |
| 12 | -trait Scheduled | |
| 13 | -{ | |
| 14 | - public function scheduled(): void | |
| 15 | - { | |
| 16 | - acym_setVar('layout', 'scheduled'); | |
| 17 | - | |
| 18 | - // Get filters data | |
| 19 | - $searchFilter = $this->getVarFiltersListing('string', 'squeue_search', ''); | |
| 20 | - $tagFilter = $this->getVarFiltersListing('string', 'squeue_tag', ''); | |
| 21 | - | |
| 22 | - // Get pagination data | |
| 23 | - $pagination = new PaginationHelper(); | |
| 24 | - $campaignsPerPage = $pagination->getListLimit(); | |
| 25 | - $page = $this->getVarFiltersListing('int', 'squeue_pagination_page', 1); | |
| 26 | - | |
| 27 | - $queueClass = new QueueClass(); | |
| 28 | - $matchingElements = $queueClass->getMatchingScheduledCampaigns( | |
| 29 | - [ | |
| 30 | - 'search' => $searchFilter, | |
| 31 | - 'tag' => $tagFilter, | |
| 32 | - 'campaignsPerPage' => $campaignsPerPage, | |
| 33 | - 'offset' => ($page - 1) * $campaignsPerPage, | |
| 34 | - ] | |
| 35 | - ); | |
| 36 | - | |
| 37 | - // Prepare the pagination | |
| 38 | - $pagination->setStatus((int)$matchingElements['total']->total, $page, $campaignsPerPage); | |
| 39 | - $tagClass = new TagClass(); | |
| 40 | - | |
| 41 | - $viewData = [ | |
| 42 | - 'allElements' => $matchingElements['elements'], | |
| 43 | - 'pagination' => $pagination, | |
| 44 | - 'search' => $searchFilter, | |
| 45 | - 'tag' => $tagFilter, | |
| 46 | - 'allTags' => $tagClass->getAllTagsByType(TagClass::TYPE_MAIL), | |
| 47 | - 'campaignClass' => new CampaignClass(), | |
| 48 | - 'languages' => acym_getLanguages(), | |
| 49 | - 'workflowHelper' => new WorkflowHelper(), | |
| 50 | - ]; | |
| 51 | - | |
| 52 | - $this->prepareScheduledToolbar($viewData); | |
| 53 | - | |
| 54 | - $this->breadcrumb[acym_translation('ACYM_SCHEDULED')] = acym_completeLink('queue&task=scheduled'); | |
| 55 | - parent::display($viewData); | |
| 56 | - } | |
| 57 | - | |
| 58 | - public function prepareScheduledToolbar(array &$data): void | |
| 59 | - { | |
| 60 | - $toolbarHelper = new ToolbarHelper(); | |
| 61 | - $toolbarHelper->addSearchBar($data['search'], 'squeue_search'); | |
| 62 | - $toolbarHelper->addFilterByTag($data, 'squeue_tag', 'acym__queue__filter__tags acym__select'); | |
| 63 | - | |
| 64 | - $data['toolbar'] = $toolbarHelper; | |
| 65 | - if (!empty($data['tag'])) { | |
| 66 | - $data['status_toolbar'] = [ | |
| 67 | - 'squeue_tag' => $data['tag'], | |
| 68 | - ]; | |
| 69 | - } | |
| 70 | - } | |
| 71 | - | |
| 72 | - public function cancelScheduledSending(): void | |
| 73 | - { | |
| 74 | - $this->cancelSending(); | |
| 75 | - $this->scheduled(); | |
| 76 | - } | |
| 77 | -} | |