| @@ -1,0 +1,83 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace AcyMailing\Controllers\Queue; | |
| 4 | + | |
| 5 | +use AcyMailing\Classes\QueueClass; | |
| 6 | +use AcyMailing\Classes\TagClass; | |
| 7 | +use AcyMailing\Helpers\PaginationHelper; | |
| 8 | +use AcyMailing\Helpers\ToolbarHelper; | |
| 9 | +use AcyMailing\Helpers\WorkflowHelper; | |
| 10 | + | |
| 11 | +trait Detailed | |
| 12 | +{ | |
| 13 | + public function detailed(): void | |
| 14 | + { | |
| 15 | + acym_setVar('layout', 'detailed'); | |
| 16 | + $pagination = new PaginationHelper(); | |
| 17 | + | |
| 18 | + // Get filters data | |
| 19 | + $searchFilter = $this->getVarFiltersListing('string', 'dqueue_search', ''); | |
| 20 | + $tagFilter = $this->getVarFiltersListing('string', 'dqueue_tag', ''); | |
| 21 | + | |
| 22 | + // Get pagination data | |
| 23 | + $elementsPerPage = $pagination->getListLimit(); | |
| 24 | + $page = $this->getVarFiltersListing('int', 'dqueue_pagination_page', 1); | |
| 25 | + | |
| 26 | + $queueClass = new QueueClass(); | |
| 27 | + $matchingElements = $queueClass->getMatchingResults( | |
| 28 | + [ | |
| 29 | + 'search' => $searchFilter, | |
| 30 | + 'tag' => $tagFilter, | |
| 31 | + 'elementsPerPage' => $elementsPerPage, | |
| 32 | + 'offset' => ($page - 1) * $elementsPerPage, | |
| 33 | + ] | |
| 34 | + ); | |
| 35 | + | |
| 36 | + // Prepare the pagination | |
| 37 | + $pagination->setStatus((int)$matchingElements['total']->total, $page, $elementsPerPage); | |
| 38 | + | |
| 39 | + $tagClass = new TagClass(); | |
| 40 | + $viewData = [ | |
| 41 | + 'allElements' => $matchingElements['elements'], | |
| 42 | + 'pagination' => $pagination, | |
| 43 | + 'search' => $searchFilter, | |
| 44 | + 'tag' => $tagFilter, | |
| 45 | + 'allTags' => $tagClass->getAllTagsByType(TagClass::TYPE_MAIL), | |
| 46 | + 'workflowHelper' => new WorkflowHelper(), | |
| 47 | + ]; | |
| 48 | + | |
| 49 | + $this->prepareToolbarDetailed($viewData); | |
| 50 | + | |
| 51 | + $this->breadcrumb[acym_translation('ACYM_QUEUE_DETAILED')] = acym_completeLink('queue&task=detailed'); | |
| 52 | + parent::display($viewData); | |
| 53 | + } | |
| 54 | + | |
| 55 | + public function prepareToolbarDetailed(array &$data): void | |
| 56 | + { | |
| 57 | + $toolbarHelper = new ToolbarHelper(); | |
| 58 | + $toolbarHelper->addSearchBar($data['search'], 'dqueue_search', 'ACYM_SEARCH'); | |
| 59 | + $toolbarHelper->addModalButton( | |
| 60 | + [ | |
| 61 | + 'button' => '<i class="acymicon-paper-plane"></i>'.esc_html(acym_translation('ACYM_SEND_ALL')), | |
| 62 | + 'attributesModal' => [ | |
| 63 | + 'data-reveal-larger' => true, | |
| 64 | + ], | |
| 65 | + 'attributesButton' => [ | |
| 66 | + 'class' => 'cell medium-shrink button', | |
| 67 | + 'data-reload' => 'true', | |
| 68 | + 'data-ajax' => 'true', | |
| 69 | + 'data-iframe' => '&ctrl=queue&task=continuesend&id=0&totalsend=0', | |
| 70 | + ], | |
| 71 | + ] | |
| 72 | + ); | |
| 73 | + $toolbarHelper->addFilterByTag($data, 'dqueue_tag', 'acym__queue__filter__tags acym__select'); | |
| 74 | + | |
| 75 | + $data['toolbar'] = $toolbarHelper; | |
| 76 | + $data['cleartask'] = 'detailed'; | |
| 77 | + if (!empty($data['tag'])) { | |
| 78 | + $data['status_toolbar'] = [ | |
| 79 | + 'dqueue_tag' => $data['tag'], | |
| 80 | + ]; | |
| 81 | + } | |
| 82 | + } | |
| 83 | +} | |