mirror of
https://github.com/Karaka-Management/oms-Exchange.git
synced 2026-02-17 02:08:40 +00:00
code fixes
This commit is contained in:
parent
ede30523c6
commit
92efabd600
|
|
@ -33,6 +33,7 @@ final class Exporter extends ExporterAbstract
|
||||||
/**
|
/**
|
||||||
* Export all data in time span
|
* Export all data in time span
|
||||||
*
|
*
|
||||||
|
* @param array $data Export data
|
||||||
* @param \DateTime $start Start time (inclusive)
|
* @param \DateTime $start Start time (inclusive)
|
||||||
* @param \DateTime $end End time (inclusive)
|
* @param \DateTime $end End time (inclusive)
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ final class Importer extends ImporterAbstract
|
||||||
/**
|
/**
|
||||||
* Import all data in time span
|
* Import all data in time span
|
||||||
*
|
*
|
||||||
|
* @param array $data Import data
|
||||||
* @param \DateTime $start Start time (inclusive)
|
* @param \DateTime $start Start time (inclusive)
|
||||||
* @param \DateTime $end End time (inclusive)
|
* @param \DateTime $end End time (inclusive)
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ final class Exporter extends ExporterAbstract
|
||||||
/**
|
/**
|
||||||
* Export all data in time span
|
* Export all data in time span
|
||||||
*
|
*
|
||||||
|
* @param array $data Export data
|
||||||
* @param \DateTime $start Start time (inclusive)
|
* @param \DateTime $start Start time (inclusive)
|
||||||
* @param \DateTime $end End time (inclusive)
|
* @param \DateTime $end End time (inclusive)
|
||||||
*
|
*
|
||||||
|
|
@ -52,7 +53,7 @@ final class Exporter extends ExporterAbstract
|
||||||
$result = $this->exportReport($data);
|
$result = $this->exportReport($data);
|
||||||
|
|
||||||
$log = new ExchangeLog();
|
$log = new ExchangeLog();
|
||||||
$log->createdBy = $this->account;
|
$log->createdBy = $data['account'] ?? 0;
|
||||||
$log->type = ExchangeType::EXPORT;
|
$log->type = ExchangeType::EXPORT;
|
||||||
$log->message = $this->l11n->getText($data['language'], 'Exchange', '', 'ReportExported');
|
$log->message = $this->l11n->getText($data['language'], 'Exchange', '', 'ReportExported');
|
||||||
$log->subtype = 'language';
|
$log->subtype = 'language';
|
||||||
|
|
@ -62,6 +63,13 @@ final class Exporter extends ExporterAbstract
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create export.
|
||||||
|
*
|
||||||
|
* @return array{type:string, name:string, content:string}
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function exportReport(array $data) : array
|
private function exportReport(array $data) : array
|
||||||
{
|
{
|
||||||
$content = '';
|
$content = '';
|
||||||
|
|
@ -100,6 +108,15 @@ final class Exporter extends ExporterAbstract
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create pdf export
|
||||||
|
*
|
||||||
|
* @param array $data Data to export
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function pdfExport(array $data) : string
|
private function pdfExport(array $data) : string
|
||||||
{
|
{
|
||||||
$view = new View();
|
$view = new View();
|
||||||
|
|
@ -115,6 +132,15 @@ final class Exporter extends ExporterAbstract
|
||||||
return $view->render();
|
return $view->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create csv export
|
||||||
|
*
|
||||||
|
* @param array $data Data to export
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function csvExport(array $data) : string
|
private function csvExport(array $data) : string
|
||||||
{
|
{
|
||||||
$view = new View();
|
$view = new View();
|
||||||
|
|
@ -130,6 +156,15 @@ final class Exporter extends ExporterAbstract
|
||||||
return $view->render();
|
return $view->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create excel export
|
||||||
|
*
|
||||||
|
* @param array $data Data to export
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function excelExport(array $data) : string
|
private function excelExport(array $data) : string
|
||||||
{
|
{
|
||||||
$view = new View();
|
$view = new View();
|
||||||
|
|
@ -145,6 +180,15 @@ final class Exporter extends ExporterAbstract
|
||||||
return $view->render();
|
return $view->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create xml export
|
||||||
|
*
|
||||||
|
* @param array $data Data to export
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function xmlExport(array $data) : string
|
private function xmlExport(array $data) : string
|
||||||
{
|
{
|
||||||
$defaultTemplates = $data['templates'] ?? [];
|
$defaultTemplates = $data['templates'] ?? [];
|
||||||
|
|
@ -154,6 +198,15 @@ final class Exporter extends ExporterAbstract
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create html export
|
||||||
|
*
|
||||||
|
* @param array $data Data to export
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function htmlExport(array $data) : string
|
private function htmlExport(array $data) : string
|
||||||
{
|
{
|
||||||
$defaultTemplates = $data['templates'] ?? [];
|
$defaultTemplates = $data['templates'] ?? [];
|
||||||
|
|
@ -163,6 +216,15 @@ final class Exporter extends ExporterAbstract
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create word export
|
||||||
|
*
|
||||||
|
* @param array $data Data to export
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function wordExport(array $data) : string
|
private function wordExport(array $data) : string
|
||||||
{
|
{
|
||||||
$defaultTemplates = $data['templates'] ?? [];
|
$defaultTemplates = $data['templates'] ?? [];
|
||||||
|
|
@ -172,6 +234,15 @@ final class Exporter extends ExporterAbstract
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create json export
|
||||||
|
*
|
||||||
|
* @param array $data Data to export
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function jsonExport(array $data) : string
|
private function jsonExport(array $data) : string
|
||||||
{
|
{
|
||||||
$defaultTemplates = $data['templates'] ?? [];
|
$defaultTemplates = $data['templates'] ?? [];
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ final class Importer extends ImporterAbstract
|
||||||
/**
|
/**
|
||||||
* Import all data in time span
|
* Import all data in time span
|
||||||
*
|
*
|
||||||
|
* @param array $data Import data
|
||||||
* @param \DateTime $start Start time (inclusive)
|
* @param \DateTime $start Start time (inclusive)
|
||||||
* @param \DateTime $end End time (inclusive)
|
* @param \DateTime $end End time (inclusive)
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
||||||
namespace Modules\Exchange\Controller;
|
namespace Modules\Exchange\Controller;
|
||||||
|
|
||||||
use Modules\Admin\Models\NullAccount;
|
use Modules\Admin\Models\NullAccount;
|
||||||
|
use Modules\Admin\Models\SettingsEnum as AdminSettingsEnum;
|
||||||
use Modules\Exchange\Models\ExchangeLogMapper;
|
use Modules\Exchange\Models\ExchangeLogMapper;
|
||||||
use Modules\Exchange\Models\ExchangeSetting;
|
use Modules\Exchange\Models\ExchangeSetting;
|
||||||
use Modules\Exchange\Models\ExchangeSettingMapper;
|
use Modules\Exchange\Models\ExchangeSettingMapper;
|
||||||
|
|
@ -27,6 +28,7 @@ use Modules\Media\Models\CollectionMapper;
|
||||||
use Modules\Media\Models\MediaMapper;
|
use Modules\Media\Models\MediaMapper;
|
||||||
use Modules\Media\Models\NullCollection;
|
use Modules\Media\Models\NullCollection;
|
||||||
use Modules\Media\Models\PathSettings;
|
use Modules\Media\Models\PathSettings;
|
||||||
|
use Modules\Organization\Models\UnitMapper;
|
||||||
use phpOMS\Account\PermissionType;
|
use phpOMS\Account\PermissionType;
|
||||||
use phpOMS\DataStorage\Database\Connection\ConnectionFactory;
|
use phpOMS\DataStorage\Database\Connection\ConnectionFactory;
|
||||||
use phpOMS\DataStorage\Database\Connection\NullConnection;
|
use phpOMS\DataStorage\Database\Connection\NullConnection;
|
||||||
|
|
@ -38,8 +40,6 @@ use phpOMS\Message\RequestAbstract;
|
||||||
use phpOMS\Message\ResponseAbstract;
|
use phpOMS\Message\ResponseAbstract;
|
||||||
use phpOMS\Model\Message\FormValidation;
|
use phpOMS\Model\Message\FormValidation;
|
||||||
use phpOMS\Utils\StringUtils;
|
use phpOMS\Utils\StringUtils;
|
||||||
use Modules\Admin\Models\SettingsEnum as AdminSettingsEnum;
|
|
||||||
use Modules\Organization\Models\UnitMapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exchange controller class.
|
* Exchange controller class.
|
||||||
|
|
@ -94,6 +94,16 @@ final class ApiController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get importer by id
|
||||||
|
*
|
||||||
|
* @param int $id Id of the importer
|
||||||
|
* @param array $dbData Database connection data
|
||||||
|
*
|
||||||
|
* @return null|\Modules\Exchange\Interface\Importer
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function getImporter(int $id, array $dbData) : ?\Modules\Exchange\Interface\Importer
|
private function getImporter(int $id, array $dbData) : ?\Modules\Exchange\Interface\Importer
|
||||||
{
|
{
|
||||||
$importer = null;
|
$importer = null;
|
||||||
|
|
@ -330,6 +340,15 @@ final class ApiController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get exporter by id
|
||||||
|
*
|
||||||
|
* @param int $id Id of the exporter
|
||||||
|
*
|
||||||
|
* @return null|\Modules\Exchange\Interface\Exporter
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function getExporter(int $id) : ?\Modules\Exchange\Interface\Exporter
|
private function getExporter(int $id) : ?\Modules\Exchange\Interface\Exporter
|
||||||
{
|
{
|
||||||
$exporter = null;
|
$exporter = null;
|
||||||
|
|
@ -366,6 +385,16 @@ final class ApiController extends Controller
|
||||||
return $exporter;
|
return $exporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the data of the export
|
||||||
|
*
|
||||||
|
* @param int $id Exporter id
|
||||||
|
* @param array $data Export data
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function exportData(int $id, array $data) : array
|
public function exportData(int $id, array $data) : array
|
||||||
{
|
{
|
||||||
$exporter = $this->getExporter($id);
|
$exporter = $this->getExporter($id);
|
||||||
|
|
@ -442,6 +471,18 @@ final class ApiController extends Controller
|
||||||
return $setting;
|
return $setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Api method to export a report
|
||||||
|
*
|
||||||
|
* @param RequestAbstract $request Request
|
||||||
|
* @param HttpResponse $response Response
|
||||||
|
* @param Report $report Report to export
|
||||||
|
* @param string $type Export type (e.g. pdf,csv,html,xml,json,xls)
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function apiExportReport(
|
public function apiExportReport(
|
||||||
RequestAbstract $request,
|
RequestAbstract $request,
|
||||||
ResponseAbstract $response,
|
ResponseAbstract $response,
|
||||||
|
|
@ -449,7 +490,7 @@ final class ApiController extends Controller
|
||||||
string $type
|
string $type
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
/** @var \Model\Setting $settings */
|
/** @var \Model\Setting[] $settings */
|
||||||
$settings = $this->app->appSettings->get(null,
|
$settings = $this->app->appSettings->get(null,
|
||||||
[
|
[
|
||||||
AdminSettingsEnum::DEFAULT_TEMPLATES,
|
AdminSettingsEnum::DEFAULT_TEMPLATES,
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,11 @@ class Report
|
||||||
|
|
||||||
public array $data = [];
|
public array $data = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->dt = new \DateTime('now');
|
$this->dt = new \DateTime('now');
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ use phpOMS\Message\Http\HttpRequest;
|
||||||
use phpOMS\Message\Http\HttpResponse;
|
use phpOMS\Message\Http\HttpResponse;
|
||||||
use phpOMS\Message\RequestAbstract;
|
use phpOMS\Message\RequestAbstract;
|
||||||
use phpOMS\Message\ResponseAbstract;
|
use phpOMS\Message\ResponseAbstract;
|
||||||
use phpOMS\Uri\HttpUri;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ use phpOMS\Message\Http\HttpRequest;
|
||||||
use phpOMS\Message\Http\HttpResponse;
|
use phpOMS\Message\Http\HttpResponse;
|
||||||
use phpOMS\Message\RequestAbstract;
|
use phpOMS\Message\RequestAbstract;
|
||||||
use phpOMS\Message\ResponseAbstract;
|
use phpOMS\Message\ResponseAbstract;
|
||||||
use phpOMS\Uri\HttpUri;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user