Prechádzať zdrojové kódy

Add SKU prefix field for suppliers

Alan Lam 2 rokov pred
rodič
commit
5cb0ae3226

+ 1 - 0
controllers/supplier_form.php

@@ -45,6 +45,7 @@ if($submit) {
 		$supplier->name = $request->string("name");
 		$supplier->name = $request->string("name");
 		$supplier->phone = $request->string("phone");
 		$supplier->phone = $request->string("phone");
 		$supplier->email = $request->email("email");
 		$supplier->email = $request->email("email");
+		$supplier->sku_prefix = $request->string("sku_prefix");
 
 
 		$address->address_1 = $request->string("address_1");
 		$address->address_1 = $request->string("address_1");
 		$address->address_2 = $request->string("address_2");
 		$address->address_2 = $request->string("address_2");

+ 12 - 0
db/migrations/20240611121226_add_sku_prefix_field_to_supplier_table.php

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

+ 2 - 1
engine/Supplier.php

@@ -10,6 +10,7 @@ namespace App;
  * @property string $phone
  * @property string $phone
  * @property string $fax
  * @property string $fax
  * @property string $email
  * @property string $email
+ * @property string $sku_prefix
  * @property string $dts_created
  * @property string $dts_created
  * @property string $dts_updated
  * @property string $dts_updated
  * @property string $dts_deleted
  * @property string $dts_deleted
@@ -19,7 +20,7 @@ class Supplier extends Model {
 
 
 	protected static $table = "supplier";
 	protected static $table = "supplier";
 	protected static $idField = "id";
 	protected static $idField = "id";
-	protected static $fillableFields = ["address_id", "name", "phone", "fax", "email", "dts_created", "dts_updated", "dts_deleted"];
+	protected static $fillableFields = ["address_id", "name", "phone", "fax", "email", "sku_prefix", "dts_created", "dts_updated", "dts_deleted"];
 
 
 	// Static methods
 	// Static methods
 
 

+ 19 - 2
views/entity_form.php

@@ -1,4 +1,4 @@
-<?php
+<?php /** @noinspection PhpUnhandledExceptionInspection */
 
 
 namespace App;
 namespace App;
 
 
@@ -16,6 +16,7 @@ $user = $core->getUser();
 $is_company = $model instanceof Company;
 $is_company = $model instanceof Company;
 $is_customer = $model instanceof Customer;
 $is_customer = $model instanceof Customer;
 $is_location = $model instanceof Location;
 $is_location = $model instanceof Location;
+$is_supplier = $model instanceof Supplier;
 
 
 $name_label = "Name";
 $name_label = "Name";
 if($is_company || $is_customer) {
 if($is_company || $is_customer) {
@@ -24,6 +25,9 @@ if($is_company || $is_customer) {
 if($is_location) {
 if($is_location) {
 	$name_label = "Location Name";
 	$name_label = "Location Name";
 }
 }
+if($is_supplier) {
+	$name_label = "Supplier Name";
+}
 
 
 ?>
 ?>
 
 
@@ -145,7 +149,7 @@ if($is_location) {
 				?>
 				?>
 				<div class="mb-3">
 				<div class="mb-3">
 					<label class="form-label" for="invoice-footer"><?=htmlspecialchars(__("Invoice Footer"))?></label>
 					<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>
+					<textarea class="form-control" id="invoice-footer" name="invoice_footer" placeholder="<?=htmlspecialchars(__("Type invoice footer"))?>" rows="3" maxlength="255"><?=htmlspecialchars($model->invoice_footer)?></textarea>
 				</div>
 				</div>
 				<?php
 				<?php
 			}
 			}
@@ -181,6 +185,19 @@ if($is_location) {
 				</section>
 				</section>
 				<?php
 				<?php
 			}
 			}
+
+			if($is_supplier) {
+				?>
+				<div class="row">
+					<div class="col-6">
+						<div class="mb-3">
+							<label class="form-label" for="sku-prefix"><?=htmlspecialchars(__("SKU Prefix"))?></label>
+							<input class="form-control" type="text" id="sku-prefix" name="sku_prefix" placeholder="<?=htmlspecialchars(__("Type SKU prefix"))?>" value="<?=htmlspecialchars($model->sku_prefix)?>" maxlength="2" />
+						</div>
+					</div>
+				</div>
+				<?php
+			}
 			?>
 			?>
 
 
 		</div>
 		</div>

+ 6 - 3
views/suppliers.php

@@ -34,9 +34,10 @@ else {
 	<table class="table table-bordered table-hover mb-3">
 	<table class="table table-bordered table-hover mb-3">
 		<colgroup>
 		<colgroup>
 			<col style="width: 1%"/>
 			<col style="width: 1%"/>
-			<col style="width: 33%"/>
-			<col style="width: 33%"/>
-			<col style="width: 33%"/>
+			<col style="width: 25%"/>
+			<col style="width: 25%"/>
+			<col style="width: 25%"/>
+			<col style="width: 25%"/>
 			<col style="width: 1%"/>
 			<col style="width: 1%"/>
 		</colgroup>
 		</colgroup>
 		<thead>
 		<thead>
@@ -45,6 +46,7 @@ else {
 			<th><?=htmlspecialchars(__("Name"))?></th>
 			<th><?=htmlspecialchars(__("Name"))?></th>
 			<th><?=htmlspecialchars(__("Phone"))?></th>
 			<th><?=htmlspecialchars(__("Phone"))?></th>
 			<th><?=htmlspecialchars(__("Email"))?></th>
 			<th><?=htmlspecialchars(__("Email"))?></th>
+			<th><?=htmlspecialchars(__("SKU Prefix"))?></th>
 			<th><?=htmlspecialchars(__("Actions"))?></th>
 			<th><?=htmlspecialchars(__("Actions"))?></th>
 		</tr>
 		</tr>
 		</thead>
 		</thead>
@@ -59,6 +61,7 @@ else {
 				</td>
 				</td>
 				<td><?=htmlspecialchars($supplier->phone)?></td>
 				<td><?=htmlspecialchars($supplier->phone)?></td>
 				<td><?=htmlspecialchars($supplier->email)?></td>
 				<td><?=htmlspecialchars($supplier->email)?></td>
+				<td><?=htmlspecialchars($supplier->sku_prefix)?></td>
 				<td class="p-1 text-nowrap">
 				<td class="p-1 text-nowrap">
 					<a class="btn btn-sm btn-primary" href="<?=htmlspecialchars($supplier->getUrl())?>">
 					<a class="btn btn-sm btn-primary" href="<?=htmlspecialchars($supplier->getUrl())?>">
 						<?=htmlspecialchars(__("View"))?>
 						<?=htmlspecialchars(__("View"))?>