Skip to content

Commit

Permalink
#13 Initial overview of multiple Runtemplates for one app
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Apr 23, 2024
1 parent 71c1990 commit 6d5c755
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 14 deletions.
4 changes: 3 additions & 1 deletion src/MultiFlexi/RunTemplate.php
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/MultiFlexi/Ui/ApplicationPanel.php
Expand Up @@ -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 {
Expand Down
25 changes: 25 additions & 0 deletions src/MultiFlexi/Ui/CompanyAppLinkButton.php
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

/**
* Multi Flexi - CompanyLink Button
*
* @author Vítězslav Dvořák <info@vitexsoftware.cz>
* @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%']),'&nbsp;', $company->getDataValue('code') ? $company->getDataValue('code') : $company->getRecordName()], 'inverse', $properties);
}
}
2 changes: 1 addition & 1 deletion src/MultiFlexi/Ui/CompanyAppSelector.php
Expand Up @@ -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 <info@vitexsoftware.cz>
* @copyright 2023 Vitex Software
Expand Down
26 changes: 26 additions & 0 deletions src/MultiFlexi/Ui/CompanyAppsBar.php
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

/**
* Multi Flexi - Select for Apps already assigned to comany
*
* @author Vítězslav Dvořák <info@vitexsoftware.cz>
* @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' ])));
}
}
}
3 changes: 2 additions & 1 deletion src/company.php
Expand Up @@ -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') . '&nbsp;&nbsp;', 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']]), '&nbsp;', $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']]), '&nbsp;', $job['appname']])]);
unset($job['appname']);
unset($job['runtemplateid']);
unset($job['app_id']);
Expand All @@ -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;
Expand Down
40 changes: 30 additions & 10 deletions src/companyapp.php
Expand Up @@ -4,24 +4,44 @@
* Multi Flexi - Company instance editor.
*
* @author Vítězslav Dvořák <info@vitexsoftware.cz>
* @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') . '&nbsp;', ['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') . '&nbsp;', ['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();

0 comments on commit 6d5c755

Please sign in to comment.