diff --git a/Controller/ApiController.php b/Controller/ApiController.php index a800a25..8fe6dd8 100644 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -102,4 +102,20 @@ final class ApiController extends Controller public function apiExchangeExport(RequestAbstract $request, ResponseAbstract $response, $data = null) : void { } + + /** + * Api method to handle file upload + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function apiExchangeUpload(RequestAbstract $request, ResponseAbstract $response, $data = null): void + { } } diff --git a/Interfaces/GSD/en.lang.php b/Interfaces/GSD/en.lang.php index 1204fed..6a65786 100644 --- a/Interfaces/GSD/en.lang.php +++ b/Interfaces/GSD/en.lang.php @@ -4,7 +4,7 @@ * * PHP Version 7.4 * - * @package TBD + * @package Modules\Exchange * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 diff --git a/Interfaces/OMS/Importer.php b/Interfaces/OMS/Importer.php new file mode 100644 index 0000000..cd1a39a --- /dev/null +++ b/Interfaces/OMS/Importer.php @@ -0,0 +1,221 @@ +getData('start') ?? 'now'); + $end = new \DateTime($request->getData('end') ?? 'now'); + + $type = (int) ($request->getData('type') ?? 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) { + + } + } + + /** + * 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 + { + + } + + /** + * 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 + { } +} diff --git a/Interfaces/OMS/en.lang.php b/Interfaces/OMS/en.lang.php new file mode 100644 index 0000000..f248ad6 --- /dev/null +++ b/Interfaces/OMS/en.lang.php @@ -0,0 +1,24 @@ + 'Account', + 'Article' => 'Articls', + 'CostCenter' => 'Cost Center', + 'CostObject' => 'Cost Object', + 'Customer' => 'Customer', + 'Invoice' => 'Invoice', + 'Options' => 'Options', + 'Supplier' => 'Supplier', +]; diff --git a/Interfaces/OMS/import.tpl.php b/Interfaces/OMS/import.tpl.php new file mode 100644 index 0000000..95793fb --- /dev/null +++ b/Interfaces/OMS/import.tpl.php @@ -0,0 +1,66 @@ + +