mirror of
https://github.com/Karaka-Management/oms-Script.git
synced 2026-01-11 12:28:41 +00:00
make id public, organigram impl. media password/encryption, settings bug fix, Money->FloatInt change, ...
This commit is contained in:
parent
7efad9401c
commit
009bd3f8f7
|
|
@ -92,7 +92,7 @@ final class ApiController extends Controller
|
|||
$isExport = \in_array($request->getData('type'), ['xlsx', 'pdf', 'docx', 'pptx', 'csv', 'json']);
|
||||
|
||||
// is allowed to read
|
||||
if (!$this->app->accountManager->get($accountId)->hasPermission(PermissionType::READ, $this->app->unitId, null, self::NAME, PermissionCategory::REPORT, $template->getId())
|
||||
if (!$this->app->accountManager->get($accountId)->hasPermission(PermissionType::READ, $this->app->unitId, null, self::NAME, PermissionCategory::REPORT, $template->id)
|
||||
|| ($isExport && !$this->app->accountManager->get($accountId)->hasPermission(PermissionType::READ, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::EXPORT))
|
||||
) {
|
||||
$response->header->status = RequestStatusCode::R_403;
|
||||
|
|
@ -354,7 +354,7 @@ final class ApiController extends Controller
|
|||
->with('template')
|
||||
->with('source')
|
||||
->with('source/sources')
|
||||
->where('template', $template->getId())
|
||||
->where('template', $template->id)
|
||||
->sort('id', OrderType::DESC)
|
||||
->limit(1)
|
||||
->execute();
|
||||
|
|
@ -362,7 +362,7 @@ final class ApiController extends Controller
|
|||
$rcoll = [];
|
||||
$report = $report === false ? new NullReport() : $report;
|
||||
|
||||
if (!($report instanceof NullReport)) {
|
||||
if ($report->id > 0) {
|
||||
$files = $report->source->getSources();
|
||||
|
||||
foreach ($files as $media) {
|
||||
|
|
@ -429,7 +429,7 @@ final class ApiController extends Controller
|
|||
);
|
||||
|
||||
foreach ($uploaded as $upload) {
|
||||
if ($upload instanceof NullMedia) {
|
||||
if ($upload->id === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -448,7 +448,7 @@ final class ApiController extends Controller
|
|||
$request->header->account
|
||||
);
|
||||
|
||||
if ($collection instanceof NullCollection) {
|
||||
if ($collection->id === 0) {
|
||||
$response->header->status = RequestStatusCode::R_403;
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Template', 'Couldn\'t create collection for template', null);
|
||||
|
||||
|
|
@ -460,7 +460,7 @@ final class ApiController extends Controller
|
|||
|
||||
$this->createModel($request->header->account, $collection, CollectionMapper::class, 'collection', $request->getOrigin());
|
||||
|
||||
$template = $this->createTemplateFromRequest($request, $collection->getId());
|
||||
$template = $this->createTemplateFromRequest($request, $collection->id);
|
||||
|
||||
$this->app->moduleManager->get('Admin')->createAccountModelPermission(
|
||||
new AccountPermission(
|
||||
|
|
@ -470,7 +470,7 @@ final class ApiController extends Controller
|
|||
self::NAME,
|
||||
self::NAME,
|
||||
PermissionCategory::TEMPLATE,
|
||||
$template->getId(),
|
||||
$template->id,
|
||||
null,
|
||||
PermissionType::READ | PermissionType::MODIFY | PermissionType::DELETE | PermissionType::PERMISSION,
|
||||
),
|
||||
|
|
@ -601,7 +601,7 @@ final class ApiController extends Controller
|
|||
$collection->setPath('/Modules/Media/Files/Modules/Helper/' . ($request->getDataString('name') ?? ''));
|
||||
$collection->setVirtualPath('/Modules/Helper');
|
||||
|
||||
if ($collection instanceof NullCollection) {
|
||||
if ($collection->id === 0) {
|
||||
$response->header->status = RequestStatusCode::R_403;
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Report', 'Couldn\'t create collection for report', null);
|
||||
|
||||
|
|
@ -610,7 +610,7 @@ final class ApiController extends Controller
|
|||
|
||||
$this->createModel($request->header->account, $collection, CollectionMapper::class, 'collection', $request->getOrigin());
|
||||
|
||||
$report = $this->createReportFromRequest($request, $response, $collection->getId());
|
||||
$report = $this->createReportFromRequest($request, $response, $collection->id);
|
||||
|
||||
$this->app->moduleManager->get('Admin')->createAccountModelPermission(
|
||||
new AccountPermission(
|
||||
|
|
@ -620,7 +620,7 @@ final class ApiController extends Controller
|
|||
self::NAME,
|
||||
self::NAME,
|
||||
PermissionCategory::REPORT,
|
||||
$report->getId(),
|
||||
$report->id,
|
||||
null,
|
||||
PermissionType::READ | PermissionType::MODIFY | PermissionType::DELETE | PermissionType::PERMISSION,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -205,13 +205,13 @@ final class BackendController extends Controller
|
|||
}
|
||||
|
||||
/** @var \Modules\Helper\Models\Report[] $report */
|
||||
$report = ReportMapper::get()->where('template', $template->getId())->sort('id', OrderType::DESC)->limit(1)->execute();
|
||||
$report = ReportMapper::get()->where('template', $template->id)->sort('id', OrderType::DESC)->limit(1)->execute();
|
||||
|
||||
$rcoll = [];
|
||||
$report = \end($report);
|
||||
$report = $report === false ? new NullReport() : $report;
|
||||
|
||||
if (!($report instanceof NullReport)) {
|
||||
if ($report->id > 0) {
|
||||
/** @var Media[] $files */
|
||||
$files = $report->source->getSources();
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Report implements \JsonSerializable
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
public int $id = 0;
|
||||
|
||||
/**
|
||||
* Report status.
|
||||
|
|
@ -43,7 +43,7 @@ class Report implements \JsonSerializable
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private int $status = HelperStatus::INACTIVE;
|
||||
public int $status = HelperStatus::INACTIVE;
|
||||
|
||||
/**
|
||||
* Report title.
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class Template implements \JsonSerializable
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
public int $id = 0;
|
||||
|
||||
/**
|
||||
* Unit.
|
||||
|
|
@ -54,7 +54,7 @@ class Template implements \JsonSerializable
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private int $status = HelperStatus::INACTIVE;
|
||||
public int $status = HelperStatus::INACTIVE;
|
||||
|
||||
/**
|
||||
* Template data type.
|
||||
|
|
|
|||
|
|
@ -23,14 +23,14 @@ $templates = $this->getData('reports');
|
|||
/** @var \Modules\Admin\Models\Account $account */
|
||||
$account = $this->getData('account');
|
||||
|
||||
$accountDir = $account->getId() . ' ' . $account->login;
|
||||
$accountDir = $account->id . ' ' . $account->login;
|
||||
|
||||
/** @var \Modules\Media\Models\Collection[] */
|
||||
$collections = $this->getData('collections');
|
||||
$mediaPath = \urldecode($this->getData('path') ?? '/');
|
||||
|
||||
$previous = empty($templates) ? '{/base}/helper/list' : '{/base}/helper/list?{?}&id=' . \reset($templates)->getId() . '&ptype=p';
|
||||
$next = empty($templates) ? '{/base}/helper/list' : 'helper/list?{?}&id=' . \end($templates)->getId() . '&ptype=n';
|
||||
$previous = empty($templates) ? '{/base}/helper/list' : '{/base}/helper/list?{?}&id=' . \reset($templates)->id . '&ptype=p';
|
||||
$next = empty($templates) ? '{/base}/helper/list' : 'helper/list?{?}&id=' . \end($templates)->id . '&ptype=n';
|
||||
|
||||
echo $this->getData('nav')->render(); ?>
|
||||
<div class="row">
|
||||
|
|
@ -149,11 +149,11 @@ echo $this->getData('nav')->render(); ?>
|
|||
<td><a href="<?= $url; ?>"><i class="fa fa-folder-open-o"></i></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
|
||||
<td>
|
||||
<td><a class="content" href="<?= UriFactory::build('{/base}/profile/single?{?}&for=' . $value->createdBy->getId()); ?>"><?= $this->printHtml($this->renderUserName('%3$s %2$s %1$s', [$value->createdBy->name1, $value->createdBy->name2, $value->createdBy->name3, $value->createdBy->login ?? ''])); ?></a>
|
||||
<td><a class="content" href="<?= UriFactory::build('{/base}/profile/single?{?}&for=' . $value->createdBy->id); ?>"><?= $this->printHtml($this->renderUserName('%3$s %2$s %1$s', [$value->createdBy->name1, $value->createdBy->name2, $value->createdBy->name3, $value->createdBy->login ?? ''])); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->createdAt->format('Y-m-d')); ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php foreach ($templates as $key => $template) : ++$count;
|
||||
$url = UriFactory::build('{/base}/helper/report/view?{?}&id=' . $template->getId()); ?>
|
||||
$url = UriFactory::build('{/base}/helper/report/view?{?}&id=' . $template->id); ?>
|
||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||
<td><label class="checkbox" for="helperList-<?= $key; ?>">
|
||||
<input type="checkbox" id="helperList-<?= $key; ?>" name="helperselect">
|
||||
|
|
@ -165,7 +165,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<?php $tags = $template->getTags(); foreach ($tags as $tag) : ?>
|
||||
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= !empty($tag->icon) ? '<i class="' . $this->printHtml($tag->icon) . '"></i>' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span>
|
||||
<?php endforeach; ?>
|
||||
<td data-label="<?= $this->getHtml('Creator'); ?>"><a class="content" href="<?= UriFactory::build('{/base}/profile/single?{?}&for=' . $template->createdBy->getId()); ?>"><?= $this->printHtml($this->renderUserName('%3$s %2$s %1$s', [$template->createdBy->name1, $template->createdBy->name2, $template->createdBy->name3, $template->createdBy->login ?? ''])); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Creator'); ?>"><a class="content" href="<?= UriFactory::build('{/base}/profile/single?{?}&for=' . $template->createdBy->id); ?>"><?= $this->printHtml($this->renderUserName('%3$s %2$s %1$s', [$template->createdBy->name1, $template->createdBy->name2, $template->createdBy->name3, $template->createdBy->login ?? ''])); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Updated'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($template->createdAt->format('Y-m-d')); ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($count === 0) : ?>
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<div class="col-xs-12 col-md-9">
|
||||
<div class="portlet">
|
||||
<div class="portlet-body">
|
||||
<iframe data-form="iUiSettings" data-name="iframeHelper" id="iHelperFrame" src="<?= UriFactory::build('{/api}helper/report/export/?{?}&id=' . $template->getId()); ?>&u=<?= $this->getData('unit'); ?>" allowfullscreen></iframe>
|
||||
<iframe data-form="iUiSettings" data-name="iframeHelper" id="iHelperFrame" src="<?= UriFactory::build('{/api}helper/report/export/?{?}&id=' . $template->id); ?>&u=<?= $this->getData('unit'); ?>" allowfullscreen></iframe>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -146,7 +146,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<td><?= $this->printHtml($template->name); ?>
|
||||
<tr>
|
||||
<td><?= $this->getHtml('Creator'); ?>
|
||||
<td><a href="<?= UriFactory::build('{/base}/profile/single?for=' . $template->createdBy->getId()); ?>"><?= $this->printHtml($template->createdBy->name1); ?></a>
|
||||
<td><a href="<?= UriFactory::build('{/base}/profile/single?for=' . $template->createdBy->id); ?>"><?= $this->printHtml($template->createdBy->name1); ?></a>
|
||||
<tr>
|
||||
<td><?= $this->getHtml('Created'); ?>
|
||||
<td><?= $template->createdAt->format('Y-m-d'); ?>
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
|
|||
TestUtils::setMember($request, 'files', $files);
|
||||
|
||||
$this->module->apiTemplateCreate($request, $response);
|
||||
self::assertGreaterThan(0, self::$depreciationHelper = $response->get('')['response']->getId());
|
||||
self::assertGreaterThan(0, self::$depreciationHelper = $response->get('')['response']->id);
|
||||
|
||||
\rmdir(__DIR__ . '/temp');
|
||||
}
|
||||
|
|
@ -186,7 +186,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
|
|||
TestUtils::setMember($request, 'files', $files);
|
||||
|
||||
$this->module->apiTemplateCreate($request, $response);
|
||||
self::assertGreaterThan(0, self::$depreciationHelper2 = $response->get('')['response']->getId());
|
||||
self::assertGreaterThan(0, self::$depreciationHelper2 = $response->get('')['response']->id);
|
||||
|
||||
\rmdir(__DIR__ . '/temp');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,6 @@ final class NullReportTest extends \PHPUnit\Framework\TestCase
|
|||
public function testId() : void
|
||||
{
|
||||
$null = new NullReport(2);
|
||||
self::assertEquals(2, $null->getId());
|
||||
self::assertEquals(2, $null->id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,6 @@ final class NullTemplateTest extends \PHPUnit\Framework\TestCase
|
|||
public function testId() : void
|
||||
{
|
||||
$null = new NullTemplate(2);
|
||||
self::assertEquals(2, $null->getId());
|
||||
self::assertEquals(2, $null->id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,12 +169,12 @@ final class ReportMapperTest extends \PHPUnit\Framework\TestCase
|
|||
$report->source = $collection;
|
||||
|
||||
$id = ReportMapper::create()->execute($report);
|
||||
self::assertGreaterThan(0, $report->getId());
|
||||
self::assertEquals($id, $report->getId());
|
||||
self::assertGreaterThan(0, $report->id);
|
||||
self::assertEquals($id, $report->id);
|
||||
|
||||
$reportR = ReportMapper::get()->with('template')->where('id', $report->getId())->execute();
|
||||
$reportR = ReportMapper::get()->with('template')->where('id', $report->id)->execute();
|
||||
self::assertEquals($report->createdAt->format('Y-m-d'), $reportR->createdAt->format('Y-m-d'));
|
||||
self::assertEquals($report->createdBy->getId(), $reportR->createdBy->getId());
|
||||
self::assertEquals($report->createdBy->id, $reportR->createdBy->id);
|
||||
self::assertEquals($report->description, $reportR->description);
|
||||
self::assertEquals($report->title, $reportR->title);
|
||||
self::assertEquals($report->getStatus(), $reportR->getStatus());
|
||||
|
|
|
|||
|
|
@ -44,15 +44,15 @@ final class ReportTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testDefault() : void
|
||||
{
|
||||
self::assertEquals(0, $this->report->getId());
|
||||
self::assertEquals(0, $this->report->createdBy->getId());
|
||||
self::assertEquals(0, $this->report->id);
|
||||
self::assertEquals(0, $this->report->createdBy->id);
|
||||
self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->report->createdAt->format('Y-m-d'));
|
||||
self::assertEquals('', $this->report->title);
|
||||
self::assertEquals(HelperStatus::INACTIVE, $this->report->getStatus());
|
||||
self::assertEquals('', $this->report->description);
|
||||
self::assertEquals('', $this->report->descriptionRaw);
|
||||
self::assertEquals(0, $this->report->template->getId());
|
||||
self::assertEquals(0, $this->report->source->getId());
|
||||
self::assertEquals(0, $this->report->template->id);
|
||||
self::assertEquals(0, $this->report->source->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -63,7 +63,7 @@ final class ReportTest extends \PHPUnit\Framework\TestCase
|
|||
public function testCreatedByInputOutput() : void
|
||||
{
|
||||
$this->report->createdBy = new NullAccount(1);
|
||||
self::assertEquals(1, $this->report->createdBy->getId());
|
||||
self::assertEquals(1, $this->report->createdBy->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -118,7 +118,7 @@ final class ReportTest extends \PHPUnit\Framework\TestCase
|
|||
public function testTemplateInputOutput() : void
|
||||
{
|
||||
$this->report->template = new NullTemplate(11);
|
||||
self::assertEquals(11, $this->report->template->getId());
|
||||
self::assertEquals(11, $this->report->template->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -129,7 +129,7 @@ final class ReportTest extends \PHPUnit\Framework\TestCase
|
|||
public function testSourceInputOutput() : void
|
||||
{
|
||||
$this->report->source = new NullCollection(4);
|
||||
self::assertEquals(4, $this->report->source->getId());
|
||||
self::assertEquals(4, $this->report->source->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -103,12 +103,12 @@ final class TemplateMapperTest extends \PHPUnit\Framework\TestCase
|
|||
$template->source = $collection;
|
||||
|
||||
$id = TemplateMapper::create()->execute($template);
|
||||
self::assertGreaterThan(0, $template->getId());
|
||||
self::assertEquals($id, $template->getId());
|
||||
self::assertGreaterThan(0, $template->id);
|
||||
self::assertEquals($id, $template->id);
|
||||
|
||||
$templateR = TemplateMapper::get()->where('id', $template->getId())->execute();
|
||||
$templateR = TemplateMapper::get()->where('id', $template->id)->execute();
|
||||
self::assertEquals($template->createdAt->format('Y-m-d'), $templateR->createdAt->format('Y-m-d'));
|
||||
self::assertEquals($template->createdBy->getId(), $templateR->createdBy->getId());
|
||||
self::assertEquals($template->createdBy->id, $templateR->createdBy->id);
|
||||
self::assertEquals($template->description, $templateR->description);
|
||||
self::assertEquals($template->descriptionRaw, $templateR->descriptionRaw);
|
||||
self::assertEquals($template->name, $templateR->name);
|
||||
|
|
|
|||
|
|
@ -48,16 +48,16 @@ final class TemplateTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testDefault() : void
|
||||
{
|
||||
self::assertEquals(0, $this->template->getId());
|
||||
self::assertEquals(0, $this->template->unit->getId());
|
||||
self::assertEquals(0, $this->template->createdBy->getId());
|
||||
self::assertEquals(0, $this->template->id);
|
||||
self::assertEquals(0, $this->template->unit->id);
|
||||
self::assertEquals(0, $this->template->createdBy->id);
|
||||
self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->template->createdAt->format('Y-m-d'));
|
||||
self::assertEquals('', $this->template->name);
|
||||
self::assertEquals(HelperStatus::INACTIVE, $this->template->getStatus());
|
||||
self::assertEquals('', $this->template->description);
|
||||
self::assertEquals('', $this->template->descriptionRaw);
|
||||
self::assertEquals([], $this->template->getExpected());
|
||||
self::assertEquals(0, $this->template->source->getId());
|
||||
self::assertEquals(0, $this->template->source->id);
|
||||
self::assertFalse($this->template->isStandalone);
|
||||
self::assertEquals(TemplateDataType::OTHER, $this->template->getDatatype());
|
||||
self::assertInstanceOf(NullReport::class, $this->template->getNewestReport());
|
||||
|
|
@ -71,7 +71,7 @@ final class TemplateTest extends \PHPUnit\Framework\TestCase
|
|||
public function testUnitInputOutput() : void
|
||||
{
|
||||
$this->template->unit = new NullUnit(1);
|
||||
self::assertEquals(1, $this->template->unit->getId());
|
||||
self::assertEquals(1, $this->template->unit->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -82,7 +82,7 @@ final class TemplateTest extends \PHPUnit\Framework\TestCase
|
|||
public function testCreatedByInputOutput() : void
|
||||
{
|
||||
$this->template->createdBy = new NullAccount(1);
|
||||
self::assertEquals(1, $this->template->createdBy->getId());
|
||||
self::assertEquals(1, $this->template->createdBy->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -160,7 +160,7 @@ final class TemplateTest extends \PHPUnit\Framework\TestCase
|
|||
public function testSourceInputOutput() : void
|
||||
{
|
||||
$this->template->source = new NullCollection(4);
|
||||
self::assertEquals(4, $this->template->source->getId());
|
||||
self::assertEquals(4, $this->template->source->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user