many fixes and expands and module expansions

This commit is contained in:
Dennis Eichhorn 2021-04-04 17:10:52 +02:00
parent c9ab0a8fb4
commit d45c1fc432
23 changed files with 2180 additions and 85 deletions

View File

@ -44,5 +44,50 @@
"children": []
}
]
},
{
"id": 1003103001,
"pid": "/sales/analysis",
"type": 3,
"subtype": 1,
"name": "Client",
"uri": "{/prefix}sales/analysis/client?{?}",
"target": "self",
"icon": null,
"order": 1,
"from": "ClientManagement",
"permission": { "permission": 2, "type": null, "element": null },
"parent": 1001602001,
"children": []
},
{
"id": 1003103002,
"pid": "/sales/analysis",
"type": 3,
"subtype": 1,
"name": "Region",
"uri": "{/prefix}sales/analysis/region?{?}",
"target": "self",
"icon": null,
"order": 2,
"from": "ClientManagement",
"permission": { "permission": 2, "type": null, "element": null },
"parent": 1001602001,
"children": []
},
{
"id": 1003103003,
"pid": "/sales/analysis",
"type": 3,
"subtype": 1,
"name": "SalesRep",
"uri": "{/prefix}sales/analysis/rep?{?}",
"target": "self",
"icon": null,
"order": 3,
"from": "ClientManagement",
"permission": { "permission": 2, "type": null, "element": null },
"parent": 1001602001,
"children": []
}
]

View File

@ -83,6 +83,198 @@
}
}
},
"clientmgmt_attr_type": {
"name": "clientmgmt_attr_type",
"fields": {
"clientmgmt_attr_type_id": {
"name": "clientmgmt_attr_type_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"clientmgmt_attr_type_name": {
"name": "clientmgmt_attr_type_name",
"type": "VARCHAR(255)",
"null": false
},
"clientmgmt_attr_type_fields": {
"name": "clientmgmt_attr_type_fields",
"type": "INT(11)",
"null": false
},
"clientmgmt_attr_type_custom": {
"name": "clientmgmt_attr_type_custom",
"type": "TINYINT(1)",
"null": false
},
"clientmgmt_attr_type_required": {
"description": "Every item must have this attribute type if set to true.",
"name": "clientmgmt_attr_type_required",
"type": "TINYINT(1)",
"null": false
},
"clientmgmt_attr_type_pattern": {
"description": "This is a regex validation pattern.",
"name": "clientmgmt_attr_type_pattern",
"type": "VARCHAR(255)",
"null": false
}
}
},
"clientmgmt_attr_type_l11n": {
"name": "clientmgmt_attr_type_l11n",
"fields": {
"clientmgmt_attr_type_l11n_id": {
"name": "clientmgmt_attr_type_l11n_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"clientmgmt_attr_type_l11n_title": {
"name": "clientmgmt_attr_type_l11n_title",
"type": "VARCHAR(255)",
"null": false
},
"clientmgmt_attr_type_l11n_type": {
"name": "clientmgmt_attr_type_l11n_type",
"type": "INT(11)",
"null": false,
"foreignTable": "clientmgmt_attr_type",
"foreignKey": "clientmgmt_attr_type_id"
},
"clientmgmt_attr_type_l11n_lang": {
"name": "clientmgmt_attr_type_l11n_lang",
"type": "VARCHAR(2)",
"null": false,
"foreignTable": "language",
"foreignKey": "language_639_1"
}
}
},
"clientmgmt_attr_value": {
"name": "clientmgmt_attr_value",
"fields": {
"clientmgmt_attr_value_id": {
"name": "clientmgmt_attr_value_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"clientmgmt_attr_value_default": {
"name": "clientmgmt_attr_value_default",
"type": "TINYINT(1)",
"null": false
},
"clientmgmt_attr_value_type": {
"name": "clientmgmt_attr_value_type",
"type": "INT(11)",
"null": false
},
"clientmgmt_attr_value_valueStr": {
"name": "clientmgmt_attr_value_valueStr",
"type": "VARCHAR(255)",
"null": true,
"default": null
},
"clientmgmt_attr_value_valueInt": {
"name": "clientmgmt_attr_value_valueInt",
"type": "INT(11)",
"null": true,
"default": null
},
"clientmgmt_attr_value_valueDec": {
"name": "clientmgmt_attr_value_valueDec",
"type": "DECIMAL(19,5)",
"null": true,
"default": null
},
"clientmgmt_attr_value_valueDat": {
"name": "clientmgmt_attr_value_valueDat",
"type": "DATETIME",
"null": true,
"default": null
},
"clientmgmt_attr_value_lang": {
"name": "clientmgmt_attr_value_lang",
"type": "VARCHAR(2)",
"null": true,
"default": null,
"foreignTable": "language",
"foreignKey": "language_639_1"
},
"clientmgmt_attr_value_country": {
"name": "clientmgmt_attr_value_country",
"type": "VARCHAR(2)",
"null": true,
"default": null,
"foreignTable": "country",
"foreignKey": "country_code2"
}
}
},
"clientmgmt_client_attr_default": {
"name": "clientmgmt_client_attr_default",
"fields": {
"clientmgmt_client_attr_default_id": {
"name": "clientmgmt_client_attr_default_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"clientmgmt_client_attr_default_type": {
"name": "clientmgmt_client_attr_default_type",
"type": "INT(11)",
"null": false,
"foreignTable": "clientmgmt_attr_type",
"foreignKey": "clientmgmt_attr_type_id"
},
"clientmgmt_client_attr_default_value": {
"name": "clientmgmt_client_attr_default_value",
"type": "INT(11)",
"null": false,
"foreignTable": "clientmgmt_attr_value",
"foreignKey": "clientmgmt_attr_value_id"
}
}
},
"clientmgmt_client_attr": {
"name": "clientmgmt_client_attr",
"fields": {
"clientmgmt_client_attr_id": {
"name": "clientmgmt_client_attr_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"clientmgmt_client_attr_client": {
"name": "clientmgmt_client_attr_client",
"type": "INT(11)",
"null": false,
"foreignTable": "clientmgmt_client",
"foreignKey": "clientmgmt_client_id"
},
"clientmgmt_client_attr_type": {
"name": "clientmgmt_client_attr_type",
"type": "INT(11)",
"null": false,
"foreignTable": "clientmgmt_attr_type",
"foreignKey": "clientmgmt_attr_type_id"
},
"clientmgmt_client_attr_value": {
"name": "clientmgmt_client_attr_value",
"type": "INT(11)",
"null": true,
"default": null,
"foreignTable": "clientmgmt_attr_value",
"foreignKey": "clientmgmt_attr_value_id"
}
}
},
"clientmgmt_client_media": {
"name": "clientmgmt_client_media",
"fields": {

View File

@ -50,4 +50,37 @@ return [
],
],
],
'^.*/sales/analysis/client(\?.*|$)$' => [
[
'dest' => '\Modules\ClientManagement\Controller\BackendController:viewClientAnalysis',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::MODULE_NAME,
'type' => PermissionType::READ,
'state' => PermissionState::ANALYSIS,
],
],
],
'^.*/sales/analysis/rep(\?.*|$)$' => [
[
'dest' => '\Modules\ClientManagement\Controller\BackendController:viewSalesRepAnalysis',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::MODULE_NAME,
'type' => PermissionType::READ,
'state' => PermissionState::ANALYSIS,
],
],
],
'^.*/sales/analysis/region(\?.*|$)$' => [
[
'dest' => '\Modules\ClientManagement\Controller\BackendController:viewRegionAnalysis',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::MODULE_NAME,
'type' => PermissionType::READ,
'state' => PermissionState::ANALYSIS,
],
],
],
];

View File

@ -26,6 +26,18 @@ use phpOMS\Message\NotificationLevel;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Model\Message\FormValidation;
use Modules\ClientManagement\Models\ClientAttribute;
use Modules\ClientManagement\Models\NullClientAttributeType;
use Modules\ClientManagement\Models\NullClientAttributeValue;
use Modules\ClientManagement\Models\ClientAttributeTypeL11n;
use phpOMS\Message\Http\HttpRequest;
use Modules\ClientManagement\Models\ClientAttributeType;
use Modules\ClientManagement\Models\ClientAttributeValue;
use Modules\ClientManagement\Models\AttributeValueType;
use Modules\ClientManagement\Models\ClientAttributeTypeMapper;
use Modules\ClientManagement\Models\ClientAttributeTypeL11nMapper;
use Modules\ClientManagement\Models\ClientAttributeValueMapper;
use Modules\ClientManagement\Models\ClientAttributeMapper;
/**
* ClientManagement class.
@ -154,7 +166,318 @@ final class ApiController extends Controller
}
/**
* Api method to create item files
* Api method to create client attribute
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiClientAttributeCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
if (!empty($val = $this->validateClientAttributeCreate($request))) {
$response->set('attribute_create', new FormValidation($val));
$response->header->status = RequestStatusCode::R_400;
return;
}
$attribute = $this->createClientAttributeFromRequest($request);
$this->createModel($request->header->account, $attribute, ClientAttributeMapper::class, 'attribute', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute', 'Attribute successfully created', $attribute);
}
/**
* Method to create client attribute from request.
*
* @param RequestAbstract $request Request
*
* @return ClientAttribute
*
* @since 1.0.0
*/
private function createClientAttributeFromRequest(RequestAbstract $request) : ClientAttribute
{
$attribute = new ClientAttribute();
$attribute->client = (int) $request->getData('client');
$attribute->type = new NullClientAttributeType((int) $request->getData('type'));
$attribute->value = new NullClientAttributeValue((int) $request->getData('value'));
return $attribute;
}
/**
* Validate client attribute create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateClientAttributeCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['type'] = empty($request->getData('type')))
|| ($val['value'] = empty($request->getData('value')))
|| ($val['client'] = empty($request->getData('client')))
) {
return $val;
}
return [];
}
/**
* Api method to create client attribute l11n
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiClientAttributeTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
if (!empty($val = $this->validateClientAttributeTypeL11nCreate($request))) {
$response->set('attr_type_l11n_create', new FormValidation($val));
$response->header->status = RequestStatusCode::R_400;
return;
}
$attrL11n = $this->createClientAttributeTypeL11nFromRequest($request);
$this->createModel($request->header->account, $attrL11n, ClientAttributeTypeL11nMapper::class, 'attr_type_l11n', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute type localization', 'Attribute type localization successfully created', $attrL11n);
}
/**
* Method to create client attribute l11n from request.
*
* @param RequestAbstract $request Request
*
* @return ClientAttributeTypeL11n
*
* @since 1.0.0
*/
private function createClientAttributeTypeL11nFromRequest(RequestAbstract $request) : ClientAttributeTypeL11n
{
$attrL11n = new ClientAttributeTypeL11n();
$attrL11n->setType((int) ($request->getData('type') ?? 0));
$attrL11n->setLanguage((string) (
$request->getData('language') ?? $request->getLanguage()
));
$attrL11n->title = (string) ($request->getData('title') ?? '');
return $attrL11n;
}
/**
* Validate client attribute l11n create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateClientAttributeTypeL11nCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['title'] = empty($request->getData('title')))
|| ($val['type'] = empty($request->getData('type')))
) {
return $val;
}
return [];
}
/**
* Api method to create client attribute type
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiClientAttributeTypeCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
if (!empty($val = $this->validateClientAttributeTypeCreate($request))) {
$response->set('attr_type_create', new FormValidation($val));
$response->header->status = RequestStatusCode::R_400;
return;
}
$attrType = $this->createClientAttributeTypeFromRequest($request);
$this->createModel($request->header->account, $attrType, ClientAttributeTypeMapper::class, 'attr_type', $request->getOrigin());
$l11nRequest = new HttpRequest($request->uri);
$l11nRequest->setData('type', $attrType->getId());
$l11nRequest->setData('title', $request->getData('title'));
$l11nRequest->setData('language', $request->getData('language'));
$l11nAttributeType = $this->createClientAttributeTypeL11nFromRequest($l11nRequest);
$this->createModel($request->header->account, $l11nAttributeType, ClientAttributeTypeL11nMapper::class, 'attr_type_l11n_create', $request->getOrigin());
$attrType->setL11n($l11nAttributeType);
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute type', 'Attribute type successfully created', $attrType);
}
/**
* Method to create client attribute from request.
*
* @param RequestAbstract $request Request
*
* @return ClientAttributeType
*
* @since 1.0.0
*/
private function createClientAttributeTypeFromRequest(RequestAbstract $request) : ClientAttributeType
{
$attrType = new ClientAttributeType();
$attrType->setL11n((string) ($request->getData('name') ?? ''));
$attrType->setFields((int) ($request->getData('fields') ?? 0));
$attrType->setCustom((bool) ($request->getData('custom') ?? false));
return $attrType;
}
/**
* Validate client attribute create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateClientAttributeTypeCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['name'] = empty($request->getData('name')))
|| ($val['title'] = empty($request->getData('title')))
) {
return $val;
}
return [];
}
/**
* Api method to create client attribute value
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiClientAttributeValueCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
if (!empty($val = $this->validateClientAttributeValueCreate($request))) {
$response->set('attr_value_create', new FormValidation($val));
$response->header->status = RequestStatusCode::R_400;
return;
}
$attrValue = $this->createClientAttributeValueFromRequest($request);
$this->createModel($request->header->account, $attrValue, ClientAttributeValueMapper::class, 'attr_value', $request->getOrigin());
if ($attrValue->isDefault) {
$this->createModelRelation(
$request->header->account,
(int) $request->getData('attributetype'),
$attrValue->getId(),
ClientAttributeTypeMapper::class, 'defaults', '', $request->getOrigin()
);
}
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute value', 'Attribute value successfully created', $attrValue);
}
/**
* Method to create client attribute value from request.
*
* @param RequestAbstract $request Request
*
* @return ClientAttributeValue
*
* @since 1.0.0
*/
private function createClientAttributeValueFromRequest(RequestAbstract $request) : ClientAttributeValue
{
$attrValue = new ClientAttributeValue();
$type = $request->getData('type') ?? 0;
if ($type === AttributeValueType::_INT) {
$attrValue->valueInt = (int) $request->getData('value');
} elseif ($type === AttributeValueType::_STRING) {
$attrValue->valueStr = (string) $request->getData('value');
} elseif ($type === AttributeValueType::_FLOAT) {
$attrValue->valueDec = (float) $request->getData('value');
} elseif ($type === AttributeValueType::_DATETIME) {
$attrValue->valueDat = new \DateTime($request->getData('value') ?? '');
}
$attrValue->type = $type;
$attrValue->isDefault = (bool) ($request->getData('default') ?? false);
if ($request->hasData('language')) {
$attrValue->setLanguage((string) ($request->getData('language') ?? $request->getLanguage()));
}
if ($request->hasData('country')) {
$attrValue->setCountry((string) ($request->getData('country') ?? $request->header->l11n->getCountry()));
}
return $attrValue;
}
/**
* Validate client attribute value create request
*
* @param RequestAbstract $request Request
*
* @return array<string, bool>
*
* @since 1.0.0
*/
private function validateClientAttributeValueCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['type'] = empty($request->getData('type')))
|| ($val['value'] = empty($request->getData('value')))
) {
return $val;
}
return [];
}
/**
* Api method to create client files
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
@ -171,7 +494,7 @@ final class ApiController extends Controller
$uploadedFiles = $request->getFiles() ?? [];
if (empty($uploadedFiles)) {
$this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Item', 'Invalid client image', $uploadedFiles);
$this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Client', 'Invalid file', $uploadedFiles);
$response->header->status = RequestStatusCode::R_400;
return;
@ -196,11 +519,11 @@ final class ApiController extends Controller
ClientMapper::class, 'files', '', $request->getOrigin()
);
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Image', 'Image successfully updated', $uploaded);
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'File', 'File successfully updated', $uploaded);
}
/**
* Api method to create item files
* Api method to create client files
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response

View File

@ -24,6 +24,7 @@ use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Stdlib\Base\SmartDateTime;
use phpOMS\Views\View;
use Modules\Media\Models\Media;
/**
* ClientManagement class.
@ -53,7 +54,12 @@ final class BackendController extends Controller
$view->setTemplate('/Modules/ClientManagement/Theme/Backend/client-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003102001, $request, $response));
$client = ClientMapper::getAfterPivot(0, null, 25);
$client = ClientMapper
::with('notes', models: null)
::with('contactElements', models: null)
::with('type', 'backend_image', models: [Media::class]) // @todo: it would be nicer if I coult say files:type or files/type and remove the models parameter?
::getAfterPivot(0, null, 25);
$view->addData('client', $client);
return $view;
@ -103,7 +109,11 @@ final class BackendController extends Controller
$view->setTemplate('/Modules/ClientManagement/Theme/Backend/client-profile');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003102001, $request, $response));
$client = ClientMapper::get((int) $request->getData('id'));
$client = ClientMapper
::with('files', limit: 5, orderBy: 'createdAt', sortOrder: 'ASC')
::with('notes', limit: 5, orderBy: 'id', sortOrder: 'ASC')
::get((int) $request->getData('id'));
$view->setData('client', $client);
// stats
@ -111,14 +121,18 @@ final class BackendController extends Controller
$ytd = SalesBillMapper::getSalesByClientId($client->getId(), new SmartDateTime('Y-01-01'), new SmartDateTime('now'));
$mtd = SalesBillMapper::getSalesByClientId($client->getId(), new SmartDateTime('Y-m-01'), new SmartDateTime('now'));
$lastOrder = SalesBillMapper::getLastOrderDateByClientId($client->getId());
$newestInvoices = SalesBillMapper::with('language', $response->getLanguage(), [BillTypeL11n::class])::getNewestClientInvoices($client->getId(), 5);
$newestInvoices = SalesBillMapper
::with('language', $response->getLanguage(), [BillTypeL11n::class])
::getNewestClientInvoices($client->getId(), 5);
$monthlySalesCosts = SalesBillMapper::getClientMonthlySalesCosts($client->getId(), (new SmartDateTime('now'))->createModify(-1), new SmartDateTime('now'));
$items = SalesBillMapper::getClientItem($client->getId(), (new SmartDateTime('now'))->createModify(-1), new SmartDateTime('now'));
} else {
$ytd = new Money();
$mtd = new Money();
$lastOrder = null;
$newestInvoices = [];
$monthlySalesCosts = [];
$items = [];
}
$view->addData('ytd', $ytd);
@ -126,6 +140,7 @@ final class BackendController extends Controller
$view->addData('lastOrder', $lastOrder);
$view->addData('newestInvoices', $newestInvoices);
$view->addData('monthlySalesCosts', $monthlySalesCosts);
$view->addData('items', $items);
return $view;
}

View File

@ -0,0 +1,36 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ClientManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\ClientManagement\Models;
use phpOMS\Stdlib\Base\Enum;
/**
* Attribute value type enum.
*
* @package Modules\ClientManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
abstract class AttributeValueType extends Enum
{
public const _INT = 0;
public const _STRING = 1;
public const _FLOAT = 2;
public const _DATETIME = 3;
}

View File

@ -21,6 +21,7 @@ use Modules\Media\Models\Media;
use Modules\Profile\Models\ContactElement;
use Modules\Profile\Models\NullContactElement;
use Modules\Profile\Models\Profile;
use Modules\Media\Models\NullMedia;
/**
* Account class.
@ -50,6 +51,14 @@ class Client
public Profile $profile;
/**
* Attributes.
*
* @var int[]|ClientAttribute[]
* @since 1.0.0
*/
private array $attributes = [];
/**
* Files.
*

88
Models/ClientAttribute.php Executable file
View File

@ -0,0 +1,88 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ClientManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\ClientManagement\Models;
use phpOMS\Contract\ArrayableInterface;
/**
* Client class.
*
* @package Modules\ClientManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class ClientAttribute implements \JsonSerializable, ArrayableInterface
{
/**
* Id.
*
* @var int
* @since 1.0.0
*/
protected int $id = 0;
/**
* Client this attribute belongs to
*
* @var int
* @since 1.0.0
*/
public int $client = 0;
/**
* Attribute type the attribute belongs to
*
* @var ClientAttributeType
* @since 1.0.0
*/
public ClientAttributeType $type;
/**
* Attribute value the attribute belongs to
*
* @var ClientAttributeValue
* @since 1.0.0
*/
public ClientAttributeValue $value;
/**
* Get id
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize()
{
return $this->toArray();
}
}

View File

@ -0,0 +1,74 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ClientManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\ClientManagement\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
/**
* Client mapper class.
*
* @package Modules\ClientManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class ClientAttributeMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'clientmgmt_client_attr_id' => ['name' => 'clientmgmt_client_attr_id', 'type' => 'int', 'internal' => 'id'],
'clientmgmt_client_attr_client' => ['name' => 'clientmgmt_client_attr_client', 'type' => 'int', 'internal' => 'client'],
'clientmgmt_client_attr_type' => ['name' => 'clientmgmt_client_attr_type', 'type' => 'int', 'internal' => 'type'],
'clientmgmt_client_attr_value' => ['name' => 'clientmgmt_client_attr_value', 'type' => 'int', 'internal' => 'value'],
];
/**
* Has one relation.
*
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
* @since 1.0.0
*/
protected static array $ownsOne = [
'type' => [
'mapper' => ClientAttributeTypeMapper::class,
'external' => 'clientmgmt_client_attr_type',
],
'value' => [
'mapper' => ClientAttributeValueMapper::class,
'external' => 'clientmgmt_client_attr_value',
],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'clientmgmt_client_attr';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'clientmgmt_client_attr_id';
}

180
Models/ClientAttributeType.php Executable file
View File

@ -0,0 +1,180 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ClientManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\ClientManagement\Models;
use phpOMS\Contract\ArrayableInterface;
use phpOMS\Localization\ISO639x1Enum;
/**
* Client Attribute Type class.
*
* @package Modules\ClientManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class ClientAttributeType implements \JsonSerializable, ArrayableInterface
{
/**
* Id
*
* @var int
* @since 1.0.0
*/
protected int $id = 0;
/**
* Name/string identifier by which it can be found/categorized
*
* @var string
* @since 1.0.0
*/
protected string $name = ''; // @todo: currently not filled, should be used as identifier or if not required removed (at the moment it seems like it is useless?!)
/**
* Which field data type is required (string, int, ...) in the value
*
* @var int
* @since 1.0.0
*/
protected int $fields = 0;
/**
* Is a custom value allowed (e.g. custom string)
*
* @var bool
* @since 1.0.0
*/
protected bool $custom = false;
public string $validationPattern = '';
public bool $isRequired = false;
/**
* Localization
*
* @var string | ClientAttributeTypeL11n
*/
protected string | ClientAttributeTypeL11n $l11n;
/**
* Possible default attribute values
*
* @var array
*/
protected array $defaults = [];
/**
* Constructor.
*
* @param string $name Name/identifier of the attribute type
*
* @since 1.0.0
*/
public function __construct(string $name = '')
{
$this->setL11n($name);
}
/**
* Get id
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Set l11n
*
* @param string|ClientAttributeTypeL11n $l11n Tag article l11n
* @param string $lang Language
*
* @return void
*
* @since 1.0.0
*/
public function setL11n($l11n, string $lang = ISO639x1Enum::_EN) : void
{
if ($l11n instanceof ClientAttributeTypeL11n) {
$this->l11n = $l11n;
} elseif ($this->l11n instanceof ClientAttributeTypeL11n && \is_string($l11n)) {
$this->l11n->title = $l11n;
} elseif (\is_string($l11n)) {
$this->l11n = new ClientAttributeTypeL11n();
$this->l11n->title = $l11n;
$this->l11n->setLanguage($lang);
}
}
/**
* @return string
*
* @since 1.0.0
*/
public function getL11n() : string
{
return $this->l11n instanceof ClientAttributeTypeL11n ? $this->l11n->title : $this->l11n;
}
/**
* Set fields
*
* @param int $fields Fields
*
* @return void
*
* @since 1.0.0
*/
public function setFields(int $fields) : void
{
$this->fields = $fields;
}
/**
* Set custom
*
* @param bool $custom FieldsCustom
*
* @return void
*
* @since 1.0.0
*/
public function setCustom(bool $custom) : void
{
$this->custom = $custom;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize()
{
return $this->toArray();
}
}

View File

@ -0,0 +1,147 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ClientManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\ClientManagement\Models;
use phpOMS\Contract\ArrayableInterface;
use phpOMS\Localization\ISO639x1Enum;
/**
* Client class.
*
* @package Modules\ClientManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class ClientAttributeTypeL11n implements \JsonSerializable, ArrayableInterface
{
/**
* ID.
*
* @var int
* @since 1.0.0
*/
protected int $id = 0;
/**
* Client ID.
*
* @var int|ClientAttributeType
* @since 1.0.0
*/
protected int |
ClientAttributeType $type = 0;
/**
* Language.
*
* @var string
* @since 1.0.0
*/
protected string $language = ISO639x1Enum::_EN;
/**
* Title.
*
* @var string
* @since 1.0.0
*/
public string $title = '';
/**
* Constructor.
*
* @param int|ClientAttributeType $type Attribute type
* @param string $title Localized title
* @param string $language Language
*
* @since 1.0.0
*/
public function __construct(int | ClientAttributeType $type = 0, string $title = '', string $language = ISO639x1Enum::_EN)
{
$this->type = $type;
$this->title = $title;
$this->language = $language;
}
/**
* Get id
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Get attribute type
*
* @return int|ClientAttributeType
*
* @since 1.0.0
*/
public function getType()
{
return $this->type;
}
/**
* Set type.
*
* @param int $type Type id
*
* @return void
*
* @since 1.0.0
*/
public function setType(int $type) : void
{
$this->type = $type;
}
/**
* Set language
*
* @param string $language Language
*
* @return void
*
* @since 1.0.0
*/
public function setLanguage(string $language) : void
{
$this->language = $language;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize()
{
return $this->toArray();
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ClientManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\ClientManagement\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
/**
* Client mapper class.
*
* @package Modules\ClientManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class ClientAttributeTypeL11nMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'clientmgmt_attr_type_l11n_id' => ['name' => 'clientmgmt_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
'clientmgmt_attr_type_l11n_title' => ['name' => 'clientmgmt_attr_type_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
'clientmgmt_attr_type_l11n_type' => ['name' => 'clientmgmt_attr_type_l11n_type', 'type' => 'int', 'internal' => 'type'],
'clientmgmt_attr_type_l11n_lang' => ['name' => 'clientmgmt_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'clientmgmt_attr_type_l11n';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'clientmgmt_attr_type_l11n_id';
}

View File

@ -0,0 +1,83 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ClientManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\ClientManagement\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
/**
* Client mapper class.
*
* @package Modules\ClientManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class ClientAttributeTypeMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'clientmgmt_attr_type_id' => ['name' => 'clientmgmt_attr_type_id', 'type' => 'int', 'internal' => 'id'],
'clientmgmt_attr_type_name' => ['name' => 'clientmgmt_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
'clientmgmt_attr_type_fields' => ['name' => 'clientmgmt_attr_type_fields', 'type' => 'int', 'internal' => 'fields'],
'clientmgmt_attr_type_custom' => ['name' => 'clientmgmt_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'],
'clientmgmt_attr_type_pattern' => ['name' => 'clientmgmt_attr_type_pattern', 'type' => 'bool', 'internal' => 'validationPattern'],
'clientmgmt_attr_type_required' => ['name' => 'clientmgmt_attr_type_required', 'type' => 'bool', 'internal' => 'isRequired'],
];
/**
* Has many relation.
*
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
protected static array $hasMany = [
'l11n' => [
'mapper' => ClientAttributeTypeL11nMapper::class,
'table' => 'clientmgmt_attr_type_l11n',
'self' => 'clientmgmt_attr_type_l11n_type',
'column' => 'title',
'conditional' => true,
'external' => null,
],
'defaults' => [
'mapper' => ClientAttributeValueMapper::class,
'table' => 'clientmgmt_client_attr_default',
'self' => 'clientmgmt_client_attr_default_type',
'external' => 'clientmgmt_client_attr_default_value',
'conditional' => false,
],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'clientmgmt_attr_type';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'clientmgmt_attr_type_id';
}

214
Models/ClientAttributeValue.php Executable file
View File

@ -0,0 +1,214 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ClientManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\ClientManagement\Models;
use phpOMS\Contract\ArrayableInterface;
use phpOMS\Localization\ISO3166TwoEnum;
use phpOMS\Localization\ISO639x1Enum;
/**
* Client attribute value class.
*
* The relation with the type/client is defined in the ClientAttribute class.
*
* @package Modules\ClientManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class ClientAttributeValue implements \JsonSerializable, ArrayableInterface
{
/**
* Id
*
* @var int
* @since 1.0.0
*/
protected int $id = 0;
/**
* Type of the attribute
*
* @var int
* @since 1.0.0
*/
public int $type = 0;
/**
* Int value
*
* @var null|int
* @since 1.0.0
*/
public ?int $valueInt = null;
/**
* String value
*
* @var null|string
* @since 1.0.0
*/
public ?string $valueStr = null;
/**
* Decimal value
*
* @var null|float
* @since 1.0.0
*/
public ?float $valueDec = null;
/**
* DateTime value
*
* @var null|\DateTimeInterface
* @since 1.0.0
*/
public ?\DateTimeInterface $valueDat = null;
/**
* Is a default value which can be selected
*
* @var bool
* @since 1.0.0
*/
public bool $isDefault = false;
/**
* Language
*
* @var string
* @since 1.0.0
*/
protected string $language = ISO639x1Enum::_EN;
/**
* Country
*
* @var string
* @since 1.0.0
*/
protected string $country = ISO3166TwoEnum::_USA;
/**
* Constructor.
*
* @param int $type Type
* @param mixed $value Value
* @param string $language Language
*
* @since 1.0.0
*/
public function __construct(int $type = 0, $value = '', string $language = ISO639x1Enum::_EN)
{
$this->type = $type;
$this->language = $language;
$this->setValue($value);
}
/**
* Get id
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
/**
* Set value
*
* @param int|string|float|\DateTimeInterface $value Value
*
* @return void
*
* @since 1.0.0
*/
public function setValue($value) : void
{
if (\is_string($value)) {
$this->valueStr = $value;
} elseif (\is_int($value)) {
$this->valueInt = $value;
} elseif (\is_float($value)) {
$this->valueDec = $value;
} elseif ($value instanceof \DateTimeInterface) {
$this->valueDat = $value;
}
}
public function getValue() : mixed
{
if (!empty($this->valueStr)) {
return $this->valueStr;
} elseif (!empty($this->valueInt)) {
return $this->valueInt;
} elseif (!empty($this->valueDec)) {
return $this->valueDec;
} elseif ($this->valueDat instanceof \DateTimeInterface) {
return $this->valueDat;
}
return null;
}
/**
* Set language
*
* @param string $language Language
*
* @return void
*
* @since 1.0.0
*/
public function setLanguage(string $language) : void
{
$this->language = $language;
}
/**
* Set country
*
* @param string $country Country
*
* @return void
*
* @since 1.0.0
*/
public function setCountry(string $country) : void
{
$this->country = $country;
}
/**
* {@inheritdoc}
*/
public function toArray() : array
{
return [];
}
/**
* {@inheritdoc}
*/
public function jsonSerialize()
{
return $this->toArray();
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ClientManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https: //orange-management.org
*/
declare(strict_types=1);
namespace Modules\ClientManagement\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
/**
* Client mapper class.
*
* @package Modules\ClientManagement\Models
* @license OMS License 1.0
* @link https: //orange-management.org
* @since 1.0.0
*/
final class ClientAttributeValueMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
'clientmgmt_attr_value_id' => ['name' => 'clientmgmt_attr_value_id', 'type' => 'int', 'internal' => 'id'],
'clientmgmt_attr_value_default' => ['name' => 'clientmgmt_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'],
'clientmgmt_attr_value_type' => ['name' => 'clientmgmt_attr_value_type', 'type' => 'int', 'internal' => 'type'],
'clientmgmt_attr_value_valueStr' => ['name' => 'clientmgmt_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'],
'clientmgmt_attr_value_valueInt' => ['name' => 'clientmgmt_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'],
'clientmgmt_attr_value_valueDec' => ['name' => 'clientmgmt_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'],
'clientmgmt_attr_value_valueDat' => ['name' => 'clientmgmt_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'],
'clientmgmt_attr_value_lang' => ['name' => 'clientmgmt_attr_value_lang', 'type' => 'string', 'internal' => 'language'],
'clientmgmt_attr_value_country' => ['name' => 'clientmgmt_attr_value_country', 'type' => 'string', 'internal' => 'country'],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'clientmgmt_attr_value';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'clientmgmt_attr_value_id';
}

View File

@ -115,5 +115,12 @@ final class ClientMapper extends DataMapperAbstract
'external' => 'clientmgmt_client_contactelement_dst',
'self' => 'clientmgmt_client_contactelement_src',
],
'attributes' => [
'mapper' => ClientAttributeMapper::class,
'table' => 'clientmgmt_client_attr',
'self' => 'clientmgmt_client_attr_client',
'conditional' => true,
'external' => null,
],
];
}

38
Models/NullClientAttribute.php Executable file
View File

@ -0,0 +1,38 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ClientManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\ClientManagement\Models;
/**
* Null model
*
* @package Modules\ClientManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class NullClientAttribute extends ClientAttribute
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
}
}

View File

@ -0,0 +1,38 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ClientManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\ClientManagement\Models;
/**
* Null model
*
* @package Modules\ClientManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class NullClientAttributeType extends ClientAttributeType
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
}
}

View File

@ -0,0 +1,38 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ClientManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\ClientManagement\Models;
/**
* Null model
*
* @package Modules\ClientManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class NullClientAttributeTypeL11n extends ClientAttributeTypeL11n
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
}
}

View File

@ -0,0 +1,38 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ClientManagement\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\ClientManagement\Models;
/**
* Null model
*
* @package Modules\ClientManagement\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class NullClientAttributeValue extends ClientAttributeValue
{
/**
* Constructor
*
* @param int $id Model id
*
* @since 1.0.0
*/
public function __construct(int $id = 0)
{
$this->id = $id;
}
}

View File

@ -0,0 +1,192 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Billing
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
use phpOMS\Uri\UriFactory;
$bills = $this->getData('newestInvoices') ?? [];
?>
<div class="row">
<div class="col-xs-12">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Bills'); ?><i class="fa fa-download floatRight download btn"></i></div>
<table id="billList" class="default">
<thead>
<tr>
<td><label class="checkbox" for="iBillSelect-0">
<input type="checkbox" id="iBillSelect-0" name="billselect">
<span class="checkmark"></span>
</label>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<label for="billList-sort-1">
<input type="radio" name="billList-sort" id="billList-sort-1">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-2">
<input type="radio" name="billList-sort" id="billList-sort-2">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Type'); ?>
<label for="billList-sort-3">
<input type="radio" name="billList-sort" id="billList-sort-3">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-4">
<input type="radio" name="billList-sort" id="billList-sort-4">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('ClientID'); ?>
<label for="billList-sort-5">
<input type="radio" name="billList-sort" id="billList-sort-5">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-6">
<input type="radio" name="billList-sort" id="billList-sort-6">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td class="wf-100"><?= $this->getHtml('Client'); ?>
<label for="billList-sort-7">
<input type="radio" name="billList-sort" id="billList-sort-7">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-8">
<input type="radio" name="billList-sort" id="billList-sort-8">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td class="wf-100"><?= $this->getHtml('Address'); ?>
<label for="billList-sort-9">
<input type="radio" name="billList-sort" id="billList-sort-9">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-10">
<input type="radio" name="billList-sort" id="billList-sort-10">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td class="wf-100"><?= $this->getHtml('Postal'); ?>
<label for="billList-sort-11">
<input type="radio" name="billList-sort" id="billList-sort-11">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-12">
<input type="radio" name="billList-sort" id="billList-sort-12">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td class="wf-100"><?= $this->getHtml('City'); ?>
<label for="billList-sort-13">
<input type="radio" name="billList-sort" id="billList-sort-13">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-14">
<input type="radio" name="billList-sort" id="billList-sort-14">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td class="wf-100"><?= $this->getHtml('Country'); ?>
<label for="billList-sort-15">
<input type="radio" name="billList-sort" id="billList-sort-15">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-16">
<input type="radio" name="billList-sort" id="billList-sort-16">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Net'); ?>
<label for="billList-sort-7">
<input type="radio" name="billList-sort" id="billList-sort-7">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-18">
<input type="radio" name="billList-sort" id="billList-sort-18">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Profit'); ?>
<label for="billList-sort-21">
<input type="radio" name="billList-sort" id="billList-sort-21">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-22">
<input type="radio" name="billList-sort" id="billList-sort-22">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Created'); ?>
<label for="billList-sort-23">
<input type="radio" name="billList-sort" id="billList-sort-23">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="billList-sort-24">
<input type="radio" name="billList-sort" id="billList-sort-24">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<tbody>
<?php $count = 0; foreach ($bills as $key => $value) :
++$count;
$url = UriFactory::build('{/prefix}sales/bill?{?}&id=' . $value->getId());
?>
<tr data-href="<?= $url; ?>">
<td><label class="checkbox" for="iBillSelect-<?= $key; ?>">
<input type="checkbox" id="iBillSelect-<?= $key; ?>" name="billselect">
<span class="checkmark"></span>
</label>
<td><a href="<?= $url; ?>"><?= $value->getNumber(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->type->getL11n(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->client->number; ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->billTo); ?></a>
<td><a href="<?= $url; ?>"><?= $value->billAddress; ?></a>
<td><a href="<?= $url; ?>"><?= $value->billZip; ?></a>
<td><a href="<?= $url; ?>"><?= $value->billCity; ?></a>
<td><a href="<?= $url; ?>"><?= $value->billCountry; ?></a>
<td><a href="<?= $url; ?>"><?= $value->net->getCurrency(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->profit->getCurrency(); ?></a>
<td><a href="<?= $url; ?>"><?= $value->createdAt->format('Y-m-d'); ?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="12" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -0,0 +1,161 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\ItemManagement
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
use Modules\Media\Models\NullMedia;
use phpOMS\Uri\UriFactory;
/** @var \phpOMS\Views\View $this */
$items = $this->getData('items') ?? [];
?>
<div class="row">
<div class="col-xs-12">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Items'); ?><i class="fa fa-download floatRight download btn"></i></div>
<table id="iSalesItemList" class="default">
<thead>
<tr>
<td><label class="checkbox" for="iSalesItemSelect-0">
<input type="checkbox" id="iSalesItemSelect-0" name="itemselect">
<span class="checkmark"></span>
</label>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<label for="iSalesItemList-sort-1">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-1">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesItemList-sort-2">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-2">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td class="wf-100"><?= $this->getHtml('Name'); ?>
<label for="iSalesItemList-sort-3">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-3">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesItemList-sort-4">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-4">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Quantity'); ?>
<label for="iSalesItemList-sort-5">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-5">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesItemList-sort-6">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-6">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('UnitPrice'); ?>
<label for="iSalesItemList-sort-7">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-7">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesItemList-sort-8">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-8">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Discount'); ?>
<label for="iSalesItemList-sort-11">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-11">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesItemList-sort-12">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-12">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Discount%'); ?>
<label for="iSalesItemList-sort-13">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-13">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesItemList-sort-14">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-14">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('DiscountBonus'); ?>
<label for="iSalesItemList-sort-15">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-15">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesItemList-sort-16">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-16">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('TotalPrice'); ?>
<label for="iSalesItemList-sort-9">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-9">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesItemList-sort-10">
<input type="radio" name="iSalesItemList-sort" id="iSalesItemList-sort-10">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<tbody>
<?php
$count = 0;
foreach ($items as $key => $value) :
if ($value->itemNumber === '') {
continue;
}
++$count;
$url = UriFactory::build('{/prefix}sales/item/profile?{?}&id=' . $value->getId());
?>
<tr data-href="<?= $url; ?>">
<td><label class="checkbox" for="iSalesItemSelect-<?= $key; ?>">
<input type="checkbox" id="iSalesItemSelect-<?= $key; ?>" name="itemselect">
<span class="checkmark"></span>
</label>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->itemNumber); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->itemName); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml((string) $value->quantity); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->singleSalesPriceNet->getCurrency()); ?></a>
<td>
<td>
<td>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->totalSalesPriceNet->getCurrency()); ?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="9" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</section>
</div>
</div>

View File

@ -37,24 +37,20 @@ echo $this->getData('nav')->render();
<div class="box">
<ul class="tab-links">
<li><label for="c-tab-1"><?= $this->getHtml('Profile'); ?></label></li>
<li><label for="c-tab-2"><?= $this->getHtml('Contact'); ?></label></li>
<li><label for="c-tab-3"><?= $this->getHtml('Addresses'); ?></label></li>
<li><label for="c-tab-4"><?= $this->getHtml('PaymentTerm'); ?></label></li>
<li><label for="c-tab-5"><?= $this->getHtml('Payment'); ?></label></li>
<li><label for="c-tab-6"><?= $this->getHtml('Prices'); ?></label></li>
<li><label for="c-tab-7"><?= $this->getHtml('AreaManager'); ?></label></li>
<li><label for="c-tab-7"><?= $this->getHtml('Attributes'); ?></label></li>
<li><label for="c-tab-8"><?= $this->getHtml('Files'); ?></label></li>
<li><label for="c-tab-10"><?= $this->getHtml('Invoices'); ?></label>
<li><label for="c-tab-9"><?= $this->getHtml('Invoices'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Articles'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Messages'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Support'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Modules'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Accounting'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Notes'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Tags'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Calendar'); ?></label>
<li><label for="c-tab-10"><?= $this->getHtml('Permission'); ?></label>
<li><label for="c-tab-9"><?= $this->getHtml('Logs'); ?></label>
<li><label for="c-tab-11"><?= $this->getHtml('Messages'); ?></label><!-- incl. support -->
<li><label for="c-tab-11"><?= $this->getHtml('Accounting'); ?></label>
<li><label for="c-tab-11"><?= $this->getHtml('Notes'); ?></label>
<li><label for="c-tab-11"><?= $this->getHtml('Tags'); ?></label>
<li><label for="c-tab-11"><?= $this->getHtml('Calendar'); ?></label>
<li><label for="c-tab-11"><?= $this->getHtml('Permission'); ?></label>
<li><label for="c-tab-12"><?= $this->getHtml('Logs'); ?></label>
</ul>
</div>
<div class="tab-content">
@ -83,7 +79,10 @@ echo $this->getData('nav')->render();
</section>
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Contact'); ?></div>
<div class="portlet-head">
<?= $this->getHtml('Contact'); ?>
<a class="floatRight" href=""><i class="fa fa-envelope-o btn"></i></a>
</div>
<div class="portlet-body">
<table class="layout wf-100">
<tr><td><label for="iName1"><?= $this->getHtml('Phone'); ?></label>
@ -97,28 +96,50 @@ echo $this->getData('nav')->render();
</section>
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Address'); ?></div>
<div class="portlet-body">
<table class="layout wf-100">
<?php if (!empty($client->mainAddress->addition)) : ?>
<tr><td><label for="iName1"><?= $this->getHtml('Addition'); ?></label>
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($client->mainAddress->addition); ?>">
<?php endif; ?>
<tr><td><label for="iName1"><?= $this->getHtml('Address'); ?></label>
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($client->mainAddress->address); ?>" required>
<tr><td><label for="iName1"><?= $this->getHtml('Postal'); ?></label>
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($client->mainAddress->postal); ?>" required>
<tr><td><label for="iName1"><?= $this->getHtml('City'); ?></label>
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($client->mainAddress->city); ?>" required>
<tr><td><label for="iName1"><?= $this->getHtml('Country'); ?></label>
<tr><td><select>
<?php foreach ($countryCodes as $code3 => $code2) : ?>
<option value="<?= $this->printHtml($code2); ?>"<?= $this->printHtml($code2 === $client->mainAddress->getCountry() ? ' selected' : ''); ?>><?= $this->printHtml($countries[$code3]); ?>
<?php endforeach; ?>
</select>
<tr><td><img id="iMap" style="width: 100%;" src="<?= UriFactory::build('phpOMS/Localization/Maps/svg/' . \strtolower($client->mainAddress->getCountry()) . '.svg'); ?>">
</table>
</div>
<div class="portlet-head">
<?= $this->getHtml('Address'); ?>
<span class="clickPopup floatRight">
<label for="addressDropdown"><i class="fa fa-print btn"></i></label>
<input id="addressDropdown" name="addressDropdown" type="checkbox">
<div class="popup">
<ul>
<li>
<input id="id1" type="checkbox">
<ul>
<li>
<label for="id1">
<a href="" class="button">Word</a>
<span></span>
<i class="fa fa-chevron-right expand"></i>
</label>
<li>Letter
</ul>
<li><label class="button cancel" for="addressDropdown">Cancel</label>
</ul>
</div>
</span>
</div>
<div class="portlet-body">
<table class="layout wf-100">
<?php if (!empty($client->mainAddress->addition)) : ?>
<tr><td><label for="iName1"><?= $this->getHtml('Addition'); ?></label>
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($client->mainAddress->addition); ?>">
<?php endif; ?>
<tr><td><label for="iName1"><?= $this->getHtml('Address'); ?></label>
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($client->mainAddress->address); ?>" required>
<tr><td><label for="iName1"><?= $this->getHtml('Postal'); ?></label>
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($client->mainAddress->postal); ?>" required>
<tr><td><label for="iName1"><?= $this->getHtml('City'); ?></label>
<tr><td><input type="text" id="iName1" name="name1" value="<?= $this->printHtml($client->mainAddress->city); ?>" required>
<tr><td><label for="iName1"><?= $this->getHtml('Country'); ?></label>
<tr><td><select>
<?php foreach ($countryCodes as $code3 => $code2) : ?>
<option value="<?= $this->printHtml($code2); ?>"<?= $this->printHtml($code2 === $client->mainAddress->getCountry() ? ' selected' : ''); ?>><?= $this->printHtml($countries[$code3]); ?>
<?php endforeach; ?>
</select>
<tr><td><img id="iMap" style="width: 100%;" src="<?= UriFactory::build('phpOMS/Localization/Maps/svg/' . \strtolower($client->mainAddress->getCountry()) . '.svg'); ?>">
</table>
</div>
</section>
<section class="portlet highlight-4">
@ -349,8 +370,38 @@ echo $this->getData('nav')->render();
</div>
</div>
</div>
<input type="radio" id="c-tab-2" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
<input type="radio" id="c-tab-3" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-3' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Address'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td><label for="iAType"><?= $this->getHtml('Type'); ?></label>
<tr><td><select id="iAType" name="atype">
<option><?= $this->getHtml('Default'); ?>
<option><?= $this->getHtml('Delivery'); ?>
<option><?= $this->getHtml('Invoice'); ?>
</select>
<tr><td><label for="iAddress"><?= $this->getHtml('Address'); ?></label>
<tr><td><input type="text" id="iAddress" name="address">
<tr><td><label for="iZip"><?= $this->getHtml('Zip'); ?></label>
<tr><td><input type="text" id="iZip" name="zip">
<tr><td><label for="iCountry"><?= $this->getHtml('Country'); ?></label>
<tr><td><input type="text" id="iCountry" name="country">
<tr><td><label for="iAInfo"><?= $this->getHtml('Info'); ?></label>
<tr><td><input type="text" id="iAInfo" name="ainfo">
<tr><td><span class="check"><input type="checkbox" id="iDefault" name="default" checked><label for="iDefault"><?= $this->getHtml('IsDefault'); ?></label></span>
<tr><td colspan="2"><input type="submit" value="<?= $this->getHtml('Add', '0', '0'); ?>">
</table>
</form>
</div>
</section>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
@ -384,30 +435,20 @@ echo $this->getData('nav')->render();
</div>
</div>
</div>
<input type="radio" id="c-tab-3" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-3' ? ' checked' : ''; ?>>
<input type="radio" id="c-tab-5" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-5' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Address'); ?></h1></header>
<header><h1><?= $this->getHtml('Payment'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td><label for="iAType"><?= $this->getHtml('Type'); ?></label>
<tr><td><select id="iAType" name="atype">
<option><?= $this->getHtml('Default'); ?>
<option><?= $this->getHtml('Delivery'); ?>
<option><?= $this->getHtml('Invoice'); ?>
<tr><td><label for="iACType"><?= $this->getHtml('Type'); ?></label>
<tr><td><select id="iACType" name="actype">
<option><?= $this->getHtml('Wire'); ?>
<option><?= $this->getHtml('Creditcard'); ?>
</select>
<tr><td><label for="iAddress"><?= $this->getHtml('Address'); ?></label>
<tr><td><input type="text" id="iAddress" name="address">
<tr><td><label for="iZip"><?= $this->getHtml('Zip'); ?></label>
<tr><td><input type="text" id="iZip" name="zip">
<tr><td><label for="iCountry"><?= $this->getHtml('Country'); ?></label>
<tr><td><input type="text" id="iCountry" name="country">
<tr><td><label for="iAInfo"><?= $this->getHtml('Info'); ?></label>
<tr><td><input type="text" id="iAInfo" name="ainfo">
<tr><td><span class="check"><input type="checkbox" id="iDefault" name="default" checked><label for="iDefault"><?= $this->getHtml('IsDefault'); ?></label></span>
<tr><td colspan="2"><input type="submit" value="<?= $this->getHtml('Add', '0', '0'); ?>">
</table>
</form>
@ -415,9 +456,7 @@ echo $this->getData('nav')->render();
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-4" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-4' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
@ -448,28 +487,6 @@ echo $this->getData('nav')->render();
</div>
</div>
</div>
<input type="radio" id="c-tab-5" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-5' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Payment'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td><label for="iACType"><?= $this->getHtml('Type'); ?></label>
<tr><td><select id="iACType" name="actype">
<option><?= $this->getHtml('Wire'); ?>
<option><?= $this->getHtml('Creditcard'); ?>
</select>
<tr><td colspan="2"><input type="submit" value="<?= $this->getHtml('Add', '0', '0'); ?>">
</table>
</form>
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-6" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-6' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
@ -546,6 +563,14 @@ echo $this->getData('nav')->render();
<div class="tab">
</div>
<input type="radio" id="c-tab-9" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-9' ? ' checked' : ''; ?>>
<div class="tab">
<?php include __DIR__ . '/client-profile-bills.tpl.php'; ?>
</div>
<input type="radio" id="c-tab-10" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-9' ? ' checked' : ''; ?>>
<div class="tab">
<?php include __DIR__ . '/client-profile-items.tpl.php'; ?>
</div>
<input type="radio" id="c-tab-11" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-10' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12">