many small fixes

This commit is contained in:
Dennis Eichhorn 2023-02-10 18:20:57 +01:00
parent 58a8ffad90
commit ff90dba39e
18 changed files with 1459 additions and 802 deletions

View File

@ -5,13 +5,11 @@ declare(strict_types=1);
class MYPDF extends TCPDF class MYPDF extends TCPDF
{ {
public string $fontName = ''; public string $fontName = '';
public int $fontSize = 8; public int $fontSize = 8;
public int $sideMargin = 15; public int $sideMargin = 15;
//Page header //Page header
public function Header() : void { public function Header() {
if ($this->header_xobjid === false) { if ($this->header_xobjid === false) {
$this->header_xobjid = $this->startTemplate($this->w, 0); $this->header_xobjid = $this->startTemplate($this->w, 0);
@ -34,7 +32,7 @@ class MYPDF extends TCPDF
$x = 0; $x = 0;
$dx = 0; $dx = 0;
if (!$this->header_xobj_autoreset && $this->booklet && (($this->page % 2) == 0)) { if (!$this->header_xobj_autoreset AND $this->booklet AND (($this->page % 2) == 0)) {
// adjust margins for booklet mode // adjust margins for booklet mode
$dx = ($this->original_lMargin - $this->original_rMargin); $dx = ($this->original_lMargin - $this->original_rMargin);
} }
@ -53,7 +51,7 @@ class MYPDF extends TCPDF
} }
// Page footer // Page footer
public function Footer() : void { public function Footer() {
$this->SetY(-25); $this->SetY(-25);
$this->SetFont('helvetica', 'I', 7); $this->SetFont('helvetica', 'I', 7);
@ -82,15 +80,56 @@ class MYPDF extends TCPDF
$pdf = new MYPDF('P', 'mm', 'A4', true, 'UTF-8', false); $pdf = new MYPDF('P', 'mm', 'A4', true, 'UTF-8', false);
$creator = $this->getData('bill_creator') ?? 'Jingga';
$author = 'Jingga';
$title = $this->getData('bill_title') ?? 'Invoice';
$subtitle = $this->getData('bill_subtitle') ?? 'Sub title';
$keywords = $this->getData('keywords') ?? [];
$logoName = $this->getData('bill_logo_name') ?? 'Jingga';
$slogan = $this->getData('bill_slogan') ?? 'Business solutions made simple.';
$legalCompanyName = $this->getData('legal_company_name') ?? 'Jingga e.K.';
$companyAddress = $this->getData('bill_company_address') ?? 'Gartenstr. 26';
$companyCity = $this->getData('bill_company_city') ?? '61206 Woellstadt';
$companyCEO = $this->getData('bill_company_ceo') ?? 'Dennis Eichhorn';
$companyWebsite = $this->getData('bill_company_website') ?? 'www.jingga.app';
$companyEmail = $this->getData('bill_company_email') ?? 'info@jingga.app';
$companyPhone = $this->getData('bill_company_phone') ?? '+49 0152 ????';
$taxOffice = $this->getData('bill_company_tax_office') ?? 'HRB';
$taxId = $this->getData('bill_company_tax_id') ?? 'DE ?????????';
$vatId = $this->getData('bill_company_vat_id') ?? 'DE ??????';
$bankName = $this->getData('bill_company_bank_name') ?? 'Volksbank Mittelhessen';
$bic = $this->getData('bill_company_bic') ?? '';
$iban = $this->getData('bill_company_iban') ?? '';
$billTypeName = $this->getData('bill_type_name') ?? 'INVOICE';
$billInvoiceNumber = $this->getData('bill_invoice_no') ?? '';
$billInvoiceDate = $this->getData('bill_invoice_date') ?? '';
$billServiceDate = $this->getData('bill_service_date') ?? '';
$billCustomerNo = $this->getData('bill_customer_no') ?? '';
$billPO = $this->getData('bill_po') ?? '';
$billDueDate = $this->getData('bill_due_date') ?? '';
$invoiceLines = $this->getData('bill_lines') ?? [];
$paymentTerms = $this->getData('bill_payment_terms') ?? '';
$terms = $this->getData('bill_terms') ?? 'https://jingga.app/terms';
$taxes = $this->getData('bill_taxes') ?? ['19%' => '0.00'];
$currency = $this->getData('bill_currency') ?? 'EUR';
// set document information // set document information
$pdf->SetCreator("Jingga"); $pdf->SetCreator($creator);
$pdf->SetAuthor('Jingga'); $pdf->SetAuthor($author);
$pdf->SetTitle('Invoice'); $pdf->SetTitle($title);
$pdf->SetSubject('Sub title'); $pdf->SetSubject($subtitle);
$pdf->SetKeywords('Invoice, 2022'); $pdf->SetKeywords(\implode(', ', $keywords));
// set default header data // set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, 'Jingga', 'Business solutions made simple.'); $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $logoName, $slogan);
// set header and footer fonts // set header and footer fonts
$pdf->SetHeaderFont([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]); $pdf->SetHeaderFont([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]);
@ -123,8 +162,7 @@ $lineHeight = ($lineHeight - $pdf->getY()) / 3;
// Document head // Document head
$pdf->SetFont('helvetica', 'B', 20); $pdf->SetFont('helvetica', 'B', 20);
$title = 'INVOICE'; $titleWidth = $pdf->GetStringWidth($billTypeName, 'helvetica', 'B', 20);
$titleWidth = $pdf->GetStringWidth($title, 'helvetica', 'B', 20);
$pdf->SetXY( $pdf->SetXY(
$rightPos = ($pdf->getPageWidth() - $titleWidth - ($titleWidth < 55 ? 55 : 35) + 15), $rightPos = ($pdf->getPageWidth() - $titleWidth - ($titleWidth < 55 ? 55 : 35) + 15),
@ -134,7 +172,7 @@ $pdf->SetXY(
$pdf->SetTextColor(255, 255, 255); $pdf->SetTextColor(255, 255, 255);
$pdf->SetFillColor(255, 162, 7); $pdf->SetFillColor(255, 162, 7);
$pdf->Cell($pdf->getPageWidth() - $rightPos - 15, 0, $title, 0, 0, 'L', true); $pdf->Cell($pdf->getPageWidth() - $rightPos - 15, 0, $billTypeName, 0, 0, 'L', true);
$pdf->SetFont('helvetica', '', 8); $pdf->SetFont('helvetica', '', 8);
$pdf->SetTextColor(255, 162, 7); $pdf->SetTextColor(255, 162, 7);
@ -180,8 +218,8 @@ $data = [
]; ];
// Header // Header
$w = [$pdf->getPageWidth() - 20 - 20 - 20 - 2 * 15, 20, 20, 20]; $w = array($pdf->getPageWidth() - 20 - 20 - 20 - 2*15, 20, 20, 20);
$num_headers = \count($header); $num_headers = count($header);
$pdf->setCellPadding(1, 1, 1, 1); $pdf->setCellPadding(1, 1, 1, 1);

View File

@ -8,7 +8,7 @@
"uri": "{/lang}/{/app}/sales/bill/list", "uri": "{/lang}/{/app}/sales/bill/list",
"target": "self", "target": "self",
"icon": null, "icon": null,
"order": 5, "order": 10,
"from": "Billing", "from": "Billing",
"permission": { "permission": 2, "category": null, "element": null }, "permission": { "permission": 2, "category": null, "element": null },
"parent": 1001601001, "parent": 1001601001,
@ -69,7 +69,7 @@
"uri": "{/lang}/{/app}/purchase/bill/list", "uri": "{/lang}/{/app}/purchase/bill/list",
"target": "self", "target": "self",
"icon": null, "icon": null,
"order": 5, "order": 10,
"from": "Billing", "from": "Billing",
"permission": { "permission": 2, "category": null, "element": null }, "permission": { "permission": 2, "category": null, "element": null },
"parent": 1002101001, "parent": 1002101001,

View File

@ -1,4 +1,185 @@
{ {
"billing_prices": {
"name": "billing_prices",
"fields": {
"billing_prices_id": {
"name": "billing_prices_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"billing_prices_name": {
"name": "billing_prices_name",
"type": "VARCHAR(255)",
"null": false
},
"billing_prices_promocode": {
"name": "billing_prices_promocode",
"type": "INT",
"null": false
},
"billing_prices_item": {
"name": "billing_prices_item",
"type": "INT",
"null": true,
"default": null,
"foreignTable": "itemmgmt_item",
"foreignKey": "itemmgmt_item_id"
},
"billing_prices_itemgroup": {
"name": "billing_prices_itemgroup",
"type": "INT",
"null": true,
"default": null,
"foreignTable": "itemmgmt_attr_value",
"foreignKey": "itemmgmt_attr_value_id"
},
"billing_prices_itemsegment": {
"name": "billing_prices_itemsegment",
"type": "INT",
"null": true,
"default": null,
"foreignTable": "itemmgmt_attr_value",
"foreignKey": "itemmgmt_attr_value_id"
},
"billing_prices_itemsection": {
"name": "billing_prices_itemsection",
"type": "INT",
"null": true,
"default": null,
"foreignTable": "itemmgmt_attr_value",
"foreignKey": "itemmgmt_attr_value_id"
},
"billing_prices_itemtype": {
"name": "billing_prices_itemtype",
"type": "INT",
"null": true,
"default": null,
"foreignTable": "itemmgmt_attr_value",
"foreignKey": "itemmgmt_attr_value_id"
},
"billing_prices_client": {
"name": "billing_prices_client",
"type": "INT",
"null": true,
"default": null,
"foreignTable": "clientmgmt_client",
"foreignKey": "clientmgmt_client_id"
},
"billing_prices_clientgroup": {
"name": "billing_prices_clientgroup",
"type": "INT",
"null": true,
"default": null,
"foreignTable": "clientmgmt_attr_value",
"foreignKey": "clientmgmt_attr_value_id"
},
"billing_prices_clientsegment": {
"name": "billing_prices_clientsegment",
"type": "INT",
"null": true,
"default": null,
"foreignTable": "clientmgmt_attr_value",
"foreignKey": "clientmgmt_attr_value_id"
},
"billing_prices_clientsection": {
"name": "billing_prices_clientsection",
"type": "INT",
"null": true,
"default": null,
"foreignTable": "clientmgmt_attr_value",
"foreignKey": "clientmgmt_attr_value_id"
},
"billing_prices_clienttype": {
"name": "billing_prices_clienttype",
"type": "INT",
"null": true,
"default": null,
"foreignTable": "clientmgmt_attr_value",
"foreignKey": "clientmgmt_attr_value_id"
},
"billing_prices_clientcountry": {
"name": "billing_prices_clientcountry",
"type": "VARCHAR(2)",
"null": true,
"default": null,
"foreignTable": "country",
"foreignKey": "country_code2"
},
"billing_prices_supplier": {
"name": "billing_prices_supplier",
"type": "INT",
"null": true,
"default": null,
"foreignTable": "suppliermgmt_supplier",
"foreignKey": "suppliermgmt_supplier_id"
},
"billing_prices_unit": {
"name": "billing_prices_unit",
"type": "INT",
"null": true,
"default": null,
"foreignTable": "unit",
"foreignKey": "unit_id"
},
"billing_prices_type": {
"name": "billing_prices_type",
"type": "TINYINT(1)",
"null": false
},
"billing_prices_quantity": {
"name": "billing_prices_quantity",
"type": "BIGINT",
"null": false
},
"billing_prices_price": {
"name": "billing_prices_price",
"type": "BIGINT",
"null": false
},
"billing_prices_discount": {
"name": "billing_prices_discount",
"type": "BIGINT",
"null": false
},
"billing_prices_discountp": {
"name": "billing_prices_discountp",
"type": "BIGINT",
"null": false
},
"billing_prices_bonus": {
"name": "billing_prices_bonus",
"type": "BIGINT",
"null": false
},
"billing_prices_multiply": {
"name": "billing_prices_multiply",
"type": "TINYINT(1)",
"null": false
},
"billing_prices_currency": {
"name": "billing_prices_currency",
"type": "VARCHAR(3)",
"null": true,
"default": null,
"foreignTable": "currency",
"foreignKey": "currency_code"
},
"billing_prices_start": {
"name": "billing_prices_start",
"type": "DATETIME",
"null": true,
"default": null
},
"billing_prices_end": {
"name": "billing_prices_end",
"type": "DATETIME",
"null": true,
"default": null
}
}
},
"billing_type": { "billing_type": {
"name": "billing_type", "name": "billing_type",
"fields": { "fields": {
@ -19,19 +200,20 @@
"type": "VARCHAR(255)", "type": "VARCHAR(255)",
"null": false "null": false
}, },
"billing_type_template": {
"name": "billing_type_template",
"type": "INT",
"null": false,
"foreignTable": "media",
"foreignKey": "media_id"
},
"billing_type_transfer_type": { "billing_type_transfer_type": {
"description": "What kind of bill is it?", "description": "What kind of bill is it?",
"name": "billing_type_transfer_type", "name": "billing_type_transfer_type",
"type": "TINYINT", "type": "TINYINT",
"null": false "null": false
}, },
"billing_type_default_template": {
"name": "billing_type_default_template",
"type": "INT",
"null": true,
"default": null,
"foreignTable": "media",
"foreignKey": "media_id"
},
"billing_type_transfer_stock": { "billing_type_transfer_stock": {
"description": "Does this bill type move stock?", "description": "Does this bill type move stock?",
"name": "billing_type_transfer_stock", "name": "billing_type_transfer_stock",
@ -46,6 +228,32 @@
} }
} }
}, },
"billing_bill_type_media_rel": {
"name": "billing_bill_type_media_rel",
"fields": {
"billing_bill_type_media_rel_id": {
"name": "billing_bill_type_media_rel_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"billing_bill_type_media_rel_src": {
"name": "billing_bill_type_media_rel_src",
"type": "INT",
"null": false,
"foreignTable": "billing_type",
"foreignKey": "billing_type_id"
},
"billing_bill_type_media_rel_dst": {
"name": "billing_bill_type_media_rel_dst",
"type": "INT",
"null": false,
"foreignTable": "media",
"foreignKey": "media_id"
}
}
},
"billing_type_l11n": { "billing_type_l11n": {
"name": "billing_type_l11n", "name": "billing_type_l11n",
"fields": { "fields": {
@ -115,6 +323,14 @@
"foreignTable": "billing_type", "foreignTable": "billing_type",
"foreignKey": "billing_type_id" "foreignKey": "billing_type_id"
}, },
"billing_bill_template": {
"name": "billing_bill_template",
"type": "INT",
"null": true,
"default": null,
"foreignTable": "media",
"foreignKey": "media_id"
},
"billing_bill_supplier": { "billing_bill_supplier": {
"name": "billing_bill_supplier", "name": "billing_bill_supplier",
"type": "INT", "type": "INT",
@ -285,6 +501,14 @@
"type": "VARCHAR(3)", "type": "VARCHAR(3)",
"null": false "null": false
}, },
"billing_bill_language": {
"name": "billing_bill_language",
"type": "VARCHAR(3)",
"null": true,
"default": null,
"foreignTable": "language",
"foreignKey": "language_639_1"
},
"billing_bill_referral": { "billing_bill_referral": {
"name": "billing_bill_referral", "name": "billing_bill_referral",
"type": "INT", "type": "INT",

View File

@ -4,9 +4,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 1, "transferType": 1,
"transferStock": false, "transferStock": false,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Offer", "en": "Offer",
"en": "Angebot" "de": "Angebot"
} }
}, },
{ {
@ -14,9 +15,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 1, "transferType": 1,
"transferStock": false, "transferStock": false,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Order Confirmation", "en": "Order Confirmation",
"en": "Auftragsbestaetigung" "de": "Auftragsbestaetigung"
} }
}, },
{ {
@ -24,9 +26,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 1, "transferType": 1,
"transferStock": true, "transferStock": true,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Delivery Note", "en": "Delivery Note",
"en": "Lieferschein" "de": "Lieferschein"
} }
}, },
{ {
@ -34,9 +37,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 1, "transferType": 1,
"transferStock": false, "transferStock": false,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Invoice", "en": "Invoice",
"en": "Rechnung" "de": "Rechnung"
} }
}, },
{ {
@ -44,9 +48,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 1, "transferType": 1,
"transferStock": false, "transferStock": false,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Proforma Invoice", "en": "Proforma Invoice",
"en": "Proforma Rechnung" "de": "Proforma Rechnung"
} }
}, },
{ {
@ -54,9 +59,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 1, "transferType": 1,
"transferStock": false, "transferStock": false,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Credit Note", "en": "Credit Note",
"en": "Rechnungskorrektur" "de": "Rechnungskorrektur"
} }
}, },
{ {
@ -64,9 +70,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 1, "transferType": 1,
"transferStock": false, "transferStock": false,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Reverse Invoice", "en": "Reverse Invoice",
"en": "Gutschrift" "de": "Gutschrift"
} }
}, },
{ {
@ -74,9 +81,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 2, "transferType": 2,
"transferStock": false, "transferStock": false,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Offer", "en": "Offer",
"en": "Angebot" "de": "Angebot"
} }
}, },
{ {
@ -84,9 +92,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 2, "transferType": 2,
"transferStock": false, "transferStock": false,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Order Confirmation", "en": "Order Confirmation",
"en": "Auftragsbestaetigung" "de": "Auftragsbestaetigung"
} }
}, },
{ {
@ -94,9 +103,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 2, "transferType": 2,
"transferStock": true, "transferStock": true,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Delivery Note", "en": "Delivery Note",
"en": "Lieferschein" "de": "Lieferschein"
} }
}, },
{ {
@ -104,9 +114,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 2, "transferType": 2,
"transferStock": false, "transferStock": false,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Invoice", "en": "Invoice",
"en": "Rechnung" "de": "Rechnung"
} }
}, },
{ {
@ -114,9 +125,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 2, "transferType": 2,
"transferStock": false, "transferStock": false,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Proforma Invoice", "en": "Proforma Invoice",
"en": "Proforma Rechnung" "de": "Proforma Rechnung"
} }
}, },
{ {
@ -124,9 +136,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 2, "transferType": 2,
"transferStock": false, "transferStock": false,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Credit Note", "en": "Credit Note",
"en": "Rechnungskorrektur" "de": "Rechnungskorrektur"
} }
}, },
{ {
@ -134,9 +147,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 2, "transferType": 2,
"transferStock": false, "transferStock": false,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Reverse Invoice", "en": "Reverse Invoice",
"en": "Gutschrift" "de": "Gutschrift"
} }
}, },
{ {
@ -144,9 +158,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 4, "transferType": 4,
"transferStock": false, "transferStock": false,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Stock Movement", "en": "Stock Movement",
"en": "Lagerumbuchung" "de": "Lagerumbuchung"
} }
}, },
{ {
@ -154,9 +169,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 4, "transferType": 4,
"transferStock": false, "transferStock": false,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Scrapping", "en": "Scrapping",
"en": "Verschrottung" "de": "Verschrottung"
} }
}, },
{ {
@ -164,9 +180,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 1, "transferType": 1,
"transferStock": false, "transferStock": false,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Subscription", "en": "Subscription",
"en": "Abonnement" "de": "Abonnement"
} }
}, },
{ {
@ -174,9 +191,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 1, "transferType": 1,
"transferStock": false, "transferStock": false,
"isTemplate": true,
"l11n": { "l11n": {
"de": "Template", "en": "Template",
"en": "Vorlage" "de": "Vorlage"
} }
}, },
{ {
@ -184,9 +202,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 1, "transferType": 1,
"transferStock": false, "transferStock": false,
"isTemplate": false,
"l11n": { "l11n": {
"de": "Subscription", "en": "Subscription",
"en": "Abonnement" "de": "Abonnement"
} }
}, },
{ {
@ -194,9 +213,10 @@
"numberFormat": "{y}-{id}", "numberFormat": "{y}-{id}",
"transferType": 1, "transferType": 1,
"transferStock": false, "transferStock": false,
"isTemplate": true,
"l11n": { "l11n": {
"de": "Template", "en": "Template",
"en": "Vorlage" "de": "Vorlage"
} }
} }
] ]

View File

@ -95,6 +95,7 @@ final class Installer extends InstallerAbstract
$request->setData('language', \array_keys($type['l11n'])[0] ?? 'en'); $request->setData('language', \array_keys($type['l11n'])[0] ?? 'en');
$request->setData('number_format', $type['numberFormat'] ?? '{id}'); $request->setData('number_format', $type['numberFormat'] ?? '{id}');
$request->setData('transfer_stock', $type['transferStock'] ?? false); $request->setData('transfer_stock', $type['transferStock'] ?? false);
$request->setData('is_template', $type['isTemplate'] ?? false);
$request->setData('transfer_type', $type['transferType'] ?? BillTransferType::SALES); $request->setData('transfer_type', $type['transferType'] ?? BillTransferType::SALES);
$request->setData('template', $template); $request->setData('template', $template);

32
Admin/Routes/Web/Api.php Normal file
View File

@ -0,0 +1,32 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use Modules\Billing\Controller\BackendController;
use Modules\Billing\Models\PermissionCategory;
use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb;
return [
'^.*/bill/render.*$' => [
[
'dest' => '\Modules\Billing\Controller\ApiController:apiPreviewRender',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::NAME,
'type' => PermissionType::CREATE,
'state' => PermissionCategory::SALES_INVOICE,
],
],
],
];

View File

@ -26,6 +26,8 @@ use Modules\Billing\Models\BillTransferType;
use Modules\Billing\Models\BillType; use Modules\Billing\Models\BillType;
use Modules\Billing\Models\BillTypeL11nMapper; use Modules\Billing\Models\BillTypeL11nMapper;
use Modules\Billing\Models\BillTypeMapper; use Modules\Billing\Models\BillTypeMapper;
use Modules\Billing\Models\PricingMapper;
use Modules\Billing\Models\PricingType;
use Modules\Billing\Models\SettingsEnum; use Modules\Billing\Models\SettingsEnum;
use Modules\ClientManagement\Models\ClientMapper; use Modules\ClientManagement\Models\ClientMapper;
use Modules\ItemManagement\Models\ItemMapper; use Modules\ItemManagement\Models\ItemMapper;
@ -47,6 +49,7 @@ use phpOMS\Message\NotificationLevel;
use phpOMS\Message\RequestAbstract; use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract; use phpOMS\Message\ResponseAbstract;
use phpOMS\Model\Message\FormValidation; use phpOMS\Model\Message\FormValidation;
use phpOMS\System\MimeType;
use phpOMS\Uri\HttpUri; use phpOMS\Uri\HttpUri;
use phpOMS\Views\View; use phpOMS\Views\View;
@ -60,6 +63,73 @@ use phpOMS\Views\View;
*/ */
final class ApiController extends Controller final class ApiController extends Controller
{ {
/**
* Api method to find items
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function apiPricingFind(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
// tax based on customer location + item tax definition = matrix
// price based on
// item quantity
// customer price for item / item group
// customer location
$queryMapper = PricingMapper::getAll();
if ($request->hasData('price_name')) {
$queryMapper->where('name', $request->getData('price_name'));
}
$queryMapper->where('promocode', \array_unique([$request->getData('price_promocode'), null]), 'IN');
$queryMapper->where('item', \array_unique([$request->getData('price_item'), null]), 'IN');
$queryMapper->where('itemgroup', \array_unique([$request->getData('price_itemgroup'), null]), 'IN');
$queryMapper->where('itemsegment', \array_unique([$request->getData('price_itemsegment'), null]), 'IN');
$queryMapper->where('itemsection', \array_unique([$request->getData('price_itemsection'), null]), 'IN');
$queryMapper->where('itemtype', \array_unique([$request->getData('price_itemtype'), null]), 'IN');
$queryMapper->where('client', \array_unique([$request->getData('price_client'), null]), 'IN');
$queryMapper->where('clientgroup', \array_unique([$request->getData('price_clientgroup'), null]), 'IN');
$queryMapper->where('clientsegment', \array_unique([$request->getData('price_clientsegment'), null]), 'IN');
$queryMapper->where('clientsection', \array_unique([$request->getData('price_clientsection'), null]), 'IN');
$queryMapper->where('clienttype', \array_unique([$request->getData('price_clienttype'), null]), 'IN');
$queryMapper->where('clientcountry', \array_unique([$request->getData('price_clientcountry'), null]), 'IN');
$queryMapper->where('supplier', \array_unique([$request->getData('price_supplier'), null]), 'IN');
$queryMapper->where('unit', \array_unique([$request->getData('price_unit'), null]), 'IN');
$queryMapper->where('type', $request->getData('price_type', 'int') ?? PricingType::SALES);
$queryMapper->where('currency', array_unique([$request->getData('price_currency'), null]), 'IN');
/*
if ($request->hasData('price_quantity')) {
$whereQuery = new Where();
$whereQuery->where('quantity', (int) $request->getData('price_quantity'), '<=')
->where('quantity', null, '=', 'OR')
$queryMapper->where('quantity', $whereQuery);
}
*/
$result = $queryMapper->execute();
$response->header->set('Content-Type', MimeType::M_JSON, true);
$response->set(
$request->uri->__toString(),
\array_values(
ItemMapper::getAll()
->where('name', '%' . ($request->getData('search') ?? '') . '%', 'LIKE')
->execute()
)
);
}
/** /**
* Api method to update a bill * Api method to update a bill
* *
@ -281,7 +351,6 @@ final class ApiController extends Controller
$request->header->account, $request->header->account,
__DIR__ . '/../../../Modules/Media/Files' . $path, __DIR__ . '/../../../Modules/Media/Files' . $path,
$path, $path,
type: $request->getData('type', 'int'),
pathSettings: PathSettings::FILE_PATH, pathSettings: PathSettings::FILE_PATH,
hasAccountRelation: false, hasAccountRelation: false,
readContent: (bool) ($request->getData('parse_content') ?? false) readContent: (bool) ($request->getData('parse_content') ?? false)
@ -294,11 +363,23 @@ final class ApiController extends Controller
$bill->getId(), $bill->getId(),
$media->getId(), $media->getId(),
BillMapper::class, BillMapper::class,
'bill_media', 'media',
'', '',
$request->getOrigin() $request->getOrigin()
); );
if ($request->hasData('type')) {
$this->createModelRelation(
$request->header->account,
$media->getId(),
$request->getData('type', 'int'),
MediaMapper::class,
'types',
'',
$request->getOrigin()
);
}
if ($collection === null) { if ($collection === null) {
$collection = MediaMapper::getParentCollection($path)->limit(1)->execute(); $collection = MediaMapper::getParentCollection($path)->limit(1)->execute();
@ -311,7 +392,15 @@ final class ApiController extends Controller
} }
} }
CollectionMapper::writer()->createRelationTable('sources', [$media->getId()], $collection->getId()); $this->createModelRelation(
$request->header->account,
$collection->getId(),
$media->getId(),
CollectionMapper::class,
'sources',
'',
$request->getOrigin()
);
} }
} }
@ -320,9 +409,9 @@ final class ApiController extends Controller
$this->createModelRelation( $this->createModelRelation(
$request->header->account, $request->header->account,
$bill->getId(), $bill->getId(),
$media, (int) $media,
BillMapper::class, BillMapper::class,
'bill_media', 'media',
'', '',
$request->getOrigin() $request->getOrigin()
); );
@ -432,7 +521,9 @@ final class ApiController extends Controller
/** @var \Modules\ItemManagement\Models\Item $item */ /** @var \Modules\ItemManagement\Models\Item $item */
$item = ItemMapper::get() $item = ItemMapper::get()
->with('l11n') ->with('l11n')
->with('l11n/type')
->where('id', $element->item) ->where('id', $element->item)
->where('l11n/type/title', ['name1', 'name2', 'name3'], 'IN')
->where('l11n/language', $response->getLanguage()) ->where('l11n/language', $response->getLanguage())
->execute(); ->execute();
@ -502,6 +593,80 @@ final class ApiController extends Controller
return []; return [];
} }
public function apiPreviewRender(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{
Autoloader::addPath(__DIR__ . '/../../../Resources/');
$templateId = $request->getData('bill_template', 'int');
if ($templateId === null) {
$billTypeId = $request->getData('bill_type', 'int');
$billType = BillTypeMapper::get()
->where('id', $billTypeId)
->execute();
$templateId = $billType->defaultTemplate->getId();
}
$template = CollectionMapper::get()
->with('sources')
->where('id', $templateId)
->execute();
require_once __DIR__ . '/../../../Resources/tcpdf/tcpdf.php';
$response->header->set('Content-Type', MimeType::M_PDF, true);
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/' . \substr($template->getSourceByName('bill.pdf.php')->getPath(), 0, -8), 'pdf.php');
$view->setData('bill', $bill);
$view->setData('path', $pdfDir . '/' . $request->getData('bill') . '.pdf');
$view->setData('bill_creator', $request->getData('bill_creator'));
$view->setData('bill_title', $request->getData('bill_title'));
$view->setData('bill_subtitle', $request->getData('bill_subtitle'));
$view->setData('keywords', $request->getData('keywords'));
$view->setData('bill_logo_name', $request->getData('bill_logo_name'));
$view->setData('bill_slogan', $request->getData('bill_slogan'));
$view->setData('legal_company_name', $request->getData('legal_company_name'));
$view->setData('bill_company_address', $request->getData('bill_company_address'));
$view->setData('bill_company_city', $request->getData('bill_company_city'));
$view->setData('bill_company_ceo', $request->getData('bill_company_ceo'));
$view->setData('bill_company_website', $request->getData('bill_company_website'));
$view->setData('bill_company_email', $request->getData('bill_company_email'));
$view->setData('bill_company_phone', $request->getData('bill_company_phone'));
$view->setData('bill_company_tax_office', $request->getData('bill_company_tax_office'));
$view->setData('bill_company_tax_id', $request->getData('bill_company_tax_id'));
$view->setData('bill_company_vat_id', $request->getData('bill_company_vat_id'));
$view->setData('bill_company_bank_name', $request->getData('bill_company_bank_name'));
$view->setData('bill_company_bic', $request->getData('bill_company_bic'));
$view->setData('bill_company_iban', $request->getData('bill_company_iban'));
$view->setData('bill_type_name', $request->getData('bill_type_name'));
$view->setData('bill_invoice_no', $request->getData('bill_invoice_no'));
$view->setData('bill_invoice_date', $request->getData('bill_invoice_date'));
$view->setData('bill_service_date', $request->getData('bill_service_date'));
$view->setData('bill_customer_no', $request->getData('bill_customer_no'));
$view->setData('bill_po', $request->getData('bill_po'));
$view->setData('bill_due_date', $request->getData('bill_due_date'));
$view->setData('bill_start_text', $request->getData('bill_start_text'));
$view->setData('bill_lines', $request->getData('bill_lines'));
$view->setData('bill_end_text', $request->getData('bill_end_text'));
$view->setData('bill_payment_terms', $request->getData('bill_payment_terms'));
$view->setData('bill_terms', $request->getData('bill_terms'));
$view->setData('bill_taxes', $request->getData('bill_taxes'));
$view->setData('bill_currency', $request->getData('bill_currency'));
$pdf = $view->render();
$response->set('', $pdf);
}
/** /**
* Api method to create and archive a bill * Api method to create and archive a bill
* *
@ -517,23 +682,39 @@ final class ApiController extends Controller
*/ */
public function apiBillPdfArchiveCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void public function apiBillPdfArchiveCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
{ {
Autoloader::addPath(__DIR__ . '/../../../Resources/');
/** @var \Modules\Billing\Models\Bill $bill */ /** @var \Modules\Billing\Models\Bill $bill */
$bill = BillMapper::get() $bill = BillMapper::get()
->with('type') ->with('elements')
->with('type/template')
->with('type/template/sources')
->where('id', $request->getData('bill') ?? 0) ->where('id', $request->getData('bill') ?? 0)
->execute(); ->execute();
/** @var \Model\Setting $previewType */ Autoloader::addPath(__DIR__ . '/../../../Resources/');
$previewType = $this->app->appSettings->get(
names: SettingsEnum::PREVIEW_MEDIA_TYPE,
module: self::NAME
);
$template = $bill->type->template; $templateId = $request->getData('bill_template', 'int');
if ($templateId === null) {
$billTypeId = $bill->type->getId();
$billType = BillTypeMapper::get()
->where('id', $billTypeId)
->execute();
$templateId = $billType->defaultTemplate->getId();
}
$template = CollectionMapper::get()
->with('sources')
->where('id', $templateId)
->execute();
require_once __DIR__ . '/../../../Resources/tcpdf/tcpdf.php';
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/' . \substr($template->getSourceByName('bill.pdf.php')->getPath(), 0, -8), 'pdf.php');
/**
@todo: pass data to bill
*/
$pdf = $view->render();
$path = $this->createBillDir($bill); $path = $this->createBillDir($bill);
$pdfDir = __DIR__ . '/../../../Modules/Media/Files' . $path; $pdfDir = __DIR__ . '/../../../Modules/Media/Files' . $path;
@ -548,15 +729,7 @@ final class ApiController extends Controller
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
} }
require_once __DIR__ . '/../../../Resources/tcpdf/tcpdf.php'; \file_put_contents($pdfDir . '/' . $request->getData('bill') . '.pdf', $pdf);
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/' . \substr($template->getSourceByName('bill.pdf.php')->getPath(), 0, -8), 'pdf.php');
$view->setData('bill', $bill);
$view->setData('path', $pdfDir . '/' . $request->getData('bill') . '.pdf');
$pdf = $view->build();
if (!\is_file($pdfDir . '/' . $request->getData('bill') . '.pdf')) { if (!\is_file($pdfDir . '/' . $request->getData('bill') . '.pdf')) {
$response->header->status = RequestStatusCode::R_400; $response->header->status = RequestStatusCode::R_400;
@ -564,7 +737,7 @@ final class ApiController extends Controller
} }
$media = $this->app->moduleManager->get('Media')->createDbEntry( $media = $this->app->moduleManager->get('Media')->createDbEntry(
[ status: [
'status' => UploadStatus::OK, 'status' => UploadStatus::OK,
'name' => $request->getData('bill') . '.pdf', 'name' => $request->getData('bill') . '.pdf',
'path' => $pdfDir, 'path' => $pdfDir,
@ -572,9 +745,12 @@ final class ApiController extends Controller
'size' => \filesize($pdfDir . '/' . $request->getData('bill') . '.pdf'), 'size' => \filesize($pdfDir . '/' . $request->getData('bill') . '.pdf'),
'extension' => 'pdf', 'extension' => 'pdf',
], ],
$request->header->account, account: $request->header->account,
$path, virtualPath: $path,
(int) $previewType->content ip: $request->getOrigin(),
app: $this->app,
readContent: true,
unit: $this->app->unitId
); );
$this->createModelRelation( $this->createModelRelation(
@ -582,7 +758,7 @@ final class ApiController extends Controller
$bill->getId(), $bill->getId(),
$media->getId(), $media->getId(),
BillMapper::class, BillMapper::class,
'bill_media', 'media',
'', '',
$request->getOrigin() $request->getOrigin()
); );
@ -782,10 +958,17 @@ final class ApiController extends Controller
{ {
$billType = new BillType($request->getData('name') ?? ''); $billType = new BillType($request->getData('name') ?? '');
$billType->setL11n((string) ($request->getData('title') ?? ''), $request->getData('language') ?? ISO639x1Enum::_EN); $billType->setL11n((string) ($request->getData('title') ?? ''), $request->getData('language') ?? ISO639x1Enum::_EN);
$billType->template = new NullCollection((int) ($request->getData('template') ?? 0));
$billType->numberFormat = (string) ($request->getData('number_format') ?? '{id}'); $billType->numberFormat = (string) ($request->getData('number_format') ?? '{id}');
$billType->transferStock = (bool) ($request->getData('transfer_stock') ?? false); $billType->transferStock = (bool) ($request->getData('transfer_stock') ?? false);
$billType->isTemplate = (bool) ($request->getData('is_template') ?? false);
$billType->transferType = (int) ($request->getData('transfer_type') ?? BillTransferType::SALES); $billType->transferType = (int) ($request->getData('transfer_type') ?? BillTransferType::SALES);
$billType->defaultTemplate = $request->hasData('template')
? new NullCollection((int) $request->getData('template'))
: null;
if ($request->hasData('template')) {
$billType->addTemplate(new NullCollection((int) $request->getData('template')));
}
return $billType; return $billType;
} }

View File

@ -14,8 +14,12 @@ declare(strict_types=1);
namespace Modules\Billing\Controller; namespace Modules\Billing\Controller;
use Modules\Auditor\Models\AuditMapper;
use Modules\Billing\Models\BillElementMapper;
use Modules\Billing\Models\BillMapper;
use Modules\Billing\Models\BillStatus; use Modules\Billing\Models\BillStatus;
use Modules\Billing\Models\BillTransferType; use Modules\Billing\Models\BillTransferType;
use Modules\Billing\Models\BillTypeMapper;
use Modules\Billing\Models\PurchaseBillMapper; use Modules\Billing\Models\PurchaseBillMapper;
use Modules\Billing\Models\SalesBillMapper; use Modules\Billing\Models\SalesBillMapper;
use Modules\Billing\Models\SettingsEnum; use Modules\Billing\Models\SettingsEnum;
@ -27,6 +31,7 @@ use phpOMS\Localization\ISO3166CharEnum;
use phpOMS\Localization\ISO3166NameEnum; use phpOMS\Localization\ISO3166NameEnum;
use phpOMS\Message\RequestAbstract; use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract; use phpOMS\Message\ResponseAbstract;
use phpOMS\Utils\StringUtils;
use phpOMS\Views\View; use phpOMS\Views\View;
/** /**
@ -108,7 +113,7 @@ final class BackendController extends Controller
public function viewBillingSalesInvoice(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface public function viewBillingSalesInvoice(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface
{ {
$view = new View($this->app->l11nManager, $request, $response); $view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Billing/Theme/Backend/sales-bill'); $view->setTemplate('/Modules/Billing/Theme/Backend/bill-create');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005104001, $request, $response)); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005104001, $request, $response));
$bill = SalesBillMapper::get() $bill = SalesBillMapper::get()
@ -120,13 +125,23 @@ final class BackendController extends Controller
$view->setData('bill', $bill); $view->setData('bill', $bill);
/** @var \Model\Setting $previewType */ $logsBill = AuditMapper::getAll()
$previewType = $this->app->appSettings->get( ->with('createdBy')
names: SettingsEnum::PREVIEW_MEDIA_TYPE, ->where('module', 'Billing')
module: self::NAME ->where('type', StringUtils::intHash(BillMapper::class))
); ->where('ref', $bill->getId())
->execute();
$view->setData('previewType', (int) $previewType->content); $logsElements = AuditMapper::getAll()
->with('createdBy')
->where('module', 'Billing')
->where('type', StringUtils::intHash(BillElementMapper::class))
->where('ref', \array_keys($bill->getElements()), 'IN')
->execute();
$logs = \array_merge($logsBill, $logsElements);
$view->setData('logs', $logs);
return $view; return $view;
} }
@ -146,9 +161,22 @@ final class BackendController extends Controller
public function viewBillingSalesInvoiceCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface public function viewBillingSalesInvoiceCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface
{ {
$view = new View($this->app->l11nManager, $request, $response); $view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Billing/Theme/Backend/invoice-create'); $view->setTemplate('/Modules/Billing/Theme/Backend/bill-create');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005104001, $request, $response)); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005104001, $request, $response));
$billTypes = BillTypeMapper::getAll()
->with('l11n')
->where('isTemplate', false)
->where('transferType', BillTransferType::SALES)
->where('l11n/language', $request->getLanguage())
->execute();
$view->setData('billtypes', $billTypes);
$mediaListView = new \Modules\Media\Theme\Backend\Components\Media\ListView($this->app->l11nManager, $request, $response);
$mediaListView->setTemplate('/Modules/Media/Theme/Backend/Components/Media/list');
$view->addData('medialist', $mediaListView);
return $view; return $view;
} }
@ -167,7 +195,7 @@ final class BackendController extends Controller
public function viewBillingPurchaseInvoiceCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface public function viewBillingPurchaseInvoiceCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface
{ {
$view = new View($this->app->l11nManager, $request, $response); $view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Billing/Theme/Backend/invoice-create'); $view->setTemplate('/Modules/Billing/Theme/Backend/bill-create');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005104001, $request, $response)); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005104001, $request, $response));
return $view; return $view;
@ -188,7 +216,7 @@ final class BackendController extends Controller
public function viewBillingStockInvoiceCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface public function viewBillingStockInvoiceCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : RenderableInterface
{ {
$view = new View($this->app->l11nManager, $request, $response); $view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Billing/Theme/Backend/invoice-create'); $view->setTemplate('/Modules/Billing/Theme/Backend/bill-create');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005104001, $request, $response)); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005104001, $request, $response));
return $view; return $view;

View File

@ -18,10 +18,13 @@ use Modules\Admin\Models\Account;
use Modules\Admin\Models\NullAccount; use Modules\Admin\Models\NullAccount;
use Modules\ClientManagement\Models\Client; use Modules\ClientManagement\Models\Client;
use Modules\Editor\Models\EditorDoc; use Modules\Editor\Models\EditorDoc;
use Modules\Media\Models\Collection;
use Modules\Media\Models\Media; use Modules\Media\Models\Media;
use Modules\Media\Models\NullMedia; use Modules\Media\Models\NullMedia;
use Modules\SupplierManagement\Models\Supplier; use Modules\SupplierManagement\Models\Supplier;
use phpOMS\Localization\ISO3166TwoEnum;
use phpOMS\Localization\ISO4217CharEnum; use phpOMS\Localization\ISO4217CharEnum;
use phpOMS\Localization\ISO639x1Enum;
use phpOMS\Localization\Money; use phpOMS\Localization\Money;
/** /**
@ -42,6 +45,8 @@ class Bill implements \JsonSerializable
*/ */
protected int $id = 0; protected int $id = 0;
public int $source = 0;
/** /**
* Number ID. * Number ID.
* *
@ -66,6 +71,8 @@ class Bill implements \JsonSerializable
*/ */
public BillType $type; public BillType $type;
public ?Collection $template = null;
/** /**
* Bill status. * Bill status.
* *
@ -118,6 +125,8 @@ class Bill implements \JsonSerializable
public ?Supplier $supplier = null; public ?Supplier $supplier = null;
public string $language = ISO639x1Enum::_EN;
/** /**
* Receiver. * Receiver.
* *
@ -214,6 +223,8 @@ class Bill implements \JsonSerializable
*/ */
public string $billCountry = ''; public string $billCountry = '';
public string $billEmail = '';
/** /**
* Person refering for this order. * Person refering for this order.
* *
@ -555,6 +566,32 @@ class Bill implements \JsonSerializable
return $this->currency; return $this->currency;
} }
/**
* Set language.
*
* @param string $language Language
*
* @return void
*
* @since 1.0.0
*/
public function setLanguage(string $language) : void
{
$this->language = $language;
}
/**
* Get language.
*
* @return string
*
* @since 1.0.0
*/
public function getLanguage() : string
{
return $this->language;
}
/** /**
* Get vouchers. * Get vouchers.
* *

View File

@ -17,6 +17,7 @@ namespace Modules\Billing\Models;
use Modules\Admin\Models\AccountMapper; use Modules\Admin\Models\AccountMapper;
use Modules\ClientManagement\Models\ClientMapper; use Modules\ClientManagement\Models\ClientMapper;
use Modules\Editor\Models\EditorDocMapper; use Modules\Editor\Models\EditorDocMapper;
use Modules\Media\Models\CollectionMapper;
use Modules\Media\Models\MediaMapper; use Modules\Media\Models\MediaMapper;
use Modules\SupplierManagement\Models\SupplierMapper; use Modules\SupplierManagement\Models\SupplierMapper;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
@ -42,6 +43,7 @@ class BillMapper extends DataMapperFactory
'billing_bill_number' => ['name' => 'billing_bill_number', 'type' => 'string', 'internal' => 'number'], 'billing_bill_number' => ['name' => 'billing_bill_number', 'type' => 'string', 'internal' => 'number'],
'billing_bill_numberformat' => ['name' => 'billing_bill_numberformat', 'type' => 'string', 'internal' => 'numberFormat'], 'billing_bill_numberformat' => ['name' => 'billing_bill_numberformat', 'type' => 'string', 'internal' => 'numberFormat'],
'billing_bill_type' => ['name' => 'billing_bill_type', 'type' => 'int', 'internal' => 'type'], 'billing_bill_type' => ['name' => 'billing_bill_type', 'type' => 'int', 'internal' => 'type'],
'billing_bill_template' => ['name' => 'billing_bill_template', 'type' => 'int', 'internal' => 'template'],
'billing_bill_header' => ['name' => 'billing_bill_header', 'type' => 'string', 'internal' => 'header'], 'billing_bill_header' => ['name' => 'billing_bill_header', 'type' => 'string', 'internal' => 'header'],
'billing_bill_footer' => ['name' => 'billing_bill_footer', 'type' => 'string', 'internal' => 'footer'], 'billing_bill_footer' => ['name' => 'billing_bill_footer', 'type' => 'string', 'internal' => 'footer'],
'billing_bill_info' => ['name' => 'billing_bill_info', 'type' => 'string', 'internal' => 'info'], 'billing_bill_info' => ['name' => 'billing_bill_info', 'type' => 'string', 'internal' => 'info'],
@ -67,6 +69,7 @@ class BillMapper extends DataMapperFactory
'billing_bill_netdiscount' => ['name' => 'billing_bill_netdiscount', 'type' => 'Serializable', 'internal' => 'netDiscount'], 'billing_bill_netdiscount' => ['name' => 'billing_bill_netdiscount', 'type' => 'Serializable', 'internal' => 'netDiscount'],
'billing_bill_grossdiscount' => ['name' => 'billing_bill_grossdiscount', 'type' => 'Serializable', 'internal' => 'grossDiscount'], 'billing_bill_grossdiscount' => ['name' => 'billing_bill_grossdiscount', 'type' => 'Serializable', 'internal' => 'grossDiscount'],
'billing_bill_currency' => ['name' => 'billing_bill_currency', 'type' => 'string', 'internal' => 'currency'], 'billing_bill_currency' => ['name' => 'billing_bill_currency', 'type' => 'string', 'internal' => 'currency'],
'billing_bill_language' => ['name' => 'billing_bill_language', 'type' => 'string', 'internal' => 'language'],
'billing_bill_referral' => ['name' => 'billing_bill_referral', 'type' => 'int', 'internal' => 'referral'], 'billing_bill_referral' => ['name' => 'billing_bill_referral', 'type' => 'int', 'internal' => 'referral'],
'billing_bill_referral_name' => ['name' => 'billing_bill_referral_name', 'type' => 'string', 'internal' => 'referralName'], 'billing_bill_referral_name' => ['name' => 'billing_bill_referral_name', 'type' => 'string', 'internal' => 'referralName'],
'billing_bill_reference' => ['name' => 'billing_bill_reference', 'type' => 'int', 'internal' => 'reference'], 'billing_bill_reference' => ['name' => 'billing_bill_reference', 'type' => 'int', 'internal' => 'reference'],
@ -125,6 +128,10 @@ class BillMapper extends DataMapperFactory
'mapper' => AccountMapper::class, 'mapper' => AccountMapper::class,
'external' => 'billing_bill_referral', 'external' => 'billing_bill_referral',
], ],
'template' => [
'mapper' => CollectionMapper::class,
'external' => 'billing_bill_template',
],
]; ];
/** /**

View File

@ -39,7 +39,9 @@ class BillType implements \JsonSerializable
public string $name = ''; public string $name = '';
public Collection $template; public array $templates = [];
public ?Collection $defaultTemplate = null;
public string $numberFormat = ''; public string $numberFormat = '';
@ -66,7 +68,6 @@ class BillType implements \JsonSerializable
public function __construct(string $name = '') public function __construct(string $name = '')
{ {
$this->name = $name; $this->name = $name;
$this->template = new NullCollection();
} }
/** /**
@ -120,6 +121,16 @@ class BillType implements \JsonSerializable
return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n; return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n;
} }
public function addTemplate(Collection $template) : void
{
$this->templates[] = $template;
}
public function getTemplates() : array
{
return $this->templates;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@ -15,6 +15,7 @@ declare(strict_types=1);
namespace Modules\Billing\Models; namespace Modules\Billing\Models;
use Modules\Media\Models\CollectionMapper; use Modules\Media\Models\CollectionMapper;
use Modules\Media\Models\MediaMapper;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/** /**
@ -37,25 +38,12 @@ final class BillTypeMapper extends DataMapperFactory
'billing_type_id' => ['name' => 'billing_type_id', 'type' => 'int', 'internal' => 'id'], 'billing_type_id' => ['name' => 'billing_type_id', 'type' => 'int', 'internal' => 'id'],
'billing_type_name' => ['name' => 'billing_type_name', 'type' => 'string', 'internal' => 'name'], 'billing_type_name' => ['name' => 'billing_type_name', 'type' => 'string', 'internal' => 'name'],
'billing_type_number_format' => ['name' => 'billing_type_number_format', 'type' => 'string', 'internal' => 'numberFormat'], 'billing_type_number_format' => ['name' => 'billing_type_number_format', 'type' => 'string', 'internal' => 'numberFormat'],
'billing_type_template' => ['name' => 'billing_type_template', 'type' => 'int', 'internal' => 'template'],
'billing_type_transfer_type' => ['name' => 'billing_type_transfer_type', 'type' => 'int', 'internal' => 'transferType'], 'billing_type_transfer_type' => ['name' => 'billing_type_transfer_type', 'type' => 'int', 'internal' => 'transferType'],
'billing_type_default_template' => ['name' => 'billing_type_default_template', 'type' => 'int', 'internal' => 'defaultTemplate'],
'billing_type_transfer_stock' => ['name' => 'billing_type_transfer_stock', 'type' => 'bool', 'internal' => 'transferStock'], 'billing_type_transfer_stock' => ['name' => 'billing_type_transfer_stock', 'type' => 'bool', 'internal' => 'transferStock'],
'billing_type_is_template' => ['name' => 'billing_type_is_template', 'type' => 'bool', 'internal' => 'isTemplate'], 'billing_type_is_template' => ['name' => 'billing_type_is_template', 'type' => 'bool', 'internal' => 'isTemplate'],
]; ];
/**
* Belongs to.
*
* @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
* @since 1.0.0
*/
public const OWNS_ONE = [
'template' => [
'mapper' => CollectionMapper::class,
'external' => 'billing_type_template',
],
];
/** /**
* Has many relation. * Has many relation.
* *
@ -70,6 +58,25 @@ final class BillTypeMapper extends DataMapperFactory
'column' => 'content', 'column' => 'content',
'external' => null, 'external' => null,
], ],
'templates' => [
'mapper' => MediaMapper::class,
'table' => 'billing_bill_type_media_rel',
'external' => 'billing_bill_type_media_rel_dst',
'self' => 'billing_bill_type_media_rel_src',
],
];
/**
* Has one relation.
*
* @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
* @since 1.0.0
*/
public const OWNS_ONE = [
'defaultTemplate' => [
'mapper' => CollectionMapper::class,
'external' => 'billing_type_default_template',
],
]; ];
/** /**

94
Models/PricingMapper.php Normal file
View File

@ -0,0 +1,94 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\Billing\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Billing\Models;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\DataStorage\Database\Query\Where;
/**
* Billing mapper class.
*
* @package Modules\Billing\Models
* @license OMS License 1.0
* @link https://jingga.app
* @since 1.0.0
*/
final class PricingMapper extends DataMapperFactory
{
/**
* Columns.
*
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
public const COLUMNS = [
'billing_type_id' => ['name' => 'billing_type_id', 'type' => 'int', 'internal' => 'id'],
'billing_type_name' => ['name' => 'billing_type_name', 'type' => 'string', 'internal' => 'name'],
'billing_type_number_format' => ['name' => 'billing_type_number_format', 'type' => 'string', 'internal' => 'numberFormat'],
'billing_type_transfer_type' => ['name' => 'billing_type_transfer_type', 'type' => 'int', 'internal' => 'transferType'],
'billing_type_default_template' => ['name' => 'billing_type_default_template', 'type' => 'int', 'internal' => 'defaultTemplate'],
'billing_type_transfer_stock' => ['name' => 'billing_type_transfer_stock', 'type' => 'bool', 'internal' => 'transferStock'],
'billing_type_is_template' => ['name' => 'billing_type_is_template', 'type' => 'bool', 'internal' => 'isTemplate'],
];
/**
* Model to use by the mapper.
*
* @var class-string
* @since 1.0.0
*/
public const MODEL = Pricing::class;
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
public const TABLE = 'billing_price';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
public const PRIMARYFIELD ='billing_price_id';
public static function findClientPrice() : array
{
/*
select * from prices
where
(promoID = ? OR promoID = null)
AND (itemID = ? OR itemID = null)
AND (itemGroup = IN (?) OR itemGroup = null)
AND (itemSegment = ? OR itemSegment = null)
AND (itemSection = ? OR itemSection = null)
AND (productType = ? OR productType = null)
AND (customerID = ? OR customerID = null)
AND (customerGroup IN (?) OR customerGroup = null)
AND (customerCountry = IN (?) OR customerCountry = null)
AND (quantity < ? OR quantity = null)
AND (start <= ? OR start = null)
AND (end >= ? OR start = null)
AND (unit = ? OR unit = null)
*/
// @todo: allow nested where clause (already possible with the query builder, but not with the mappers)
return [];
}
}

32
Models/PricingType.php Normal file
View File

@ -0,0 +1,32 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\Billing\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Billing\Models;
use phpOMS\Stdlib\Base\Enum;
/**
* Module settings enum.
*
* @package Modules\Billing\Models
* @license OMS License 1.0
* @link https://jingga.app
* @since 1.0.0
*/
abstract class PricingType extends Enum
{
public const SALES = 1;
public const PURCHASE = 2;
}

View File

@ -13,9 +13,12 @@
declare(strict_types=1); declare(strict_types=1);
return ['Billing' => [ return ['Billing' => [
'Amount' => 'Amount',
'Address' => 'Address', 'Address' => 'Address',
'Addresses' => 'Addresses', 'Addresses' => 'Addresses',
'Africa' => 'Africa', 'Africa' => 'Africa',
'Currency' => 'Currency',
'Language' => 'Language',
'AlreadyPaid' => 'Already Paid', 'AlreadyPaid' => 'Already Paid',
'America' => 'America', 'America' => 'America',
'Analyse' => 'Analyse', 'Analyse' => 'Analyse',
@ -23,6 +26,7 @@ return ['Billing' => [
'Asia' => 'Asia', 'Asia' => 'Asia',
'Attribute' => 'Attribute', 'Attribute' => 'Attribute',
'BaseTime' => 'Base time', 'BaseTime' => 'Base time',
'Billing' => 'Billing',
'Bills' => 'Bills', 'Bills' => 'Bills',
'Bonus' => 'Bonus', 'Bonus' => 'Bonus',
'CIS' => 'CIS', 'CIS' => 'CIS',
@ -52,6 +56,7 @@ return ['Billing' => [
'Invoice' => 'Invoice', 'Invoice' => 'Invoice',
'Invoices' => 'Invoices', 'Invoices' => 'Invoices',
'Item' => 'Item', 'Item' => 'Item',
'Email' => 'Email',
'Items' => 'Items', 'Items' => 'Items',
'Log' => 'Log', 'Log' => 'Log',
'Logs' => 'Logs', 'Logs' => 'Logs',
@ -62,6 +67,7 @@ return ['Billing' => [
'Offer' => 'Offer', 'Offer' => 'Offer',
'Other' => 'Other', 'Other' => 'Other',
'Payment' => 'Payment', 'Payment' => 'Payment',
'PaymentPlan' => 'Payment Plan',
'Postal' => 'Postal', 'Postal' => 'Postal',
'Prepaid' => 'Prepaid', 'Prepaid' => 'Prepaid',
'Preview' => 'Preview', 'Preview' => 'Preview',
@ -81,6 +87,7 @@ return ['Billing' => [
'TermsOfDelivery' => 'Terms Of Delivery', 'TermsOfDelivery' => 'Terms Of Delivery',
'Total' => 'Total', 'Total' => 'Total',
'Type' => 'Type', 'Type' => 'Type',
'Types' => 'Types',
'Upload' => 'Upload', 'Upload' => 'Upload',
'Value' => 'Value', 'Value' => 'Value',
'Variation' => 'Variation', 'Variation' => 'Variation',

538
Theme/Backend/bill-create.tpl.php Executable file
View File

@ -0,0 +1,538 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\Billing
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use Modules\Billing\Models\NullBill;
use phpOMS\Localization\ISO3166NameEnum;
use phpOMS\Localization\ISO3166TwoEnum;
use phpOMS\Localization\ISO4217Enum;
use phpOMS\Localization\ISO639Enum;
use phpOMS\Uri\UriFactory;
$countryCodes = ISO3166TwoEnum::getConstants();
$countries = ISO3166NameEnum::getConstants();
$languages = ISO639Enum::getConstants();
$currencies = ISO4217Enum::getConstants();
/**
* @var \phpOMS\Views\View $this
*/
$media = $this->getData('media') ?? [];
/** @var \Modules\Billing\Models\Bill $bill */
$bill = $this->getData('bill') ?? new NullBill();
$elements = $bill->getElements();
$billTypes = $this->getData('billtypes') ?? [];
/** @var \Modules\Auditor\Models\Audit */
$logs = $this->getData('logs') ?? [];
// @todo: false needs to be replaced with status->NOT_FINALIZED (check which status it actually is)
$editable = $bill instanceof NullBill || false;
$disabled = !$editable ? ' disabled' : '';
echo $this->getData('nav')->render(); ?>
<div class="tabview tab-2 col-simple">
<div class="box">
<ul class="tab-links">
<li><label for="c-tab-1"><?= $this->getHtml('Invoice'); ?></label></li>
<li><label for="c-tab-2"><?= $this->getHtml('Items'); ?></label></li>
<li><label for="c-tab-3">Preview</label></li>
<li><label for="c-tab-4"><?= $this->getHtml('Payment'); ?></label></li>
<li><label for="c-tab-5"><?= $this->getHtml('Media'); ?></label></li>
<li><label for="c-tab-6"><?= $this->getHtml('Logs'); ?></label></li>
</ul>
</div>
<div class="tab-content col-simple">
<input type="radio" id="c-tab-1" name="tabular-2" checked>
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="portlet">
<form>
<div class="portlet-head"><?= $this->getHtml('Invoice'); ?></div>
<div class="portlet-body">
<div class="form-group">
<label for="iLanguage"><?= $this->getHtml('Language'); ?></label>
<select id="iLanguage" name="bill_language"<?= $disabled; ?>>
<?php foreach ($languages as $code => $language) : $code = \strtolower(\substr($code, 1)); ?>
<option value="<?= $this->printHtml($code); ?>"<?= $code === $bill->getLanguage() ? ' selected' : ''; ?>><?= $this->printHtml($language); ?>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="iCurrency"><?= $this->getHtml('Currency'); ?></label>
<select id="iCurrency" name="bill_currency"<?= $disabled; ?>>
<?php foreach ($currencies as $code => $currency) : $code = \substr($code, 1); ?>
<option value="<?= $this->printHtml($code); ?>"<?= $code === $bill->getCurrency() ? ' selected' : ''; ?>><?= $this->printHtml($currency); ?>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="iSource"><?= $this->getHtml('Source'); ?></label>
<span class="input">
<button type="button" formaction="">
<i class="fa fa-book"></i>
</button>
<input type="text" id="iSource" name="bill_source"<?= $disabled; ?>>
</span>
</div>
<div class="form-group">
<label for="iBillType"><?= $this->getHtml('Type'); ?></label>
<select id="iBillType" name="bill_type"<?= $disabled; ?>>
<?php foreach ($billTypes as $type) : ?>
<option value="<?= $type->getId(); ?>"><?= $this->printHtml($type->getL11n()); ?>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="iClient"><?= $this->getHtml('Client'); ?></label>
<span class="input">
<button type="button" formaction="">
<i class="fa fa-book"></i>
</button>
<input type="text" id="iClient" name="bill_client" value="<?= $bill->client?->number ?? $bill->supplier?->number; ?>"<?= $disabled; ?>>
</span>
</div>
<div class="form-group">
<label for="iInvoiceDate"><?= $this->getHtml('Invoice'); ?></label>
<input type="datetime-local" id="iInvoiceDate" name="bill_invoice_date"
value="<?= $bill->createdAt->format('Y-m-d\TH:i'); ?>"<?= $disabled; ?>>
</div>
<div class="form-group">
<label for="iDeliveryDate"><?= $this->getHtml('Delivery'); ?></label>
<input type="datetime-local" id="iDeliveryDate" name="bill_delivery_date"
value="<?= $bill->createdAt->format('Y-m-d\TH:i'); ?>"<?= $disabled; ?>>
</div>
<div class="form-group">
<label for="iDueDate"><?= $this->getHtml('Due'); ?></label>
<input type="datetime-local" id="iDueDate" name="bill_due"
value="<?= (new \DateTime('now'))->format('Y-m-d\TH:i'); ?>"<?= $disabled; ?>>
</div>
<div class="form-group">
<label for="iShipment"><?= $this->getHtml('Shipment'); ?></label>
<select id="iShipment" name="bill_shipment_type"<?= $disabled; ?>>
<option>
</select>
</div>
<div class="form-group">
<label for="iTermsOfDelivery"><?= $this->getHtml('TermsOfDelivery'); ?></label>
<select id="iTermsOfDelivery" name="bill_termsofdelivery"<?= $disabled; ?>>
<option>
</select>
</div>
</div>
<?php if ($editable) : ?>
<div class="portlet-foot">
<input type="submit" value="<?= $this->getHtml('Create', '0', '0'); ?>" name="create-invoice">
</div>
<?php endif; ?>
</form>
</section>
</div>
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Billing'); ?></div>
<div class="portlet-body">
<form>
<div class="form-group">
<label for="iAddressListBill"><?= $this->getHtml('Addresses'); ?></label>
<select id="iAddressListBill" name="bill_address_bill_list"<?= $disabled; ?>>
<option>
</select>
</div>
<div class="form-group">
<label for="iRecipientBill"><?= $this->getHtml('Recipient'); ?></label>
<input type="text" id="iRecipientBill" name="bill_recipient_bill" value="<?= $this->printHtml($bill->billTo) ?>"<?= $disabled; ?>>
</div>
<div class="form-group">
<label for="iAddressBill"><?= $this->getHtml('Address'); ?></label>
<input type="text" id="iAddressBill" name="bill_address_bill" value="<?= $this->printHtml($bill->billAddress) ?>"<?= $disabled; ?>>
</div>
<div class="form-group">
<label for="iZipBill"><?= $this->getHtml('Zip'); ?></label>
<input type="text" id="iZipBill" name="bill_address_bill" value="<?= $this->printHtml($bill->billZip) ?>"<?= $disabled; ?>>
</div>
<div class="form-group">
<label for="iCityBill"><?= $this->getHtml('City'); ?></label>
<input type="text" id="iCityBill" name="bill_city_bill" value="<?= $this->printHtml($bill->billCity) ?>"<?= $disabled; ?>>
</div>
<div class="form-group">
<label for="iCountryBill"><?= $this->getHtml('Country'); ?></label>
<select id="iCountryBill" name="bill_country_bill"<?= $disabled; ?>>
<?php foreach ($countryCodes as $code3 => $code2) : ?>
<option value="<?= $this->printHtml($code2); ?>"<?= $code2 === $bill->billCountry ? ' selected' : ''; ?>><?= $this->printHtml($countries[$code3]); ?>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="iEmailBill"><?= $this->getHtml('Email'); ?></label>
<input type="text" id="iEmailBill" name="bill_email_bill" value="<?= $this->printHtml($bill->billEmail) ?>"<?= $disabled; ?>>
</div>
</form>
</div>
</section>
</div>
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Delivery'); ?></div>
<div class="portlet-body">
<form>
<div class="form-group">
<label for="iAddressListDelivery"><?= $this->getHtml('Addresses'); ?></label>
<select id="iAddressListDelivery" name="bill_address_delivery_list"<?= $disabled; ?>>
<option>
</select>
</div>
<div class="form-group">
<label for="iRecipientDelivery"><?= $this->getHtml('Recipient'); ?></label>
<input type="text" id="iRecipientDelivery" name="bill_recipient_delivery" value="<?= $this->printHtml($bill->shipTo) ?>"<?= $disabled; ?>>
</div>
<div class="form-group">
<label for="iAddressDelivery"><?= $this->getHtml('Address'); ?></label>
<input type="text" id="iAddressDelivery" name="bill_address_delivery" value="<?= $this->printHtml($bill->shipAddress) ?>"<?= $disabled; ?>>
</div>
<div class="form-group">
<label for="iZipDelivery"><?= $this->getHtml('Zip'); ?></label>
<input type="text" id="iZipDelivery" name="bill_zip_delivery" value="<?= $this->printHtml($bill->shipZip) ?>"<?= $disabled; ?>>
</div>
<div class="form-group">
<label for="iCityDelivery"><?= $this->getHtml('City'); ?></label>
<input type="text" id="iCityDelivery" name="bill_city_delivery" value="<?= $this->printHtml($bill->shipCity) ?>"<?= $disabled; ?>>
</div>
<div class="form-group">
<label for="iCountryDelivery"><?= $this->getHtml('Country'); ?></label>
<select id="iCountryDelivery" name="bill_country_delivery"<?= $disabled; ?>>
<option value="" <?= $bill->shipTo === '' ? 'selected ' : ''; ?>><?= $this->getHtml('Select', '0', '0'); ?>
<?php foreach ($countryCodes as $code3 => $code2) : ?>
<option value="<?= $this->printHtml($code2); ?>"<?= $code2 === $bill->shipCountry ? ' selected' : ''; ?>><?= $this->printHtml($countries[$code3]); ?>
<?php endforeach; ?>
</select>
</div>
</form>
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-2" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Invoice'); ?><i class="fa fa-download floatRight download btn"></i></div>
<table
id="invoiceElements"
class="default sticky"
data-tag="form"
data-ui-container="tbody"
data-ui-element="tr"
data-add-tpl=".oms-invoice-add">
<thead>
<tr>
<td>
<td><?= $this->getHtml('Item'); ?>
<td class="wf-100"><?= $this->getHtml('Name'); ?>
<td><?= $this->getHtml('Quantity'); ?>
<td><?= $this->getHtml('Discount'); ?>
<td><?= $this->getHtml('DiscountP'); ?>
<td><?= $this->getHtml('Bonus'); ?>
<td><?= $this->getHtml('Tax'); ?>
<td><?= $this->getHtml('Price'); ?>
<td><?= $this->getHtml('Net'); ?>
<tbody class="oms-ordercontainer">
<?php if ($editable) : ?>
<template class="oms-invoice-add">
<tr data-id="">
<td>
<i class="fa fa-chevron-up order-up"></i>
<i class="fa fa-chevron-down order-down"></i>
<i class="fa fa-times btn remove-form"></i>
<td><span class="input">
<button type="button" formaction="">
<label><i class="fa fa-book"></i></label>
</button><input type="text" autocomplete="off"></span>
<td><textarea autocomplete="off"></textarea>
<td><input type="number" min="0" value="" autocomplete="off">
<td><input type="number" min="0" value="" autocomplete="off">
<td><input type="number" min="0" max="100" step="any" value="" autocomplete="off">
<td><input type="number" min="0" step="any" value="" autocomplete="off">
<td><input type="number" min="0" step="any" value="" autocomplete="off">
<td>
</tr>
</template>
<?php endif; ?>
<?php foreach ($elements as $element) : ?>
<tr>
<td><?php if ($editable) : ?>
<i class="fa fa-chevron-up order-up"></i>
<i class="fa fa-chevron-down order-down"></i>
<i class="fa fa-times btn remove-form"></i>
<?php endif; ?>
<td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input name="" type="text" value="<?= $element->itemNumber; ?>" required<?= $disabled; ?>></span>
<td><textarea required<?= $disabled; ?>><?= $element->itemName; ?></textarea>
<td><input name="" type="number" min="0" value="<?= $element->quantity; ?>" required<?= $disabled; ?>>
<td><input name="" type="text" value="<?= $element->singleSalesPriceNet->getCurrency(symbol: ''); ?>"<?= $disabled; ?>>
<td><input name="" type="number" min="0"<?= $disabled; ?>>
<td><input name="" type="number" min="0" max="100" step="any"<?= $disabled; ?>>
<td><input name="" type="number" min="0" step="any"<?= $disabled; ?>>
<td><input name="" type="number" min="0" step="any"<?= $disabled; ?>>
<td><?= $element->totalSalesPriceNet->getCurrency(); ?>
<?php endforeach; ?>
<?php if ($editable) : ?>
<tr data-id="0">
<td><i class="fa fa-chevron-up order-up"></i>
<i class="fa fa-chevron-down order-down"></i>
<i class="fa fa-times btn remove-form"></i>
<td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" autocomplete="off"></span>
<td><textarea autocomplete="off"></textarea>
<td><input type="number" min="0" value="" autocomplete="off">
<td><input type="number" min="0" value="" autocomplete="off">
<td><input type="number" min="0" max="100" step="any" value="" autocomplete="off">
<td><input type="number" min="0" step="any" value="" autocomplete="off">
<td><input type="number" min="0" step="any" value="" autocomplete="off">
<td>
<?php endif; ?>
</table>
</section>
<?php if ($editable) : ?>
<div class="box">
<input type="submit" class="add-form" value="Add" form="invoiceElements">
</div>
<?php endif; ?>
</div>
</div>
</div>
<input type="radio" id="c-tab-3" name="tabular-2">
<div class="tab col-simple">
<div>
<div class="col-xs-12 col-sm-3 box">
<select id="iBillPreviewType" name="bill_preview_type">>
<?php foreach ($billTypes as $type) : ?>
<option value="<?= $type->getId(); ?>"><?= $this->printHtml($type->getL11n()); ?>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-simple">
<div class="col-xs-12 col-simple">
<section id="mediaFile" class="portlet col-simple">
<div class="portlet-body col-simple">
<iframe class="col-simple" id="iHelperFrame" src="Resources/mozilla/Pdf/web/viewer.html?file=<?= \urlencode('http://127.0.0.1/en/api/bill/render?bill_type='); ?>{#iBillPreviewType}" loading="lazy" allowfullscreen></iframe>
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-4" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Payment'); ?></div>
<div class="portlet-body">
<form>
<div class="form-group">
<label for="iPaymentTypeList"><?= $this->getHtml('Types'); ?></label>
<input type="text" id="iPaymentTypeList" name="bill_payment_type_list"<?= $disabled; ?>>
</div>
<div class="form-group">
<label for="iPaymentType"><?= $this->getHtml('Type'); ?></label>
<select id="iPaymentType" name="bill_payment_type"<?= $disabled; ?>>
<option><?= $this->getHtml('MoneyTransfer'); ?>
<option><?= $this->getHtml('Prepaid'); ?>
<option><?= $this->getHtml('AlreadyPaid'); ?>
<option><?= $this->getHtml('CreditCard'); ?>
<option><?= $this->getHtml('DirectDebit'); ?>
</select>
</div>
<div class="form-group">
<label for="iPaymentDueDate"><?= $this->getHtml('Due'); ?></label>
<input type="datetime-local" id="iPaymentDueDate" name="bill_payment_due_date"<?= $disabled; ?>>
</div>
</div>
<div class="portlet-separator"></div>
<div class="portlet-body">
<div class="form-group">
<label for="iPaymentCashbackDate1"><?= $this->getHtml('Cashback'); ?></label>
<input type="datetime-local" id="iPaymentCashbackDate1" name="bill_payment_cashback_date1"<?= $disabled; ?>>
</div>
<div class="form-group">
<label for="iPaymentCashbackAmount1"><?= $this->getHtml('Cashback'); ?></label>
<input type="number" id="iPaymentCashbackAmount1" name="bill_payment_cashback_amount1"<?= $disabled; ?>>
</div>
</div>
<div class="portlet-separator"></div>
<div class="portlet-body">
<div class="form-group">
<label for="iPaymentCashbackDate2"><?= $this->getHtml('Cashback'); ?></label>
<input type="datetime-local" id="iPaymentCashbackDate2" name="bill_payment_cashback_date2"<?= $disabled; ?>>
</div>
<div class="form-group">
<label for="iPaymentCashbackAmount2"><?= $this->getHtml('Cashback'); ?></label>
<input type="number" id="iPaymentCashbackAmount2" name="bill_payment_cashback_amount2"<?= $disabled; ?>>
</div>
</form>
</div>
</section>
</div>
<div class="col-xs-12 col-md-6 col-lg-8">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('PaymentPlan'); ?></div>
<table id="paymentPlan"
class="default sticky"
data-tag="form"
data-ui-container="tbody"
data-ui-element="tr"
data-add-tpl=".oms-payment-add">
<thead>
<tr>
<td>
<td class="wf-100"><?= $this->getHtml('Date'); ?>
<td><?= $this->getHtml('Amount'); ?>
<tbody class="oms-ordercontainer">
<template class="oms-payment-add">
<tr data-id="">
<td><?php if ($editable) : ?>
<i class="fa fa-chevron-up order-up"></i>
<i class="fa fa-chevron-down order-down"></i>
<i class="fa fa-times btn remove-form"></i>
<?php endif; ?>
<td><input type="datetime-local" autocomplete="off" required>
<td><input type="number" min="0" value="" autocomplete="off" required>
</tr>
</template>
</table>
</section>
<?php if ($editable) : ?>
<div class="box">
<input type="submit" class="add-form" value="Add" form="paymentPlan">
</div>
<?php endif; ?>
</div>
</div>
</div>
<input type="radio" id="c-tab-5" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Media'); ?></div>
<div class="portlet-body">
<form>
<div class="form-group">
<label for="iMedia"><?= $this->getHtml('Media'); ?></label>
<div class="ipt-first">
<input type="text" id="iMedia" placeholder="&#xf15b; File">
</div>
<div class="ipt-second"><button><?= $this->getHtml('Select'); ?></button></div>
</div>
<div class="form-group">
<label for="iUpload"><?= $this->getHtml('Upload'); ?></label>
<input type="file" id="iUpload" form="fTask"><input form="fTask" type="hidden" name="type">
</div>
</form>
</div>
</section>
</div>
<div class="col-xs-12 col-md-6 col-lg-8">
<?= $this->getData('medialist')?->render($media); ?>
</div>
</div>
</div>
<input type="radio" id="c-tab-6" name="tabular-2">
<div class="tab">
<?php
$footerView = new \phpOMS\Views\PaginationView($this->l11nManager, $this->request, $this->response);
$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig');
$footerView->setPages(20);
$footerView->setPage(1);
?>
<div class="row">
<div class="col-xs-12">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Logs'); ?><i class="fa fa-download floatRight download btn"></i></div>
<table class="default">
<thead>
<tr>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<td><?= $this->getHtml('Trigger', 'Auditor', 'Backend'); ?>
<td><?= $this->getHtml('Action', 'Auditor', 'Backend'); ?>
<td><?= $this->getHtml('CreatedBy', 'Auditor', 'Backend'); ?>
<td><?= $this->getHtml('CreatedAt', 'Auditor', 'Backend'); ?>
<tbody>
<?php
foreach ($logs as $audit) :
$url = UriFactory::build('{/lang}/{/app}/admin/audit/single?id=' . $audit->getId());
?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= $audit->getId(); ?></a>
<td><a href="<?= $url; ?>"><?= $audit->trigger; ?></a>
<td><?php if ($audit->old === null) : echo $this->getHtml('CREATE', 'Auditor', 'Backend'); ?>
<?php elseif ($audit->old !== null && $audit->new !== null) : echo $this->getHtml('UPDATE', 'Auditor', 'Backend'); ?>
<?php elseif ($audit->new === null) : echo $this->getHtml('DELETE', 'Auditor', 'Backend'); ?>
<?php else : echo $this->getHtml('UNKNOWN', 'Auditor', 'Backend'); ?>
<?php endif; ?>
<td><a class="content"
href="<?= UriFactory::build('{/lang}/{/app}/admin/account/settings?id=' . $audit->createdBy->getId()); ?>"><?= $this->printHtml(
$this->renderUserName('%3$s %2$s %1$s', [$audit->createdBy->name1, $audit->createdBy->name2, $audit->createdBy->name3, $audit->createdBy->login])
); ?></a>
<td><a href="<?= $url; ?>"><?= $audit->createdAt->format('Y-m-d'); ?></a>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -1,269 +0,0 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\Billing
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
/**
* @var \phpOMS\Views\View $this
*/
echo $this->getData('nav')->render(); ?>
<div class="tabview tab-2">
<div class="box">
<ul class="tab-links">
<li><label for="c-tab-1"><?= $this->getHtml('Invoice'); ?></label></li>
<li><label for="c-tab-2"><?= $this->getHtml('Items'); ?></label></li>
<li><label for="c-tab-3">Preview</label></li>
<li><label for="c-tab-4"><?= $this->getHtml('Payment'); ?></label></li>
<li><label for="c-tab-5"><?= $this->getHtml('Media'); ?></label></li>
<li><label for="c-tab-6"><?= $this->getHtml('Logs'); ?></label></li>
</ul>
</div>
<div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-2" checked>
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Invoice'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td><label for="iSource"><?= $this->getHtml('Source'); ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" id="iSource" name="source"></span>
<tr><td><label for="iType"><?= $this->getHtml('Type'); ?></label>
<tr><td><select id="iType" name="type">
<option><?= $this->getHtml('Invoice'); ?>
<option><?= $this->getHtml('Offer'); ?>
<option><?= $this->getHtml('Confirmation'); ?>
<option><?= $this->getHtml('DeliveryNote'); ?>
<option><?= $this->getHtml('CreditNote'); ?>
</select>
<tr><td><label for="iClient"><?= $this->getHtml('Client'); ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" id="iClient" name="client"></span>
<tr><td><label for="iDelivery"><?= $this->getHtml('Delivery'); ?></label>
<tr><td><input type="datetime-local" id="iDelivery" name="delivery">
<tr><td><label for="iDue"><?= $this->getHtml('Due'); ?></label>
<tr><td><input type="datetime-local" id="iDue" name="due">
<tr><td><label for="iFreightage"><?= $this->getHtml('Freightage'); ?></label>
<tr><td><input type="number" id="iFreightage" name="freightage">
<tr><td><label for="iShipment"><?= $this->getHtml('Shipment'); ?></label>
<tr><td><select id="iShipment" name="shipment">
<option>
</select>
<tr><td><label for="iTermsOfDelivery"><?= $this->getHtml('TermsOfDelivery'); ?></label>
<tr><td><select id="iTermsOfDelivery" name="termsofdelivery">
<option>
</select>
<tr><td><input type="submit" value="<?= $this->getHtml('Create', '0', '0'); ?>" name="create-invoice">
</table>
</form>
</div>
</section>
</div>
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Invoice'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td><label for="iAddressS"><?= $this->getHtml('Addresses'); ?></label>
<tr><td><select id="iAddressS" name="addressS">
<option>
</select>
<tr><td><label for="iIRecipient"><?= $this->getHtml('Recipient'); ?></label>
<tr><td><input type="text" id="iIRecipient" name="irecipient">
<tr><td><label for="iAddress"><?= $this->getHtml('Address'); ?></label>
<tr><td><input type="text" id="iAddress" name="address">
<tr><td><label for="iZip"><?= $this->getHtml('Zip'); ?></label>
<tr><td><input type="text" id="iZip" name="zip">
<tr><td><label for="iCity"><?= $this->getHtml('City'); ?></label>
<tr><td><input type="text" id="iCity" name="city">
<tr><td><label for="iCountry"><?= $this->getHtml('Country'); ?></label>
<tr><td><input type="text" id="iCountry" name="country">
</table>
</form>
</div>
</section>
</div>
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Delivery'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td><label for="iAddressS"><?= $this->getHtml('Addresses'); ?></label>
<tr><td><select id="iAddressS" name="addressS">
<option>
</select>
<tr><td><label for="iDRecipient"><?= $this->getHtml('Recipient'); ?></label>
<tr><td><input type="text" id="iDRecipient" name="drecipient">
<tr><td><label for="iAddress"><?= $this->getHtml('Address'); ?></label>
<tr><td><input type="text" id="iAddress" name="address">
<tr><td><label for="iZip"><?= $this->getHtml('Zip'); ?></label>
<tr><td><input type="text" id="iZip" name="zip">
<tr><td><label for="iCity"><?= $this->getHtml('City'); ?></label>
<tr><td><input type="text" id="iCity" name="city">
<tr><td><label for="iCountry"><?= $this->getHtml('Country'); ?></label>
<tr><td><input type="text" id="iCountry" name="country">
</table>
</form>
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-2" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="default">
<caption><?= $this->getHtml('Invoice'); ?><i class="fa fa-download floatRight download btn"></i></caption>
<thead>
<tr>
<td>
<td><?= $this->getHtml('Item'); ?>
<td><?= $this->getHtml('Variation'); ?>
<td class="wf-100"><?= $this->getHtml('Name'); ?>
<td><?= $this->getHtml('Quantity'); ?>
<td><?= $this->getHtml('Discount'); ?>
<td><?= $this->getHtml('DiscountP'); ?>
<td><?= $this->getHtml('Bonus'); ?>
<td><?= $this->getHtml('Tax'); ?>
<td><?= $this->getHtml('Net'); ?>
<tfoot>
<tr>
<td colspan="8">
<?= $this->getHtml('Freightage'); ?>: 0.00 -
<?= $this->getHtml('Net'); ?>: 0.00 -
<?= $this->getHtml('Tax'); ?>: 0.00 -
<?= $this->getHtml('Total'); ?>: 0.00
<tbody>
<tr>
<td><i class="fa fa-plus"></i> <i class="fa fa-chevron-up"></i> <i class="fa fa-chevron-down"></i>
<td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" required></span>
<td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" required></span>
<td><textarea required></textarea>
<td><input type="number" min="0" value="0" required>
<td><input type="number" min="0">
<td><input type="number" min="0" max="100" step="any">
<td><input type="number" min="0" step="any">
<td><input type="number" min="0" step="any">
<td>
</table>
</div>
</div>
</div>
</div>
<input type="radio" id="c-tab-3" name="tabular-2">
<div class="tab">
</div>
<input type="radio" id="c-tab-4" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Payment'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td><label for="iType"><?= $this->getHtml('Type'); ?></label>
<tr><td><select id="iType" name="type">
<option>
</select>
<tr><td><label for="iType"><?= $this->getHtml('Type'); ?></label>
<tr><td><select id="iType" name="type">
<option><?= $this->getHtml('MoneyTransfer'); ?>
<option><?= $this->getHtml('Prepaid'); ?>
<option><?= $this->getHtml('AlreadyPaid'); ?>
<option><?= $this->getHtml('CreditCard'); ?>
<option><?= $this->getHtml('DirectDebit'); ?>
</select>
<tr><td><label for="iDue"><?= $this->getHtml('Due'); ?></label>
<tr><td><input type="datetime-local" id="iDue" name="due">
<tr><td><label for="iDue"><?= $this->getHtml('Due'); ?> - <?= $this->getHtml('Cashback'); ?></label>
<tr><td><input type="datetime-local" id="iDue" name="due">
<tr><td><label for="iCashBack"><?= $this->getHtml('Cashback'); ?></label>
<tr><td><input type="number" id="iCashBack" name="cashback">
<tr><td><label for="iDue"><?= $this->getHtml('Due'); ?> - <?= $this->getHtml('Cashback'); ?> 2</label>
<tr><td><input type="datetime-local" id="iDue" name="due">
<tr><td><label for="iCashBack2"><?= $this->getHtml('Cashback'); ?> 2</label>
<tr><td><input type="number" id="iCashBack2" name="cashback2">
<tr><td><input type="submit" value="<?= $this->getHtml('Create', '0', '0'); ?>" name="create-invoice">
</table>
</form>
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-5" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Media'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tbody>
<tr><td colspan="2"><label for="iMedia"><?= $this->getHtml('Media'); ?></label>
<tr><td><input type="text" id="iMedia" placeholder="&#xf15b; File"><td><button><?= $this->getHtml('Select'); ?></button>
<tr><td colspan="2"><label for="iUpload"><?= $this->getHtml('Upload'); ?></label>
<tr><td><input type="file" id="iUpload" form="fTask"><input form="fTask" type="hidden" name="type"><td>
</table>
</form>
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-6" name="tabular-2">
<div class="tab">
<?php
$footerView = new \phpOMS\Views\PaginationView($this->l11nManager, $this->request, $this->response);
$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig');
$footerView->setPages(20);
$footerView->setPage(1);
?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="default">
<caption><?= $this->getHtml('Logs'); ?><i class="fa fa-download floatRight download btn"></i></caption>
<thead>
<tr>
<td>IP
<td><?= $this->getHtml('ID', '0', '0'); ?>
<td><?= $this->getHtml('Name'); ?>
<td class="wf-100"><?= $this->getHtml('Log'); ?>
<td><?= $this->getHtml('Date'); ?>
<tbody>
<tr>
<td><?= $this->printHtml($this->request->getOrigin()); ?>
<td><?= $this->printHtml((string) $this->request->header->account); ?>
<td><?= $this->printHtml((string) $this->request->header->account); ?>
<td>Create Invoice
<td><?= $this->printHtml((new \DateTime('now'))->format('Y-m-d H:i:s')); ?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -1,333 +0,0 @@
<?php
/**
* Karaka
*
* PHP Version 8.1
*
* @package Modules\Billing
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use phpOMS\System\File\FileUtils;
use phpOMS\Uri\UriFactory;
// Media helper functions (e.g. file icon generator)
include __DIR__ . '/../../../Media/Theme/Backend/template-functions.php';
/**
* @var \phpOMS\Views\View $this
*/
/** @var Modules\Billing\Models\Bill $bill */
$bill = $this->getData('bill');
$elements = $bill->getElements();
$media = $bill->getMedia();
$previewType = $this->getData('previewType');
$billPdf = $bill->getFileByType($previewType);
echo $this->getData('nav')->render(); ?>
<div class="tabview tab-2">
<div class="box">
<ul class="tab-links">
<li><label for="c-tab-1"><?= $this->getHtml('Invoice'); ?></label></li>
<li><label for="c-tab-2"><?= $this->getHtml('Items'); ?></label></li>
<li><label for="c-tab-3"><?= $this->getHtml('Preview'); ?></label></li>
<li><label for="c-tab-4"><?= $this->getHtml('Payment'); ?></label></li>
<li><label for="c-tab-5"><?= $this->getHtml('Media'); ?></label></li>
<li><label for="c-tab-6"><?= $this->getHtml('Logs'); ?></label></li>
</ul>
</div>
<div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-2" checked>
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="portlet">
<form>
<div class="portlet-head"><?= $this->getHtml('Invoice'); ?></div>
<div class="portlet-body">
<table class="layout wf-100">
<tr><td><label for="iSource"><?= $this->getHtml('Source'); ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" id="iSource" name="source"></span>
<tr><td><label for="iType"><?= $this->getHtml('Type'); ?></label>
<tr><td><select id="iType" name="type">
<option><?= $this->getHtml('Invoice'); ?>
<option><?= $this->getHtml('Offer'); ?>
<option><?= $this->getHtml('Confirmation'); ?>
<option><?= $this->getHtml('DeliveryNote'); ?>
<option><?= $this->getHtml('CreditNote'); ?>
</select>
<tr><td><label for="iClient"><?= $this->getHtml('Client'); ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" id="iClient" name="client"></span>
<tr><td><label for="iDelivery"><?= $this->getHtml('Delivery'); ?></label>
<tr><td><input type="datetime-local" id="iDelivery" name="delivery">
<tr><td><label for="iDue"><?= $this->getHtml('Due'); ?></label>
<tr><td><input type="datetime-local" id="iDue" name="due">
<tr><td><label for="iFreightage"><?= $this->getHtml('Freightage'); ?></label>
<tr><td><input type="number" id="iFreightage" name="freightage">
<tr><td><label for="iShipment"><?= $this->getHtml('Shipment'); ?></label>
<tr><td><select id="iShipment" name="shipment">
<option>
</select>
<tr><td><label for="iTermsOfDelivery"><?= $this->getHtml('TermsOfDelivery'); ?></label>
<tr><td><select id="iTermsOfDelivery" name="termsofdelivery">
<option>
</select>
</table>
</div>
<div class="portlet-foot"><input type="submit" value="<?= $this->getHtml('Create', '0', '0'); ?>" name="create-bill"></div>
</form>
</section>
</div>
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Invoice'); ?></div>
<div class="portlet-body">
<form>
<table class="layout wf-100">
<tr><td><label for="iAddressS"><?= $this->getHtml('Addresses'); ?></label>
<tr><td><select id="iAddressS" name="addressS">
<option>
</select>
<tr><td><label for="iIRecipient"><?= $this->getHtml('Recipient'); ?></label>
<tr><td><input type="text" id="iIRecipient" name="irecipient">
<tr><td><label for="iAddress"><?= $this->getHtml('Address'); ?></label>
<tr><td><input type="text" id="iAddress" name="address">
<tr><td><label for="iZip"><?= $this->getHtml('Zip'); ?></label>
<tr><td><input type="text" id="iZip" name="zip">
<tr><td><label for="iCity"><?= $this->getHtml('City'); ?></label>
<tr><td><input type="text" id="iCity" name="city">
<tr><td><label for="iCountry"><?= $this->getHtml('Country'); ?></label>
<tr><td><input type="text" id="iCountry" name="country">
</table>
</form>
</div>
</section>
</div>
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Delivery'); ?></div>
<div class="portlet-body">
<form>
<table class="layout wf-100">
<tr><td><label for="iAddressS"><?= $this->getHtml('Addresses'); ?></label>
<tr><td><select id="iAddressS" name="addressS">
<option>
</select>
<tr><td><label for="iDRecipient"><?= $this->getHtml('Recipient'); ?></label>
<tr><td><input name="" type="text" id="iDRecipient" name="drecipient">
<tr><td><label for="iAddress"><?= $this->getHtml('Address'); ?></label>
<tr><td><input name="" type="text" id="iAddress" name="address">
<tr><td><label for="iZip"><?= $this->getHtml('Zip'); ?></label>
<tr><td><input name="" type="text" id="iZip" name="zip">
<tr><td><label for="iCity"><?= $this->getHtml('City'); ?></label>
<tr><td><input name="" type="text" id="iCity" name="city">
<tr><td><label for="iCountry"><?= $this->getHtml('Country'); ?></label>
<tr><td><input name="" type="text" id="iCountry" name="country">
</table>
</form>
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-2" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Invoice'); ?><i class="fa fa-download floatRight download btn"></i></div>
<div class="slider">
<table class="default" id="invoice-item-list">
<thead>
<tr>
<td>
<td><?= $this->getHtml('Item'); ?>
<td class="wf-100"><?= $this->getHtml('Name'); ?>
<td><?= $this->getHtml('Quantity'); ?>
<td><?= $this->getHtml('Price'); ?>
<td><?= $this->getHtml('Discount'); ?>
<td><?= $this->getHtml('DiscountP'); ?>
<td><?= $this->getHtml('Bonus'); ?>
<td><?= $this->getHtml('Tax'); ?>
<td><?= $this->getHtml('Net'); ?>
<tbody>
<?php foreach ($elements as $element) : ?>
<tr>
<td><i class="fa fa-plus add"></i> <i class="fa fa-chevron-up order-up"></i> <i class="fa fa-chevron-down order-down"></i>
<td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input name="" type="text" value="<?= $element->itemNumber; ?>" required></span>
<td><textarea required><?= $element->itemName; ?></textarea>
<td><input name="" type="number" min="0" value="<?= $element->quantity; ?>" required>
<td><input name="" type="text" value="<?= $element->singleSalesPriceNet->getCurrency(); ?>">
<td><input name="" type="number" min="0">
<td><input name="" type="number" min="0" max="100" step="any">
<td><input name="" type="number" min="0" step="any">
<td><input name="" type="number" min="0" step="any">
<td><?= $element->totalSalesPriceNet->getCurrency(); ?>
<?php endforeach; ?>
<tr>
<td><i class="fa fa-plus"></i> <i class="fa fa-chevron-up order-up"></i> <i class="fa fa-chevron-down order-down"></i>
<td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input name="" type="text" required></span>
<td><textarea required></textarea>
<td><input name="" type="number" min="0" value="0" required>
<td><input name="" type="text">
<td><input name="" type="number" min="0">
<td><input name="" type="number" min="0" max="100" step="any">
<td><input name="" type="number" min="0" step="any">
<td><input name="" type="number" min="0" step="any">
<td>
</table>
</div>
<div class="portlet-foot">
<?= $this->getHtml('Freightage'); ?>: 0.00 -
<?= $this->getHtml('Net'); ?>: <?= $bill->netSales->getCurrency(); ?> -
<?= $this->getHtml('Tax'); ?>: 0.00 -
<?= $this->getHtml('Total'); ?>: <?= $bill->grossSales->getCurrency(); ?>
</div>
</div>
</div>
</div>
</div>
<input type="radio" id="c-tab-3" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12">
<section id="mediaFile" class="portlet">
<div class="portlet-body">
<iframe style="min-height: 600px;" data-form="iUiSettings" data-name="iframeHelper" id="iHelperFrame" src="<?= UriFactory::build('{/backend}Resources/mozilla/Pdf/web/viewer.html?{?}&file=' . ($billPdf->isAbsolute ? '' : '/../../../../') . $billPdf->getPath()); ?>" allowfullscreen></iframe>
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-4" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Payment'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tr><td><label for="iType"><?= $this->getHtml('Type'); ?></label>
<tr><td><select id="iType" name="type">
<option>
</select>
<tr><td><label for="iType"><?= $this->getHtml('Type'); ?></label>
<tr><td><select id="iType" name="type">
<option><?= $this->getHtml('MoneyTransfer'); ?>
<option><?= $this->getHtml('Prepaid'); ?>
<option><?= $this->getHtml('AlreadyPaid'); ?>
<option><?= $this->getHtml('CreditCard'); ?>
<option><?= $this->getHtml('DirectDebit'); ?>
</select>
<tr><td><label for="iDue"><?= $this->getHtml('Due'); ?></label>
<tr><td><input type="datetime-local" id="iDue" name="due">
<tr><td><label for="iDue"><?= $this->getHtml('Due'); ?> - <?= $this->getHtml('Cashback'); ?></label>
<tr><td><input type="datetime-local" id="iDue" name="due">
<tr><td><label for="iCashBack"><?= $this->getHtml('Cashback'); ?></label>
<tr><td><input type="number" id="iCashBack" name="cashback">
<tr><td><label for="iDue"><?= $this->getHtml('Due'); ?> - <?= $this->getHtml('Cashback'); ?> 2</label>
<tr><td><input type="datetime-local" id="iDue" name="due">
<tr><td><label for="iCashBack2"><?= $this->getHtml('Cashback'); ?> 2</label>
<tr><td><input type="number" id="iCashBack2" name="cashback2">
<tr><td><input type="submit" value="<?= $this->getHtml('Create', '0', '0'); ?>" name="create-bill">
</table>
</form>
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-5" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Media'); ?></h1></header>
<div class="inner">
<form>
<table class="layout wf-100">
<tbody>
<tr><td colspan="2"><label for="iMedia"><?= $this->getHtml('Media'); ?></label>
<tr><td><input type="text" id="iMedia" placeholder="&#xf15b; File"><td><button><?= $this->getHtml('Select'); ?></button>
<tr><td colspan="2"><label for="iUpload"><?= $this->getHtml('Upload'); ?></label>
<tr><td><input type="file" id="iUpload" form="fTask"><input form="fTask" type="hidden" name="type"><td>
</table>
</form>
</div>
</section>
</div>
<div class="col-xs-12 col-md-6 col-lg-8">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Media'); ?><i class="fa fa-download floatRight download btn"></i></div>
<table class="default" id="invoice-item-list">
<thead>
<tr>
<td>
<td>
<td class="wf-100"><?= $this->getHtml('Name'); ?>
<td><?= $this->getHtml('Type'); ?>
<tbody>
<?php foreach ($media as $file) :
$url = $file->extension === 'collection'
? UriFactory::build('{/lang}/{/app}/media/list?path=' . \rtrim($file->getVirtualPath(), '/') . '/' . $file->name)
: UriFactory::build('{/lang}/{/app}/media/single?id=' . $file->getId()
. '&path={?path}' . (
$file->getId() === 0
? '/' . $file->name
: ''
)
);
$icon = $fileIconFunction(FileUtils::getExtensionType($file->extension));
?>
<tr data-href="<?= $url; ?>">
<td>
<td data-label="<?= $this->getHtml('Type'); ?>"><a href="<?= $url; ?>"><i class="fa fa-<?= $this->printHtml($icon); ?>"></i></a>
<td><a href="<?= $url; ?>"><?= $file->name; ?></a>
<td><a href="<?= $url; ?>"><?= $file->extension; ?></a>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</div>
<input type="radio" id="c-tab-6" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="default">
<caption><?= $this->getHtml('Logs'); ?><i class="fa fa-download floatRight download btn"></i></caption>
<thead>
<tr>
<td>IP
<td><?= $this->getHtml('ID', '0', '0'); ?>
<td><?= $this->getHtml('Name'); ?>
<td class="wf-100"><?= $this->getHtml('Log'); ?>
<td><?= $this->getHtml('Date'); ?>
<tbody>
<tr>
<td><?= $this->printHtml($this->request->getOrigin()); ?>
<td><?= $this->printHtml((string) $this->request->header->account); ?>
<td><?= $this->printHtml((string) $this->request->header->account); ?>
<td>Create Invoice
<td><?= $this->printHtml((new \DateTime('now'))->format('Y-m-d H:i:s')); ?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>