bug fixes and item management improvements

This commit is contained in:
Dennis Eichhorn 2023-05-24 18:11:37 +00:00
parent b8cdda7246
commit afa823affa
10 changed files with 471 additions and 8 deletions

View File

@ -5,7 +5,7 @@
"type": 2,
"subtype": 1,
"name": "BusinessExpenses",
"uri": "{/base}/businessexpenses/list",
"uri": "{/base}/businessexpenses/expense/list",
"target": "self",
"icon": null,
"order": 40,
@ -16,10 +16,26 @@
{
"id": 1001002001,
"pid": "/",
"type": 2,
"type": 3,
"subtype": 1,
"name": "List",
"uri": "{/base}/businessexpenses/list",
"uri": "{/base}/businessexpenses/expense/list",
"target": "self",
"icon": null,
"order": 40,
"from": 1001000000,
"permission": { "permission": 2, "type": null, "element": null },
"parent": 1001001001,
"children": [
]
},
{
"id": 1001002002,
"pid": "/",
"type": 3,
"subtype": 1,
"name": "Create",
"uri": "{/base}/businessexpenses/expense/create",
"target": "self",
"icon": null,
"order": 40,

View File

@ -1,3 +1,87 @@
<?php declare(strict_types=1);
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
return [];
use Modules\BusinessExpenses\Controller\BackendController;
use Modules\BusinessExpenses\Models\PermissionCategory;
use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb;
return [
'^.*/businessexpenses/expense/list.*$' => [
[
'dest' => '\Modules\BusinessExpenses\Controller\BackendController:viewBusinessExpensesList',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EXPENSE,
],
],
],
'^.*/businessexpenses/expense/create.*$' => [
[
'dest' => '\Modules\BusinessExpenses\Controller\BackendController:viewBusinessExpensesExpenseCreate',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EXPENSE,
],
],
],
'^.*/businessexpenses/expense(\?.*|$)$' => [
[
'dest' => '\Modules\BusinessExpenses\Controller\BackendController:viewBusinessExpensesExpense',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EXPENSE,
],
],
],
'^.*/businessexpenses/type/list\?.*$' => [
[
'dest' => '\Modules\BusinessExpenses\Controller\BackendController:viewBusinessExpensesTypeList',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EXPENSE,
],
],
],
'^.*/businessexpenses/type(\?.*|$)$' => [
[
'dest' => '\Modules\BusinessExpenses\Controller\BackendController:viewBusinessExpensesType',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::EXPENSE,
],
],
],
'^.*/businessexpenses/type/create.*$' => [
[
'dest' => '\Modules\BusinessExpenses\Controller\BackendController:viewBusinessExpensesTypeCreate',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
'state' => PermissionCategory::EXPENSE,
],
],
],
];

View File

@ -14,6 +14,7 @@ declare(strict_types=1);
namespace Modules\BusinessExpenses\Controller;
use Modules\BusinessExpenses\Models\ExpenseMapper;
use phpOMS\Contract\RenderableInterface;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
@ -49,6 +50,12 @@ final class BackendController extends Controller
$view->setTemplate('/Modules/BusinessExpenses/Theme/Backend/expense-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001001001, $request, $response));
$list = ExpenseMapper::getAll()
->with('from')
->execute();
$view->addData('expenses', $list);
return $view;
}
@ -68,9 +75,16 @@ final class BackendController extends Controller
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/BusinessExpenses/Theme/Backend/expenses-profile');
$view->setTemplate('/Modules/BusinessExpenses/Theme/Backend/expense-single');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001001001, $request, $response));
$expense = ExpenseMapper::get()
->with('from')
->where('id', (int) $request->getData('id'))
->execute();
$view->addData('expense', $expense);
return $view;
}
}

View File

@ -28,7 +28,9 @@ abstract class ExpenseStatus extends Enum
{
public const DRAFT = 1;
public const FINALIZED = 2;
public const OPEN = 2;
public const INACTIVE = 3;
public const APPROVED = 3;
public const DENIED = 3;
}

View File

@ -34,6 +34,7 @@ final class NullExpense extends Expense
public function __construct(int $id = 0)
{
$this->id = $id;
parent::__construct();
}
/**

30
Models/PermissionCategory.php Executable file
View File

@ -0,0 +1,30 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\BusinessExpenses\Models
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\BusinessExpenses\Models;
use phpOMS\Stdlib\Base\Enum;
/**
* Permision state enum.
*
* @package Modules\BusinessExpenses\Models
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
abstract class PermissionCategory extends Enum
{
public const EXPENSE = 1;
}

View File

@ -0,0 +1,34 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\Localization
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
return ['BusinessExpenses' => [
'Expenses' => 'Expenses',
'Status' => 'Status',
'Title' => 'Title',
'Paid' => 'Paid',
'Approved' => 'Approved',
'From' => 'From',
'Amount' => 'Amount',
'Start' => 'Start',
'End' => 'End',
'Description' => 'Description',
'Report' => 'Report',
'Net' => 'Net',
'Gross' => 'Gross',
'Notes' => 'Notes',
'CreatedAt' => 'Created At',
':status1' => 'Draft',
':status2' => 'Finalized',
':status3' => 'Inactive',
]];

View File

@ -0,0 +1,145 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\ClientManagement
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use Modules\BusinessExpenses\Models\ExpenseStatus;
use phpOMS\Uri\UriFactory;
/** @var \phpOMS\Views\View $this */
$expenses = $this->getData('expenses') ?? [];
$expenseStatus = ExpenseStatus::getConstants();
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Expenses'); ?><i class="fa fa-download floatRight download btn"></i></div>
<div class="slider">
<table id="iSalesClientList" class="default sticky">
<thead>
<tr>
<td>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<label for="iSalesClientList-sort-1">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-1">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesClientList-sort-2">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-2">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Status'); ?>
<label for="iSalesClientList-sort-3">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-3">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesClientList-sort-4">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-4">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Paid'); ?>
<label for="iSalesClientList-sort-3">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-3">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesClientList-sort-4">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-4">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<td><?= $this->getHtml('Approved'); ?>
<label for="iSalesClientList-sort-3">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-3">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesClientList-sort-4">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-4">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<td class="wf-100"><?= $this->getHtml('From'); ?>
<label for="iSalesClientList-sort-5">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-5">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesClientList-sort-6">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-6">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Amount'); ?>
<label for="iSalesClientList-sort-7">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-7">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesClientList-sort-8">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-8">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('Start'); ?>
<label for="iSalesClientList-sort-7">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-7">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesClientList-sort-8">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-8">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<td><?= $this->getHtml('End'); ?>
<label for="iSalesClientList-sort-7">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-7">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesClientList-sort-8">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-8">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<tbody>
<?php $count = 0; foreach ($expenses as $key => $value) : ++$count;
$url = UriFactory::build('{/base}/businessexpenses/expense?{?}&id=' . $value->id);
?>
<tr data-href="<?= $url; ?>">
<td>
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $value->id; ?></a>
<td data-label="<?= $this->getHtml('Status'); ?>"><a href="<?= $url; ?>"><?= $this->getHtml(':status' . $value->status); ?></a>
<td class="centerText" data-label="<?= $this->getHtml('Paid'); ?>"><a href="<?= $url; ?>"><i class="fa <?= $value->paid ? 'fa-checkmark' : 'fa-times'; ?>"></i></a>
<td class="centerText" data-label="<?= $this->getHtml('Approved'); ?>"><a href="<?= $url; ?>"><i class="fa <?= $value->approved ? 'fa-checkmark' : 'fa-times'; ?>"></i></a>
<td data-label="<?= $this->getHtml('From'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($this->renderUserName('%3$s %2$s %1$s', [$value->from->name1, $value->from->name2, $value->from->name3])); ?></a>
<td data-label="<?= $this->getHtml('Amount'); ?>"><a href="<?= $url; ?>"><?= $this->getCurrency($value->gross); ?></a>
<td data-label="<?= $this->getHtml('Start'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->start->format('Y-m-d')); ?></a>
<td data-label="<?= $this->getHtml('End'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->end->format('Y-m-d')); ?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="9" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</section>
</div>
</div>

View File

@ -0,0 +1,137 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\ClientManagement
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use Modules\BusinessExpenses\Models\NullExpense;
use phpOMS\Uri\UriFactory;
/** @var \phpOMS\Views\View $this */
$expense = $this->getData('expense') ?? new NullExpense();
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12 col-lg-6">
<section class="portlet highlight-2">
<div class="portlet-body">
<table class="wf-100">
<tr><td><?= $this->getHtml('Net'); ?>:
<td>
<tr><td><?= $this->getHtml('Gross'); ?>:
<td>
</table>
</div>
</section>
</div>
<div class="col-xs-12 col-lg-6">
<section class="portlet highlight-3">
<div class="portlet-body">
<table class="wf-100">
<tr><td><?= $this->getHtml('Approved'); ?>:
<td>
<tr><td><?= $this->getHtml('Paid'); ?>:
<td>
</table>
</div>
</section>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-6">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Report'); ?></div>
<div class="portlet-body">
<div class="form-group">
<label for="iReportFrom"><?= $this->getHtml('From'); ?></label>
<input type="text" id="iReportFrom" name="name" value="<?= $this->printHtml($this->renderUserName('%3$s %2$s %1$s', [$expense->from->name1, $expense->from->name2, $expense->from->name3])); ?>" disabled>
</div>
<div class="form-group">
<label for="iCreatedAt"><?= $this->getHtml('CreatedAt'); ?></label>
<input type="datetime-local" id="iCreatedAt" name="created" value="<?= $expense->createdAt->format('Y-m-d\TH:i'); ?>" disabled>
</div>
<div class="form-group">
<label for="iExpenseStart"><?= $this->getHtml('Start'); ?></label>
<input type="datetime-local" id="iExpenseStart" name="start" value="<?= $expense->start->format('Y-m-d\TH:i'); ?>">
</div>
<div class="form-group">
<label for="iExpenseEnd"><?= $this->getHtml('End'); ?></label>
<input type="datetime-local" id="iExpenseEnd" name="end" value="<?= $expense->end->format('Y-m-d\TH:i'); ?>">
</div>
<div class="form-group">
<label for="iDescription"><?= $this->getHtml('Description'); ?></label>
<textarea id="iDescription" name="description"><?= $this->printHtml($expense->description); ?></textarea>
</div>
</div>
<div class="portlet-foot"></div>
</section>
</div>
<div class="col-xs-12 col-md-6">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Notes'); ?><i class="fa fa-download floatRight download btn"></i></div>
<div class="slider">
<table id="iSalesClientList" class="default sticky">
<thead>
<tr>
<td>
<td class="wf-100"><?= $this->getHtml('Title'); ?>
<label for="iSalesClientList-sort-1">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-1">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesClientList-sort-2">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-2">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<tbody>
</table>
</section>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Expenses'); ?><i class="fa fa-download floatRight download btn"></i></div>
<div class="slider">
<table id="iSalesClientList" class="default sticky">
<thead>
<tr>
<td>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<label for="iSalesClientList-sort-1">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-1">
<i class="sort-asc fa fa-chevron-up"></i>
</label>
<label for="iSalesClientList-sort-2">
<input type="radio" name="iSalesClientList-sort" id="iSalesClientList-sort-2">
<i class="sort-desc fa fa-chevron-down"></i>
</label>
<label>
<i class="filter fa fa-filter"></i>
</label>
<tbody>
</table>
</section>
</div>
</div>