Alan Lam 3 лет назад
Родитель
Сommit
db789d7dd1

+ 24 - 1
controllers/document.php

@@ -210,6 +210,10 @@ $controller = new class($document_type, $document_number) {
 			$document->dts_paid = $this->request->dateTime("dts_paid", "Y-m-d\TH:i", $this->user->getTimezone());
 		}
 
+		if($document->isAru()) {
+			$document->aru_status = $this->request->int("aru_status");
+		}
+
 		$document->date = $this->request->string("date");
 
 		if($document->isInvoice() || $document->isDeliveryNote()) {
@@ -222,6 +226,11 @@ $controller = new class($document_type, $document_number) {
 
 		$document->delivery_company = $this->request->string("delivery_company");
 		$document->tracking_number = $this->request->string("tracking_number");
+		$document->delivery_cost = $this->request->decimal("delivery_cost", 2);
+
+		$document->contact_name = $this->request->string("contact_name");
+		$document->contact_phone = $this->request->string("contact_phone");
+		$document->contact_email = $this->request->email("contact_email");
 
 		$document->commit();
 
@@ -249,6 +258,7 @@ $controller = new class($document_type, $document_number) {
 		$item->serial_number = $this->request->string("serial_number");
 		$item->quantity = $this->request->int("quantity");
 		$item->unit_price = $this->request->decimal("unit_price", 2);
+		$item->insurance_value = $this->request->decimal("insurance_value", 2);
 		$item->commit();
 
 		JSON::success([
@@ -309,6 +319,10 @@ $controller = new class($document_type, $document_number) {
 		$document->date = date("Y-m-d");
 		$document->delivery_company = $source_document->delivery_company;
 		$document->tracking_number = $source_document->tracking_number;
+		$document->notes = $source_document->notes;
+		$document->contact_name = $source_document->contact_name;
+		$document->contact_phone = $source_document->contact_phone;
+		$document->contact_email = $source_document->contact_email;
 		$document->dts_created = Database::dts();
 		$document->commit();
 
@@ -349,7 +363,12 @@ $controller = new class($document_type, $document_number) {
 			throw new RuntimeException(__("Invalid access token."));
 		}
 
-		View::include("document_pdf", compact("document", "variant"));
+		$view = "document_pdf";
+		if($document->isPartOfAru() && $document->isDeliveryNote()) {
+			$view = "aru_dn_pdf";
+		}
+
+		View::include($view, compact("document", "variant"));
 	}
 
 	public function downloadPdf(): void {
@@ -423,6 +442,10 @@ switch($action) {
 				$controller->createDocumentWithItems(DocumentTypes::DELIVERY_NOTE);
 				break;
 
+			case "create-goods-in":
+				$controller->createDocumentWithItems(DocumentTypes::GOODS_IN);
+				break;
+
 			default:
 				throw new RuntimeException(__("Invalid batch action."));
 		}

+ 4 - 0
controllers/location_form.php

@@ -59,6 +59,10 @@ if($submit) {
 		$location->fax = $request->string("fax");
 		$location->email = $request->email("email");
 
+		$location->contact_name = $request->string("contact_name");
+		$location->contact_phone = $request->string("contact_phone");
+		$location->contact_email = $request->email("contact_email");
+
 		$address->address_1 = $request->string("address_1");
 		$address->address_2 = $request->string("address_2");
 		$address->city = $request->string("city");

+ 3 - 0
controllers/sale.php

@@ -269,6 +269,9 @@ $controller = new class($number) {
 		$invoice->delivery_address = $address_string;
 		$invoice->number = Document::getNextNumber(DocumentTypes::INVOICE);
 		$invoice->date = date("Y-m-d");
+		$invoice->contact_name = $location->contact_name;
+		$invoice->contact_phone = $location->contact_phone;
+		$invoice->contact_email = $location->contact_email;
 		$invoice->dts_created = Database::dts();
 		$invoice->commit();
 

+ 14 - 0
db/migrations/20221223124141_add_contact_fields_to_location_table.php

@@ -0,0 +1,14 @@
+<?php
+declare(strict_types=1);
+
+use Phinx\Migration\AbstractMigration;
+
+final class AddContactFieldsToLocationTable extends AbstractMigration {
+	public function change(): void {
+		$this->table("location")
+			->addColumn("contact_name", "string", ["null" => true, "after" => "email"])
+			->addColumn("contact_phone", "string", ["null" => true, "after" => "contact_name"])
+			->addColumn("contact_email", "string", ["null" => true, "after" => "contact_phone"])
+			->update();
+	}
+}

+ 14 - 0
db/migrations/20221223124955_add_contact_fields_to_document_table.php

@@ -0,0 +1,14 @@
+<?php
+declare(strict_types=1);
+
+use Phinx\Migration\AbstractMigration;
+
+final class AddContactFieldsToDocumentTable extends AbstractMigration {
+	public function change(): void {
+		$this->table("document")
+			->addColumn("contact_name", "string", ["null" => true, "after" => "notes"])
+			->addColumn("contact_phone", "string", ["null" => true, "after" => "contact_name"])
+			->addColumn("contact_email", "string", ["null" => true, "after" => "contact_phone"])
+			->update();
+	}
+}

+ 13 - 0
db/migrations/20221223144046_add_insurance_value_field_to_document_item_table.php

@@ -0,0 +1,13 @@
+<?php
+declare(strict_types=1);
+
+use Phinx\Migration\AbstractMigration;
+
+final class AddInsuranceValueFieldToDocumentItemTable extends AbstractMigration {
+	public function change(): void {
+		$this->table("document_item")
+			->addColumn("insurance_value", "decimal", ["signed" => false, "null" => true, "precision" => 11, "scale" => 2, "after" => "unit_price"])
+			->update();
+	}
+}
+

+ 13 - 0
db/migrations/20221223161237_add_aru_status_field_to_document_table.php

@@ -0,0 +1,13 @@
+<?php
+declare(strict_types=1);
+
+use Phinx\Db\Adapter\MysqlAdapter;
+use Phinx\Migration\AbstractMigration;
+
+final class AddAruStatusFieldToDocumentTable extends AbstractMigration {
+	public function change(): void {
+		$this->table("document")
+			->addColumn("aru_status", "integer", ["limit" => MysqlAdapter::INT_TINY, "signed" => false, "null" => true, "after" => "invoice_status"])
+			->update();
+	}
+}

+ 39 - 2
engine/Document.php

@@ -2,10 +2,12 @@
 
 namespace App;
 
+use App\Enums\AruStatuses;
 use App\Enums\DocumentTypes;
 use App\Enums\InvoiceStatuses;
 use App\Traits\DateTimeTrait;
 use App\Traits\SoftDeleteTrait;
+use Carbon\CarbonImmutable;
 use Exception;
 use NumberFormatter;
 use RuntimeException;
@@ -20,6 +22,7 @@ use RuntimeException;
  * @property int $related_document_id Used to link a delivery note to an invoice
  * @property int $type
  * @property int $invoice_status
+ * @property int $aru_status
  * @property string $currency
  * @property string $tax_rate
  * @property string $billing_address
@@ -32,6 +35,9 @@ use RuntimeException;
  * @property string $tracking_number
  * @property string $delivery_cost
  * @property string $notes
+ * @property string $contact_name
+ * @property string $contact_phone
+ * @property string $contact_email
  * @property string $dts_finalised
  * @property string $dts_paid
  */
@@ -42,12 +48,13 @@ class Document extends Model {
 	protected static $fillableFields = [
 		"company_id", "user_id", "sale_id", "supplier_id", "location_id", "related_document_id",
 		"type",
-		"invoice_status",
+		"invoice_status", "aru_status",
 		"currency", "tax_rate",
 		"billing_address", "delivery_address",
 		"number", "date", "po_number", "terms",
 		"delivery_company", "tracking_number", "delivery_cost",
 		"notes",
+		"contact_name", "contact_phone", "contact_email",
 		"dts_finalised", "dts_paid",
 		"dts_created", "dts_updated", "dts_deleted"
 	];
@@ -172,6 +179,10 @@ class Document extends Model {
 		return InvoiceStatuses::enumToText($this->invoice_status);
 	}
 
+	public function getDisplayAruStatus(): string {
+		return AruStatuses::enumToText($this->aru_status);
+	}
+
 	public function getDisplayTotal(): string {
 		$formatter = new NumberFormatter("en_GB", NumberFormatter::CURRENCY);
 
@@ -278,7 +289,7 @@ class Document extends Model {
 
 	/**
 	 * Get invoices related to this ARU
-	 * @return array
+	 * @return Document[]
 	 */
 	public function getInvoices(): array {
 		return self::query([
@@ -297,5 +308,31 @@ class Document extends Model {
 		return $related && $related->isAru();
 	}
 
+	/**
+	 * @return Document[]
+	 */
+	public function getGoodsInDocuments(): array {
+		return self::query([
+			"type" => DocumentTypes::GOODS_IN,
+			"related_document_id" => $this->id,
+			"dts_deleted" => null
+		]);
+	}
+
+	public function getDisplayDate(string $format = "d/m/Y"): string {
+		return CarbonImmutable::parse($this->date)->format($format);
+	}
+
+	public function getSubtotal(): string {
+		$subtotal = "0.00";
+		foreach($this->getItems() as $item) {
+			$subtotal = bcadd($subtotal, $item->getAmount(), 2);
+		}
+		return $subtotal;
+	}
+
+	public function getNotesHtml(): string {
+		return nl2br(htmlspecialchars($this->notes));
+	}
 
 }

+ 3 - 1
engine/DocumentItem.php

@@ -13,6 +13,7 @@ use JsonSerializable;
  * @property string $serial_number
  * @property int $quantity
  * @property string $unit_price
+ * @property string $insurance_value
  */
 class DocumentItem extends Model implements JsonSerializable {
 
@@ -21,7 +22,7 @@ class DocumentItem extends Model implements JsonSerializable {
 	protected static $fillableFields = [
 		"document_id",
 		"description", "serial_number",
-		"quantity", "unit_price",
+		"quantity", "unit_price", "insurance_value",
 		"dts_created", "dts_updated", "dts_deleted"
 	];
 
@@ -42,6 +43,7 @@ class DocumentItem extends Model implements JsonSerializable {
 			"serialNumber" => $this->serial_number,
 			"quantity" => (int) $this->quantity,
 			"unitPrice" => $this->unit_price,
+			"insuranceValue" => $this->insurance_value,
 		];
 	}
 }

+ 20 - 0
engine/Enums/AruStatuses.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Enums;
+
+class AruStatuses extends AbstractEnum {
+
+	public const DRAFT = 0;
+	public const AWAITING_PARTS_FROM_SUPPLIER = 1;
+	public const AWAITING_CUSTOMER_RETURN = 2;
+	public const COMPLETED = 3;
+
+	public static function options(): array {
+		return [
+			self::DRAFT => __("Draft"),
+			self::AWAITING_PARTS_FROM_SUPPLIER => __("Awaiting Parts From Supplier"),
+			self::AWAITING_CUSTOMER_RETURN => __("Awaiting Customer Return"),
+			self::COMPLETED => __("Completed"),
+		];
+	}
+}

+ 15 - 5
engine/Location.php

@@ -2,6 +2,9 @@
 
 namespace App;
 
+use App\Enums\AruStatuses;
+use App\Traits\DateTimeTrait;
+use App\Traits\SoftDeleteTrait;
 use Exception;
 
 /**
@@ -13,16 +16,24 @@ use Exception;
  * @property string $phone
  * @property string $fax
  * @property string $email
- * @property string $dts_created
- * @property string $dts_updated
- * @property string $dts_deleted
+ * @property string $contact_name
+ * @property string $contact_phone
+ * @property string $contact_email
  */
 
 class Location extends Model {
 
 	protected static $table = "location";
 	protected static $idField = "id";
-	protected static $fillableFields = ["customer_id", "address_id", "name", "phone", "fax", "email", "dts_created", "dts_updated", "dts_deleted"];
+	protected static $fillableFields = [
+		"customer_id", "address_id",
+		"name", "phone", "fax", "email",
+		"contact_name", "contact_phone", "contact_email",
+		"dts_created", "dts_updated", "dts_deleted"
+	];
+
+	use DateTimeTrait;
+	use SoftDeleteTrait;
 
 	/**
 	 * @return Customer
@@ -61,5 +72,4 @@ class Location extends Model {
 		$customer = $this->getCustomer();
 		return sprintf("%s - %s", $customer->name, $this->name);
 	}
-
 }

+ 8 - 0
public/js/app.js

@@ -70,6 +70,14 @@ class AddressMap {
 	}
 }
 
+const DocumentTypes = Object.freeze({
+	Invoice: 0,
+	DeliveryNote: 1,
+	GoodsIn: 2,
+	AdvancedReplacementUnit: 3,
+	CreditNote: 4,
+});
+
 $(() => {
 	const addressMap = document.querySelector("#address-map");
 	if(addressMap) {

+ 26 - 6
public/js/document-item-modal.js

@@ -13,14 +13,19 @@ class DocumentItemModal {
 		this.$form.on("submit", event => this.onSubmit(event));
 		this.form = this.$form.get(0);
 
-		this.$documentItemIdField = this.$form.find("[name=document_item_id]");
+		this.$documentItemIdField = this.getField("document_item_id");
 
-		this.$descriptionField = this.$form.find("[name=description]");
-		this.$serialNumberField = this.$form.find("[name=serial_number]");
+		this.$descriptionField = this.getField("description");
+		this.$serialNumberField = this.getField("serial_number");
 
-		this.$quantityField = this.$form.find("[name=quantity]");
+		this.$quantityField = this.getField("quantity");
 
-		this.$unitPriceField = this.$form.find("[name=unit_price]");
+		this.$unitPriceField = this.getField("unit_price");
+		this.$insuranceValueField = this.getField("insurance_value");
+	}
+
+	getField(name) {
+		return this.$form.find(`[name=${name}]`);
 	}
 
 	// Modal lifecycle
@@ -28,7 +33,21 @@ class DocumentItemModal {
 	    const $element = $(event.relatedTarget);
 	    const data = $element.data();
 
-		const { item } = data;
+		const { item, documentType } = data;
+
+		this.$unitPriceField.closest("div").hide();
+		this.$insuranceValueField.closest("div").hide();
+
+		switch(documentType) {
+			case DocumentTypes.DeliveryNote:
+				this.$insuranceValueField.closest("div").show();
+				break;
+
+			case DocumentTypes.AdvancedReplacementUnit:
+			case DocumentTypes.Invoice:
+				this.$unitPriceField.closest("div").show();
+				break;
+		}
 
 		if(item) {
 			this.$title.text("Update Item");
@@ -38,6 +57,7 @@ class DocumentItemModal {
 			this.$serialNumberField.val(item.serialNumber);
 			this.$quantityField.val(item.quantity);
 			this.$unitPriceField.val(item.unitPrice);
+			this.$insuranceValueField.val(item.insuranceValue);
 		}
 		else {
 			this.$title.text("Add Item");

+ 11 - 6
public/js/new-document-modal.js

@@ -12,16 +12,21 @@ class NewDocumentModal {
 		this.$form = this.$modal.find("form");
 		this.$form.on("submit", event => this.onSubmit(event));
 
-		this.$typeField = this.$form.find("[name=type]");
-		this.$locationDropdown = this.$form.find("[name=location_id]");
-		this.$supplierDropdown = this.$form.find("[name=supplier_id]");
+		this.$typeField = this.getField("type");
+		this.$companyDropdown = this.getField("company_id");
+		this.$locationDropdown = this.getField("location_id");
+		this.$supplierDropdown = this.getField("supplier_id");
 
 		this.$aruSection = $("#new-document-aru-section");
-		this.$itemDescriptionField = this.$form.find("[name=item_description]");
-		this.$itemSerialNumberField = this.$form.find("[name=item_serial_number]");
+		this.$itemDescriptionField = this.getField("item_description");
+		this.$itemSerialNumberField = this.getField("item_serial_number");
 
 	}
 
+	getField(name) {
+		return this.$form.find(`[name=${name}]`);
+	}
+
 	// Modal lifecycle
 	onShow(event) {
 	    const $element = $(event.relatedTarget);
@@ -48,7 +53,7 @@ class NewDocumentModal {
 	}
 
 	onShown() {
-	    this.$supplierDropdown.trigger("focus");
+		this.$companyDropdown.trigger("focus");
 	}
 
 	onHidden() {

+ 404 - 0
views/aru_dn_pdf.php

@@ -0,0 +1,404 @@
+<?php /** @noinspection PhpUnhandledExceptionInspection */
+namespace App;
+
+use Carbon\CarbonImmutable;
+use NumberFormatter;
+
+/**
+ * @var Document $document
+ * @var string $variant
+ */
+
+$core = Core::getInstance();
+
+$delivery_note_number = $document->number;
+
+$company = $document->getCompany();
+$address = $company->getAddress();
+$address_lines = explode("\n", (string) $address);
+
+$aru = $document->getRelatedDocument();
+$goods_in_documents = $aru->getGoodsInDocuments();
+$invoices = $aru->getInvoices();
+
+$charges = "0.00";
+foreach($invoices as $invoice) {
+	$charges = bcadd($charges, $invoice->getSubtotal(), 2);
+}
+
+$formatter = new NumberFormatter("en_GB", NumberFormatter::CURRENCY);
+
+$render_card = static function(string $title, ?string $content): void {
+	$content = trim($content) ? htmlspecialchars($content) : "&nbsp;";
+	?>
+	<div class="card mb-2">
+		<div class="card-header">
+			<strong>
+				<?=htmlspecialchars($title)?>
+			</strong>
+		</div>
+		<div class="card-body">
+			<?=$content?>
+		</div>
+	</div>
+	<?php
+}
+
+?>
+<!doctype html>
+<html lang="en">
+<head>
+	<meta charset="UTF-8">
+	<meta name="viewport"
+		  content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
+	<meta http-equiv="X-UA-Compatible" content="ie=edge">
+	<title><?=htmlspecialchars($core->getSiteName())?></title>
+
+	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" integrity="sha256-IUOUHAPazai08QFs7W4MbzTlwEWFo7z/4zw8YmxEiko=" crossorigin="anonymous">
+	<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha256-xLI5SjD6DkojxrMIVBNT4ghypv12Xtj7cOa0AgKd6wA=" crossorigin="anonymous"></script>
+
+	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.2.0/css/all.min.css" integrity="sha256-AbA177XfpSnFEvgpYu1jMygiLabzPCJCRIBtR5jGc0k=" crossorigin="anonymous">
+
+	<style>
+		<?php
+		echo file_get_contents("https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css");
+		?>
+
+		:root {
+            --bs-body-font-size: 0.7rem;
+		}
+
+		.card {
+			border-radius: 0;
+		}
+
+		.card-header {
+			padding: 0.25rem 0.5rem;
+            border-radius: 0 !important;
+		}
+
+		.card-body {
+			padding: 0.25rem 0.5rem;
+		}
+
+		.large {
+			font-size: 125%;
+		}
+
+		.xlarge {
+			font-size: 175%;
+		}
+
+		.border-4 {
+			border: 4px solid black;
+		}
+
+		.compact {
+			line-height: 1.25;
+		}
+	</style>
+
+</head>
+<body>
+	<div class="container">
+
+		<div class="row g-2 mb-2">
+			<div class="col text-nowrap">
+				<div class="text-uppercase xlarge">
+					<strong>Advance Replacement Unit</strong>
+				</div>
+			</div>
+			<div class="col text-center" >
+				<img src="/img/logo.png" alt="Logo" style="width: 100px;" />
+			</div>
+			<div class="col-auto">
+				<strong class="text-uppercase xlarge">
+					ARU DN<br />
+				</strong>
+				<b class="large">No. <?=$delivery_note_number?></b>
+			</div>
+		</div>
+
+		<div class="row g-2">
+			<div class="col-6">
+				<div class="card mb-2">
+					<div class="card-header">
+						<strong>Company, Name and Address</strong>
+					</div>
+					<div class="card-body">
+						<?=$document->getBillingAddressHtml()?>
+					</div>
+				</div>
+
+				<div class="card mb-2">
+					<div class="card-header">
+						<strong>Cost / Charge of Repairs</strong>
+					</div>
+					<div class="card-body">
+						<?=htmlspecialchars($formatter->formatCurrency($charges, $aru->currency))?>
+					</div>
+				</div>
+			</div>
+			<div class="col-6">
+				<div class="card mb-2">
+					<div class="card-header">
+						<strong>Deliver To</strong>
+					</div>
+					<div class="card-body">
+						<?=$document->getDeliveryAddressHtml()?>
+					</div>
+				</div>
+				<div class="card mb-2">
+					<div class="card-header">
+						<strong>Delivery Cost</strong>
+					</div>
+					<div class="card-body">
+						<?=htmlspecialchars($formatter->formatCurrency($document->delivery_cost, $aru->currency))?>
+					</div>
+				</div>
+			</div>
+		</div>
+
+		<div class="bg-danger text-center text-white p-1 mb-2 border-4 compact">
+			<p class="mb-1">
+				<strong class="large">IMPORTANT INFORMATION ON RETURNS OF ARUs</strong><br />
+				<strong class="large">ON LOAN FOR A MAXIMUM OF 14 DAYS</strong><br />
+			</p>
+			<p class="mb-1">
+				The FAULTY UNIT must be returned to us (if the item has been tampered warranty will be void and the full charge may be applied) at the address below within 14 days by Recorded Delivery Carriage / Insurance to be pre-paid. <strong>(WARNING)</strong> If not received back within 14 days you will be invoiced at the <b>FULL COST</b> and <b>ADVANCE REPLACEMENT UNIT FACILITIES</b> will be <b>WITHDRAWN</b> for any future requirements.
+			</p>
+
+			<p class="mb-1">
+				<strong>Failure to return the faulty part(s) within 28 days will incur a 20% HANDLING CHARGE<br />AFTER 60 DAYS NO CREDIT WILL BE ISSUED</strong>
+			</p>
+		</div>
+
+		<div class="row g-2">
+			<div class="col-6">
+				<div class="row g-2">
+					<div class="col-6">
+						<?php
+						$render_card("Person Ordering", $document->contact_name);
+						?>
+					</div>
+					<div class="col-6">
+						<?php
+						$render_card("Date", CarbonImmutable::parse($document->date)->format("d/m/Y"));
+						?>
+					</div>
+				</div>
+				<div class="card mb-2">
+					<div class="card-header">
+						<strong>Contact Details</strong>
+					</div>
+					<div class="card-body">
+						<?php
+						if($document->contact_phone) {
+							?>
+							<div>
+								<i class="fa fa-fw fa-phone"></i>
+								<?=htmlspecialchars($document->contact_phone)?>
+							</div>
+							<?php
+						}
+						if($document->contact_email) {
+							?>
+							<div>
+								<i class="fa fa-fw fa-envelope"></i>
+								<?=htmlspecialchars($document->contact_email)?>
+							</div>
+							<?php
+						}
+						if(!$document->contact_phone && !$document->contact_email) {
+							?>
+							&nbsp;
+							<?php
+						}
+						?>
+					</div>
+				</div>
+			</div>
+			<div class="col-6">
+				<?php
+				$render_card("Your Order No.", $document->po_number);
+				?>
+
+				<div class="card mb-2">
+					<div class="card-header">
+						<strong>
+							Help Us To Help Yourselves
+						</strong>
+					</div>
+					<div class="card-body">
+						Please return the Faulty Unit with a <strong>DUPLICATE COPY</strong> of the ARU Delivery Note, completing details of the fault - i.e. what the fault is; not needed; incorrect, to the address below.
+					</div>
+				</div>
+
+			</div>
+		</div>
+
+		<table class="table table-bordered mb-2">
+			<colgroup>
+				<col style="width: 40%"/>
+				<col style="width: 40%"/>
+				<col style="width: 20%"/>
+			</colgroup>
+			<thead>
+			<tr>
+				<th>Requested Items</th>
+				<th>Serial Numbers</th>
+				<th>Insurance Value</th>
+			</tr>
+			</thead>
+			<tbody>
+			<?php
+			foreach($document->getItems() as $item) {
+				?>
+				<tr>
+					<td><?=htmlspecialchars($item->description)?></td>
+					<td><?=htmlspecialchars($item->serial_number)?></td>
+					<td class="text-end"><?=htmlspecialchars($formatter->formatCurrency($item->insurance_value, $aru->currency))?></td>
+				</tr>
+				<?php
+			}
+			?>
+			</tbody>
+			<tfoot>
+			<tr>
+				<td colspan="3">
+					<strong>
+						The goods should be examined immediately on arrival and any apparent damage, shortage or misdescription notified at once to us, quoting this ARU DN number within 3 days.
+					</strong>
+				</td>
+			</tr>
+			</tfoot>
+		</table>
+
+		<div class="card mb-2">
+			<div class="card-header">
+				<div class="d-flex justify-content-between">
+					<strong>Description of Fault / Additional Comments</strong>
+					<div class="badge text-bg-danger">
+						TO BE COMPLETED BY CUSTOMER
+					</div>
+				</div>
+			</div>
+			<div class="card-body" style="min-height: 100px;">
+				<?=$document->getNotesHtml()?>
+			</div>
+		</div>
+
+		<div class="mb-2 border-4 text-danger compact text-center p-1">
+			<strong class="large text-uppercase">Items must be returned to the address below:</strong><br />
+			<strong class="large"><?=htmlspecialchars($company->name)?>, <?=htmlspecialchars(implode(", ", $address_lines))?></strong><br />
+			Tel: <?=htmlspecialchars($company->phone)?>
+			<span class="px-1"></span>
+			Fax: <?=htmlspecialchars($company->fax)?>
+			<span class="px-1"></span>
+			Email: <?=htmlspecialchars($company->email)?>
+		</div>
+
+		<div class="row g-2">
+			<div class="col-4">
+				<div class="card mb-2">
+					<div class="card-header">
+						<strong>Received Goods-In</strong>
+					</div>
+					<div class="card-body">
+						<?php
+						if(empty($goods_in_documents)) {
+							?>
+							No Goods-Ins
+							<?php
+						}
+
+						foreach($goods_in_documents as $goods_in_document) {
+							?>
+							<div>
+								<strong>
+									GIN <?=$goods_in_document->number?>
+								</strong>
+								<span class="px-1"></span>
+								<?=htmlspecialchars($goods_in_document->getDisplayDate())?>
+							</div>
+							<?php
+						}
+						?>
+					</div>
+				</div>
+			</div>
+			<div class="col-4">
+				<div class="card mb-2">
+					<div class="card-header">
+						<strong>Invoices</strong>
+					</div>
+					<div class="card-body">
+						<?php
+						if(empty($invoices)) {
+							?>
+							No Invoices
+							<?php
+						}
+
+						foreach($invoices as $invoice) {
+							?>
+							<div>
+								<strong>
+									INV <?=$invoice->number?>
+								</strong>
+								<span class="px-1"></span>
+								<?=htmlspecialchars($invoice->getDisplayDate())?>
+								<span class="px-1"></span>
+								<strong>
+									<?=htmlspecialchars($formatter->formatCurrency($invoice->getSubtotal(), $aru->currency))?>
+								</strong>
+							</div>
+							<?php
+						}
+						?>
+					</div>
+				</div>
+			</div>
+			<div class="col-4">
+				<div class="card mb-2">
+					<div class="card-header">
+						<strong>ARU Parts</strong>
+					</div>
+					<div class="card-body">
+						<?php
+						$aru_items = $aru->getItems();
+						if(!$aru_items) {
+							?>
+							No Items
+							<?php
+						}
+						else {
+							?>
+							<ul class="mb-0 list-unstyled">
+								<?php
+								foreach($aru_items as $aru_item) {
+									?>
+									<li>
+										<?=htmlspecialchars($aru_item->description)?> &times; <?=$aru_item->quantity?>
+										<?php
+										if($aru_item->serial_number) {
+											?>
+											<span class="text-muted">(S/N: <?=htmlspecialchars($aru_item->serial_number)?>)</span>
+											<?php
+										}
+										?>
+									</li>
+									<?php
+								}
+								?>
+							</ul>
+							<?php
+						}
+						?>
+					</div>
+				</div>
+			</div>
+		</div>
+	</div><!-- End of container -->
+</body>
+</html>

+ 25 - 2
views/arus.php

@@ -38,6 +38,7 @@ else {
 		<tr>
 			<th><?=htmlspecialchars(__("Number"))?></th>
 			<th><?=htmlspecialchars(__("Location"))?></th>
+			<th><?=htmlspecialchars(__("Status"))?></th>
 			<th><?=htmlspecialchars(__("Items"))?></th>
 			<th><?=htmlspecialchars(__("Actions"))?></th>
 		</tr>
@@ -48,7 +49,7 @@ else {
 			$location = $document->getLocation();
 			?>
 			<tr>
-				<td class="text-right">
+				<td class="text-end">
 					<?=htmlspecialchars($document->number)?>
 				</td>
 				<td>
@@ -57,7 +58,29 @@ else {
 					</a>
 				</td>
 				<td>
-					Items
+					<?=htmlspecialchars($document->getDisplayAruStatus())?>
+				</td>
+				<td>
+					<ul class="list-unstyled mb-0">
+						<?php
+						foreach($document->getItems() as $item) {
+							?>
+							<li>
+								<?=htmlspecialchars($item->description)?> &times; <?=$item->quantity?>
+								<?php
+								if($item->serial_number) {
+									?>
+									<span class="text-muted">
+										(S/N: <?=htmlspecialchars($item->serial_number)?>)
+									</span>
+									<?php
+								}
+								?>
+							</li>
+							<?php
+						}
+						?>
+					</ul>
 				</td>
 				<td class="p-1">
 					<a class="btn btn-sm btn-primary" href="<?=htmlspecialchars($document->getUrl())?>">

+ 8 - 6
views/components/address_fields.php

@@ -20,28 +20,30 @@ else {
 <input type="hidden" name="latitude" value="<?=htmlspecialchars($latitude)?>" />
 <input type="hidden" name="longitude" value="<?=htmlspecialchars($longitude)?>" />
 
+<h4><?=htmlspecialchars(__("Address"))?></h4>
+
 <div class="mb-3">
-	<label for="address-1"><?=htmlspecialchars(__("Address Line 1"))?></label>
+	<label class="form-label" for="address-1"><?=htmlspecialchars(__("Address Line 1"))?></label>
 	<input class="form-control" type="text" id="address-1" name="address_1" placeholder="<?=htmlspecialchars(__("Type address line 1"))?>" value="<?=htmlspecialchars($address->address_1)?>" />
 </div>
 <div class="mb-3">
-	<label for="address-2"><?=htmlspecialchars(__("Address Line 2"))?></label>
+	<label class="form-label" for="address-2"><?=htmlspecialchars(__("Address Line 2"))?></label>
 	<input class="form-control" type="text" id="address-2" name="address_2" placeholder="<?=htmlspecialchars(__("Type address line 2"))?>" value="<?=htmlspecialchars($address->address_2)?>" />
 </div>
 <div class="mb-3">
-	<label for="city"><?=htmlspecialchars(__("Town/City"))?></label>
+	<label class="form-label" for="city"><?=htmlspecialchars(__("Town/City"))?></label>
 	<input class="form-control" type="text" id="city" name="city" placeholder="<?=htmlspecialchars(__("Type town/city"))?>" value="<?=htmlspecialchars($address->city)?>" />
 </div>
 <div class="row">
 	<div class="col-6">
 		<div class="mb-3">
-			<label for="county"><?=htmlspecialchars(__("County"))?></label>
+			<label class="form-label" for="county"><?=htmlspecialchars(__("County"))?></label>
 			<input class="form-control" type="text" id="county" name="county" placeholder="<?=htmlspecialchars(__("Type county"))?>" value="<?=htmlspecialchars($address->county)?>" />
 		</div>
 	</div>
 	<div class="col-6">
 		<div class="mb-3">
-			<label for="postal-code"><?=htmlspecialchars(__("Postcode"))?></label>
+			<label class="form-label" for="postal-code"><?=htmlspecialchars(__("Postcode"))?></label>
 			<input class="form-control" type="text" id="postal-code" name="postal_code" placeholder="<?=htmlspecialchars(__("Type postcode"))?>" value="<?=htmlspecialchars($address->postal_code)?>" required />
 		</div>
 	</div>
@@ -49,7 +51,7 @@ else {
 <div class="row mb-3">
 	<div class="col-6">
 		<div class="mb-3">
-			<label for="country"><?=htmlspecialchars(__("Country"))?></label>
+			<label class="form-label" for="country"><?=htmlspecialchars(__("Country"))?></label>
 			<select class="form-select" name="country" id="country">
 				<option value=""><?=htmlspecialchars(__("Select Country"))?></option>
 				<?php

+ 48 - 4
views/document.php

@@ -2,11 +2,10 @@
 
 namespace App;
 
+use App\Enums\AruStatuses;
 use App\Enums\Currencies;
-use App\Enums\DocumentTypes;
 use App\Enums\InvoiceStatuses;
 use App\Helpers\HtmlHelper;
-use NumberFormatter;
 
 /**
  * @var Sale $sale
@@ -64,6 +63,22 @@ $related_document = $document->getRelatedDocument();
 						</div>
 						<?php
 					}
+					if($document->isAru()) {
+						?>
+						<div class="col-sm-6">
+							<div class="mb-3">
+								<label for="aru-status" class="form-label">
+									<?=htmlspecialchars(__("Status"))?>
+								</label>
+								<select class="form-control" name="aru_status" id="aru-status">
+									<?php
+									HtmlHelper::renderOptions(AruStatuses::options(), $document->aru_status);
+									?>
+								</select>
+							</div>
+						</div>
+						<?php
+					}
 					?>
 					<div class="col-sm-6">
 						<div class="mb-3">
@@ -200,6 +215,37 @@ $related_document = $document->getRelatedDocument();
 					</label>
 					<input type="text" class="form-control" name="tracking_number" id="tracking-number" placeholder="<?=htmlspecialchars(__("Type tracking number"))?>" value="<?=htmlspecialchars($document->tracking_number)?>" />
 				</div>
+				<?php
+				if($document->isDeliveryNote() && $document->isPartOfAru()) {
+					?>
+					<div class="mb-3">
+						<label for="delivery-cost" class="form-label">
+							<?=htmlspecialchars(__("Delivery Cost"))?>
+						</label>
+						<input type="number" class="form-control" name="delivery_cost" id="delivery-cost" placeholder="<?=htmlspecialchars(__("Type delivery cost"))?>" value="<?=htmlspecialchars($document->delivery_cost)?>" min="0" required />
+					</div>
+					<?php
+				}
+				?>
+
+				<div class="mb-3">
+					<label for="contact-name" class="form-label">
+						<?=htmlspecialchars(__("Contact Name"))?>
+					</label>
+					<input type="text" class="form-control" name="contact_name" id="contact-name" placeholder="<?=htmlspecialchars(__("Type contact name"))?>" value="<?=htmlspecialchars($document->contact_name)?>" />
+				</div>
+				<div class="mb-3">
+					<label for="contact-phone" class="form-label">
+						<?=htmlspecialchars(__("Contact Phone / Mobile"))?>
+					</label>
+					<input type="tel" class="form-control" name="contact_phone" id="contact-phone" placeholder="<?=htmlspecialchars(__("Type contact phone or mobile number"))?>" value="<?=htmlspecialchars($document->contact_phone)?>" />
+				</div>
+				<div class="mb-3">
+					<label for="contact-email" class="form-label">
+						<?=htmlspecialchars(__("Contact Email Address"))?>
+					</label>
+					<input type="text" class="form-control" name="contact_email" id="contact-email" placeholder="<?=htmlspecialchars(__("Type contact email address"))?>" value="<?=htmlspecialchars($document->contact_email)?>" />
+				</div>
 
 				<dl>
 					<?php
@@ -302,8 +348,6 @@ $related_document = $document->getRelatedDocument();
 			<?php
 		}
 		?>
-
-
 	</form>
 </section>
 

+ 24 - 3
views/document_items_section.php

@@ -1,4 +1,4 @@
-<?php
+<?php /** @noinspection PhpUnhandledExceptionInspection */
 namespace App;
 
 use App\Helpers\HtmlHelper;
@@ -30,7 +30,7 @@ if($document->isAru()) {
 			<h3><?=htmlspecialchars($title)?></h3>
 		</div>
 		<div class="col-auto">
-			<button type="button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#document-item-modal">
+			<button type="button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#document-item-modal" data-document-type="<?=$document->type?>">
 				<i class="fa fa-fw fa-plus"></i>
 				<?=htmlspecialchars(__("Add Item"))?>
 			</button>
@@ -58,6 +58,11 @@ if($document->isAru()) {
 						<col style="width: 15%"/>
 						<?php
 					}
+					if($document->isDeliveryNote()) {
+						?>
+						<col style="width: 15%"/>
+						<?php
+					}
 					?>
 					<col style="width: 1%"/>
 				</colgroup>
@@ -77,6 +82,11 @@ if($document->isAru()) {
 						<th><?=htmlspecialchars(__("Amount"))?></th>
 						<?php
 					}
+					if($document->isDeliveryNote()) {
+						?>
+						<th><?=htmlspecialchars(__("Insurance Value"))?></th>
+						<?php
+					}
 					?>
 					<th><?=htmlspecialchars(__("Actions"))?></th>
 				</tr>
@@ -115,9 +125,16 @@ if($document->isAru()) {
 							<?php
 							$subtotal = bcadd($subtotal, $item->getAmount());
 						}
+						if($document->isDeliveryNote()) {
+							?>
+							<td class="text-end">
+								<?=htmlspecialchars($formatter->formatCurrency($item->insurance_value, $currency))?>
+							</td>
+							<?php
+						}
 						?>
 						<td class="p-1 text-nowrap">
-							<button class="btn btn-sm btn-primary" type="button" data-bs-toggle="modal" data-bs-target="#document-item-modal" data-document-id="<?=$document->id?>" data-item="<?=htmlspecialchars(json_encode($item))?>">
+							<button class="btn btn-sm btn-primary" type="button" data-bs-toggle="modal" data-bs-target="#document-item-modal" data-document-id="<?=$document->id?>" data-document-type="<?=$document->type?>" data-item="<?=htmlspecialchars(json_encode($item))?>">
 								<i class="fa fa-fw fa-pencil"></i>
 							</button>
 							<button class="btn btn-sm btn-danger btn-delete-document-item" type="button" data-document-item-id="<?=$item->id?>">
@@ -178,6 +195,10 @@ if($document->isAru()) {
 					<i class="fa fa-fw fa-file-invoice"></i>
 					<?=htmlspecialchars(__("Create Invoice"))?>
 				</button>
+				<button type="submit" class="btn btn-primary" name="batch_action" value="create-goods-in">
+					<i class="fa fa-fw fa-truck"></i>
+					<?=htmlspecialchars(__("Create Goods-In"))?>
+				</button>
 				<?php
 			}
 

+ 34 - 13
views/entity_form.php

@@ -26,12 +26,14 @@ $is_location = $model instanceof Location;
 	<div class="row">
 		<div class="col-lg">
 
+			<h4><?=htmlspecialchars(__("Main Details"))?></h4>
+
 			<?php
 			if($is_location) {
 				$customers = Customer::getAll();
 				?>
 				<div class="mb-3">
-					<label for="customer-id"><?=htmlspecialchars(__("Customer"))?></label>
+					<label class="form-label" for="customer-id"><?=htmlspecialchars(__("Customer"))?></label>
 					<select class="form-select" name="customer_id" id="customer-id" required>
 						<option value=""><?=htmlspecialchars(__("Select Customer"))?></option>
 						<?php
@@ -50,27 +52,27 @@ $is_location = $model instanceof Location;
 			?>
 
 			<div class="mb-3">
-				<label for="name"><?=htmlspecialchars(__("Name"))?></label>
+				<label class="form-label" for="name"><?=htmlspecialchars(__("Name"))?></label>
 				<input class="form-control" type="text" id="name" name="name" placeholder="<?=htmlspecialchars(__("Type name"))?>" value="<?=htmlspecialchars($model->name)?>" required />
 			</div>
 
 			<div class="row">
 				<div class="col-6">
 					<div class="mb-3">
-						<label for="phone"><?=htmlspecialchars(__("Phone"))?></label>
+						<label class="form-label" for="phone"><?=htmlspecialchars(__("Phone"))?></label>
 						<input class="form-control" type="tel" id="phone" name="phone" placeholder="<?=htmlspecialchars(__("Type phone"))?>" value="<?=htmlspecialchars($model->phone)?>" />
 					</div>
 				</div>
 				<div class="col-6">
 					<div class="mb-3">
-						<label for="fax"><?=htmlspecialchars(__("Fax"))?></label>
+						<label class="form-label" for="fax"><?=htmlspecialchars(__("Fax"))?></label>
 						<input class="form-control" type="tel" id="fax" name="fax" placeholder="<?=htmlspecialchars(__("Type fax"))?>" value="<?=htmlspecialchars($model->fax)?>" />
 					</div>
 				</div>
 			</div>
 
 			<div class="mb-3">
-				<label for="email"><?=htmlspecialchars(__("Email"))?></label>
+				<label class="form-label" for="email"><?=htmlspecialchars(__("Email"))?></label>
 				<input class="form-control" type="email" id="email" name="email" placeholder="<?=htmlspecialchars(__("Type email"))?>" value="<?=htmlspecialchars($model->email)?>" />
 			</div>
 
@@ -80,19 +82,38 @@ $is_location = $model instanceof Location;
 				<div class="row">
 					<div class="col-6">
 						<div class="mb-3">
-							<label for="company-number"><?=htmlspecialchars(__("Company Number"))?></label>
+							<label class="form-label" for="company-number"><?=htmlspecialchars(__("Company Number"))?></label>
 							<input class="form-control" type="text" id="company-number" name="company_number" placeholder="<?=htmlspecialchars(__("Type company number"))?>" value="<?=htmlspecialchars($model->company_number)?>" />
 						</div>
 					</div>
 					<div class="col-6">
 						<div class="mb-3">
-							<label for="vat-number"><?=htmlspecialchars(__("VAT Number"))?></label>
+							<label class="form-label" for="vat-number"><?=htmlspecialchars(__("VAT Number"))?></label>
 							<input class="form-control" type="tel" id="vat-number" name="vat_number" placeholder="<?=htmlspecialchars(__("Type VAT number"))?>" value="<?=htmlspecialchars($model->vat_number)?>" />
 						</div>
 					</div>
 				</div>
 				<?php
 			}
+
+			if($is_location) {
+				?>
+				<h4><?=htmlspecialchars(__("Contact Person"))?></h4>
+
+				<div class="mb-3">
+					<label class="form-label" for="contact-name"><?=htmlspecialchars(__("Name"))?></label>
+					<input class="form-control" type="text" id="contact-name" name="contact_name" placeholder="<?=htmlspecialchars(__("Type contact name"))?>" value="<?=htmlspecialchars($model->contact_name)?>" />
+				</div>
+				<div class="mb-3">
+					<label class="form-label" for="contact-phone"><?=htmlspecialchars(__("Phone / Mobile"))?></label>
+					<input class="form-control" type="tel" id="contact-phone" name="contact_phone" placeholder="<?=htmlspecialchars(__("Type contact phone or mobile number"))?>" value="<?=htmlspecialchars($model->contact_phone)?>" />
+				</div>
+				<div class="mb-3">
+					<label class="form-label" for="contact-email"><?=htmlspecialchars(__("Email Address"))?></label>
+					<input class="form-control" type="email" id="contact-email" name="contact_email" placeholder="<?=htmlspecialchars(__("Type contact email address"))?>" value="<?=htmlspecialchars($model->contact_email)?>" />
+				</div>
+				<?php
+			}
 			?>
 
 		</div>
@@ -118,36 +139,36 @@ $is_location = $model instanceof Location;
 					<h4><?=htmlspecialchars(__("%s Bank Details", $value))?></h4>
 
 					<div class="mb-3">
-						<label for="<?=$value?>-bank-name"><?=htmlspecialchars(__("Bank Name"))?></label>
+						<label class="form-label" for="<?=$value?>-bank-name"><?=htmlspecialchars(__("Bank Name"))?></label>
 						<input class="form-control" type="text" id="<?=$value?>-bank-name" name="bank_names[]" value="<?=htmlspecialchars($bank_details->bank_name)?>" placeholder="<?=htmlspecialchars(__("Type bank name"))?>" />
 					</div>
 					<div class="mb-3">
-						<label for="<?=$value?>-bank-address"><?=htmlspecialchars(__("Bank Address"))?></label>
+						<label class="form-label" for="<?=$value?>-bank-address"><?=htmlspecialchars(__("Bank Address"))?></label>
 						<input class="form-control" type="text" id="<?=$value?>-bank-address" name="bank_addresses[]" value="<?=htmlspecialchars($bank_details->bank_address)?>" placeholder="<?=htmlspecialchars(__("Type bank address"))?>" />
 					</div>
 
 					<div class="row">
 						<div class="col-6">
 							<div class="mb-3">
-								<label for="<?=$value?>-bank-sort-code"><?=htmlspecialchars(__("Sort Code"))?></label>
+								<label class="form-label" for="<?=$value?>-bank-sort-code"><?=htmlspecialchars(__("Sort Code"))?></label>
 								<input class="form-control" type="text" id="<?=$value?>-bank-sort-code" name="bank_sort_codes[]" value="<?=htmlspecialchars($bank_details->bank_sort_code)?>" placeholder="<?=htmlspecialchars(__("Type sort code"))?>" />
 							</div>
 						</div>
 						<div class="col-6">
 							<div class="mb-3">
-								<label for="<?=$value?>-bank-account-name"><?=htmlspecialchars(__("Account Name"))?></label>
+								<label class="form-label" for="<?=$value?>-bank-account-name"><?=htmlspecialchars(__("Account Name"))?></label>
 								<input class="form-control" type="text" id="<?=$value?>-bank-account-name" name="bank_account_names[]" value="<?=htmlspecialchars($bank_details->bank_account_name)?>" placeholder="<?=htmlspecialchars(__("Type account name"))?>" />
 							</div>
 						</div>
 						<div class="col-6">
 							<div class="mb-3">
-								<label for="<?=$value?>-bank-account-number"><?=htmlspecialchars(__("Account Number"))?></label>
+								<label class="form-label" for="<?=$value?>-bank-account-number"><?=htmlspecialchars(__("Account Number"))?></label>
 								<input class="form-control" type="text" id="<?=$value?>-bank-account-number" name="bank_account_numbers[]" value="<?=htmlspecialchars($bank_details->bank_account_number)?>" placeholder="<?=htmlspecialchars(__("Type account number"))?>" />
 							</div>
 						</div>
 						<div class="col-6">
 							<div class="mb-3">
-								<label for="<?=$value?>-bank-account-iban"><?=htmlspecialchars(__("IBAN"))?></label>
+								<label class="form-label" for="<?=$value?>-bank-account-iban"><?=htmlspecialchars(__("IBAN"))?></label>
 								<input class="form-control" type="text" id="<?=$value?>-bank-account-iban" name="bank_account_ibans[]" value="<?=htmlspecialchars($bank_details->bank_account_iban)?>" placeholder="<?=htmlspecialchars(__("Type IBAN"))?>" />
 							</div>
 						</div>

+ 27 - 10
views/goods_in.php

@@ -37,7 +37,7 @@ else {
 		<thead>
 		<tr>
 			<th><?=htmlspecialchars(__("Number"))?></th>
-			<th><?=htmlspecialchars(__("Location"))?></th>
+			<th><?=htmlspecialchars(__("Supplier / Location"))?></th>
 			<th><?=htmlspecialchars(__("Items"))?></th>
 			<th><?=htmlspecialchars(__("Actions"))?></th>
 		</tr>
@@ -49,29 +49,46 @@ else {
 			$supplier = $document->getSupplier();
 			?>
 			<tr>
-				<td class="text-right">
-					<?=htmlspecialchars($document->number)?>
+				<td class="text-end">
+					<a href="<?=htmlspecialchars($document->getUrl())?>"><?=$document->number?></a>
 				</td>
 				<td>
 					<?php
 					if($location) {
 						?>
-						<a href="<?=htmlspecialchars($location->getUrl())?>">
-							<?=htmlspecialchars($location->getDisplayName())?>
-						</a>
+						<a href="<?=htmlspecialchars($location->getUrl())?>"><?=htmlspecialchars($location->getDisplayName())?></a>
+						<i class="fa fa-fw fa-shop"></i>
 						<?php
 					}
 					else if($supplier) {
 						?>
-						<a href="<?=htmlspecialchars($supplier->getUrl())?>">
-							<?=htmlspecialchars($supplier->name)?>
-						</a>
+						<a href="<?=htmlspecialchars($supplier->getUrl())?>"><?=htmlspecialchars($supplier->name)?></a>
+						<i class="fa fa-fw fa-truck"></i>
 						<?php
 					}
 					?>
 				</td>
 				<td>
-					Items
+					<ul class="list-unstyled mb-0">
+						<?php
+						foreach($document->getItems() as $item) {
+							?>
+							<li>
+								<?=htmlspecialchars($item->description)?> &times; <?=$item->quantity?>
+								<?php
+								if($item->serial_number) {
+									?>
+									<span class="text-muted">
+										(S/N: <?=htmlspecialchars($item->serial_number)?>)
+									</span>
+									<?php
+								}
+								?>
+							</li>
+							<?php
+						}
+						?>
+					</ul>
 				</td>
 				<td class="p-1">
 					<a class="btn btn-sm btn-primary" href="<?=htmlspecialchars($document->getUrl())?>">

+ 10 - 4
views/modals/document_item.php

@@ -25,16 +25,22 @@ namespace App;
 					<input class="form-control" type="text" name="serial_number" id="document-item-serial-number" placeholder="<?=htmlspecialchars(__("Type serial number"))?>" maxlength="255" />
 				</div>
 				<div class="mb-3">
-					<label for="sale-item-quantity" class="form-label">
+					<label for="document-item-quantity" class="form-label">
 						<?=htmlspecialchars(__("Quantity"))?>
 					</label>
-					<input class="form-control" type="number" name="quantity" id="sale-item-quantity" min="0" value="1" placeholder="<?=htmlspecialchars(__("Type quantity"))?>" required />
+					<input class="form-control" type="number" name="quantity" id="document-item-quantity" min="0" value="1" placeholder="<?=htmlspecialchars(__("Type quantity"))?>" required />
 				</div>
 				<div class="mb-3">
-					<label for="sale-item-unit-price" class="form-label">
+					<label for="document-item-unit-price" class="form-label">
 						<?=htmlspecialchars(__("Unit Price"))?>
 					</label>
-					<input class="form-control" type="number" name="unit_price" id="sale-item-unit-price" min="0.00" step="0.01" value="0.00" placeholder="<?=htmlspecialchars(__("Type unit price"))?>" required />
+					<input class="form-control" type="number" name="unit_price" id="document-item-unit-price" min="0.00" step="0.01" value="0.00" placeholder="<?=htmlspecialchars(__("Type unit price"))?>" required />
+				</div>
+				<div class="mb-3">
+					<label for="document-item-insurance-value" class="form-label">
+						<?=htmlspecialchars(__("Insurance Value"))?>
+					</label>
+					<input class="form-control" type="number" name="insurance_value" id="document-item-insurance-value" min="0.00" step="0.01" value="0.00" placeholder="<?=htmlspecialchars(__("Type insurance value"))?>" required />
 				</div>
 			</div>
 			<div class="modal-footer">

+ 1 - 1
views/modals/new_document.php

@@ -12,7 +12,7 @@ namespace App;
 			<div class="modal-body">
 				<div class="mb-3">
 					<label class="form-label" for="new-document-company-id"><?= htmlspecialchars(__("Company")) ?></label>
-					<select class="form-control" name="company_id" id="new-document-company-id">
+					<select class="form-control" name="company_id" id="new-document-company-id" required>
 						<option value=""><?=htmlspecialchars(__("Select Company"))?></option>
 						<?php
 						foreach(Company::getAll() as $company) {

+ 1 - 1
views/sales.php

@@ -46,7 +46,7 @@ else {
 			$location = $sale->getLocation();
 			?>
 			<tr>
-				<td class="text-right">
+				<td class="text-end">
 					<?=htmlspecialchars($sale->getNumber())?>
 				</td>
 				<td>