report_problems.html 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <html>
  2. <head>
  3. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  4. <style>
  5. table {
  6. font-family: arial, sans-serif;
  7. border-collapse: collapse;
  8. width: 100%;
  9. }
  10. td, th {
  11. border: 1px solid #dddddd;
  12. text-align: left;
  13. padding: 8px;
  14. }
  15. tr:nth-child(even) {
  16. background-color: #dddddd;
  17. }
  18. button:hover { background-color: blue; }
  19. button:focus { background-color: blue; }
  20. </style>
  21. </head>
  22. <body>
  23. <h2>Report Problems</h2>
  24. <div id="cont"></div>
  25. <div id="actions"></div>
  26. <form method="GET" action="../services/return_cpee.php">
  27. <input type="text" name="id" id="cbid" required>
  28. <input type="text" name="workerID" id="workerID" required>
  29. <br><input type="text" name="action" id="action" required></br>
  30. <p>New Article ID: <input type="text" name="newAID" id="newAID"></p>
  31. <p>Quantity: <input type="text" name="quantity" id="quantity"></p>
  32. <select id="selectNumber" onchange="singleSelectChangeText()"><option>Choose tool part</option></select>
  33. <input type="text" id="dropdown" name="toolPart" hidden>
  34. <br><textarea rows="4" cols="50" name="comment" id="comment"></textarea></br>
  35. <input type="submit" value="Report" onclick="reloaded(rolle);">
  36. </form>
  37. <script type="text/javascript" src="form.js"></script>
  38. <script type="text/javascript">
  39. var doc = "";
  40. $.ajax({
  41. url: '../callbacks/'+ cbid + '.txt',
  42. async: false,
  43. success: function (data){
  44. doc = data;
  45. }
  46. });
  47. doc = JSON.parse(doc);
  48. var params = doc[1];
  49. var rolle = params['rolle'];
  50. var actions = params['actions'];
  51. console.log(params);
  52. actions = JSON.parse(actions);
  53. var toolPart = actions['toolPart'];
  54. toolPart = JSON.parse(toolPart);
  55. var actionList = actions['actionList'];
  56. actionList = JSON.parse(actionList);
  57. console.log(actionList);
  58. var mytable = "<table cellpadding=\"0\" cellspacing=\"0\">";
  59. mytable += "<thead><tr><th>Parameter</th><th>Value</th></tr></thead><tbody><tr>";
  60. Object.keys(params).forEach(val => {
  61. if (val != "form" && val != "rolle" && val !="actions"){
  62. mytable += "<td>" + val + "</td>";
  63. mytable += "<td>" + params[val] + "</td></tr><tr>";}
  64. });
  65. mytable += "</tr></tbody></table>";
  66. var elem = document.getElementById("cont");
  67. elem.insertAdjacentHTML( 'beforeend', mytable );
  68. function singleSelectChangeText() {
  69. var selObj = document.getElementById("selectNumber");
  70. var selValue = selObj.options[selObj.selectedIndex].text;
  71. document.getElementById("dropdown").value = selValue;
  72. }
  73. var select = document.getElementById("selectNumber");
  74. for(var i = 0; i < toolPart.length; i++) {
  75. var opt = toolPart[i];
  76. var el = document.createElement("option");
  77. el.textContent = opt;
  78. el.value = opt;
  79. select.appendChild(el);
  80. }
  81. var myActions = "";
  82. for(var b = 0; b < actionList.length; b++) {
  83. myActions += "<button id=\""+actionList[b]+"\" onClick=\"do_after(this.id)\">"+actionList[b]+"</button>";
  84. }
  85. var act = document.getElementById("actions");
  86. act.insertAdjacentHTML( 'beforeend', myActions );
  87. function do_after(id){
  88. document.getElementById("action").value = id;
  89. }
  90. </script>
  91. </body>
  92. </html>