mirror of
https://github.com/Karaka-Management/oms-SupplierManagement.git
synced 2026-01-11 17:28:41 +00:00
many fixes and expands and module expansions
This commit is contained in:
parent
39143096fe
commit
ac181da801
|
|
@ -82,6 +82,198 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"suppliermgmt_attr_type": {
|
||||
"name": "suppliermgmt_attr_type",
|
||||
"fields": {
|
||||
"suppliermgmt_attr_type_id": {
|
||||
"name": "suppliermgmt_attr_type_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"suppliermgmt_attr_type_name": {
|
||||
"name": "suppliermgmt_attr_type_name",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"suppliermgmt_attr_type_fields": {
|
||||
"name": "suppliermgmt_attr_type_fields",
|
||||
"type": "INT(11)",
|
||||
"null": false
|
||||
},
|
||||
"suppliermgmt_attr_type_custom": {
|
||||
"name": "suppliermgmt_attr_type_custom",
|
||||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
},
|
||||
"suppliermgmt_attr_type_required": {
|
||||
"description": "Every item must have this attribute type if set to true.",
|
||||
"name": "suppliermgmt_attr_type_required",
|
||||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
},
|
||||
"suppliermgmt_attr_type_pattern": {
|
||||
"description": "This is a regex validation pattern.",
|
||||
"name": "suppliermgmt_attr_type_pattern",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"suppliermgmt_attr_type_l11n": {
|
||||
"name": "suppliermgmt_attr_type_l11n",
|
||||
"fields": {
|
||||
"suppliermgmt_attr_type_l11n_id": {
|
||||
"name": "suppliermgmt_attr_type_l11n_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"suppliermgmt_attr_type_l11n_title": {
|
||||
"name": "suppliermgmt_attr_type_l11n_title",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"suppliermgmt_attr_type_l11n_type": {
|
||||
"name": "suppliermgmt_attr_type_l11n_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "suppliermgmt_attr_type",
|
||||
"foreignKey": "suppliermgmt_attr_type_id"
|
||||
},
|
||||
"suppliermgmt_attr_type_l11n_lang": {
|
||||
"name": "suppliermgmt_attr_type_l11n_lang",
|
||||
"type": "VARCHAR(2)",
|
||||
"null": false,
|
||||
"foreignTable": "language",
|
||||
"foreignKey": "language_639_1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"suppliermgmt_attr_value": {
|
||||
"name": "suppliermgmt_attr_value",
|
||||
"fields": {
|
||||
"suppliermgmt_attr_value_id": {
|
||||
"name": "suppliermgmt_attr_value_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"suppliermgmt_attr_value_default": {
|
||||
"name": "suppliermgmt_attr_value_default",
|
||||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
},
|
||||
"suppliermgmt_attr_value_type": {
|
||||
"name": "suppliermgmt_attr_value_type",
|
||||
"type": "INT(11)",
|
||||
"null": false
|
||||
},
|
||||
"suppliermgmt_attr_value_valueStr": {
|
||||
"name": "suppliermgmt_attr_value_valueStr",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"suppliermgmt_attr_value_valueInt": {
|
||||
"name": "suppliermgmt_attr_value_valueInt",
|
||||
"type": "INT(11)",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"suppliermgmt_attr_value_valueDec": {
|
||||
"name": "suppliermgmt_attr_value_valueDec",
|
||||
"type": "DECIMAL(19,5)",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"suppliermgmt_attr_value_valueDat": {
|
||||
"name": "suppliermgmt_attr_value_valueDat",
|
||||
"type": "DATETIME",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"suppliermgmt_attr_value_lang": {
|
||||
"name": "suppliermgmt_attr_value_lang",
|
||||
"type": "VARCHAR(2)",
|
||||
"null": true,
|
||||
"default": null,
|
||||
"foreignTable": "language",
|
||||
"foreignKey": "language_639_1"
|
||||
},
|
||||
"suppliermgmt_attr_value_country": {
|
||||
"name": "suppliermgmt_attr_value_country",
|
||||
"type": "VARCHAR(2)",
|
||||
"null": true,
|
||||
"default": null,
|
||||
"foreignTable": "country",
|
||||
"foreignKey": "country_code2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"suppliermgmt_supplier_attr_default": {
|
||||
"name": "suppliermgmt_supplier_attr_default",
|
||||
"fields": {
|
||||
"suppliermgmt_supplier_attr_default_id": {
|
||||
"name": "suppliermgmt_supplier_attr_default_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"suppliermgmt_supplier_attr_default_type": {
|
||||
"name": "suppliermgmt_supplier_attr_default_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "suppliermgmt_attr_type",
|
||||
"foreignKey": "suppliermgmt_attr_type_id"
|
||||
},
|
||||
"suppliermgmt_supplier_attr_default_value": {
|
||||
"name": "suppliermgmt_supplier_attr_default_value",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "suppliermgmt_attr_value",
|
||||
"foreignKey": "suppliermgmt_attr_value_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"suppliermgmt_supplier_attr": {
|
||||
"name": "suppliermgmt_supplier_attr",
|
||||
"fields": {
|
||||
"suppliermgmt_supplier_attr_id": {
|
||||
"name": "suppliermgmt_supplier_attr_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"suppliermgmt_supplier_attr_supplier": {
|
||||
"name": "suppliermgmt_supplier_attr_supplier",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "suppliermgmt_supplier",
|
||||
"foreignKey": "suppliermgmt_supplier_id"
|
||||
},
|
||||
"suppliermgmt_supplier_attr_type": {
|
||||
"name": "suppliermgmt_supplier_attr_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "suppliermgmt_attr_type",
|
||||
"foreignKey": "suppliermgmt_attr_type_id"
|
||||
},
|
||||
"suppliermgmt_supplier_attr_value": {
|
||||
"name": "suppliermgmt_supplier_attr_value",
|
||||
"type": "INT(11)",
|
||||
"null": true,
|
||||
"default": null,
|
||||
"foreignTable": "suppliermgmt_attr_value",
|
||||
"foreignKey": "suppliermgmt_attr_value_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"suppliermgmt_supplier_media": {
|
||||
"name": "suppliermgmt_supplier_media",
|
||||
"fields": {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,18 @@ use phpOMS\Message\NotificationLevel;
|
|||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Model\Message\FormValidation;
|
||||
use Modules\SupplierManagement\Models\SupplierAttribute;
|
||||
use Modules\SupplierManagement\Models\NullSupplierAttributeValue;
|
||||
use Modules\SupplierManagement\Models\SupplierAttributeTypeL11n;
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
use Modules\SupplierManagement\Models\SupplierAttributeType;
|
||||
use Modules\SupplierManagement\Models\SupplierAttributeValue;
|
||||
use Modules\SupplierManagement\Models\AttributeValueType;
|
||||
use Modules\SupplierManagement\Models\NullSupplierAttributeType;
|
||||
use Modules\SupplierManagement\Models\SupplierAttributeTypeMapper;
|
||||
use Modules\SupplierManagement\Models\SupplierAttributeTypeL11nMapper;
|
||||
use Modules\SupplierManagement\Models\SupplierAttributeValueMapper;
|
||||
use Modules\SupplierManagement\Models\SupplierAttributeMapper;
|
||||
|
||||
/**
|
||||
* SupplierManagement class.
|
||||
|
|
@ -153,7 +165,318 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Api method to create item files
|
||||
* Api method to create supplier attribute
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiSupplierAttributeCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateSupplierAttributeCreate($request))) {
|
||||
$response->set('attribute_create', new FormValidation($val));
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attribute = $this->createSupplierAttributeFromRequest($request);
|
||||
$this->createModel($request->header->account, $attribute, SupplierAttributeMapper::class, 'attribute', $request->getOrigin());
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute', 'Attribute successfully created', $attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create supplier attribute from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return SupplierAttribute
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createSupplierAttributeFromRequest(RequestAbstract $request) : SupplierAttribute
|
||||
{
|
||||
$attribute = new SupplierAttribute();
|
||||
$attribute->supplier = (int) $request->getData('supplier');
|
||||
$attribute->type = new NullSupplierAttributeType((int) $request->getData('type'));
|
||||
$attribute->value = new NullSupplierAttributeValue((int) $request->getData('value'));
|
||||
|
||||
return $attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate supplier attribute create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateSupplierAttributeCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['type'] = empty($request->getData('type')))
|
||||
|| ($val['value'] = empty($request->getData('value')))
|
||||
|| ($val['supplier'] = empty($request->getData('supplier')))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create supplier attribute l11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiSupplierAttributeTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateSupplierAttributeTypeL11nCreate($request))) {
|
||||
$response->set('attr_type_l11n_create', new FormValidation($val));
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attrL11n = $this->createSupplierAttributeTypeL11nFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrL11n, SupplierAttributeTypeL11nMapper::class, 'attr_type_l11n', $request->getOrigin());
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute type localization', 'Attribute type localization successfully created', $attrL11n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create supplier attribute l11n from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return SupplierAttributeTypeL11n
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createSupplierAttributeTypeL11nFromRequest(RequestAbstract $request) : SupplierAttributeTypeL11n
|
||||
{
|
||||
$attrL11n = new SupplierAttributeTypeL11n();
|
||||
$attrL11n->setType((int) ($request->getData('type') ?? 0));
|
||||
$attrL11n->setLanguage((string) (
|
||||
$request->getData('language') ?? $request->getLanguage()
|
||||
));
|
||||
$attrL11n->title = (string) ($request->getData('title') ?? '');
|
||||
|
||||
return $attrL11n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate supplier attribute l11n create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateSupplierAttributeTypeL11nCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['title'] = empty($request->getData('title')))
|
||||
|| ($val['type'] = empty($request->getData('type')))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create supplier attribute type
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiSupplierAttributeTypeCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateSupplierAttributeTypeCreate($request))) {
|
||||
$response->set('attr_type_create', new FormValidation($val));
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attrType = $this->createSupplierAttributeTypeFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrType, SupplierAttributeTypeMapper::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->createSupplierAttributeTypeL11nFromRequest($l11nRequest);
|
||||
$this->createModel($request->header->account, $l11nAttributeType, SupplierAttributeTypeL11nMapper::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 supplier attribute from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return SupplierAttributeType
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createSupplierAttributeTypeFromRequest(RequestAbstract $request) : SupplierAttributeType
|
||||
{
|
||||
$attrType = new SupplierAttributeType();
|
||||
$attrType->setL11n((string) ($request->getData('name') ?? ''));
|
||||
$attrType->setFields((int) ($request->getData('fields') ?? 0));
|
||||
$attrType->setCustom((bool) ($request->getData('custom') ?? false));
|
||||
|
||||
return $attrType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate supplier attribute create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateSupplierAttributeTypeCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['name'] = empty($request->getData('name')))
|
||||
|| ($val['title'] = empty($request->getData('title')))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create supplier attribute value
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiSupplierAttributeValueCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateSupplierAttributeValueCreate($request))) {
|
||||
$response->set('attr_value_create', new FormValidation($val));
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attrValue = $this->createSupplierAttributeValueFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrValue, SupplierAttributeValueMapper::class, 'attr_value', $request->getOrigin());
|
||||
|
||||
if ($attrValue->isDefault) {
|
||||
$this->createModelRelation(
|
||||
$request->header->account,
|
||||
(int) $request->getData('attributetype'),
|
||||
$attrValue->getId(),
|
||||
SupplierAttributeTypeMapper::class, 'defaults', '', $request->getOrigin()
|
||||
);
|
||||
}
|
||||
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute value', 'Attribute value successfully created', $attrValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create supplier attribute value from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return SupplierAttributeValue
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createSupplierAttributeValueFromRequest(RequestAbstract $request) : SupplierAttributeValue
|
||||
{
|
||||
$attrValue = new SupplierAttributeValue();
|
||||
|
||||
$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 supplier attribute value create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateSupplierAttributeValueCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['type'] = empty($request->getData('type')))
|
||||
|| ($val['value'] = empty($request->getData('value')))
|
||||
) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create supplier files
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
|
|
@ -199,7 +522,7 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Api method to create item files
|
||||
* Api method to create supplier files
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* SupplierManagement controller class.
|
||||
|
|
@ -53,7 +54,12 @@ 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::getAfterPivot(0, null, 25);
|
||||
$supplier = SupplierMapper
|
||||
::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('supplier', $supplier);
|
||||
|
||||
return $view;
|
||||
|
|
@ -103,7 +109,11 @@ 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'));
|
||||
$supplier = SupplierMapper
|
||||
::with('files', limit: 5, orderBy: 'createdAt', sortOrder: 'ASC')
|
||||
::with('notes', limit: 5, orderBy: 'id', sortOrder: 'ASC')
|
||||
::get((int) $request->getData('id'));
|
||||
|
||||
$view->setData('supplier', $supplier);
|
||||
|
||||
// stats
|
||||
|
|
|
|||
36
Models/AttributeValueType.php
Executable file
36
Models/AttributeValueType.php
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\SupplierManagement\Models;
|
||||
|
||||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
/**
|
||||
* Attribute value type enum.
|
||||
*
|
||||
* @package Modules\SupplierManagement\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;
|
||||
}
|
||||
38
Models/NullSupplierAttribute.php
Executable file
38
Models/NullSupplierAttribute.php
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\SupplierManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullSupplierAttribute extends SupplierAttribute
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
38
Models/NullSupplierAttributeType.php
Executable file
38
Models/NullSupplierAttributeType.php
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\SupplierManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullSupplierAttributeType extends SupplierAttributeType
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
38
Models/NullSupplierAttributeTypeL11n.php
Executable file
38
Models/NullSupplierAttributeTypeL11n.php
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\SupplierManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullSupplierAttributeTypeL11n extends SupplierAttributeTypeL11n
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
38
Models/NullSupplierAttributeValue.php
Executable file
38
Models/NullSupplierAttributeValue.php
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\SupplierManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullSupplierAttributeValue extends SupplierAttributeValue
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* Supplier class.
|
||||
|
|
@ -54,6 +55,14 @@ class Supplier
|
|||
|
||||
public Profile $profile;
|
||||
|
||||
/**
|
||||
* Attributes.
|
||||
*
|
||||
* @var int[]|SupplierAttribute[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $attributes = [];
|
||||
|
||||
/**
|
||||
* Files.
|
||||
*
|
||||
|
|
|
|||
88
Models/SupplierAttribute.php
Executable file
88
Models/SupplierAttribute.php
Executable file
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\SupplierManagement\Models;
|
||||
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
|
||||
/**
|
||||
* Supplier class.
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class SupplierAttribute implements \JsonSerializable, ArrayableInterface
|
||||
{
|
||||
/**
|
||||
* Id.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Supplier this attribute belongs to
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $supplier = 0;
|
||||
|
||||
/**
|
||||
* Attribute type the attribute belongs to
|
||||
*
|
||||
* @var SupplierAttributeType
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public SupplierAttributeType $type;
|
||||
|
||||
/**
|
||||
* Attribute value the attribute belongs to
|
||||
*
|
||||
* @var SupplierAttributeValue
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public SupplierAttributeValue $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();
|
||||
}
|
||||
}
|
||||
74
Models/SupplierAttributeMapper.php
Executable file
74
Models/SupplierAttributeMapper.php
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\SupplierManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Supplier mapper class.
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class SupplierAttributeMapper 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 = [
|
||||
'suppliermgmt_supplier_attr_id' => ['name' => 'suppliermgmt_supplier_attr_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'suppliermgmt_supplier_attr_supplier' => ['name' => 'suppliermgmt_supplier_attr_supplier', 'type' => 'int', 'internal' => 'supplier'],
|
||||
'suppliermgmt_supplier_attr_type' => ['name' => 'suppliermgmt_supplier_attr_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'suppliermgmt_supplier_attr_value' => ['name' => 'suppliermgmt_supplier_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' => SupplierAttributeTypeMapper::class,
|
||||
'external' => 'suppliermgmt_supplier_attr_type',
|
||||
],
|
||||
'value' => [
|
||||
'mapper' => SupplierAttributeValueMapper::class,
|
||||
'external' => 'suppliermgmt_supplier_attr_value',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'suppliermgmt_supplier_attr';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'suppliermgmt_supplier_attr_id';
|
||||
}
|
||||
180
Models/SupplierAttributeType.php
Executable file
180
Models/SupplierAttributeType.php
Executable file
|
|
@ -0,0 +1,180 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\SupplierManagement\Models;
|
||||
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Supplier Attribute Type class.
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class SupplierAttributeType 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 | SupplierAttributeTypeL11n
|
||||
*/
|
||||
protected string | SupplierAttributeTypeL11n $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|SupplierAttributeTypeL11n $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 SupplierAttributeTypeL11n) {
|
||||
$this->l11n = $l11n;
|
||||
} elseif ($this->l11n instanceof SupplierAttributeTypeL11n && \is_string($l11n)) {
|
||||
$this->l11n->title = $l11n;
|
||||
} elseif (\is_string($l11n)) {
|
||||
$this->l11n = new SupplierAttributeTypeL11n();
|
||||
$this->l11n->title = $l11n;
|
||||
$this->l11n->setLanguage($lang);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getL11n() : string
|
||||
{
|
||||
return $this->l11n instanceof SupplierAttributeTypeL11n ? $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();
|
||||
}
|
||||
}
|
||||
147
Models/SupplierAttributeTypeL11n.php
Executable file
147
Models/SupplierAttributeTypeL11n.php
Executable file
|
|
@ -0,0 +1,147 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\SupplierManagement\Models;
|
||||
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Supplier class.
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class SupplierAttributeTypeL11n implements \JsonSerializable, ArrayableInterface
|
||||
{
|
||||
/**
|
||||
* ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Supplier ID.
|
||||
*
|
||||
* @var int|SupplierAttributeType
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int |
|
||||
|
||||
SupplierAttributeType $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|SupplierAttributeType $type Attribute type
|
||||
* @param string $title Localized title
|
||||
* @param string $language Language
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int | SupplierAttributeType $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|SupplierAttributeType
|
||||
*
|
||||
* @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();
|
||||
}
|
||||
}
|
||||
57
Models/SupplierAttributeTypeL11nMapper.php
Executable file
57
Models/SupplierAttributeTypeL11nMapper.php
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\SupplierManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Supplier mapper class.
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class SupplierAttributeTypeL11nMapper 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 = [
|
||||
'suppliermgmt_attr_type_l11n_id' => ['name' => 'suppliermgmt_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'suppliermgmt_attr_type_l11n_title' => ['name' => 'suppliermgmt_attr_type_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
|
||||
'suppliermgmt_attr_type_l11n_type' => ['name' => 'suppliermgmt_attr_type_l11n_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'suppliermgmt_attr_type_l11n_lang' => ['name' => 'suppliermgmt_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'suppliermgmt_attr_type_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'suppliermgmt_attr_type_l11n_id';
|
||||
}
|
||||
83
Models/SupplierAttributeTypeMapper.php
Executable file
83
Models/SupplierAttributeTypeMapper.php
Executable file
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\SupplierManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Supplier mapper class.
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class SupplierAttributeTypeMapper 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 = [
|
||||
'suppliermgmt_attr_type_id' => ['name' => 'suppliermgmt_attr_type_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'suppliermgmt_attr_type_name' => ['name' => 'suppliermgmt_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
|
||||
'suppliermgmt_attr_type_fields' => ['name' => 'suppliermgmt_attr_type_fields', 'type' => 'int', 'internal' => 'fields'],
|
||||
'suppliermgmt_attr_type_custom' => ['name' => 'suppliermgmt_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'],
|
||||
'suppliermgmt_attr_type_pattern' => ['name' => 'suppliermgmt_attr_type_pattern', 'type' => 'bool', 'internal' => 'validationPattern'],
|
||||
'suppliermgmt_attr_type_required' => ['name' => 'suppliermgmt_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' => SupplierAttributeTypeL11nMapper::class,
|
||||
'table' => 'suppliermgmt_attr_type_l11n',
|
||||
'self' => 'suppliermgmt_attr_type_l11n_type',
|
||||
'column' => 'title',
|
||||
'conditional' => true,
|
||||
'external' => null,
|
||||
],
|
||||
'defaults' => [
|
||||
'mapper' => SupplierAttributeValueMapper::class,
|
||||
'table' => 'suppliermgmt_supplier_attr_default',
|
||||
'self' => 'suppliermgmt_supplier_attr_default_type',
|
||||
'external' => 'suppliermgmt_supplier_attr_default_value',
|
||||
'conditional' => false,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'suppliermgmt_attr_type';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'suppliermgmt_attr_type_id';
|
||||
}
|
||||
214
Models/SupplierAttributeValue.php
Executable file
214
Models/SupplierAttributeValue.php
Executable file
|
|
@ -0,0 +1,214 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\SupplierManagement\Models;
|
||||
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
use phpOMS\Localization\ISO3166TwoEnum;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Supplier attribute value class.
|
||||
*
|
||||
* The relation with the type/supplier is defined in the SupplierAttribute class.
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class SupplierAttributeValue 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();
|
||||
}
|
||||
}
|
||||
62
Models/SupplierAttributeValueMapper.php
Executable file
62
Models/SupplierAttributeValueMapper.php
Executable file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https: //orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\SupplierManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Supplier mapper class.
|
||||
*
|
||||
* @package Modules\SupplierManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https: //orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class SupplierAttributeValueMapper 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 = [
|
||||
'suppliermgmt_attr_value_id' => ['name' => 'suppliermgmt_attr_value_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'suppliermgmt_attr_value_default' => ['name' => 'suppliermgmt_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'],
|
||||
'suppliermgmt_attr_value_type' => ['name' => 'suppliermgmt_attr_value_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'suppliermgmt_attr_value_valueStr' => ['name' => 'suppliermgmt_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'],
|
||||
'suppliermgmt_attr_value_valueInt' => ['name' => 'suppliermgmt_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'],
|
||||
'suppliermgmt_attr_value_valueDec' => ['name' => 'suppliermgmt_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'],
|
||||
'suppliermgmt_attr_value_valueDat' => ['name' => 'suppliermgmt_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'],
|
||||
'suppliermgmt_attr_value_lang' => ['name' => 'suppliermgmt_attr_value_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
'suppliermgmt_attr_value_country' => ['name' => 'suppliermgmt_attr_value_country', 'type' => 'string', 'internal' => 'country'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'suppliermgmt_attr_value';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'suppliermgmt_attr_value_id';
|
||||
}
|
||||
|
|
@ -115,5 +115,12 @@ final class SupplierMapper extends DataMapperAbstract
|
|||
'external' => 'suppliermgmt_supplier_contactelement_dst',
|
||||
'self' => 'suppliermgmt_supplier_contactelement_src',
|
||||
],
|
||||
'attributes' => [
|
||||
'mapper' => SupplierAttributeMapper::class,
|
||||
'table' => 'suppliermgmt_supplier_attr',
|
||||
'self' => 'suppliermgmt_supplier_attr_supplier',
|
||||
'conditional' => true,
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user