Bootswatch, Summernote, and Captcheck mods for Mods for HESK (mods-for-hesk.com). In use at support.netsyms.com.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

manage_categories.php 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. <?php
  2. /**
  3. *
  4. * This file is part of HESK - PHP Help Desk Software.
  5. *
  6. * (c) Copyright Klemen Stirn. All rights reserved.
  7. * https://www.hesk.com
  8. *
  9. * For the full copyright and license agreement information visit
  10. * https://www.hesk.com/eula.php
  11. *
  12. */
  13. define('IN_SCRIPT', 1);
  14. define('HESK_PATH', '../');
  15. define('VALIDATOR', 1);
  16. define('PAGE_TITLE', 'ADMIN_CATEGORIES');
  17. define('MFH_PAGE_LAYOUT', 'TOP_ONLY');
  18. define('EXTRA_JS', '<script src="'.HESK_PATH.'internal-api/js/manage-categories.js"></script>');
  19. /* Get all the required files and functions */
  20. require(HESK_PATH . 'hesk_settings.inc.php');
  21. require(HESK_PATH . 'inc/common.inc.php');
  22. require(HESK_PATH . 'inc/admin_functions.inc.php');
  23. require(HESK_PATH . 'inc/mail_functions.inc.php');
  24. hesk_load_database_functions();
  25. hesk_session_start();
  26. hesk_dbConnect();
  27. hesk_isLoggedIn();
  28. /* Check permissions for this feature */
  29. hesk_checkPermission('can_man_cat');
  30. // Possible priorities
  31. $priorities = array(
  32. 3 => array('value' => 3, 'text' => $hesklang['low'], 'formatted' => $hesklang['low']),
  33. 2 => array('value' => 2, 'text' => $hesklang['medium'], 'formatted' => '<span class="medium">' . $hesklang['medium'] . '</span>'),
  34. 1 => array('value' => 1, 'text' => $hesklang['high'], 'formatted' => '<span class="important">' . $hesklang['high'] . '</span>'),
  35. 0 => array('value' => 0, 'text' => $hesklang['critical'], 'formatted' => '<span class="critical">' . $hesklang['critical'] . '</span>'),
  36. );
  37. /* What should we do? */
  38. if ($action = hesk_REQUEST('a')) {
  39. if ($action == 'linkcode') {
  40. generate_link_code();
  41. } elseif (defined('HESK_DEMO')) {
  42. hesk_process_messages($hesklang['ddemo'], 'manage_categories.php', 'NOTICE');
  43. } elseif ($action == 'new') {
  44. new_cat();
  45. } elseif ($action == 'remove') {
  46. remove();
  47. } elseif ($action == 'order') {
  48. order_cat();
  49. } elseif ($action == 'autoassign') {
  50. toggle_autoassign();
  51. } elseif ($action == 'type') {
  52. toggle_type();
  53. } elseif ($action == 'edit') {
  54. update_category();
  55. }
  56. }
  57. $modsForHesk_settings = mfh_getSettings();
  58. /* Print header */
  59. require_once(HESK_PATH . 'inc/headerAdmin.inc.php');
  60. /* Print main manage users page */
  61. require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
  62. ?>
  63. <script language="Javascript" type="text/javascript"><!--
  64. function confirm_delete() {
  65. if (confirm('<?php echo hesk_makeJsString($hesklang['confirm_del_cat']); ?>')) {
  66. return true;
  67. }
  68. else {
  69. return false;
  70. }
  71. }
  72. //-->
  73. </script>
  74. <?php
  75. $orderBy = $modsForHesk_settings['category_order_column'];
  76. $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` ORDER BY `" . $orderBy . "` ASC");
  77. ?>
  78. <div class="content-wrapper">
  79. <section class="content">
  80. <div class="box">
  81. <div class="box-header with-border">
  82. <h1 class="box-title">
  83. <?php echo $hesklang['manage_cat']; ?> <a href="javascript:void(0)"
  84. onclick="javascript:alert('<?php echo hesk_makeJsString($hesklang['cat_intro']); ?>')"><i
  85. class="fa fa-question-circle settingsquestionmark"></i></a>
  86. </h1>
  87. <div class="box-tools pull-right">
  88. <button type="button" class="btn btn-box-tool" data-widget="collapse">
  89. <i class="fa fa-minus"></i>
  90. </button>
  91. </div>
  92. </div>
  93. <div class="box-body">
  94. <?php
  95. /* This will handle error, success and notice messages */
  96. hesk_handle_messages();
  97. if ($hesk_settings['cust_urgency']) {
  98. hesk_show_notice($hesklang['cat_pri_info'] . ' ' . $hesklang['cpri']);
  99. }
  100. ?>
  101. <div class="row">
  102. <div class="col-md-12 text-right">
  103. <button id="create-button" class="btn btn-success">
  104. <i class="fa fa-plus-circle"></i>&nbsp;
  105. <?php echo $hesklang['create_new']; ?>
  106. </button>
  107. </div>
  108. <div class="col-md-12">
  109. <table class="table table-striped">
  110. <thead>
  111. <tr>
  112. <th><?php echo $hesklang['id']; ?></th>
  113. <th><?php echo $hesklang['cat_name']; ?></th>
  114. <th><?php echo $hesklang['visibility']; ?></th>
  115. <th><?php echo $hesklang['aass']; ?></th>
  116. <th><?php echo $hesklang['priority']; ?></th>
  117. <th><?php echo $hesklang['not']; ?></th>
  118. <th><?php echo $hesklang['graph']; ?></th>
  119. <th><?php echo $hesklang['manager']; ?></th>
  120. <th><?php echo $hesklang['usage']; ?></th>
  121. <th><?php echo $hesklang['opt']; ?></th>
  122. </tr>
  123. </thead>
  124. <tbody id="table-body">
  125. </tbody>
  126. </table>
  127. </div>
  128. </div>
  129. </div>
  130. <div class="overlay" id="overlay">
  131. <i class="fa fa-spinner fa-spin"></i>
  132. </div>
  133. </div>
  134. </section>
  135. </div>
  136. <?php
  137. $usersRs = hesk_dbQuery("SELECT `id`, `name` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` WHERE `active` = '1' AND `isadmin` = '0'");
  138. echo '<script>var users = [];';
  139. $users = array();
  140. while ($row = hesk_dbFetchAssoc($usersRs)) {
  141. $users[] = $row;
  142. echo "users[" . $row['id'] . "] = {
  143. id: ".$row['id'].",
  144. name: '".$row['name']."'
  145. }\n";
  146. }
  147. echo '</script>';
  148. ?>
  149. <!-- Category modal -->
  150. <div class="modal fade" id="category-modal" tabindex="-1" role="dialog" style="overflow: hidden">
  151. <div class="modal-dialog modal-lg" role="document">
  152. <div class="modal-content">
  153. <div class="modal-header" style="cursor: move">
  154. <button type="button" class="close cancel-callback" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  155. <h4 class="modal-title" id="myModalLabel">
  156. <span id="edit-label"><?php echo $hesklang['edit_category']; ?></span>
  157. <span id="create-label"><?php echo $hesklang['create_cat']; ?></span>
  158. </h4>
  159. </div>
  160. <form id="manage-category" class="form-horizontal" data-toggle="validator" method="post">
  161. <div class="modal-body">
  162. <div class="row">
  163. <div class="col-md-6">
  164. <h4><?php echo $hesklang['cat_name_description']; ?></h4>
  165. <div class="form-group">
  166. <label for="name" class="col-sm-5 control-label"><?php echo $hesklang['cat_name']; ?></label>
  167. <div class="col-sm-7">
  168. <input type="text" name="name" class="form-control" placeholder="<?php echo $hesklang['cat_name']; ?>"
  169. data-error="<?php echo htmlspecialchars($hesklang['this_field_is_required']); ?>"
  170. required>
  171. <div class="help-block with-errors"></div>
  172. </div>
  173. </div>
  174. <div class="form-group">
  175. <label for="description" class="col-sm-5 control-label">
  176. <?php echo $hesklang['description']; ?>
  177. </label>
  178. <div class="col-sm-7">
  179. <textarea class="form-control" name="description" placeholder="<?php echo $hesklang['description']; ?>"></textarea>
  180. </div>
  181. </div>
  182. </div>
  183. <div class="col-md-6">
  184. <h4><?php echo $hesklang['color']; ?></h4>
  185. <div class="form-group">
  186. <label for="background-color" class="col-sm-5 control-label">
  187. <?php echo $hesklang['category_background_color']; ?>
  188. <i class="fa fa-question-circle settingsquestionmark" data-toggle="popover"
  189. title="<?php echo htmlspecialchars($hesklang['category_background_color']); ?>"
  190. data-content="<?php echo htmlspecialchars($hesklang['category_background_color_help']); ?>"></i>
  191. </label>
  192. <div class="col-sm-7">
  193. <input type="text" name="background-color" class="form-control category-colorpicker"
  194. placeholder="<?php echo $hesklang['category_background_color']; ?>"
  195. data-error="<?php echo htmlspecialchars($hesklang['this_field_is_required']); ?>"
  196. required>
  197. <div class="help-block with-errors"></div>
  198. </div>
  199. </div>
  200. <div class="form-group">
  201. <label for="foreground-color" class="col-sm-5 control-label">
  202. <?php echo $hesklang['category_foreground_color']; ?>
  203. <i class="fa fa-question-circle settingsquestionmark" data-toggle="popover"
  204. title="<?php echo htmlspecialchars($hesklang['category_foreground_color']); ?>"
  205. data-content="<?php echo htmlspecialchars($hesklang['category_foreground_color_help']); ?>"></i>
  206. </label>
  207. <div class="col-sm-7">
  208. <input type="text" name="foreground-color" class="form-control category-colorpicker"
  209. placeholder="<?php echo $hesklang['category_foreground_color']; ?>">
  210. <div class="help-block with-errors"></div>
  211. </div>
  212. </div>
  213. <div class="form-group">
  214. <label for="display-border" class="col-sm-5 control-label">
  215. <?php echo $hesklang['category_display_border']; ?>
  216. <i class="fa fa-question-circle settingsquestionmark" data-toggle="htmlpopover"
  217. title="<?php echo htmlspecialchars($hesklang['category_display_border']); ?>"
  218. data-content="<?php echo htmlspecialchars($hesklang['category_display_border_help']); ?>"></i>
  219. </label>
  220. <div class="col-sm-7 form-inline">
  221. <div class="radio">
  222. <label>
  223. <input type="radio" name="display-border" value="1">
  224. <?php echo $hesklang['yes']; ?>
  225. </label>
  226. </div>&nbsp;&nbsp;&nbsp;
  227. <div class="radio">
  228. <label>
  229. <input type="radio" name="display-border" value="0" checked>
  230. <?php echo $hesklang['no']; ?>
  231. </label>
  232. </div>
  233. </div>
  234. </div>
  235. </div>
  236. </div>
  237. <div class="row">
  238. <div class="col-md-12">
  239. <h4><?php echo $hesklang['basicProperties']; ?></h4>
  240. </div>
  241. <div class="col-md-6">
  242. <div class="form-group">
  243. <label for="priority" class="col-sm-5 control-label">
  244. <?php echo $hesklang['priority']; ?>
  245. <a href="#"
  246. onclick="alert('<?php echo hesk_makeJsString($hesklang['cat_pri']); ?>')"><i
  247. class="fa fa-question-circle settingsquestionmark"></i> </a>
  248. </label>
  249. <div class="col-sm-7">
  250. <select name="priority" class="form-control">
  251. <?php
  252. // List possible priorities
  253. foreach ($priorities as $value => $info) {
  254. echo '<option value="' . $value . '">' . $info['text'] . '</option>';
  255. }
  256. ?>
  257. </select>
  258. <div class="help-block with-errors"></div>
  259. </div>
  260. </div>
  261. <div class="form-group">
  262. <label for="usage" class="col-sm-5 control-label">
  263. <?php echo $hesklang['usage']; ?>
  264. </label>
  265. <div class="col-sm-7">
  266. <select name="usage" class="form-control">
  267. <option value="0"><?php echo $hesklang['tickets_and_events']; ?></option>
  268. <option value="1"><?php echo $hesklang['tickets_only']; ?></option>
  269. <option value="2"><?php echo $hesklang['events_only']; ?></option>
  270. </select>
  271. </div>
  272. </div>
  273. <div class="form-group">
  274. <label for="manager" class="col-sm-5 control-label">
  275. <?php echo $hesklang['manager']; ?>
  276. </label>
  277. <div class="col-sm-7">
  278. <select name="manager" class="form-control">
  279. <option value="0"><?php echo $hesklang['no_manager']; ?></option>
  280. <?php foreach ($users as $user): ?>
  281. <option value="<?php echo $user['id']; ?>"><?php echo $user['name']; ?></option>
  282. <?php endforeach; ?>
  283. </select>
  284. </div>
  285. </div>
  286. </div>
  287. <div class="col-md-6">
  288. <div class="form-group">
  289. <label for="autoassign" class="col-sm-5 control-label">
  290. <?php echo $hesklang['aass']; ?>
  291. </label>
  292. <div class="col-sm-7 form-inline">
  293. <div class="radio">
  294. <label>
  295. <input type="radio" name="autoassign" value="1">
  296. <?php echo $hesklang['yes']; ?>
  297. </label>
  298. </div>&nbsp;&nbsp;&nbsp;
  299. <div class="radio">
  300. <label>
  301. <input type="radio" name="autoassign" value="0" checked>
  302. <?php echo $hesklang['no']; ?>
  303. </label>
  304. </div>
  305. </div>
  306. </div>
  307. <div class="form-group">
  308. <label for="type" class="col-sm-5 control-label">
  309. <?php echo $hesklang['visibility']; ?>
  310. </label>
  311. <div class="col-sm-7 form-inline">
  312. <div class="radio">
  313. <label>
  314. <input type="radio" name="type" value="0">
  315. <?php echo $hesklang['cat_public']; ?>
  316. </label>
  317. </div><br>
  318. <div class="radio">
  319. <label>
  320. <input type="radio" name="type" value="1" checked>
  321. <?php echo $hesklang['cat_private']; ?>
  322. </label>
  323. </div>
  324. </div>
  325. </div>
  326. </div>
  327. </div>
  328. </div>
  329. <div class="modal-footer">
  330. <input type="hidden" name="id">
  331. <input type="hidden" name="cat-order">
  332. <div id="action-buttons" class="btn-group">
  333. <button type="button" class="btn btn-default cancel-button cancel-callback" data-dismiss="modal">
  334. <i class="fa fa-times-circle"></i>
  335. <span><?php echo $hesklang['cancel']; ?></span>
  336. </button>
  337. <button type="submit" class="btn btn-success save-button">
  338. <i class="fa fa-check-circle"></i>
  339. <span><?php echo $hesklang['save']; ?></span>
  340. </button>
  341. </div>
  342. </div>
  343. </form>
  344. </div>
  345. </div>
  346. </div>
  347. <div class="modal fade" id="generate-link-modal" tabindex="-1" role="dialog" style="overflow: hidden">
  348. <div class="modal-dialog modal-lg" role="document">
  349. <div class="modal-content">
  350. <div class="modal-header" style="cursor: move">
  351. <button type="button" class="close cancel-callback" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  352. <h4 class="modal-title"><?php echo $hesklang['genl']; ?></h4>
  353. </div>
  354. <div class="modal-body">
  355. <div class="row">
  356. <div class="col-md-12">
  357. <p><?php echo $hesklang['genl2']; ?></p>
  358. </div>
  359. </div>
  360. <div class="row">
  361. <div class="col-md-12 form-group">
  362. <div class="input-group">
  363. <input type="text" id="link" class="form-control white-readonly"
  364. title="<?php echo $hesklang['genl']; ?>" readonly>
  365. <div class="generate-link-button input-group-addon button" data-toggle="tooltip" title="Copy to clipboard"
  366. style="padding:0; border: none">
  367. <button class="btn btn-primary">
  368. <i class="fa fa-files-o"></i>
  369. </button>
  370. </div>
  371. </div>
  372. </div>
  373. </div>
  374. </div>
  375. <div class="modal-footer">
  376. <button type="button" class="btn btn-default cancel-button cancel-callback" data-dismiss="modal">
  377. <i class="fa fa-times-circle"></i>
  378. <span><?php echo $hesklang['close_modal']; ?></span>
  379. </button>
  380. </div>
  381. </div>
  382. </div>
  383. </div>
  384. <script type="text/html" id="category-row-template">
  385. <tr>
  386. <td><span data-property="id" data-value="x"></span></td>
  387. <td>
  388. <span class="label category-label" data-property="category-name">
  389. </span>
  390. <i class="fa fa-info-circle" data-toggle="popover" title="<?php echo $hesklang['description']; ?>"></i>
  391. </td>
  392. <td>
  393. <i style="display: none; padding-right: 8px;" class="fa fa-fw fa-lock icon-link gray"></i>
  394. <i style="display: none; padding-right: 8px;" class="fa fa-fw fa-unlock-alt icon-link blue"></i>
  395. <span data-property="type"></span>
  396. </td>
  397. <td>
  398. <i class="fa fa-fw fa-bolt icon-link"></i>
  399. <span data-property="autoassign"></span>
  400. </td>
  401. <td><span data-property="priority"></span></td>
  402. <td><a data-property="number-of-tickets" href="#"></a></td>
  403. <td>
  404. <div class="progress" style="width: 160px; margin-bottom: 0" title="Width tooltip" data-toggle="tooltip">
  405. <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100">
  406. </div>
  407. </div>
  408. </td>
  409. <td>
  410. <span data-property="manager"></span>
  411. </td>
  412. <td>
  413. <i class="fa fa-fw fa-ticket icon-link" data-toggle="tooltip" title="<?php echo $hesklang['tickets']; ?>"></i>
  414. <i class="fa fa-fw fa-calendar icon-link" data-toggle="tooltip" title="<?php echo $hesklang['events']; ?>"></i>
  415. </td>
  416. <td>
  417. <a data-property="generate-link" href="#">
  418. <i class="fa fa-fw icon-link" data-toggle="tooltip"
  419. data-placement="top"></i>
  420. </a>
  421. <span class="sort-arrows">
  422. <a href="#" data-action="sort"
  423. data-direction="up">
  424. <i class="fa fa-fw fa-arrow-up icon-link green"
  425. data-toggle="tooltip" title="<?php echo $hesklang['move_up']; ?>"></i>
  426. </a>
  427. <a href="#" data-action="sort"
  428. data-direction="down">
  429. <i class="fa fa-fw fa-arrow-down icon-link green"
  430. data-toggle="tooltip" title="<?php echo $hesklang['move_dn'] ?>"></i>
  431. </a>
  432. </span>
  433. <a href="#" data-action="edit">
  434. <i class="fa fa-fw fa-pencil icon-link orange"
  435. data-toggle="tooltip" title="<?php echo $hesklang['edit']; ?>"></i>
  436. </a>
  437. <a name="Delete Category" href="#" data-action="delete">
  438. <i class="fa fa-fw fa-times icon-link red"
  439. data-toggle="tooltip" title="<?php echo $hesklang['delete']; ?>"></i>
  440. </a>
  441. </td>
  442. </tr>
  443. </script>
  444. <input type="hidden" name="show-tickets-path" value="show_tickets.php?category={0}&amp;s_all=1&amp;s_my=1&amp;s_ot=1&amp;s_un=1">
  445. <?php
  446. echo mfh_get_hidden_fields_for_language(array(
  447. 'critical',
  448. 'high',
  449. 'medium',
  450. 'low',
  451. 'perat',
  452. 'aaon',
  453. 'aaoff',
  454. 'cat_private',
  455. 'cat_public',
  456. 'cat_removed',
  457. 'error_deleting_category',
  458. 'error_retrieving_categories',
  459. 'error_saving_updating_category',
  460. 'copied_to_clipboard',
  461. 'category_updated',
  462. 'cat_name_added',
  463. 'enabled_title_case',
  464. 'disabled_title_case',
  465. 'geco',
  466. 'cpric',
  467. 'no_manager',
  468. 'e_udel',
  469. ));
  470. require_once(HESK_PATH . 'inc/footer.inc.php');
  471. exit();
  472. ?>