dolibarr  x.y.z
fetchKnowledgeRecord.php
Go to the documentation of this file.
1 <?php
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <https://www.gnu.org/licenses/>.
15  */
16 
22 if (!defined('NOTOKENRENEWAL')) {
23  define('NOTOKENRENEWAL', '1'); // Disables token renewal
24 }
25 if (!defined('NOREQUIREHTML')) {
26  define('NOREQUIREHTML', '1');
27 }
28 if (!defined('NOREQUIREAJAX')) {
29  define('NOREQUIREAJAX', '1');
30 }
31 if (!defined('NOREQUIRESOC')) {
32  define('NOREQUIRESOC', '1');
33 }
34 // Do not check anti CSRF attack test
35 if (!defined('NOREQUIREMENU')) {
36  define('NOREQUIREMENU', '1');
37 }
38 // If there is no need to load and show top and left menu
39 if (!defined("NOLOGIN")) {
40  define("NOLOGIN", '1');
41 }
42 if (!defined('NOIPCHECK')) {
43  define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
44 }
45 if (!defined('NOBROWSERNOTIF')) {
46  define('NOBROWSERNOTIF', '1');
47 }
48 include '../../main.inc.php';
49 
50 $action = GETPOST('action', 'aZ09');
51 $idticketgroup = GETPOST('idticketgroup', 'aZ09');
52 $idticketgroup = GETPOST('idticketgroup', 'aZ09');
53 $lang = GETPOST('lang', 'aZ09');
54 
55 /*
56  * Actions
57  */
58 
59 // None
60 
61 
62 /*
63  * View
64  */
65 
66 top_httphead('application/json');
67 
68 if ($action == "getKnowledgeRecord") {
69  $response = '';
70  $sql = "SELECT kr.rowid, kr.ref, kr.question, kr.answer,kr.url,ctc.code";
71  $sql .= " FROM ".MAIN_DB_PREFIX."knowledgemanagement_knowledgerecord as kr ";
72  $sql .= " JOIN ".MAIN_DB_PREFIX."c_ticket_category as ctc ON ctc.rowid = kr.fk_c_ticket_category";
73  $sql .= " WHERE ctc.code = '".$db->escape($idticketgroup)."'";
74  $sql .= " AND ctc.active = 1 AND ctc.public = 1 AND (kr.lang = '".$db->escape($lang)."' OR kr.lang = 0 OR kr.lang IS NULL)";
75  $sql .= " AND kr.status = 1 AND (kr.answer IS NOT NULL AND kr.answer <> '')";
76  $resql = $db->query($sql);
77  if ($resql) {
78  $num = $db->num_rows($resql);
79  $i = 0;
80  $response = array();
81  while ($i < $num) {
82  $obj = $db->fetch_object($resql);
83  $response[] = array('title'=>$obj->question,'ref'=>$obj->ref,'answer'=>dol_escape_htmltag(preg_replace('/\\r|\\r\\n|\\n/', "", $obj->answer)),'url'=>$obj->url);
84  $i++;
85  }
86  } else {
87  dol_print_error($db);
88  }
89  $response =json_encode($response);
90  echo $response;
91 }
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1436