forked from Business/BinStack
Replace cat and loc search boxes with select dropdowns (#11)
This commit is contained in:
parent
ab717e6030
commit
e1045eed9e
@ -202,8 +202,12 @@ switch ($VARS['action']) {
|
||||
}
|
||||
returnToSender("invalid_parameters");
|
||||
case "autocomplete_category":
|
||||
exit(json_encode($database->select('categories', ['catid (id)', 'catname (name)'], ['catname[~]' => $VARS['q'], 'LIMIT' => 10])));
|
||||
header("Content-Type: application/json");
|
||||
$q = (empty($VARS['q']) ? "" : $VARS['q']);
|
||||
exit(json_encode($database->select('categories', ['catid (id)', 'catname (name)'], ['catname[~]' => $q, 'LIMIT' => 10])));
|
||||
case "autocomplete_location":
|
||||
header("Content-Type: application/json");
|
||||
$q = (empty($VARS['q']) ? "" : $VARS['q']);
|
||||
exit(json_encode($database->select('locations', ['locid (id)', 'locname (name)'], ["OR" => ['locname[~]' => $VARS['q'], 'loccode' => $VARS['q']], 'LIMIT' => 10])));
|
||||
case "autocomplete_user":
|
||||
header("Content-Type: application/json");
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"New Category": "New Category",
|
||||
"editing category": "Editing {cat}",
|
||||
"Adding new category": "Adding new category"
|
||||
"Adding new category": "Adding new category",
|
||||
"Choose a category": "Choose a category"
|
||||
}
|
||||
|
@ -22,5 +22,7 @@
|
||||
"login server error": "The login server returned an error: {arg}",
|
||||
"login server user data error": "The login server refused to provide account information. Try again or contact technical support.",
|
||||
"captcha error": "There was a problem with the CAPTCHA (robot test). Try again.",
|
||||
"no access permission": "You do not have permission to access this system."
|
||||
"no access permission": "You do not have permission to access this system.",
|
||||
"no permission": "You do not have permission to access this system.",
|
||||
"no edit permission": "You do not have permission to modify records."
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
"Adding Item": "Adding new item",
|
||||
"editing item": "Editing {item}",
|
||||
"cloning item": "Copying {oitem} <i class=\"fa fa-angle-right\"></i> {nitem}",
|
||||
"item saved": "Item Saved",
|
||||
"itemid": "Item ID",
|
||||
"id": "ID"
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"new location": "New Location",
|
||||
"Adding new location": "Adding new location",
|
||||
"editing location": "Editing {loc}"
|
||||
"editing location": "Editing {loc}",
|
||||
"Choose a location": "Choose a location"
|
||||
}
|
||||
|
@ -104,15 +104,33 @@ if (!empty($VARS['id'])) {
|
||||
<div class="col-12 col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="cat"><i class="fas fa-archive"></i> <?php $Strings->get("category"); ?></label>
|
||||
<input type="text" name="catstr" class="form-control" id="cat" placeholder="<?php $Strings->get("placeholder category name"); ?>" value="<?php echo htmlspecialchars($itemdata['catname']); ?>" />
|
||||
<input type="hidden" id="realcat" name="cat" value="<?php echo $itemdata['catid']; ?>" required="required" />
|
||||
<select class="form-control" name="cat" id="cat" required="required">
|
||||
<option value=""><?php $Strings->get("Choose a category"); ?></option>
|
||||
<?php
|
||||
$categories = $database->select('categories', ['catid (id)', 'catname (name)']);
|
||||
foreach ($categories as $cat) {
|
||||
?>
|
||||
<option value="<?php echo $cat['id']; ?>" <?php echo $itemdata['catid'] == $cat['id'] ? "selected" : ""; ?>><?php echo $cat['name']; ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="loc"><i class="fas fa-map-marker"></i> <?php $Strings->get("location"); ?></label>
|
||||
<input type="text" name="locstr" class="form-control" id="loc" placeholder="<?php $Strings->get("placeholder location name"); ?>" value="<?php echo htmlspecialchars($itemdata['locname']); ?>" />
|
||||
<input type="hidden" id="realloc" name="loc" value="<?php echo $itemdata['locid']; ?>" required="required" />
|
||||
<select class="form-control" name="loc" id="loc" required="required">
|
||||
<option value=""><?php $Strings->get("Choose a location"); ?></option>
|
||||
<?php
|
||||
$locations = $database->select('locations', ['locid (id)', 'locname (name)']);
|
||||
foreach ($locations as $loc) {
|
||||
?>
|
||||
<option value="<?php echo $loc['id']; ?>" <?php echo $itemdata['locid'] == $loc['id'] ? "selected" : ""; ?>><?php echo $loc['name']; ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -2,59 +2,6 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
$("#cat").easyAutocomplete({
|
||||
url: "action.php",
|
||||
ajaxSettings: {
|
||||
dataType: "json",
|
||||
method: "GET",
|
||||
data: {
|
||||
action: "autocomplete_category"
|
||||
}
|
||||
},
|
||||
preparePostData: function (data) {
|
||||
data.q = $("#cat").val();
|
||||
return data;
|
||||
},
|
||||
getValue: function (element) {
|
||||
return element.name;
|
||||
},
|
||||
list: {
|
||||
onSelectItemEvent: function () {
|
||||
var catid = $("#cat").getSelectedItemData().id;
|
||||
$("#realcat").val(catid).trigger("change");
|
||||
},
|
||||
match: {
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
});
|
||||
$("#loc").easyAutocomplete({
|
||||
url: "action.php",
|
||||
ajaxSettings: {
|
||||
dataType: "json",
|
||||
method: "GET",
|
||||
data: {
|
||||
action: "autocomplete_location"
|
||||
}
|
||||
},
|
||||
preparePostData: function (data) {
|
||||
data.q = $("#loc").val();
|
||||
return data;
|
||||
},
|
||||
getValue: function (element) {
|
||||
return element.name;
|
||||
},
|
||||
list: {
|
||||
onSelectItemEvent: function () {
|
||||
var locid = $("#loc").getSelectedItemData().id;
|
||||
$("#realloc").val(locid).trigger("change");
|
||||
},
|
||||
match: {
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$("#assignedto").easyAutocomplete({
|
||||
url: "action.php",
|
||||
ajaxSettings: {
|
||||
@ -82,3 +29,4 @@ $("#assignedto").easyAutocomplete({
|
||||
$('#name').on('input propertychange paste', function () {
|
||||
$('#name_title').text($('#name').val());
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user