Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.44 KB | None | 0 0
  1. <?php
  2. session_start();
  3. ?>
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  8.  
  9. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  10. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  11.  
  12. <link rel="stylesheet" type="text/css" href="mainCSS.css">
  13.  
  14. <script>
  15. // Used to show / hide content (solution) depending on whether or not the problem is solved
  16. function check(offset) { // Offset values are used to determine which (if multiple) of the tickets are being checked
  17. acheck="solvedCheck".concat(offset);
  18. field="solutionField".concat(offset);
  19. label="solutionLabel".concat(offset);
  20. if(document.getElementById(acheck).checked == true) { // If the checkbox is checked, show the field
  21. document.getElementById(field).style.display = "block";
  22. document.getElementById(label).style.display = "block";
  23. }else{ // Else hide the field
  24. document.getElementById(field).style.display = "none";
  25. document.getElementById(label).style.display = "none";
  26. }
  27. }
  28. // Used to show optional content (nearest problem) if the current problem is not known / stored in the database
  29. function unknownProblem(ticket){ // Ticket parameter same use as offset above
  30. known="problemTypes";
  31. type="actualProblemType".concat(ticket);
  32.  
  33. knownTypes = document.getElementById(known).childNodes; // Get elements stored in datalist of known problem types
  34. problemType = document.getElementById(type).value; // Get the problem type selected by the helpdesk operator
  35. flag = false;
  36. for (i = 0;i < knownTypes.length; i++){ // If the selected problem type is known (stored in the database)
  37. if(problemType.toLowerCase() == knownTypes[i].text.toLowerCase()){
  38. flag = true; // set a flag to be true
  39. }
  40. }
  41. label="closestProblemLabel".concat(ticket); // Create unique label depending on ticket number (offset)
  42. Type="closestProblemType".concat(ticket);
  43. if (!flag){ // If the flag is false (i.e the selected problem is not one that is in the database)
  44. document.getElementById(label).style.display = "block"; // Show optional input fields
  45. document.getElementById(Type).style.display = "block"; // Which are used to select nearest known problem type
  46. }
  47. else{ // Else keep them hidden (as the selected problem type is known to us)
  48. document.getElementById(label).style.display = "none";
  49. document.getElementById(Type).style.display = "none";
  50. }
  51.  
  52. }
  53. // Finish the creation of the new ticket
  54. function finishTicket(ticket){ // Again...ticket is an offset to uniquely identify current ticket being worked on
  55. ticketDiv ="ticket".concat(ticket); // Create unique div for each ticket
  56. ticketDiv =document.getElementById(ticketDiv);
  57. children = ticketDiv.children;
  58. for (var i = 0; i < children.length; i++) { // Remove all contents of the div
  59. children[i].style.display = 'none';
  60. }
  61. ticketDiv.style.height = "60px";
  62.  
  63. // The following create unique fields etc... for each ticket by using their ticket ID as an offset
  64. hardwareField = "hardware".concat(ticket); // e.g... hardware1 (ticket1), hardware2 (ticket2) etc...
  65. hardwareField = document.getElementById(hardwareField).value;
  66.  
  67. OSField = "OS".concat(ticket);
  68. OSField = document.getElementById(OSField).value;
  69.  
  70. softwareField = "softwarefield".concat(ticket);
  71. softwareField = document.getElementById(softwareField).value;
  72.  
  73. hardwareField = "hardware".concat(ticket);
  74. hardwareField = document.getElementById(hardwareField).value;
  75.  
  76. problemField ="closestProblemType".concat(ticket);
  77. if(document.getElementById(problemField).style.display == "none"){
  78. problemField="actualProblemType".concat(ticket);
  79. }
  80. problemField = document.getElementById(problemField).value;
  81.  
  82. finishedField = "solvedCheck".concat(ticket);
  83. finishedField = document.getElementById(finishedField).checked;
  84.  
  85. solutionField = "solutionField".concat(ticket);
  86. solutionField = document.getElementById(solutionField).value;
  87.  
  88. detailsField = "details".concat(ticket);
  89. detailsField = document.getElementById(detailsField).value;
  90.  
  91. specialistField = "specialistSelection".concat(ticket);
  92. if (document.getElementById(specialistField)){
  93. specialistField = document.getElementById(specialistField).value;
  94. }
  95. else{
  96. specialistField = "none";
  97. };
  98.  
  99. varstring = "hardware=";
  100. varstring.concat(hardwareField);
  101. varstring.concat("&os=");
  102. varstring.concat(OSField);
  103. varstring.concat("&software=");
  104. varstring.concat(softwareField);
  105. varstring.concat("&problemType=");
  106. varstring.concat(problemField);
  107. varstring.concat("&finished=");
  108. varstring.concat(finishedField);
  109. varstring.concat("&solution=");
  110. varstring.concat(solutionField);
  111. varstring.concat("&details=");
  112. varstring.concat(detailsField);
  113. varstring.concat("&specialist=");
  114. varstring.concat(specialistField);
  115.  
  116. // Post results to final ticket to be inserted into the database
  117. $.post("finalTicket.php",{
  118. hardware : hardwareField,
  119. os : OSField,
  120. software : softwareField,
  121. problemType : problemField,
  122. finished : finishedField,
  123. solution : solutionField,
  124. details : detailsField,
  125. specialist : specialistField
  126. },function(result){if(result=="success"){
  127. header("location: Main.php");}
  128. else{alert(result);}});
  129. }
  130. // Select most relevant specialist based on their specialization followed by their current workload
  131. function selectSpecialist(number){
  132. checkbox= "solvedCheck".concat(number);
  133. if (document.getElementById(checkbox).checked == true){ // If the solved checkbox is checked
  134. solutionField = "solutionField".concat(number); // Show the solution field
  135. solutionField = document.getElementById(solutionField).value;
  136. if(solutionField != ""){
  137. finishTicket(number);
  138. } else{}
  139. }else{
  140. var array = [];
  141. ticketDiv ="ticket".concat(number);
  142. problemType ="closestProblemType".concat(number);
  143. if(document.getElementById(problemType).style.display == "none"){
  144. problemType="actualProblemType".concat(number);
  145. }
  146. array =document.getElementById(problemType).value;
  147. ticketDiv =document.getElementById(ticketDiv);
  148. children = ticketDiv.children;
  149. for (var i = 0; i < children.length; i++) {
  150. children[i].style.display = 'none';
  151. }
  152. ticketDiv.style.height = "60px";
  153. ticketString="#ticket".concat(number)
  154. specialistLabel = document.createElement("label");
  155. specialistLabel.innerHTML ="Specalist assigned : ";
  156. specialistSelection = document.createElement("select");
  157. specialistSelection.id = "specialistSelection".concat(number);
  158. newButton = document.createElement("input");
  159. newButton.setAttribute("type", "button");
  160. newButton.addEventListener("click", finishTicket(number));
  161. newButton.id = "newButton";
  162. newButton.value = "Confirm";
  163. $.post("specialistSelection.php", { problemType: array}, function(result){
  164. result = JSON.parse(result);
  165. for(i=0;i<result['listSpecialists'].length;i++){
  166. specalistEntry = document.createElement("option");
  167. specalistEntry.value = result['listSpecialists'][i];
  168. specalistEntry.innerHTML = result['listSpecialists'][i];
  169. if(specalistEntry.value == result['assignedSpecialist']){
  170. specalistEntry.selected = true;
  171. }
  172. specialistSelection.add(specalistEntry);
  173. }
  174. $( ticketString).append(specialistLabel);
  175. $( ticketString).append(specialistSelection);
  176. $( ticketString).append(newButton);
  177. });}
  178.  
  179. }
  180. </script>
  181.  
  182. <?php
  183. session_start();
  184. if(empty($_SESSION['login_user'])){
  185. header("location: index.php");
  186. }
  187.  
  188.  
  189. date_default_timezone_set("Europe/London");
  190. $emp = $_POST['idEmployee'];
  191. $numberTickets =$_POST['numberTickets'];
  192.  
  193. $callReason = $_POST['callReasonNew'];
  194. $date = date("l, d/m/Y, G:i");
  195. $Opid = $_SESSION['login_user'];
  196. $_SESSION['numberTickets'] = $numberTickets;
  197. $numberTickets = $_SESSION['numberTickets'];
  198.  
  199. include 'SQLConnect.inc';
  200.  
  201. $conn = new mysqli($host, $username, $password, $dbName);
  202.  
  203. if ($conn->connect_error) {
  204. die("Connection failed: " . $conn->connect_error);
  205. }
  206. if($stmt = $conn->prepare("SELECT `Call-ID` FROM incomingCall ORDER BY `Call-ID` DESC LIMIT 1")){
  207. $stmt->execute();
  208. $query= $stmt->get_result();
  209. $stmt->close();
  210. }
  211. $result = $query->fetch_assoc();
  212. $CallID = $result['Call-ID'] +1;
  213. $_SESSION['CallID'] = $CallID;
  214.  
  215. if($stmt = $conn->prepare("INSERT INTO incomingCall (`Call-ID`, `Emp-ID`, `Op-ID`, `Time`)
  216. VALUES (?,?,?,?)")){
  217. $stmt->bind_param("ssss", $CallID, $emp, $Opid, $date);
  218. $stmt->execute();
  219. $stmt->close();
  220. }
  221.  
  222. if($stmt = $conn->prepare("SELECT `Expertise` FROM expertise")){
  223. $stmt->execute();
  224. $query= $stmt->get_result();
  225. $stmt->close();
  226. }
  227. $rows = mysqli_num_rows($query);
  228. $options = "";
  229. for($i=0;$i<$rows;$i++){
  230. $row = $query->fetch_assoc();
  231. $options.= '<option value="';
  232. $options.= $row['Expertise'];
  233. $options.= '">';
  234. $options.= $row['Expertise'];
  235. $options.= "</option>";
  236. }
  237.  
  238. echo '<datalist id="problemTypes">';
  239. if($stmt = $conn->prepare("SELECT `Expertise` FROM expertise")){
  240. $stmt->execute();
  241. $query= $stmt->get_result();
  242. $stmt->close();
  243. }
  244. $rows = mysqli_num_rows($query);
  245. for($i=0;$i<$rows;$i++){
  246. $row = $query->fetch_assoc();
  247. echo '<option value="';
  248. echo $row['Expertise'];
  249. echo '">';
  250. echo $row['Expertise'];
  251. echo "</option>";
  252. }
  253. echo '</datalist>';
  254. mysqli_close($conn);
  255. ?>
  256. </head>
  257.  
  258. <body id="body">
  259. <div id="main">
  260. <div id="sidebar">
  261. <img src="logo.png" id="logo"/>
  262. <ul class="nav nav-pills nav-stacked">
  263. <li id="homeMenu" ><a href="Main.php">Home</a></li>
  264. <li class="active" id="editTicketMenu" ><a href="viewcalllog.php">View Call Log</a></li>
  265. <li id="viewEmpMenu" ><a href="viewemployees.php">View Employees</a></li>
  266. <li id="viewEquipMenu" ><a href="viewequipment.php">View Equipment</a></li>
  267. </ul>
  268. </div>
  269. <div id="content" style="overflow: auto;height: 80%;">
  270. <form action="logout.php">
  271. <input id="submit" name="submit" type="submit" value="Logout">
  272. </form>
  273.  
  274. <ul class="nav nav-tabs">
  275. <li class="active" id="homeMenu" onclick="loadMain()"><a href="#">Call Log</a></li>
  276. </ul>
  277.  
  278. <?php
  279.  
  280. for($i=1;$i<=$numberTickets;$i++){
  281. echo '<div class="newTicket
  282. " id="ticket';
  283. echo $i;
  284. echo '"><h1>Ticket ';
  285. echo $i;
  286. echo ': </h1>';
  287. echo '
  288. <form id="newTicketForm';
  289. echo $i;
  290. echo '" action="post">
  291. <div class="formDiv">
  292. <label for="hardware" class="newTicketLabels">Hardware affected: </label>
  293. <input type="text" id="hardware';
  294. echo $i;
  295. echo '" name="hardware" style="float:right;"/><br>
  296. </div>
  297.  
  298. <div class="formDiv">
  299. <label for="OS" class="newTicketLabels">OS used: </label>
  300. <input type="text" id="OS';
  301. echo $i;
  302. echo '" name="OS" style="float:right;"/><br>
  303. </div>
  304.  
  305. <div class="formDiv">
  306. <label for="software" class="newTicketLabels">Software used: </label>
  307. <input type="text" id="softwarefield';
  308. echo $i;
  309. echo '" name="softwarefield" style="float:right;"/><br>
  310. </div>
  311.  
  312. <div class="formDiv">
  313. <label for="actualProblemType" class="newTicketLabels">Type of problem:* </label>
  314. <input type="text" id="actualProblemType';
  315. echo $i;
  316. echo '" name="actualProblemType" list="problemTypes" onblur="unknownProblem(';
  317. echo $i;
  318. echo ')"
  319. style="float:right;"/>
  320. </div>
  321.  
  322. <div class="formDiv">
  323. <label for="closestProblemType" class="newTicketLabels" style="display: none;" id="closestProblemLabel';
  324. echo $i;
  325. echo '">Choose the option closest to the problem:* </label>
  326. <select id="closestProblemType';
  327. echo $i;
  328. echo '" name="closestProblemType" style="display: none; float:right;">';
  329. echo $options;
  330. echo '</select><br>
  331. </div>
  332.  
  333. <div class="formDiv">
  334. <label for="solved" class="newTicketLabels">Problem solved?</label>
  335. <input type="checkbox" id="solvedCheck';
  336. echo $i;
  337. echo '" name="solved" onclick="check(';
  338. echo $i;
  339. echo ')" style="float:right;"/><br>
  340. </div>
  341.  
  342. <div class="formDiv">
  343. <label for="details" class="newTicketLabels">Problem details:* </label>
  344. <textarea id="details';
  345. echo $i;
  346. echo '" class="newTicketTAs" name="details" form="newTicketForm" style="float:right;"></textarea><br>
  347. </div>
  348.  
  349. <div class="formDiv">
  350. <label for="solution" class="newTicketLabels" id="solutionLabel';
  351. echo $i;
  352. echo '" style="display: none;">Solution:* </label>
  353. <textarea id="solutionField';
  354. echo $i;
  355. echo '" class="newTicketTAs" name="solution" form="newTicketForm"
  356. style="display: none;float:right;"></textarea><br>
  357. </div>
  358.  
  359. <input type="button" id="createTicket';
  360. echo $i;
  361. echo '" value="Create Ticket" onclick="selectSpecialist(';
  362. echo $i;
  363. echo ')"/><br>
  364.  
  365. </form>
  366. </div>';}
  367.  
  368. ?>
  369. </div>
  370. </div>
  371. </body>
  372. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement