v_fifo_agent_languages_edit.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2012
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. require_once "root.php";
  22. require_once "resources/require.php";
  23. require_once "resources/check_auth.php";
  24. if (if_group("admin") || if_group("superadmin")) {
  25. //access granted
  26. }
  27. else {
  28. echo "access denied";
  29. exit;
  30. }
  31. //Action add or update
  32. if (isset($_REQUEST["id"])) {
  33. $action = "update";
  34. $fifo_agent_language_id = check_str($_REQUEST["id"]);
  35. }
  36. else {
  37. $action = "add";
  38. }
  39. //POST to PHP variables
  40. if (count($_POST)>0) {
  41. $username = check_str($_POST["username"]);
  42. $language = check_str($_POST["language"]);
  43. $proficiency = check_str($_POST["proficiency"]);
  44. }
  45. if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
  46. $msg = '';
  47. if ($action == "update") {
  48. $fifo_agent_language_id = check_str($_POST["fifo_agent_language_id"]);
  49. }
  50. //check for all required data
  51. //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid<br>\n"; }
  52. //if (strlen($username) == 0) { $msg .= "Please provide: Username<br>\n"; }
  53. //if (strlen($language) == 0) { $msg .= "Please provide: Language<br>\n"; }
  54. //if (strlen($proficiency) == 0) { $msg .= "Please provide: Proficiency<br>\n"; }
  55. if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
  56. require_once "resources/header.php";
  57. require_once "resources/persist_form_var.php";
  58. echo "<div align='center'>\n";
  59. echo "<table><tr><td>\n";
  60. echo $msg."<br />";
  61. echo "</td></tr></table>\n";
  62. persistformvar($_POST);
  63. echo "</div>\n";
  64. require_once "resources/footer.php";
  65. return;
  66. }
  67. //Add or update the database
  68. if ($_POST["persistformvar"] != "true") {
  69. if ($action == "add") {
  70. $sql = "insert into v_fifo_agent_languages ";
  71. $sql .= "(";
  72. $sql .= "domain_uuid, ";
  73. $sql .= "username, ";
  74. $sql .= "language, ";
  75. $sql .= "proficiency ";
  76. $sql .= ")";
  77. $sql .= "values ";
  78. $sql .= "(";
  79. $sql .= "'$domain_uuid', ";
  80. $sql .= "'$username', ";
  81. $sql .= "'$language', ";
  82. $sql .= "'$proficiency' ";
  83. $sql .= ")";
  84. $db->exec(check_sql($sql));
  85. unset($sql);
  86. require_once "resources/header.php";
  87. echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_languages.php\">\n";
  88. echo "<div align='center'>\n";
  89. echo "Add Complete\n";
  90. echo "</div>\n";
  91. require_once "resources/footer.php";
  92. return;
  93. } //if ($action == "add")
  94. if ($action == "update") {
  95. $sql = "update v_fifo_agent_languages set ";
  96. $sql .= "domain_uuid = '$domain_uuid', ";
  97. $sql .= "username = '$username', ";
  98. $sql .= "language = '$language', ";
  99. $sql .= "proficiency = '$proficiency' ";
  100. $sql .= "where domain_uuid = '$domain_uuid' ";
  101. $sql .= "and fifo_agent_language_id = '$fifo_agent_language_id'";
  102. $db->exec(check_sql($sql));
  103. unset($sql);
  104. require_once "resources/header.php";
  105. echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fifo_agent_languages.php\">\n";
  106. echo "<div align='center'>\n";
  107. echo "Update Complete\n";
  108. echo "</div>\n";
  109. require_once "resources/footer.php";
  110. return;
  111. } //if ($action == "update")
  112. } //if ($_POST["persistformvar"] != "true")
  113. } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
  114. //pre-populate the form
  115. if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
  116. $fifo_agent_language_id = $_GET["id"];
  117. $sql = "";
  118. $sql .= "select * from v_fifo_agent_languages ";
  119. $sql .= "where domain_uuid = '$domain_uuid' ";
  120. $sql .= "and fifo_agent_language_id = '$fifo_agent_language_id' ";
  121. $prep_statement = $db->prepare(check_sql($sql));
  122. $prep_statement->execute();
  123. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  124. foreach ($result as &$row) {
  125. $domain_uuid = $row["domain_uuid"];
  126. $username = $row["username"];
  127. $language = $row["language"];
  128. $proficiency = $row["proficiency"];
  129. break; //limit to 1 row
  130. }
  131. unset ($prep_statement);
  132. }
  133. //begin the content
  134. require_once "resources/header.php";
  135. echo "<div align='center'>";
  136. echo "<table width='100%' border='0' cellpadding='0' cellspacing=''>\n";
  137. echo "<tr class='border'>\n";
  138. echo " <td align=\"left\">\n";
  139. echo " <br>";
  140. echo "<form method='post' name='frm' action=''>\n";
  141. echo "<div align='center'>\n";
  142. echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
  143. echo "<tr>\n";
  144. if ($action == "add") {
  145. echo "<td align='left' width='30%' nowrap='nowrap' align='left'><b>Fifo Agent Language Add</b></td>\n";
  146. }
  147. if ($action == "update") {
  148. echo "<td align='left' width='30%' nowrap='nowrap' align='left'><b>Fifo Agent Language Edit</b></td>\n";
  149. }
  150. echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='v_fifo_agent_languages.php'\" value='Back'></td>\n";
  151. echo "</tr>\n";
  152. echo "<tr>\n";
  153. echo "<td colspan='2' align='left'>\n";
  154. echo "Matches the Agent with languages they can speak with their proficiency level.<br /><br />\n";
  155. echo "</td>\n";
  156. echo "</tr>\n";
  157. echo "<tr>\n";
  158. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  159. echo " Username:\n";
  160. echo "</td>\n";
  161. echo "<td class='vtable' align='left'>\n";
  162. //generate the user list
  163. $sql = "SELECT * FROM v_users ";
  164. $sql .= "where domain_uuid = '$domain_uuid' ";
  165. $sql .= "and user_enabled = 'true' ";
  166. $prep_statement = $db->prepare(check_sql($sql));
  167. $prep_statement->execute();
  168. echo "<select name=\"username\" class='formfld'>\n";
  169. echo "<option value=\"\"></option>\n";
  170. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  171. foreach($result as $field) {
  172. if ($username == $field[username]) {
  173. echo "<option value='".$field[username]."' selected='selected'>".$field[username]."</option>\n";
  174. }
  175. else {
  176. echo "<option value='".$field[username]."'>".$field[username]."</option>\n";
  177. }
  178. }
  179. echo "</select>";
  180. unset($sql, $result);
  181. echo "<br />\n";
  182. echo "Select the Username from the list.\n";
  183. echo "</td>\n";
  184. echo "</tr>\n";
  185. echo "<tr>\n";
  186. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  187. echo " Language:\n";
  188. echo "</td>\n";
  189. echo "<td class='vtable' align='left'>\n";
  190. //generate the language select list
  191. $sql = "SELECT var_name, var_value FROM v_vars ";
  192. $sql .= "where domain_uuid = '$domain_uuid' ";
  193. $sql .= "and var_cat = 'Languages' ";
  194. $prep_statement = $db->prepare(check_sql($sql));
  195. $prep_statement->execute();
  196. echo "<select name=\"language\" class='formfld'>\n";
  197. echo "<option value=\"\"></option>\n";
  198. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  199. foreach($result as $field) {
  200. if ($field[var_value] == $agent_status) {
  201. echo "<option value='".$field[var_value]."' selected='selected'>".$field[var_name]."</option>\n";
  202. }
  203. else {
  204. echo "<option value='".$field[var_value]."'>".$field[var_name]."</option>\n";
  205. }
  206. }
  207. echo "</select>";
  208. echo "<br />\n";
  209. echo "Enter the two letter language code.\n";
  210. echo "</td>\n";
  211. echo "</tr>\n";
  212. echo "<tr>\n";
  213. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  214. echo " Proficiency:\n";
  215. echo "</td>\n";
  216. echo "<td class='vtable' align='left'>\n";
  217. echo " <select class='formfld' name='proficiency'>\n";
  218. echo " <option value=''></option>\n";
  219. if ($agent_priority == "1") {
  220. echo " <option value='1' SELECTED >1</option>\n";
  221. }
  222. else {
  223. echo " <option value='1'>1</option>\n";
  224. }
  225. if ($agent_priority == "2") {
  226. echo " <option value='2' SELECTED >2</option>\n";
  227. }
  228. else {
  229. echo " <option value='2'>2</option>\n";
  230. }
  231. if ($agent_priority == "3") {
  232. echo " <option value='3' SELECTED >3</option>\n";
  233. }
  234. else {
  235. echo " <option value='3'>3</option>\n";
  236. }
  237. if ($agent_priority == "4") {
  238. echo " <option value='4' SELECTED >4</option>\n";
  239. }
  240. else {
  241. echo " <option value='4'>4</option>\n";
  242. }
  243. if ($agent_priority == "5") {
  244. echo " <option value='5' SELECTED >5</option>\n";
  245. }
  246. else {
  247. echo " <option value='5'>5</option>\n";
  248. }
  249. if ($agent_priority == "6") {
  250. echo " <option value='6' SELECTED >6</option>\n";
  251. }
  252. else {
  253. echo " <option value='6'>6</option>\n";
  254. }
  255. if ($agent_priority == "7") {
  256. echo " <option value='7' SELECTED >7</option>\n";
  257. }
  258. else {
  259. echo " <option value='7'>7</option>\n";
  260. }
  261. if ($agent_priority == "8") {
  262. echo " <option value='8' SELECTED >8</option>\n";
  263. }
  264. else {
  265. echo " <option value='8'>8</option>\n";
  266. }
  267. if ($agent_priority == "9") {
  268. echo " <option value='9' SELECTED >9</option>\n";
  269. }
  270. else {
  271. echo " <option value='9'>9</option>\n";
  272. }
  273. if ($agent_priority == "10") {
  274. echo " <option value='10' SELECTED >10</option>\n";
  275. }
  276. else {
  277. echo " <option value='10'>10</option>\n";
  278. }
  279. echo " </select>\n";
  280. echo "<br />\n";
  281. echo "Select the language proficiency level.\n";
  282. echo "</td>\n";
  283. echo "</tr>\n";
  284. echo " <tr>\n";
  285. echo " <td colspan='2' align='right'>\n";
  286. if ($action == "update") {
  287. echo " <input type='hidden' name='fifo_agent_language_id' value='$fifo_agent_language_id'>\n";
  288. }
  289. echo " <input type='submit' name='submit' class='btn' value='Save'>\n";
  290. echo " </td>\n";
  291. echo " </tr>";
  292. echo "</table>";
  293. echo "</form>";
  294. echo " </td>";
  295. echo " </tr>";
  296. echo "</table>";
  297. echo "</div>";
  298. require_once "resources/footer.php";
  299. ?>