27require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/knowledgemanagement/class/knowledgerecord.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/knowledgemanagement/lib/knowledgemanagement_knowledgerecord.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
46$langs->loadLangs(array(
"knowledgemanagement",
"ticket",
"other"));
51$action =
GETPOST(
'action',
'aZ09');
52$confirm =
GETPOST(
'confirm',
'alpha');
53$cancel =
GETPOST(
'cancel',
'aZ09');
54$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'knowledgerecordcard';
55$backtopage =
GETPOST(
'backtopage',
'alpha');
56$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
62$diroutputmassaction =
$conf->knowledgemanagement->dir_output.
'/temp/massgeneration/'.$user->id;
63$hookmanager->initHooks(array(
'knowledgerecordcard',
'globalcard'));
66$extrafields->fetch_name_optionals_label(
$object->table_element);
68$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
71$search_all =
GETPOST(
"search_all",
'alpha');
73foreach (
$object->fields as $key => $val) {
74 if (
GETPOST(
'search_'.$key,
'alpha')) {
75 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
79if (empty($action) && empty($id) && empty($ref)) {
84include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
87$permissiontoread = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'read');
88$permissiontoadd = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'write');
89$permissiontodelete = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
90$permissiontovalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $permissiontoadd) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'knowledgemanagement',
'knowledgerecord_advance',
'validate')));
91$permissionnote = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'write');
92$permissiondellink = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'write');
93$upload_dir =
$conf->knowledgemanagement->multidir_output[isset(
$object->entity) ?
$object->entity : 1];
98$isdraft = ((
$object->status == $object::STATUS_DRAFT) ? 1 : 0);
108$parameters = array();
109$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
114if (empty($reshook)) {
117 $backurlforlist = DOL_URL_ROOT.
'/knowledgemanagement/knowledgerecord_list.php';
119 if (empty($backtopage) || ($cancel && empty($id))) {
120 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
121 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
122 $backtopage = $backurlforlist;
124 $backtopage = DOL_URL_ROOT.
'/knowledgemanagement/knowledgerecord_card.php?id='.(
$id > 0 ?
$id :
'__ID__');
129 $triggermodname =
'KNOWLEDGERECORD_MODIFY';
132 if (($action ==
'update' || $action ==
'add') && !empty($permissiontoadd)) {
137 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
140 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
143 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
149 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
151 if ($action ==
'set_thirdparty' && $permissiontoadd) {
152 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
154 if ($action ==
'classin' && $permissiontoadd) {
159 $triggersendname =
'KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_SENTBYMAIL';
160 $autocopy =
'MAIN_MAIL_AUTOCOPY_KNOWLEDGERECORD_TO';
161 $trackid =
'knowledgerecord'.$object->id;
162 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
164if ($action ==
'confirm_validate') {
172$form =
new Form($db);
177$title = $langs->trans(
"KnowledgeRecord");
179llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-knowledgemanagement page-card');
182if ($action ==
'create') {
183 print
load_fiche_titre($langs->trans(
"NewKnowledgeRecord"),
'',
'object_'.$object->picto);
185 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
186 print
'<input type="hidden" name="token" value="'.newToken().
'">';
187 print
'<input type="hidden" name="action" value="add">';
188 if (!empty($backtopage)) {
189 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
191 if (!empty($backtopageforcancel)) {
192 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
197 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
200 $object->fields[
'answer'][
'enabled'] = 0;
201 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
202 $object->fields[
'answer'][
'enabled'] = 1;
204 if (isModEnabled(
'category')) {
205 $cate_arbo = $form->select_all_categories(Categorie::TYPE_KNOWLEDGEMANAGEMENT,
'',
'parent', 64, 0, 3);
207 if (count($cate_arbo)) {
209 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
210 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
216 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
218 print
'</table>'.
"\n";
222 print $langs->trans(
$object->fields[
'answer'][
'label']).
'<br>';
223 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
224 $doleditor =
new DolEditor(
'answer',
$object->answer,
'', 200,
'dolibarr_notes',
'In',
true,
true,
true, ROWS_9,
'100%');
225 $out = $doleditor->Create(1);
230 print $form->buttonsSaveCancel(
'Create');
238if (($id || $ref) && $action ==
'edit') {
239 print
load_fiche_titre($langs->trans(
"KnowledgeRecord"),
'',
'object_'.$object->picto);
241 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
242 print
'<input type="hidden" name="token" value="'.newToken().
'">';
243 print
'<input type="hidden" name="action" value="update">';
244 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
245 if (!empty($backtopage)) {
246 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
248 if (!empty($backtopageforcancel)) {
249 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
254 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
257 $object->fields[
'answer'][
'enabled'] = 0;
258 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
259 $object->fields[
'answer'][
'enabled'] = 1;
261 if (isModEnabled(
'category')) {
262 $cate_arbo = $form->select_all_categories(Categorie::TYPE_KNOWLEDGEMANAGEMENT,
'',
'parent', 64, 0, 3);
264 if (count($cate_arbo)) {
266 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
268 $cats = $c->containing(
$object->id, Categorie::TYPE_KNOWLEDGEMANAGEMENT);
269 $arrayselected = array();
270 if (is_array($cats)) {
271 foreach ($cats as $cat) {
272 $arrayselected[] = $cat->id;
275 print $form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
281 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
287 print $langs->trans(
$object->fields[
'answer'][
'label']).
'<br>';
288 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
289 $doleditor =
new DolEditor(
'answer',
$object->answer,
'', 200,
'dolibarr_notes',
'In',
true,
true,
true, ROWS_9,
'100%');
290 $out = $doleditor->Create(1);
295 print $form->buttonsSaveCancel();
301if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
302 $res =
$object->fetch_optionals();
310 if ($action ==
'delete') {
311 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteKnowledgeRecord'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
314 if ($action ==
'deleteline') {
315 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
318 if ($action ==
'clone') {
320 $formquestion = array();
321 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
325 if ($action ==
'close') {
326 $text = $langs->trans(
'ConfirmCloseKM',
$object->ref);
335 $formquestion = array();
346 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'SetObsolete'), $text,
'confirm_close', $formquestion, 0, 1, 220);
350 if ($action ==
'reopen') {
351 $text = $langs->trans(
'ConfirmReopenKM',
$object->ref);
360 $formquestion = array();
371 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Re-Open'), $text,
'confirm_reopen', $formquestion, 0, 1, 220);
375 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
376 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
377 if (empty($reshook)) {
378 $formconfirm .= $hookmanager->resPrint;
379 } elseif ($reshook > 0) {
380 $formconfirm = $hookmanager->resPrint;
389 $linkback =
'<a href="'.DOL_URL_ROOT.
'/knowledgemanagement/knowledgerecord_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
391 $morehtmlref =
'<div class="refidno">';
426 $morehtmlref .=
'</div>';
429 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
432 print
'<div class="fichecenter">';
433 print
'<div class="fichehalfleft">';
434 print
'<div class="underbanner clearboth"></div>';
435 print
'<table class="border centpercent tableforfield">'.
"\n";
438 $keyforbreak =
'fk_c_ticket_category';
441 $object->fields[
'answer'][
'enabled'] = 0;
442 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
443 $object->fields[
'answer'][
'enabled'] = 1;
446 if (isModEnabled(
'category')) {
447 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
448 print $form->showCategories(
$object->id, Categorie::TYPE_KNOWLEDGEMANAGEMENT, 1);
453 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
460 print
'<div class="clearboth"></div>';
464 print $langs->trans(
$object->fields[
'answer'][
'label']).
'<br>';
465 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
466 $doleditor =
new DolEditor(
'answer',
$object->answer,
'', 200,
'dolibarr_notes',
'In',
true,
true,
true, ROWS_9,
'100%', 1);
467 $out = $doleditor->Create(1);
475 if ($action !=
'presend' && $action !=
'editline') {
476 print
'<div class="tabsAction">'.
"\n";
477 $parameters = array();
478 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
483 if (empty($reshook)) {
485 if (empty($user->socid)) {
490 if (
$object->status == $object::STATUS_VALIDATED) {
491 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
493 if ((
$object->status == $object::STATUS_DRAFT ||
$object->status == $object::STATUS_VALIDATED) && $permissiontovalidate) {
494 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
497 if (
$object->status == $object::STATUS_DRAFT) {
498 if ((empty(
$object->table_element_line) || (is_array(
$object->lines) && count(
$object->lines) > 0)) && $permissiontovalidate) {
499 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&token='.
newToken().
'&confirm=yes',
'', $permissiontoadd);
501 $langs->load(
"errors");
503 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Reply").
'</a>';
508 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=clone&token='.
newToken().
'&object=scrumsprint',
'', $permissiontoadd);
519 if ($permissiontoadd) {
520 if (
$object->status == $object::STATUS_VALIDATED) {
521 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=close&token='.
newToken().
'">'.$langs->trans(
"SetObsolete").
'</a>'.
"\n";
523 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=reopen&token='.
newToken().
'">'.$langs->trans(
"Re-Open").
'</a>'.
"\n";
528 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'', $permissiontodelete || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd));
535 if (
GETPOST(
'modelselected')) {
539 if ($action !=
'presend') {
540 print
'<div class="fichecenter"><div class="fichehalfleft">';
541 print
'<a name="builddoc"></a>';
543 $includedocgeneration = 0;
546 if ($includedocgeneration) {
548 $relativepath = $objref.
'/'.$objref.
'.pdf';
549 $filedir =
$conf->knowledgemanagement->dir_output.
'/'.
$object->element.
'/'.$objref;
550 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
551 $genallowed = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'read');
552 $delallowed = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'write');
553 print $formfile->showdocuments(
'knowledgemanagement:KnowledgeRecord',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
557 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'knowledgerecord'), 1);
558 $linktoelem = $tmparray[
'linktoelem'];
559 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
560 print $htmltoenteralink;
562 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
565 print
'</div><div class="fichehalfright">';
569 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/knowledgemanagement/knowledgerecord_agenda.php?id='.
$object->id);
572 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
574 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
576 print
'</div></div>';
580 if (
GETPOST(
'modelselected')) {
585 $modelmail =
'knowledgerecord';
586 $defaulttopic =
'InformationMessage';
587 $diroutput =
$conf->knowledgemanagement->dir_output;
588 $trackid =
'knowledgerecord'.$object->id;
590 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.