فهرست منبع

Add ability to enter proforma/commercial invoice notes for a sales order

Alan Lam 3 سال پیش
والد
کامیت
7547a0c9ba

+ 2 - 0
controllers/document.php

@@ -228,6 +228,8 @@ $controller = new class($document_type, $document_number) {
 		}
 
 		$document->notes = $this->request->string("notes");
+		$document->proforma_notes = $this->request->string("proforma_notes");
+		$document->commercial_notes = $this->request->string("commercial_notes");
 
 		$document->delivery_company = $this->request->string("delivery_company");
 		$document->tracking_number = $this->request->string("tracking_number");

+ 13 - 0
db/migrations/20231013215150_add_proforma_commercial_note_fields_to_document_table.php

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

+ 3 - 1
engine/Document.php

@@ -38,6 +38,8 @@ use RuntimeException;
  * @property string $tracking_number
  * @property string $delivery_cost
  * @property string $notes
+ * @property string $proforma_notes
+ * @property string $commercial_notes
  * @property string $contact_name
  * @property string $contact_phone
  * @property string $contact_email
@@ -56,7 +58,7 @@ class Document extends Model {
 		"billing_address", "delivery_address",
 		"number", "date", "po_number", "terms", "vat_number",
 		"delivery_company", "tracking_number", "delivery_cost",
-		"notes",
+		"notes", "proforma_notes", "commercial_notes",
 		"contact_name", "contact_phone", "contact_email",
 		"dts_finalised", "dts_paid",
 		"dts_created", "dts_updated", "dts_deleted"

+ 21 - 2
views/document.php

@@ -212,11 +212,30 @@ $location = $document->getLocation();
 
 				<div class="mb-3">
 					<label for="notes" class="form-label">
-						<?=htmlspecialchars(__("Notes"))?>
+						<?=htmlspecialchars(__("Internal Notes"))?>
 					</label>
-					<textarea class="form-control" name="notes" id="notes" rows="6" placeholder="<?=htmlspecialchars(__("Type notes"))?>"><?=htmlspecialchars($document->notes)?></textarea>
+					<textarea class="form-control" name="notes" id="notes" rows="3" placeholder="<?=htmlspecialchars(__("Type notes"))?>"><?=htmlspecialchars($document->notes)?></textarea>
 				</div>
 
+				<?php
+				if($document->isSalesOrder()) {
+					?>
+					<div class="mb-3">
+						<label for="proforma-notes" class="form-label">
+							<?=htmlspecialchars(__("Proforma Invoice Notes"))?>
+						</label>
+						<textarea class="form-control" name="proforma_notes" id="proforma-notes" rows="3" placeholder="<?=htmlspecialchars(__("Type notes"))?>"><?=htmlspecialchars($document->proforma_notes)?></textarea>
+					</div>
+					<div class="mb-3">
+						<label for="commercial-notes" class="form-label">
+							<?=htmlspecialchars(__("Commercial Invoice Notes"))?>
+						</label>
+						<textarea class="form-control" name="commercial_notes" id="commercial-notes" rows="3" placeholder="<?=htmlspecialchars(__("Type notes"))?>"><?=htmlspecialchars($document->commercial_notes)?></textarea>
+					</div>
+					<?php
+				}
+				?>
+
 			</div>
 			<div class="col-xl-4">
 

+ 27 - 0
views/document_pdf.php

@@ -183,6 +183,33 @@ $is_part_of_aru = $document->isPartOfAru();
 					</div>
 
 					<?php
+					if($is_proforma && $document->proforma_notes) {
+						?>
+						<div class="card mb-2">
+							<div class="card-header bg-document">
+								Notes
+							</div>
+							<div class="card-body">
+								<?=nl2br(htmlspecialchars($document->proforma_notes))?>
+							</div>
+						</div>
+						<?php
+					}
+
+					if($is_commercial && $document->commercial_notes) {
+						?>
+						<div class="card mb-2">
+							<div class="card-header bg-document">
+								Notes
+							</div>
+							<div class="card-body">
+								<?=nl2br(htmlspecialchars($document->commercial_notes))?>
+							</div>
+						</div>
+						<?php
+					}
+
+
 				}
 				?>
 			</div>