From b1489090113c4ac8c437795e6a7ef0be1e79d3ec Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 26 Mar 2022 15:01:45 +0100 Subject: [PATCH] undo serialize deprecation and switch to installExternal api calls --- Admin/Install/Media2.install.json | 1 - Admin/Install/Navigation.install.json | 2 +- Admin/Install/db.json | 12 +- Admin/Routes/Web/Backend.php | 11 + Controller/ApiController.php | 1 - Controller/BackendController.php | 51 ++- Models/BillTypeL11n.php | 3 +- .../user-purchase-bill-dashboard.tpl.php | 2 +- Theme/Backend/user-purchase-bill.tpl.php | 351 ++++++++++++++++++ 9 files changed, 418 insertions(+), 16 deletions(-) create mode 100644 Theme/Backend/user-purchase-bill.tpl.php diff --git a/Admin/Install/Media2.install.json b/Admin/Install/Media2.install.json index 895180f..ac91bf7 100644 --- a/Admin/Install/Media2.install.json +++ b/Admin/Install/Media2.install.json @@ -5,7 +5,6 @@ "name": "Default", "virtualPath": "/Modules/Billing/Templates", "path": "/Modules/Media/Files/Modules/Billing/Templates/Default", - "fixed_names": true, "files": [ "/Modules/Billing/Admin/Install/Media" ], diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json index e746d05..49d8e1e 100755 --- a/Admin/Install/Navigation.install.json +++ b/Admin/Install/Navigation.install.json @@ -258,7 +258,7 @@ ] }, { - "id": 1005109101, + "id": 1005109201, "pid": "/", "type": 3, "subtype": 1, diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 9f26ae0..ae16961 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -95,7 +95,7 @@ }, "billing_bill_status": { "name": "billing_bill_status", - "type": "TINYINT", + "type": "INT", "null": false }, "billing_bill_type": { @@ -464,31 +464,31 @@ }, "billing_bill_element_price_discount_single": { "name": "billing_bill_element_price_discount_single", - "type": "INT", + "type": "BIGINT", "null": true, "default": null }, "billing_bill_element_price_discount_total": { "name": "billing_bill_element_price_discount_total", - "type": "INT", + "type": "BIGINT", "null": true, "default": null }, "billing_bill_element_percentage_discount_single": { "name": "billing_bill_element_percentage_discount_single", - "type": "INT", + "type": "BIGINT", "null": true, "default": null }, "billing_bill_element_percentage_discount_total": { "name": "billing_bill_element_percentage_discount_total", - "type": "INT", + "type": "BIGINT", "null": true, "default": null }, "billing_bill_element_quantity_discount": { "name": "billing_bill_element_quantity_discount", - "type": "INT", + "type": "BIGINT", "null": true, "default": null }, diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index ee8b082..8cbc65d 100755 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -187,4 +187,15 @@ return [ ], ], ], + '^.*/private/purchase/billing/bill.*$' => [ + [ + 'dest' => '\Modules\Billing\Controller\BackendController:viewPrivateBillingPurchaseInvoice', + 'verb' => RouteVerb::GET, + 'permission' => [ + 'module' => BackendController::NAME, + 'type' => PermissionType::READ, + 'state' => PermissionCategory::PRIVATE_DASHBOARD, + ], + ], + ], ]; diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 05df2d3..691d3e4 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -187,7 +187,6 @@ final class ApiController extends Controller ->execute(); } - /** @var \Modules\Billing\Models\BillType $billType */ $billType = BillTypeMapper::get()->where('id', (int) ($request->getData('type') ?? 1))->execute(); diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 6de1de3..a722f60 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace Modules\Billing\Controller; +use Modules\Billing\Models\BillStatus; use Modules\Billing\Models\BillTransferType; use Modules\Billing\Models\PurchaseBillMapper; use Modules\Billing\Models\SalesBillMapper; @@ -694,7 +695,7 @@ final class BackendController extends Controller { $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/Billing/Theme/Backend/user-purchase-bill-upload'); - $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1002901101, $request, $response)); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005109001, $request, $response)); return $view; } @@ -722,6 +723,7 @@ final class BackendController extends Controller ->with('type/l11n') ->with('supplier') ->where('type/transferType', BillTransferType::PURCHASE) + ->where('status', BillStatus::UNPARSED) ->sort('id', OrderType::DESC) ->limit(25); @@ -729,21 +731,18 @@ final class BackendController extends Controller $view->setData('bills', $mapperQuery ->where('id', (int) ($request->getData('id') ?? 0), '<') - ->where('supplier', null, '!=') ->where('type/l11n/language', $response->getLanguage()) ->execute() ); } elseif ($request->getData('ptype') === 'n') { $view->setData('bills', $mapperQuery->where('id', (int) ($request->getData('id') ?? 0), '>') - ->where('supplier', null, '!=') ->where('type/l11n/language', $response->getLanguage()) ->execute() ); } else { $view->setData('bills', $mapperQuery->where('id', 0, '>') - ->where('supplier', null, '!=') ->where('type/l11n/language', $response->getLanguage()) ->execute() ); @@ -751,4 +750,48 @@ final class BackendController extends Controller return $view; } + + /** + * Routing end-point for application behaviour. + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @codeCoverageIgnore + */ + public function viewPrivateBillingPurchaseInvoice(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app->l11nManager, $request, $response); + $view->setTemplate('/Modules/Billing/Theme/Backend/user-purchase-bill'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005109001, $request, $response)); + + $bill = PurchaseBillMapper::get() + ->with('elements') + ->with('media') + ->with('notes') + ->where('id', (int) $request->getData('id')) + ->execute(); + + $view->setData('bill', $bill); + + $previewType = (int) $this->app->appSettings->get( + names: SettingsEnum::PREVIEW_MEDIA_TYPE, + module: self::NAME + )->content; + + $view->setData('previewType', $previewType); + + $originalType = (int) $this->app->appSettings->get( + names: SettingsEnum::ORIGINAL_MEDIA_TYPE, + module: self::NAME + )->content; + + $view->setData('originalType', $originalType); + + return $view; + } } diff --git a/Models/BillTypeL11n.php b/Models/BillTypeL11n.php index a1c8f8e..ed7ad0b 100755 --- a/Models/BillTypeL11n.php +++ b/Models/BillTypeL11n.php @@ -14,7 +14,6 @@ declare(strict_types=1); namespace Modules\Billing\Models; -use phpOMS\Contract\ArrayableInterface; use phpOMS\Localization\ISO639x1Enum; /** @@ -25,7 +24,7 @@ use phpOMS\Localization\ISO639x1Enum; * @link https://karaka.app * @since 1.0.0 */ -class BillTypeL11n implements \JsonSerializable, ArrayableInterface +class BillTypeL11n implements \JsonSerializable { /** * Type ID. diff --git a/Theme/Backend/user-purchase-bill-dashboard.tpl.php b/Theme/Backend/user-purchase-bill-dashboard.tpl.php index efc5969..6050486 100644 --- a/Theme/Backend/user-purchase-bill-dashboard.tpl.php +++ b/Theme/Backend/user-purchase-bill-dashboard.tpl.php @@ -154,7 +154,7 @@ echo $this->getData('nav')->render(); ?> $value) : ++$count; - $url = UriFactory::build('{/prefix}purchase/bill?{?}&id=' . $value->getId()); + $url = UriFactory::build('{/prefix}private/purchase/bill?{?}&id=' . $value->getId()); ?>