mirror of
https://github.com/Karaka-Management/oms-SupplierManagement.git
synced 2026-02-11 14:38:40 +00:00
UI fixes
This commit is contained in:
parent
7043141a0c
commit
937145f166
|
|
@ -44,7 +44,84 @@ class Installer extends InstallerAbstract
|
|||
|
||||
switch ($dbPool->get('core')->getType()) {
|
||||
case DatabaseType::MYSQL:
|
||||
$dbPool->get('core')->con->beginTransaction();
|
||||
|
||||
$dbPool->get('core')->con->prepare(/* todo: maybe add supplier logo? */
|
||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier` (
|
||||
`suppliermgmt_supplier_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`suppliermgmt_supplier_no` int(11) NOT NULL,
|
||||
`suppliermgmt_supplier_no_reverse` varchar(25) DEFAULT NULL,
|
||||
`suppliermgmt_supplier_status` tinyint(2) NOT NULL,
|
||||
`suppliermgmt_supplier_type` tinyint(2) NOT NULL,
|
||||
`suppliermgmt_supplier_taxid` varchar(50) DEFAULT NULL,
|
||||
`suppliermgmt_supplier_info` text DEFAULT NULL,
|
||||
`suppliermgmt_supplier_created_at` datetime NOT NULL,
|
||||
`suppliermgmt_supplier_account` int(11) NOT NULL,
|
||||
PRIMARY KEY (`suppliermgmt_supplier_id`),
|
||||
KEY `suppliermgmt_supplier_account` (`suppliermgmt_supplier_account`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get('core')->con->prepare(
|
||||
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier`
|
||||
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier_ibfk_1` FOREIGN KEY (`suppliermgmt_supplier_account`) REFERENCES `' . $dbPool->get('core')->prefix . 'profile_account` (`profile_account_id`);'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get('core')->con->prepare(
|
||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier_address` (
|
||||
`suppliermgmt_supplier_address_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`suppliermgmt_supplier_address_supplier` int(11) NOT NULL,
|
||||
`suppliermgmt_supplier_address_address` int(11) NOT NULL,
|
||||
`suppliermgmt_supplier_address_type` tinyint(2) NOT NULL,
|
||||
PRIMARY KEY (`suppliermgmt_supplier_address_id`),
|
||||
KEY `suppliermgmt_supplier_address_supplier` (`suppliermgmt_supplier_address_supplier`),
|
||||
KEY `suppliermgmt_supplier_address_address` (`suppliermgmt_supplier_address_address`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get('core')->con->prepare(
|
||||
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier_address`
|
||||
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier_address_ibfk_1` FOREIGN KEY (`suppliermgmt_supplier_address_supplier`) REFERENCES `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier` (`suppliermgmt_supplier_id`),
|
||||
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier_address_ibfk_2` FOREIGN KEY (`suppliermgmt_supplier_address_address`) REFERENCES `' . $dbPool->get('core')->prefix . 'profile_address` (`profile_address_id`);'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get('core')->con->prepare(
|
||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier_contactelement` (
|
||||
`suppliermgmt_supplier_contactelement_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`suppliermgmt_supplier_contactelement_dst` int(11) NOT NULL,
|
||||
`suppliermgmt_supplier_contactelement_src` int(11) NOT NULL,
|
||||
`suppliermgmt_supplier_contactelement_type` tinyint(2) NOT NULL,
|
||||
PRIMARY KEY (`suppliermgmt_supplier_contactelement_id`),
|
||||
KEY `suppliermgmt_supplier_contactelement_dst` (`suppliermgmt_supplier_contactelement_dst`),
|
||||
KEY `suppliermgmt_supplier_contactelement_src` (`suppliermgmt_supplier_contactelement_src`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get('core')->con->prepare(
|
||||
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier_contactelement`
|
||||
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier_contactelement_ibfk_1` FOREIGN KEY (`suppliermgmt_supplier_contactelement_src`) REFERENCES `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier` (`suppliermgmt_supplier_id`),
|
||||
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier_contactelement_ibfk_2` FOREIGN KEY (`suppliermgmt_supplier_contactelement_dst`) REFERENCES `' . $dbPool->get('core')->prefix . 'profile_contactelement` (`profile_contactelement_id`);'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get('core')->con->prepare(
|
||||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier_media` (
|
||||
`suppliermgmt_supplier_media_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`suppliermgmt_supplier_media_dst` int(11) NOT NULL,
|
||||
`suppliermgmt_supplier_media_src` int(11) NOT NULL,
|
||||
`suppliermgmt_supplier_media_type` tinyint(2) NOT NULL,
|
||||
PRIMARY KEY (`suppliermgmt_supplier_media_id`),
|
||||
KEY `suppliermgmt_supplier_media_dst` (`suppliermgmt_supplier_media_dst`),
|
||||
KEY `suppliermgmt_supplier_media_src` (`suppliermgmt_supplier_media_src`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get('core')->con->prepare(
|
||||
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier_media`
|
||||
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier_media_ibfk_1` FOREIGN KEY (`suppliermgmt_supplier_media_src`) REFERENCES `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier` (`suppliermgmt_supplier_id`),
|
||||
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'suppliermgmt_supplier_media_ibfk_2` FOREIGN KEY (`suppliermgmt_supplier_media_dst`) REFERENCES `' . $dbPool->get('core')->prefix . 'media` (`media_id`);'
|
||||
)->execute();
|
||||
|
||||
$dbPool->get('core')->con->commit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
168
Models/Supplier.php
Normal file
168
Models/Supplier.php
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
namespace Modules\SupplierManagement\Models;
|
||||
|
||||
use Modules\Media\Models\Media;
|
||||
use Modules\Profile\Models\Profile;
|
||||
|
||||
/**
|
||||
* Account class.
|
||||
*
|
||||
* @category Modules
|
||||
* @package Modules\Admin
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @license OMS License 1.0
|
||||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Supplier
|
||||
{
|
||||
private $id = 0;
|
||||
|
||||
private $number = 0;
|
||||
|
||||
private $numberReverse = 0;
|
||||
|
||||
private $status = 0;
|
||||
|
||||
private $type = 0;
|
||||
|
||||
private $taxId = '';
|
||||
|
||||
private $info = '';
|
||||
|
||||
private $createdAt = null;
|
||||
|
||||
private $profile = null;
|
||||
|
||||
private $files = [];
|
||||
|
||||
private $contactElements = [];
|
||||
|
||||
private $address = [];
|
||||
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->createdAt = new \DateTime('now');
|
||||
$this->profile = new Profile();
|
||||
}
|
||||
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getNumber() : int
|
||||
{
|
||||
return $this->number;
|
||||
}
|
||||
|
||||
public function setNumber(int $number) /* : void */
|
||||
{
|
||||
$this->number = $number;
|
||||
}
|
||||
|
||||
public function getReverseNumber()
|
||||
{
|
||||
return $this->numberReverse;
|
||||
}
|
||||
|
||||
public function setReverseNumber($rev_no) /* : void */
|
||||
{
|
||||
if (!is_scalar($rev_no)) {
|
||||
throw new \Exception();
|
||||
}
|
||||
|
||||
$this->numberReverse = $rev_no;
|
||||
}
|
||||
|
||||
public function getStatus() : int
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function setStatus(int $status) /* : void */
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function getType() : int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType(int $type) /* : void */
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function getTaxId() : string
|
||||
{
|
||||
return $this->taxId;
|
||||
}
|
||||
|
||||
public function setTaxId(string $taxId) /* : void */
|
||||
{
|
||||
$this->taxId = $taxId;
|
||||
}
|
||||
|
||||
public function getInfo() : string
|
||||
{
|
||||
return $this->info;
|
||||
}
|
||||
|
||||
public function setInfo(string $info) /* : void */
|
||||
{
|
||||
$this->info = $info;
|
||||
}
|
||||
|
||||
public function getCreatedAt() : \DateTime
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function getProfile() : Profile
|
||||
{
|
||||
return $this->profile;
|
||||
}
|
||||
|
||||
public function setProfile(Profile $profile) /* : void */
|
||||
{
|
||||
$this->profile = $profile;
|
||||
}
|
||||
|
||||
public function getFiles() : array
|
||||
{
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
public function addFile(Media $file) /* : void */
|
||||
{
|
||||
$this->files[] = $file;
|
||||
}
|
||||
|
||||
public function getAddresses() : array
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
public function getContactElements() : array
|
||||
{
|
||||
return $this->contactElements;
|
||||
}
|
||||
}
|
||||
165
Models/SupplierMapper.php
Normal file
165
Models/SupplierMapper.php
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
namespace Modules\SupplierManagement\Models;
|
||||
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
use Modules\Profile\Models\ProfileMapper;
|
||||
use Modules\Profile\Models\ContactElement;
|
||||
use Modules\Profile\Models\ContactElementMapper;
|
||||
use Modules\Profile\Models\ContactMapper;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Query\Builder;
|
||||
use phpOMS\DataStorage\Database\Query\Column;
|
||||
use phpOMS\DataStorage\Database\RelationType;
|
||||
|
||||
class SupplierMapper extends DataMapperAbstract
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $columns = [
|
||||
'suppliermgmt_supplier_id' => ['name' => 'suppliermgmt_supplier_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'suppliermgmt_supplier_no' => ['name' => 'suppliermgmt_supplier_no', 'type' => 'int', 'internal' => 'number'],
|
||||
'suppliermgmt_supplier_no_reverse' => ['name' => 'suppliermgmt_supplier_no_reverse', 'type' => 'string', 'internal' => 'numberReverse'],
|
||||
'suppliermgmt_supplier_status' => ['name' => 'suppliermgmt_supplier_status', 'type' => 'int', 'internal' => 'status'],
|
||||
'suppliermgmt_supplier_type' => ['name' => 'suppliermgmt_supplier_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'suppliermgmt_supplier_taxid' => ['name' => 'suppliermgmt_supplier_taxid', 'type' => 'string', 'internal' => 'taxId'],
|
||||
'suppliermgmt_supplier_info' => ['name' => 'suppliermgmt_supplier_info', 'type' => 'string', 'internal' => 'info'],
|
||||
'suppliermgmt_supplier_created_at' => ['name' => 'suppliermgmt_supplier_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'],
|
||||
'suppliermgmt_supplier_account' => ['name' => 'suppliermgmt_supplier_account', 'type' => 'int', 'internal' => 'profile'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $table = 'suppliermgmt_supplier';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $primaryField = 'suppliermgmt_supplier_id';
|
||||
|
||||
/**
|
||||
* Created at column
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $createdAt = 'suppliermgmt_supplier_created_at';
|
||||
|
||||
/**
|
||||
* Has one relation.
|
||||
*
|
||||
* @var array
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static $ownsOne = [
|
||||
'profile' => [
|
||||
'mapper' => ProfileMapper::class,
|
||||
'src' => 'suppliermgmt_supplier_account',
|
||||
],
|
||||
];
|
||||
|
||||
protected static $hasMany = [
|
||||
'files' => [
|
||||
'mapper' => MediaMapper::class, /* mapper of the related object */
|
||||
'table' => 'suppliermgmt_supplier_media', /* table of the related object, null if no relation table is used (many->1) */
|
||||
'dst' => 'suppliermgmt_supplier_media_dst',
|
||||
'src' => 'suppliermgmt_supplier_media_src',
|
||||
],
|
||||
'contactElements' => [
|
||||
'mapper' => ContactElementMapper::class,
|
||||
'table' => 'suppliermgmt_supplier_contactelement',
|
||||
'dst' => 'suppliermgmt_supplier_contactelement_dst',
|
||||
'src' => 'suppliermgmt_supplier_contactelement_src',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Create object.
|
||||
*
|
||||
* @param mixed $obj Object
|
||||
* @param int $relations Behavior for relations creation
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function create($obj, int $relations = RelationType::ALL)
|
||||
{
|
||||
try {
|
||||
$objId = parent::create($obj, $relations);
|
||||
|
||||
if($objId === null || !is_scalar($objId)) {
|
||||
return $objId;
|
||||
}
|
||||
|
||||
$query = new Builder(self::$db);
|
||||
|
||||
$query->prefix(self::$db->getPrefix())
|
||||
->insert(
|
||||
'account_permission_account',
|
||||
'account_permission_from',
|
||||
'account_permission_for',
|
||||
'account_permission_id1',
|
||||
'account_permission_id2',
|
||||
'account_permission_r',
|
||||
'account_permission_w',
|
||||
'account_permission_m',
|
||||
'account_permission_d',
|
||||
'account_permission_p'
|
||||
)
|
||||
->into('account_permission')
|
||||
->values(1, 'suppliermgmt_supplier', 'suppliermgmt_supplier', 1, $objId, 1, 1, 1, 1, 1);
|
||||
|
||||
self::$db->con->prepare($query->toSql())->execute();
|
||||
} catch (\Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $objId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object.
|
||||
*
|
||||
* @param mixed $primaryKey Key
|
||||
* @param int $relations Load relations
|
||||
* @param mixed $fill Object to fill
|
||||
*
|
||||
* @return supplier
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function get($primaryKey, int $relations = RelationType::ALL, $fill = null)
|
||||
{
|
||||
return parent::get((int) $primaryKey, $relations, $fill);
|
||||
}
|
||||
}
|
||||
|
|
@ -21,28 +21,31 @@ $footerView->setPage(1);
|
|||
|
||||
echo $this->getData('nav')->render(); ?>
|
||||
|
||||
|
||||
<div class="box w-100">
|
||||
<table class="table red">
|
||||
<caption><?= $this->getText('Suppliers') ?></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $this->getText('ID', 0, 0); ?>
|
||||
<td><?= $this->getText('Name1'); ?>
|
||||
<td><?= $this->getText('Name2'); ?>
|
||||
<td class="wf-100"><?= $this->getText('Name3'); ?>
|
||||
<td><?= $this->getText('City'); ?>
|
||||
<td><?= $this->getText('Zip'); ?>
|
||||
<td><?= $this->getText('Address'); ?>
|
||||
<td><?= $this->getText('Country'); ?>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="8"><?= $footerView->render(); ?>
|
||||
<tbody>
|
||||
<?php $count = 0; foreach([] as $key => $value) : $count++; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php if($count === 0) : ?>
|
||||
<tr><td colspan="8" class="empty"><?= $this->getText('Empty', 0, 0); ?>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="box wf-100">
|
||||
<table class="table red">
|
||||
<caption><?= $this->getText('Suppliers') ?></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?= $this->getText('ID', 0, 0); ?>
|
||||
<td><?= $this->getText('Name1'); ?>
|
||||
<td><?= $this->getText('Name2'); ?>
|
||||
<td class="wf-100"><?= $this->getText('Name3'); ?>
|
||||
<td><?= $this->getText('City'); ?>
|
||||
<td><?= $this->getText('Zip'); ?>
|
||||
<td><?= $this->getText('Address'); ?>
|
||||
<td><?= $this->getText('Country'); ?>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="8"><?= $footerView->render(); ?>
|
||||
<tbody>
|
||||
<?php $count = 0; foreach([] as $key => $value) : $count++; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php if($count === 0) : ?>
|
||||
<tr><td colspan="8" class="empty"><?= $this->getText('Empty', 0, 0); ?>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user