diff --git a/src/MultiFlexi/RunTemplate.php b/src/MultiFlexi/RunTemplate.php index d9c5485..17bd51a 100644 --- a/src/MultiFlexi/RunTemplate.php +++ b/src/MultiFlexi/RunTemplate.php @@ -36,9 +36,11 @@ public function __construct($identifier = null, $options = []) * * SELECT runtemplate.id, runtemplate.interv, runtemplate.prepared, apps.name AS app, company.name AS company FROM runtemplate LEFT JOIN apps ON runtemplate.app_id=apps.id LEFT JOIN company ON runtemplate.company_id=company.id; * + * @deprecated since version 1.0 + * * @param int $appId * @param int $companyId - * + * * @return int */ public function runTemplateID(int $appId, int $companyId) diff --git a/src/MultiFlexi/Ui/ApplicationPanel.php b/src/MultiFlexi/Ui/ApplicationPanel.php index 48ccc6c..b663b5f 100644 --- a/src/MultiFlexi/Ui/ApplicationPanel.php +++ b/src/MultiFlexi/Ui/ApplicationPanel.php @@ -49,7 +49,7 @@ public function __construct($application, $content = null, $footer = null) $usedByCompany = new \Ease\Html\SpanTag(_('Used by') . ': '); foreach ($usedInCompanys as $companyInfo) { $companyInfo['id'] = $companyInfo['company_id']; - $usedByCompany->addItem(new CompanyLinkButton(new \MultiFlexi\Company($companyInfo, ['autoload' => false]), ['style' => 'height: 50px;'])); + $usedByCompany->addItem(new CompanyAppLinkButton(new \MultiFlexi\Company($companyInfo, ['autoload' => false]), $application->getMyKey(), ['style' => 'height: 50px;'])); } $this->headRow->addColumn(6, $usedByCompany); } else { diff --git a/src/MultiFlexi/Ui/CompanyAppLinkButton.php b/src/MultiFlexi/Ui/CompanyAppLinkButton.php new file mode 100644 index 0000000..adae51b --- /dev/null +++ b/src/MultiFlexi/Ui/CompanyAppLinkButton.php @@ -0,0 +1,25 @@ + + * @copyright 2023 Vitex Software + */ + +namespace MultiFlexi\Ui; + +/** + * Description of CompanyLinkButton + * + * @author vitex + */ +class CompanyAppLinkButton extends \Ease\TWB4\LinkButton +{ + public function __construct(\MultiFlexi\Company $company, $app_id , $properties = []) + { + parent::__construct('companyapp.php?company_id=' . $company->getMyKey().'&app_id='.$app_id, [ new CompanyLogo($company, ['style' => 'height: 100%']),' ', $company->getDataValue('code') ? $company->getDataValue('code') : $company->getRecordName()], 'inverse', $properties); + } +} diff --git a/src/MultiFlexi/Ui/CompanyAppSelector.php b/src/MultiFlexi/Ui/CompanyAppSelector.php index 702c4d9..e5a96a1 100644 --- a/src/MultiFlexi/Ui/CompanyAppSelector.php +++ b/src/MultiFlexi/Ui/CompanyAppSelector.php @@ -3,7 +3,7 @@ declare(strict_types=1); /** - * Multi Flexi - Select for Apps already assigned to comany + * Multi Flexi - Select for Apps already assigned to company * * @author Vítězslav Dvořák * @copyright 2023 Vitex Software diff --git a/src/MultiFlexi/Ui/CompanyAppsBar.php b/src/MultiFlexi/Ui/CompanyAppsBar.php new file mode 100644 index 0000000..8a2ab32 --- /dev/null +++ b/src/MultiFlexi/Ui/CompanyAppsBar.php @@ -0,0 +1,26 @@ + + * @copyright 2023 Vitex Software + */ + +namespace MultiFlexi\Ui; + +use MultiFlexi\Company; +use MultiFlexi\CompanyApp; + +class CompanyAppsBar extends \Ease\TWB4\Container { + + public function __construct(Company $company, $properties = []) { + parent::__construct('', []); + $companyApps = (new CompanyApp($company))->getAssigned()->leftJoin('apps ON apps.id = companyapp.app_id')->select(['apps.name', 'apps.description', 'apps.id', 'apps.image'], true)->fetchAll(); + foreach ($companyApps as $companyApp) { + $this->addItem(new \Ease\Html\ATag('companyapp.php?company_id=' . $company->getMyKey() . '&app_id=' . $companyApp['id'], new \Ease\Html\ImgTag($companyApp['image'], _($companyApp['name']), ['title' => _($companyApp['description']), 'height' => '50px', 'style' => 'padding: 5px; margin: 5px;', 'class'=>'button' ]))); + } + } +} diff --git a/src/company.php b/src/company.php index fbd1b2c..41e276f 100644 --- a/src/company.php +++ b/src/company.php @@ -54,7 +54,7 @@ $job['schedule'] = new \Ease\TWB4\LinkButton('schedule.php?cancel=' . $job['id'] . '&templateid=' . $job['runtemplateid'] . '&app_id=' . $job['app_id'] . '&company_id=' . $companies->getMyKey(), [_('Cancel') . '  ', new \Ease\Html\ImgTag('images/cancel.svg', _('Cancel'), ['height' => '30px'])], 'danger btn-lg'); } - $job['appimage'] = new ATag('companyapp.php?id=' . $job['runtemplateid'], [new \Ease\TWB4\Badge('light', [new \Ease\Html\ImgTag($job['appimage'], $job['appname'], ['height' => 50, 'title' => $job['appname']]), ' ', $job['appname']])]); + $job['appimage'] = new ATag('runtemplate.php?id=' . $job['runtemplateid'], [new \Ease\TWB4\Badge('light', [new \Ease\Html\ImgTag($job['appimage'], $job['appname'], ['height' => 50, 'title' => $job['appname']]), ' ', $job['appname']])]); unset($job['appname']); unset($job['runtemplateid']); unset($job['app_id']); @@ -76,6 +76,7 @@ $jobList->addRowColumns($job); } +$companyPanelContents[] = new CompanyAppsBar($companies); $companyPanelContents[] = new CompanyJobChart($jobber, ['id' => 'container']); $companyPanelContents[] = new \Ease\Html\H3Tag(_('job queue')); $companyPanelContents[] = $jobList; diff --git a/src/companyapp.php b/src/companyapp.php index 0f82e45..dbf4bc8 100644 --- a/src/companyapp.php +++ b/src/companyapp.php @@ -4,24 +4,44 @@ * Multi Flexi - Company instance editor. * * @author Vítězslav Dvořák - * @copyright 2023 Vitex Software + * @copyright 2024 Vitex Software */ namespace MultiFlexi\Ui; +use Ease\Html\SpanTag; +use MultiFlexi\Application; use MultiFlexi\Company; require_once './init.php'; $oPage->onlyForLogged(); -$oPage->addItem(new PageTop(_('Company Tasks'))); -$companyApp = new \MultiFlexi\RunTemplate(\Ease\Document::getRequestValue('id', 'int')); -$appData = $companyApp->getAppInfo(); -$companies = new Company($companyApp->getDataValue('company_id')); -if (strlen($companies->getDataValue('logo'))) { - $companyTasksHeading[] = new \Ease\Html\ImgTag($companies->getDataValue('logo'), 'logo', ['class' => 'img-fluid','style' => 'height']); -} -$companyTasksHeading[] = new \Ease\Html\SpanTag($companies->getDataValue('name') . ' ', ['style' => 'font-size: xxx-large;']); + +$companer = new Company(WebPage::getRequestValue('company_id', 'int')); +$application = new Application(WebPage::getRequestValue('app_id', 'int')); + +$oPage->addItem(new PageTop(_($application->getRecordName()) . '@' . $companer->getRecordName())); +//$companyApp = new \MultiFlexi\RunTemplate(\Ease\Document::getRequestValue('id', 'int')); +//$appData = $companyApp->getAppInfo(); +//$companies = new Company($companyApp->getDataValue('company_id')); +//if (strlen($companies->getDataValue('logo'))) { +// $companyTasksHeading[] = new \Ease\Html\ImgTag($companies->getDataValue('logo'), 'logo', ['class' => 'img-fluid','style' => 'height']); +//} + +$companyTasksHeading[] = new SpanTag($companer->getDataValue('name') . ' ', ['style' => 'font-size: xxx-large;']); $companyTasksHeading[] = _('Assigned applications'); -$oPage->container->addItem(new CompanyPanel($companies, new AppRow($appData))); + +$runTemplater = new \MultiFlexi\RunTemplate(); +$runtemplatesRaw = $runTemplater->listingQuery()->where('app_id',$application->getMyKey())->where('company_id',$companer->getMyKey()); + +$runtemplatesDiv = new \Ease\Html\DivTag(); + +foreach ($runtemplatesRaw as $runtemplateData) { + $runtemplateRow = new \Ease\TWB4\Row(); + $runtemplateRow->addColumn(1, '#' . strval($runtemplateData['id'])); + $runtemplateRow->addColumn(4, $runtemplateData['name']); + $runtemplatesDiv->addItem(new \Ease\Html\ATag('runtemplate.php?id=' . $runtemplateData['id'], $runtemplateRow)); +} + +$oPage->container->addItem(new CompanyPanel($companer, new ApplicationPanel($application, $runtemplatesDiv))); $oPage->addItem(new PageBottom()); $oPage->draw();