Ver Fonte

Add notes field for locations

Alan Lam há 6 anos atrás
pai
commit
1c8f27c31a

+ 1 - 0
controllers/location_add.php

@@ -31,6 +31,7 @@ if($submit) {
 		$location->email = http::value("email", "email");
 		$location->phone = http::value("phone", "trim");
 		$location->opening_hours = http::value("opening_hours", "trim");
+		$location->notes = http::value("notes", "trim");
 
 		$location->shop_left = http::value("shop_left", "trim");
 		$location->shop_right = http::value("shop_right", "trim");

+ 1 - 0
controllers/location_edit.php

@@ -27,6 +27,7 @@ if($submit) {
 		$location->email = http::value("email", "email");
 		$location->phone = http::value("phone", "trim");
 		$location->opening_hours = http::value("opening_hours", "trim");
+		$location->notes = http::value("notes", "trim");
 
 		$location->shop_left = http::value("shop_left", "trim");
 		$location->shop_right = http::value("shop_right", "trim");

+ 11 - 0
db/migrations/20200907174445_add_notes_field_to_location_table.php

@@ -0,0 +1,11 @@
+<?php
+
+use Phinx\Migration\AbstractMigration;
+
+class AddNotesFieldToLocationTable extends AbstractMigration {
+	public function change() {
+		$this->table("location")
+			->addColumn("notes", "text", ["null" => true, "after" => "opening_hours"])
+			->update();
+	}
+}

+ 2 - 1
engine/location.php

@@ -15,6 +15,7 @@
  * @property string $email
  * @property string $phone
  * @property string $opening_hours
+ * @property string $notes
  * @property string $shop_left
  * @property string $shop_right
  * @property string $brand
@@ -37,7 +38,7 @@ class Location extends Model {
 
 	protected static $table = "location";
 	protected static $id_field = "id";
-	protected static $fillable_fields = ["customer_id", "name", "legal_entity_name", "address_1", "address_2", "city", "county", "postal_code", "state", "country", "email", "phone", "opening_hours", "shop_left", "shop_right", "brand", "region", "region_name", "internal_id", "area_manager", "area_manager_name", "area_manager_email", "operations_manager_name", "do_not_test", "closed", "archived", "latitude", "longitude", "dts_verified"];
+	protected static $fillable_fields = ["customer_id", "name", "legal_entity_name", "address_1", "address_2", "city", "county", "postal_code", "state", "country", "email", "phone", "opening_hours", "notes", "shop_left", "shop_right", "brand", "region", "region_name", "internal_id", "area_manager", "area_manager_name", "area_manager_email", "operations_manager_name", "do_not_test", "closed", "archived", "latitude", "longitude", "dts_verified"];
 
 	// Object methods
 

+ 2 - 0
views/location.php

@@ -16,6 +16,8 @@ $details = [
 	"Address" => htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city", "county", "postal_code"])),
 ];
 
+if($location->opening_hours) $details["Opening Hours"] = $location->opening_hours;
+if($location->notes) $details["Notes"] = $location->notes;
 if($location->shop_left) $details["Shop Name (Left)"] = $location->shop_left;
 if($location->shop_right) $details["Shop Name (Right)"] = $location->shop_right;
 if($location->legal_entity_name) $details["Legal Entity Name"] = $location->legal_entity_name;

+ 7 - 0
views/location_form.php

@@ -127,6 +127,13 @@ if($is_edit) {
 							</div>
 						</div>
 
+						<div class="row mb-1">
+							<label class="col-sm-4 col-form-label" for="notes">Notes</label>
+							<div class="col-sm">
+								<textarea class="form-control" name="notes" id="notes" placeholder="Enter notes" rows="4" maxlength="65535"><?=htmlspecialchars($location->notes)?></textarea>
+							</div>
+						</div>
+
                         <div class="row mb-1">
                             <div class="col-sm offset-sm-4">
                                 <div class="custom-control custom-switch">