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.

index.php 73KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597
  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('WYSIWYG', 1);
  16. define('VALIDATOR', 1);
  17. // Get all the required files and functions
  18. require(HESK_PATH . 'hesk_settings.inc.php');
  19. require(HESK_PATH . 'inc/common.inc.php');
  20. require(HESK_PATH . 'inc/view_attachment_functions.inc.php');
  21. hesk_load_database_functions();
  22. hesk_dbConnect();
  23. // Are we in maintenance mode?
  24. hesk_check_maintenance();
  25. // Are we in "Knowledgebase only" mode?
  26. hesk_check_kb_only();
  27. $modsForHesk_settings = mfh_getSettings();
  28. // What should we do?
  29. $action = hesk_REQUEST('a');
  30. switch ($action) {
  31. case 'add':
  32. hesk_session_start();
  33. print_add_ticket();
  34. break;
  35. case 'forgot_tid':
  36. hesk_session_start();
  37. forgot_tid();
  38. break;
  39. default:
  40. print_start();
  41. }
  42. // Print footer
  43. require_once(HESK_PATH . 'inc/footer.inc.php');
  44. exit();
  45. /*** START FUNCTIONS ***/
  46. function print_select_category($number_of_categories)
  47. {
  48. global $hesk_settings, $hesklang;
  49. // Print header
  50. $hesk_settings['tmp_title'] = $hesk_settings['hesk_title'] . ' - ' . $hesklang['select_category'];
  51. require_once(HESK_PATH . 'inc/header.inc.php');
  52. // A categoy needs to be selected
  53. if (isset($_GET['category']) && empty($_GET['category']))
  54. {
  55. hesk_process_messages($hesklang['sel_app_cat'],'NOREDIRECT','NOTICE');
  56. }
  57. ?>
  58. <ol class="breadcrumb">
  59. <li><a href="<?php echo $hesk_settings['site_url']; ?>"><?php echo $hesk_settings['site_title']; ?></a></li>
  60. <li><a href="<?php echo $hesk_settings['hesk_url']; ?>"><?php echo $hesk_settings['hesk_title']; ?></a></li>
  61. <li class="active"><?php echo $hesklang['submit_ticket']; ?></li>
  62. </ol>
  63. <?php
  64. /* This will handle error, success and notice messages */
  65. hesk_handle_messages();
  66. ?>
  67. <div style="text-align: center">
  68. <h3><?php echo $hesklang['select_category_text']; ?></h3>
  69. <div class="select_category">
  70. <?php
  71. // Print a select box if number of categories is large
  72. if ($number_of_categories > $hesk_settings['cat_show_select'])
  73. {
  74. ?>
  75. <form action="index.php" method="get">
  76. <select name="category" id="select_category" class="form-control">
  77. <?php
  78. if ($hesk_settings['select_cat'])
  79. {
  80. echo '<option value="">'.$hesklang['select'].'</option>';
  81. }
  82. foreach ($hesk_settings['categories'] as $k=>$v)
  83. {
  84. echo '<option value="'.$k.'">'.$v.'</option>';
  85. }
  86. ?>
  87. </select>
  88. &nbsp;<br />
  89. <div style="text-align:center">
  90. <input type="submit" value="<?php echo $hesklang['c2c']; ?>" class="btn btn-default">
  91. <input type="hidden" name="a" value="add" />
  92. </div>
  93. </form>
  94. <?php
  95. }
  96. // Otherwise print quick links
  97. else
  98. {
  99. $new_row = 1;
  100. foreach ($hesk_settings['categories'] as $k=>$v):
  101. if ($new_row == 1) {
  102. echo '<div class="row">';
  103. $new_row = -1;
  104. }
  105. ?>
  106. <div class="col-md-5 col-sm-10 col-md-offset-1 col-sm-offset-1">
  107. <a href="index.php?a=add&category=<?php echo $k; ?>" class="button-link">
  108. <div class="panel panel-default">
  109. <div class="panel-body">
  110. <div class="row">
  111. <div class="col-xs-12">
  112. <?php echo $v; ?>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. </a>
  118. </div>
  119. <?php
  120. $new_row++;
  121. if ($new_row == 1) {
  122. echo '</div>';
  123. }
  124. endforeach;
  125. }
  126. ?>
  127. </div>
  128. </div>
  129. <?php
  130. return true;
  131. } // END print_select_category()
  132. function print_add_ticket()
  133. {
  134. global $hesk_settings, $hesklang, $modsForHesk_settings;
  135. // Connect to the database
  136. hesk_load_database_functions();
  137. hesk_dbConnect();
  138. // Load custom fields
  139. require_once(HESK_PATH . 'inc/custom_fields.inc.php');
  140. // Load calendar JS and CSS
  141. define('CALENDAR',1);
  142. // Auto-focus first empty or error field
  143. define('AUTOFOCUS', true);
  144. // Pre-populate fields
  145. // Customer name
  146. if (isset($_REQUEST['name'])) {
  147. $_SESSION['c_name'] = $_REQUEST['name'];
  148. }
  149. // Customer email address
  150. if (isset($_REQUEST['email'])) {
  151. $_SESSION['c_email'] = $_REQUEST['email'];
  152. $_SESSION['c_email2'] = $_REQUEST['email'];
  153. }
  154. // Priority
  155. if (isset($_REQUEST['priority'])) {
  156. $_SESSION['c_priority'] = intval($_REQUEST['priority']);
  157. }
  158. // Subject
  159. if (isset($_REQUEST['subject'])) {
  160. $_SESSION['c_subject'] = $_REQUEST['subject'];
  161. }
  162. // Message
  163. if (isset($_REQUEST['message'])) {
  164. $_SESSION['c_message'] = $_REQUEST['message'];
  165. }
  166. // Custom fields
  167. foreach ($hesk_settings['custom_fields'] as $k => $v) {
  168. if ($v['use']==1 && isset($_REQUEST[$k])) {
  169. $_SESSION['c_' . $k] = $_REQUEST[$k];
  170. }
  171. }
  172. // Variables for coloring the fields in case of errors
  173. if (!isset($_SESSION['iserror'])) {
  174. $_SESSION['iserror'] = array();
  175. }
  176. if (!isset($_SESSION['isnotice'])) {
  177. $_SESSION['isnotice'] = array();
  178. }
  179. hesk_cleanSessionVars('already_submitted');
  180. // Tell header to load reCaptcha API if needed
  181. if ($hesk_settings['recaptcha_use'] == 2) {
  182. define('RECAPTCHA', 1);
  183. }
  184. // Get categories
  185. $hesk_settings['categories'] = array();
  186. $res = hesk_dbQuery("SELECT `id`, `name` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` WHERE `type`='0' ORDER BY `cat_order` ASC");
  187. while ($row=hesk_dbFetchAssoc($res)) {
  188. $hesk_settings['categories'][$row['id']] = $row['name'];
  189. }
  190. $number_of_categories = count($hesk_settings['categories']);
  191. if ($number_of_categories == 0) {
  192. $category = 1;
  193. } elseif ($number_of_categories == 1) {
  194. $category = current(array_keys($hesk_settings['categories']));
  195. } else {
  196. $category = isset($_GET['catid']) ? hesk_REQUEST('catid'): hesk_REQUEST('category');
  197. // Force the customer to select a category?
  198. if (!isset($hesk_settings['categories'][$category])) {
  199. return print_select_category($number_of_categories);
  200. }
  201. }
  202. // Print header
  203. $hesk_settings['tmp_title'] = $hesk_settings['hesk_title'] . ' - ' . $hesklang['submit_ticket'];
  204. require_once(HESK_PATH . 'inc/header.inc.php');
  205. ?>
  206. <ol class="breadcrumb">
  207. <li><a href="<?php echo $hesk_settings['site_url']; ?>"><?php echo $hesk_settings['site_title']; ?></a></li>
  208. <li><a href="<?php echo $hesk_settings['hesk_url']; ?>"><?php echo $hesk_settings['hesk_title']; ?></a></li>
  209. <?php if ($number_of_categories > 1) { ?>
  210. <li>
  211. <a href="index.php?a=add">
  212. <?php echo $hesklang['sub_support']; ?>
  213. </a>
  214. </li>
  215. <li class="active"><?php echo $hesk_settings['categories'][$category]; ?></li>
  216. <?php } else { ?>
  217. <li class="active"><?php echo $hesklang['sub_support']; ?></li>
  218. <?php } ?>
  219. </ol>
  220. <!-- START MAIN LAYOUT -->
  221. <?php
  222. $columnWidth = 'col-md-8';
  223. hesk_dbConnect();
  224. $showRs = hesk_dbQuery("SELECT `show` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` WHERE `id` = 1");
  225. $show = hesk_dbFetchAssoc($showRs);
  226. if (!$show['show']) {
  227. $columnWidth = 'col-md-10 col-md-offset-1';
  228. }
  229. ?>
  230. <div class="row">
  231. <?php if ($columnWidth == 'col-md-8'): ?>
  232. <div align="left" class="col-md-4">
  233. <div class="panel panel-default">
  234. <div class="panel-heading"><?php echo $hesklang['quick_help']; ?></div>
  235. <div class="panel-body">
  236. <p><?php echo $hesklang['quick_help_submit_ticket']; ?></p>
  237. </div>
  238. </div>
  239. </div>
  240. <?php endif; ?>
  241. <div class="<?php echo $columnWidth; ?>">
  242. <?php
  243. // This will handle error, success and notice messages
  244. hesk_handle_messages();
  245. ?>
  246. <!-- START FORM -->
  247. <div class="form">
  248. <h2><?php hesk_showTopBar($hesklang['submit_ticket']); ?></h2>
  249. <small><?php echo $hesklang['use_form_below']; ?></small>
  250. <div class="blankSpace"></div>
  251. <div align="left" class="h3"><?php echo $hesklang['add_ticket_general_information']; ?></div>
  252. <div class="footerWithBorder"></div>
  253. <div class="blankSpace"></div>
  254. <?php
  255. $onsubmit = '';
  256. if ($modsForHesk_settings['rich_text_for_tickets_for_customers']) {
  257. $onsubmit = 'onsubmit="return validateRichText(\'message-help-block\', \'message-group\', \'message\', \''.htmlspecialchars($hesklang['this_field_is_required']).'\')"';
  258. }
  259. ?>
  260. <form class="form-horizontal" role="form" method="post" action="submit_ticket.php?submit=1" name="form1"
  261. enctype="multipart/form-data" <?php echo $onsubmit; ?>>
  262. <!-- Contact info -->
  263. <div class="form-group">
  264. <label for="name" class="col-sm-3 control-label"><?php echo $hesklang['name']; ?> <span
  265. class="important">*</span></label>
  266. <div class="col-sm-9">
  267. <input type="text" class="form-control" id="name" name="name" size="40" maxlength="30"
  268. value="<?php if (isset($_SESSION['c_name'])) {
  269. echo stripslashes(hesk_input($_SESSION['c_name']));
  270. } ?>" <?php if (in_array('name', $_SESSION['iserror'])) {
  271. echo ' class="isError" ';
  272. } ?> placeholder="<?php echo htmlspecialchars($hesklang['name']); ?>"
  273. data-error="<?php echo htmlspecialchars($hesklang['enter_your_name']); ?>" required>
  274. <div class="help-block with-errors"></div>
  275. </div>
  276. </div>
  277. <div class="form-group">
  278. <label for="email" class="col-sm-3 control-label"><?php echo $hesklang['email'] .
  279. ($hesk_settings['require_email'] ? ' <span class="important">*</span>' : ''); ?></label>
  280. <div class="col-sm-9">
  281. <input type="text" class="form-control" id="email" name="email" size="40" maxlength="1000"
  282. value="<?php if (isset($_SESSION['c_email'])) {
  283. echo stripslashes(hesk_input($_SESSION['c_email']));
  284. } ?>" <?php if (in_array('email', $_SESSION['iserror'])) {
  285. echo ' class="isError" ';
  286. } elseif (in_array('email', $_SESSION['isnotice'])) {
  287. echo ' class="isNotice" ';
  288. } ?> <?php if ($hesk_settings['detect_typos']) {
  289. echo ' onblur="Javascript:hesk_suggestEmail(\'email\', \'email_suggestions\', 1, 0)"';
  290. } ?> placeholder="<?php echo htmlspecialchars($hesklang['email']); ?>"
  291. data-error="<?php echo htmlspecialchars($hesklang['enter_valid_email']); ?>" required>
  292. <div class="help-block with-errors"></div>
  293. </div>
  294. </div>
  295. <?php
  296. if ($hesk_settings['confirm_email']) {
  297. ?>
  298. <div class="form-group">
  299. <label for="email2" class="col-sm-3 control-label"><?php echo $hesklang['confemail']; ?>
  300. <?php echo $hesk_settings['require_email'] ? ' <span class="important">*</span>' : ''; ?></label>
  301. <div class="col-sm-9">
  302. <input type="text" id="email2" class="form-control" name="email2" size="40"
  303. maxlength="1000"
  304. value="<?php if (isset($_SESSION['c_email2'])) {
  305. echo stripslashes(hesk_input($_SESSION['c_email2']));
  306. } ?>" <?php if (in_array('email2', $_SESSION['iserror'])) {
  307. echo ' class="isError" ';
  308. } ?> placeholder="<?php echo htmlspecialchars($hesklang['confemail']); ?>"
  309. data-match="#email"
  310. data-error="<?php echo htmlspecialchars($hesklang['confemaile']); ?>" required>
  311. <div class="help-block with-errors"></div>
  312. </div>
  313. </div>
  314. <?php
  315. } ?>
  316. <div id="email_suggestions"></div>
  317. <!-- Priority -->
  318. <?php
  319. /* Can customer assign urgency? */
  320. if ($hesk_settings['cust_urgency']) {
  321. ?>
  322. <div class="form-group">
  323. <label for="priority" class="col-sm-3 control-label"><?php echo $hesklang['priority']; ?> <span
  324. class="important">*</span></label>
  325. <div class="col-sm-9">
  326. <select id="priority" class="form-control"
  327. pattern="[0-9]+"
  328. data-error="<?php echo htmlspecialchars($hesklang['sel_app_priority']); ?>"
  329. name="priority" <?php if (in_array('priority', $_SESSION['iserror'])) {
  330. echo ' class="isError" ';
  331. } ?> required>
  332. <?php
  333. // Show the "Click to select"?
  334. if ($hesk_settings['select_pri']) {
  335. echo '<option value="">' . $hesklang['select'] . '</option>';
  336. }
  337. ?>
  338. <option
  339. value="3" <?php if (isset($_SESSION['c_priority']) && $_SESSION['c_priority'] == 3) {
  340. echo 'selected="selected"';
  341. } ?>><?php echo $hesklang['low']; ?></option>
  342. <option
  343. value="2" <?php if (isset($_SESSION['c_priority']) && $_SESSION['c_priority'] == 2) {
  344. echo 'selected="selected"';
  345. } ?>><?php echo $hesklang['medium']; ?></option>
  346. <option
  347. value="1" <?php if (isset($_SESSION['c_priority']) && $_SESSION['c_priority'] == 1) {
  348. echo 'selected="selected"';
  349. } ?>><?php echo $hesklang['high']; ?></option>
  350. </select>
  351. <div class="help-block with-errors"></div>
  352. </div>
  353. </div>
  354. <?php
  355. }
  356. ?>
  357. <!-- START CUSTOM BEFORE -->
  358. <?php
  359. /* custom fields BEFORE comments */
  360. $hidden_cf_buffer = '';
  361. foreach ($hesk_settings['custom_fields'] as $k=>$v)
  362. {
  363. if ($v['use']==1 && $v['place']==0 && hesk_is_custom_field_in_category($k, $category) )
  364. {
  365. if ($v['req']) {
  366. $v['req']= '<span class="important">*</span>';
  367. $required_attribute = 'data-error="' . $hesklang['this_field_is_required'] . '" required';
  368. } else {
  369. $v['req'] = '';
  370. $required_attribute = '';
  371. }
  372. if ($v['type'] == 'checkbox')
  373. {
  374. $k_value = array();
  375. if (isset($_SESSION["c_$k"]) && is_array($_SESSION["c_$k"]))
  376. {
  377. foreach ($_SESSION["c_$k"] as $myCB)
  378. {
  379. $k_value[] = stripslashes(hesk_input($myCB));
  380. }
  381. }
  382. }
  383. elseif (isset($_SESSION["c_$k"]))
  384. {
  385. $k_value = stripslashes(hesk_input($_SESSION["c_$k"]));
  386. }
  387. else
  388. {
  389. $k_value = '';
  390. }
  391. switch ($v['type'])
  392. {
  393. /* Radio box */
  394. case 'radio':
  395. $cls = in_array($k,$_SESSION['iserror']) ? ' class="isError" ' : '';
  396. echo '
  397. <div class="form-group '.$cls.'">
  398. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  399. <div class="col-sm-9">';
  400. foreach ($v['value']['radio_options'] as $option) {
  401. if (strlen($k_value) == 0) {
  402. $k_value = $option;
  403. $checked = empty($v['value']['no_default']) ? 'checked' : '';
  404. } elseif ($k_value == $option) {
  405. $k_value = $option;
  406. $checked = 'checked';
  407. } else {
  408. $checked = '';
  409. }
  410. echo '<div class="radio"><label><input type="radio" name="'.$k.'" value="'.$option.'" '.$checked.' ' . $required_attribute . '> '.$option.'</label></div>';
  411. }
  412. echo '
  413. <div class="help-block with-errors"></div>
  414. </div>
  415. </div>';
  416. break;
  417. /* Select drop-down box */
  418. case 'select':
  419. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  420. echo '
  421. <div class="form-group '.$cls.'">
  422. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  423. <div class="col-sm-9">
  424. <select name="'.$k.'" class="form-control" ' . $required_attribute . '>';
  425. // Show "Click to select"?
  426. if ( ! empty($v['value']['show_select']))
  427. {
  428. echo '<option value="">'.$hesklang['select'].'</option>';
  429. }
  430. foreach ($v['value']['select_options'] as $option)
  431. {
  432. if ($k_value == $option)
  433. {
  434. $k_value = $option;
  435. $selected = 'selected';
  436. }
  437. else
  438. {
  439. $selected = '';
  440. }
  441. echo '<option '.$selected.'>'.$option.'</option>';
  442. }
  443. echo '</select>
  444. <div class="help-block with-errors"></div>
  445. </div>
  446. </div>';
  447. break;
  448. /* Checkbox */
  449. case 'checkbox':
  450. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  451. $validator = $v['req'] == '<span class="important">*</span>' ? 'data-checkbox="' . $k . '"' : '';
  452. $required_attribute = $validator == '' ? '' : ' data-error="' . $hesklang['this_field_is_required'] . '"';
  453. echo '
  454. <div class="form-group '.$cls.'">
  455. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  456. <div class="col-sm-9">';
  457. foreach ($v['value']['checkbox_options'] as $option)
  458. {
  459. if (in_array($option,$k_value))
  460. {
  461. $checked = 'checked';
  462. }
  463. else
  464. {
  465. $checked = '';
  466. }
  467. echo '<div class="checkbox"><label><input ' . $validator . ' type="checkbox" name="'.$k.'[]" value="'.$option.'" '.$checked.' ' . $required_attribute . '> '.$option.'</label></div>';
  468. }
  469. echo '
  470. <div class="help-block with-errors"></div>
  471. </div>
  472. </div>';
  473. break;
  474. /* Large text box */
  475. case 'textarea':
  476. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  477. echo '
  478. <div class="form-group '.$cls.'">
  479. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  480. <div class="col-sm-9">
  481. <textarea class="form-control" name="'.$k.'" rows="'.intval($v['value']['rows']).'" cols="'.intval($v['value']['cols']).'" '.$required_attribute.'>'.$k_value.'</textarea>
  482. <div class="help-block with-errors"></div>
  483. </div>
  484. </div>';
  485. break;
  486. // Date
  487. case 'date':
  488. if ($required_attribute != '') {
  489. $required_attribute .= ' pattern="[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])"';
  490. }
  491. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  492. echo '
  493. <div class="form-group '.$cls.'">
  494. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  495. <div class="col-sm-9">
  496. <input type="text" name="'.$k.'" value="'.$k_value.'" class="form-control datepicker" size="10" ' . $required_attribute . '>
  497. <div class="help-block with-errors"></div>
  498. </div>
  499. </div>';
  500. break;
  501. // Email
  502. case 'email':
  503. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  504. $suggest = $hesk_settings['detect_typos'] ? 'onblur="Javascript:hesk_suggestEmail(\''.$k.'\', \''.$k.'_suggestions\', 0, 0'.($v['value']['multiple'] ? ',1' : '').')"' : '';
  505. echo '
  506. <div class="form-group '.$cls.'">
  507. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  508. <div class="col-sm-9">
  509. <input type="text" name="'.$k.'" id="'.$k.'" value="'.$k_value.'" size="40" class="form-control" '.$suggest.' '.$required_attribute.'>
  510. <div class="help-block with-errors"></div>
  511. </div>
  512. <div id="'.$k.'_suggestions"></div>
  513. </div>';
  514. break;
  515. // Hidden
  516. case 'hidden':
  517. if (strlen($k_value) != 0 || isset($_SESSION["c_$k"]))
  518. {
  519. $v['value']['default_value'] = $k_value;
  520. }
  521. $hidden_cf_buffer .= '<input type="hidden" name="'.$k.'" value="'.$v['value']['default_value'].'" />';
  522. break;
  523. // Readonly
  524. case 'readonly':
  525. if (strlen($k_value) != 0 || isset($_SESSION["c_$k"]))
  526. {
  527. $v['value']['default_value'] = $k_value;
  528. }
  529. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  530. echo '
  531. <div class="form-group '.$cls.'">
  532. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  533. <div class="col-sm-9">
  534. <input type="text" class="form-control white-readonly" name="'.$k.'" size="40" value="'.$v['value']['default_value'].'" readonly>
  535. </div>
  536. </div>';
  537. break;
  538. /* Default text input */
  539. default:
  540. if (strlen($k_value) != 0 || isset($_SESSION["c_$k"]))
  541. {
  542. $v['value']['default_value'] = $k_value;
  543. }
  544. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  545. echo '
  546. <div class="form-group '.$cls.'">
  547. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  548. <div class="col-sm-9">
  549. <input type="text" class="form-control" name="'.$k.'" size="40" maxlength="'.intval($v['value']['max_length']).'" value="'.$v['value']['default_value'].'" '.$required_attribute.'>
  550. <div class="help-block with-errors"></div>
  551. </div>
  552. </div>';
  553. }
  554. }
  555. }
  556. ?>
  557. <!-- END CUSTOM BEFORE -->
  558. <?php
  559. if ($hesk_settings['require_subject'] != -1 || $hesk_settings['require_message'] != -1) {
  560. ?>
  561. <div class="blankSpace"></div>
  562. <div align="left" class="h3"><?php echo $hesklang['add_ticket_your_message']; ?></div>
  563. <div class="footerWithBorder"></div>
  564. <div class="blankSpace"></div>
  565. <!-- ticket info -->
  566. <?php if ($hesk_settings['require_subject'] != -1) { ?>
  567. <div class="form-group">
  568. <label for="subject" class="col-sm-3 control-label"><?php echo $hesklang['subject']; ?>
  569. <?php echo $hesk_settings['require_subject'] ? '<span class="important">*</span>' : ''; ?>
  570. </label>
  571. <div class="col-sm-9">
  572. <input type="text" id="subject" class="form-control" name="subject" size="40"
  573. maxlength="40"
  574. value="<?php if (isset($_SESSION['c_subject'])) {
  575. echo stripslashes(hesk_input($_SESSION['c_subject']));
  576. } ?>" <?php if (in_array('subject', $_SESSION['iserror'])) {
  577. echo ' class="isError" ';
  578. } ?> placeholder="<?php echo htmlspecialchars($hesklang['subject']); ?>"
  579. data-error="<?php echo htmlspecialchars($hesklang['enter_subject']); ?>"
  580. required>
  581. <div class="help-block with-errors"></div>
  582. </div>
  583. </div>
  584. <?php
  585. }
  586. if ($hesk_settings['require_message'] != -1) {
  587. ?>
  588. <div class="form-group" id="message-group">
  589. <label for="message" class="col-sm-3 control-label">
  590. <?php echo $hesklang['message']; ?>
  591. <?php echo $hesk_settings['require_message'] ? '<span class="important">*</span>' : ''; ?>
  592. </label>
  593. <div class="col-sm-9">
  594. <textarea placeholder="<?php echo htmlspecialchars($hesklang['message']); ?>" name="message"
  595. id="message" class="form-control htmlEditor" rows="12"
  596. data-rich-text-enabled="<?php echo $modsForHesk_settings['rich_text_for_tickets_for_customers']; ?>"
  597. cols="60" <?php if (in_array('message', $_SESSION['iserror'])) {
  598. echo ' class="isError" ';
  599. } ?> data-error="<?php echo htmlspecialchars($hesklang['enter_message']); ?>"
  600. required><?php if (isset($_SESSION['c_message'])) {
  601. echo stripslashes(hesk_input($_SESSION['c_message']));
  602. } ?></textarea>
  603. <div class="help-block with-errors" id="message-help-block"></div>
  604. <?php if ($modsForHesk_settings['rich_text_for_tickets_for_customers']): ?>
  605. <script type="text/javascript">
  606. /* <![CDATA[ */
  607. $(document).ready(function() {
  608. $('.htmlEditor').summernote({
  609. height: 200,
  610. toolbar: [
  611. ['style', ['bold', 'italic', 'underline', 'clear']],
  612. ['font', ['strikethrough', 'superscript', 'subscript']],
  613. ['para', ['ul', 'ol']]
  614. ]
  615. });
  616. });
  617. /* ]]> */
  618. </script>
  619. <?php endif; ?>
  620. </div>
  621. </div>
  622. <?php
  623. }
  624. }
  625. ?>
  626. <!-- START KNOWLEDGEBASE SUGGEST -->
  627. <?php
  628. if (has_public_kb() && $hesk_settings['kb_recommendanswers']) {
  629. ?>
  630. <div id="kb_suggestions" style="display:none">
  631. <br/>&nbsp;<br/>
  632. <img src="img/loading.gif" width="24" height="24" alt="" border="0"
  633. style="vertical-align:text-bottom"/> <i><?php echo $hesklang['lkbs']; ?></i>
  634. </div>
  635. <script language="Javascript" type="text/javascript"><!--
  636. hesk_suggestKB();
  637. //-->
  638. </script>
  639. <?php
  640. }
  641. ?>
  642. <!-- END KNOWLEDGEBASE SUGGEST -->
  643. <!-- START CUSTOM AFTER -->
  644. <?php
  645. /* custom fields AFTER comments */
  646. foreach ($hesk_settings['custom_fields'] as $k=>$v)
  647. {
  648. if ($v['use']==1 && $v['place']==1 && hesk_is_custom_field_in_category($k, $category) )
  649. {
  650. if ($v['req']) {
  651. $v['req']= '<span class="important">*</span>';
  652. $required_attribute = 'data-error="' . $hesklang['this_field_is_required'] . '" required';
  653. } else {
  654. $v['req'] = '';
  655. $required_attribute = '';
  656. }
  657. if ($v['type'] == 'checkbox')
  658. {
  659. $k_value = array();
  660. if (isset($_SESSION["c_$k"]) && is_array($_SESSION["c_$k"]))
  661. {
  662. foreach ($_SESSION["c_$k"] as $myCB)
  663. {
  664. $k_value[] = stripslashes(hesk_input($myCB));
  665. }
  666. }
  667. }
  668. elseif (isset($_SESSION["c_$k"]))
  669. {
  670. $k_value = stripslashes(hesk_input($_SESSION["c_$k"]));
  671. }
  672. else
  673. {
  674. $k_value = '';
  675. }
  676. switch ($v['type'])
  677. {
  678. /* Radio box */
  679. case 'radio':
  680. $cls = in_array($k,$_SESSION['iserror']) ? ' class="isError" ' : '';
  681. echo '
  682. <div class="form-group '.$cls.'">
  683. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  684. <div class="col-sm-9">';
  685. foreach ($v['value']['radio_options'] as $option) {
  686. if (strlen($k_value) == 0) {
  687. $k_value = $option;
  688. $checked = empty($v['value']['no_default']) ? 'checked' : '';
  689. } elseif ($k_value == $option) {
  690. $k_value = $option;
  691. $checked = 'checked';
  692. } else {
  693. $checked = '';
  694. }
  695. echo '<div class="radio"><label><input type="radio" name="'.$k.'" value="'.$option.'" '.$checked.' '.$required_attribute.'> '.$option.'</label></div>';
  696. }
  697. echo '
  698. <div class="help-block with-errors"></div>
  699. </div>
  700. </div>';
  701. break;
  702. /* Select drop-down box */
  703. case 'select':
  704. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  705. echo '
  706. <div class="form-group '.$cls.'">
  707. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  708. <div class="col-sm-9">
  709. <select name="'.$k.'" class="form-control" '.$required_attribute.'>';
  710. // Show "Click to select"?
  711. if ( ! empty($v['value']['show_select']))
  712. {
  713. echo '<option value="">'.$hesklang['select'].'</option>';
  714. }
  715. foreach ($v['value']['select_options'] as $option)
  716. {
  717. if ($k_value == $option)
  718. {
  719. $k_value = $option;
  720. $selected = 'selected';
  721. }
  722. else
  723. {
  724. $selected = '';
  725. }
  726. echo '<option '.$selected.'>'.$option.'</option>';
  727. }
  728. echo '</select>
  729. <div class="help-block with-errors"></div>
  730. </div>
  731. </div>';
  732. break;
  733. /* Checkbox */
  734. case 'checkbox':
  735. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  736. $validator = $v['req'] == '<span class="important">*</span>' ? 'data-checkbox="' . $k . '"' : '';
  737. $required_attribute = $validator == '' ? '' : ' data-error="' . $hesklang['this_field_is_required'] . '"';
  738. echo '
  739. <div class="form-group '.$cls.'">
  740. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  741. <div class="col-sm-9">';
  742. foreach ($v['value']['checkbox_options'] as $option)
  743. {
  744. if (in_array($option,$k_value))
  745. {
  746. $checked = 'checked';
  747. }
  748. else
  749. {
  750. $checked = '';
  751. }
  752. echo '<div class="checkbox"><label><input ' . $validator . ' type="checkbox" name="'.$k.'[]" value="'.$option.'" '.$checked.' '.$required_attribute.'> '.$option.'</label></div>';
  753. }
  754. echo '
  755. <div class="help-block with-errors"></div>
  756. </div>
  757. </div>';
  758. break;
  759. /* Large text box */
  760. case 'textarea':
  761. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  762. echo '
  763. <div class="form-group '.$cls.'">
  764. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  765. <div class="col-sm-9">
  766. <textarea class="form-control" name="'.$k.'" rows="'.intval($v['value']['rows']).'" cols="'.intval($v['value']['cols']).'" '.$required_attribute.'>'.$k_value.'</textarea>
  767. <div class="help-block with-errors"></div>
  768. </div>
  769. </div>';
  770. break;
  771. // Date
  772. case 'date':
  773. if ($required_attribute != '') {
  774. $required_attribute .= ' pattern="[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])"';
  775. }
  776. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  777. echo '
  778. <div class="form-group '.$cls.'">
  779. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  780. <div class="col-sm-9">
  781. <input type="text" name="'.$k.'" value="'.$k_value.'" class="form-control datepicker" size="10" '.$required_attribute.'>
  782. <div class="help-block with-errors"></div>
  783. </div>
  784. </div>';
  785. break;
  786. // Email
  787. case 'email':
  788. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  789. $suggest = $hesk_settings['detect_typos'] ? 'onblur="Javascript:hesk_suggestEmail(\''.$k.'\', \''.$k.'_suggestions\', 0, 0'.($v['value']['multiple'] ? ',1' : '').')"' : '';
  790. echo '
  791. <div class="form-group '.$cls.'">
  792. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  793. <div class="col-sm-9">
  794. <input type="text" name="'.$k.'" id="'.$k.'" value="'.$k_value.'" size="40" class="form-control" '.$suggest.' '.$required_attribute.'>
  795. <div class="help-block with-errors"></div>
  796. </div>
  797. <div id="'.$k.'_suggestions"></div>
  798. </div>';
  799. break;
  800. // Hidden
  801. case 'hidden':
  802. if (strlen($k_value) != 0 || isset($_SESSION["c_$k"]))
  803. {
  804. $v['value']['default_value'] = $k_value;
  805. }
  806. $hidden_cf_buffer .= '<input type="hidden" name="'.$k.'" value="'.$v['value']['default_value'].'" />';
  807. break;
  808. // Readonly
  809. case 'readonly':
  810. if (strlen($k_value) != 0 || isset($_SESSION["c_$k"]))
  811. {
  812. $v['value']['default_value'] = $k_value;
  813. }
  814. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  815. echo '
  816. <div class="form-group '.$cls.'">
  817. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  818. <div class="col-sm-9">
  819. <input type="text" class="form-control white-readonly" name="'.$k.'" size="40" value="'.$v['value']['default_value'].'" readonly>
  820. </div>
  821. </div>';
  822. break;
  823. /* Default text input */
  824. default:
  825. if (strlen($k_value) != 0 || isset($_SESSION["c_$k"]))
  826. {
  827. $v['value']['default_value'] = $k_value;
  828. }
  829. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  830. echo '
  831. <div class="form-group '.$cls.'">
  832. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  833. <div class="col-sm-9">
  834. <input type="text" class="form-control" name="'.$k.'" size="40" maxlength="'.intval($v['value']['max_length']).'" value="'.$v['value']['default_value'].'" ' . $required_attribute . '>
  835. <div class="help-block with-errors"></div>
  836. </div>
  837. </div>';
  838. }
  839. }
  840. }
  841. ?>
  842. <!-- END CUSTOM AFTER -->
  843. <?php
  844. /* attachments */
  845. if ($hesk_settings['attachments']['use']) {
  846. ?>
  847. <div class="form-group">
  848. <label for="attachments" class="col-sm-3 control-label"><?php echo $hesklang['attachments']; ?>
  849. :</label>
  850. <div align="left" class="col-sm-9">
  851. <?php build_dropzone_markup(); ?>
  852. </div>
  853. </div>
  854. <?php
  855. display_dropzone_field(HESK_PATH . 'internal-api/ticket/upload-attachment.php');
  856. }
  857. if ($hesk_settings['question_use'] || $hesk_settings['secimg_use'])
  858. {
  859. ?>
  860. <!-- Security checks -->
  861. <?php
  862. if ($hesk_settings['question_use']) {
  863. ?>
  864. <div class="form-group">
  865. <label for="question" class="col-sm-3 control-label"><?php echo $hesklang['verify_q']; ?> <span
  866. class="important">*</span></label>
  867. <?php
  868. $value = '';
  869. if (isset($_SESSION['c_question'])) {
  870. $value = stripslashes(hesk_input($_SESSION['c_question']));
  871. }
  872. $cls = in_array('question', $_SESSION['iserror']) ? ' class="isError" ' : '';
  873. echo '<div class="col-md-9">' . $hesk_settings['question_ask'] . '<br />
  874. <input class="form-control" id="question" type="text" name="question"
  875. data-error="'.htmlspecialchars($hesklang['this_field_is_required']).'"
  876. size="20" value="' . $value . '" ' . $cls . ' required>
  877. <div class="help-block with-errors"></div>
  878. </div>';
  879. ?>
  880. </div>
  881. <?php
  882. }
  883. if ($hesk_settings['secimg_use'])
  884. {
  885. ?>
  886. <div class="form-group">
  887. <label for="secimage" class="col-sm-3 control-label"><?php echo $hesklang['verify_i']; ?> <span
  888. class="important">*</span></label>
  889. <?php
  890. // SPAM prevention verified for this session
  891. if (isset($_SESSION['img_verified'])) {
  892. echo '<img src="' . HESK_PATH . 'img/success.png" width="16" height="16" border="0" alt="" style="vertical-align:text-bottom" /> ' . $hesklang['vrfy'];
  893. } // Not verified yet, should we use Recaptcha?
  894. elseif ($hesk_settings['recaptcha_use'] == 1) {
  895. ?>
  896. <script type="text/javascript">
  897. var RecaptchaOptions = {
  898. theme: '<?php echo ( isset($_SESSION['iserror']) && in_array('mysecnum',$_SESSION['iserror']) ) ? 'red' : 'white'; ?>',
  899. custom_translations: {
  900. visual_challenge: "<?php echo hesk_slashJS($hesklang['visual_challenge']); ?>",
  901. audio_challenge: "<?php echo hesk_slashJS($hesklang['audio_challenge']); ?>",
  902. refresh_btn: "<?php echo hesk_slashJS($hesklang['refresh_btn']); ?>",
  903. instructions_visual: "<?php echo hesk_slashJS($hesklang['instructions_visual']); ?>",
  904. instructions_context: "<?php echo hesk_slashJS($hesklang['instructions_context']); ?>",
  905. instructions_audio: "<?php echo hesk_slashJS($hesklang['instructions_audio']); ?>",
  906. help_btn: "<?php echo hesk_slashJS($hesklang['help_btn']); ?>",
  907. play_again: "<?php echo hesk_slashJS($hesklang['play_again']); ?>",
  908. cant_hear_this: "<?php echo hesk_slashJS($hesklang['cant_hear_this']); ?>",
  909. incorrect_try_again: "<?php echo hesk_slashJS($hesklang['incorrect_try_again']); ?>",
  910. image_alt_text: "<?php echo hesk_slashJS($hesklang['image_alt_text']); ?>"
  911. }
  912. };
  913. </script>
  914. <div class="col-md-9">
  915. <?php
  916. require(HESK_PATH . 'inc/recaptcha/recaptchalib.php');
  917. echo recaptcha_get_html($hesk_settings['recaptcha_public_key'], null, true);
  918. ?>
  919. </div>
  920. <?php
  921. }
  922. // Use reCaptcha API v2?
  923. elseif ($hesk_settings['recaptcha_use'] == 2)
  924. {
  925. ?>
  926. <div class="col-md-9">
  927. <div class="g-recaptcha"
  928. data-sitekey="<?php echo $hesk_settings['recaptcha_public_key']; ?>">
  929. </div>
  930. </div>
  931. <?php
  932. }
  933. // At least use some basic PHP generated image (better than nothing)
  934. else {
  935. $cls = in_array('mysecnum', $_SESSION['iserror']) ? ' class="isError" ' : '';
  936. echo '<div align="left" class="col-sm-9">';
  937. echo $hesklang['sec_enter'] . '<br />&nbsp;<br /><img src="print_sec_img.php?' . rand(10000, 99999) . '" width="150" height="40" alt="' . $hesklang['sec_img'] . '" title="' . $hesklang['sec_img'] . '" border="1" name="secimg" style="vertical-align:text-bottom" /> ' .
  938. '<a href="javascript:void(0)" onclick="javascript:document.form1.secimg.src=\'print_sec_img.php?\'+ ( Math.floor((90000)*Math.random()) + 10000);"><img src="img/reload.png" height="24" width="24" alt="' . $hesklang['reload'] . '" title="' . $hesklang['reload'] . '" border="0" style="vertical-align:text-bottom" /></a>' .
  939. '<br />&nbsp;<br /><input type="text" name="mysecnum" size="20" maxlength="5" ' . $cls . ' /></div>';
  940. }
  941. echo '</div>';
  942. }
  943. ?>
  944. <?php
  945. }
  946. if ($modsForHesk_settings['request_location']):
  947. ?>
  948. <div class="form-group">
  949. <label for="location"
  950. class="col-md-3 control-label"><?php echo $hesklang['location_colon']; ?></label>
  951. <div class="col-sm-9">
  952. <p id="console"><?php echo $hesklang['requesting_location_ellipsis']; ?></p>
  953. <div id="map" style="height: 300px; display:none">
  954. </div>
  955. </div>
  956. </div>
  957. <!-- Submit -->
  958. <?php
  959. endif;
  960. if ($hesk_settings['submit_notice']) {
  961. ?>
  962. <div class="row">
  963. <div class="col-md-12">
  964. <div class="alert alert-info">
  965. <b><?php echo $hesklang['before_submit']; ?></b>
  966. <ul>
  967. <li><?php echo $hesklang['all_info_in']; ?>.</li>
  968. <li><?php echo $hesklang['all_error_free']; ?>.</li>
  969. </ul>
  970. <b><?php echo $hesklang['we_have']; ?>:</b>
  971. <ul>
  972. <li><?php echo hesk_htmlspecialchars(hesk_getClientIP()) . ' ' . $hesklang['recorded_ip']; ?></li>
  973. <li><?php echo $hesklang['recorded_time']; ?></li>
  974. </ul>
  975. </div>
  976. </div>
  977. </div>
  978. <div class="row">
  979. <div class="col-md-9 col-md-offset-3">
  980. <input type="hidden" id="latitude" name="latitude" value="E-0">
  981. <input type="hidden" id="longitude" name="longitude" value="E-0">
  982. <input type="hidden" name="token" value="<?php hesk_token_echo(); ?>">
  983. <input type="hidden" id="screen-resolution-height" name="screen_resolution_height">
  984. <input type="hidden" id="screen-resolution-width" name="screen_resolution_width">
  985. <input type="submit" value="<?php echo $hesklang['sub_ticket']; ?>"
  986. class="btn btn-default">
  987. </div>
  988. </div>
  989. <script>
  990. $('#screen-resolution-height').prop('value', screen.height);
  991. $('#screen-resolution-width').prop('value', screen.width);
  992. </script>
  993. <?php
  994. } // End IF submit_notice
  995. else {
  996. ?>
  997. <div class=" row">
  998. <div class="col-md-9 col-md-offset-3">
  999. <input type="hidden" id="latitude" name="latitude" value="E-0">
  1000. <input type="hidden" id="longitude" name="longitude" value="E-0">
  1001. <input type="hidden" id="screen-resolution-height" name="screen_resolution_height">
  1002. <input type="hidden" id="screen-resolution-width" name="screen_resolution_width">
  1003. <input type="hidden" name="token" value="<?php hesk_token_echo(); ?>">
  1004. <input class="btn btn-default" type="submit"
  1005. value="<?php echo $hesklang['sub_ticket']; ?>">
  1006. <script>
  1007. $('#screen-resolution-height').prop('value', screen.height);
  1008. $('#screen-resolution-width').prop('value', screen.width);
  1009. </script>
  1010. </div>
  1011. </div>
  1012. <?php
  1013. } // End ELSE submit_notice
  1014. // Print custom hidden fields
  1015. echo $hidden_cf_buffer;
  1016. ?>
  1017. <input type="hidden" name="category" value="<?php echo $category; ?>">
  1018. <!-- Do not delete or modify the code below, it is used to detect simple SPAM bots -->
  1019. <input type="hidden" name="hx" value="3"/><input type="hidden" name="hy" value=""/>
  1020. <!-- >
  1021. <input type="text" name="phone" value="3" />
  1022. < -->
  1023. </form>
  1024. <script>
  1025. buildValidatorForTicketSubmission("form1",
  1026. "<?php echo addslashes($hesklang['select_at_least_one_value']); ?>");
  1027. </script>
  1028. </div>
  1029. </form>
  1030. <?php if ($columnWidth == 'col-md-10 col-md-offset-1'): ?>
  1031. <div class="col-md-1">&nbsp;</div></div>
  1032. <?php endif; ?>
  1033. <!-- END FORM -->
  1034. <?php
  1035. // Request for the users location if enabled
  1036. if ($modsForHesk_settings['request_location']) {
  1037. echo '
  1038. <script>
  1039. requestUserLocation("' . $hesklang['your_current_location'] . '", "' . $hesklang['unable_to_determine_location'] . '");
  1040. </script>
  1041. ';
  1042. }
  1043. hesk_cleanSessionVars('iserror');
  1044. hesk_cleanSessionVars('isnotice');
  1045. } // End print_add_ticket()
  1046. function print_start()
  1047. {
  1048. global $hesk_settings, $hesklang;
  1049. // Connect to database
  1050. hesk_load_database_functions();
  1051. hesk_dbConnect();
  1052. define('PAGE_TITLE', 'CUSTOMER_HOME');
  1053. // This will be used to determine how much space to print after KB
  1054. $hesk_settings['kb_spacing'] = 4;
  1055. // Include KB functionality only if we have any public articles
  1056. has_public_kb();
  1057. if ($hesk_settings['kb_enable'])
  1058. {
  1059. require(HESK_PATH . 'inc/knowledgebase_functions.inc.php');
  1060. }
  1061. else
  1062. {
  1063. $hesk_settings['kb_spacing'] += 2;
  1064. }
  1065. /* Print header */
  1066. require_once(HESK_PATH . 'inc/header.inc.php');
  1067. ?>
  1068. <ol class="breadcrumb">
  1069. <li><a href="<?php echo $hesk_settings['site_url']; ?>"><?php echo $hesk_settings['site_title']; ?></a></li>
  1070. <li class="active"><?php echo $hesk_settings['hesk_title']; ?></li>
  1071. </ol>
  1072. <?php
  1073. // Service messages
  1074. $res = hesk_dbQuery('SELECT `title`, `message`, `style`, `icon` FROM `'.hesk_dbEscape($hesk_settings['db_pfix'])."service_messages` WHERE `type`='0' ORDER BY `order` ASC");
  1075. if (hesk_dbNumRows($res) > 0)
  1076. {
  1077. ?>
  1078. <div class="row">
  1079. <div class="col-md-12">
  1080. <?php
  1081. while ($sm=hesk_dbFetchAssoc($res))
  1082. {
  1083. hesk_service_message($sm);
  1084. }
  1085. ?>
  1086. </div>
  1087. </div>
  1088. <?php } ?>
  1089. <div class="row">
  1090. <div class="col-md-4">
  1091. <div class="panel panel-default">
  1092. <div class="panel-heading"><?php echo $hesklang['view_ticket']; ?></div>
  1093. <div class="panel-body">
  1094. <form data-toggle="validator" role="form" class="viewTicketSidebar" action="ticket.php" method="get" name="form2">
  1095. <div class="form-group">
  1096. <br/>
  1097. <label for="ticketID"><?php echo $hesklang['ticket_trackID']; ?>:</label>
  1098. <input type="text" class="form-control" name="track" id="ticketID" maxlength="20" size="35" value=""
  1099. data-error="<?php echo htmlspecialchars($hesklang['enter_id']); ?>"
  1100. placeholder="<?php echo htmlspecialchars($hesklang['ticket_trackID']); ?>" required>
  1101. <div class="help-block with-errors"></div>
  1102. </div>
  1103. <?php
  1104. $tmp = '';
  1105. if ($hesk_settings['email_view_ticket'])
  1106. {
  1107. $tmp = 'document.form1.email.value=document.form2.e.value;';
  1108. ?>
  1109. <div class="form-group">
  1110. <label for="emailAddress"><?php echo $hesklang['email']; ?>:</label>
  1111. <?php
  1112. $my_email = '';
  1113. $do_remember = '';
  1114. if (isset($_COOKIE['hesk_myemail']))
  1115. {
  1116. $my_email = $_COOKIE['hesk_myemail'];
  1117. $do_remember = 'checked';
  1118. }
  1119. ?>
  1120. <input type="text" class="form-control" name="e" id="emailAddress" size="35" value="<?php echo $my_email; ?>"
  1121. data-error="<?php echo htmlspecialchars($hesklang['enter_valid_email']); ?>"
  1122. placeholder="<?php echo htmlspecialchars($hesklang['email']); ?>" required>
  1123. <div class="help-block with-errors"></div>
  1124. </div>
  1125. <div class="checkbox">
  1126. <label for="r">
  1127. <input type="checkbox" name="r" value="Y" <?php echo $do_remember; ?>> <?php echo $hesklang['rem_email']; ?>
  1128. </label>
  1129. </div>
  1130. <?php
  1131. }
  1132. ?>
  1133. <input type="submit" value="<?php echo $hesklang['view_ticket']; ?>" class="btn btn-default" /><input type="hidden" name="Refresh" value="<?php echo rand(10000,99999); ?>"><input type="hidden" name="f" value="1">
  1134. </form>
  1135. </div>
  1136. </div>
  1137. </div>
  1138. <div class="col-md-8">
  1139. <?php
  1140. // Print small search box
  1141. if ($hesk_settings['kb_enable'])
  1142. {
  1143. hesk_kbSearchSmall();
  1144. hesk_kbSearchLarge();
  1145. }
  1146. else
  1147. {
  1148. echo '&nbsp;';
  1149. }
  1150. ?>
  1151. <div class="row default-row-margins">
  1152. <div class="col-sm-6 col-xs-12">
  1153. <a href="index.php?a=add" class="button-link">
  1154. <div class="panel panel-default">
  1155. <div class="panel-body">
  1156. <div class="row">
  1157. <div class="col-xs-1">
  1158. <img src="img/newTicket.png" alt="<?php echo $hesklang['sub_support']; ?>">
  1159. </div>
  1160. <div class="col-xs-11">
  1161. <b><?php echo $hesklang['sub_support']; ?></b><br>
  1162. <?php echo $hesklang['open_ticket']; ?>
  1163. </div>
  1164. </div>
  1165. </div>
  1166. </div>
  1167. </a>
  1168. </div>
  1169. <div class="col-sm-6 col-xs-12">
  1170. <a href="ticket.php" class="button-link">
  1171. <div class="panel panel-default">
  1172. <div class="panel-body">
  1173. <div class="row">
  1174. <div class="col-xs-1">
  1175. <img src="img/viewTicket.png" alt="<?php echo $hesklang['view_existing']; ?>">
  1176. </div>
  1177. <div class="col-xs-11">
  1178. <b><?php echo $hesklang['view_existing']; ?></b><br>
  1179. <?php echo $hesklang['vet']; ?>
  1180. </div>
  1181. </div>
  1182. </div>
  1183. </div>
  1184. </a>
  1185. </div>
  1186. </div>
  1187. <div class="row default-row-margins">
  1188. <?php
  1189. if ($hesk_settings['kb_enable'])
  1190. {
  1191. ?>
  1192. <div class="col-sm-6 col-xs-12">
  1193. <a href="knowledgebase.php" class="button-link">
  1194. <div class="panel panel-default">
  1195. <div class="panel-body">
  1196. <div class="row">
  1197. <div class="col-xs-1">
  1198. <img src="img/knowledgebase.png" alt="<?php echo $hesklang['kb_text']; ?>">
  1199. </div>
  1200. <div class="col-xs-11">
  1201. <b><?php echo $hesklang['kb_text']; ?></b><br>
  1202. <?php echo $hesklang['viewkb']; ?>
  1203. </div>
  1204. </div>
  1205. </div>
  1206. </div>
  1207. </a>
  1208. </div>
  1209. <?php } if ($modsForHesk_settings['enable_calendar'] == 1): ?>
  1210. <div class="col-sm-6 col-xs-12">
  1211. <a href="calendar.php" class="button-link">
  1212. <div class="panel panel-default">
  1213. <div class="panel-body">
  1214. <div class="row">
  1215. <div class="col-xs-1">
  1216. <i class="fa fa-calendar black" style="font-size: 32px"
  1217. title="<?php echo $hesklang['calendar_title_case']; ?>"></i>
  1218. </div>
  1219. <div class="col-xs-11">
  1220. <b><?php echo $hesklang['calendar_title_case']; ?></b><br>
  1221. <?php echo $hesklang['calendar_index']; ?>
  1222. </div>
  1223. </div>
  1224. </div>
  1225. </div>
  1226. </a>
  1227. </div>
  1228. <?php endif;
  1229. $customNavRs = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "custom_nav_element` AS `t1`
  1230. INNER JOIN `" . hesk_dbEscape($hesk_settings['db_pfix']) . "custom_nav_element_to_text` AS `t2`
  1231. ON `t1`.`id` = `t2`.`nav_element_id`
  1232. AND `t2`.`language` = '" . hesk_dbEscape($hesk_settings['language']) . "'
  1233. WHERE `t1`.`place` = 1");
  1234. while ($row = hesk_dbFetchAssoc($customNavRs)):
  1235. ?>
  1236. <div class="col-sm-6 col-xs-12">
  1237. <a href="<?php echo $row['url']; ?>" class="button-link">
  1238. <div class="panel panel-default">
  1239. <div class="panel-body">
  1240. <div class="row">
  1241. <div class="col-xs-1">
  1242. <?php if ($row['image_url'] !== null): ?>
  1243. <img src="<?php echo $row['image_url']; ?>" alt="<?php echo $row['text']; ?>">
  1244. <?php else: ?>
  1245. <i class="<?php echo $row['font_icon']; ?> black" style="font-size: 32px"></i>
  1246. <?php endif; ?>
  1247. </div>
  1248. <div class="col-xs-11">
  1249. <b><?php echo $row['text']; ?></b><br>
  1250. <?php echo $row['subtext']; ?>
  1251. </div>
  1252. </div>
  1253. </div>
  1254. </div>
  1255. </a>
  1256. </div>
  1257. <?php endwhile; ?>
  1258. </div>
  1259. <?php
  1260. if ($hesk_settings['kb_enable'])
  1261. {
  1262. hesk_kbTopArticles($hesk_settings['kb_index_popart']);
  1263. hesk_kbLatestArticles($hesk_settings['kb_index_latest']);
  1264. }
  1265. ?>
  1266. </div>
  1267. </div>
  1268. <div class="blankSpace"></div>
  1269. <div class="footerWithBorder"></div>
  1270. <div class="blankSpace"></div>
  1271. </div>
  1272. <?php
  1273. // Show a link to admin panel?
  1274. if ($hesk_settings['alink'])
  1275. {
  1276. ?>
  1277. <p class="text-center"><a href="<?php echo $hesk_settings['admin_dir']; ?>/" ><?php echo $hesklang['ap']; ?></a></p>
  1278. <?php
  1279. }
  1280. } // End print_start()
  1281. function forgot_tid()
  1282. {
  1283. global $hesk_settings, $hesklang, $modsForHesk_settings;
  1284. require(HESK_PATH . 'inc/email_functions.inc.php');
  1285. /* Get ticket(s) from database */
  1286. hesk_dbConnect();
  1287. $email = hesk_emailCleanup(hesk_validateEmail(hesk_POST('email'), 'ERR', 0)) or hesk_process_messages($hesklang['enter_valid_email'], 'ticket.php?remind=1');
  1288. if (isset($_POST['open_only'])) {
  1289. $hesk_settings['open_only'] = $_POST['open_only'] == 1 ? 1 : 0;
  1290. }
  1291. /* Prepare ticket statuses */
  1292. $myStatusSQL = hesk_dbQuery("SELECT `ID`, `Key` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses`");
  1293. $my_status = array();
  1294. while ($myStatusRow = hesk_dbFetchAssoc($myStatusSQL)) {
  1295. $my_status[$myStatusRow['ID']] = $hesklang[$myStatusRow['Key']];
  1296. }
  1297. // Get tickets from the database
  1298. $res = hesk_dbQuery('SELECT * FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'tickets` FORCE KEY (`statuses`) WHERE ' . ($hesk_settings['open_only'] ? "`status` IN (SELECT `ID` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` WHERE `IsClosed` = 0) AND " : '') . ' ' . hesk_dbFormatEmail($email) . ' ORDER BY `status` ASC, `lastchange` DESC ');
  1299. $num = hesk_dbNumRows($res);
  1300. if ($num < 1) {
  1301. if ($hesk_settings['open_only']) {
  1302. hesk_process_messages($hesklang['noopen'],'ticket.php?remind=1&e='.rawurlencode($email));
  1303. } else {
  1304. hesk_process_messages($hesklang['tid_not_found'],'ticket.php?remind=1&e='.rawurlencode($email));
  1305. }
  1306. }
  1307. $tid_list = '';
  1308. $html_tid_list = '<ul>';
  1309. $name = '';
  1310. $email_param = $hesk_settings['email_view_ticket'] ? '&e=' . rawurlencode($email) : '';
  1311. while ($my_ticket = hesk_dbFetchAssoc($res)) {
  1312. $name = $name ? $name : hesk_msgToPlain($my_ticket['name'], 1, 0);
  1313. $tid_list .= "
  1314. $hesklang[trackID]: " . $my_ticket['trackid'] . "
  1315. $hesklang[subject]: " . hesk_msgToPlain($my_ticket['subject'], 1, 0) . "
  1316. $hesklang[status]: " . $my_status[$my_ticket['status']] . "
  1317. $hesk_settings[hesk_url]/ticket.php?track={$my_ticket['trackid']}{$email_param}
  1318. ";
  1319. $html_tid_list .= "<li>
  1320. $hesklang[trackID]: " . $my_ticket['trackid'] . " <br>
  1321. $hesklang[subject]: " . hesk_msgToPlain($my_ticket['subject'], 1, 0) . " <br>
  1322. $hesklang[status]: " . $my_status[$my_ticket['status']] . " <br>
  1323. $hesk_settings[hesk_url]/ticket.php?track={$my_ticket['trackid']}{$email_param}
  1324. </li>";
  1325. }
  1326. $html_tid_list .= '</ul>';
  1327. /* Get e-mail message for customer */
  1328. $msg = hesk_getEmailMessage('forgot_ticket_id', '', $modsForHesk_settings, 0, 0, 1);
  1329. $msg = processEmail($msg, $name, $num, $tid_list);
  1330. // Get HTML message for customer
  1331. $htmlMsg = hesk_getHtmlMessage('forgot_ticket_id', '', $modsForHesk_settings, 0, 0, 1);
  1332. $htmlMsg = processEmail($htmlMsg, $name, $num, $html_tid_list);
  1333. $subject = hesk_getEmailSubject('forgot_ticket_id');
  1334. /* Send e-mail */
  1335. hesk_mail($email, $subject, $msg, $htmlMsg, $modsForHesk_settings);
  1336. /* Show success message */
  1337. $tmp = '<b>' . $hesklang['tid_sent'] . '!</b>';
  1338. $tmp .= '<br />&nbsp;<br />' . $hesklang['tid_sent2'] . '.';
  1339. $tmp .= '<br />&nbsp;<br />' . $hesklang['check_spambox'];
  1340. hesk_process_messages($tmp, 'ticket.php?e=' . $email, 'SUCCESS');
  1341. exit();
  1342. /* Print header */
  1343. $hesk_settings['tmp_title'] = $hesk_settings['hesk_title'] . ' - ' . $hesklang['tid_sent'];
  1344. require_once(HESK_PATH . 'inc/header.inc.php');
  1345. ?>
  1346. <ol class="breadcrumb">
  1347. <li><a href="<?php echo $hesk_settings['site_url']; ?>"><?php echo $hesk_settings['site_title']; ?></a></li>
  1348. <li><a href="<?php echo $hesk_settings['hesk_url']; ?>"><?php echo $hesk_settings['hesk_title']; ?></a></li>
  1349. <li class="active"><?php echo $hesklang['tid_sent']; ?></li>
  1350. </ol>
  1351. <tr>
  1352. <td>
  1353. <?php
  1354. } // End forgot_tid()
  1355. function processEmail($msg, $name, $num, $tid_list) {
  1356. global $hesk_settings;
  1357. $msg = str_replace('%%NAME%%', $name, $msg);
  1358. $msg = str_replace('%%NUM%%', $num, $msg);
  1359. $msg = str_replace('%%LIST_TICKETS%%', $tid_list, $msg);
  1360. $msg = str_replace('%%SITE_TITLE%%', hesk_msgToPlain($hesk_settings['site_title'], 1), $msg);
  1361. $msg = str_replace('%%SITE_URL%%', $hesk_settings['site_url'], $msg);
  1362. return $msg;
  1363. }
  1364. function has_public_kb($use_cache=1) {
  1365. global $hesk_settings;
  1366. // Return if KB is disabled
  1367. if ( ! $hesk_settings['kb_enable']) {
  1368. return 0;
  1369. }
  1370. // Do we have a cached version available
  1371. $cache_dir = $hesk_settings['cache_dir'].'/';
  1372. $cache_file = $cache_dir . 'kb.cache.php';
  1373. if ($use_cache && file_exists($cache_file)) {
  1374. require($cache_file);
  1375. return $hesk_settings['kb_enable'];
  1376. }
  1377. // Make sure we have database connection
  1378. hesk_load_database_functions();
  1379. hesk_dbConnect();
  1380. // Do we have any public articles at all?
  1381. $res = hesk_dbQuery("SELECT `t1`.`id` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` AS `t1`
  1382. LEFT JOIN `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` AS `t2` ON `t1`.`catid` = `t2`.`id`
  1383. WHERE `t1`.`type`='0' AND `t2`.`type`='0' LIMIT 1");
  1384. // If no public articles, disable the KB functionality
  1385. if (hesk_dbNumRows($res) < 1) {
  1386. $hesk_settings['kb_enable'] = 0;
  1387. }
  1388. // Try to cache results
  1389. if ($use_cache && (is_dir($cache_dir) || (@mkdir($cache_dir, 0777) && is_writable($cache_dir)))) {
  1390. // Is there an index.htm file?
  1391. if ( ! file_exists($cache_dir.'index.htm')) {
  1392. @file_put_contents($cache_dir.'index.htm', '');
  1393. }
  1394. // Write data
  1395. @file_put_contents($cache_file, '<?php if (!defined(\'IN_SCRIPT\')) {die();} $hesk_settings[\'kb_enable\']=' . $hesk_settings['kb_enable'] . ';' );
  1396. }
  1397. return $hesk_settings['kb_enable'];
  1398. } // End has_public_kb()