mirror of
https://github.com/Karaka-Management/oms-Exchange.git
synced 2026-04-20 16:18:42 +00:00
typehint fixes
This commit is contained in:
parent
7261242641
commit
f4e952aead
|
|
@ -1,251 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @package Interfaces
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Exchange\Interfaces\OMS;
|
||||
|
||||
use Modules\Accounting\Models\CostCenter;
|
||||
use Modules\Accounting\Models\CostCenterMapper;
|
||||
use Modules\Accounting\Models\CostObject;
|
||||
use Modules\Accounting\Models\CostObjectMapper;
|
||||
use Modules\ClientManagement\Models\ClientMapper;
|
||||
use Modules\Exchange\Models\ExchangeType;
|
||||
use Modules\Exchange\Models\ImporterAbstract;
|
||||
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
|
||||
/**
|
||||
* OMS import class
|
||||
*
|
||||
* @package Modules\Exchange\Models\Interfaces\OMS
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class Importer extends ImporterAbstract
|
||||
{
|
||||
/**
|
||||
* Import data from request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function importFromRequest(RequestAbstract $request): bool
|
||||
{
|
||||
$start = new \DateTime($request->getData('start') ?? 'now');
|
||||
$end = new \DateTime($request->getData('end') ?? 'now');
|
||||
|
||||
$type = (int) ($request->getData('type') ?? 0);
|
||||
$source = (int) ($request->getData('source') ?? 0);
|
||||
|
||||
if ($type === ExchangeType::CUSTOMER) {
|
||||
$this->importCustomer($start, $end);
|
||||
} elseif ($type === ExchangeType::SUPPLIER) {
|
||||
$this->importSupplier($start, $end);
|
||||
} elseif ($type === ExchangeType::ACCOUNT) {
|
||||
$this->importAccount($start, $end);
|
||||
} elseif ($type === ExchangeType::COSTCENTER) {
|
||||
$this->importCostCenter($start, $end);
|
||||
} elseif ($type === ExchangeType::COSTOBJECT) {
|
||||
$this->importCostObject($start, $end);
|
||||
} elseif ($type === ExchangeType::ARTICLE) {
|
||||
$this->importArticle($start, $end);
|
||||
} elseif ($type === ExchangeType::INVOICE) {
|
||||
$this->importInvoice($start, $end);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import cost centers
|
||||
*
|
||||
* @param \DateTime $start Start time (inclusive)
|
||||
* @param \DateTime $end End time (inclusive)
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function importCostCenter(\DateTime $start, \DateTime $end): void
|
||||
{
|
||||
$costCenters = OMSCostCenterMapper::getAll();
|
||||
|
||||
$obj = new CostCenter();
|
||||
DataMapperAbstract::setConnection($this->local);
|
||||
|
||||
foreach ($costCenters as $cc) {
|
||||
$obj->setCostCenter((int) $cc->getCostCenter());
|
||||
$obj->setCostCenterName($cc->getDescription());
|
||||
|
||||
CostCenterMapper::create($obj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Import cost objects
|
||||
*
|
||||
* @param \DateTime $start Start time (inclusive)
|
||||
* @param \DateTime $end End time (inclusive)
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function importCostObject(\DateTime $start, \DateTime $end): void
|
||||
{
|
||||
$costObjects = OMSCostObjectMapper::getAll();
|
||||
|
||||
$obj = new CostObject();
|
||||
DataMapperAbstract::setConnection($this->local);
|
||||
|
||||
foreach ($costObjects as $co) {
|
||||
$obj->setCostObject((int) $co->getCostObject());
|
||||
$obj->setCostObjectName($co->getDescription());
|
||||
|
||||
CostObjectMapper::create($obj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Import addresses
|
||||
*
|
||||
* @param \DateTime $start Start time (inclusive)
|
||||
* @param \DateTime $end End time (inclusive)
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function importAddress(\DateTime $start, \DateTime $end): void
|
||||
{
|
||||
while (($line = \fgetcsv($this->remote)) !== false) {
|
||||
\var_dump($line);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Import customers
|
||||
*
|
||||
* @param \DateTime $start Start time (inclusive)
|
||||
* @param \DateTime $end End time (inclusive)
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function importCustomer(\DateTime $start, \DateTime $end): void
|
||||
{
|
||||
$euTIN = CustomerIdTypeMapper::getByType(CustomerIdType::EU_TIN);
|
||||
$gerTIN = CustomerIdTypeMapper::getByType(CustomerIdType::GER_TIN);
|
||||
|
||||
while (($line = \fgetcsv($this->remote)) !== false) {
|
||||
$customer = new Client();
|
||||
|
||||
$customer->setNumber($line[0]);
|
||||
$customer->getProfile()->getAccount()->setName1($line[1]);
|
||||
$customer->getProfile()->getAccount()->setName2($line[2]);
|
||||
$customer->getProfile()->getAccount()->setName3($line[3]);
|
||||
//$customer->addEmail(EmailType::BUSINESS, $line[4]);
|
||||
//$customer->addPhone(PhoneType::BUSINESS, $line[5]);
|
||||
//$customer->addWebsite(PhoneType::BUSINESS, $line[5]);
|
||||
|
||||
$address = new Address();
|
||||
$customer->setDefaultDeliveryAddress($address);
|
||||
$customer->setDefaultInvoiceAddress($address);
|
||||
|
||||
$customer->setDefaultPaymentTerms(new PaymentTerms());
|
||||
$customer->setCreditLimit($line[12]);
|
||||
$customer->setStatus($line[9]);
|
||||
$customer->setInfo($line[9]);
|
||||
$customer->setAdvertisementMaterial($line[13]);
|
||||
$customer->setSalesRep();
|
||||
$customer->setType();
|
||||
$customer->addPartner();
|
||||
|
||||
$customer->addId($euTIN, $line[10]);
|
||||
$customer->addId($gerTIN, $line[11]);
|
||||
|
||||
ClientMapper::create($customer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Import suppliers
|
||||
*
|
||||
* @param \DateTime $start Start time (inclusive)
|
||||
* @param \DateTime $end End time (inclusive)
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function importSupplier(\DateTime $start, \DateTime $end): void
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Import accounts
|
||||
*
|
||||
* @param \DateTime $start Start time (inclusive)
|
||||
* @param \DateTime $end End time (inclusive)
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function importAccount(\DateTime $start, \DateTime $end): void
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Import invoices
|
||||
*
|
||||
* @param \DateTime $start Start time (inclusive)
|
||||
* @param \DateTime $end End time (inclusive)
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function importInvoice(\DateTime $start, \DateTime $end): void
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Import postings
|
||||
*
|
||||
* @param \DateTime $start Start time (inclusive)
|
||||
* @param \DateTime $end End time (inclusive)
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function importPosting(\DateTime $start, \DateTime $end): void
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Import batch postings
|
||||
*
|
||||
* @param \DateTime $start Start time (inclusive)
|
||||
* @param \DateTime $end End time (inclusive)
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function importBatchPosting(\DateTime $start, \DateTime $end): void
|
||||
{ }
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
use Modules\Exchange\Models\ExchangeType;
|
||||
|
||||
?>
|
||||
<div class="tabview tab-2">
|
||||
<div class="box wf-100 col-xs-12">
|
||||
<ul class="tab-links">
|
||||
<li><label for="c-tab-1"><?= $this->getHtml('File'); ?></label></li>
|
||||
<li><label for="c-tab-2"><?= $this->getHtml('Database'); ?></label></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<input type="radio" id="c-tab-1" name="tabular-2" checked>
|
||||
<div class="tab">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<section class="box wf-100">
|
||||
<header>
|
||||
<h1><?= $this->getHtml('Import') ?> - Orange Management</h1>
|
||||
</header>
|
||||
|
||||
<div class="inner">
|
||||
<form id="fImport" method="POST" action="<?= \phpOMS\Uri\UriFactory::build('{/api}admin/exchange/import/profile?{?}&exchange=GSD&csrf={$CSRF}'); ?>">
|
||||
<table class="layout wf-100" style="table-layout: fixed">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><label for="iHost"><?= $this->getHtml('Host') ?></label>
|
||||
<tr>
|
||||
<td><input type="file" id="iFile" name="file" placeholder=" <?= $this->getHtml('Host') ?>" data-uri="api/exchange/file" required><input type="hidden" id="iUploaded" name="uploaded">
|
||||
<tr>
|
||||
<td><?= $this->getHtml('Options') ?>
|
||||
<tr>
|
||||
<td>
|
||||
<select>
|
||||
<option value="<?= ExchangeType::CUSTOMER; ?>"><?= $this->getHtml('Customer') ?>
|
||||
<option value="<?= ExchangeType::SUPPLIER; ?>"><?= $this->getHtml('Supplier') ?>
|
||||
<option value="<?= ExchangeType::ARTICLE; ?>"><?= $this->getHtml('Article') ?>
|
||||
<option value="<?= ExchangeType::BOOKING; ?>"><?= $this->getHtml('Booking') ?>
|
||||
<option value="<?= ExchangeType::ACCOUNT; ?>"><?= $this->getHtml('Account') ?>
|
||||
<option value="<?= ExchangeType::COSTCENTER; ?>"><?= $this->getHtml('CostCenter') ?>
|
||||
<option value="<?= ExchangeType::COSTOBJECT; ?>"><?= $this->getHtml('CostObject') ?>
|
||||
<option value="<?= ExchangeType::ADDRESS; ?>"><?= $this->getHtml('Address') ?>
|
||||
</select>
|
||||
<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>
|
||||
<input type="submit" value="<?= $this->getHtml('Import'); ?>">
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="radio" id="c-tab-2" name="tabular-2">
|
||||
<div class="tab">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -3,6 +3,6 @@
|
|||
"version": "1.0.0",
|
||||
"website": "",
|
||||
"path": "OMS",
|
||||
"export": false,
|
||||
"import": true
|
||||
"export": true,
|
||||
"import": false
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user