diff --git a/Layout/default/Preorder/Index.php b/Layout/default/Preorder/Index.php index 64f41c837..838abbd3c 100644 --- a/Layout/default/Preorder/Index.php +++ b/Layout/default/Preorder/Index.php @@ -1019,14 +1019,24 @@ return false; } - $.post("", - { - 'do': "createWorkorder", - id: pid, + $("#preorder-detail-" + pid + "-rimo button.create-workorder").prop("disabled", true); + $("#preorder-detail-" + pid + "-rimo .workorder-container").append(""); + + + $.ajax({ + url: "", + method: "POST", + data: { + do: "createWorkorder", + id: pid, }, - function(success) { - if(success.status == "OK") { - wo = success.result; + context: { + pid: pid + }, + dataType: 'json', + success: function(response) { + if(response.status == "OK") { + wo = response.result; html = '

\ ' + wo.name + ' \ ?id=' + wo.id + '" onclick="event.preventDefault(); downloadWorkorderAha(' + wo.id + ');"> AHA Blatt \ @@ -1052,13 +1062,28 @@ \ '; + $("#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); - $("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) {