Added Borderpoint status to Preorder
This commit is contained in:
@@ -204,6 +204,16 @@ $pagination_entity_name = "Vorbestellungen";
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 col-md-2">
|
||||
<label class="form-label" for="filter_borderpoint_status">Borderpoint Status</label>
|
||||
<select name="filter[borderpoint_status]" id="filter_borderpoint_status" class="form-control">
|
||||
<option></option>
|
||||
<option value="need_measurement" <?=(isset($filter) && array_key_exists("borderpoint_status", $filter) && $filter["borderpoint_status"] == "need_measurement") ? "selected='selected'" : ""?>>Messung erforderlich</option>
|
||||
<option value="informed" <?=(isset($filter) && array_key_exists("borderpoint_status", $filter) && $filter["borderpoint_status"] == "informed") ? "selected='selected'" : ""?>>Beauskunftet</option>
|
||||
<option value="need_digging" <?=(isset($filter) && array_key_exists("borderpoint_status", $filter) && $filter["borderpoint_status"] == "need_digging") ? "selected='selected'" : ""?>>Grabung ausständig</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 col-md-2">
|
||||
<label class="form-label" for="connection_type">Anschlusstyp</label>
|
||||
<select name="filter[connection_type][]" id="connection_type_id" class="form-control" multiple="multiple">
|
||||
@@ -1336,6 +1346,74 @@ $pagination_entity_name = "Vorbestellungen";
|
||||
'json');
|
||||
}
|
||||
|
||||
/*
|
||||
* Toggle Borderpoint status radio buttons on/off
|
||||
*/
|
||||
// get and save initial radio button states
|
||||
var bpstatus_radiostate = [];
|
||||
$("input[name^='borderpoint_status_']").each(function(i) {
|
||||
let match = $(this).attr("name").match(/_(\d+)$/);
|
||||
let pid = match[1];
|
||||
bpstatus_radiostate[pid + "-" + $(this).val()] = $(this).is(":checked");
|
||||
});
|
||||
|
||||
// if saved value is checked => uncheck
|
||||
$("input[name^='borderpoint_status_']").click(async (e) => {
|
||||
var radio = $(e.target);
|
||||
var val = radio.val();
|
||||
|
||||
console.log(radio.attr("name"));
|
||||
let match = radio.attr("name").match(/_(\d+)$/);
|
||||
if(!match || !match[1]) {
|
||||
return;
|
||||
}
|
||||
|
||||
let pid = match[1];
|
||||
var new_status;
|
||||
|
||||
if(bpstatus_radiostate[pid + "-" + val]) {
|
||||
new_status = false;
|
||||
radio.prop("checked", false);
|
||||
bpstatus_radiostate[pid + "-" + val] = false;
|
||||
} else {
|
||||
new_status = true;
|
||||
radio.prop("checked", true);
|
||||
for(const [key, value] of Object.entries(bpstatus_radiostate)) {
|
||||
if(key.startsWith(pid + "-")) {
|
||||
bpstatus_radiostate[key] = false;
|
||||
}
|
||||
}
|
||||
bpstatus_radiostate[pid + "-" + val] = true;
|
||||
}
|
||||
|
||||
// save new status
|
||||
await fetch("<?=self::getUrl("Preorder", "Api")?>", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
do: "saveBorderpointStatus",
|
||||
preorder_id: pid,
|
||||
status_type: val,
|
||||
value: new_status ? 1 : 0
|
||||
})
|
||||
}).then(resp => {
|
||||
if(resp.ok) {
|
||||
return resp.json();
|
||||
}
|
||||
}).then((data) => {
|
||||
console.log(data);
|
||||
console.log(pid);
|
||||
if(data.status == "OK") {
|
||||
window.notify("success", "Borderpoint Status gespeichert");
|
||||
} else {
|
||||
window.notify("error", "Fehler beim Speichern des Borderpoint Status");
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function createWorkorder(pid) {
|
||||
if(!Number.isInteger(pid) || pid < 1) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user