mirror of
https://github.com/Karaka-Management/oms-Exchange.git
synced 2026-01-26 15:58:42 +00:00
Implement basic exchange draft
This commit is contained in:
parent
58377a15b4
commit
8a183c5452
18
Admin/Routes/Web/Api.php
Normal file
18
Admin/Routes/Web/Api.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
use phpOMS\Router\RouteVerb;
|
||||
|
||||
return [
|
||||
'^.*/api/admin/exchange/import/profile.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\Exchange\Controller:apiExchangeImport',
|
||||
'verb' => RouteVerb::SET,
|
||||
],
|
||||
],
|
||||
'^.*/api/admin/exchange/export/profile.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\Exchange\Controller:apiExchangeExport',
|
||||
'verb' => RouteVerb::SET,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
@ -20,12 +20,15 @@ use Modules\Navigation\Views\NavigationView;
|
|||
use phpOMS\Contract\RenderableInterface;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Message\NotificationLevel;
|
||||
use phpOMS\Module\ModuleAbstract;
|
||||
use phpOMS\Module\WebInterface;
|
||||
use phpOMS\Views\View;
|
||||
use phpOMS\Account\PermissionType;
|
||||
|
||||
use Modules\Exchange\Models\InterfaceManager;
|
||||
use Modules\Exchange\Models\InterfaceManagerMapper;
|
||||
use Modules\Exchange\Models\PermissionState;
|
||||
|
||||
/**
|
||||
* Exchange controller class.
|
||||
|
|
@ -155,6 +158,73 @@ final class Controller extends ModuleAbstract implements WebInterface
|
|||
|
||||
$view->addData('interface', $interface);
|
||||
|
||||
$lang = include __DIR__ . '/Interfaces/' . $interface->getInterfacePath() . '/' . $response->getHeader()->getL11n()->getLanguage() . '.lang.php';
|
||||
$view->addData('lang', $lang);
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to import data
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiExchangeImport(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
if (!$this->app->accountManager->get($request->getHeader()->getAccount())->hasPermission(
|
||||
PermissionType::MODIFY, $this->app->orgId, $this->app->appName, self::MODULE_NAME, PermissionState::IMPORT)
|
||||
) {
|
||||
$response->set('exchange_import', null);
|
||||
$response->getHeader()->setStatusCode(RequestStatusCode::R_403);
|
||||
return;
|
||||
}
|
||||
|
||||
$import = $this->importDataFromRequest($request);
|
||||
|
||||
if ($import) {
|
||||
$response->set($request->getUri()->__toString(), [
|
||||
'status' => NotificationLevel::OK,
|
||||
'title' => 'Exchange',
|
||||
'message' => 'Import succeeded.'
|
||||
]);
|
||||
} else {
|
||||
$response->set($request->getUri()->__toString(), [
|
||||
'status' => NotificationLevel::ERROR,
|
||||
'title' => 'Exchange',
|
||||
'message' => 'Import failed.'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to import data based on a request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function importDataFromRequest(RequestAbstract $request) : bool
|
||||
{
|
||||
$interfaces = InterfaceManagerMapper::getAll();
|
||||
foreach ($interfaces as $interface) {
|
||||
if ($request->getData('exchange') === $interface->getInterfacePath()) {
|
||||
$class = '\\Modules\\Exchange\\Interfaces\\' . $interface->getInterfacePath() . '\\Importer';
|
||||
$importer = new $class();
|
||||
|
||||
return $importer->importRequest($request);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
22
Interfaces/GSD/en.lang.php
Normal file
22
Interfaces/GSD/en.lang.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package TBD
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://website.orange-management.de
|
||||
*/
|
||||
return [
|
||||
'Accounts' => 'Accounts',
|
||||
'Articles' => 'Articles',
|
||||
'CostCenters' => 'Cost Centers',
|
||||
'CostObjects' => 'Cost Objects',
|
||||
'Customers' => 'Customers',
|
||||
'Invoices' => 'Invoices',
|
||||
'Options' => 'Options',
|
||||
'Suppliers' => 'Suppliers',
|
||||
];
|
||||
|
|
@ -1,12 +1,54 @@
|
|||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<section class="box wf-100">
|
||||
<header><h1><?= $this->getHtml('Task') ?></h1></header>
|
||||
<header><h1><?= $this->getHtml('Import') ?> - GSD</h1></header>
|
||||
|
||||
<div class="inner">
|
||||
<form id="fTask" method="PUT" action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/task?{?}&csrf={$CSRF}'); ?>">
|
||||
<form id="fImport" method="POST" action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/admin/exchange/import/profile?{?}&exchange=GSD&csrf={$CSRF}'); ?>">
|
||||
<table class="layout wf-100" style="table-layout: fixed">
|
||||
<tbody>
|
||||
<tr><td><label for="iStart"><?= $this->getHtml('Start') ?></label>
|
||||
<tr><td><input type="datetime-local" id="iStart" name="start" value="<?= $this->printHtml((new \DateTime('NOW'))->format('Y-m-d\TH:i:s')); ?>">
|
||||
<tr><td><label for="iEnd"><?= $this->getHtml('End') ?></label>
|
||||
<tr><td><input type="datetime-local" id="iEnd" name="end" value="<?= $this->printHtml((new \DateTime('NOW'))->format('Y-m-d\TH:i:s')); ?>">
|
||||
<tr><td><?= $this->getHtml('Options') ?>
|
||||
<tr><td>
|
||||
<span class="checkbox">
|
||||
<input id="iCustomers" name="customers" type="checkbox" value="1">
|
||||
<label for="iCustomers"><?= $lang['Customers']; ?></label>
|
||||
</span>
|
||||
<tr><td>
|
||||
<span class="checkbox">
|
||||
<input id="iSuppliers" name="suppliers" type="checkbox" value="1">
|
||||
<label for="iSuppliers"><?= $lang['Suppliers']; ?></label>
|
||||
</span>
|
||||
<tr><td>
|
||||
<span class="checkbox">
|
||||
<input id="iAccounts" name="accounts" type="checkbox" value="1">
|
||||
<label for="iAccounts"><?= $lang['Accounts']; ?></label>
|
||||
</span>
|
||||
<tr><td>
|
||||
<span class="checkbox">
|
||||
<input id="iCostCenters" name="costcenters" type="checkbox" value="1">
|
||||
<label for="iCostCenters"><?= $lang['CostCenters']; ?></label>
|
||||
</span>
|
||||
<tr><td>
|
||||
<span class="checkbox">
|
||||
<input id="iCostObjects" name="costobjects" type="checkbox" value="1">
|
||||
<label for="iCostObjects"><?= $lang['CostObjects']; ?></label>
|
||||
</span>
|
||||
<tr><td>
|
||||
<span class="checkbox">
|
||||
<input id="iArticles" name="articles" type="checkbox" value="1">
|
||||
<label for="iArticles"><?= $lang['Articles']; ?></label>
|
||||
</span>
|
||||
<tr><td>
|
||||
<span class="checkbox">
|
||||
<input id="iInvoices" name="invoices" type="checkbox" value="1">
|
||||
<label for="iInvoices"><?= $lang['Invoices']; ?></label>
|
||||
</span>
|
||||
<tr><td>
|
||||
<input type="submit" value="<?= $this->getHtml('Import'); ?>">
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
31
Models/PermissionState.php
Normal file
31
Models/PermissionState.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package Modules\Exchange
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://website.orange-management.de
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Exchange\Models;
|
||||
|
||||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
/**
|
||||
* Permision state enum.
|
||||
*
|
||||
* @package Modules\Exchange
|
||||
* @license OMS License 1.0
|
||||
* @link http://website.orange-management.de
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class PermissionState extends Enum
|
||||
{
|
||||
public const IMPORT = 1;
|
||||
public const EXPORT = 2;
|
||||
}
|
||||
|
|
@ -11,9 +11,14 @@
|
|||
* @link http://website.orange-management.de
|
||||
*/
|
||||
return ['Exchange' => [
|
||||
'End' => 'End',
|
||||
'Exchange' => 'Exchange',
|
||||
'Export' => 'Export',
|
||||
'Exports' => 'Exports',
|
||||
'Import' => 'Import',
|
||||
'Imports' => 'Imports',
|
||||
'Options' => 'Options',
|
||||
'Start' => 'Start',
|
||||
'Title' => 'Title',
|
||||
'Website' => 'Website',
|
||||
]];
|
||||
|
|
|
|||
|
|
@ -11,9 +11,11 @@
|
|||
* @link http://website.orange-management.de
|
||||
*/
|
||||
|
||||
$lang = $this->getData('lang');
|
||||
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
*/
|
||||
echo $this->getData('nav')->render();
|
||||
|
||||
include __DIR__ . '/../../Interfaces/' . $this->getData('interface')->getInterfacePath() . '/import.tpl.php';
|
||||
include __DIR__ . '/../../Interfaces/' . $this->getData('interface')->getInterfacePath() . '/import.tpl.php';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user