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 74KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604
  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. tinyMCE.init({
  608. mode: "textareas",
  609. editor_selector: "htmlEditor",
  610. elements: "content",
  611. theme: "advanced",
  612. convert_urls: false,
  613. plugins: "autolink",
  614. theme_advanced_buttons1: "cut,copy,paste,|,undo,redo,|,formatselect,fontselect,fontsizeselect,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull",
  615. theme_advanced_buttons2: "sub,sup,|,charmap,|,bullist,numlist,|,outdent,indent,insertdate,inserttime,preview,|,forecolor,backcolor,|,hr,removeformat,visualaid,|,link,unlink,anchor,image,cleanup",
  616. theme_advanced_buttons3: "",
  617. theme_advanced_toolbar_location: "top",
  618. theme_advanced_toolbar_align: "left",
  619. theme_advanced_statusbar_location: "bottom",
  620. theme_advanced_resizing: true
  621. });
  622. /* ]]> */
  623. </script>
  624. <?php endif; ?>
  625. </div>
  626. </div>
  627. <?php
  628. }
  629. }
  630. ?>
  631. <!-- START KNOWLEDGEBASE SUGGEST -->
  632. <?php
  633. if (has_public_kb() && $hesk_settings['kb_recommendanswers']) {
  634. ?>
  635. <div id="kb_suggestions" style="display:none">
  636. <br/>&nbsp;<br/>
  637. <img src="img/loading.gif" width="24" height="24" alt="" border="0"
  638. style="vertical-align:text-bottom"/> <i><?php echo $hesklang['lkbs']; ?></i>
  639. </div>
  640. <script language="Javascript" type="text/javascript"><!--
  641. hesk_suggestKB();
  642. //-->
  643. </script>
  644. <?php
  645. }
  646. ?>
  647. <!-- END KNOWLEDGEBASE SUGGEST -->
  648. <!-- START CUSTOM AFTER -->
  649. <?php
  650. /* custom fields AFTER comments */
  651. foreach ($hesk_settings['custom_fields'] as $k=>$v)
  652. {
  653. if ($v['use']==1 && $v['place']==1 && hesk_is_custom_field_in_category($k, $category) )
  654. {
  655. if ($v['req']) {
  656. $v['req']= '<span class="important">*</span>';
  657. $required_attribute = 'data-error="' . $hesklang['this_field_is_required'] . '" required';
  658. } else {
  659. $v['req'] = '';
  660. $required_attribute = '';
  661. }
  662. if ($v['type'] == 'checkbox')
  663. {
  664. $k_value = array();
  665. if (isset($_SESSION["c_$k"]) && is_array($_SESSION["c_$k"]))
  666. {
  667. foreach ($_SESSION["c_$k"] as $myCB)
  668. {
  669. $k_value[] = stripslashes(hesk_input($myCB));
  670. }
  671. }
  672. }
  673. elseif (isset($_SESSION["c_$k"]))
  674. {
  675. $k_value = stripslashes(hesk_input($_SESSION["c_$k"]));
  676. }
  677. else
  678. {
  679. $k_value = '';
  680. }
  681. switch ($v['type'])
  682. {
  683. /* Radio box */
  684. case 'radio':
  685. $cls = in_array($k,$_SESSION['iserror']) ? ' class="isError" ' : '';
  686. echo '
  687. <div class="form-group '.$cls.'">
  688. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  689. <div class="col-sm-9">';
  690. foreach ($v['value']['radio_options'] as $option) {
  691. if (strlen($k_value) == 0) {
  692. $k_value = $option;
  693. $checked = empty($v['value']['no_default']) ? 'checked' : '';
  694. } elseif ($k_value == $option) {
  695. $k_value = $option;
  696. $checked = 'checked';
  697. } else {
  698. $checked = '';
  699. }
  700. echo '<div class="radio"><label><input type="radio" name="'.$k.'" value="'.$option.'" '.$checked.' '.$required_attribute.'> '.$option.'</label></div>';
  701. }
  702. echo '
  703. <div class="help-block with-errors"></div>
  704. </div>
  705. </div>';
  706. break;
  707. /* Select drop-down box */
  708. case 'select':
  709. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  710. echo '
  711. <div class="form-group '.$cls.'">
  712. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  713. <div class="col-sm-9">
  714. <select name="'.$k.'" class="form-control" '.$required_attribute.'>';
  715. // Show "Click to select"?
  716. if ( ! empty($v['value']['show_select']))
  717. {
  718. echo '<option value="">'.$hesklang['select'].'</option>';
  719. }
  720. foreach ($v['value']['select_options'] as $option)
  721. {
  722. if ($k_value == $option)
  723. {
  724. $k_value = $option;
  725. $selected = 'selected';
  726. }
  727. else
  728. {
  729. $selected = '';
  730. }
  731. echo '<option '.$selected.'>'.$option.'</option>';
  732. }
  733. echo '</select>
  734. <div class="help-block with-errors"></div>
  735. </div>
  736. </div>';
  737. break;
  738. /* Checkbox */
  739. case 'checkbox':
  740. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  741. $validator = $v['req'] == '<span class="important">*</span>' ? 'data-checkbox="' . $k . '"' : '';
  742. $required_attribute = $validator == '' ? '' : ' data-error="' . $hesklang['this_field_is_required'] . '"';
  743. echo '
  744. <div class="form-group '.$cls.'">
  745. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  746. <div class="col-sm-9">';
  747. foreach ($v['value']['checkbox_options'] as $option)
  748. {
  749. if (in_array($option,$k_value))
  750. {
  751. $checked = 'checked';
  752. }
  753. else
  754. {
  755. $checked = '';
  756. }
  757. echo '<div class="checkbox"><label><input ' . $validator . ' type="checkbox" name="'.$k.'[]" value="'.$option.'" '.$checked.' '.$required_attribute.'> '.$option.'</label></div>';
  758. }
  759. echo '
  760. <div class="help-block with-errors"></div>
  761. </div>
  762. </div>';
  763. break;
  764. /* Large text box */
  765. case 'textarea':
  766. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  767. echo '
  768. <div class="form-group '.$cls.'">
  769. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  770. <div class="col-sm-9">
  771. <textarea class="form-control" name="'.$k.'" rows="'.intval($v['value']['rows']).'" cols="'.intval($v['value']['cols']).'" '.$required_attribute.'>'.$k_value.'</textarea>
  772. <div class="help-block with-errors"></div>
  773. </div>
  774. </div>';
  775. break;
  776. // Date
  777. case 'date':
  778. if ($required_attribute != '') {
  779. $required_attribute .= ' pattern="[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])"';
  780. }
  781. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  782. echo '
  783. <div class="form-group '.$cls.'">
  784. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  785. <div class="col-sm-9">
  786. <input type="text" name="'.$k.'" value="'.$k_value.'" class="form-control datepicker" size="10" '.$required_attribute.'>
  787. <div class="help-block with-errors"></div>
  788. </div>
  789. </div>';
  790. break;
  791. // Email
  792. case 'email':
  793. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  794. $suggest = $hesk_settings['detect_typos'] ? 'onblur="Javascript:hesk_suggestEmail(\''.$k.'\', \''.$k.'_suggestions\', 0, 0'.($v['value']['multiple'] ? ',1' : '').')"' : '';
  795. echo '
  796. <div class="form-group '.$cls.'">
  797. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  798. <div class="col-sm-9">
  799. <input type="text" name="'.$k.'" id="'.$k.'" value="'.$k_value.'" size="40" class="form-control" '.$suggest.' '.$required_attribute.'>
  800. <div class="help-block with-errors"></div>
  801. </div>
  802. <div id="'.$k.'_suggestions"></div>
  803. </div>';
  804. break;
  805. // Hidden
  806. case 'hidden':
  807. if (strlen($k_value) != 0 || isset($_SESSION["c_$k"]))
  808. {
  809. $v['value']['default_value'] = $k_value;
  810. }
  811. $hidden_cf_buffer .= '<input type="hidden" name="'.$k.'" value="'.$v['value']['default_value'].'" />';
  812. break;
  813. // Readonly
  814. case 'readonly':
  815. if (strlen($k_value) != 0 || isset($_SESSION["c_$k"]))
  816. {
  817. $v['value']['default_value'] = $k_value;
  818. }
  819. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  820. echo '
  821. <div class="form-group '.$cls.'">
  822. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  823. <div class="col-sm-9">
  824. <input type="text" class="form-control white-readonly" name="'.$k.'" size="40" value="'.$v['value']['default_value'].'" readonly>
  825. </div>
  826. </div>';
  827. break;
  828. /* Default text input */
  829. default:
  830. if (strlen($k_value) != 0 || isset($_SESSION["c_$k"]))
  831. {
  832. $v['value']['default_value'] = $k_value;
  833. }
  834. $cls = in_array($k,$_SESSION['iserror']) ? 'isError' : '';
  835. echo '
  836. <div class="form-group '.$cls.'">
  837. <label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
  838. <div class="col-sm-9">
  839. <input type="text" class="form-control" name="'.$k.'" size="40" maxlength="'.intval($v['value']['max_length']).'" value="'.$v['value']['default_value'].'" ' . $required_attribute . '>
  840. <div class="help-block with-errors"></div>
  841. </div>
  842. </div>';
  843. }
  844. }
  845. }
  846. ?>
  847. <!-- END CUSTOM AFTER -->
  848. <?php
  849. /* attachments */
  850. if ($hesk_settings['attachments']['use']) {
  851. ?>
  852. <div class="form-group">
  853. <label for="attachments" class="col-sm-3 control-label"><?php echo $hesklang['attachments']; ?>
  854. :</label>
  855. <div align="left" class="col-sm-9">
  856. <?php build_dropzone_markup(); ?>
  857. </div>
  858. </div>
  859. <?php
  860. display_dropzone_field($hesk_settings['hesk_url'] . '/internal-api/ticket/upload-attachment.php');
  861. }
  862. if ($hesk_settings['question_use'] || $hesk_settings['secimg_use'])
  863. {
  864. ?>
  865. <!-- Security checks -->
  866. <?php
  867. if ($hesk_settings['question_use']) {
  868. ?>
  869. <div class="form-group">
  870. <label for="question" class="col-sm-3 control-label"><?php echo $hesklang['verify_q']; ?> <span
  871. class="important">*</span></label>
  872. <?php
  873. $value = '';
  874. if (isset($_SESSION['c_question'])) {
  875. $value = stripslashes(hesk_input($_SESSION['c_question']));
  876. }
  877. $cls = in_array('question', $_SESSION['iserror']) ? ' class="isError" ' : '';
  878. echo '<div class="col-md-9">' . $hesk_settings['question_ask'] . '<br />
  879. <input class="form-control" id="question" type="text" name="question"
  880. data-error="'.htmlspecialchars($hesklang['this_field_is_required']).'"
  881. size="20" value="' . $value . '" ' . $cls . ' required>
  882. <div class="help-block with-errors"></div>
  883. </div>';
  884. ?>
  885. </div>
  886. <?php
  887. }
  888. if ($hesk_settings['secimg_use'])
  889. {
  890. ?>
  891. <div class="form-group">
  892. <label for="secimage" class="col-sm-3 control-label"><?php echo $hesklang['verify_i']; ?> <span
  893. class="important">*</span></label>
  894. <?php
  895. // SPAM prevention verified for this session
  896. if (isset($_SESSION['img_verified'])) {
  897. echo '<img src="' . HESK_PATH . 'img/success.png" width="16" height="16" border="0" alt="" style="vertical-align:text-bottom" /> ' . $hesklang['vrfy'];
  898. } // Not verified yet, should we use Recaptcha?
  899. elseif ($hesk_settings['recaptcha_use'] == 1) {
  900. ?>
  901. <script type="text/javascript">
  902. var RecaptchaOptions = {
  903. theme: '<?php echo ( isset($_SESSION['iserror']) && in_array('mysecnum',$_SESSION['iserror']) ) ? 'red' : 'white'; ?>',
  904. custom_translations: {
  905. visual_challenge: "<?php echo hesk_slashJS($hesklang['visual_challenge']); ?>",
  906. audio_challenge: "<?php echo hesk_slashJS($hesklang['audio_challenge']); ?>",
  907. refresh_btn: "<?php echo hesk_slashJS($hesklang['refresh_btn']); ?>",
  908. instructions_visual: "<?php echo hesk_slashJS($hesklang['instructions_visual']); ?>",
  909. instructions_context: "<?php echo hesk_slashJS($hesklang['instructions_context']); ?>",
  910. instructions_audio: "<?php echo hesk_slashJS($hesklang['instructions_audio']); ?>",
  911. help_btn: "<?php echo hesk_slashJS($hesklang['help_btn']); ?>",
  912. play_again: "<?php echo hesk_slashJS($hesklang['play_again']); ?>",
  913. cant_hear_this: "<?php echo hesk_slashJS($hesklang['cant_hear_this']); ?>",
  914. incorrect_try_again: "<?php echo hesk_slashJS($hesklang['incorrect_try_again']); ?>",
  915. image_alt_text: "<?php echo hesk_slashJS($hesklang['image_alt_text']); ?>"
  916. }
  917. };
  918. </script>
  919. <div class="col-md-9">
  920. <?php
  921. require(HESK_PATH . 'inc/recaptcha/recaptchalib.php');
  922. echo recaptcha_get_html($hesk_settings['recaptcha_public_key'], null, true);
  923. ?>
  924. </div>
  925. <?php
  926. }
  927. // Use reCaptcha API v2?
  928. elseif ($hesk_settings['recaptcha_use'] == 2)
  929. {
  930. ?>
  931. <div class="col-md-9">
  932. <div class="g-recaptcha"
  933. data-sitekey="<?php echo $hesk_settings['recaptcha_public_key']; ?>">
  934. </div>
  935. </div>
  936. <?php
  937. }
  938. // At least use some basic PHP generated image (better than nothing)
  939. else {
  940. $cls = in_array('mysecnum', $_SESSION['iserror']) ? ' class="isError" ' : '';
  941. echo '<div align="left" class="col-sm-9">';
  942. 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" /> ' .
  943. '<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>' .
  944. '<br />&nbsp;<br /><input type="text" name="mysecnum" size="20" maxlength="5" ' . $cls . ' /></div>';
  945. }
  946. echo '</div>';
  947. }
  948. ?>
  949. <?php
  950. }
  951. if ($modsForHesk_settings['request_location']):
  952. ?>
  953. <div class="form-group">
  954. <label for="location"
  955. class="col-md-3 control-label"><?php echo $hesklang['location_colon']; ?></label>
  956. <div class="col-sm-9">
  957. <p id="console"><?php echo $hesklang['requesting_location_ellipsis']; ?></p>
  958. <div id="map" style="height: 300px; display:none">
  959. </div>
  960. </div>
  961. </div>
  962. <!-- Submit -->
  963. <?php
  964. endif;
  965. if ($hesk_settings['submit_notice']) {
  966. ?>
  967. <div class="row">
  968. <div class="col-md-12">
  969. <div class="alert alert-info">
  970. <b><?php echo $hesklang['before_submit']; ?></b>
  971. <ul>
  972. <li><?php echo $hesklang['all_info_in']; ?>.</li>
  973. <li><?php echo $hesklang['all_error_free']; ?>.</li>
  974. </ul>
  975. <b><?php echo $hesklang['we_have']; ?>:</b>
  976. <ul>
  977. <li><?php echo hesk_htmlspecialchars(hesk_getClientIP()) . ' ' . $hesklang['recorded_ip']; ?></li>
  978. <li><?php echo $hesklang['recorded_time']; ?></li>
  979. </ul>
  980. </div>
  981. </div>
  982. </div>
  983. <div class="row">
  984. <div class="col-md-9 col-md-offset-3">
  985. <input type="hidden" id="latitude" name="latitude" value="E-0">
  986. <input type="hidden" id="longitude" name="longitude" value="E-0">
  987. <input type="hidden" name="token" value="<?php hesk_token_echo(); ?>">
  988. <input type="hidden" id="screen-resolution-height" name="screen_resolution_height">
  989. <input type="hidden" id="screen-resolution-width" name="screen_resolution_width">
  990. <input type="submit" value="<?php echo $hesklang['sub_ticket']; ?>"
  991. class="btn btn-default">
  992. </div>
  993. </div>
  994. <script>
  995. $('#screen-resolution-height').prop('value', screen.height);
  996. $('#screen-resolution-width').prop('value', screen.width);
  997. </script>
  998. <?php
  999. } // End IF submit_notice
  1000. else {
  1001. ?>
  1002. <div class=" row">
  1003. <div class="col-md-9 col-md-offset-3">
  1004. <input type="hidden" id="latitude" name="latitude" value="E-0">
  1005. <input type="hidden" id="longitude" name="longitude" value="E-0">
  1006. <input type="hidden" id="screen-resolution-height" name="screen_resolution_height">
  1007. <input type="hidden" id="screen-resolution-width" name="screen_resolution_width">
  1008. <input type="hidden" name="token" value="<?php hesk_token_echo(); ?>">
  1009. <input class="btn btn-default" type="submit"
  1010. value="<?php echo $hesklang['sub_ticket']; ?>">
  1011. <script>
  1012. $('#screen-resolution-height').prop('value', screen.height);
  1013. $('#screen-resolution-width').prop('value', screen.width);
  1014. </script>
  1015. </div>
  1016. </div>
  1017. <?php
  1018. } // End ELSE submit_notice
  1019. // Print custom hidden fields
  1020. echo $hidden_cf_buffer;
  1021. ?>
  1022. <input type="hidden" name="category" value="<?php echo $category; ?>">
  1023. <!-- Do not delete or modify the code below, it is used to detect simple SPAM bots -->
  1024. <input type="hidden" name="hx" value="3"/><input type="hidden" name="hy" value=""/>
  1025. <!-- >
  1026. <input type="text" name="phone" value="3" />
  1027. < -->
  1028. </form>
  1029. <script>
  1030. buildValidatorForTicketSubmission("form1",
  1031. "<?php echo addslashes($hesklang['select_at_least_one_value']); ?>");
  1032. </script>
  1033. </div>
  1034. </form>
  1035. <?php if ($columnWidth == 'col-md-10 col-md-offset-1'): ?>
  1036. <div class="col-md-1">&nbsp;</div></div>
  1037. <?php endif; ?>
  1038. <!-- END FORM -->
  1039. <?php
  1040. // Request for the users location if enabled
  1041. if ($modsForHesk_settings['request_location']) {
  1042. echo '
  1043. <script>
  1044. requestUserLocation("' . $hesklang['your_current_location'] . '", "' . $hesklang['unable_to_determine_location'] . '");
  1045. </script>
  1046. ';
  1047. }
  1048. hesk_cleanSessionVars('iserror');
  1049. hesk_cleanSessionVars('isnotice');
  1050. } // End print_add_ticket()
  1051. function print_start()
  1052. {
  1053. global $hesk_settings, $hesklang;
  1054. // Connect to database
  1055. hesk_load_database_functions();
  1056. hesk_dbConnect();
  1057. define('PAGE_TITLE', 'CUSTOMER_HOME');
  1058. // This will be used to determine how much space to print after KB
  1059. $hesk_settings['kb_spacing'] = 4;
  1060. // Include KB functionality only if we have any public articles
  1061. has_public_kb();
  1062. if ($hesk_settings['kb_enable'])
  1063. {
  1064. require(HESK_PATH . 'inc/knowledgebase_functions.inc.php');
  1065. }
  1066. else
  1067. {
  1068. $hesk_settings['kb_spacing'] += 2;
  1069. }
  1070. /* Print header */
  1071. require_once(HESK_PATH . 'inc/header.inc.php');
  1072. ?>
  1073. <ol class="breadcrumb">
  1074. <li><a href="<?php echo $hesk_settings['site_url']; ?>"><?php echo $hesk_settings['site_title']; ?></a></li>
  1075. <li class="active"><?php echo $hesk_settings['hesk_title']; ?></li>
  1076. </ol>
  1077. <?php
  1078. // Service messages
  1079. $res = hesk_dbQuery('SELECT `title`, `message`, `style`, `icon` FROM `'.hesk_dbEscape($hesk_settings['db_pfix'])."service_messages` WHERE `type`='0' ORDER BY `order` ASC");
  1080. if (hesk_dbNumRows($res) > 0)
  1081. {
  1082. ?>
  1083. <div class="row">
  1084. <div class="col-md-12">
  1085. <?php
  1086. while ($sm=hesk_dbFetchAssoc($res))
  1087. {
  1088. hesk_service_message($sm);
  1089. }
  1090. ?>
  1091. </div>
  1092. </div>
  1093. <?php } ?>
  1094. <div class="row">
  1095. <div class="col-md-4">
  1096. <div class="panel panel-default">
  1097. <div class="panel-heading"><?php echo $hesklang['view_ticket']; ?></div>
  1098. <div class="panel-body">
  1099. <form data-toggle="validator" role="form" class="viewTicketSidebar" action="ticket.php" method="get" name="form2">
  1100. <div class="form-group">
  1101. <br/>
  1102. <label for="ticketID"><?php echo $hesklang['ticket_trackID']; ?>:</label>
  1103. <input type="text" class="form-control" name="track" id="ticketID" maxlength="20" size="35" value=""
  1104. data-error="<?php echo htmlspecialchars($hesklang['enter_id']); ?>"
  1105. placeholder="<?php echo htmlspecialchars($hesklang['ticket_trackID']); ?>" required>
  1106. <div class="help-block with-errors"></div>
  1107. </div>
  1108. <?php
  1109. $tmp = '';
  1110. if ($hesk_settings['email_view_ticket'])
  1111. {
  1112. $tmp = 'document.form1.email.value=document.form2.e.value;';
  1113. ?>
  1114. <div class="form-group">
  1115. <label for="emailAddress"><?php echo $hesklang['email']; ?>:</label>
  1116. <?php
  1117. $my_email = '';
  1118. $do_remember = '';
  1119. if (isset($_COOKIE['hesk_myemail']))
  1120. {
  1121. $my_email = $_COOKIE['hesk_myemail'];
  1122. $do_remember = 'checked';
  1123. }
  1124. ?>
  1125. <input type="text" class="form-control" name="e" id="emailAddress" size="35" value="<?php echo $my_email; ?>"
  1126. data-error="<?php echo htmlspecialchars($hesklang['enter_valid_email']); ?>"
  1127. placeholder="<?php echo htmlspecialchars($hesklang['email']); ?>" required>
  1128. <div class="help-block with-errors"></div>
  1129. </div>
  1130. <div class="checkbox">
  1131. <label for="r">
  1132. <input type="checkbox" name="r" value="Y" <?php echo $do_remember; ?>> <?php echo $hesklang['rem_email']; ?>
  1133. </label>
  1134. </div>
  1135. <?php
  1136. }
  1137. ?>
  1138. <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">
  1139. </form>
  1140. </div>
  1141. </div>
  1142. </div>
  1143. <div class="col-md-8">
  1144. <?php
  1145. // Print small search box
  1146. if ($hesk_settings['kb_enable'])
  1147. {
  1148. hesk_kbSearchSmall();
  1149. hesk_kbSearchLarge();
  1150. }
  1151. else
  1152. {
  1153. echo '&nbsp;';
  1154. }
  1155. ?>
  1156. <div class="row default-row-margins">
  1157. <div class="col-sm-6 col-xs-12">
  1158. <a href="index.php?a=add" class="button-link">
  1159. <div class="panel panel-default">
  1160. <div class="panel-body">
  1161. <div class="row">
  1162. <div class="col-xs-1">
  1163. <img src="img/newTicket.png" alt="<?php echo $hesklang['sub_support']; ?>">
  1164. </div>
  1165. <div class="col-xs-11">
  1166. <b><?php echo $hesklang['sub_support']; ?></b><br>
  1167. <?php echo $hesklang['open_ticket']; ?>
  1168. </div>
  1169. </div>
  1170. </div>
  1171. </div>
  1172. </a>
  1173. </div>
  1174. <div class="col-sm-6 col-xs-12">
  1175. <a href="ticket.php" class="button-link">
  1176. <div class="panel panel-default">
  1177. <div class="panel-body">
  1178. <div class="row">
  1179. <div class="col-xs-1">
  1180. <img src="img/viewTicket.png" alt="<?php echo $hesklang['view_existing']; ?>">
  1181. </div>
  1182. <div class="col-xs-11">
  1183. <b><?php echo $hesklang['view_existing']; ?></b><br>
  1184. <?php echo $hesklang['vet']; ?>
  1185. </div>
  1186. </div>
  1187. </div>
  1188. </div>
  1189. </a>
  1190. </div>
  1191. </div>
  1192. <div class="row default-row-margins">
  1193. <?php
  1194. if ($hesk_settings['kb_enable'])
  1195. {
  1196. ?>
  1197. <div class="col-sm-6 col-xs-12">
  1198. <a href="knowledgebase.php" class="button-link">
  1199. <div class="panel panel-default">
  1200. <div class="panel-body">
  1201. <div class="row">
  1202. <div class="col-xs-1">
  1203. <img src="img/knowledgebase.png" alt="<?php echo $hesklang['kb_text']; ?>">
  1204. </div>
  1205. <div class="col-xs-11">
  1206. <b><?php echo $hesklang['kb_text']; ?></b><br>
  1207. <?php echo $hesklang['viewkb']; ?>
  1208. </div>
  1209. </div>
  1210. </div>
  1211. </div>
  1212. </a>
  1213. </div>
  1214. <?php } if ($modsForHesk_settings['enable_calendar'] == 1): ?>
  1215. <div class="col-sm-6 col-xs-12">
  1216. <a href="calendar.php" class="button-link">
  1217. <div class="panel panel-default">
  1218. <div class="panel-body">
  1219. <div class="row">
  1220. <div class="col-xs-1">
  1221. <i class="fa fa-calendar black" style="font-size: 32px"
  1222. title="<?php echo $hesklang['calendar_title_case']; ?>"></i>
  1223. </div>
  1224. <div class="col-xs-11">
  1225. <b><?php echo $hesklang['calendar_title_case']; ?></b><br>
  1226. <?php echo $hesklang['calendar_index']; ?>
  1227. </div>
  1228. </div>
  1229. </div>
  1230. </div>
  1231. </a>
  1232. </div>
  1233. <?php endif;
  1234. $customNavRs = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "custom_nav_element` AS `t1`
  1235. INNER JOIN `" . hesk_dbEscape($hesk_settings['db_pfix']) . "custom_nav_element_to_text` AS `t2`
  1236. ON `t1`.`id` = `t2`.`nav_element_id`
  1237. AND `t2`.`language` = '" . hesk_dbEscape($hesk_settings['language']) . "'
  1238. WHERE `t1`.`place` = 1");
  1239. while ($row = hesk_dbFetchAssoc($customNavRs)):
  1240. ?>
  1241. <div class="col-sm-6 col-xs-12">
  1242. <a href="<?php echo $row['url']; ?>" class="button-link">
  1243. <div class="panel panel-default">
  1244. <div class="panel-body">
  1245. <div class="row">
  1246. <div class="col-xs-1">
  1247. <?php if ($row['image_url'] !== null): ?>
  1248. <img src="<?php echo $row['image_url']; ?>" alt="<?php echo $row['text']; ?>">
  1249. <?php else: ?>
  1250. <i class="<?php echo $row['font_icon']; ?> black" style="font-size: 32px"></i>
  1251. <?php endif; ?>
  1252. </div>
  1253. <div class="col-xs-11">
  1254. <b><?php echo $row['text']; ?></b><br>
  1255. <?php echo $row['subtext']; ?>
  1256. </div>
  1257. </div>
  1258. </div>
  1259. </div>
  1260. </a>
  1261. </div>
  1262. <?php endwhile; ?>
  1263. </div>
  1264. <?php
  1265. if ($hesk_settings['kb_enable'])
  1266. {
  1267. hesk_kbTopArticles($hesk_settings['kb_index_popart']);
  1268. hesk_kbLatestArticles($hesk_settings['kb_index_latest']);
  1269. }
  1270. ?>
  1271. </div>
  1272. </div>
  1273. <div class="blankSpace"></div>
  1274. <div class="footerWithBorder"></div>
  1275. <div class="blankSpace"></div>
  1276. </div>
  1277. <?php
  1278. // Show a link to admin panel?
  1279. if ($hesk_settings['alink'])
  1280. {
  1281. ?>
  1282. <p class="text-center"><a href="<?php echo $hesk_settings['admin_dir']; ?>/" ><?php echo $hesklang['ap']; ?></a></p>
  1283. <?php
  1284. }
  1285. } // End print_start()
  1286. function forgot_tid()
  1287. {
  1288. global $hesk_settings, $hesklang, $modsForHesk_settings;
  1289. require(HESK_PATH . 'inc/email_functions.inc.php');
  1290. /* Get ticket(s) from database */
  1291. hesk_dbConnect();
  1292. $email = hesk_emailCleanup(hesk_validateEmail(hesk_POST('email'), 'ERR', 0)) or hesk_process_messages($hesklang['enter_valid_email'], 'ticket.php?remind=1');
  1293. if (isset($_POST['open_only'])) {
  1294. $hesk_settings['open_only'] = $_POST['open_only'] == 1 ? 1 : 0;
  1295. }
  1296. /* Prepare ticket statuses */
  1297. $myStatusSQL = hesk_dbQuery("SELECT `ID`, `Key` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses`");
  1298. $my_status = array();
  1299. while ($myStatusRow = hesk_dbFetchAssoc($myStatusSQL)) {
  1300. $my_status[$myStatusRow['ID']] = $hesklang[$myStatusRow['Key']];
  1301. }
  1302. // Get tickets from the database
  1303. $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 ');
  1304. $num = hesk_dbNumRows($res);
  1305. if ($num < 1) {
  1306. if ($hesk_settings['open_only']) {
  1307. hesk_process_messages($hesklang['noopen'],'ticket.php?remind=1&e='.rawurlencode($email));
  1308. } else {
  1309. hesk_process_messages($hesklang['tid_not_found'],'ticket.php?remind=1&e='.rawurlencode($email));
  1310. }
  1311. }
  1312. $tid_list = '';
  1313. $html_tid_list = '<ul>';
  1314. $name = '';
  1315. $email_param = $hesk_settings['email_view_ticket'] ? '&e=' . rawurlencode($email) : '';
  1316. while ($my_ticket = hesk_dbFetchAssoc($res)) {
  1317. $name = $name ? $name : hesk_msgToPlain($my_ticket['name'], 1, 0);
  1318. $tid_list .= "
  1319. $hesklang[trackID]: " . $my_ticket['trackid'] . "
  1320. $hesklang[subject]: " . hesk_msgToPlain($my_ticket['subject'], 1, 0) . "
  1321. $hesklang[status]: " . $my_status[$my_ticket['status']] . "
  1322. $hesk_settings[hesk_url]/ticket.php?track={$my_ticket['trackid']}{$email_param}
  1323. ";
  1324. $html_tid_list .= "<li>
  1325. $hesklang[trackID]: " . $my_ticket['trackid'] . " <br>
  1326. $hesklang[subject]: " . hesk_msgToPlain($my_ticket['subject'], 1, 0) . " <br>
  1327. $hesklang[status]: " . $my_status[$my_ticket['status']] . " <br>
  1328. $hesk_settings[hesk_url]/ticket.php?track={$my_ticket['trackid']}{$email_param}
  1329. </li>";
  1330. }
  1331. $html_tid_list .= '</ul>';
  1332. /* Get e-mail message for customer */
  1333. $msg = hesk_getEmailMessage('forgot_ticket_id', '', $modsForHesk_settings, 0, 0, 1);
  1334. $msg = processEmail($msg, $name, $num, $tid_list);
  1335. // Get HTML message for customer
  1336. $htmlMsg = hesk_getHtmlMessage('forgot_ticket_id', '', $modsForHesk_settings, 0, 0, 1);
  1337. $htmlMsg = processEmail($htmlMsg, $name, $num, $html_tid_list);
  1338. $subject = hesk_getEmailSubject('forgot_ticket_id');
  1339. /* Send e-mail */
  1340. hesk_mail($email, $subject, $msg, $htmlMsg, $modsForHesk_settings);
  1341. /* Show success message */
  1342. $tmp = '<b>' . $hesklang['tid_sent'] . '!</b>';
  1343. $tmp .= '<br />&nbsp;<br />' . $hesklang['tid_sent2'] . '.';
  1344. $tmp .= '<br />&nbsp;<br />' . $hesklang['check_spambox'];
  1345. hesk_process_messages($tmp, 'ticket.php?e=' . $email, 'SUCCESS');
  1346. exit();
  1347. /* Print header */
  1348. $hesk_settings['tmp_title'] = $hesk_settings['hesk_title'] . ' - ' . $hesklang['tid_sent'];
  1349. require_once(HESK_PATH . 'inc/header.inc.php');
  1350. ?>
  1351. <ol class="breadcrumb">
  1352. <li><a href="<?php echo $hesk_settings['site_url']; ?>"><?php echo $hesk_settings['site_title']; ?></a></li>
  1353. <li><a href="<?php echo $hesk_settings['hesk_url']; ?>"><?php echo $hesk_settings['hesk_title']; ?></a></li>
  1354. <li class="active"><?php echo $hesklang['tid_sent']; ?></li>
  1355. </ol>
  1356. <tr>
  1357. <td>
  1358. <?php
  1359. } // End forgot_tid()
  1360. function processEmail($msg, $name, $num, $tid_list) {
  1361. global $hesk_settings;
  1362. $msg = str_replace('%%NAME%%', $name, $msg);
  1363. $msg = str_replace('%%NUM%%', $num, $msg);
  1364. $msg = str_replace('%%LIST_TICKETS%%', $tid_list, $msg);
  1365. $msg = str_replace('%%SITE_TITLE%%', hesk_msgToPlain($hesk_settings['site_title'], 1), $msg);
  1366. $msg = str_replace('%%SITE_URL%%', $hesk_settings['site_url'], $msg);
  1367. return $msg;
  1368. }
  1369. function has_public_kb($use_cache=1) {
  1370. global $hesk_settings;
  1371. // Return if KB is disabled
  1372. if ( ! $hesk_settings['kb_enable']) {
  1373. return 0;
  1374. }
  1375. // Do we have a cached version available
  1376. $cache_dir = $hesk_settings['cache_dir'].'/';
  1377. $cache_file = $cache_dir . 'kb.cache.php';
  1378. if ($use_cache && file_exists($cache_file)) {
  1379. require($cache_file);
  1380. return $hesk_settings['kb_enable'];
  1381. }
  1382. // Make sure we have database connection
  1383. hesk_load_database_functions();
  1384. hesk_dbConnect();
  1385. // Do we have any public articles at all?
  1386. $res = hesk_dbQuery("SELECT `t1`.`id` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` AS `t1`
  1387. LEFT JOIN `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` AS `t2` ON `t1`.`catid` = `t2`.`id`
  1388. WHERE `t1`.`type`='0' AND `t2`.`type`='0' LIMIT 1");
  1389. // If no public articles, disable the KB functionality
  1390. if (hesk_dbNumRows($res) < 1) {
  1391. $hesk_settings['kb_enable'] = 0;
  1392. }
  1393. // Try to cache results
  1394. if ($use_cache && (is_dir($cache_dir) || (@mkdir($cache_dir, 0777) && is_writable($cache_dir)))) {
  1395. // Is there an index.htm file?
  1396. if ( ! file_exists($cache_dir.'index.htm')) {
  1397. @file_put_contents($cache_dir.'index.htm', '');
  1398. }
  1399. // Write data
  1400. @file_put_contents($cache_file, '<?php if (!defined(\'IN_SCRIPT\')) {die();} $hesk_settings[\'kb_enable\']=' . $hesk_settings['kb_enable'] . ';' );
  1401. }
  1402. return $hesk_settings['kb_enable'];
  1403. } // End has_public_kb()