Close #18677 : new show articles of KM
This commit is contained in:
parent
283f37a364
commit
b26e9be36f
80
htdocs/core/ajax/fetchKnowledgeRecord.php
Normal file
80
htdocs/core/ajax/fetchKnowledgeRecord.php
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file /htdocs/core/ajax/fetchKnowledgeRecord.php
|
||||||
|
* \brief File to make Ajax action on Knowledge Management
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('NOTOKENRENEWAL')) {
|
||||||
|
define('NOTOKENRENEWAL', '1'); // Disables token renewal
|
||||||
|
}
|
||||||
|
if (!defined('NOREQUIREMENU')) {
|
||||||
|
define('NOREQUIREMENU', '1');
|
||||||
|
}
|
||||||
|
if (!defined('NOREQUIREHTML')) {
|
||||||
|
define('NOREQUIREHTML', '1');
|
||||||
|
}
|
||||||
|
if (!defined('NOREQUIREAJAX')) {
|
||||||
|
define('NOREQUIREAJAX', '1');
|
||||||
|
}
|
||||||
|
if (!defined('NOREQUIRESOC')) {
|
||||||
|
define('NOREQUIRESOC', '1');
|
||||||
|
}
|
||||||
|
|
||||||
|
include '../../main.inc.php';
|
||||||
|
|
||||||
|
$action = GETPOST('action', 'aZ09');
|
||||||
|
$idticketgroup = GETPOST('idticketgroup', 'aZ09');
|
||||||
|
$idticketgroup = GETPOST('idticketgroup', 'aZ09');
|
||||||
|
$lang = GETPOST('lang', 'aZ09');
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Actions
|
||||||
|
*/
|
||||||
|
|
||||||
|
// None
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ($action == "getKnowledgeRecord") {
|
||||||
|
$response = '';
|
||||||
|
$sql = "SELECT kr.rowid, kr.ref, kr.question, kr.answer,l.url,ctc.code";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."links as l";
|
||||||
|
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."knowledgemanagement_knowledgerecord as kr ON kr.rowid = l.objectid";
|
||||||
|
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_ticket_category as ctc ON ctc.rowid = kr.fk_c_ticket_category";
|
||||||
|
$sql .= " WHERE ctc.code = '".$db->escape($idticketgroup)."'";
|
||||||
|
$sql .= " AND ctc.active = 1 AND ctc.public = 1 AND (kr.lang = '".$db->escape($lang)."' OR kr.lang = 0)";
|
||||||
|
$sql .= " AND kr.status = 1";
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
$i = 0;
|
||||||
|
$response = array();
|
||||||
|
while ($i < $num) {
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
$response[] = array('title'=>$obj->question,'ref'=>$obj->url,'answer'=>$obj->answer,'url'=>$obj->url);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
$response =json_encode($response);
|
||||||
|
echo $response;
|
||||||
|
}
|
||||||
@ -243,6 +243,65 @@ class FormTicket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($conf->knowledgemanagement->enabled) {
|
||||||
|
// KM Articles
|
||||||
|
print '<tr id="KWwithajax"></tr>';
|
||||||
|
print '<!-- Script to manage change of ticket group -->
|
||||||
|
<script>
|
||||||
|
jQuery(document).ready(function() {
|
||||||
|
function groupticketchange(){
|
||||||
|
console.log("We called groupticketchange, so we try to load list KM linked to event");
|
||||||
|
$("#KWwithajax").html("");
|
||||||
|
idgroupticket = $("#selectcategory_code").val();
|
||||||
|
|
||||||
|
console.log("We have selected id="+idgroupticket);
|
||||||
|
|
||||||
|
if (idgroupticket != "") {
|
||||||
|
$.ajax({ url: \''.DOL_URL_ROOT.'/core/ajax/fetchKnowledgeRecord.php\',
|
||||||
|
data: { action: \'getKnowledgeRecord\', idticketgroup: idgroupticket, token: \''.newToken().'\', lang:\''.$langs->defaultlang.'\'},
|
||||||
|
type: \'GET\',
|
||||||
|
success: function(response) {
|
||||||
|
var urllist = \'\';
|
||||||
|
console.log("We received response "+response);
|
||||||
|
response = JSON.parse(response)
|
||||||
|
for (key in response) {
|
||||||
|
console.log(response[key])
|
||||||
|
urllist += "<li>" + response[key].title + ": " + \'<a href="\'+response[key].ref + "\">"+response[key].url+"</a></li>";
|
||||||
|
}
|
||||||
|
if (urllist != "") {
|
||||||
|
console.log(urllist)
|
||||||
|
$("#KWwithajax").html(\'<td>'.$langs->trans("KMFoundForTicketGroup").'</td><td><ul style="list-style:none;padding-left: 0;">\'+urllist+\'</ul></td>\');
|
||||||
|
$("#KWwithajax").show();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error : function(output) {
|
||||||
|
console.log("error");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$("#selectcategory_code").bind("change",function() { groupticketchange(); });
|
||||||
|
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
||||||
|
var trackChange = function(element) {
|
||||||
|
var observer = new MutationObserver(function(mutations, observer) {
|
||||||
|
if (mutations[0].attributeName == "value") {
|
||||||
|
$(element).trigger("change");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
observer.observe(element, {
|
||||||
|
attributes: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
trackChange($("#selectcategory_code")[0]);
|
||||||
|
|
||||||
|
if ($("#selectcategory_code").val() != "") {
|
||||||
|
groupticketchange();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
// MESSAGE
|
// MESSAGE
|
||||||
$msg = GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : '';
|
$msg = GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : '';
|
||||||
print '<tr><td><label for="message"><span class="fieldrequired">'.$langs->trans("Message").'</span></label></td><td>';
|
print '<tr><td><label for="message"><span class="fieldrequired">'.$langs->trans("Message").'</span></label></td><td>';
|
||||||
|
|||||||
@ -318,4 +318,5 @@ BoxNoTicketLastXDays=No new tickets the last %s days
|
|||||||
BoxNumberOfTicketByDay=Number of new tickets by day
|
BoxNumberOfTicketByDay=Number of new tickets by day
|
||||||
BoxNewTicketVSClose=Number of today's new tickets versus today's closed tickets
|
BoxNewTicketVSClose=Number of today's new tickets versus today's closed tickets
|
||||||
TicketCreatedToday=Ticket created today
|
TicketCreatedToday=Ticket created today
|
||||||
TicketClosedToday=Ticket closed today
|
TicketClosedToday=Ticket closed today
|
||||||
|
KMFoundForTicketGroup=We found topics and FAQs that may answers your question, thanks to check them before submitting the ticket
|
||||||
|
|||||||
@ -319,3 +319,4 @@ BoxNumberOfTicketByDay=Nombre de nouveaux tickets par jour
|
|||||||
BoxNewTicketVSClose=Nombre de nouveaux tickets aujourd’hui par rapport aux tickets fermés aujourd’hui
|
BoxNewTicketVSClose=Nombre de nouveaux tickets aujourd’hui par rapport aux tickets fermés aujourd’hui
|
||||||
TicketCreatedToday=Ticket créé aujourd'hui
|
TicketCreatedToday=Ticket créé aujourd'hui
|
||||||
TicketClosedToday=Ticket fermé aujourd'hui
|
TicketClosedToday=Ticket fermé aujourd'hui
|
||||||
|
KMFoundForTicketGroup=Nous avons trouvé des sujets et des FAQ susceptibles de répondre à votre question, merci de les vérifier avant de soumettre le ticket
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user