Error handling for Workorder Creation in Preorder/Index
This commit is contained in:
@@ -1019,14 +1019,24 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$.post("<?=self::getUrl("Preorder","Api")?>",
|
$("#preorder-detail-" + pid + "-rimo button.create-workorder").prop("disabled", true);
|
||||||
{
|
$("#preorder-detail-" + pid + "-rimo .workorder-container").append("<img src='<?=self::getResourcePath()?>img/ajax-loader.gif' />");
|
||||||
'do': "createWorkorder",
|
|
||||||
id: pid,
|
|
||||||
|
$.ajax({
|
||||||
|
url: "<?=self::getUrl("Preorder","Api")?>",
|
||||||
|
method: "POST",
|
||||||
|
data: {
|
||||||
|
do: "createWorkorder",
|
||||||
|
id: pid,
|
||||||
},
|
},
|
||||||
function(success) {
|
context: {
|
||||||
if(success.status == "OK") {
|
pid: pid
|
||||||
wo = success.result;
|
},
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(response) {
|
||||||
|
if(response.status == "OK") {
|
||||||
|
wo = response.result;
|
||||||
html = '<h4> \
|
html = '<h4> \
|
||||||
' + wo.name + ' \
|
' + wo.name + ' \
|
||||||
<a href="<?=self::getUrl("RimoWorkorder", "downloadAh")?>?id=' + wo.id + '" onclick="event.preventDefault(); downloadWorkorderAha(' + wo.id + ');"><i class="fas fa-fw fa-file-download ml-2"></i> AHA Blatt</a> \
|
<a href="<?=self::getUrl("RimoWorkorder", "downloadAh")?>?id=' + wo.id + '" onclick="event.preventDefault(); downloadWorkorderAha(' + wo.id + ');"><i class="fas fa-fw fa-file-download ml-2"></i> AHA Blatt</a> \
|
||||||
@@ -1052,13 +1062,28 @@
|
|||||||
</tr> \
|
</tr> \
|
||||||
</table>';
|
</table>';
|
||||||
|
|
||||||
|
$("#preorder-detail-" + wo.preorder_id + "-rimo img").remove();
|
||||||
|
$("#preorder-detail-" + wo.preorder_id + "-rimo .workorder-container img").remove();
|
||||||
|
$("#preorder-detail-" + wo.preorder_id + "-rimo button.create-workorder").remove();
|
||||||
$("#preorder-detail-" + wo.preorder_id + "-rimo .workorder-container").append(html);
|
$("#preorder-detail-" + wo.preorder_id + "-rimo .workorder-container").append(html);
|
||||||
$("button.create-workorder").remove();
|
|
||||||
|
} else {
|
||||||
|
restoreBlankWorkorderView(this.pid);
|
||||||
|
window.notify("error", "Workorder konnte nicht erstellt werden!");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'json');
|
error: function() {
|
||||||
|
restoreBlankWorkorderView(this.pid);
|
||||||
|
window.notify("error", "Workorder konnte nicht erstellt werden!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function restoreBlankWorkorderView(pid) {
|
||||||
|
$("#preorder-detail-" + pid + "-rimo .workorder-container img").remove();
|
||||||
|
$("#preorder-detail-" + pid + "-rimo button.create-workorder").prop("disabled", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteWorkorder(pid, wid) {
|
function deleteWorkorder(pid, wid) {
|
||||||
|
|||||||
Reference in New Issue
Block a user