This commit is contained in:
Dennis Eichhorn 2018-12-24 16:08:15 +01:00
parent 275b3a52c6
commit 6a787b81b7
4 changed files with 123 additions and 99 deletions

118
Admin/Install/db.json Normal file
View File

@ -0,0 +1,118 @@
{
"clientmgmt_client": {
"name": "clientmgmt_client",
"fields": {
"clientmgmt_client_id": {
"name": "clientmgmt_client_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"clientmgmt_client_no": {
"name": "clientmgmt_client_no",
"type": "VARCHAR(255)",
"null": false
},
"clientmgmt_client_no_reverse": {
"name": "clientmgmt_client_no_reverse",
"type": "VARCHAR(255)",
"null": false
},
"clientmgmt_client_status": {
"name": "clientmgmt_client_status",
"type": "TINYINT",
"null": false
},
"clientmgmt_client_type": {
"name": "clientmgmt_client_type",
"type": "TINYINT",
"null": false
},
"clientmgmt_client_taxid": {
"name": "clientmgmt_client_taxid",
"type": "INT",
"null": false
},
"clientmgmt_client_info": {
"name": "clientmgmt_client_info",
"type": "TEXT",
"null": false
},
"clientmgmt_client_created_at": {
"name": "clientmgmt_client_created_at",
"type": "DATETIME",
"null": false
},
"clientmgmt_client_account": {
"name": "clientmgmt_client_account",
"type": "INT",
"null": false,
"foreignTable": "profile_account",
"foreignKey": "profile_account_id"
}
}
},
"clientmgmt_client_contactelement": {
"name": "clientmgmt_client_contactelement",
"fields": {
"clientmgmt_client_contactelement_id": {
"name": "clientmgmt_client_contactelement_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"clientmgmt_client_contactelement_dst": {
"name": "clientmgmt_client_contactelement_dst",
"type": "INT",
"null": false,
"foreignTable": "profile_contactelement",
"foreignKey": "profile_contactelement_id"
},
"clientmgmt_client_contactelement_src": {
"name": "clientmgmt_client_contactelement_src",
"type": "INT",
"null": false,
"foreignTable": "clientmgmt_client",
"foreignKey": "clientmgmt_client_id"
},
"clientmgmt_client_contactelement_type": {
"name": "clientmgmt_client_contactelement_type",
"type": "TINYINT",
"null": false
}
}
},
"clientmgmt_client_media": {
"name": "clientmgmt_client_media",
"fields": {
"clientmgmt_client_media_id": {
"name": "clientmgmt_client_media_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"clientmgmt_client_media_dst": {
"name": "clientmgmt_client_media_dst",
"type": "INT",
"null": false,
"foreignTable": "media",
"foreignKey": "media_id"
},
"clientmgmt_client_media_src": {
"name": "clientmgmt_client_media_src",
"type": "INT",
"null": false,
"foreignTable": "clientmgmt_client",
"foreignKey": "clientmgmt_client_id"
},
"clientmgmt_client_media_type": {
"name": "clientmgmt_client_media_type",
"type": "TINYINT",
"null": false
}
}
}
}

View File

@ -14,13 +14,10 @@ declare(strict_types=1);
namespace Modules\ClientManagement\Admin;
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\DataStorage\Database\DatabaseType;
use phpOMS\Module\InfoManager;
use phpOMS\Module\InstallerAbstract;
/**
* Client Management install class.
* Installer class.
*
* @package Modules\ClientManagement\Admin
* @license OMS License 1.0
@ -29,95 +26,4 @@ use phpOMS\Module\InstallerAbstract;
*/
class Installer extends InstallerAbstract
{
/**
* {@inheritdoc}
*/
public static function install(DatabasePool $dbPool, InfoManager $info) : void
{
parent::install($dbPool, $info);
switch ($dbPool->get()->getType()) {
case DatabaseType::MYSQL:
$dbPool->get()->con->beginTransaction();
$dbPool->get()->con->prepare(/* todo: maybe add client logo? */
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'clientmgmt_client` (
`clientmgmt_client_id` int(11) NOT NULL AUTO_INCREMENT,
`clientmgmt_client_no` int(11) NOT NULL,
`clientmgmt_client_no_reverse` varchar(25) DEFAULT NULL,
`clientmgmt_client_status` tinyint(2) NOT NULL,
`clientmgmt_client_type` tinyint(2) NOT NULL,
`clientmgmt_client_taxid` varchar(50) DEFAULT NULL,
`clientmgmt_client_info` text DEFAULT NULL,
`clientmgmt_client_created_at` datetime NOT NULL,
`clientmgmt_client_account` int(11) NOT NULL,
PRIMARY KEY (`clientmgmt_client_id`),
KEY `clientmgmt_client_account` (`clientmgmt_client_account`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute();
$dbPool->get()->con->prepare(
'ALTER TABLE `' . $dbPool->get()->prefix . 'clientmgmt_client`
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'clientmgmt_client_ibfk_1` FOREIGN KEY (`clientmgmt_client_account`) REFERENCES `' . $dbPool->get()->prefix . 'profile_account` (`profile_account_id`);'
)->execute();
$dbPool->get()->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'clientmgmt_client_address` (
`clientmgmt_client_address_id` int(11) NOT NULL AUTO_INCREMENT,
`clientmgmt_client_address_client` int(11) NOT NULL,
`clientmgmt_client_address_address` int(11) NOT NULL,
`clientmgmt_client_address_type` tinyint(2) NOT NULL,
PRIMARY KEY (`clientmgmt_client_address_id`),
KEY `clientmgmt_client_address_client` (`clientmgmt_client_address_client`),
KEY `clientmgmt_client_address_address` (`clientmgmt_client_address_address`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute();
$dbPool->get()->con->prepare(
'ALTER TABLE `' . $dbPool->get()->prefix . 'clientmgmt_client_address`
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'clientmgmt_client_address_ibfk_1` FOREIGN KEY (`clientmgmt_client_address_client`) REFERENCES `' . $dbPool->get()->prefix . 'clientmgmt_client` (`clientmgmt_client_id`),
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'clientmgmt_client_address_ibfk_2` FOREIGN KEY (`clientmgmt_client_address_address`) REFERENCES `' . $dbPool->get()->prefix . 'profile_address` (`profile_address_id`);'
)->execute();
$dbPool->get()->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'clientmgmt_client_contactelement` (
`clientmgmt_client_contactelement_id` int(11) NOT NULL AUTO_INCREMENT,
`clientmgmt_client_contactelement_dst` int(11) NOT NULL,
`clientmgmt_client_contactelement_src` int(11) NOT NULL,
`clientmgmt_client_contactelement_type` tinyint(2) NOT NULL,
PRIMARY KEY (`clientmgmt_client_contactelement_id`),
KEY `clientmgmt_client_contactelement_dst` (`clientmgmt_client_contactelement_dst`),
KEY `clientmgmt_client_contactelement_src` (`clientmgmt_client_contactelement_src`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute();
$dbPool->get()->con->prepare(
'ALTER TABLE `' . $dbPool->get()->prefix . 'clientmgmt_client_contactelement`
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'clientmgmt_client_contactelement_ibfk_1` FOREIGN KEY (`clientmgmt_client_contactelement_src`) REFERENCES `' . $dbPool->get()->prefix . 'clientmgmt_client` (`clientmgmt_client_id`),
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'clientmgmt_client_contactelement_ibfk_2` FOREIGN KEY (`clientmgmt_client_contactelement_dst`) REFERENCES `' . $dbPool->get()->prefix . 'profile_contactelement` (`profile_contactelement_id`);'
)->execute();
$dbPool->get()->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'clientmgmt_client_media` (
`clientmgmt_client_media_id` int(11) NOT NULL AUTO_INCREMENT,
`clientmgmt_client_media_dst` int(11) NOT NULL,
`clientmgmt_client_media_src` int(11) NOT NULL,
`clientmgmt_client_media_type` tinyint(2) NOT NULL,
PRIMARY KEY (`clientmgmt_client_media_id`),
KEY `clientmgmt_client_media_dst` (`clientmgmt_client_media_dst`),
KEY `clientmgmt_client_media_src` (`clientmgmt_client_media_src`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute();
$dbPool->get()->con->prepare(
'ALTER TABLE `' . $dbPool->get()->prefix . 'clientmgmt_client_media`
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'clientmgmt_client_media_ibfk_1` FOREIGN KEY (`clientmgmt_client_media_src`) REFERENCES `' . $dbPool->get()->prefix . 'clientmgmt_client` (`clientmgmt_client_id`),
ADD CONSTRAINT `' . $dbPool->get()->prefix . 'clientmgmt_client_media_ibfk_2` FOREIGN KEY (`clientmgmt_client_media_dst`) REFERENCES `' . $dbPool->get()->prefix . 'media` (`media_id`);'
)->execute();
$dbPool->get()->con->commit();
break;
}
}
}

View File

@ -37,7 +37,7 @@ class Client
private $type = 0;
private $taxId = '';
private $taxId = 0;
private $info = '';
@ -106,12 +106,12 @@ class Client
$this->type = $type;
}
public function getTaxId() : string
public function getTaxId() : int
{
return $this->taxId;
}
public function setTaxId(string $taxId) : void
public function setTaxId(int $taxId) : void
{
$this->taxId = $taxId;
}

View File

@ -34,7 +34,7 @@ final class ClientMapper extends DataMapperAbstract
'clientmgmt_client_no_reverse' => ['name' => 'clientmgmt_client_no_reverse', 'type' => 'string', 'internal' => 'numberReverse'],
'clientmgmt_client_status' => ['name' => 'clientmgmt_client_status', 'type' => 'int', 'internal' => 'status'],
'clientmgmt_client_type' => ['name' => 'clientmgmt_client_type', 'type' => 'int', 'internal' => 'type'],
'clientmgmt_client_taxid' => ['name' => 'clientmgmt_client_taxid', 'type' => 'string', 'internal' => 'taxId'],
'clientmgmt_client_taxid' => ['name' => 'clientmgmt_client_taxid', 'type' => 'int', 'internal' => 'taxId'],
'clientmgmt_client_info' => ['name' => 'clientmgmt_client_info', 'type' => 'string', 'internal' => 'info'],
'clientmgmt_client_created_at' => ['name' => 'clientmgmt_client_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'],
'clientmgmt_client_account' => ['name' => 'clientmgmt_client_account', 'type' => 'int', 'internal' => 'profile'],