Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vítězslav Dvořák
committed
Apr 5, 2024
1 parent
7066c5b
commit ec89671
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
/** | ||
* Multi Flexi - Periodical Tasks behaviour | ||
* | ||
* @author Vítězslav Dvořák <info@vitexsoftware.cz> | ||
* @copyright 2023-2024 Vitex Software | ||
*/ | ||
|
||
namespace MultiFlexi\Ui; | ||
|
||
use Ease\TWB4\WebPage; | ||
use MultiFlexi\AbraFlexi\Company; | ||
use MultiFlexi\Application; | ||
use MultiFlexi\RunTemplate; | ||
use MultiFlexi\Ui\PageBottom; | ||
use MultiFlexi\Ui\PageTop; | ||
|
||
require_once './init.php'; | ||
|
||
$oPage->onlyForLogged(); | ||
|
||
$runTemplater = new RunTemplate(); | ||
$runTemplater->loadFromSQL($runTemplater->runTemplateID(WebPage::getRequestValue('app'), $_SESSION['company'])); | ||
|
||
$actions = new \MultiFlexi\ActionConfig(); | ||
if (\Ease\WebPage::isPosted()) { | ||
$succesActions = ActionsChooser::toggles('success'); | ||
$failActions = ActionsChooser::toggles('fail'); | ||
$runTemplater->setDataValue('fail', serialize($failActions)); | ||
$runTemplater->setDataValue('success', serialize($succesActions)); | ||
$runTemplater->saveToSQL(); | ||
|
||
$actions->saveModeConfigs('success', ActionsChooser::formModuleCofig('success'), $runTemplater->getMyKey()); | ||
$actions->saveModeConfigs('fail', ActionsChooser::formModuleCofig('fail'), $runTemplater->getMyKey()); | ||
} else { | ||
$failActions = $runTemplater->getDataValue('fail') ? unserialize($runTemplater->getDataValue('fail')) : []; | ||
$succesActions = $runTemplater->getDataValue('success') ? unserialize($runTemplater->getDataValue('success')) : []; | ||
} | ||
|
||
$oPage->addItem(new PageTop(_('Periodical Tasks'))); | ||
|
||
$periodcalTaskInfo = $runTemplater->getData(); | ||
|
||
$app = new Application($periodcalTaskInfo['app_id']); | ||
|
||
$interval = new \Ease\Html\DivTag(_(\MultiFlexi\Job::codeToInterval($periodcalTaskInfo['interv'])) . ' ' . _('interval')); | ||
$appPanel = new ApplicationPanel($app, $interval); | ||
|
||
$runTemplateButton = new \Ease\TWB4\LinkButton('runtemplate.php?id=' . $runTemplater->getMyKey(), '⚗️ ' . _('Run Template'), 'dark btn-lg btn-block'); | ||
$appPanel->headRow->addColumn(2, $runTemplateButton); | ||
|
||
$actionsRow = new \Ease\TWB4\Row(); | ||
$actionsRow->addColumn(6, new \Ease\TWB4\Panel(_('Success Actions'), 'success', new ActionsChooser('success', $app, $succesActions), $periodcalTaskInfo['success'])); | ||
$actionsRow->addColumn(6, new \Ease\TWB4\Panel(_('Fail Actions'), 'danger', new ActionsChooser('fail', $app, $failActions), $periodcalTaskInfo['fail'])); | ||
|
||
$appPanel->addItem($actionsRow); | ||
$jobtempform = new \Ease\TWB4\Form(); | ||
$jobtempform->addItem(new \Ease\Html\InputHiddenTag('app', $periodcalTaskInfo['app_id'])); | ||
$jobtempform->addItem(new \Ease\Html\InputHiddenTag('company_id', $periodcalTaskInfo['company_id'])); | ||
$jobtempform->addItem(new \Ease\Html\InputHiddenTag('interval', $periodcalTaskInfo['interv'])); | ||
$jobtempform->addItem($appPanel); | ||
$jobtempform->addItem(new \Ease\TWB4\SubmitButton('🍏'._('Apply'), 'primary btn-lg btn-block')); | ||
|
||
$oPage->container->addItem(new CompanyPanel(new Company($periodcalTaskInfo['company_id']), $jobtempform)); | ||
|
||
$oPage->addItem(new PageBottom()); | ||
|
||
$oPage->finalizeRegistred(); | ||
$jobtempform->fillUp(ActionsChooser::sqlToForm($actions->getRuntemplateConfig($runTemplater->getMyKey()))); | ||
$oPage->draw(); |