mirror of
https://github.com/Karaka-Management/oms-Organization.git
synced 2026-01-11 16:18:40 +00:00
many fixes and expands and module expansions
This commit is contained in:
parent
18c2de5b9e
commit
9e0e153484
|
|
@ -5,5 +5,24 @@
|
|||
"name": "Organization",
|
||||
"virtualPath": "/Modules",
|
||||
"user": 1
|
||||
},
|
||||
{
|
||||
"type": "collection",
|
||||
"create_directory": true,
|
||||
"name": "Templates",
|
||||
"virtualPath": "/Modules/Organization",
|
||||
"user": 1
|
||||
},
|
||||
{
|
||||
"type": "upload",
|
||||
"create_collection": false,
|
||||
"name": "Letter",
|
||||
"type": "default_letter",
|
||||
"virtualPath": "/Modules/Organization/Templates",
|
||||
"path": "/Modules/Media/Files/Modules/Organization/Templates",
|
||||
"files": [
|
||||
"/Modules/Organization/Admin/Install/Media/letter.doc.php"
|
||||
],
|
||||
"user": 1
|
||||
}
|
||||
]
|
||||
0
Admin/Install/Media/letter.doc.php
Normal file
0
Admin/Install/Media/letter.doc.php
Normal file
|
|
@ -51,6 +51,32 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"organization_unit_media": {
|
||||
"name": "organization_unit_media",
|
||||
"fields": {
|
||||
"organization_unit_media_id": {
|
||||
"name": "organization_unit_media_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"organization_unit_media_src": {
|
||||
"name": "organization_unit_media_src",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "organization_unit",
|
||||
"foreignKey": "organization_unit_id"
|
||||
},
|
||||
"organization_unit_media_dst": {
|
||||
"name": "organization_unit_media_dst",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "media",
|
||||
"foreignKey": "media_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"organization_department": {
|
||||
"name": "organization_department",
|
||||
"fields": {
|
||||
|
|
|
|||
|
|
@ -84,6 +84,14 @@ class Unit implements \JsonSerializable, ArrayableInterface
|
|||
*/
|
||||
protected int $status = Status::INACTIVE;
|
||||
|
||||
/**
|
||||
* Media files
|
||||
*
|
||||
* @var array
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected array $files = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
|
@ -107,6 +115,73 @@ class Unit implements \JsonSerializable, ArrayableInterface
|
|||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get media.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getFiles() : array
|
||||
{
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add media.
|
||||
*
|
||||
* @param Media $file Media
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addFile(Media $file) : void
|
||||
{
|
||||
$this->files[] = $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get media file by type
|
||||
*
|
||||
* @param string $type Media type
|
||||
*
|
||||
* @return Media
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getFileByType(string $type) : Media
|
||||
{
|
||||
foreach ($this->files as $file) {
|
||||
if ($file->type === $type) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
return new NullMedia();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all media files by type
|
||||
*
|
||||
* @param string $type Media type
|
||||
*
|
||||
* @return Media[]
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getFilesByType(string $type) : array
|
||||
{
|
||||
$files = [];
|
||||
foreach ($this->files as $file) {
|
||||
if ($file->type === $type) {
|
||||
$files[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get status
|
||||
*
|
||||
|
|
|
|||
|
|
@ -69,6 +69,21 @@ final class UnitMapper extends DataMapperAbstract
|
|||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $hasMany = [
|
||||
'files' => [
|
||||
'mapper' => MediaMapper::class, /* mapper of the related object */
|
||||
'table' => 'organization_unit_media', /* table of the related object, null if no relation table is used (many->1) */
|
||||
'external' => 'organization_unit_media_dst',
|
||||
'self' => 'organization_unit_media_src',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
data-emptyAfter="true"
|
||||
data-autocomplete="off"
|
||||
data-src="api/organization/find/department?search={!#i<?= $this->getId(); ?>}">
|
||||
<div id="<?= $this->getId(); ?>-dropdown" class="dropdown" data-active="true">
|
||||
<div id="<?= $this->getId(); ?>-popup" class="popup" data-active="true">
|
||||
<table class="default">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
data-emptyAfter="true"
|
||||
data-autocomplete="off"
|
||||
data-src="api/organization/find/position?search={!#i<?= $this->getId(); ?>}">
|
||||
<div id="<?= $this->getId(); ?>-dropdown" class="dropdown" data-active="true">
|
||||
<div id="<?= $this->getId(); ?>-popup" class="popup" data-active="true">
|
||||
<table class="default">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
data-emptyAfter="true"
|
||||
data-autocomplete="off"
|
||||
data-src="api/organization/find/unit?search={!#i<?= $this->getId(); ?>}">
|
||||
<div id="<?= $this->getId(); ?>-dropdown" class="dropdown" data-active="true">
|
||||
<div id="<?= $this->getId(); ?>-popup" class="popup" data-active="true">
|
||||
<table class="default">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user