mirror of
https://github.com/Karaka-Management/oms-ClientManagement.git
synced 2026-02-12 14:58:43 +00:00
prepare for data import in demo
This commit is contained in:
parent
4087791396
commit
edfef0d093
|
|
@ -12,7 +12,8 @@
|
||||||
"clientmgmt_client_no": {
|
"clientmgmt_client_no": {
|
||||||
"name": "clientmgmt_client_no",
|
"name": "clientmgmt_client_no",
|
||||||
"type": "VARCHAR(255)",
|
"type": "VARCHAR(255)",
|
||||||
"null": false
|
"null": false,
|
||||||
|
"unique": true
|
||||||
},
|
},
|
||||||
"clientmgmt_client_no_reverse": {
|
"clientmgmt_client_no_reverse": {
|
||||||
"name": "clientmgmt_client_no_reverse",
|
"name": "clientmgmt_client_no_reverse",
|
||||||
|
|
@ -39,8 +40,8 @@
|
||||||
"type": "DATETIME",
|
"type": "DATETIME",
|
||||||
"null": false
|
"null": false
|
||||||
},
|
},
|
||||||
"clientmgmt_client_account": {
|
"clientmgmt_client_profile": {
|
||||||
"name": "clientmgmt_client_account",
|
"name": "clientmgmt_client_profile",
|
||||||
"type": "INT",
|
"type": "INT",
|
||||||
"null": false,
|
"null": false,
|
||||||
"foreignTable": "profile_account",
|
"foreignTable": "profile_account",
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ final class BackendController extends Controller
|
||||||
$view->setTemplate('/Modules/ClientManagement/Theme/Backend/clients-list');
|
$view->setTemplate('/Modules/ClientManagement/Theme/Backend/clients-list');
|
||||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003102001, $request, $response));
|
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003102001, $request, $response));
|
||||||
|
|
||||||
$client = ClientMapper::getNewest(50);
|
$client = ClientMapper::getAll();
|
||||||
$view->addData('client', $client);
|
$view->addData('client', $client);
|
||||||
|
|
||||||
return $view;
|
return $view;
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class Client
|
||||||
|
|
||||||
private \DateTime $createdAt;
|
private \DateTime $createdAt;
|
||||||
|
|
||||||
private $profile = null;
|
private Profile $profile;
|
||||||
|
|
||||||
private array $files = [];
|
private array $files = [];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ final class ClientMapper extends DataMapperAbstract
|
||||||
'clientmgmt_client_type' => ['name' => 'clientmgmt_client_type', 'type' => 'int', 'internal' => 'type'],
|
'clientmgmt_client_type' => ['name' => 'clientmgmt_client_type', 'type' => 'int', 'internal' => 'type'],
|
||||||
'clientmgmt_client_info' => ['name' => 'clientmgmt_client_info', 'type' => 'string', 'internal' => 'info'],
|
'clientmgmt_client_info' => ['name' => 'clientmgmt_client_info', 'type' => 'string', 'internal' => 'info'],
|
||||||
'clientmgmt_client_created_at' => ['name' => 'clientmgmt_client_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
|
'clientmgmt_client_created_at' => ['name' => 'clientmgmt_client_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
|
||||||
'clientmgmt_client_account' => ['name' => 'clientmgmt_client_account', 'type' => 'int', 'internal' => 'profile'],
|
'clientmgmt_client_profile' => ['name' => 'clientmgmt_client_profile', 'type' => 'int', 'internal' => 'profile'],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -79,7 +79,7 @@ final class ClientMapper extends DataMapperAbstract
|
||||||
protected static array $ownsOne = [
|
protected static array $ownsOne = [
|
||||||
'profile' => [
|
'profile' => [
|
||||||
'mapper' => ProfileMapper::class,
|
'mapper' => ProfileMapper::class,
|
||||||
'self' => 'clientmgmt_client_account',
|
'self' => 'clientmgmt_client_profile',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,9 @@ echo $this->getData('nav')->render();
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="portlet highlight-4">
|
<section class="portlet highlight-4">
|
||||||
<div class="portlet-body"></div>
|
<div class="portlet-body">
|
||||||
|
<textarea class="undecorated"></textarea>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="portlet">
|
<section class="portlet">
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.4
|
||||||
|
*
|
||||||
|
* @package tests
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Modules\ClientManagement\tests\Models;
|
||||||
|
|
||||||
|
use Modules\Admin\Models\NullAccount;
|
||||||
|
use Modules\ClientManagement\Models\Client;
|
||||||
|
use Modules\ClientManagement\Models\ClientMapper;
|
||||||
|
use Modules\Profile\Models\NullProfile;
|
||||||
|
use Modules\Profile\Models\ProfileMapper;
|
||||||
|
use Modules\Profile\Models\Profile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
class ClientMapperTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testCR() : void
|
||||||
|
{
|
||||||
|
$client = new Client();
|
||||||
|
$client->setNumber('123456789');
|
||||||
|
|
||||||
|
// This is required because by default a NullAccount without an ID is created in the Profile model
|
||||||
|
// but NullModels without ids are handled like "null" values which are not allowed for Accounts.
|
||||||
|
$profile = ProfileMapper::getFor(1, 'account');
|
||||||
|
$profile = $profile instanceof NullProfile ? new Profile() : $profile;
|
||||||
|
if ($profile->getAccount()->getId() === 0) {
|
||||||
|
$profile->setAccount(new NullAccount(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
$client->setProfile($profile);
|
||||||
|
|
||||||
|
$id = ClientMapper::create($client);
|
||||||
|
self::assertGreaterThan(0, $client->getId());
|
||||||
|
self::assertEquals($id, $client->getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group volume
|
||||||
|
* @group module
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
public function testClientVolume() : void
|
||||||
|
{
|
||||||
|
$profile = ProfileMapper::getFor(1, 'account');
|
||||||
|
$profile = $profile instanceof NullProfile ? new Profile() : $profile;
|
||||||
|
if ($profile->getAccount()->getId() === 0) {
|
||||||
|
$profile->setAccount(new NullAccount(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($i = 0; $i < 100; ++$i) {
|
||||||
|
$client = new Client();
|
||||||
|
$client->setNumber((string) \mt_rand(100000, 999999));
|
||||||
|
|
||||||
|
$client->setProfile($profile);
|
||||||
|
ClientMapper::create($client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user