Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 43 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| SupportPageController | |
0.00% |
0 / 43 |
|
0.00% |
0 / 4 |
56 | |
0.00% |
0 / 1 |
| pageSupport | |
0.00% |
0 / 40 |
|
0.00% |
0 / 1 |
20 | |||
| pageArticle | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| pageCategory | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| pageSearch | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * SupportPageController |
| 4 | * |
| 5 | * Handles rendering of the Support Portal pages within the Workspace. |
| 6 | * The support portal is integrated as an SPA view within workspace.html. |
| 7 | */ |
| 8 | |
| 9 | namespace BuyerKiosk\Support\Controllers; |
| 10 | |
| 11 | use BuyerKiosk\Core\Controllers\BaseController; |
| 12 | |
| 13 | class SupportPageController extends BaseController |
| 14 | { |
| 15 | /** |
| 16 | * Render the Support Portal within Workspace |
| 17 | * |
| 18 | * GET /:typeNum/support/ |
| 19 | * |
| 20 | * Uses the combined workspace template with activePage='support' |
| 21 | * to enable SPA-style navigation between Queue, Workbook, and Support. |
| 22 | * |
| 23 | * @param string $typeNum Store type number |
| 24 | */ |
| 25 | public function pageSupport($typeNum) |
| 26 | { |
| 27 | $app = $this->_app; |
| 28 | |
| 29 | // Check user has store access OR is a support admin (for previewing articles) |
| 30 | if (!$app->user->checkStoreGroup($typeNum) && !$app->user->checkAccess('uri_support_admin')) { |
| 31 | $app->notAuthorized(); |
| 32 | return; |
| 33 | } |
| 34 | |
| 35 | // Get store |
| 36 | $storeController = new \BuyerKiosk\StoreController($typeNum); |
| 37 | $store = $storeController->getStore(); |
| 38 | |
| 39 | if (!$store) { |
| 40 | $app->notFound(); |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | // Get store directory for CSS/asset paths |
| 45 | $storeDir = \getStoreDirectory($store); |
| 46 | |
| 47 | // Get database connection for queue data (needed for workspace template) |
| 48 | $db = \dbConnectByName($store->getDbName()); |
| 49 | |
| 50 | // Get queue data (needed for the combined template) |
| 51 | $BuyQueue = new \BuyQueue(); |
| 52 | $BuyQueue->createStore($typeNum); |
| 53 | $queueItemArray = $BuyQueue->getAllCurrentQueueItems($db); |
| 54 | |
| 55 | // Get completed buys data (needed for SPA navigation) |
| 56 | $completedBuysArray = \getCompletedBuysArray($store); |
| 57 | |
| 58 | // Get breadcrumb data |
| 59 | $minutesPerContainer = $store->getMinutesPerContainer(); |
| 60 | |
| 61 | // Use combined workspace template with support active |
| 62 | $app->render('workspace/workspace.html', [ |
| 63 | 'page' => [ |
| 64 | 'title' => 'Help Center', |
| 65 | 'typeNum' => $typeNum, |
| 66 | 'storeType' => $storeDir, |
| 67 | 'timeZone' => $store->getTimezone() |
| 68 | ], |
| 69 | 'store' => $store, |
| 70 | 'typeNum' => $typeNum, |
| 71 | 'token' => $app->csrf_token, |
| 72 | 'activePage' => 'support', // This makes support view active |
| 73 | 'user' => $app->user, |
| 74 | 'ably_key' => $_ENV['ABLY_KEY'] ?? '', |
| 75 | 'breadcrumb' => [ |
| 76 | 'storeType' => $store->getStoreType(), |
| 77 | 'storeCity' => $store->getCity(), |
| 78 | 'waitTime' => $minutesPerContainer |
| 79 | ], |
| 80 | 'queue' => $queueItemArray, |
| 81 | 'completedBuys' => $completedBuysArray, |
| 82 | 'workbookEnabled' => true, |
| 83 | 'activeTab' => 'support', |
| 84 | 'enableQueueSignIn' => $store->getEnableQueueSignIn() |
| 85 | ]); |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Render a single article view within Workspace |
| 90 | * |
| 91 | * GET /:typeNum/support/article/:slug/ |
| 92 | * |
| 93 | * The article will be loaded via JavaScript in the support view. |
| 94 | * |
| 95 | * @param string $typeNum Store type number |
| 96 | * @param string $slug Article slug |
| 97 | */ |
| 98 | public function pageArticle($typeNum, $slug) |
| 99 | { |
| 100 | // For SPA, just render the support page - JS will handle loading the article |
| 101 | $this->pageSupport($typeNum); |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Render a category listing page within Workspace |
| 106 | * |
| 107 | * GET /:typeNum/support/category/:categorySlug/ |
| 108 | * |
| 109 | * The category will be loaded via JavaScript in the support view. |
| 110 | * |
| 111 | * @param string $typeNum Store type number |
| 112 | * @param string $categorySlug Category slug |
| 113 | */ |
| 114 | public function pageCategory($typeNum, $categorySlug) |
| 115 | { |
| 116 | // For SPA, just render the support page - JS will handle loading the category |
| 117 | $this->pageSupport($typeNum); |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * Render search results page within Workspace |
| 122 | * |
| 123 | * GET /:typeNum/support/search/ |
| 124 | * |
| 125 | * Search results will be loaded via JavaScript in the support view. |
| 126 | * |
| 127 | * @param string $typeNum Store type number |
| 128 | */ |
| 129 | public function pageSearch($typeNum) |
| 130 | { |
| 131 | // For SPA, just render the support page - JS will handle search |
| 132 | $this->pageSupport($typeNum); |
| 133 | } |
| 134 | } |