25require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/knowledgemanagement/class/knowledgerecord.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/knowledgemanagement/lib/knowledgemanagement_knowledgerecord.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
36$langs->loadLangs(array(
"knowledgemanagement",
"ticket",
"other"));
41$action =
GETPOST(
'action',
'aZ09');
42$confirm =
GETPOST(
'confirm',
'alpha');
43$cancel =
GETPOST(
'cancel',
'aZ09');
44$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'knowledgerecordcard';
45$backtopage =
GETPOST(
'backtopage',
'alpha');
46$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
52$diroutputmassaction = $conf->knowledgemanagement->dir_output.
'/temp/massgeneration/'.$user->id;
53$hookmanager->initHooks(array(
'knowledgerecordcard',
'globalcard'));
56$extrafields->fetch_name_optionals_label(
$object->table_element);
58$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
61$search_all =
GETPOST(
"search_all",
'alpha');
63foreach (
$object->fields as $key => $val) {
64 if (
GETPOST(
'search_'.$key,
'alpha')) {
65 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
69if (empty($action) && empty($id) && empty($ref)) {
74include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
77$permissiontoread = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'read');
78$permissiontoadd = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'write');
79$permissiontodelete = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
80$permissiontovalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $permissiontoadd) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'knowledgemanagement',
'knowledgerecord_advance',
'validate')));
81$permissionnote = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'write');
82$permissiondellink = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'write');
83$upload_dir = $conf->knowledgemanagement->multidir_output[isset(
$object->entity) ?
$object->entity : 1];
88$isdraft = ((
$object->status == $object::STATUS_DRAFT) ? 1 : 0);
99$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
104if (empty($reshook)) {
107 $backurlforlist = DOL_URL_ROOT.
'/knowledgemanagement/knowledgerecord_list.php';
109 if (empty($backtopage) || ($cancel && empty($id))) {
110 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
111 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
112 $backtopage = $backurlforlist;
114 $backtopage = DOL_URL_ROOT.
'/knowledgemanagement/knowledgerecord_card.php?id='.(
$id > 0 ?
$id :
'__ID__');
119 $triggermodname =
'KNOWLEDGERECORD_MODIFY';
122 if (($action ==
'update' || $action ==
'add') && !empty($permissiontoadd)) {
127 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
130 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
133 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
139 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
141 if ($action ==
'set_thirdparty' && $permissiontoadd) {
142 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
'',
'date',
'', $user, $triggermodname);
144 if ($action ==
'classin' && $permissiontoadd) {
149 $triggersendname =
'KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_SENTBYMAIL';
150 $autocopy =
'MAIN_MAIL_AUTOCOPY_KNOWLEDGERECORD_TO';
151 $trackid =
'knowledgerecord'.$object->id;
152 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
154if ($action ==
'confirm_validate') {
162$form =
new Form($db);
167$title = $langs->trans(
"KnowledgeRecord");
169llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-knowledgemanagement page-card');
172if ($action ==
'create') {
173 print
load_fiche_titre($langs->trans(
"NewKnowledgeRecord"),
'',
'object_'.$object->picto);
175 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
176 print
'<input type="hidden" name="token" value="'.newToken().
'">';
177 print
'<input type="hidden" name="action" value="add">';
178 if (!empty($backtopage)) {
179 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
181 if (!empty($backtopageforcancel)) {
182 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
187 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
190 $object->fields[
'answer'][
'enabled'] = 0;
191 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
192 $object->fields[
'answer'][
'enabled'] = 1;
194 if (isModEnabled(
'category')) {
195 $cate_arbo = $form->select_all_categories(Categorie::TYPE_KNOWLEDGEMANAGEMENT,
'',
'parent', 64, 0, 3);
197 if (count($cate_arbo)) {
199 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
200 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
206 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
208 print
'</table>'.
"\n";
212 print $langs->trans(
$object->fields[
'answer'][
'label']).
'<br>';
213 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
214 $doleditor =
new DolEditor(
'answer',
$object->answer,
'', 200,
'dolibarr_notes',
'In',
true,
true,
true, ROWS_9,
'100%');
215 $out = $doleditor->Create(1);
220 print $form->buttonsSaveCancel(
'Create');
228if (($id || $ref) && $action ==
'edit') {
229 print
load_fiche_titre($langs->trans(
"KnowledgeRecord"),
'',
'object_'.$object->picto);
231 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
232 print
'<input type="hidden" name="token" value="'.newToken().
'">';
233 print
'<input type="hidden" name="action" value="update">';
234 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
235 if (!empty($backtopage)) {
236 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
238 if (!empty($backtopageforcancel)) {
239 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
244 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
247 $object->fields[
'answer'][
'enabled'] = 0;
248 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
249 $object->fields[
'answer'][
'enabled'] = 1;
251 if (isModEnabled(
'category')) {
252 $cate_arbo = $form->select_all_categories(Categorie::TYPE_KNOWLEDGEMANAGEMENT,
'',
'parent', 64, 0, 3);
254 if (count($cate_arbo)) {
256 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
258 $cats = $c->containing(
$object->id, Categorie::TYPE_KNOWLEDGEMANAGEMENT);
259 $arrayselected = array();
260 if (is_array($cats)) {
261 foreach ($cats as $cat) {
262 $arrayselected[] = $cat->id;
265 print $form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
271 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
277 print $langs->trans(
$object->fields[
'answer'][
'label']).
'<br>';
278 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
279 $doleditor =
new DolEditor(
'answer',
$object->answer,
'', 200,
'dolibarr_notes',
'In',
true,
true,
true, ROWS_9,
'100%');
280 $out = $doleditor->Create(1);
285 print $form->buttonsSaveCancel();
291if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
292 $res =
$object->fetch_optionals();
300 if ($action ==
'delete') {
301 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteKnowledgeRecord'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
304 if ($action ==
'deleteline') {
305 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
308 if ($action ==
'clone') {
310 $formquestion = array();
311 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
315 if ($action ==
'close') {
316 $text = $langs->trans(
'ConfirmCloseKM',
$object->ref);
325 $formquestion = array();
336 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'SetObsolete'), $text,
'confirm_close', $formquestion, 0, 1, 220);
340 if ($action ==
'reopen') {
341 $text = $langs->trans(
'ConfirmReopenKM',
$object->ref);
350 $formquestion = array();
361 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Re-Open'), $text,
'confirm_reopen', $formquestion, 0, 1, 220);
365 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
366 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
367 if (empty($reshook)) {
368 $formconfirm .= $hookmanager->resPrint;
369 } elseif ($reshook > 0) {
370 $formconfirm = $hookmanager->resPrint;
379 $linkback =
'<a href="'.DOL_URL_ROOT.
'/knowledgemanagement/knowledgerecord_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
381 $morehtmlref =
'<div class="refidno">';
416 $morehtmlref .=
'</div>';
419 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
422 print
'<div class="fichecenter">';
423 print
'<div class="fichehalfleft">';
424 print
'<div class="underbanner clearboth"></div>';
425 print
'<table class="border centpercent tableforfield">'.
"\n";
428 $keyforbreak=
'fk_c_ticket_category';
431 $object->fields[
'answer'][
'enabled'] = 0;
432 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
433 $object->fields[
'answer'][
'enabled'] = 1;
436 if (isModEnabled(
'category')) {
437 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
438 print $form->showCategories(
$object->id, Categorie::TYPE_KNOWLEDGEMANAGEMENT, 1);
443 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
450 print
'<div class="clearboth"></div>';
454 print $langs->trans(
$object->fields[
'answer'][
'label']).
'<br>';
455 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
456 $doleditor =
new DolEditor(
'answer',
$object->answer,
'', 200,
'dolibarr_notes',
'In',
true,
true,
true, ROWS_9,
'100%', 1);
457 $out = $doleditor->Create(1);
465 if ($action !=
'presend' && $action !=
'editline') {
466 print
'<div class="tabsAction">'.
"\n";
467 $parameters = array();
468 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
473 if (empty($reshook)) {
475 if (empty($user->socid)) {
480 if (
$object->status == $object::STATUS_VALIDATED) {
481 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
483 if ((
$object->status == $object::STATUS_DRAFT ||
$object->status == $object::STATUS_VALIDATED) && $permissiontovalidate) {
484 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
487 if (
$object->status == $object::STATUS_DRAFT) {
488 if ((empty(
$object->table_element_line) || (is_array(
$object->lines) && count(
$object->lines) > 0)) && $permissiontovalidate) {
489 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&token='.
newToken().
'&confirm=yes',
'', $permissiontoadd);
491 $langs->load(
"errors");
493 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Reply").
'</a>';
498 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=clone&token='.
newToken().
'&object=scrumsprint',
'', $permissiontoadd);
509 if ($permissiontoadd) {
510 if (
$object->status == $object::STATUS_VALIDATED) {
511 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=close&token='.
newToken().
'">'.$langs->trans(
"SetObsolete").
'</a>'.
"\n";
513 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=reopen&token='.
newToken().
'">'.$langs->trans(
"Re-Open").
'</a>'.
"\n";
518 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'', $permissiontodelete || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd));
525 if (
GETPOST(
'modelselected')) {
529 if ($action !=
'presend') {
530 print
'<div class="fichecenter"><div class="fichehalfleft">';
531 print
'<a name="builddoc"></a>';
533 $includedocgeneration = 0;
536 if ($includedocgeneration) {
538 $relativepath = $objref.
'/'.$objref.
'.pdf';
539 $filedir = $conf->knowledgemanagement->dir_output.
'/'.
$object->element.
'/'.$objref;
540 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
541 $genallowed = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'read');
542 $delallowed = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'write');
543 print $formfile->showdocuments(
'knowledgemanagement:KnowledgeRecord',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
547 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'knowledgerecord'));
548 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
551 print
'</div><div class="fichehalfright">';
555 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/knowledgemanagement/knowledgerecord_agenda.php?id='.
$object->id);
558 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
560 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
562 print
'</div></div>';
566 if (
GETPOST(
'modelselected')) {
571 $modelmail =
'knowledgerecord';
572 $defaulttopic =
'InformationMessage';
573 $diroutput = $conf->knowledgemanagement->dir_output;
574 $trackid =
'knowledgerecord'.$object->id;
576 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage categories.
Class to manage a WYSIWYG editor.
Class for KnowledgeRecord.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
knowledgerecordPrepareHead($object)
Prepare array of tabs for KnowledgeRecord.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.