make id public, organigram impl. media password/encryption, settings bug fix, Money->FloatInt change, ...

This commit is contained in:
Dennis Eichhorn 2023-05-06 11:42:06 +00:00
parent a7bf9066ab
commit 095369dfec
16 changed files with 204 additions and 36 deletions

View File

@ -379,6 +379,30 @@
}
}
},
"suppliermgmt_supplier_account": {
"name": "suppliermgmt_supplier_account",
"fields": {
"suppliermgmt_supplier_account_id": {
"name": "suppliermgmt_supplier_account_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"suppliermgmt_supplier_account_account": {
"name": "suppliermgmt_supplier_account_account",
"type": "VARCHAR(50)",
"null": false
},
"suppliermgmt_supplier_account_supplier": {
"name": "suppliermgmt_supplier_account_supplier",
"type": "INT(11)",
"null": false,
"foreignTable": "suppliermgmt_supplier",
"foreignKey": "suppliermgmt_supplier_id"
}
}
},
"suppliermgmt_supplier_media": {
"name": "suppliermgmt_supplier_media",
"fields": {

View File

@ -136,7 +136,7 @@ final class Installer extends InstallerAbstract
$request->setData('title', \reset($attribute['l11n']));
$request->setData('language', \array_keys($attribute['l11n'])[0] ?? 'en');
$request->setData('is_required', $attribute['is_required'] ?? false);
$request->setData('is_custom_allowed', $attribute['is_custom_allowed'] ?? false);
$request->setData('custom', $attribute['is_custom_allowed'] ?? false);
$request->setData('validation_pattern', $attribute['validation_pattern'] ?? '');
$request->setData('datatype', (int) $attribute['value_type']);

View File

@ -505,7 +505,7 @@ final class ApiController extends Controller
$this->createModelRelation(
$request->header->account,
(int) $request->getData('type'),
$attrValue->getId(),
$attrValue->id,
SupplierAttributeTypeMapper::class, 'defaults', '', $request->getOrigin()
);
}
@ -668,7 +668,7 @@ final class ApiController extends Controller
foreach ($uploaded as $file) {
$this->createModelRelation(
$request->header->account,
$file->getId(),
$file->id,
$request->getDataInt('type'),
MediaMapper::class,
'types',
@ -681,7 +681,7 @@ final class ApiController extends Controller
$this->createModelRelation(
$request->header->account,
(int) $request->getData('supplier'),
\reset($uploaded)->getId(),
\reset($uploaded)->id,
SupplierMapper::class, 'files', '', $request->getOrigin()
);
@ -715,7 +715,7 @@ final class ApiController extends Controller
$this->createModelRelation(
$request->header->account,
$request->getData('id'),
$model->getId(),
$model->id,
SupplierMapper::class,
'notes',
'',

View File

@ -15,6 +15,7 @@ declare(strict_types=1);
namespace Modules\SupplierManagement\Controller;
use Modules\Billing\Models\PurchaseBillMapper;
use Modules\SupplierManagement\Models\SupplierAttributeTypeL11nMapper;
use Modules\SupplierManagement\Models\SupplierAttributeTypeMapper;
use Modules\SupplierManagement\Models\SupplierAttributeValueMapper;
use Modules\SupplierManagement\Models\SupplierMapper;
@ -50,7 +51,7 @@ final class BackendController extends Controller
* @since 1.0.0
* @codeCoverageIgnore
*/
public function SupplierManagementAttributeTypeList(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface
public function viewSupplierManagementAttributeTypeList(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/SupplierManagement/Theme/Backend/attribute-type-list');
@ -79,7 +80,7 @@ final class BackendController extends Controller
* @since 1.0.0
* @codeCoverageIgnore
*/
public function SupplierManagementAttributeValues(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface
public function viewSupplierManagementAttributeValues(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/SupplierManagement/Theme/Backend/attribute-value-list');
@ -108,7 +109,7 @@ final class BackendController extends Controller
* @since 1.0.0
* @codeCoverageIgnore
*/
public function SupplierManagementAttributeType(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface
public function viewSupplierManagementAttributeType(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/SupplierManagement/Theme/Backend/attribute-type');
@ -121,7 +122,12 @@ final class BackendController extends Controller
->where('l11n/language', $response->getLanguage())
->execute();
$l11ns = SupplierAttributeTypeL11nMapper::getAll()
->where('ref', $attribute->id)
->execute();
$view->addData('attribute', $attribute);
$view->addData('l11ns', $l11ns);
return $view;
}
@ -214,11 +220,11 @@ final class BackendController extends Controller
// stats
if ($this->app->moduleManager->isActive('Billing')) {
$ytd = PurchaseBillMapper::getPurchaseBySupplierId($supplier->getId(), new SmartDateTime('Y-01-01'), new SmartDateTime('now'));
$mtd = PurchaseBillMapper::getPurchaseBySupplierId($supplier->getId(), new SmartDateTime('Y-m-01'), new SmartDateTime('now'));
$lastOrder = PurchaseBillMapper::getLastOrderDateBySupplierId($supplier->getId());
$newestInvoices = PurchaseBillMapper::getAll()->with('supplier')->where('supplier', $supplier->getId())->sort('id', OrderType::DESC)->limit(5)->execute();
$monthlyPurchaseCosts = PurchaseBillMapper::getSupplierMonthlyPurchaseCosts($supplier->getId(), (new SmartDateTime('now'))->createModify(-1), new SmartDateTime('now'));
$ytd = PurchaseBillMapper::getPurchaseBySupplierId($supplier->id, new SmartDateTime('Y-01-01'), new SmartDateTime('now'));
$mtd = PurchaseBillMapper::getPurchaseBySupplierId($supplier->id, new SmartDateTime('Y-m-01'), new SmartDateTime('now'));
$lastOrder = PurchaseBillMapper::getLastOrderDateBySupplierId($supplier->id);
$newestInvoices = PurchaseBillMapper::getAll()->with('supplier')->where('supplier', $supplier->id)->sort('id', OrderType::DESC)->limit(5)->execute();
$monthlyPurchaseCosts = PurchaseBillMapper::getSupplierMonthlyPurchaseCosts($supplier->id, (new SmartDateTime('now'))->createModify(-1), new SmartDateTime('now'));
} else {
$ytd = new Money();
$mtd = new Money();

View File

@ -40,15 +40,15 @@ class Supplier
* @var int
* @since 1.0.0
*/
protected int $id = 0;
public int $id = 0;
public string $number = '';
public string $numberReverse = '';
private int $status = SupplierStatus::ACTIVE;
public int $status = SupplierStatus::ACTIVE;
private int $type = 0;
public int $type = 0;
public string $info = '';

View File

@ -32,7 +32,7 @@ class SupplierL11n implements \JsonSerializable
* @var int
* @since 1.0.0
*/
protected int $id = 0;
public int $id = 0;
/**
* Supplier ID.

View File

@ -30,7 +30,7 @@ class SupplierL11nType implements \JsonSerializable
* @var int
* @since 1.0.0
*/
protected int $id = 0;
public int $id = 0;
/**
* Identifier for the l11n type.

View File

@ -13,6 +13,8 @@
declare(strict_types=1);
return ['SupplierManagement' => [
'AttributeTypes' => 'Attribute Types',
'Attribute' => 'Attribute',
'Accounting' => 'Accounting',
'Addition' => 'Addition',
'Address' => 'Address',

View File

@ -0,0 +1,71 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\ItemManagement
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use phpOMS\Uri\UriFactory;
/** @var \phpOMS\Views\View $this */
$attributes = $this->getData('attributes');
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('AttributeTypes'); ?><i class="fa fa-download floatRight download btn"></i></div>
<div class="slider">
<table id="iAttributeTypeList" class="default sticky">
<thead>
<tr>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<label for="iAttributeTypeList-sort-1">
<input type="radio" name="iAttributeTypeList-sort" id="iAttributeTypeList-sort-1">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iAttributeTypeList-sort-2">
<input type="radio" name="iAttributeTypeList-sort" id="iAttributeTypeList-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="iAttributeTypeList-sort-2">
<input type="radio" name="iAttributeTypeList-sort" id="iAttributeTypeList-sort-2">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iAttributeTypeList-sort-3">
<input type="radio" name="iAttributeTypeList-sort" id="iAttributeTypeList-sort-3">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<tbody>
<?php
$count = 0;
foreach ($attributes as $key => $value) : ++$count;
$url = UriFactory::build('{/base}/purchase/supplier/attribute/type?{?}&id=' . $value->id);
?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $value->id; ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->getL11n()); ?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="2" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</section>
</div>
</div>

View File

@ -0,0 +1,65 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\Tasks
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use phpOMS\Localization\ISO639Enum;
$attribute = $this->getData('attribute');
$l11ns = $this->getData('l11ns');
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-md-6 col-xs-12">
<section id="task" class="portlet">
<div class="portlet-head"><?= $this->getHtml('Attribute'); ?></div>
<div class="portlet-body">
<div class="form-group">
<label for="iId"><?= $this->getHtml('ID'); ?></label>
<input type="text" value="<?= $this->printHtml((string) $attribute->id); ?>" disabled>
</div>
<div class="form-group">
<label for="iName"><?= $this->getHtml('Name'); ?></label>
<input type="text" value="<?= $this->printHtml($attribute->name); ?>" disabled>
</div>
</div>
</section>
</div>
<div class="col-xs-12 col-md-6">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Language', '0', '0'); ?><i class="fa fa-download floatRight download btn"></i></div>
<table class="default">
<thead>
<tr>
<td>
<td>
<td><?= $this->getHtml('Language', '0', '0'); ?>
<td class="wf-100"><?= $this->getHtml('Title'); ?>
<tbody>
<?php $c = 0; foreach ($l11ns as $key => $value) : ++$c; ?>
<tr>
<td><a href="#"><i class="fa fa-times"></i></a>
<td><a href="#"><i class="fa fa-cogs"></i></a>
<td><?= ISO639Enum::getByName('_' . \strtoupper($value->getLanguage())); ?>
<td><?= $value->content; ?>
<?php endforeach; ?>
<?php if ($c === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -103,11 +103,11 @@ echo $this->getData('nav')->render(); ?>
</label>
<tbody>
<?php $count = 0; foreach ($suppliers as $key => $value) : ++$count;
$url = UriFactory::build('{/base}/purchase/supplier/profile?{?}&id=' . $value->getId());
$url = UriFactory::build('{/base}/purchase/supplier/profile?{?}&id=' . $value->id);
$image = $value->getFileByTypeName('supplier_profile_image'); ?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><img alt="<?= $this->getHtml('IMG_alt_supplier'); ?>" width="30" loading="lazy" class="item-image"
src="<?= $image instanceof NullMedia ?
src="<?= $image->id === 0 ?
UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) .'.png') :
UriFactory::build('{/base}/' . $image->getPath()); ?>"></a>
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->number); ?></a>

View File

@ -239,7 +239,7 @@ echo $this->getData('nav')->render();
<td><?= $this->getHtml('CreatedAt'); ?>
<tbody>
<?php foreach ($notes as $note) :
$url = UriFactory::build('{/base}/editor/single?{?}&id=' . $note->getId());
$url = UriFactory::build('{/base}/editor/single?{?}&id=' . $note->id);
?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $note->title; ?></a>
@ -262,7 +262,7 @@ echo $this->getData('nav')->render();
<td><?= $this->getHtml('CreatedAt'); ?>
<tbody>
<?php foreach ($files as $file) :
$url = UriFactory::build('{/base}/media/single?{?}&id=' . $file->getId());
$url = UriFactory::build('{/base}/media/single?{?}&id=' . $file->id);
?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $file->name; ?></a>
@ -292,7 +292,7 @@ echo $this->getData('nav')->render();
<?php
/** @var \Modules\Billing\Models\Bill $invoice */
foreach ($newestInvoices as $invoice) :
$url = UriFactory::build('{/base}/purchase/bill?{?}&id=' . $invoice->getId());
$url = UriFactory::build('{/base}/purchase/bill?{?}&id=' . $invoice->id);
?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $invoice->getNumber(); ?></a>

View File

@ -38,7 +38,7 @@ trait ApiControllerAttributeTrait
$request->setData('language', ISO639x1Enum::_EN);
$this->module->apiSupplierAttributeTypeCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->getId());
self::assertGreaterThan(0, $response->get('')['response']->id);
}
/**
@ -56,7 +56,7 @@ trait ApiControllerAttributeTrait
$request->setData('language', ISO639x1Enum::_DE);
$this->module->apiSupplierAttributeTypeL11nCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->getId());
self::assertGreaterThan(0, $response->get('')['response']->id);
}
/**
@ -76,7 +76,7 @@ trait ApiControllerAttributeTrait
$request->setData('country', ISO3166TwoEnum::_DEU);
$this->module->apiSupplierAttributeValueCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->getId());
self::assertGreaterThan(0, $response->get('')['response']->id);
}
/**
@ -95,7 +95,7 @@ trait ApiControllerAttributeTrait
$request->setData('country', ISO3166TwoEnum::_DEU);
$this->module->apiSupplierAttributeValueCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->getId());
self::assertGreaterThan(0, $response->get('')['response']->id);
}
/**
@ -114,7 +114,7 @@ trait ApiControllerAttributeTrait
$request->setData('country', ISO3166TwoEnum::_DEU);
$this->module->apiSupplierAttributeValueCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->getId());
self::assertGreaterThan(0, $response->get('')['response']->id);
}
/**
@ -133,7 +133,7 @@ trait ApiControllerAttributeTrait
$request->setData('country', ISO3166TwoEnum::_DEU);
$this->module->apiSupplierAttributeValueCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->getId());
self::assertGreaterThan(0, $response->get('')['response']->id);
}
/**
@ -151,7 +151,7 @@ trait ApiControllerAttributeTrait
$request->setData('type', '1');
$this->module->apiSupplierAttributeCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->getId());
self::assertGreaterThan(0, $response->get('')['response']->id);
}
/**

View File

@ -56,7 +56,7 @@ trait ApiControllerSupplierTrait
$request->setData('country', ISO3166TwoEnum::_USA);
$this->module->apiSupplierCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->getId());
self::assertGreaterThan(0, $response->get('')['response']->id);
}
/**
@ -103,7 +103,7 @@ trait ApiControllerSupplierTrait
$this->module->apiFileCreate($request, $response);
$file = $response->get('')['response'];
self::assertGreaterThan(0, \reset($file)->getId());
self::assertGreaterThan(0, \reset($file)->id);
}
/**
@ -133,7 +133,7 @@ trait ApiControllerSupplierTrait
$this->module->apiFileCreate($request, $response);
$file = $response->get('')['response'];
self::assertGreaterThan(0, \reset($file)->getId());
self::assertGreaterThan(0, \reset($file)->id);
}
/**
@ -154,7 +154,7 @@ trait ApiControllerSupplierTrait
$request->setData('plain', \preg_replace('/^.+\n/', '', $MARKDOWN));
$this->module->apiNoteCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->getId());
self::assertGreaterThan(0, $response->get('')['response']->id);
}
/**

View File

@ -37,6 +37,6 @@ final class NullSupplierTest extends \PHPUnit\Framework\TestCase
public function testId() : void
{
$null = new NullSupplier(2);
self::assertEquals(2, $null->getId());
self::assertEquals(2, $null->id);
}
}

View File

@ -41,7 +41,7 @@ final class SupplierTest extends \PHPUnit\Framework\TestCase
*/
public function testDefault() : void
{
self::assertEquals(0, $this->supplier->getId());
self::assertEquals(0, $this->supplier->id);
self::assertEquals('', $this->supplier->number);
self::assertEquals('', $this->supplier->numberReverse);
self::assertEquals('', $this->supplier->info);