فهرست منبع

Add ability to add a sales order via the location form

Alan Lam 2 سال پیش
والد
کامیت
508d785b7e
3فایلهای تغییر یافته به همراه24 افزوده شده و 9 حذف شده
  1. 7 0
      public/js/new-document-modal.js
  2. 4 0
      views/entity_form.php
  3. 13 9
      views/modals/new_document.php

+ 7 - 0
public/js/new-document-modal.js

@@ -38,6 +38,13 @@ class NewDocumentModal {
 			theme: "bootstrap-5",
 			theme: "bootstrap-5",
 			dropdownParent: this.$locationDropdown.closest("div")
 			dropdownParent: this.$locationDropdown.closest("div")
 		});
 		});
+
+		const parameters = new URLSearchParams(window.location.search);
+		const locationId = parameters.get("add_location_id");
+		if(locationId) {
+			const button = document.getElementById("new-document-button");
+			button.click();
+		}
 	}
 	}
 
 
 	getField(name) {
 	getField(name) {

+ 4 - 0
views/entity_form.php

@@ -39,6 +39,10 @@ if($is_location) {
 				<i class="fa fa-fw fa-plus"></i>
 				<i class="fa fa-fw fa-plus"></i>
 				<?=htmlspecialchars(__("Add Lead"))?>
 				<?=htmlspecialchars(__("Add Lead"))?>
 			</a>
 			</a>
+			<a class="btn btn-success" href="/sales-orders?add_location_id=<?=$model->id?>">
+				<i class="fa fa-fw fa-plus"></i>
+				<?=htmlspecialchars(__("Add Sales Order"))?>
+			</a>
 			<?php
 			<?php
 		}
 		}
 		?>
 		?>

+ 13 - 9
views/modals/new_document.php

@@ -7,6 +7,18 @@ $settings = $core->getSettings();
 
 
 $products = Product::query([], ["sort" => "name"]);
 $products = Product::query([], ["sort" => "name"]);
 
 
+$request = Request::fromRequest();
+$default_location_id = $request->int("add_location_id");
+
+$location_options = [];
+
+foreach(Customer::getAll() as $customer) {
+	foreach($customer->getLocations() as $location) {
+		$location_options[$location->id] = $location->getDisplayName();
+	}
+}
+
+
 ?>
 ?>
 <div class="modal fade" role="dialog" tabindex="-1" data-backdrop="static" id="new-document-modal">
 <div class="modal fade" role="dialog" tabindex="-1" data-backdrop="static" id="new-document-modal">
 	<div class="modal-dialog modal-lg">
 	<div class="modal-dialog modal-lg">
@@ -47,15 +59,7 @@ $products = Product::query([], ["sort" => "name"]);
 					<select class="form-select" name="location_id" id="new-document-location-id">
 					<select class="form-select" name="location_id" id="new-document-location-id">
 						<option value=""><?=htmlspecialchars(__("Select Location"))?></option>
 						<option value=""><?=htmlspecialchars(__("Select Location"))?></option>
 						<?php
 						<?php
-						foreach(Customer::getAll() as $customer) {
-							foreach($customer->getLocations() as $location) {
-								?>
-								<option value="<?=$location->id?>">
-									<?=htmlspecialchars($location->getDisplayName())?>
-								</option>
-								<?php
-							}
-						}
+						HtmlHelper::renderOptions($location_options, $default_location_id);
 						?>
 						?>
 					</select>
 					</select>
 				</div>
 				</div>