From f6496a88242f6e18f078d3dc2f37060a40b9a637 Mon Sep 17 00:00:00 2001 From: Michael Howden Date: Thu, 7 May 2015 16:08:25 +1200 Subject: [PATCH] add location_id to inv_send --- modules/s3db/gis.py | 1 + modules/s3db/inv.py | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/modules/s3db/gis.py b/modules/s3db/gis.py index 474db57129..c68c81726c 100644 --- a/modules/s3db/gis.py +++ b/modules/s3db/gis.py @@ -320,6 +320,7 @@ def model(self): widget = S3LocationSelector(show_address=True, show_map=settings.get_gis_map_selector(), show_postcode=settings.get_gis_postcode_selector(), + levels=["L1", "L2", "L3", "L4"], #@ToDo: Fix ), # Alternate LocationSelector for when you don't have the Location Hierarchy available to load #requires = IS_EMPTY_OR( diff --git a/modules/s3db/inv.py b/modules/s3db/inv.py index 4ca8d6e524..80348e3b1d 100644 --- a/modules/s3db/inv.py +++ b/modules/s3db/inv.py @@ -1095,6 +1095,8 @@ def model(self): not_filter_opts = (True,), )), ), + self.gis_location_id(label = T("To Location"), + ), organisation_id( label = T("To Organization"), readable = show_org, @@ -1183,6 +1185,8 @@ def model(self): s3_comments(), *s3_meta_fields()) + levels = current.gis.get_relevant_hierarchy_levels() + # Filter Widgets filter_widgets = [ S3TextFilter(["sender_id$first_name", @@ -1194,7 +1198,7 @@ def model(self): "recipient_id$first_name", "recipient_id$middle_name", "recipient_id$last_name", - ], + ] + ["location_id$%s" % level for level in levels], label = T("Search"), comment = T("Search for an item by text."), ), @@ -1204,6 +1208,9 @@ def model(self): cols = 2, hidden = True, ), + S3LocationFilter("location_id", + levels=levels, + ), S3TextFilter("type", label = T("Shipment Type"), hidden = True, @@ -1278,6 +1285,7 @@ def model(self): "req_ref", "sender_id", "site_id", + "location_id", "date", "recipient_id", "delivery_date", @@ -2407,6 +2415,24 @@ def prep(r): else: set_send_attr(SHIP_STATUS_IN_PROCESS) sendtable.send_ref.readable = False + script = \ +""" +$("#inv_send_to_site_id__row").hide(); +$("[id^='inv_send_location_id']").hide(); +$('
' + ).insertBefore( "#inv_send_to_site_id__row" ); +$("input[name=site_or_location]").on( "change", function() { + if ($("input[name=site_or_location]:checked").val()=="site") { + $("#inv_send_to_site_id__row").show(); + $("[id^='inv_send_location_id']").hide(); + } else { + $("#inv_send_to_site_id__row").hide(); + $("[id^='inv_send_location_id']").show(); + } + +}); +""" + s3.jquery_ready.append(script) return True args = request.args