Test fixes
Some checks failed
Image optimization / general_image_workflow (push) Has been cancelled
CI / general_module_workflow_php (push) Has been cancelled
CI / general_module_workflow_js (push) Has been cancelled

This commit is contained in:
Dennis Eichhorn 2024-05-16 02:14:54 +00:00
parent dd5e2e73e0
commit af73bc7d6c
15 changed files with 138 additions and 135 deletions

View File

@ -14,14 +14,7 @@ declare(strict_types=1);
namespace Modules\Customs\Admin;
use Modules\Admin\Models\NullAccount;
use phpOMS\Application\ApplicationAbstract;
use phpOMS\Config\SettingsInterface;
use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Module\InstallerAbstract;
use phpOMS\Module\ModuleInfo;
use phpOMS\System\File\PathException;
/**
* Installer class.
@ -40,12 +33,4 @@ final class Installer extends InstallerAbstract
* @since 1.0.0
*/
public const PATH = __DIR__;
/**
* {@inheritdoc}
*/
public static function install(ApplicationAbstract $app, ModuleInfo $info, SettingsInterface $cfgHandler) : void
{
parent::install($app, $info, $cfgHandler);
}
}

View File

@ -12,10 +12,5 @@
*/
declare(strict_types=1);
use Modules\Dashboard\Controller\ApiController;
use Modules\Dashboard\Models\PermissionCategory;
use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb;
return [
];

View File

@ -14,10 +14,6 @@ declare(strict_types=1);
namespace Modules\Customs\Controller;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
/**
* Api controller for the dashboard module.
*

View File

@ -78,18 +78,18 @@ final class BackendController extends Controller
}
$con = new \phpOMS\DataStorage\Database\Connection\SQLiteConnection([
'db' => 'sqlite',
'database' => __DIR__ . '/../Data/customs.sqlite'
'db' => 'sqlite',
'database' => __DIR__ . '/../Data/customs.sqlite',
]);
$con->connect();
$query = new Builder($con);
$nameString = \str_replace(['.', ';', ',', '-'], ' ', $request->getDataString('name') ?? '');
$names = \explode(' ', $nameString);
$nameString = \str_replace(['.', ';', ',', '-'], ' ', $request->getDataString('name') ?? '');
$names = \explode(' ', $nameString);
$fileSearchArray = $names;
$name = '';
$name = '';
// US SDN and CONS
foreach ($names as $idx => $n) {
@ -140,7 +140,7 @@ final class BackendController extends Controller
LIMIT 100;
SQL;
$view->data['sanctions'] = \array_merge($view->data['sanctions'], $query->raw($sql)->execute()->fetchAll());
$view->data['sanctions'] = \array_merge($view->data['sanctions'], $query->raw($sql)->execute()?->fetchAll() ?? []);
$sql = <<<SQL
SELECT sanction_us_cons.Ent_num,
@ -158,7 +158,7 @@ final class BackendController extends Controller
LIMIT 100;
SQL;
$view->data['sanctions'] = \array_merge($view->data['sanctions'], $query->raw($sql)->execute()->fetchAll());
$view->data['sanctions'] = \array_merge($view->data['sanctions'], $query->raw($sql)->execute()?->fetchAll() ?? []);
// EU Consolidated
$name = '';
@ -246,7 +246,7 @@ final class BackendController extends Controller
LIMIT 500;
SQL;
$view->data['sanctions'] = \array_merge($view->data['sanctions'], $query->raw($sql)->execute()->fetchAll());
$view->data['sanctions'] = \array_merge($view->data['sanctions'], $query->raw($sql)->execute()?->fetchAll() ?? []);
$con->close();
@ -254,7 +254,7 @@ final class BackendController extends Controller
$positions = SearchUtils::findInFile(__DIR__ . '/../Data/Sanctions/EU/CELEX 32002R0881 EN TXT.html', $fileSearchArray);
$lex_881_2002 = [];
$hashResults = [];
$hashResults = [];
foreach ($positions as $position) {
if ($position['distance'] > 500) {
continue;
@ -272,11 +272,11 @@ final class BackendController extends Controller
continue;
}
$hashResults[] = $hash;
$hashResults[] = $hash;
$lex_881_2002[] = [
'sanction_db' => 'EU_881/2002',
'Ent_num' => 'EU_881/2002',
'parsed' => $sanction,
'Ent_num' => 'EU_881/2002',
'parsed' => $sanction,
];
}
@ -286,7 +286,7 @@ final class BackendController extends Controller
$positions = SearchUtils::findInFile(__DIR__ . '/../Data/Sanctions/EU/CELEX 32011R0753 EN TXT.html', $fileSearchArray);
$lex_753_2011 = [];
$hashResults = [];
$hashResults = [];
foreach ($positions as $position) {
if ($position['distance'] > 500) {
continue;
@ -304,11 +304,11 @@ final class BackendController extends Controller
continue;
}
$hashResults[] = $hash;
$hashResults[] = $hash;
$lex_753_2011[] = [
'sanction_db' => 'EU_753/2011',
'Ent_num' => 'EU_753/2011',
'parsed' => $sanction,
'Ent_num' => 'EU_753/2011',
'parsed' => $sanction,
];
}
@ -318,7 +318,7 @@ final class BackendController extends Controller
$positions = SearchUtils::findInFile(__DIR__ . '/../Data/Sanctions/EU/CELEX 32011R0753 EN TXT.html', $fileSearchArray);
$lex_2024_385 = [];
$hashResults = [];
$hashResults = [];
foreach ($positions as $position) {
if ($position['distance'] > 500) {
continue;
@ -336,11 +336,11 @@ final class BackendController extends Controller
continue;
}
$hashResults[] = $hash;
$hashResults[] = $hash;
$lex_2024_385[] = [
'sanction_db' => 'EU_2024/385',
'Ent_num' => 'EU_2024/385',
'parsed' => $sanction,
'Ent_num' => 'EU_2024/385',
'parsed' => $sanction,
];
}
@ -349,20 +349,35 @@ final class BackendController extends Controller
return $view;
}
/**
* Create HS code view
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return RenderableInterface
*
* @api
*
* @since 1.0.0
*/
public function viewHSCodeView(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Customs/Theme/Backend/hscode-view');
$original = $request->getDataString('id') ?? '';
if (!$request->hasData('id')
|| \preg_match('/^[0-9 ]+$/', $original = $request->getDataString('id')) !== 1
|| \preg_match('/^[0-9 ]+$/', $original) !== 1
) {
return $view;
}
$con = new \phpOMS\DataStorage\Database\Connection\SQLiteConnection([
'db' => 'sqlite',
'database' => __DIR__ . '/../Data/customs.sqlite'
'db' => 'sqlite',
'database' => __DIR__ . '/../Data/customs.sqlite',
]);
$con->connect();
@ -395,7 +410,7 @@ final class BackendController extends Controller
$query = new Builder($con);
$view->data['goods'] = $query->raw($sql)->execute()->fetchAll();
$view->data['goods'] = $query->raw($sql)->execute()?->fetchAll() ?? [];
if (empty($view->data['goods'])) {
return $view;
@ -425,7 +440,7 @@ final class BackendController extends Controller
$query = new Builder($con);
$view->data['footnotes'] = $query->raw($sql)->execute()->fetchAll();
$view->data['footnotes'] = $query->raw($sql)->execute()?->fetchAll() ?? [];
return $view;
}
@ -453,8 +468,8 @@ final class BackendController extends Controller
}
$con = new \phpOMS\DataStorage\Database\Connection\SQLiteConnection([
'db' => 'sqlite',
'database' => __DIR__ . '/../Data/customs.sqlite'
'db' => 'sqlite',
'database' => __DIR__ . '/../Data/customs.sqlite',
]);
$con->connect();
@ -474,7 +489,7 @@ final class BackendController extends Controller
$query->bind(['value' => '%' . $request->getDataString('hscode') . '%'], ':description');
$query->bind(['value' => '%' . $request->getDataString('hscode') . '%'], ':code');
$temp = $query->raw($sql)->execute()->fetchAll();
$temp = $query->raw($sql)->execute()?->fetchAll() ?? [];
if (($exactCount = \count($temp)) === 0) {
return $view;
@ -484,7 +499,7 @@ final class BackendController extends Controller
// For this reason we have to also load all the sub-categories
// Create code range by finding the last none-0 value and increasing that value by 1
// While that value is a 9 the value is set to 0 and the left number is increased by 1
$codeRanges = [];
$codeRanges = [];
$exactMatches = [];
foreach ($temp as $code) {
@ -495,7 +510,7 @@ final class BackendController extends Controller
}
$length = \strlen($code['Goods_code']);
$max = \max(
$max = \max(
\strrpos($code['Goods_code'], '1', -3),
\strrpos($code['Goods_code'], '2', -3),
\strrpos($code['Goods_code'], '3', -3),
@ -506,7 +521,7 @@ final class BackendController extends Controller
\strrpos($code['Goods_code'], '8', -3),
\strrpos($code['Goods_code'], '9', -3),
);
$maxCode = $code['Goods_code'];
$maxCode = $code['Goods_code'];
$maxCode[$length - 1] = '0';
$maxCode[$length - 2] = '0';
@ -516,13 +531,13 @@ final class BackendController extends Controller
}
$maxCode[$max] = ((int) $code['Goods_code'][$max]) + 1;
$codeRanges[] = '(taric_good.Goods_code >= "' . $code['Goods_code'] . '"'
$codeRanges[] = '(taric_good.Goods_code >= "' . $code['Goods_code'] . '"'
. ' AND taric_good.Goods_code < "' . $maxCode . '")';
}
$codeRanges = empty($codeRanges)
? ''
: ' OR (' . \implode (' OR ', $codeRanges) . ')';
: ' OR (' . \implode(' OR ', $codeRanges) . ')';
$exactMatches = '"' . \implode('","', $exactMatches) . '"';
@ -535,8 +550,8 @@ final class BackendController extends Controller
LIMIT 1000;
SQL;
$query = new Builder($con);
$view->data['codes'] = $query->raw($sql)->execute()->fetchAll();
$query = new Builder($con);
$view->data['codes'] = $query->raw($sql)->execute()?->fetchAll() ?? [];
$con->close();

View File

@ -1,4 +1,16 @@
<?php
/**
* Jingga
*
* PHP Version 8.2
*
* @package Modules\Customs\Data
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
// Sources:
@ -29,13 +41,21 @@ if (\is_file($file)) {
$con = new SQLiteConnection(
[
'db' => 'sqlite',
'db' => 'sqlite',
'database' => $file,
]
);
$con->connect();
$schema = \json_decode(\file_get_contents(__DIR__ . '/schema.json'), true);
$schemaContent = \file_get_contents(__DIR__ . '/schema.json');
if ($schemaContent === false) {
return;
}
$schema = \json_decode($schemaContent, true);
if (!\is_array($schema)) {
return;
}
foreach ($schema as $table) {
Builder::createFromSchema($table, $con)->execute();

View File

@ -1,5 +0,0 @@
# Structure
## ER
![ER](Modules/Customs/Docs/Dev/img/er.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

View File

@ -13,7 +13,7 @@
declare(strict_types=1);
return ['Navigation' => [
'Customs' => 'Zoll',
'Customs' => 'Zoll',
'Sanctions' => 'Sanktionen',
'HSCode' => 'Zolltarifnummer',
]];
'HSCode' => 'Zolltarifnummer',
]];

View File

@ -13,7 +13,7 @@
declare(strict_types=1);
return ['Navigation' => [
'Customs' => 'Customs',
'Customs' => 'Customs',
'Sanctions' => 'Sanctions',
'HSCode' => 'HS Code',
'HSCode' => 'HS Code',
]];

View File

@ -13,28 +13,28 @@
declare(strict_types=1);
return ['Customs' => [
'HSCodes' => 'Zolltarifnummern',
'Code' => 'ZTN',
'Description' => 'Beschreibung',
'Basic' => 'Standard',
'Type' => 'Typ',
'Name' => 'Name',
'Address' => 'Adresse',
'Start' => 'Begin',
'City' => 'Stadt',
'Country' => 'Land',
'Detail' => 'Detail',
'Birthday' => 'Geburtstag',
'Phone' => 'Telefon',
'Remark' => 'Bemerkung',
'HSCodes' => 'Zolltarifnummern',
'Code' => 'ZTN',
'Description' => 'Beschreibung',
'Basic' => 'Standard',
'Type' => 'Typ',
'Name' => 'Name',
'Address' => 'Adresse',
'Start' => 'Begin',
'City' => 'Stadt',
'Country' => 'Land',
'Detail' => 'Detail',
'Birthday' => 'Geburtstag',
'Phone' => 'Telefon',
'Remark' => 'Bemerkung',
'Sanctions' => 'Sanktionen',
'Sanction' => 'Sanktion',
'IdentificationNumber' => 'Identifikationsnummer',
'MeasureType' => 'Measure Type',
'Footnote' => 'Fußnote',
'FootnoteDescription' => 'Fußnote Beschreibung',
'ExportDuty' => 'Export Zoll',
'ImportDuty' => 'Import Zoll',
'AddCode' => 'Add Code',
'AddDescription' => 'Add Beschreibung',
]];
'Sanction' => 'Sanktion',
'IdentificationNumber' => 'Identifikationsnummer',
'MeasureType' => 'Measure Type',
'Footnote' => 'Fußnote',
'FootnoteDescription' => 'Fußnote Beschreibung',
'ExportDuty' => 'Export Zoll',
'ImportDuty' => 'Import Zoll',
'AddCode' => 'Add Code',
'AddDescription' => 'Add Beschreibung',
]];

View File

@ -13,28 +13,28 @@
declare(strict_types=1);
return ['Customs' => [
'HSCodes' => 'HS Codes',
'Code' => 'Code',
'Description' => 'Description',
'Basic' => 'Basic',
'Type' => 'Type',
'Name' => 'Name',
'Address' => 'Address',
'City' => 'City',
'Start' => 'Start',
'Country' => 'Country',
'Detail' => 'Detail',
'Birthday' => 'Birthday',
'Phone' => 'Phone',
'Remark' => 'Remark',
'HSCodes' => 'HS Codes',
'Code' => 'Code',
'Description' => 'Description',
'Basic' => 'Basic',
'Type' => 'Type',
'Name' => 'Name',
'Address' => 'Address',
'City' => 'City',
'Start' => 'Start',
'Country' => 'Country',
'Detail' => 'Detail',
'Birthday' => 'Birthday',
'Phone' => 'Phone',
'Remark' => 'Remark',
'Sanctions' => 'Sanctions',
'Sanction' => 'Sanction',
'IdentificationNumber' => 'Identification Number',
'MeasureType' => 'Measure Type',
'Footnote' => 'Footnote',
'FootnoteDescription' => 'Footnote Description',
'ExportDuty' => 'Export Duty',
'ImportDuty' => 'Import Duty',
'AddCode' => 'Add Code',
'AddDescription' => 'Add Description',
]];
'Sanction' => 'Sanction',
'IdentificationNumber' => 'Identification Number',
'MeasureType' => 'Measure Type',
'Footnote' => 'Footnote',
'FootnoteDescription' => 'Footnote Description',
'ExportDuty' => 'Export Duty',
'ImportDuty' => 'Import Duty',
'AddCode' => 'Add Code',
'AddDescription' => 'Add Description',
]];

View File

@ -39,9 +39,9 @@ $codes = $this->data['codes'] ?? [];
<tbody>
<?php $count = 0;
foreach ($codes as $key => $value) : ++$count;
$id = \substr($value['Goods_code'], 0, (int) \stripos($value['Goods_code'], ' '));
$url = UriFactory::build('{/base}/customs/hscode/view?id=' . $id);
$description = $this->printHtml($value['Description']);
$id = \substr($value['Goods_code'], 0, (int) \stripos($value['Goods_code'], ' '));
$url = UriFactory::build('{/base}/customs/hscode/view?id=' . $id);
$description = $this->printHtml($value['Description']);
$foundKeyword = \stripos($description, $this->request->getDataString('hscode'));
if ($foundKeyword !== false) {
@ -50,13 +50,13 @@ $codes = $this->data['codes'] ?? [];
// Whitespace handling is causing issues since the whitespace is only rendered if followed by another character
// If whitespace found -> exclude from string -> add &nbsp; which gets always rendered unlike the whitespace
$startsWithS = ($description[$foundKeyword - 1] ?? '') === ' ';
$endsWithS = ($description[$foundKeyword + $len] ?? '') === ' ';
$endsWithS = ($description[$foundKeyword + $len] ?? '') === ' ';
$description = \substr($description, 0, $foundKeyword - ((int) $startsWithS))
. (($description[$foundKeyword - 1] ?? '') === ' ' ? '&nbsp;' : '')
. '<mark>' . \substr($description, $foundKeyword, $len) . '</mark>'
. (($description[$foundKeyword + $len] ?? '') === ' ' ? '&nbsp;' : '')
. \substr($description, $foundKeyword + $len + ((int) $endsWithS));
. \substr($description, $foundKeyword + $len + ((int) $endsWithS));
}
?>
<tr tabindex="0" data-href="<?= $url; ?>">

View File

@ -1,7 +1,7 @@
<?php
$footnotes = $this->data['footnotes'] ?? [];
$goods = $this->data['goods'] ?? [];
$baseDate = strtotime("1899-12-30");
$goods = $this->data['goods'] ?? [];
$baseDate = \strtotime("1899-12-30");
?>
<div class="row">
<div class="col-xs-12 col-md-6">
@ -9,8 +9,8 @@ $baseDate = strtotime("1899-12-30");
<div class="portlet-body">
<?php foreach ($goods as $good) : ?>
<div class="form-group">
<label><?= $good['Goods_code'] ?></label>
<p><?= $good['Description'] ?></p>
<label><?= $good['Goods_code']; ?></label>
<p><?= $good['Description']; ?></p>
</div>
<?php endforeach; ?>
</div>
@ -19,7 +19,7 @@ $baseDate = strtotime("1899-12-30");
</div>
<?php
$length = \count($footnotes);
$length = \count($footnotes);
$lastOrigin = '';
foreach ($footnotes as $idx => $value) :
if ($lastOrigin === $value['Origin_code']) {
@ -46,8 +46,8 @@ foreach ($footnotes as $idx => $value) :
$start = '';
if (!empty($footnotes[$i]['Start_date'])) {
$seconds = $footnotes[$i]['Start_date'] * 86400;
$date = new DateTime('@' . ($baseDate + $seconds));
$start = $date->format('Y-m-d');
$date = new DateTime('@' . ($baseDate + $seconds));
$start = $date->format('Y-m-d');
}
?>
<div class="portlet-body">

View File

@ -12,7 +12,7 @@
},
"creator": {
"name": "Jingga",
"website": "jingga.app"
"website": "https://jingga.app"
},
"description": "The customs module.",
"directory": "Customs",

View File

@ -24,9 +24,6 @@ use phpOMS\DataStorage\Session\HttpSession;
use phpOMS\Dispatcher\Dispatcher;
use phpOMS\Event\EventManager;
use phpOMS\Localization\L11nManager;
use phpOMS\Message\Http\HttpRequest;
use phpOMS\Message\Http\HttpResponse;
use phpOMS\Message\Http\RequestStatusCode;
use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\ModuleManager;
use phpOMS\Router\WebRouter;