Skip to content

Commit

Permalink
add location_id to inv_send
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhowden committed May 7, 2015
1 parent 6b6aef3 commit f6496a8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/s3db/gis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
28 changes: 27 additions & 1 deletion modules/s3db/inv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand All @@ -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."),
),
Expand All @@ -1204,6 +1208,9 @@ def model(self):
cols = 2,
hidden = True,
),
S3LocationFilter("location_id",
levels=levels,
),
S3TextFilter("type",
label = T("Shipment Type"),
hidden = True,
Expand Down Expand Up @@ -1278,6 +1285,7 @@ def model(self):
"req_ref",
"sender_id",
"site_id",
"location_id",
"date",
"recipient_id",
"delivery_date",
Expand Down Expand Up @@ -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();
$('<div id="facility_or_location_radio" class = "form-row row"><input type="radio" name="site_or_location" value="site"><label style="font-weight: bold;">To Facility</label><input type="radio" name="site_or_location" value="location"><label style="font-weight: bold;">To Location</label></div>'
).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
Expand Down

0 comments on commit f6496a8

Please sign in to comment.