diff --git a/Admin/Install/db.json b/Admin/Install/db.json
index 3373395..bb9d7e0 100644
--- a/Admin/Install/db.json
+++ b/Admin/Install/db.json
@@ -44,12 +44,20 @@
"type": "DATETIME",
"null": false
},
- "suppliermgmt_supplier_account": {
- "name": "suppliermgmt_supplier_account",
+ "suppliermgmt_supplier_profile": {
+ "name": "suppliermgmt_supplier_profile",
"type": "INT",
"null": false,
- "foreignTable": "account",
- "foreignKey": "account_id"
+ "foreignTable": "profile_account",
+ "foreignKey": "profile_account_id"
+ },
+ "suppliermgmt_supplier_address": {
+ "name": "suppliermgmt_supplier_address",
+ "type": "INT",
+ "null": true,
+ "default": null,
+ "foreignTable": "address",
+ "foreignKey": "address_id"
}
}
},
@@ -67,8 +75,8 @@
"name": "suppliermgmt_supplier_contactelement_dst",
"type": "INT",
"null": false,
- "foreignTable": "profile_contactelement",
- "foreignKey": "profile_contactelement_id"
+ "foreignTable": "profile_contact_element",
+ "foreignKey": "profile_contact_element_id"
},
"suppliermgmt_supplier_contactelement_src": {
"name": "suppliermgmt_supplier_contactelement_src",
@@ -76,11 +84,6 @@
"null": false,
"foreignTable": "suppliermgmt_supplier",
"foreignKey": "suppliermgmt_supplier_id"
- },
- "suppliermgmt_supplier_contactelement_type": {
- "name": "suppliermgmt_supplier_contactelement_type",
- "type": "TINYINT",
- "null": false
}
}
},
diff --git a/Controller/BackendController.php b/Controller/BackendController.php
index a57e410..2820dea 100644
--- a/Controller/BackendController.php
+++ b/Controller/BackendController.php
@@ -18,6 +18,7 @@ use phpOMS\Contract\RenderableInterface;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Views\View;
+use Modules\SupplierManagement\Models\SupplierMapper;
/**
* SupplierManagement controller class.
@@ -47,6 +48,9 @@ final class BackendController extends Controller
$view->setTemplate('/Modules/SupplierManagement/Theme/Backend/supplier-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003202001, $request, $response));
+ $supplier = SupplierMapper::getAll();
+ $view->addData('supplier', $supplier);
+
return $view;
}
@@ -89,6 +93,9 @@ final class BackendController extends Controller
$view->setTemplate('/Modules/SupplierManagement/Theme/Backend/supplier-profile');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003202001, $request, $response));
+ $supplier = SupplierMapper::get((int) $request->getData('id'));
+ $view->setData('supplier', $supplier);
+
return $view;
}
}
diff --git a/Models/Supplier.php b/Models/Supplier.php
index 06cff70..59d03cf 100644
--- a/Models/Supplier.php
+++ b/Models/Supplier.php
@@ -16,6 +16,9 @@ namespace Modules\SupplierManagement\Models;
use Modules\Media\Models\Media;
use Modules\Profile\Models\Profile;
+use Modules\Admin\Models\NullAddress;
+use Modules\Profile\Models\ContactElement;
+use Modules\Profile\Models\NullContactElement;
/**
* Supplier class.
@@ -57,6 +60,8 @@ class Supplier
private $address = [];
+ private $mainAddress;
+
/**
* Constructor.
*
@@ -66,6 +71,7 @@ class Supplier
{
$this->createdAt = new \DateTimeImmutable('now');
$this->profile = new Profile();
+ $this->mainAddress = new NullAddress();
}
/**
@@ -278,6 +284,16 @@ class Supplier
$this->profile = $profile;
}
+ public function setMainAddress($address) : void
+ {
+ $this->mainAddress = $address;
+ }
+
+ public function getMainAddress()
+ {
+ return $this->mainAddress;
+ }
+
/**
* Get media.
*
@@ -327,4 +343,27 @@ class Supplier
{
return $this->contactElements;
}
+
+ private function orderContactElements(ContactElement $a, ContactElement $b) : int
+ {
+ return $a->getOrder() <=> $b->getOrder();
+ }
+
+ public function getMainContactElement(int $type) : ContactElement
+ {
+ \uasort($this->contactElements, [$this, 'orderContactElements']);
+
+ foreach ($this->contactElements as $element) {
+ if ($element->getType() === $type) {
+ return $element;
+ }
+ }
+
+ return new NullContactElement();
+ }
+
+ public function addContactElement($element) : void
+ {
+ $this->contactElements[] = $element;
+ }
}
diff --git a/Models/SupplierMapper.php b/Models/SupplierMapper.php
index c6ffafc..7d77d54 100644
--- a/Models/SupplierMapper.php
+++ b/Models/SupplierMapper.php
@@ -18,7 +18,7 @@ use Modules\Media\Models\MediaMapper;
use Modules\Profile\Models\ContactElementMapper;
use Modules\Profile\Models\ProfileMapper;
use phpOMS\DataStorage\Database\DataMapperAbstract;
-use phpOMS\DataStorage\Database\Query\Column;
+use Modules\Admin\Models\AddressMapper;
/**
* Supplier mapper class.
@@ -45,7 +45,8 @@ final class SupplierMapper extends DataMapperAbstract
'suppliermgmt_supplier_taxid' => ['name' => 'suppliermgmt_supplier_taxid', 'type' => 'int', 'internal' => 'taxId'],
'suppliermgmt_supplier_info' => ['name' => 'suppliermgmt_supplier_info', 'type' => 'string', 'internal' => 'info'],
'suppliermgmt_supplier_created_at' => ['name' => 'suppliermgmt_supplier_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
- 'suppliermgmt_supplier_account' => ['name' => 'suppliermgmt_supplier_account', 'type' => 'int', 'internal' => 'profile'],
+ 'suppliermgmt_supplier_profile' => ['name' => 'suppliermgmt_supplier_profile', 'type' => 'int', 'internal' => 'profile'],
+ 'suppliermgmt_supplier_address' => ['name' => 'suppliermgmt_supplier_address', 'type' => 'int', 'internal' => 'mainAddress'],
];
/**
@@ -81,7 +82,11 @@ final class SupplierMapper extends DataMapperAbstract
protected static array $ownsOne = [
'profile' => [
'mapper' => ProfileMapper::class,
- 'self' => 'suppliermgmt_supplier_account',
+ 'self' => 'suppliermgmt_supplier_profile',
+ ],
+ 'mainAddress' => [
+ 'mapper' => AddressMapper::class,
+ 'self' => 'suppliermgmt_supplier_address',
],
];
@@ -101,8 +106,8 @@ final class SupplierMapper extends DataMapperAbstract
'contactElements' => [
'mapper' => ContactElementMapper::class,
'table' => 'suppliermgmt_supplier_contactelement',
- 'external' => 'suppliermgmt_supplier_contactelement_dst',
- 'self' => 'suppliermgmt_supplier_contactelement_src',
+ 'external' => 'suppliermgmt_supplier_contactelement_src',
+ 'self' => 'suppliermgmt_supplier_contactelement_dst',
],
];
}
diff --git a/Theme/Backend/supplier-list.tpl.php b/Theme/Backend/supplier-list.tpl.php
index 68a85ad..5708253 100644
--- a/Theme/Backend/supplier-list.tpl.php
+++ b/Theme/Backend/supplier-list.tpl.php
@@ -12,7 +12,11 @@
*/
declare(strict_types=1);
+use phpOMS\Uri\UriFactory;
+
/** @var \phpOMS\Views\View $this */
+$suppliers = $this->getData('supplier');
+
echo $this->getData('nav')->render(); ?>
@@ -24,14 +28,22 @@ echo $this->getData('nav')->render(); ?>
| = $this->getHtml('ID', '0', '0'); ?>
| = $this->getHtml('Name1'); ?>
- | = $this->getHtml('Name2'); ?>
- | = $this->getHtml('Name3'); ?>
+ | = $this->getHtml('Name2'); ?>
| = $this->getHtml('City'); ?>
| = $this->getHtml('Zip'); ?>
| = $this->getHtml('Address'); ?>
| = $this->getHtml('Country'); ?>
|
- $value) : ++$count; ?>
+ $value) : ++$count;
+ $url = UriFactory::build('{/prefix}purchase/supplier/profile?{?}&id=' . $value->getId()); ?>
+
+ | = $this->printHtml($value->getNumber()); ?>
+ | = $this->printHtml($value->getProfile()->getAccount()->getName1()); ?>
+ | = $this->printHtml($value->getProfile()->getAccount()->getName2()); ?>
+ | = $this->printHtml($value->getMainAddress()->getCity()); ?>
+ | = $this->printHtml($value->getMainAddress()->getPostal()); ?>
+ | = $this->printHtml($value->getMainAddress()->getAddress()); ?>
+ | = $this->printHtml($value->getMainAddress()->getCountry()); ?>
|
= $this->getHtml('Empty', '0', '0'); ?>
diff --git a/Theme/Backend/supplier-profile.tpl.php b/Theme/Backend/supplier-profile.tpl.php
new file mode 100644
index 0000000..549e4db
--- /dev/null
+++ b/Theme/Backend/supplier-profile.tpl.php
@@ -0,0 +1,447 @@
+getData('supplier');
+
+/**
+ * @var \phpOMS\Views\View $this
+ */
+echo $this->getData('nav')->render();
+?>
+
+
+
+
+
+
+
+
+
+
+
+ -
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+ request->getUri()->getFragment() === 'c-tab-1' ? ' checked' : ''; ?>>
+
+
+
+
+
+
+
+
+ Contact
+
+
+ | Main:
+ | | Phone:
+ |
+ | | Email:
+ |
+ | | Accounting:
+ | | Phone:
+ |
+ | | Email:
+ |
+ |
+
+
+
+
+
+
+
+
+
+ | YTD Sales:
+ |
+ | | MTD Sales:
+ |
+ | | CLV:
+ |
+ | | MRR:
+ |
+ |
+
+
+
+
+
+
+
+
+ | Last Contact:
+ |
+ | | Last Order:
+ |
+ | | Created:
+ |
+ | | Modified:
+ |
+ |
+
+
+
+
+
+
+
+
+ | DSO:
+ |
+ | | Due:
+ |
+ | | Balance:
+ |
+ | | Credit Rating:
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+ request->getUri()->getFragment() === 'c-tab-2' ? ' checked' : ''; ?>>
+
+
+
+
+ = $this->getHtml('Contact'); ?>
+
+
+
+
+
+ request->getUri()->getFragment() === 'c-tab-3' ? ' checked' : ''; ?>>
+
+
+
+
+ = $this->getHtml('Address'); ?>
+
+
+
+
+
+ request->getUri()->getFragment() === 'c-tab-4' ? ' checked' : ''; ?>>
+
+
+
+
+ = $this->getHtml('PaymentTerm'); ?>
+
+
+
+
+
+ request->getUri()->getFragment() === 'c-tab-5' ? ' checked' : ''; ?>>
+
+
+
+
+ = $this->getHtml('Payment'); ?>
+
+
+
+
+
+ request->getUri()->getFragment() === 'c-tab-6' ? ' checked' : ''; ?>>
+
+
+
+
+ = $this->getHtml('Price'); ?>
+
+
+
+
+
+ request->getUri()->getFragment() === 'c-tab-7' ? ' checked' : ''; ?>>
+
+
+
+
+ = $this->getHtml('AreaManager'); ?>
+
+
+
+
+
+ request->getUri()->getFragment() === 'c-tab-8' ? ' checked' : ''; ?>>
+
+
+ request->getUri()->getFragment() === 'c-tab-9' ? ' checked' : ''; ?>>
+
+
+
+ l11nManager, $this->request, $this->response);
+ $footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig');
+ $footerView->setPages(20);
+ $footerView->setPage(1);
+ ?>
+
+
+ = $this->getHtml('Logs'); ?>
+
+
+ | IP
+ | = $this->getHtml('ID', '0', '0'); ?>
+ | = $this->getHtml('Name'); ?>
+ | = $this->getHtml('Log'); ?>
+ | = $this->getHtml('Date'); ?>
+ |
+
+ |
+ |
+
+ | = $this->printHtml($this->request->getOrigin()); ?>
+ | = $this->printHtml($this->request->getHeader()->getAccount()); ?>
+ | = $this->printHtml($this->request->getHeader()->getAccount()); ?>
+ | Creating customer
+ | = $this->printHtml((new \DateTime('now'))->format('Y-m-d H:i:s')); ?>
+ |
+
+
+
+
+
+
diff --git a/Theme/Backend/supplier-single.tpl.php b/Theme/Backend/supplier-single.tpl.php
deleted file mode 100644
index 225c79a..0000000
--- a/Theme/Backend/supplier-single.tpl.php
+++ /dev/null
@@ -1,18 +0,0 @@
-getData('nav')->render();
|