diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json index bd077a3..e746d05 100755 --- a/Admin/Install/Navigation.install.json +++ b/Admin/Install/Navigation.install.json @@ -241,6 +241,38 @@ "permission": { "permission": 2, "type": null, "element": null }, "parent": 1003401001, "children": [ + { + "id": 1005109101, + "pid": "/", + "type": 3, + "subtype": 1, + "name": "List", + "uri": "{/prefix}private/purchase/billing/dashboard?{?}", + "target": "self", + "icon": null, + "order": 1, + "from": "Billing", + "permission": { "permission": 2, "type": null, "element": null }, + "parent": 1005109001, + "children": [ + ] + }, + { + "id": 1005109101, + "pid": "/", + "type": 3, + "subtype": 1, + "name": "Upload", + "uri": "{/prefix}private/purchase/billing/upload?{?}", + "target": "self", + "icon": null, + "order": 5, + "from": "Billing", + "permission": { "permission": 2, "type": null, "element": null }, + "parent": 1005109001, + "children": [ + ] + } ] } ] diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 06b640a..9f26ae0 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -631,6 +631,16 @@ "foreignTable": "group", "foreignKey": "group_id" }, + "billing_bill_responsible_status": { + "name": "billing_bill_responsible_status", + "type": "INT", + "null": false + }, + "billing_bill_responsible_type": { + "name": "billing_bill_responsible_type", + "type": "INT", + "null": false + }, "billing_bill_responsible_account": { "name": "billing_bill_responsible_account", "type": "INT", diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index cded2bd..ee8b082 100755 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -51,6 +51,7 @@ return [ ], ], ], + '^.*/purchase/bill/create.*$' => [ [ 'dest' => '\Modules\Billing\Controller\BackendController:viewBillingPurchaseInvoiceCreate', @@ -84,6 +85,18 @@ return [ ], ], ], + '^.*/purchase/bill/upload\?.*$' => [ + [ + 'dest' => '\Modules\Billing\Controller\BackendController:viewBillingPurchaseInvoiceUpload', + 'verb' => RouteVerb::GET, + 'permission' => [ + 'module' => BackendController::NAME, + 'type' => PermissionType::READ, + 'state' => PermissionCategory::SALES_INVOICE, + ], + ], + ], + '^.*/warehouse/bill/create.*$' => [ [ 'dest' => '\Modules\Billing\Controller\BackendController:viewBillingStockInvoiceCreate', @@ -117,6 +130,7 @@ return [ ], ], ], + '^.*/sales/analysis/bill(\?.*|$)$' => [ [ 'dest' => '\Modules\Billing\Controller\BackendController:viewBillAnalysis', @@ -150,4 +164,27 @@ return [ ], ], ], + + '^.*/private/purchase/billing/dashboard.*$' => [ + [ + 'dest' => '\Modules\Billing\Controller\BackendController:viewPrivatePurchaseBillDashboard', + 'verb' => RouteVerb::GET, + 'permission' => [ + 'module' => BackendController::NAME, + 'type' => PermissionType::READ, + 'state' => PermissionCategory::PRIVATE_DASHBOARD, + ], + ], + ], + '^.*/private/purchase/billing/upload.*$' => [ + [ + 'dest' => '\Modules\Billing\Controller\BackendController:viewPrivatePurchaseBillUpload', + 'verb' => RouteVerb::GET, + 'permission' => [ + 'module' => BackendController::NAME, + 'type' => PermissionType::READ, + 'state' => PermissionCategory::PRIVATE_BILL_UPLOAD, + ], + ], + ], ]; diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 34b36a3..6de1de3 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -656,4 +656,99 @@ 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 viewBillingPurchaseInvoiceUpload(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app->l11nManager, $request, $response); + $view->setTemplate('/Modules/Billing/Theme/Backend/purchase-bill-upload'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1002901101, $request, $response)); + + 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 viewPrivatePurchaseBillUpload(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $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)); + + 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 viewPrivatePurchaseBillDashboard(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app->l11nManager, $request, $response); + $view->setTemplate('/Modules/Billing/Theme/Backend/user-purchase-bill-dashboard'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005109001, $request, $response)); + + $mapperQuery = PurchaseBillMapper::getAll() + ->with('type') + ->with('type/l11n') + ->with('supplier') + ->where('type/transferType', BillTransferType::PURCHASE) + ->sort('id', OrderType::DESC) + ->limit(25); + + if ($request->getData('ptype') === 'p') { + $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() + ); + } + + return $view; + } } diff --git a/Models/PermissionCategory.php b/Models/PermissionCategory.php index f051e4a..7e05922 100755 --- a/Models/PermissionCategory.php +++ b/Models/PermissionCategory.php @@ -31,4 +31,9 @@ abstract class PermissionCategory extends Enum public const PURCHASE_INVOICE = 2; public const SALES_ANALYSIS = 4; + + public const PRIVATE_DASHBOARD = 5; + + public const PRIVATE_BILL_UPLOAD = 6; + } diff --git a/Theme/Backend/user-purchase-bill-dashboard.tpl.php b/Theme/Backend/user-purchase-bill-dashboard.tpl.php new file mode 100644 index 0000000..efc5969 --- /dev/null +++ b/Theme/Backend/user-purchase-bill-dashboard.tpl.php @@ -0,0 +1,183 @@ +getData('bills') ?? []; + +echo $this->getData('nav')->render(); ?> + +
+
+
+
getHtml('Bills'); ?>
+
+ + + + + $value) : + ++$count; + $url = UriFactory::build('{/prefix}purchase/bill?{?}&id=' . $value->getId()); + ?> + +
+ getHtml('ID', '0', '0'); ?> + + + + getHtml('Type'); ?> + + + + getHtml('SupplierID'); ?> + + + + getHtml('Supplier'); ?> + + + + getHtml('Address'); ?> + + + + getHtml('Postal'); ?> + + + + getHtml('City'); ?> + + + + getHtml('Country'); ?> + + + + getHtml('Net'); ?> + + + + getHtml('Created'); ?> + + + +
+ getNumber(); ?> + type->getL11n(); ?> + supplier->number; ?> + printHtml($value->billTo); ?> + billAddress; ?> + billZip; ?> + billCity; ?> + billCountry; ?> + netSales->getCurrency(); ?> + createdAt->format('Y-m-d'); ?> + + +
getHtml('Empty', '0', '0'); ?> + +
+
+
+
+