mirror of
https://github.com/Karaka-Management/oms-ItemManagement.git
synced 2026-02-16 04:08:43 +00:00
correct datamapper self/external usage (invert)
This commit is contained in:
parent
dd7afdc98f
commit
1eafeaa9c5
17
Admin/Install/Media.install.json
Normal file
17
Admin/Install/Media.install.json
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "ItemManagement",
|
||||||
|
"virtualPath": "/Modules",
|
||||||
|
"user": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Articles",
|
||||||
|
"virtualPath": "/Modules/ItemManagement",
|
||||||
|
"user": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Images",
|
||||||
|
"virtualPath": "/Modules/ItemManagement/Articles",
|
||||||
|
"user": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
43
Admin/Install/Media.php
Normal file
43
Admin/Install/Media.php
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.4
|
||||||
|
*
|
||||||
|
* @package Modules\ItemManagement\Admin\Install
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Modules\ItemManagement\Admin\Install;
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\DatabasePool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Media class.
|
||||||
|
*
|
||||||
|
* @package Modules\ItemManagement\Admin\Install
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
class Media
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Install media providing
|
||||||
|
*
|
||||||
|
* @param string $path Module path
|
||||||
|
* @param DatabasePool $dbPool Database pool for database interaction
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static function install(string $path, DatabasePool $dbPool) : void
|
||||||
|
{
|
||||||
|
\Modules\Media\Admin\Installer::installExternal($dbPool, ['path' => __DIR__ . '/Media.install.json']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -234,23 +234,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"itemmgmt_item_media_type": {
|
|
||||||
"name": "itemmgmt_item_media_type",
|
|
||||||
"fields": {
|
|
||||||
"itemmgmt_item_media_type_id": {
|
|
||||||
"name": "itemmgmt_item_media_type_id",
|
|
||||||
"type": "INT",
|
|
||||||
"null": false,
|
|
||||||
"primary": true,
|
|
||||||
"autoincrement": true
|
|
||||||
},
|
|
||||||
"itemmgmt_item_media_type_title": {
|
|
||||||
"name": "itemmgmt_item_media_type_title",
|
|
||||||
"type": "VARCHAR(255)",
|
|
||||||
"null": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"itemmgmt_item_media": {
|
"itemmgmt_item_media": {
|
||||||
"name": "itemmgmt_item_media",
|
"name": "itemmgmt_item_media",
|
||||||
"fields": {
|
"fields": {
|
||||||
|
|
@ -261,13 +244,6 @@
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"autoincrement": true
|
"autoincrement": true
|
||||||
},
|
},
|
||||||
"itemmgmt_item_media_type": {
|
|
||||||
"name": "itemmgmt_item_media_type",
|
|
||||||
"type": "INT",
|
|
||||||
"null": false,
|
|
||||||
"foreignTable": "itemmgmt_item_media_type",
|
|
||||||
"foreignKey": "itemmgmt_item_media_type_id"
|
|
||||||
},
|
|
||||||
"itemmgmt_item_media_item": {
|
"itemmgmt_item_media_item": {
|
||||||
"name": "itemmgmt_item_media_item",
|
"name": "itemmgmt_item_media_item",
|
||||||
"type": "INT",
|
"type": "INT",
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\ItemManagement\Models;
|
namespace Modules\ItemManagement\Models;
|
||||||
|
|
||||||
|
use Modules\Media\Models\NullMedia;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account class.
|
* Account class.
|
||||||
*
|
*
|
||||||
|
|
@ -46,7 +48,7 @@ class Item
|
||||||
|
|
||||||
private int $type = 0;
|
private int $type = 0;
|
||||||
|
|
||||||
private $media = [];
|
private $files = [];
|
||||||
|
|
||||||
private $l11n = [];
|
private $l11n = [];
|
||||||
|
|
||||||
|
|
@ -179,4 +181,32 @@ class Item
|
||||||
|
|
||||||
return new NullItemL11n();
|
return new NullItemL11n();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addFile($media) : void
|
||||||
|
{
|
||||||
|
$this->files[] = $media;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFileByType(string $type)
|
||||||
|
{
|
||||||
|
foreach ($this->files as $file) {
|
||||||
|
if ($file->getType() === $type) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new NullMedia();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilesByType(string $type) : array
|
||||||
|
{
|
||||||
|
$files = [];
|
||||||
|
foreach ($this->files as $file) {
|
||||||
|
if ($file->getType() === $type) {
|
||||||
|
$files[] = $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $files;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,11 +51,11 @@ final class ItemAttributeMapper extends DataMapperAbstract
|
||||||
protected static array $ownsOne = [
|
protected static array $ownsOne = [
|
||||||
'type' => [
|
'type' => [
|
||||||
'mapper' => ItemAttributeTypeMapper::class,
|
'mapper' => ItemAttributeTypeMapper::class,
|
||||||
'self' => 'itemmgmt_item_l11n_typeref',
|
'external' => 'itemmgmt_item_l11n_typeref',
|
||||||
],
|
],
|
||||||
'value' => [
|
'value' => [
|
||||||
'mapper' => ItemAttributeValueMapper::class,
|
'mapper' => ItemAttributeValueMapper::class,
|
||||||
'self' => 'itemmgmt_item_l11n_typeref',
|
'external' => 'itemmgmt_item_l11n_typeref',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ final class ItemAttributeTypeL11nMapper extends DataMapperAbstract
|
||||||
protected static array $ownsOne = [
|
protected static array $ownsOne = [
|
||||||
'language' => [
|
'language' => [
|
||||||
'mapper' => LanguageMapper::class,
|
'mapper' => LanguageMapper::class,
|
||||||
'self' => 'itemmgmt_attr_type_l11n_lang',
|
'external' => 'itemmgmt_attr_type_l11n_lang',
|
||||||
'by' => 'code2',
|
'by' => 'code2',
|
||||||
'column' => 'code2',
|
'column' => 'code2',
|
||||||
'conditional' => true,
|
'conditional' => true,
|
||||||
|
|
|
||||||
|
|
@ -52,10 +52,10 @@ final class ItemAttributeTypeMapper extends DataMapperAbstract
|
||||||
'l11n' => [
|
'l11n' => [
|
||||||
'mapper' => ItemAttributeTypeL11nMapper::class,
|
'mapper' => ItemAttributeTypeL11nMapper::class,
|
||||||
'table' => 'itemmgmt_attr_type_l11n',
|
'table' => 'itemmgmt_attr_type_l11n',
|
||||||
'external' => 'itemmgmt_attr_type_l11n_type',
|
'self' => 'itemmgmt_attr_type_l11n_type',
|
||||||
'column' => 'title',
|
'column' => 'title',
|
||||||
'conditional' => true,
|
'conditional' => true,
|
||||||
'self' => null,
|
'external' => null,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,14 +57,14 @@ final class ItemAttributeValueMapper extends DataMapperAbstract
|
||||||
protected static array $ownsOne = [
|
protected static array $ownsOne = [
|
||||||
'language' => [
|
'language' => [
|
||||||
'mapper' => LanguageMapper::class,
|
'mapper' => LanguageMapper::class,
|
||||||
'self' => 'itemmgmt_attr_value_lang',
|
'external' => 'itemmgmt_attr_value_lang',
|
||||||
'by' => 'code2',
|
'by' => 'code2',
|
||||||
'column' => 'code2',
|
'column' => 'code2',
|
||||||
'conditional' => true,
|
'conditional' => true,
|
||||||
],
|
],
|
||||||
'country' => [
|
'country' => [
|
||||||
'mapper' => CountryMapper::class,
|
'mapper' => CountryMapper::class,
|
||||||
'self' => 'itemmgmt_attr_value_country',
|
'external' => 'itemmgmt_attr_value_country',
|
||||||
'by' => 'code2',
|
'by' => 'code2',
|
||||||
'column' => 'code2',
|
'column' => 'code2',
|
||||||
'conditional' => true,
|
'conditional' => true,
|
||||||
|
|
|
||||||
|
|
@ -52,14 +52,14 @@ final class ItemL11nMapper extends DataMapperAbstract
|
||||||
protected static array $ownsOne = [
|
protected static array $ownsOne = [
|
||||||
'language' => [
|
'language' => [
|
||||||
'mapper' => LanguageMapper::class,
|
'mapper' => LanguageMapper::class,
|
||||||
'self' => 'itemmgmt_item_l11n_lang',
|
'external' => 'itemmgmt_item_l11n_lang',
|
||||||
'by' => 'code2',
|
'by' => 'code2',
|
||||||
'column' => 'code2',
|
'column' => 'code2',
|
||||||
'conditional' => true,
|
'conditional' => true,
|
||||||
],
|
],
|
||||||
'type' => [
|
'type' => [
|
||||||
'mapper' => ItemL11nTypeMapper::class,
|
'mapper' => ItemL11nTypeMapper::class,
|
||||||
'self' => 'itemmgmt_item_l11n_typeref',
|
'external' => 'itemmgmt_item_l11n_typeref',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,25 +66,25 @@ final class ItemMapper extends DataMapperAbstract
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected static array $hasMany = [
|
protected static array $hasMany = [
|
||||||
// 'media' => [
|
'files' => [
|
||||||
// 'mapper' => MediaMapper::class, /* mapper of the related object */
|
'mapper' => MediaMapper::class, /* mapper of the related object */
|
||||||
// 'table' => 'itemmgmt_item_media', /* table of the related object, null if no relation table is used (many->1) */
|
'table' => 'itemmgmt_item_media', /* table of the related object, null if no relation table is used (many->1) */
|
||||||
// 'external' => 'itemmgmt_item_media_dst',
|
'external' => 'itemmgmt_item_media_media',
|
||||||
// 'self' => 'itemmgmt_item_media_src',
|
'self' => 'itemmgmt_item_media_item',
|
||||||
// ],
|
],
|
||||||
'l11n' => [
|
'l11n' => [
|
||||||
'mapper' => ItemL11nMapper::class,
|
'mapper' => ItemL11nMapper::class,
|
||||||
'table' => 'itemmgmt_item_l11n',
|
'table' => 'itemmgmt_item_l11n',
|
||||||
'external' => 'itemmgmt_item_l11n_item',
|
'self' => 'itemmgmt_item_l11n_item',
|
||||||
'conditional' => true,
|
'conditional' => true,
|
||||||
'self' => null,
|
'external' => null,
|
||||||
],
|
],
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'mapper' => ItemAttributeMapper::class,
|
'mapper' => ItemAttributeMapper::class,
|
||||||
'table' => 'itemmgmt_item_attr',
|
'table' => 'itemmgmt_item_attr',
|
||||||
'external' => 'itemmgmt_item_attr_item',
|
'self' => 'itemmgmt_item_attr_item',
|
||||||
'conditional' => true,
|
'conditional' => true,
|
||||||
'self' => null,
|
'external' => null,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use phpOMS\Uri\UriFactory;
|
use phpOMS\Uri\UriFactory;
|
||||||
|
use Modules\Media\Models\NullMedia;
|
||||||
|
|
||||||
/** @var \phpOMS\Views\View $this */
|
/** @var \phpOMS\Views\View $this */
|
||||||
$items = $this->getData('items');
|
$items = $this->getData('items');
|
||||||
|
|
@ -26,6 +27,7 @@ echo $this->getData('nav')->render(); ?>
|
||||||
<table id="iSalesItemList" class="default">
|
<table id="iSalesItemList" class="default">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><?= $this->getHtml('ID', '0', '0'); ?>
|
||||||
<td><?= $this->getHtml('ID', '0', '0'); ?>
|
<td><?= $this->getHtml('ID', '0', '0'); ?>
|
||||||
<input id="itemList-r1-asc" name="itemList-sort" type="radio"><label for="itemList-r1-asc"><i class="sort-asc fa fa-chevron-up"></i></label>
|
<input id="itemList-r1-asc" name="itemList-sort" type="radio"><label for="itemList-r1-asc"><i class="sort-asc fa fa-chevron-up"></i></label>
|
||||||
<input id="itemList-r1-desc" name="itemList-sort" type="radio"><label for="itemList-r1-desc"><i class="sort-desc fa fa-chevron-down"></i></label>
|
<input id="itemList-r1-desc" name="itemList-sort" type="radio"><label for="itemList-r1-desc"><i class="sort-desc fa fa-chevron-down"></i></label>
|
||||||
|
|
@ -52,8 +54,14 @@ echo $this->getData('nav')->render(); ?>
|
||||||
<input id="itemList-r8-desc" name="itemList-sort" type="radio"><label for="itemList-r8-desc"><i class="sort-desc fa fa-chevron-down"></i></label>
|
<input id="itemList-r8-desc" name="itemList-sort" type="radio"><label for="itemList-r8-desc"><i class="sort-desc fa fa-chevron-down"></i></label>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php $count = 0; foreach ($items as $key => $value) : ++$count;
|
<?php $count = 0; foreach ($items as $key => $value) : ++$count;
|
||||||
$url = UriFactory::build('{/prefix}sales/item/profile?{?}&id=' . $value->getId()); ?>
|
$url = UriFactory::build('{/prefix}sales/item/profile?{?}&id=' . $value->getId());
|
||||||
|
$image = $value->getFileByType('backend_image');
|
||||||
|
?>
|
||||||
<tr data-href="<?= $url; ?>">
|
<tr data-href="<?= $url; ?>">
|
||||||
|
<td><a href="<?= $url; ?>"><img width="30" loading="lazy" class="item-image"
|
||||||
|
src="<?= $image instanceof NullMedia ?
|
||||||
|
UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) .'.png') :
|
||||||
|
UriFactory::build('{/prefix}' . $image->getPath()); ?>"></a>
|
||||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getNumber()); ?></a>
|
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getNumber()); ?></a>
|
||||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getL11n('name1')->getDescription()); ?></a>
|
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getL11n('name1')->getDescription()); ?></a>
|
||||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getL11n('name2')->getDescription()); ?></a>
|
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getL11n('name2')->getDescription()); ?></a>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user