From 83efadb3a38345b8bc9792ca1ec32750729dd36b Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 2 Apr 2024 21:40:47 +0000 Subject: [PATCH] template fixes + bug fixes + style fixes --- Admin/Routes/Web/Backend.php | 2 +- Controller/ApiController.php | 2 +- Controller/BackendController.php | 127 ++++--- Theme/Backend/Lang/de.lang.php | 6 + Theme/Backend/Lang/en.lang.php | 8 +- Theme/Backend/costcenter-list.tpl.php | 4 +- Theme/Backend/costobject-list.tpl.php | 4 +- Theme/Backend/entries.tpl.php | 6 +- Theme/Backend/personal-profile.tpl.php | 479 ------------------------- Theme/Backend/personal-view.tpl.php | 156 ++++++-- tests/Models/CostCenterMapperTest.php | 8 +- tests/Models/CostObjectMapperTest.php | 8 +- 12 files changed, 228 insertions(+), 582 deletions(-) delete mode 100644 Theme/Backend/personal-profile.tpl.php diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index bc59c19..42ece06 100755 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -18,7 +18,7 @@ use phpOMS\Account\PermissionType; use phpOMS\Router\RouteVerb; return [ - '^/accounting/entries(\?.*$|$)' => [ + '^/accounting/entries/dashboard(\?.*$|$)' => [ [ 'dest' => '\Modules\Accounting\Controller\BackendController:viewEntries', 'verb' => RouteVerb::GET, diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 3a6a1c4..221bfb8 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -349,7 +349,7 @@ final class ApiController extends Controller // https://github.com/Karaka-Management/oms-Accounting/issues/8 $request->header->account = $account; - $request->setData('code', $new->number); + $request->setData('code', $new->number . '-1'); $request->setData('content', \rtrim($new->account->name1 . ' ' . $new->account->name2)); $request->setData('language', ISO639x1Enum::_EN); $request->setData('type', $accountType); diff --git a/Controller/BackendController.php b/Controller/BackendController.php index a1554d1..cb241f9 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -218,7 +218,8 @@ final class BackendController extends Controller $view->data['accounts'] = AccountAbstractMapper::getAll() ->with('l11n') ->where('l11n/language', $response->header->l11n->language) - ->execute(); + ->where('account', null) + ->executeGetArray(); return $view; } @@ -253,7 +254,7 @@ final class BackendController extends Controller /** @var \phpOMS\Localization\BaseStringL11n[] $l11nValues */ $l11nValues = AccountL11nMapper::getAll() ->where('ref', $view->data['account']->id) - ->execute(); + ->executeGetArray(); $view->data['l11nValues'] = $l11nValues; @@ -359,7 +360,7 @@ final class BackendController extends Controller /** @var \phpOMS\Localization\BaseStringL11n[] $l11nValues */ $l11nValues = CostCenterL11nMapper::getAll() ->where('ref', $view->data['costcenter']->id) - ->execute(); + ->executeGetArray(); $view->data['l11nValues'] = $l11nValues; @@ -396,7 +397,7 @@ final class BackendController extends Controller /** @var \phpOMS\Localization\BaseStringL11n[] $l11nValues */ $l11nValues = CostObjectL11nMapper::getAll() ->where('ref', $view->data['costobject']->id) - ->execute(); + ->executeGetArray(); $view->data['l11nValues'] = $l11nValues; @@ -427,10 +428,10 @@ final class BackendController extends Controller ->limit(25); if ($request->getData('ptype') === 'p') { - $view->data['costcenter'] = $mapper->where('id', $request->getDataInt('id') ?? 0, '<') + $view->data['costcenter'] = $mapper->where('id', $request->getDataInt('offset') ?? 0, '<') ->execute(); } elseif ($request->getData('ptype') === 'n') { - $view->data['costcenter'] = $mapper->where('id', $request->getDataInt('id') ?? 0, '>') + $view->data['costcenter'] = $mapper->where('id', $request->getDataInt('offset') ?? 0, '>') ->execute(); } else { $view->data['costcenter'] = $mapper->where('id', 0, '>') @@ -464,10 +465,10 @@ final class BackendController extends Controller ->limit(25); if ($request->getData('ptype') === 'p') { - $view->data['costobject'] = $mapper->where('id', $request->getDataInt('id') ?? 0, '<') + $view->data['costobject'] = $mapper->where('id', $request->getDataInt('offset') ?? 0, '<') ->execute(); } elseif ($request->getData('ptype') === 'n') { - $view->data['costobject'] = $mapper->where('id', $request->getDataInt('id') ?? 0, '>') + $view->data['costobject'] = $mapper->where('id', $request->getDataInt('offset') ?? 0, '>') ->execute(); } else { $view->data['costobject'] = $mapper->where('id', 0, '>') @@ -499,7 +500,7 @@ final class BackendController extends Controller ->with('account') ->with('mainAddress') ->limit(25) - ->execute(); + ->executeGetArray(); $view->data['accounts'] = $accounts; @@ -528,7 +529,7 @@ final class BackendController extends Controller ->with('account') ->with('mainAddress') ->limit(25) - ->execute(); + ->executeGetArray(); $view->data['accounts'] = $accounts; @@ -561,13 +562,54 @@ final class BackendController extends Controller $view->setTemplate('/Modules/Accounting/Theme/Backend/personal-view'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002604001, $request, $response); - $account = SupplierMapper::get() + $view->data['account'] = SupplierMapper::get() ->with('account') + ->with('account/addresses') + ->with('account/contacts') ->with('mainAddress') + ->with('files')->limit(5, 'files')->sort('files/id', OrderType::DESC) + ->with('notes')->limit(5, 'notes')->sort('notes/id', OrderType::DESC) + ->with('attributes') + ->with('attributes/type') + ->with('attributes/type/l11n') + ->with('attributes/value') ->where('id', (int) $request->getData('id')) ->execute(); - $view->data['account'] = $account; + $view->data['fiAccounts'] = AccountAbstractMapper::getAll() + ->where('account', $view->data['account']->account->id) + ->executeGetArray(); + + $view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response); + $view->data['attributeView']->data['default_localization'] = $this->app->l11nServer; + + $view->data['attributeTypes'] = ClientAttributeTypeMapper::getAll() + ->with('l11n') + ->where('l11n/language', $response->header->l11n->language) + ->executeGetArray(); + + // Get item profile image + // @feature Create a new read mapper function that returns relation models instead of its own model + // https://github.com/Karaka-Management/phpOMS/issues/320 + $query = new Builder($this->app->dbPool->get()); + $results = $query->selectAs(SupplierMapper::HAS_MANY['files']['external'], 'file') + ->from(SupplierMapper::TABLE) + ->leftJoin(SupplierMapper::HAS_MANY['files']['table']) + ->on(SupplierMapper::HAS_MANY['files']['table'] . '.' . SupplierMapper::HAS_MANY['files']['self'], '=', SupplierMapper::TABLE . '.' . SupplierMapper::PRIMARYFIELD) + ->leftJoin(MediaMapper::TABLE) + ->on(SupplierMapper::HAS_MANY['files']['table'] . '.' . SupplierMapper::HAS_MANY['files']['external'], '=', MediaMapper::TABLE . '.' . MediaMapper::PRIMARYFIELD) + ->leftJoin(MediaMapper::HAS_MANY['types']['table']) + ->on(MediaMapper::TABLE . '.' . MediaMapper::PRIMARYFIELD, '=', MediaMapper::HAS_MANY['types']['table'] . '.' . MediaMapper::HAS_MANY['types']['self']) + ->leftJoin(MediaTypeMapper::TABLE) + ->on(MediaMapper::HAS_MANY['types']['table'] . '.' . MediaMapper::HAS_MANY['types']['external'], '=', MediaTypeMapper::TABLE . '.' . MediaTypeMapper::PRIMARYFIELD) + ->where(SupplierMapper::HAS_MANY['files']['self'], '=', $view->data['account']->id) + ->where(MediaTypeMapper::TABLE . '.' . MediaTypeMapper::getColumnByMember('name'), '=', 'supplier_profile_image'); + + $view->data['accountImage'] = MediaMapper::get() + ->with('types') + ->where('id', $results) + ->limit(1) + ->execute(); $businessStart = UnitAttributeMapper::get() ->with('type') @@ -578,25 +620,25 @@ final class BackendController extends Controller $view->data['business_start'] = $businessStart->id === 0 ? 1 : $businessStart->value->getValue(); - $view->data['hasBilling'] = $this->app->moduleManager->isActive('Billing'); + $view->data['audits'] = AuditMapper::getAll() + ->where('type', StringUtils::intHash(ClientMapper::class)) + ->where('module', 'ClientManagement') + ->where('ref', (string) $view->data['account']->id) + ->executeGetArray(); - $view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response); - $view->data['attributeView']->data['default_localization'] = $this->app->l11nServer; - - /** @var \Modules\Media\Models\Media[] $files */ - $files = MediaMapper::getAll() + $view->data['files'] = MediaMapper::getAll() ->with('types') ->join('id', ClientMapper::class, 'files') // id = media id, files = client relations - ->on('id', $account->id, relation: 'files') // id = item id - ->execute(); - - $view->data['files'] = $files; + ->on('id', $view->data['account']->id, relation: 'files') // id = item id + ->executeGetArray(); $view->data['media-upload'] = new \Modules\Media\Theme\Backend\Components\Upload\BaseView($this->app->l11nManager, $request, $response); $view->data['note'] = new \Modules\Editor\Theme\Backend\Components\Note\BaseView($this->app->l11nManager, $request, $response); $view->data['address-component'] = new \Modules\Admin\Theme\Backend\Components\AddressEditor\AddressView($this->app->l11nManager, $request, $response); $view->data['contact-component'] = new \Modules\Admin\Theme\Backend\Components\ContactEditor\ContactView($this->app->l11nManager, $request, $response); + $view->data['hasBilling'] = $this->app->moduleManager->isActive('Billing'); + return $view; } @@ -626,28 +668,31 @@ final class BackendController extends Controller $view->setTemplate('/Modules/Accounting/Theme/Backend/personal-view'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002604001, $request, $response); - $account = ClientMapper::get() + $view->data['account'] = ClientMapper::get() ->with('account') ->with('account/addresses') ->with('account/contacts') ->with('mainAddress') ->with('files')->limit(5, 'files')->sort('files/id', OrderType::DESC) ->with('notes')->limit(5, 'notes')->sort('notes/id', OrderType::DESC) + ->with('attributes') + ->with('attributes/type') + ->with('attributes/type/l11n') + ->with('attributes/value') ->where('id', (int) $request->getData('id')) ->execute(); - $view->data['account'] = $account; + $view->data['fiAccounts'] = AccountAbstractMapper::getAll() + ->where('account', $view->data['account']->account->id) + ->executeGetArray(); $view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response); $view->data['attributeView']->data['default_localization'] = $this->app->l11nServer; - /** @var \Modules\Attribute\Models\AttributeType[] $attributeTypes */ - $attributeTypes = ClientAttributeTypeMapper::getAll() + $view->data['attributeTypes'] = ClientAttributeTypeMapper::getAll() ->with('l11n') ->where('l11n/language', $response->header->l11n->language) - ->execute(); - - $view->data['attributeTypes'] = $attributeTypes; + ->executeGetArray(); // Get item profile image // @feature Create a new read mapper function that returns relation models instead of its own model @@ -663,17 +708,15 @@ final class BackendController extends Controller ->on(MediaMapper::TABLE . '.' . MediaMapper::PRIMARYFIELD, '=', MediaMapper::HAS_MANY['types']['table'] . '.' . MediaMapper::HAS_MANY['types']['self']) ->leftJoin(MediaTypeMapper::TABLE) ->on(MediaMapper::HAS_MANY['types']['table'] . '.' . MediaMapper::HAS_MANY['types']['external'], '=', MediaTypeMapper::TABLE . '.' . MediaTypeMapper::PRIMARYFIELD) - ->where(ClientMapper::HAS_MANY['files']['self'], '=', $account->id) + ->where(ClientMapper::HAS_MANY['files']['self'], '=', $view->data['account']->id) ->where(MediaTypeMapper::TABLE . '.' . MediaTypeMapper::getColumnByMember('name'), '=', 'client_profile_image'); - $accountImage = MediaMapper::get() + $view->data['accountImage'] = MediaMapper::get() ->with('types') ->where('id', $results) ->limit(1) ->execute(); - $view->data['accountImage'] = $accountImage; - $businessStart = UnitAttributeMapper::get() ->with('type') ->with('value') @@ -683,23 +726,17 @@ final class BackendController extends Controller $view->data['business_start'] = $businessStart->id === 0 ? 1 : $businessStart->value->getValue(); - /** @var \Modules\Auditor\Models\Audit[] $audits */ - $audits = AuditMapper::getAll() + $view->data['audits'] = AuditMapper::getAll() ->where('type', StringUtils::intHash(ClientMapper::class)) ->where('module', 'ClientManagement') - ->where('ref', (string) $account->id) - ->execute(); + ->where('ref', (string) $view->data['account']->id) + ->executeGetArray(); - $view->data['audits'] = $audits; - - /** @var \Modules\Media\Models\Media[] $files */ - $files = MediaMapper::getAll() + $view->data['files'] = MediaMapper::getAll() ->with('types') ->join('id', ClientMapper::class, 'files') // id = media id, files = client relations - ->on('id', $account->id, relation: 'files') // id = item id - ->execute(); - - $view->data['files'] = $files; + ->on('id', $view->data['account']->id, relation: 'files') // id = item id + ->executeGetArray(); $view->data['media-upload'] = new \Modules\Media\Theme\Backend\Components\Upload\BaseView($this->app->l11nManager, $request, $response); $view->data['note'] = new \Modules\Editor\Theme\Backend\Components\Note\BaseView($this->app->l11nManager, $request, $response); diff --git a/Theme/Backend/Lang/de.lang.php b/Theme/Backend/Lang/de.lang.php index d110cac..8bb745a 100755 --- a/Theme/Backend/Lang/de.lang.php +++ b/Theme/Backend/Lang/de.lang.php @@ -84,4 +84,10 @@ return ['Accounting' => [ 'Title' => 'Titel', 'Net' => 'Netto', 'BalanceSheet' => 'Balance Sheet', + 'QuickAction' => 'Aktion', + 'Status' => 'Status', + 'Wire' => 'Überweisung', + 'Creditcard' => 'Kreditkarte', + ':status-1' => 'Aktiv', + ':status-2' => 'Inaktiv', ]]; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index b858f23..8d96599 100755 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -28,7 +28,7 @@ return ['Accounting' => [ 'Creator' => 'Creator', 'Credit' => 'Credit', 'Debit' => 'Debit', - 'Description' => '', + 'Description' => 'Description', 'Due' => 'Due', 'Entries' => 'Entries', 'EntryDate' => 'Entry Date', @@ -84,4 +84,10 @@ return ['Accounting' => [ 'Title' => 'Title', 'Net' => 'Net', 'BalanceSheet' => 'Balance Sheet', + 'QuickAction' => 'Quick Action', + 'Status' => 'Status', + 'Wire' => 'Wire', + 'Creditcard' => 'Creditcard', + ':status-1' => 'Active', + ':status-2' => 'Inactive', ]]; diff --git a/Theme/Backend/costcenter-list.tpl.php b/Theme/Backend/costcenter-list.tpl.php index ad463e7..4e6d9c6 100755 --- a/Theme/Backend/costcenter-list.tpl.php +++ b/Theme/Backend/costcenter-list.tpl.php @@ -20,8 +20,8 @@ use phpOMS\Uri\UriFactory; */ $costcenter = $this->data['costcenter']; -$previous = empty($costcenter) ? '{/base}/accounting/costcenter/list' : '{/base}/accounting/costcenter/list?{?}&id=' . \reset($costcenter)->id . '&ptype=p'; -$next = empty($costcenter) ? '{/base}/accounting/costcenter/list' : '{/base}/accounting/costcenter/list?{?}&id=' . \end($costcenter)->id . '&ptype=n'; +$previous = empty($costcenter) ? '{/base}/accounting/costcenter/list' : '{/base}/accounting/costcenter/list?{?}&offset=' . \reset($costcenter)->id . '&ptype=p'; +$next = empty($costcenter) ? '{/base}/accounting/costcenter/list' : '{/base}/accounting/costcenter/list?{?}&offset=' . \end($costcenter)->id . '&ptype=n'; echo $this->data['nav']->render(); ?>
diff --git a/Theme/Backend/costobject-list.tpl.php b/Theme/Backend/costobject-list.tpl.php index 096b71b..2dcbd0c 100755 --- a/Theme/Backend/costobject-list.tpl.php +++ b/Theme/Backend/costobject-list.tpl.php @@ -20,8 +20,8 @@ use phpOMS\Uri\UriFactory; */ $costobject = $this->data['costobject']; -$previous = empty($costobject) ? '{/base}/accounting/costobject/list' : '{/base}/accounting/costobject/list?{?}&id=' . \reset($costobject)->id . '&ptype=p'; -$next = empty($costobject) ? '{/base}/accounting/costobject/list' : '{/base}/accounting/costobject/list?{?}&id=' . \end($costobject)->id . '&ptype=n'; +$previous = empty($costobject) ? '{/base}/accounting/costobject/list' : '{/base}/accounting/costobject/list?{?}&offset=' . \reset($costobject)->id . '&ptype=p'; +$next = empty($costobject) ? '{/base}/accounting/costobject/list' : '{/base}/accounting/costobject/list?{?}&offset=' . \end($costobject)->id . '&ptype=n'; echo $this->data['nav']->render(); ?>
diff --git a/Theme/Backend/entries.tpl.php b/Theme/Backend/entries.tpl.php index fe79579..2178bcb 100755 --- a/Theme/Backend/entries.tpl.php +++ b/Theme/Backend/entries.tpl.php @@ -35,9 +35,9 @@ $footerView->setResults(1);
- - \ No newline at end of file diff --git a/Theme/Backend/personal-profile.tpl.php b/Theme/Backend/personal-profile.tpl.php deleted file mode 100644 index 04ead31..0000000 --- a/Theme/Backend/personal-profile.tpl.php +++ /dev/null @@ -1,479 +0,0 @@ -data['account'] ?? null; - -$accountImage = $this->getData('accountImage') ?? new NullMedia(); - -$attributeView = $this->data['attributeView']; - -$countryCodes = \phpOMS\Localization\ISO3166TwoEnum::getConstants(); -$countries = \phpOMS\Localization\ISO3166NameEnum::getConstants(); -$languages = ISO639Enum::getConstants(); - -echo $this->data['nav']->render(); ?> -
-
- -
-
- request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>> -
-
-
- - -
-
-
-
- - -
- -
- - -
- -
- - -
- -
- - -
-
-
- -
-
-
- -
-
- getHtml('Contact'); ?> - mail -
-
-
- - -
- -
- - -
- -
- - -
-
-
- -
-
- getHtml('Address'); ?> - - - - - -
-
- mainAddress->fao)) : ?> -
- - -
- - -
- - -
- - mainAddress->addressAddition)) : ?> -
- - -
- - -
- - -
- -
- - -
- -
- - -
- -
- -
-
-
-
- -
-
- <?= $this->printHtml($accountImage->name); ?> -
-
- -
-
- -
-
-
-
- notes) && ($warning = $account->getEditorDocByTypeName('account_backend_warning'))->id !== 0) : ?> - -
-
-
-
printHtml($warning->plain); ?>
-
-
-
- - - data['hasBilling']) : ?> -
-
-
-
- -
getHtml('YTDSales'); ?>: - getCurrency(SalesBillMapper::getClientNetSales($account->id, SmartDateTime::startOfYear($this->data['business_start']), new \DateTime('now')), format: 'medium'); ?> -
getHtml('MTDSales'); ?>: - getCurrency(SalesBillMapper::getClientNetSales($account->id, SmartDateTime::startOfMonth(), new \DateTime('now')), format: 'medium'); ?> -
getHtml('CLV'); ?>: - getCurrency(SalesBillMapper::getCLVHistoric($account->id), format: 'medium'); ?> -
-
-
-
- -
-
-
- -
getHtml('LastContact'); ?>: - id)?->format('Y-m-d'); ?> -
getHtml('LastOrder'); ?>: - id)?->format('Y-m-d'); ?> -
getHtml('Created'); ?>: - createdAt->format('Y-m-d H:i'); ?> -
-
-
-
- -
-
-
- -
getHtml('DSO'); ?>: - TBD -
getHtml('Due'); ?>: - TBD -
getHtml('Balance'); ?>: - TBD -
-
-
-
-
- - -
-
-
-
getHtml('Notes'); ?>
-
- - - - - notes as $note) : - $url = UriFactory::build('{/base}/editor/view?{?}&id=' . $note->id); - ?> - -
getHtml('Title'); ?> - getHtml('CreatedAt'); ?> -
title; ?> - createdAt->format('Y-m-d'); ?> - -
-
-
-
- -
-
-
getHtml('Documents'); ?>
-
- - - - - files as $file) : - $url = UriFactory::build('{/base}/media/view?{?}&id=' . $file->id); - ?> - -
getHtml('Title'); ?> - - getHtml('CreatedAt'); ?> -
name; ?> - extension; ?> - createdAt->format('Y-m-d'); ?> - -
-
-
-
-
- - data['hasBilling']) : ?> -
-
-
-
getHtml('RecentInvoices'); ?>
- - - - - with('type') - ->with('type/l11n') - ->with('account') - ->where('account', $account->id) - ->where('type/l11n/language', $this->response->header->l11n->language) - ->sort('id', OrderType::DESC) - ->limit(5) - ->execute(); - - /** @var \Modules\Billing\Models\Bill $invoice */ - foreach ($newestInvoices as $invoice) : - $url = UriFactory::build('{/base}/sales/bill?{?}&id=' . $invoice->id); - ?> - -
getHtml('Number'); ?> - getHtml('Type'); ?> - getHtml('Name'); ?> - getHtml('Net'); ?> - getHtml('Date'); ?> -
getNumber(); ?> - type->getL11n(); ?> - billTo; ?> - getCurrency($invoice->netSales); ?> - createdAt->format('Y-m-d'); ?> - -
-
-
-
- -
-
-
- - request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>> -
-
-
-
-
getHtml('Account'); ?>
-
-
- - -
-
-
-
- -
-
-
getHtml('Accounts'); ?>
-
- - - - - -
-
-
-
-
-
-
-
- - request->uri->fragment === 'c-tab-7' ? ' checked' : ''; ?>> -
-
- -
-
- - request->uri->fragment === 'c-tab-3' ? ' checked' : ''; ?>> -
-
-
-
-
getHtml('QuickAction'); ?>
-
- -
-
-
- -
-
-
-
-
getHtml('Open'); ?>
- - - - - -
- getHtml('Info'); ?> - getHtml('Date'); ?> - getHtml('Credit'); ?> - getHtml('Debit'); ?> - getHtml('Number'); ?> - getHtml('Text'); ?> - getHtml('Due'); ?> - getHtml('Payment'); ?> -
getHtml('Empty', '0', '0'); ?> -
-
-
- getHtml('Total'); ?>: 0.00 - getHtml('Due'); ?>: 0.00 -
-
-
-
- -
-
-
-
getHtml('Total'); ?>
- - - - - -
getHtml('Info'); ?> - getHtml('Date'); ?> - getHtml('Credit'); ?> - getHtml('Debit'); ?> - getHtml('Number'); ?> - getHtml('Text'); ?> - getHtml('Due'); ?> - getHtml('Payment'); ?> - getHtml('Balanced'); ?> - getHtml('Balance'); ?> -
getHtml('Empty', '0', '0'); ?> -
-
-
-
-
-
-
-
- - request->uri->fragment === 'c-tab-4' ? ' checked' : ''; ?>> -
- data['contact-component']->render('account-contact', 'contacts', $account->account->contacts); ?> - data['address-component']->render('account-address', 'addresses', $account->account->addresses); ?> -
- - request->uri->fragment === 'c-tab-5' ? ' checked' : ''; ?>> -
- data['media-upload']->render('account-file', 'files', '', $account->files); ?> -
- - request->uri->fragment === 'c-tab-6' ? ' checked' : ''; ?>> -
- data['note']->render('account-note', 'notes', $account->notes); ?> -
-
-
diff --git a/Theme/Backend/personal-view.tpl.php b/Theme/Backend/personal-view.tpl.php index 04ead31..20b180b 100644 --- a/Theme/Backend/personal-view.tpl.php +++ b/Theme/Backend/personal-view.tpl.php @@ -12,8 +12,12 @@ */ declare(strict_types=1); +use Modules\Accounting\Models\AccountStatus; use Modules\Admin\Models\ContactType; +use Modules\Billing\Models\BillMapper; +use Modules\Billing\Models\PurchaseBillMapper; use Modules\Billing\Models\SalesBillMapper; +use Modules\ClientManagement\Models\Client; use Modules\Media\Models\NullMedia; use phpOMS\DataStorage\Database\Query\OrderType; use phpOMS\Localization\ISO639Enum; @@ -22,6 +26,9 @@ use phpOMS\Uri\UriFactory; /** @var \phpOMS\Views\View $this */ $account = $this->data['account'] ?? null; +$isNew = ($account?->id ?? 0) === 0; + +$isClient = $account instanceof Client; $accountImage = $this->getData('accountImage') ?? new NullMedia(); @@ -31,8 +38,11 @@ $countryCodes = \phpOMS\Localization\ISO3166TwoEnum::getConstants(); $countries = \phpOMS\Localization\ISO3166NameEnum::getConstants(); $languages = ISO639Enum::getConstants(); +$accountStatus = AccountStatus::getConstants(); + echo $this->data['nav']->render(); ?>
+
+
- request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>> + request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
- -
-
+
-
+
- + > +
+ +
+ +
@@ -82,7 +93,12 @@ echo $this->data['nav']->render(); ?>
- + + + + + +
@@ -95,17 +111,17 @@ echo $this->data['nav']->render(); ?>
- +
- +
- +
@@ -138,48 +154,51 @@ echo $this->data['nav']->render(); ?> mainAddress->fao)) : ?>
- +
- +
mainAddress->addressAddition)) : ?>
- +
- +
- +
- $code2) : ?>
+
+
+
<?= $this->printHtml($accountImage->name); ?>data['nav']->render(); ?>
+
+ +
notes) && ($warning = $account->getEditorDocByTypeName('account_backend_warning'))->id !== 0) : ?> @@ -214,11 +236,20 @@ echo $this->data['nav']->render(); ?>
getHtml('YTDSales'); ?>: - getCurrency(SalesBillMapper::getClientNetSales($account->id, SmartDateTime::startOfYear($this->data['business_start']), new \DateTime('now')), format: 'medium'); ?> + id, SmartDateTime::startOfYear($this->data['business_start']), new \DateTime('now'))->getAmount() + : PurchaseBillMapper::getSupplierNetSales($account->id, SmartDateTime::startOfYear($this->data['business_start']), new \DateTime('now'))->getAmount(); + ?>
getHtml('MTDSales'); ?>: - getCurrency(SalesBillMapper::getClientNetSales($account->id, SmartDateTime::startOfMonth(), new \DateTime('now')), format: 'medium'); ?> + id, SmartDateTime::startOfMonth(), new \DateTime('now'))->getAmount() + : PurchaseBillMapper::getSupplierNetSales($account->id, SmartDateTime::startOfMonth(), new \DateTime('now'))->getAmount(); + ?>
getHtml('CLV'); ?>: - getCurrency(SalesBillMapper::getCLVHistoric($account->id), format: 'medium'); ?> + id)->getAmount() + : PurchaseBillMapper::getSLVHistoric($account->id)->getAmount(); + ?>
@@ -229,9 +260,15 @@ echo $this->data['nav']->render(); ?>
getHtml('LastContact'); ?>: - id)?->format('Y-m-d'); ?> + id)?->format('Y-m-d') + : PurchaseBillMapper::getSupplierLastOrder($account->id)?->format('Y-m-d'); + ?>
getHtml('LastOrder'); ?>: - id)?->format('Y-m-d'); ?> + id)?->format('Y-m-d') + : PurchaseBillMapper::getSupplierLastOrder($account->id)?->format('Y-m-d'); + ?>
getHtml('Created'); ?>: createdAt->format('Y-m-d H:i'); ?>
@@ -267,13 +304,19 @@ echo $this->data['nav']->render(); ?> getHtml('Title'); ?> getHtml('CreatedAt'); ?> - notes as $note) : + notes as $note) : + ++$count; $url = UriFactory::build('{/base}/editor/view?{?}&id=' . $note->id); - ?> + ?> title; ?> createdAt->format('Y-m-d'); ?> + + getHtml('Empty', '0', '0'); ?> +
@@ -290,14 +333,20 @@ echo $this->data['nav']->render(); ?> getHtml('CreatedAt'); ?> - files as $file) : + files as $file) : + ++$count; $url = UriFactory::build('{/base}/media/view?{?}&id=' . $file->id); - ?> + ?> name; ?> extension; ?> createdAt->format('Y-m-d'); ?> + + getHtml('Empty', '0', '0'); ?> +
@@ -319,7 +368,7 @@ echo $this->data['nav']->render(); ?> getHtml('Date'); ?> with('type') ->with('type/l11n') ->with('account') @@ -327,11 +376,11 @@ echo $this->data['nav']->render(); ?> ->where('type/l11n/language', $this->response->header->l11n->language) ->sort('id', OrderType::DESC) ->limit(5) - ->execute(); + ->executeGetArray(); /** @var \Modules\Billing\Models\Bill $invoice */ foreach ($newestInvoices as $invoice) : - $url = UriFactory::build('{/base}/sales/bill?{?}&id=' . $invoice->id); + $url = UriFactory::build('{/base}/sales/bill/view?{?}&id=' . $invoice->id); ?> getNumber(); ?> @@ -346,9 +395,11 @@ echo $this->data['nav']->render(); ?>
+
+ request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
@@ -373,8 +424,18 @@ echo $this->data['nav']->render(); ?> + data['fiAccounts'] as $fiAccount) : + ++$c; + ?> - + printHtml($fiAccount->code); ?> + + + + getHtml('Empty', '0', '0'); ?> +
@@ -384,8 +445,24 @@ echo $this->data['nav']->render(); ?> request->uri->fragment === 'c-tab-7' ? ' checked' : ''; ?>>
-
- +
+
+
+
getHtml('Payment'); ?>
+
+
+ +
+
+
+
+
+
+
+
@@ -396,7 +473,7 @@ echo $this->data['nav']->render(); ?>
getHtml('QuickAction'); ?>
- + TBD
@@ -475,5 +552,6 @@ echo $this->data['nav']->render(); ?>
data['note']->render('account-note', 'notes', $account->notes); ?>
+
diff --git a/tests/Models/CostCenterMapperTest.php b/tests/Models/CostCenterMapperTest.php index a2d0fc3..fda0ef2 100755 --- a/tests/Models/CostCenterMapperTest.php +++ b/tests/Models/CostCenterMapperTest.php @@ -28,10 +28,10 @@ final class CostCenterMapperTest extends \PHPUnit\Framework\TestCase #[\PHPUnit\Framework\Attributes\Group('module')] public function testCR() : void { - $costcenter = new CostCenter(); - $costcenter->code = '123'; - $costcenter->l11n = new BaseStringL11n(); - $costcenter->l11n->name = 'Test CostCenter'; + $costcenter = new CostCenter(); + $costcenter->code = '123'; + $costcenter->l11n = new BaseStringL11n(); + $costcenter->l11n->name = 'Test CostCenter'; $costcenter->l11n->content = 'Test description'; $id = CostCenterMapper::create()->execute($costcenter); diff --git a/tests/Models/CostObjectMapperTest.php b/tests/Models/CostObjectMapperTest.php index 6a00a2f..3c28d7c 100755 --- a/tests/Models/CostObjectMapperTest.php +++ b/tests/Models/CostObjectMapperTest.php @@ -28,10 +28,10 @@ final class CostObjectMapperTest extends \PHPUnit\Framework\TestCase #[\PHPUnit\Framework\Attributes\Group('module')] public function testCR() : void { - $costobject = new CostObject(); - $costobject->code = '123'; - $costobject->l11n = new BaseStringL11n(); - $costobject->l11n->name = 'Test CostObject'; + $costobject = new CostObject(); + $costobject->code = '123'; + $costobject->l11n = new BaseStringL11n(); + $costobject->l11n->name = 'Test CostObject'; $costobject->l11n->content = 'Test description'; $id = CostObjectMapper::create()->execute($costobject);