PageRenderTime 35ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/support/options.php

https://gitlab.com/alexprowars/bitrix
PHP | 490 lines | 440 code | 46 blank | 4 comment | 32 complexity | c21509549575074c3b6212b101308f88 MD5 | raw file
  1. <?
  2. // Clear Category table
  3. function ClearCategoryTable()
  4. {
  5. global $DB;
  6. $err_mess = "<br>Module: support<br>File: options<br>Function: ClearCategoryTable<br>Line: ";
  7. $DB->Query("DELETE FROM b_ticket_sla_2_category", false, $err_mess.__LINE__);
  8. $arrSLA = array();
  9. $strSql = "
  10. SELECT
  11. SLA.ID
  12. FROM
  13. b_ticket_sla SLA
  14. ";
  15. $z = $DB->Query( $strSql, false, $err_mess . __LINE__ );
  16. while( $zr = $z->Fetch() )
  17. {
  18. $arFields_i = array(
  19. "SLA_ID" => intval($zr["ID"]),
  20. "CATEGORY_ID" => 0,
  21. );
  22. $ID = $DB->Insert( "b_ticket_sla_2_category", $arFields_i, $err_mess . __LINE__ );
  23. }
  24. }
  25. $module_id = "support";
  26. IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/".$module_id."/include.php");
  27. IncludeModuleLangFile(__FILE__);
  28. $SUP_RIGHT = $APPLICATION->GetGroupRight($module_id);
  29. if ($SUP_RIGHT>="R") :
  30. if ($REQUEST_METHOD=="GET" && $SUP_RIGHT>="W" && $RestoreDefaults <> '' && check_bitrix_sessid())
  31. {
  32. COption::RemoveOption("support");
  33. $z = CGroup::GetList("id", "asc", array("ACTIVE" => "Y", "ADMIN" => "N"));
  34. while($zr = $z->Fetch())
  35. $APPLICATION->DelGroupRight($module_id, array($zr["ID"]));
  36. }
  37. $message = false;
  38. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/".$module_id."/include.php");
  39. if($REQUEST_METHOD=="POST" && $Update <> '' && $SUP_RIGHT>="W" && check_bitrix_sessid())
  40. {
  41. $SUPPORT_DIR = str_replace("\\", "/", $SUPPORT_DIR);
  42. $SUPPORT_DIR = str_replace("//", "/", $SUPPORT_DIR);
  43. COption::SetOptionString($module_id, "SUPPORT_DIR", $SUPPORT_DIR);
  44. COption::SetOptionString($module_id, "SUPPORT_EDIT", $SUPPORT_EDIT);
  45. COption::SetOptionString($module_id, "SUPPORT_MAX_FILESIZE", intval($SUPPORT_MAX_FILESIZE));
  46. COption::SetOptionString($module_id, "ONLINE_INTERVAL", intval($ONLINE_INTERVAL));
  47. COption::SetOptionString($module_id, "DEFAULT_VALUE_HIDDEN", $DEFAULT_VALUE_HIDDEN);
  48. COption::SetOptionString($module_id, "DEFAULT_RESPONSIBLE_ID", $DEFAULT_RESPONSIBLE_ID);
  49. COption::SetOptionString($module_id, "DEFAULT_AUTO_CLOSE_DAYS", $DEFAULT_AUTO_CLOSE_DAYS);
  50. COption::SetOptionString($module_id, "VIEW_TICKET_DEFAULT_MODE", $VIEW_TICKET_DEFAULT_MODE);
  51. COption::SetOptionString($module_id, "ONLINE_AUTO_REFRESH", $ONLINE_AUTO_REFRESH);
  52. COption::SetOptionString($module_id, "MESSAGES_PER_PAGE", $MESSAGES_PER_PAGE);
  53. COption::SetOptionString($module_id, "SHOW_COMMENTS_IN_TICKET_LIST", $SHOW_COMMENTS_IN_TICKET_LIST ?: 'N');
  54. COption::SetOptionString($module_id, "SOURCE_MAIL", $SOURCE_MAIL);
  55. COption::SetOptionString($module_id, "REINDEX_MSG_S", $REINDEX_MSG_S);
  56. if (preg_match_all('|#|'.BX_UTF_PCRE_MODIFIER, $SUPERTICKET_COUPON_FORMAT, $_tmp) && is_array($_tmp[0]) && count($_tmp[0]) >= 6)
  57. {
  58. COption::SetOptionString($module_id, "SUPERTICKET_COUPON_FORMAT", $SUPERTICKET_COUPON_FORMAT);
  59. }
  60. else
  61. {
  62. $message = new CAdminMessage(GetMessage('SUP_SUPERTICKET_ERROR'));
  63. }
  64. COption::SetOptionString($module_id, "SUPERTICKET_DEFAULT_SLA", $SUPERTICKET_DEFAULT_SLA);
  65. $SUPPORT_OLD_FUNCTIONALITY_OLD = COption::GetOptionString($module_id, "SUPPORT_OLD_FUNCTIONALITY");
  66. $SUPPORT_OLD_FUNCTIONALITY = ( $SUPPORT_OLD_FUNCTIONALITY == "Y" ? "Y" : "N" );
  67. if( $SUPPORT_OLD_FUNCTIONALITY_OLD <> $SUPPORT_OLD_FUNCTIONALITY ) ClearCategoryTable();
  68. COption::SetOptionString($module_id, "SUPPORT_OLD_FUNCTIONALITY", $SUPPORT_OLD_FUNCTIONALITY);
  69. COption::SetOptionString($module_id, "SUPPORT_DEFAULT_SLA_ID", intval($SUPPORT_DEFAULT_SLA_ID) );
  70. COption::SetOptionString($module_id, "SUPPORT_CACHE_DAYS_FORWARD", intval($SUPPORT_CACHE_DAYS_FORWARD) );
  71. COption::SetOptionString($module_id, "SUPPORT_CACHE_DAYS_BACKWARD", intval($SUPPORT_CACHE_DAYS_BACKWARD) );
  72. }
  73. $SUPPORT_DIR = COption::GetOptionString($module_id, "SUPPORT_DIR");
  74. $SUPPORT_EDIT = COption::GetOptionString($module_id, "SUPPORT_EDIT");
  75. $SUPPORT_MAX_FILESIZE = COption::GetOptionString($module_id, "SUPPORT_MAX_FILESIZE");
  76. $ONLINE_INTERVAL = COption::GetOptionString($module_id, "ONLINE_INTERVAL");
  77. $DEFAULT_VALUE_HIDDEN = COption::GetOptionString($module_id, "DEFAULT_VALUE_HIDDEN");
  78. $DEFAULT_RESPONSIBLE_ID = COption::GetOptionString($module_id, "DEFAULT_RESPONSIBLE_ID");
  79. $DEFAULT_AUTO_CLOSE_DAYS = COption::GetOptionString($module_id, "DEFAULT_AUTO_CLOSE_DAYS");
  80. $VIEW_TICKET_DEFAULT_MODE = COption::GetOptionString($module_id, "VIEW_TICKET_DEFAULT_MODE");
  81. $ONLINE_AUTO_REFRESH = COption::GetOptionString($module_id, "ONLINE_AUTO_REFRESH");
  82. $MESSAGES_PER_PAGE = COption::GetOptionString($module_id, "MESSAGES_PER_PAGE");
  83. $SHOW_COMMENTS_IN_TICKET_LIST = COption::GetOptionString($module_id, "SHOW_COMMENTS_IN_TICKET_LIST");
  84. $SOURCE_MAIL = COption::GetOptionString($module_id, "SOURCE_MAIL");
  85. $SUPERTICKET_COUPON_FORMAT = COption::GetOptionString($module_id, "SUPERTICKET_COUPON_FORMAT");
  86. $SUPERTICKET_DEFAULT_SLA = COption::GetOptionString($module_id, "SUPERTICKET_DEFAULT_SLA");
  87. $SUPPORT_OLD_FUNCTIONALITY = COption::GetOptionString($module_id, "SUPPORT_OLD_FUNCTIONALITY");
  88. $SUPPORT_DEFAULT_SLA_ID = COption::GetOptionString($module_id, "SUPPORT_DEFAULT_SLA_ID");
  89. $SUPPORT_CACHE_DAYS_FORWARD = COption::GetOptionString($module_id, "SUPPORT_CACHE_DAYS_FORWARD");
  90. $SUPPORT_CACHE_DAYS_BACKWARD = COption::GetOptionString($module_id, "SUPPORT_CACHE_DAYS_BACKWARD");
  91. $REINDEX_MSG_S = COption::GetOptionString($module_id, "REINDEX_MSG_S",8);
  92. if ($message)
  93. echo $message->Show();
  94. $aTabs = array(
  95. array("DIV" => "edit1", "TAB" => GetMessage("MAIN_TAB_SET"), "ICON" => "support_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_SET")),
  96. array("DIV" => "edit2", "TAB" => GetMessage("MAIN_TAB_RIGHTS"), "ICON" => "support_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_RIGHTS")),
  97. );
  98. $tabControl = new CAdminTabControl("tabControl", $aTabs);
  99. ?>
  100. <?
  101. $tabControl->Begin();
  102. ?><form method="POST" action="<?echo $APPLICATION->GetCurPage()?>?mid=<?=htmlspecialcharsbx($mid)?>&lang=<?=LANGUAGE_ID?>">
  103. <?=bitrix_sessid_post()?>
  104. <?
  105. $tabControl->BeginNextTab();
  106. ?>
  107. <tr>
  108. <td valign="top" width="50%"><?=GetMessage("SUP_URL_PUBLIC")?></td>
  109. <td valign="top" width="50%"><input type="text" size="40" value="<?echo htmlspecialcharsbx($SUPPORT_DIR)?>" name="SUPPORT_DIR"></td>
  110. </tr>
  111. <tr>
  112. <td valign="top" width="50%"><?=GetMessage("SUP_URL_PUBLIC_EDIT")?></td>
  113. <td valign="top" width="50%"><input type="text" size="40" value="<?echo htmlspecialcharsbx($SUPPORT_EDIT)?>" name="SUPPORT_EDIT"></td>
  114. </tr>
  115. <tr>
  116. <td valign="top"><?=GetMessage("SUP_MAX_FILESIZE")?></td>
  117. <td valign="top"><input type="text" size="5" value="<?echo htmlspecialcharsbx($SUPPORT_MAX_FILESIZE)?>" name="SUPPORT_MAX_FILESIZE"></td>
  118. </tr>
  119. <tr>
  120. <td valign="top"><label><?=GetMessage("SUP_DEFAULT_VALUE_HIDDEN")?></label></td>
  121. <td valign="top"><?echo InputType("checkbox", "DEFAULT_VALUE_HIDDEN", "Y", $DEFAULT_VALUE_HIDDEN, false, "", 'id="DEFAULT_VALUE_HIDDEN"')?></td>
  122. </tr>
  123. <tr>
  124. <td valign="top"><?=GetMessage("SUP_DEFAULT_RESPONSIBLE")?></td>
  125. <td valign="top"><?
  126. echo SelectBox("DEFAULT_RESPONSIBLE_ID", CTicket::GetSupportTeamList(), " ", $DEFAULT_RESPONSIBLE_ID);
  127. ?></td>
  128. </tr>
  129. <tr>
  130. <td valign="top"><?=GetMessage("SUP_DEFAULT_AUTO_CLOSE_DAYS")?></td>
  131. <td valign="top"><?
  132. $ref_id = array("-1", "0");
  133. $ref = array(GetMessage("SUP_NOT_CHANGE"), GetMessage("SUP_SET_NULL"));
  134. for ($i=1;$i<=90;$i++)
  135. {
  136. $ref[] = $i." ".GetMessage("SUP_DAY");
  137. $ref_id[] = $i;
  138. }
  139. $arr = Array("reference" => $ref, "reference_id" => $ref_id);
  140. echo SelectBoxFromArray("DEFAULT_AUTO_CLOSE_DAYS", $arr, $DEFAULT_AUTO_CLOSE_DAYS, "");
  141. ?></td>
  142. </tr>
  143. <tr>
  144. <td valign="top"><?=GetMessage("SUP_DEFAULT_MODE")?></td>
  145. <td valign="top"><?
  146. $ref_id = array("", "view", "answer");
  147. $ref = array(GetMessage("SUP_NO_MODE"), GetMessage("SUP_VIEW_MODE"), GetMessage("SUP_ANSWER_MODE"));
  148. $arr = Array("reference" => $ref, "reference_id" => $ref_id);
  149. echo SelectBoxFromArray("VIEW_TICKET_DEFAULT_MODE", $arr, $VIEW_TICKET_DEFAULT_MODE, "");
  150. ?></td>
  151. </tr>
  152. <tr>
  153. <td valign="top"><?=GetMessage("SUP_ONLINE_INTERVAL")?></td>
  154. <td valign="top"><?
  155. $ref_id = array(
  156. "60",
  157. "120",
  158. "180",
  159. "240",
  160. "300",
  161. "360",
  162. "420",
  163. "480",
  164. "540",
  165. "600",
  166. "900",
  167. );
  168. $ref = array(
  169. "1 ".GetMessage("SUP_MIN"),
  170. "2 ".GetMessage("SUP_MIN"),
  171. "3 ".GetMessage("SUP_MIN"),
  172. "4 ".GetMessage("SUP_MIN"),
  173. "5 ".GetMessage("SUP_MIN"),
  174. "6 ".GetMessage("SUP_MIN"),
  175. "7 ".GetMessage("SUP_MIN"),
  176. "8 ".GetMessage("SUP_MIN"),
  177. "9 ".GetMessage("SUP_MIN"),
  178. "10 ".GetMessage("SUP_MIN"),
  179. "15 ".GetMessage("SUP_MIN"),
  180. );
  181. $arr = Array("reference" => $ref, "reference_id" => $ref_id);
  182. echo SelectBoxFromArray("ONLINE_INTERVAL", $arr, $ONLINE_INTERVAL, "");
  183. ?></td>
  184. </tr>
  185. <tr>
  186. <td valign="top"><?=GetMessage("SUP_ONLINE_AUTO_REFRESH")?></td>
  187. <td valign="top"><?
  188. $ref_id = array(
  189. "0",
  190. "10",
  191. "20",
  192. "30",
  193. "40",
  194. "50",
  195. "60",
  196. "120",
  197. "180",
  198. "240",
  199. "300",
  200. );
  201. $ref = array(
  202. GetMessage("SUP_NO_AUTO_REFRESH"),
  203. "10 ".GetMessage("SUP_SEC"),
  204. "20 ".GetMessage("SUP_SEC"),
  205. "30 ".GetMessage("SUP_SEC"),
  206. "40 ".GetMessage("SUP_SEC"),
  207. "50 ".GetMessage("SUP_SEC"),
  208. "1 ".GetMessage("SUP_MIN"),
  209. "2 ".GetMessage("SUP_MIN"),
  210. "3 ".GetMessage("SUP_MIN"),
  211. "4 ".GetMessage("SUP_MIN"),
  212. "5 ".GetMessage("SUP_MIN"),
  213. );
  214. $arr = Array("reference" => $ref, "reference_id" => $ref_id);
  215. echo SelectBoxFromArray("ONLINE_AUTO_REFRESH", $arr, $ONLINE_AUTO_REFRESH, "");
  216. ?></td>
  217. </tr>
  218. <tr>
  219. <td valign="top"><?=GetMessage("SUP_MESSAGES_PER_PAGE")?></td>
  220. <td valign="top"><input type="text" size="5" value="<?=intval($MESSAGES_PER_PAGE)?>" name="MESSAGES_PER_PAGE"></td>
  221. </tr>
  222. <tr>
  223. <td valign="top"><?=GetMessage("SUP_SHOW_COMMENTS_IN_TICKET_LIST")?></td>
  224. <td valign="top"><?echo InputType("checkbox", "SHOW_COMMENTS_IN_TICKET_LIST", "Y", $SHOW_COMMENTS_IN_TICKET_LIST, false, "", 'id="SHOW_COMMENTS_IN_TICKET_LIST"')?></td>
  225. </tr>
  226. <tr>
  227. <td valign="top"><?=GetMessage('SUP_SUPERTICKET_COUPON_FORMAT')?></td>
  228. <td valign="top"><input type="text" size="30" value="<?echo htmlspecialcharsbx($SUPERTICKET_COUPON_FORMAT)?>" name="SUPERTICKET_COUPON_FORMAT"></td>
  229. </tr>
  230. <?
  231. $arr = Array("reference" => array(), "reference_id" => array());
  232. $a = array('NAME' => 'ASC');
  233. $rs = CTicketSLA::GetList($a, array(), $__is_f);
  234. while ($arSla = $rs->GetNext())
  235. {
  236. $arr['reference'][] = htmlspecialcharsback($arSla['NAME']) . ' ['.$arSla['ID'].']';
  237. $arr['reference_id'][] = $arSla['ID'];
  238. }
  239. $arr2['reference_id'][] = "Y";
  240. $arr2['reference'][] =GetMessage('SUP_OLD_FUNCTIONALITY_Y');
  241. $arr2['reference_id'][] = "N";
  242. $arr2['reference'][] =GetMessage('SUP_OLD_FUNCTIONALITY_N');
  243. ?>
  244. <tr>
  245. <td valign="top"><?=GetMessage('SUP_SUPERTICKET_DEFAULT_SLA')?></td>
  246. <td valign="top"><?=SelectBoxFromArray("SUPERTICKET_DEFAULT_SLA", $arr, $SUPERTICKET_DEFAULT_SLA , "")?></td>
  247. </tr>
  248. <tr>
  249. <td valign="top"><?=GetMessage('SUP_DEFAULT_SLA_ID')?></td>
  250. <td valign="top"><?=SelectBoxFromArray("SUPPORT_DEFAULT_SLA_ID", $arr, $SUPPORT_DEFAULT_SLA_ID , "")?></td>
  251. </tr>
  252. <tr>
  253. <td valign="top"><?=GetMessage('SUP_OLD_FUNCTIONALITY')?></td>
  254. <td valign="top"><?=SelectBoxFromArray("SUPPORT_OLD_FUNCTIONALITY", $arr2, $SUPPORT_OLD_FUNCTIONALITY , "")?></td>
  255. </tr>
  256. <?
  257. $arr = Array("reference" => array(), "reference_id" => array());
  258. $rs = CTicketDictionary::GetDropDown("SR");
  259. $arEmail = array();
  260. while ($arDict = $rs->GetNext())
  261. {
  262. if (!isset($arEmail[$arDict['SID']]) && isset($arDict['SID']) && !empty($arDict['SID']))
  263. {
  264. $arEmail[$arDict['SID']] = htmlspecialcharsback($arDict['NAME']);
  265. $arr['reference'][] = htmlspecialcharsback($arDict['NAME']);
  266. $arr['reference_id'][] = $arDict['SID'];
  267. }
  268. }
  269. ?>
  270. <tr>
  271. <td valign="top"><?=GetMessage('SUP_SOURCE_MAIL')?></td>
  272. <td valign="top"><?=SelectBoxFromArray("SOURCE_MAIL", $arr, $SOURCE_MAIL, "")?></td>
  273. </tr>
  274. <tr>
  275. <td valign="top"><?=GetMessage('SUP_CACHE_DAYS_BACKWARD')?></td>
  276. <td valign="top"><input type="text" size="30" value="<? echo intval($SUPPORT_CACHE_DAYS_BACKWARD); ?>" name="SUPPORT_CACHE_DAYS_BACKWARD"></td>
  277. </tr>
  278. <tr>
  279. <td valign="top"><?=GetMessage('SUP_CACHE_DAYS_FORWARD')?></td>
  280. <td valign="top"><input type="text" size="30" value="<? echo intval($SUPPORT_CACHE_DAYS_FORWARD); ?>" name="SUPPORT_CACHE_DAYS_FORWARD"></td>
  281. </tr>
  282. <tr>
  283. <td valign="top">&nbsp;</td>
  284. <td valign="top">
  285. <script type="text/javascript">
  286. var reindexAlreadyRunning = false;
  287. var reindexStep = 0;
  288. function callbackFnRAOK(datum)
  289. {
  290. var obj = JSON.parse( datum );
  291. if( obj.hasOwnProperty( "ALL_OK" ) && obj.ALL_OK == "OK" )
  292. {
  293. alert( "<? echo GetMessage("SUP_RESTART_AGENTS_OK"); ?>" );
  294. return;
  295. }
  296. alert( "<? echo GetMessage("SUP_RESTART_AGENTS_NO_OK"); ?>" );
  297. }
  298. function callbackFnRANoOK(datum)
  299. {
  300. alert( "<? echo GetMessage("SUP_RESTART_AGENTS_NO_OK"); ?>" );
  301. }
  302. function restartAgentsJS()
  303. {
  304. var data = {
  305. 'MY_AJAX' : 'restartAgentsAJAX',
  306. "b_sessid": '<? echo bitrix_sessid(); ?>'
  307. };
  308. return BX.ajax({
  309. 'method': 'POST',
  310. 'dataType': 'html',
  311. 'url': "ticket_messages_reindex.php",
  312. 'data': data,
  313. 'onsuccess': callbackFnRAOK,
  314. 'onfailure': callbackFnRANoOK
  315. });
  316. }
  317. </script>
  318. <a id="RESTART_AGENTS" href="#nul" onClick="javascript: restartAgentsJS();"><? echo GetMessage('SUP_RESTART_AGENTS_BTN'); ?></a>
  319. </td>
  320. </tr>
  321. <?$tabControl->BeginNextTab();?>
  322. <?require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/admin/group_rights.php");?>
  323. <?$tabControl->Buttons();?>
  324. <script language="JavaScript">
  325. function RestoreDefaults()
  326. {
  327. if(confirm('<?echo AddSlashes(GetMessage("MAIN_HINT_RESTORE_DEFAULTS_WARNING"))?>'))
  328. window.location = "<?echo $APPLICATION->GetCurPage()?>?RestoreDefaults=Y&lang=<?echo LANG?>&mid=<?echo urlencode($mid)?>&<?echo bitrix_sessid_get()?>";
  329. }
  330. </script>
  331. <input <?if ($SUP_RIGHT<"W") echo "disabled" ?> type="submit" name="Update" value="<?=GetMessage("SUP_SAVE")?>">
  332. <input type="hidden" name="Update" value="Y">
  333. <input type="reset" name="reset" value="<?=GetMessage("SUP_RESET")?>">
  334. <input <?if ($SUP_RIGHT<"W") echo "disabled" ?> type="button" title="<?echo GetMessage("MAIN_HINT_RESTORE_DEFAULTS")?>" OnClick="RestoreDefaults();" value="<?echo GetMessage("MAIN_RESTORE_DEFAULTS")?>">
  335. <?$tabControl->End();?>
  336. </form>
  337. <?
  338. $aTabs = array(
  339. array("DIV" => "edit21", "TAB" => GetMessage("SUP_SEARCH_NDX_TAB_NAME"), "ICON" => "support_settings", "TITLE" => GetMessage("SUP_SEARCH_NDX_TAB_TITLE")),
  340. );
  341. $tabControl = new CAdminTabControl("tabControl2", $aTabs);
  342. ?>
  343. <h2><?=GetMessage('SUP_SERVICE_OPERAIONS')?></h2>
  344. <?
  345. $tabControl->Begin();
  346. ?>
  347. <?
  348. $tabControl->BeginNextTab();
  349. ?>
  350. <tr>
  351. <td valign="top">
  352. <div id="sup_search_ndx_progressbar">
  353. </div>
  354. <div id="sup_search_ndx_progressbar_nil" style="display: none;">
  355. <? CAdminMessage::ShowMessage(array(
  356. "DETAILS" => "<br>#PROGRESS_BAR#",
  357. "HTML" => true,
  358. "TYPE" => "PROGRESS",
  359. "PROGRESS_TOTAL" => 100,
  360. "PROGRESS_VALUE" => 0,
  361. )); ?>
  362. </div>
  363. <?=GetMessage('SUP_SEARCH_NDX_INTERVAL')?> <input type="text" style="width: 20px" value="10" id="sup_search_ndx_inerval"> <?=GetMessage('SUP_SEARCH_NDX_INTERVAL_SEC')?>
  364. <p>
  365. <input type="button" value="<?=GetMessage('SUP_SEARCH_NDX_START')?>" id="sup_search_ndx_start">
  366. <input type="button" value="<?=GetMessage('SUP_SEARCH_NDX_STOP')?>" style="display: none;" id="sup_search_ndx_stop">
  367. </p>
  368. <script type="text/javascript">
  369. BX.ready(function() {
  370. // start
  371. BX.bind(BX('sup_search_ndx_start'), 'click', function() {
  372. BX('sup_search_ndx_inerval').disabled = true;
  373. BX('sup_search_ndx_progressbar').innerHTML = BX('sup_search_ndx_progressbar_nil').innerHTML;
  374. BX('sup_search_ndx_stop').style.display = '';
  375. this.disabled = true;
  376. supSearchNdxGo(0);
  377. });
  378. // stop
  379. BX.bind(BX('sup_search_ndx_stop'), 'click', supSearchNdxStop);
  380. });
  381. function supSearchNdxStop()
  382. {
  383. BX('sup_search_ndx_progressbar').innerHTML = '';
  384. BX('sup_search_ndx_stop').style.display = 'none';
  385. BX('sup_search_ndx_start').disabled = false;
  386. BX('sup_search_ndx_inerval').disabled = false;
  387. }
  388. function supSearchNdxGo( firstID )
  389. {
  390. if (!BX('sup_search_ndx_start').disabled)
  391. {
  392. return;
  393. }
  394. var data = {
  395. 'b_sessid': '<? echo bitrix_sessid(); ?>',
  396. 'action' : 'reindex',
  397. 'data' : {
  398. 'interval' : BX('sup_search_ndx_inerval').value,
  399. 'firstID' : firstID
  400. }
  401. };
  402. return BX.ajax({
  403. 'method': 'POST',
  404. 'dataType': 'json',
  405. 'url': 'ticket_messages_reindex.php',
  406. 'data': data,
  407. 'onsuccess': supSearchNdxGoSuccess,
  408. 'onfailure': supSearchNdxGoFail
  409. });
  410. }
  411. function supSearchNdxGoSuccess(response)
  412. {
  413. if(!BX('sup_search_ndx_start').disabled)
  414. {
  415. // indexing was stopped
  416. return;
  417. }
  418. if (!response)
  419. {
  420. return supSearchNdxGoFail(response);
  421. }
  422. if (!response.hasOwnProperty("LAST_ID"))
  423. {
  424. return supSearchNdxGoFail(data);
  425. }
  426. if (response.LAST_ID == (-1))
  427. {
  428. alert( "<? echo GetMessageJS("SUP_REINDEX_END"); ?>" );
  429. supSearchNdxStop();
  430. return;
  431. }
  432. BX('sup_search_ndx_progressbar').innerHTML = response.BAR;
  433. supSearchNdxGo(response.LAST_ID);
  434. }
  435. function supSearchNdxGoFail(data)
  436. {
  437. alert( "<? echo GetMessageJS("SUP_REINDEX_STRANGE_ANSWER"); ?>" );
  438. supSearchNdxStop();
  439. }
  440. </script>
  441. </td>
  442. </tr>
  443. <?$tabControl->End();?>
  444. <?endif;?>