diff --git a/Controller/BackendController.php b/Controller/BackendController.php index c8e409a..a5f7829 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -15,7 +15,8 @@ declare(strict_types=1); namespace Modules\ContractManagement\Controller; use Modules\ContractManagement\Models\ContractMapper; -use Modules\ContractManagement\Models\ContractTypeL11n; +use Modules\ContractManagement\Models\ContractTypeMapper; +use Modules\Organization\Models\UnitMapper; use phpOMS\Contract\RenderableInterface; use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; @@ -53,17 +54,21 @@ final class BackendController extends Controller $view->setTemplate('/Modules/ContractManagement/Theme/Backend/contract-list'); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1007901001, $request, $response)); + $mapper = ContractMapper::getAll() + ->with('account') + ->limit(25); + if ($request->getData('ptype') === 'p') { $view->setData('contracts', - ContractMapper::getAll()->where('id', $request->getDataInt('id') ?? 0, '<')->limit(25)->execute() + $mapper->where('id', $request->getDataInt('id') ?? 0, '<')->execute() ); } elseif ($request->getData('ptype') === 'n') { $view->setData('contracts', - ContractMapper::getAll()->where('id', $request->getDataInt('id') ?? 0, '>')->limit(25)->execute() + $mapper->where('id', $request->getDataInt('id') ?? 0, '>')->execute() ); } else { $view->setData('contracts', - ContractMapper::getAll()->where('id', 0, '>')->limit(25)->execute() + $mapper->where('id', 0, '>')->execute() ); } @@ -89,7 +94,23 @@ final class BackendController extends Controller $view->setTemplate('/Modules/ContractManagement/Theme/Backend/contract-single'); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1007901001, $request, $response)); - $view->addData('contract', ContractMapper::get()->where('id', (int) $request->getData('id'))->execute()); + $contract = ContractMapper::get() + ->with('account') + ->with('files') + ->where('id', (int) $request->getData('id')) + ->sort('files/id', 'DESC') + ->execute(); + $view->addData('contract', $contract); + + $contractTypes = ContractTypeMapper::getAll() + ->with('l11n') + ->where('l11n/language', $response->getLanguage()) + ->execute(); + $view->setData('contractTypes', $contractTypes); + + $units = UnitMapper::getAll() + ->execute(); + $view->setData('units', $units); $editor = new \Modules\Editor\Theme\Backend\Components\Editor\BaseView($this->app->l11nManager, $request, $response); $view->addData('editor', $editor); diff --git a/Models/Contract.php b/Models/Contract.php index bf2abcd..13938af 100755 --- a/Models/Contract.php +++ b/Models/Contract.php @@ -54,8 +54,13 @@ class Contract public string $description = ''; + // The original start of the contract ignoring renewals + public \DateTime $originalStart; + + // Start of the contract considering renewals public ?\DateTime $start = null; + // End of the contract considering renewals public ?\DateTime $end = null; /** @@ -73,6 +78,7 @@ class Contract public ?int $responsible = null; + // Contract with public Account $account; /** diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 57e6b07..315a4e9 100755 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -20,4 +20,11 @@ return ['ContractManagement' => [ 'Files' => 'Files', 'Overview' => 'Overview', 'Title' => 'Title', + 'With' => 'With', + 'Start' => 'Start', + 'Description' => 'Description', + 'AutoRenewal' => 'Auto Renewal', + 'Termination' => 'Termination', + 'Costs' => 'Costs', + 'Unit' => 'Unit', ]]; diff --git a/Theme/Backend/contract-list.tpl.php b/Theme/Backend/contract-list.tpl.php index cfe04dc..494a83e 100755 --- a/Theme/Backend/contract-list.tpl.php +++ b/Theme/Backend/contract-list.tpl.php @@ -30,7 +30,7 @@ echo $this->getData('nav')->render(); ?>
-
getHtml('Contracts'); ?>
+
getHtml('Contracts'); ?>
@@ -47,7 +47,7 @@ echo $this->getData('nav')->render(); ?> -
getHtml('Account'); ?> + getHtml('With'); ?>