<?php
 namespace Modules\Admin\ReportsDataStatus\Disable; class Controller extends \App\Mvc\Controller\Form\PopupAbstract { protected function initialize() { parent::initialize(); $this->actionsCfg['index'] = ['checkSection' => 'Modules/Admin/ReportsDataStatus', 'checkOption' => false,]; } protected function getDefaultFormData($R) { return $R; } protected function processFormData(array $R, \App\MessagesCollector $msgs) { $formData = $R; if ($formData['disable']) { if (strtolower($formData['confirmation']) !== strtolower($this->globalLang['yes'])) { $msgs->addError(sprintf($this->lang['messages']['confirmationNotOk'], $this->globalLang['yes'])); } if ($msgs->hasErrorOrWarning()) { return false; } try { \App\ReportsData\Params::getAdmin()->saveStatusToDisabled(); $msgs->addSuccess($this->lang['messages']['success']['disable']); return true; } catch (\App\MessagesException $e) { $msgs->appendMessages($e->getMessagesCollector()); return false; } } if ($formData['enable']) { try { \App\ReportsData\Params::getAdmin()->saveStatusToPending(); $msgs->addSuccess($this->lang['messages']['success']['enable']); return true; } catch (\App\MessagesException $e) { $msgs->appendMessages($e->getMessagesCollector()); return false; } } } }