From c33676985080db3c512432e045298f6ebec24f65 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 5 Mar 2021 21:01:37 +0100 Subject: [PATCH] fix php version, lang files, basic tpl and sales impl. --- Admin/Install/Media.install.json | 9 ++ Admin/Install/Media.php | 43 +++++++++ Admin/Install/db.json | 26 ++++++ Controller/ApiController.php | 22 +++++ Models/Client.php | 35 +++++++ Models/ClientMapper.php | 7 ++ Theme/Backend/Lang/de.lang.php | 133 ++++++++++++++++----------- Theme/Backend/Lang/en.lang.php | 133 ++++++++++++++++----------- Theme/Backend/client-profile.tpl.php | 40 +++++++- info.json | 6 +- 10 files changed, 343 insertions(+), 111 deletions(-) create mode 100644 Admin/Install/Media.install.json create mode 100644 Admin/Install/Media.php mode change 100755 => 100644 Theme/Backend/Lang/de.lang.php mode change 100755 => 100644 Theme/Backend/Lang/en.lang.php diff --git a/Admin/Install/Media.install.json b/Admin/Install/Media.install.json new file mode 100644 index 0000000..a27445c --- /dev/null +++ b/Admin/Install/Media.install.json @@ -0,0 +1,9 @@ +[ + { + "type": "collection", + "create_directory": true, + "name": "ClientManagement", + "virtualPath": "/Modules", + "user": 1 + } +] \ No newline at end of file diff --git a/Admin/Install/Media.php b/Admin/Install/Media.php new file mode 100644 index 0000000..f5b8a65 --- /dev/null +++ b/Admin/Install/Media.php @@ -0,0 +1,43 @@ + __DIR__ . '/Media.install.json']); + } +} diff --git a/Admin/Install/db.json b/Admin/Install/db.json index ce0eb9a..b7316ff 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -108,5 +108,31 @@ "foreignKey": "clientmgmt_client_id" } } + }, + "clientmgmt_client_note": { + "name": "clientmgmt_client_note", + "fields": { + "clientmgmt_client_note_id": { + "name": "clientmgmt_client_note_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "clientmgmt_client_note_dst": { + "name": "clientmgmt_client_note_dst", + "type": "INT", + "null": false, + "foreignTable": "editor_doc", + "foreignKey": "editor_doc_id" + }, + "clientmgmt_client_note_src": { + "name": "clientmgmt_client_note_src", + "type": "INT", + "null": false, + "foreignTable": "clientmgmt_client", + "foreignKey": "clientmgmt_client_id" + } + } } } \ No newline at end of file diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 3a13cf2..1f0706e 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -198,4 +198,26 @@ final class ApiController extends Controller $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Image', 'Image successfully updated', $uploaded); } + + /** + * Api method to create item files + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function apiNoteCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void + { + $request->setData('virtualpath', '/Modules/ClientManagement/' . $request->getData('id'), true); + $this->app->moduleManager->get('Editor')->apiEditorCreate($request, $response, $data); + + $model = $response->get($request->uri->__toString())['response']; + $this->createModelRelation($request->header->account, $request->getData('id'), $model->getId(), ClientMapper::class, 'notes', '', $request->getOrigin()); + } } diff --git a/Models/Client.php b/Models/Client.php index b6e0e20..198d53c 100755 --- a/Models/Client.php +++ b/Models/Client.php @@ -16,6 +16,7 @@ namespace Modules\ClientManagement\Models; use Modules\Admin\Models\Address; use Modules\Admin\Models\NullAddress; +use Modules\Editor\Models\EditorDoc; use Modules\Media\Models\Media; use Modules\Profile\Models\ContactElement; use Modules\Profile\Models\NullContactElement; @@ -49,6 +50,14 @@ class Client public Profile $profile; + /** + * Files. + * + * @var EditorDoc[] + * @since 1.0.0 + */ + private array $notes = []; + private array $files = []; private array $contactElements = []; @@ -199,6 +208,32 @@ class Client $this->info = $info; } + /** + * Add doc to item + * + * @param EditorDoc $note Note + * + * @return void + * + * @since 1.0.0 + */ + public function addNote(EditorDoc $note) : void + { + $this->notes[] = $note; + } + + /** + * Get notes + * + * @return EditorDoc[] + * + * @since 1.0.0 + */ + public function getNotes() : array + { + return $this->notes; + } + /** * Get media. * diff --git a/Models/ClientMapper.php b/Models/ClientMapper.php index 859a7a9..c5ff98c 100755 --- a/Models/ClientMapper.php +++ b/Models/ClientMapper.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace Modules\ClientManagement\Models; use Modules\Admin\Models\AddressMapper; +use Modules\Editor\Models\EditorDocMapper; use Modules\Media\Models\MediaMapper; use Modules\Profile\Models\ContactElementMapper; use Modules\Profile\Models\ProfileMapper; @@ -102,6 +103,12 @@ final class ClientMapper extends DataMapperAbstract 'external' => 'clientmgmt_client_media_dst', 'self' => 'clientmgmt_client_media_src', ], + 'notes' => [ + 'mapper' => EditorDocMapper::class, /* mapper of the related object */ + 'table' => 'clientmgmt_client_note', /* table of the related object, null if no relation table is used (many->1) */ + 'external' => 'clientmgmt_client_note_dst', + 'self' => 'clientmgmt_client_note_src', + ], 'contactElements' => [ 'mapper' => ContactElementMapper::class, 'table' => 'clientmgmt_client_contactelement', diff --git a/Theme/Backend/Lang/de.lang.php b/Theme/Backend/Lang/de.lang.php old mode 100755 new mode 100644 index 96711ec..6aea73c --- a/Theme/Backend/Lang/de.lang.php +++ b/Theme/Backend/Lang/de.lang.php @@ -4,7 +4,7 @@ * * PHP Version 8.0 * - * @package Modules\ClientManagement + * @package Modules\Localization * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -13,55 +13,84 @@ declare(strict_types=1); return ['ClientManagement' => [ - 'Accounting' => 'Buchhaltung', - 'Address' => 'Addresse', - 'Addresses' => 'Addressen', - 'AreaManager' => 'Area Manager', - 'Articlegroup' => 'Artikelgruppe', - 'Bonus' => 'Bonus', - 'Business' => 'Business', - 'City' => 'Stadt', - 'Client' => 'Kunde', - 'Clients' => 'Kunden', - 'Contact' => 'Kontakt', - 'Country' => 'Land', - 'Creditcard' => 'Kreditkarte', - 'Date' => 'Datum', - 'Default' => 'Standard', - 'Delivery' => 'Lieferung', - 'Discount' => 'Rabatt', - 'DiscountP' => 'Rabatt %', - 'Email' => 'Email', - 'Fax' => 'Fax', - 'Files' => 'Dateien', - 'Freightage' => 'Frachtkosten', - 'Group' => 'Gruppe', - 'ID' => 'ID', - 'Info' => 'Info', - 'Invoice' => 'Rechnung', - 'IsDefault' => 'Ist Standard?', - 'Log' => 'Log', - 'Logs' => 'Logs', - 'Profile' => 'Profile', - 'Name' => 'Name', - 'Name1' => 'Name1', - 'Name2' => 'Name2', - 'Name3' => 'Name3', - 'Office' => 'Büro', - 'Payment' => 'Zahlung', - 'PaymentTerm' => 'Zahlungsziel', - 'Phone' => 'Telefon', - 'Price' => 'Preis', - 'Prices' => 'Preise', - 'Private' => 'Privat', - 'Productgroup' => 'Produktgruppe', - 'Purchase' => 'Einkauf', - 'Quantity' => 'Anzahl', - 'Sales' => 'Umsatz', - 'Segment' => 'Segment', - 'Subtype' => 'Untergruppe', - 'Support' => 'Support', - 'Type' => 'Typ', - 'Wire' => 'Wire', - 'Zip' => 'Postleitzahl', + 'Accounting' => 'Buchhaltung', + 'Addition' => '', + 'Address' => 'Addresse', + 'Addresses' => 'Addressen', + 'AreaManager' => 'Area Manager', + 'Articlegroup' => 'Artikelgruppe', + 'Articles' => '', + 'Balance' => '', + 'Bonus' => 'Bonus', + 'Business' => 'Business', + 'CLV' => '', + 'Calendar' => '', + 'City' => 'Stadt', + 'Client' => 'Kunde', + 'Clients' => 'Kunden', + 'Contact' => 'Kontakt', + 'Country' => 'Land', + 'Created' => '', + 'CreditRating' => '', + 'Creditcard' => 'Kreditkarte', + 'DSO' => '', + 'Date' => 'Datum', + 'Default' => 'Standard', + 'Delivery' => 'Lieferung', + 'Discount' => 'Rabatt', + 'DiscountP' => 'Rabatt %', + 'Documents' => '', + 'Due' => '', + 'Email' => 'Email', + 'Fax' => 'Fax', + 'Files' => 'Dateien', + 'Freightage' => 'Frachtkosten', + 'Group' => 'Gruppe', + 'ID' => 'ID', + 'Info' => 'Info', + 'Invoice' => 'Rechnung', + 'Invoices' => '', + 'IsDefault' => 'Ist Standard?', + 'LastContact' => '', + 'LastOrder' => '', + 'Log' => 'Log', + 'Logs' => 'Logs', + 'MRR' => '', + 'MTDSales' => '', + 'Margin' => '', + 'Messages' => '', + 'Modified' => '', + 'Modules' => '', + 'Name' => 'Name', + 'Name1' => 'Name1', + 'Name2' => 'Name2', + 'Name3' => 'Name3', + 'Net' => '', + 'Notes' => '', + 'Number' => '', + 'Office' => 'Büro', + 'Payment' => 'Zahlung', + 'PaymentTerm' => 'Zahlungsziel', + 'Permission' => '', + 'Phone' => 'Telefon', + 'Postal' => '', + 'Price' => 'Preis', + 'Prices' => 'Preise', + 'Private' => 'Privat', + 'Productgroup' => 'Produktgruppe', + 'Profile' => 'Profile', + 'Purchase' => 'Einkauf', + 'Quantity' => 'Anzahl', + 'RecentInvoices' => '', + 'Sales' => 'Umsatz', + 'Segment' => 'Segment', + 'Segments' => '', + 'Subtype' => 'Untergruppe', + 'Support' => 'Support', + 'Tags' => '', + 'Type' => 'Typ', + 'Website' => '', + 'Wire' => 'Wire', + 'YTDSales' => '', + 'Zip' => 'Postleitzahl', ]]; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php old mode 100755 new mode 100644 index dfe856d..35688aa --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -4,7 +4,7 @@ * * PHP Version 8.0 * - * @package Modules\ClientManagement + * @package Modules\Localization * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -13,55 +13,84 @@ declare(strict_types=1); return ['ClientManagement' => [ - 'Accounting' => 'Accounting', - 'Address' => 'Address', - 'Addresses' => 'Addresses', - 'AreaManager' => 'Area Manager', - 'Articlegroup' => 'Articlegroup', - 'Bonus' => 'Bonus', - 'Business' => 'Business', - 'City' => 'City', - 'Client' => 'Client', - 'Clients' => 'Clients', - 'Contact' => 'Contact', - 'Country' => 'Country', - 'Creditcard' => 'Creditcard', - 'Date' => 'Date', - 'Default' => 'Default', - 'Delivery' => 'Delivery', - 'Discount' => 'Discount', - 'DiscountP' => 'Discount %', - 'Email' => 'Email', - 'Fax' => 'Fax', - 'Files' => 'Files', - 'Freightage' => 'Freightage', - 'Group' => 'Group', - 'ID' => 'ID', - 'Info' => 'Info', - 'Invoice' => 'Invoice', - 'IsDefault' => 'Is default?', - 'Log' => 'Log', - 'Logs' => 'Logs', - 'Profile' => 'Profile', - 'Name' => 'Name', - 'Name1' => 'Name1', - 'Name2' => 'Name2', - 'Name3' => 'Name3', - 'Office' => 'Office', - 'Payment' => 'Payment', - 'PaymentTerm' => 'Payment Term', - 'Phone' => 'Phone', - 'Price' => 'Price', - 'Prices' => 'Prices', - 'Private' => 'Private', - 'Productgroup' => 'Productgroup', - 'Purchase' => 'Purchase', - 'Quantity' => 'Quantity', - 'Sales' => 'Sales', - 'Segment' => 'Segment', - 'Subtype' => 'Subtype', - 'Support' => 'Support', - 'Type' => 'Type', - 'Wire' => 'Wire', - 'Zip' => 'Zip', + 'Accounting' => 'Accounting', + 'Addition' => 'Addition', + 'Address' => 'Address', + 'Addresses' => 'Addresses', + 'AreaManager' => 'Area Manager', + 'Articlegroup' => 'Articlegroup', + 'Articles' => 'Articles', + 'Balance' => 'Balance', + 'Bonus' => 'Bonus', + 'Business' => 'Business', + 'CLV' => 'CLV', + 'Calendar' => 'Calendar', + 'City' => 'City', + 'Client' => 'Client', + 'Clients' => 'Clients', + 'Contact' => 'Contact', + 'Country' => 'Country', + 'Created' => 'Created', + 'CreditRating' => 'Credit Rating', + 'Creditcard' => 'Creditcard', + 'DSO' => 'DSO', + 'Date' => 'Date', + 'Default' => 'Default', + 'Delivery' => 'Delivery', + 'Discount' => 'Discount', + 'DiscountP' => 'Discount %', + 'Documents' => 'Documents', + 'Due' => 'Due', + 'Email' => 'Email', + 'Fax' => 'Fax', + 'Files' => 'Files', + 'Freightage' => 'Freightage', + 'Group' => 'Group', + 'ID' => 'ID', + 'Info' => 'Info', + 'Invoice' => 'Invoice', + 'Invoices' => 'Invoices', + 'IsDefault' => 'Is default?', + 'LastContact' => 'Last Contact', + 'LastOrder' => 'Last Order', + 'Log' => 'Log', + 'Logs' => 'Logs', + 'MRR' => 'MRR', + 'MTDSales' => 'MTD Sales', + 'Margin' => 'Margin', + 'Messages' => 'Messages', + 'Modified' => 'Modified', + 'Modules' => 'Modules', + 'Name' => 'Name', + 'Name1' => 'Name1', + 'Name2' => 'Name2', + 'Name3' => 'Name3', + 'Net' => 'Net', + 'Notes' => 'Notes', + 'Number' => 'Number', + 'Office' => 'Office', + 'Payment' => 'Payment', + 'PaymentTerm' => 'Payment Term', + 'Permission' => 'Permission', + 'Phone' => 'Phone', + 'Postal' => 'Postal', + 'Price' => 'Price', + 'Prices' => 'Prices', + 'Private' => 'Private', + 'Productgroup' => 'Productgroup', + 'Profile' => 'Profile', + 'Purchase' => 'Purchase', + 'Quantity' => 'Quantity', + 'RecentInvoices' => 'Recent Invoices', + 'Sales' => 'Sales', + 'Segment' => 'Segment', + 'Segments' => 'Segments', + 'Subtype' => 'Subtype', + 'Support' => 'Support', + 'Tags' => 'Tags', + 'Type' => 'Type', + 'Website' => 'Website', + 'Wire' => 'Wire', + 'YTDSales' => 'YTD Sales', + 'Zip' => 'Zip', ]]; diff --git a/Theme/Backend/client-profile.tpl.php b/Theme/Backend/client-profile.tpl.php index 34eeb04..ba2b887 100755 --- a/Theme/Backend/client-profile.tpl.php +++ b/Theme/Backend/client-profile.tpl.php @@ -22,6 +22,8 @@ $countries = \phpOMS\Localization\ISO3166NameEnum::getConstants(); * @var \Modules\ClientManagement\Models\Client $client */ $client = $this->getData('client'); +$notes = $client->getNotes(); +$files = $client->getFiles(); $newestInvoices = $this->getData('newestInvoices') ?? []; $monthlySalesCosts = $this->getData('monthlySalesCosts') ?? []; @@ -130,7 +132,7 @@ echo $this->getData('nav')->render();
- +
getHtml('YTDSales'); ?>:
getHtml('MTDSales'); ?>: @@ -147,7 +149,7 @@ echo $this->getData('nav')->render();
- +
getHtml('LastContact'); ?>:
getHtml('LastOrder'); ?>: @@ -164,7 +166,7 @@ echo $this->getData('nav')->render();
- +
getHtml('DSO'); ?>:
getHtml('Due'); ?>: @@ -183,14 +185,42 @@ echo $this->getData('nav')->render();
getHtml('Notes'); ?>
-
+ + + + + getId()); + ?> + +
getHtml('Title'); ?> + getHtml('CreatedAt'); ?> +
title; ?> + createdAt->format('Y-m-d'); ?> + +
getHtml('Documents'); ?>
-
+ + + + + getId()); + ?> + +
getHtml('Title'); ?> + + getHtml('CreatedAt'); ?> +
name; ?> + extension; ?> + createdAt->format('Y-m-d'); ?> + +
diff --git a/info.json b/info.json index 7db12cc..282c5f0 100755 --- a/info.json +++ b/info.json @@ -19,10 +19,12 @@ "dependencies": { "Admin": "1.0.0", "Profile": "1.0.0", - "Media": "1.0.0" + "Media": "1.0.0", + "Editor": "1.0.0" }, "providing": { - "Navigation": "*" + "Navigation": "*", + "Media": "*" }, "load": [ {