Selaa lähdekoodia

Add footer to invoices

Alan Lam 3 vuotta sitten
vanhempi
commit
88083dc825

+ 1 - 0
controllers/company_form.php

@@ -51,6 +51,7 @@ if($submit) {
 		$company->email = $request->email("email");
 		$company->company_number = $request->string("company_number");
 		$company->vat_number = $request->string("vat_number");
+		$company->invoice_footer = $request->string("invoice_footer");
 
 		$address->address_1 = $request->string("address_1");
 		$address->address_2 = $request->string("address_2");

+ 12 - 0
db/migrations/20221225153442_add_invoice_footer_field_to_company_table.php

@@ -0,0 +1,12 @@
+<?php
+declare(strict_types=1);
+
+use Phinx\Migration\AbstractMigration;
+
+final class AddInvoiceFooterFieldToCompanyTable extends AbstractMigration {
+	public function change(): void {
+		$this->table("company")
+			->addColumn("invoice_footer", "string", ["null" => true, "after" => "vat_number"])
+			->update();
+	}
+}

+ 11 - 1
engine/Company.php

@@ -12,6 +12,7 @@ namespace App;
  * @property string $email
  * @property string $company_number
  * @property string $vat_number
+ * @property string $invoice_footer
  * @property string $dts_created
  * @property string $dts_updated
  * @property string $dts_deleted
@@ -21,7 +22,12 @@ class Company extends Model {
 
 	protected static $table = "company";
 	protected static $idField = "id";
-	protected static $fillableFields = ["address_id", "name", "phone", "fax", "email", "company_number", "vat_number", "dts_created", "dts_updated", "dts_deleted"];
+	protected static $fillableFields = [
+		"address_id",
+		"name", "phone", "fax", "email",
+		"company_number", "vat_number", "invoice_footer",
+		"dts_created", "dts_updated", "dts_deleted"
+	];
 
 	// Static methods
 
@@ -74,4 +80,8 @@ class Company extends Model {
 		return $details;
 	}
 
+	public function getInvoiceFooterHtml(): string {
+		return nl2br(htmlspecialchars($this->invoice_footer));
+	}
+
 }

+ 10 - 2
views/document_pdf.php

@@ -383,8 +383,16 @@ $is_part_of_aru = $document->isPartOfAru();
 			?>
 		</table>
 
-	</div><!-- End of container -->
-
+		<?php
+		if($document->isSalesOrder() && $company->invoice_footer) {
+			?>
+			<div class="text-center small">
+				<?=$company->getInvoiceFooterHtml()?>
+			</div>
+			<?php
+		}
+		?>
 
+	</div><!-- End of container -->
 </body>
 </html>

+ 9 - 0
views/entity_form.php

@@ -104,6 +104,15 @@ $is_location = $model instanceof Location;
 			</div>
 
 			<?php
+			if($is_company) {
+				?>
+				<div class="mb-3">
+					<label class="form-label" for="invoice-footer"><?=htmlspecialchars(__("Invoice Footer"))?></label>
+					<textarea class="form-control" type="tel" id="invoice-footer" name="invoice_footer" placeholder="<?=htmlspecialchars(__("Type invoice footer"))?>" rows="3" maxlength="255"><?=htmlspecialchars($model->invoice_footer)?></textarea>
+				</div>
+				<?php
+			}
+
 			if($is_location) {
 				?>
 				<h4><?=htmlspecialchars(__("Contact Person"))?></h4>