Merge pull request #23883 from frederic34/knowledgemgmt

add ajax tooltip on knowledge record
This commit is contained in:
Laurent Destailleur 2023-02-13 18:21:09 +01:00 committed by GitHub
commit 66369567b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 659 additions and 85 deletions

View File

@ -2288,6 +2288,7 @@ class Adherent extends CommonObject
$datas = [];
$nofetch = empty($params['nofetch']) ? false : true;
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$langs->load("users");
return ['optimize' => $langs->trans("ShowUser")];
@ -2318,6 +2319,12 @@ class Adherent extends CommonObject
$datas['email'] = '<br><b>'.$langs->trans("EMail").':</b> '.$this->email;
}
$datas['address'] = '<br><b>'.$langs->trans("Address").':</b> '.dol_format_address($this, 1, ' ', $langs);
// show categories for this record only in ajax to not overload lists
if (isModEnabled('categorie') && !$nofetch) {
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$form = new Form($this->db);
$datas['categories'] = '<br>' . $form->showCategories($this->id, Categorie::TYPE_MEMBER, 1);
}
$datas['divclose'] = '</div>';
return $datas;
@ -2353,6 +2360,7 @@ class Adherent extends CommonObject
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
'nofetch' => 1,
];
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$classfortooltip = 'classforajaxtooltip';

View File

@ -461,7 +461,7 @@ class Documents extends DolibarrApi
} elseif ($modulepart == 'knowledgemanagement') {
require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class.php';
if (!DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read && !DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read) {
if (!DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read') && !DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) {
throw new RestException(401);
}

View File

@ -323,7 +323,7 @@ class Categories extends DolibarrApi
throw new RestException(401);
} elseif ($type == Categorie::TYPE_PROJECT && !DolibarrApiAccess::$user->rights->projet->lire) {
throw new RestException(401);
} elseif ($type == Categorie::TYPE_KNOWLEDGEMANAGEMENT && !DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read) {
} elseif ($type == Categorie::TYPE_KNOWLEDGEMANAGEMENT && !DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) {
throw new RestException(401);
}

View File

@ -1580,6 +1580,7 @@ class ActionComm extends CommonObject
$langs->load('agenda');
$datas = [];
$nofetch = empty($params['nofetch']) ? false : true;
// Set label of type
$labeltype = '';
if ($this->type_code) {
@ -1631,6 +1632,12 @@ class ActionComm extends CommonObject
$datas['note'] .= (dol_textishtml($texttoshow) ? str_replace(array("\r", "\n"), "", $texttoshow) : str_replace(array("\r", "\n"), '<br>', $texttoshow));
$datas['note'] .= '</div>';
}
// show categories for this record only in ajax to not overload lists
if (isModEnabled('categorie') && !$nofetch) {
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$form = new Form($this->db);
$datas['categories'] = '<br>' . $form->showCategories($this->id, Categorie::TYPE_ACTIONCOMM, 1);
}
return $datas;
}
@ -1734,6 +1741,7 @@ class ActionComm extends CommonObject
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
'nofetch' => 1,
];
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);

View File

@ -1417,6 +1417,7 @@ class Account extends CommonObject
$datas = [];
$nofetch = empty($params['nofetch']) ? false : true;
$pictos = img_picto('', $this->picto).' <u class="paddingrightnow">'.$langs->trans("BankAccount").'</u>';
if (isset($this->status)) {
$pictos .= ' '.$this->getLibStatut(5);
@ -1434,6 +1435,12 @@ class Account extends CommonObject
$datas['accountaccounting'] = '<br><b>'.$langs->trans('AccountAccounting').':</b> '.length_accountg($this->account_number);
$datas['accountancyjournal'] = '<br><b>'.$langs->trans('AccountancyJournal').':</b> '.$this->accountancy_journal;
}
// show categories for this record only in ajax to not overload lists
if (isModEnabled('categorie') && !$nofetch) {
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$form = new Form($this->db);
$datas['categories'] = '<br>' . $form->showCategories($this->id, Categorie::TYPE_ACCOUNT, 1);
}
return $datas;
}
@ -1454,38 +1461,20 @@ class Account extends CommonObject
include_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
$result = '';
$label = img_picto('', $this->picto).' <u class="paddingrightnow">'.$langs->trans("BankAccount").'</u>';
if (isset($this->status)) {
$label .= ' '.$this->getLibStatut(5);
}
$label .= '<br><b>'.$langs->trans('Label').':</b> '.$this->label;
$label .= '<br><b>'.$langs->trans('AccountNumber').':</b> '.$this->number;
$label .= '<br><b>'.$langs->trans('IBAN').':</b> '.getIbanHumanReadable($this);
$label .= '<br><b>'.$langs->trans('BIC').':</b> '.$this->bic;
$label .= '<br><b>'.$langs->trans("AccountCurrency").':</b> '.$this->currency_code;
if (empty($user->rights->banque->lire) || !empty($user->socid)) {
$option = 'nolink';
}
if (isModEnabled('accounting')) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
$langs->load("accountancy");
$label .= '<br><b>'.$langs->trans('AccountAccounting').':</b> '.length_accountg($this->account_number);
$label .= '<br><b>'.$langs->trans('AccountancyJournal').':</b> '.$this->accountancy_journal;
}
$classfortooltip = 'classfortooltip';
$dataparams = '';
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
'nofetch' => 1,
];
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
];
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
$label = $langs->trans('Loading');
}
$label = implode($this->getTooltipContentArray($params));
$linkclose = '"'.$dataparams.' title="'.dol_escape_htmltag($label, 1).'" class="'.$classfortooltip.'">';
$url = DOL_URL_ROOT.'/compta/bank/card.php?id='.$this->id;
@ -1871,7 +1860,7 @@ class Account extends CommonObject
/**
* Class to manage bank transaction lines
*/
class AccountLine extends CommonObject
class AccountLine extends CommonObjectLine
{
/**
* @var string Error code (or message)

View File

@ -163,6 +163,10 @@ if ($objecttype == 'facture' || $objecttype == 'invoice') {
$classpath = 'opensurvey/class';
$module = 'opensurvey';
$myobject = 'opensurveysondage';
} elseif ($objecttype == 'knowledgerecord') {
$classpath = 'knowledgemanagement/class';
$module = 'knowledgemanagement';
$myobject = 'knowledgerecord';
}
// Generic case for $classfile and $classname

View File

@ -0,0 +1,217 @@
<?php
/*
* Copyright (C) 2013-2016 Jean-François FERRY <hello@librethic.io>
* Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
* Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
*
* 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/boxes/box_last_knowledgerecord.php
* \ingroup knowledgerecord
* \brief This box shows latest created knowledgerecords
*/
require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php";
/**
* Class to manage the box
*/
class box_last_knowledgerecord extends ModeleBoxes
{
/**
* @var string boxcode
*/
public $boxcode = "box_last_knowledgerecord";
/**
* @var string box img
*/
public $boximg = "knowledgemanagement";
/**
* @var string boc label
*/
public $boxlabel;
/**
* @var array box dependancies
*/
public $depends = array("knowledgemanagement");
/**
* @var DoliDB Database handler.
*/
public $db;
/**
* @var string param
*/
public $param;
/**
* @var array box info heads
*/
public $info_box_head = array();
/**
* @var array box info content
*/
public $info_box_contents = array();
/**
* Constructor
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
public function __construct($db, $param = '')
{
global $langs;
$langs->load("boxes", "languages");
$this->db = $db;
$this->boxlabel = $langs->transnoentitiesnoconv("BoxLastKnowledgerecord");
}
/**
* Load data into info_box_contents array to show array later.
*
* @param int $max Maximum number of records to load
* @return void
*/
public function loadBox($max = 5)
{
global $user, $langs;
$this->max = $max;
require_once DOL_DOCUMENT_ROOT."/knowledgemanagement/class/knowledgerecord.class.php";
$text = $langs->trans("BoxLastKnowledgerecordDescription", $max);
$this->info_box_head = array(
'text' => $text,
'limit' => dol_strlen($text),
);
$this->info_box_contents[0][0] = array(
'td' => 'class="left"',
'text' => $langs->trans("BoxLastKnowledgerecordContent"),
);
if ($user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) {
$sql = 'SELECT k.rowid as id, k.date_creation, k.ref, k.lang, k.question, k.status as status';
$sql .= " FROM ".MAIN_DB_PREFIX."knowledgemanagement_knowledgerecord as k";
$sql .= " WHERE k.entity IN (".getEntity('knowledgemanagement').")";
if ($user->socid) {
$sql .= " AND k.fk_soc= ".((int) $user->socid);
}
$sql.= " AND k.status > 0";
$sql .= " ORDER BY k.date_creation DESC, k.rowid DESC ";
$sql .= $this->db->plimit($max, 0);
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num) {
$objp = $this->db->fetch_object($resql);
$datec = $this->db->jdate($objp->date_creation);
$knowledgerecord = new KnowledgeRecord($this->db);
$knowledgerecord->id = $objp->id;
$knowledgerecord->date_creation = $objp->date_creation;
$knowledgerecord->ref = $objp->ref;
$knowledgerecord->status = $objp->status;
$knowledgerecord->question = $objp->question;
$r = 0;
// Ticket
$this->info_box_contents[$i][$r] = array(
'td' => 'class="nowraponall"',
'text' => $knowledgerecord->getNomUrl(1),
'asis' => 1
);
$r++;
// Question
$this->info_box_contents[$i][$r] = array(
'td' => 'class="tdoverflowmax200"',
'text' => '<span title="'.dol_escape_htmltag($objp->question).'">'.dol_escape_htmltag($objp->question).'</span>',
'url' => DOL_URL_ROOT."/knowledgemanagement/knowledgerecord_card.php?id=".urlencode($objp->id),
);
$r++;
// Language
$labellang = ($objp->lang ? $langs->trans('Language_'.$objp->lang) : '');
$this->info_box_contents[$i][$r] = array(
'td' => 'class="tdoverflowmax100"',
'text' => picto_from_langcode($objp->lang, 'class="paddingrightonly saturatemedium opacitylow"') . $labellang,
'asis' => 1,
);
$r++;
// Date creation
$this->info_box_contents[$i][$r] = array(
'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateCreation").': '.dol_print_date($datec, 'dayhour', 'tzuserrel')).'"',
'text' => dol_print_date($datec, 'dayhour', 'tzuserrel'),
);
$r++;
// Statut
$this->info_box_contents[$i][$r] = array(
'td' => 'class="right nowraponall"',
'text' => $knowledgerecord->getLibStatut(3),
);
$r++;
$i++;
}
if ($num == 0) {
$this->info_box_contents[$i][0] = array(
'td' => '',
'text' => '<span class="opacitymedium">'.$langs->trans("BoxLastTicketNoRecordedTickets").'</span>',
);
}
} else {
dol_print_error($this->db);
}
} else {
$this->info_box_contents[0][0] = array(
'td' => '',
'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>',
);
}
}
/**
* Method to show box
*
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
* @return string
*/
public function showBox($head = null, $contents = null, $nooutput = 0)
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
}

View File

@ -0,0 +1,217 @@
<?php
/*
* Copyright (C) 2013-2016 Jean-François FERRY <hello@librethic.io>
* Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
* Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
*
* 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/boxes/box_last_modified_knowledgerecord.php
* \ingroup knowledgerecord
* \brief This box shows latest created knowledgerecords
*/
require_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php";
/**
* Class to manage the box
*/
class box_last_modified_knowledgerecord extends ModeleBoxes
{
/**
* @var string boxcode
*/
public $boxcode = "box_last_modified_knowledgerecord";
/**
* @var string box img
*/
public $boximg = "knowledgemanagement";
/**
* @var string boc label
*/
public $boxlabel;
/**
* @var array box dependancies
*/
public $depends = array("knowledgemanagement");
/**
* @var DoliDB Database handler.
*/
public $db;
/**
* @var string param
*/
public $param;
/**
* @var array box info heads
*/
public $info_box_head = array();
/**
* @var array box info content
*/
public $info_box_contents = array();
/**
* Constructor
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
public function __construct($db, $param = '')
{
global $langs;
$langs->load("boxes", "knowledgemanagement", "languages");
$this->db = $db;
$this->boxlabel = $langs->transnoentitiesnoconv("BoxLastModifiedKnowledgerecord");
}
/**
* Load data into info_box_contents array to show array later.
*
* @param int $max Maximum number of records to load
* @return void
*/
public function loadBox($max = 5)
{
global $user, $langs;
$this->max = $max;
require_once DOL_DOCUMENT_ROOT."/knowledgemanagement/class/knowledgerecord.class.php";
$text = $langs->trans("BoxLastModifiedKnowledgerecordDescription", $max);
$this->info_box_head = array(
'text' => $text,
'limit' => dol_strlen($text),
);
$this->info_box_contents[0][0] = array(
'td' => 'class="left"',
'text' => $langs->trans("BoxLastKnowledgerecordContent"),
);
if ($user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) {
$sql = 'SELECT k.rowid as id, k.date_creation, k.ref, k.lang, k.question, k.status as status';
$sql .= " FROM ".MAIN_DB_PREFIX."knowledgemanagement_knowledgerecord as k";
$sql .= " WHERE k.entity IN (".getEntity('knowledgemanagement').")";
if ($user->socid) {
$sql .= " AND k.fk_soc= ".((int) $user->socid);
}
$sql.= " AND k.status > 0";
$sql .= " ORDER BY k.tms DESC, k.rowid DESC ";
$sql .= $this->db->plimit($max, 0);
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num) {
$objp = $this->db->fetch_object($resql);
$datec = $this->db->jdate($objp->date_creation);
$knowledgerecord = new KnowledgeRecord($this->db);
$knowledgerecord->id = $objp->id;
$knowledgerecord->date_creation = $objp->date_creation;
$knowledgerecord->ref = $objp->ref;
$knowledgerecord->status = $objp->status;
$knowledgerecord->question = $objp->question;
$r = 0;
// Ticket
$this->info_box_contents[$i][$r] = array(
'td' => 'class="nowraponall"',
'text' => $knowledgerecord->getNomUrl(1),
'asis' => 1
);
$r++;
// Question
$this->info_box_contents[$i][$r] = array(
'td' => 'class="tdoverflowmax200"',
'text' => '<span title="'.dol_escape_htmltag($objp->question).'">'.dol_escape_htmltag($objp->question).'</span>',
'url' => DOL_URL_ROOT."/knowledgemanagement/knowledgerecord_card.php?id=".urlencode($objp->id),
);
$r++;
// Language
$labellang = ($objp->lang ? $langs->trans('Language_'.$objp->lang) : '');
$this->info_box_contents[$i][$r] = array(
'td' => 'class="tdoverflowmax100"',
'text' => picto_from_langcode($objp->lang, 'class="paddingrightonly saturatemedium opacitylow"') . $labellang,
'asis' => 1,
);
$r++;
// Date creation
$this->info_box_contents[$i][$r] = array(
'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateCreation").': '.dol_print_date($datec, 'dayhour', 'tzuserrel')).'"',
'text' => dol_print_date($datec, 'dayhour', 'tzuserrel'),
);
$r++;
// Statut
$this->info_box_contents[$i][$r] = array(
'td' => 'class="right nowraponall"',
'text' => $knowledgerecord->getLibStatut(3),
);
$r++;
$i++;
}
if ($num == 0) {
$this->info_box_contents[$i][0] = array(
'td' => '',
'text' => '<span class="opacitymedium">'.$langs->trans("BoxLastTicketNoRecordedTickets").'</span>',
);
}
} else {
dol_print_error($this->db);
}
} else {
$this->info_box_contents[0][0] = array(
'td' => '',
'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>',
);
}
}
/**
* Method to show box
*
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
* @return string
*/
public function showBox($head = null, $contents = null, $nooutput = 0)
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
}

View File

@ -191,7 +191,7 @@ class box_members_subscriptions_by_year extends ModeleBoxes
if ($num == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center"',
'td' => 'class="left" colspan="4"',
'text' => $langs->trans("NoRecordedMembers"),
);
} else {

View File

@ -201,12 +201,14 @@ class modKnowledgeManagement extends DolibarrModules
// Boxes/Widgets
// Add here list of php file(s) stored in knowledgemanagement/core/boxes that contains a class to show a widget.
$this->boxes = array(
// 0 => array(
// 'file' => 'knowledgemanagementwidget1.php@knowledgemanagement',
// 'note' => 'Widget provided by KnowledgeManagement',
// 'enabledbydefaulton' => 'Home',
// ),
// ...
0 => array(
'file' => 'box_last_knowledgerecord.php',
'enabledbydefaulton' => 'ticketindex',
),
1 => array(
'file' => 'box_last_modified_knowledgerecord.php',
'enabledbydefaulton' => 'ticketindex',
),
);
// Cronjobs (List of cron jobs entries to add when module is enabled)
@ -271,7 +273,7 @@ class modKnowledgeManagement extends DolibarrModules
'langs'=>'knowledgemanagement', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000 + $r,
'enabled'=>'$conf->knowledgemanagement->enabled', // Define condition to show or hide menu entry. Use '$conf->knowledgemanagement->enabled' if entry must be visible if module is enabled.
'perms'=>'1', // Use 'perms'=>'$user->rights->knowledgemanagement->knowledgerecord->read' if you want your menu with a permission rules
'perms'=>'1', // Use 'perms'=>'$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')' if you want your menu with a permission rules
'target'=>'',
'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
);
@ -334,7 +336,7 @@ class modKnowledgeManagement extends DolibarrModules
// Define condition to show or hide menu entry. Use '$conf->knowledgemanagement->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'enabled'=>'$conf->knowledgemanagement->enabled',
// Use 'perms'=>'$user->rights->knowledgemanagement->level1->level2' if you want your menu with a permission rules
'perms'=>'$user->rights->knowledgemanagement->knowledgerecord->write',
'perms'=>'$user->hasRight("knowledgemanagement", "knowledgerecord", "write")',
'target'=>'',
// 0=Menu for internal users, 1=external users, 2=both
'user'=>2

View File

@ -70,7 +70,7 @@ class KnowledgeManagement extends DolibarrApi
*/
public function get($id)
{
if (!DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read) {
if (!DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) {
throw new RestException(401);
}
@ -144,7 +144,7 @@ class KnowledgeManagement extends DolibarrApi
$obj_ret = array();
$tmpobject = new KnowledgeRecord($this->db);
if (!DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read) {
if (!DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) {
throw new RestException(401);
}
@ -249,7 +249,7 @@ class KnowledgeManagement extends DolibarrApi
*/
public function post($request_data = null)
{
if (!DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->write) {
if (!DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'write')) {
throw new RestException(401);
}
@ -282,7 +282,7 @@ class KnowledgeManagement extends DolibarrApi
*/
public function put($id, $request_data = null)
{
if (!DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->write) {
if (!DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'write')) {
throw new RestException(401);
}
@ -324,7 +324,7 @@ class KnowledgeManagement extends DolibarrApi
*/
public function delete($id)
{
if (!DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->delete) {
if (!DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'delete')) {
throw new RestException(401);
}
$result = $this->knowledgerecord->fetch($id);

View File

@ -129,7 +129,15 @@ class KnowledgeRecord extends CommonObject
public $fk_user_valid;
public $import_key;
public $model_pdf;
/**
* @var string question asked
*/
public $question;
/**
* @var string answer to question
*/
public $answer;
public $url;
public $status;
@ -192,7 +200,7 @@ class KnowledgeRecord extends CommonObject
}
// Example to show how to set values of fields definition dynamically
/*if ($user->rights->knowledgemanagement->knowledgerecord->read) {
/*if ($user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) {
$this->fields['myfield']['visible'] = 1;
$this->fields['myfield']['noteditable'] = 0;
}*/
@ -265,8 +273,8 @@ class KnowledgeRecord extends CommonObject
if (property_exists($object, 'ref')) {
$object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
}
if (property_exists($object, 'label')) {
$object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
if (property_exists($object, 'question')) {
$object->question = empty($this->fields['question']['default']) ? $langs->trans("CopyOf")." ".$object->question : $this->fields['question']['default'];
}
if (property_exists($object, 'status')) {
$object->status = self::STATUS_DRAFT;
@ -530,7 +538,7 @@ class KnowledgeRecord extends CommonObject
return 0;
}
/*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->knowledgemanagement->knowledgerecord->write))
/*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'))
|| (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->knowledgemanagement->knowledgerecord->knowledgerecord_advance->validate))))
{
$this->error='NotEnoughPermissions';
@ -706,6 +714,39 @@ class KnowledgeRecord extends CommonObject
return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'KNOWLEDGERECORD_REOPEN');
}
/**
* getTooltipContentArray
*
* @param array $params ex option, infologin
* @since v18
* @return array
*/
public function getTooltipContentArray($params)
{
global $conf, $langs;
$langs->loadLangs(['knowledgemanagement', 'languages']);
$datas = [];
$nofetch = empty($params['nofetch']) ? false : true;
$datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("KnowledgeRecord").'</u>';
if (isset($this->statut)) {
$datas['picto'] .= ' '.$this->getLibStatut(5);
}
$datas['label'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
$datas['question'] = '<br><b>'.$langs->trans('Question').':</b> '.$this->question;
$labellang = ($this->lang ? $langs->trans('Language_'.$this->lang) : '');
$datas['lang'] = '<br><b>'.$langs->trans('Language').':</b> ' . picto_from_langcode($this->lang, 'class="paddingrightonly saturatemedium opacitylow"') . $labellang;
// show categories for this record only in ajax to not overload lists
if (isModEnabled('categorie') && !$nofetch) {
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$form = new Form($this->db);
$datas['categories'] = '<br>' . $form->showCategories($this->id, Categorie::TYPE_KNOWLEDGEMANAGEMENT, 1);
}
return $datas;
}
/**
* Return a link to the object card (with optionaly the picto)
*
@ -726,12 +767,19 @@ class KnowledgeRecord extends CommonObject
$result = '';
$label = img_picto('', $this->picto).' <u>'.$langs->trans("KnowledgeRecord").'</u>';
if (isset($this->status)) {
$label .= ' '.$this->getLibStatut(5);
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
'nofetch' => 1,
];
$classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
}
$label .= '<br>';
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
$label = implode($this->getTooltipContentArray($params));
$url = dol_buildpath('/knowledgemanagement/knowledgerecord_card.php', 1).'?id='.$this->id;
@ -752,8 +800,8 @@ class KnowledgeRecord extends CommonObject
$label = $langs->trans("ShowKnowledgeRecord");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
$linkclose .= $dataparams.' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
} else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
@ -774,7 +822,7 @@ class KnowledgeRecord extends CommonObject
if (empty($this->showphoto_on_popup)) {
if ($withpicto) {
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
}
} else {
if ($withpicto) {

View File

@ -90,7 +90,7 @@ if ($id > 0 || !empty($ref)) {
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', 'rowid', $isdraft);
$permissiontoadd = $user->rights->knowledgemanagement->knowledgerecord->write; // Used by the include of actions_addupdatedelete.inc.php
$permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_addupdatedelete.inc.php
/*

View File

@ -74,12 +74,12 @@ if (empty($action) && empty($id) && empty($ref)) {
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
$permissiontoread = $user->rights->knowledgemanagement->knowledgerecord->read;
$permissiontovalidate = $user->rights->knowledgemanagement->knowledgerecord->write;
$permissiontoadd = $user->rights->knowledgemanagement->knowledgerecord->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$permissiontodelete = $user->rights->knowledgemanagement->knowledgerecord->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
$permissionnote = $user->rights->knowledgemanagement->knowledgerecord->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->knowledgemanagement->knowledgerecord->write; // Used by the include of actions_dellink.inc.php
$permissiontoread = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'read');
$permissiontovalidate = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write');
$permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$permissiontodelete = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
$permissionnote = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_dellink.inc.php
$upload_dir = $conf->knowledgemanagement->multidir_output[isset($object->entity) ? $object->entity : 1];
// Security check - Protection if external user
@ -538,8 +538,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$relativepath = $objref.'/'.$objref.'.pdf';
$filedir = $conf->knowledgemanagement->dir_output.'/'.$object->element.'/'.$objref;
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed = $user->rights->knowledgemanagement->knowledgerecord->read; // If you can read, you can build the PDF to read content
$delallowed = $user->rights->knowledgemanagement->knowledgerecord->write; // If you can create/edit, you can remove a file on card
$genallowed = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'read'); // If you can read, you can build the PDF to read content
$delallowed = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // If you can create/edit, you can remove a file on card
print $formfile->showdocuments('knowledgemanagement:KnowledgeRecord', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
}

View File

@ -56,7 +56,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', 'rowid', $isdraft);
$permission = $user->rights->knowledgemanagement->knowledgerecord->write;
$permission = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write');
/*

View File

@ -81,7 +81,7 @@ if ($id > 0 || !empty($ref)) {
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', 'rowid', $isdraft);
$permissiontoadd = $user->rights->knowledgemanagement->knowledgerecord->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php
$permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php
@ -183,9 +183,9 @@ if ($object->id) {
print dol_get_fiche_end();
$modulepart = 'knowledgemanagement';
//$permission = $user->rights->knowledgemanagement->knowledgerecord->write;
//$permission = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write');
$permission = 1;
//$permtoedit = $user->rights->knowledgemanagement->knowledgerecord->write;
//$permtoedit = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write');
$permtoedit = 1;
$param = '&id='.$object->id;

View File

@ -140,9 +140,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
$permissiontoread = $user->rights->knowledgemanagement->knowledgerecord->read;
$permissiontoadd = $user->rights->knowledgemanagement->knowledgerecord->write;
$permissiontodelete = $user->rights->knowledgemanagement->knowledgerecord->delete;
$permissiontoread = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'read');
$permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write');
$permissiontodelete = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'delete');
// Security check
if (empty($conf->knowledgemanagement->enabled)) {
@ -428,7 +428,7 @@ if ($permissiontodelete) {
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
}
if (isModEnabled('category') && $user->rights->knowledgemanagement->knowledgerecord->write) {
if (isModEnabled('category') && $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write')) {
$arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag");
}

View File

@ -52,8 +52,8 @@ if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->knowledgemanagement->multidir_output[$object->entity]."/".$object->id;
}
$permissionnote = $user->rights->knowledgemanagement->knowledgerecord->write; // Used by the include of actions_setnotes.inc.php
$permissiontoadd = $user->rights->knowledgemanagement->knowledgerecord->write; // Used by the include of actions_addupdatedelete.inc.php
$permissionnote = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_setnotes.inc.php
$permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_addupdatedelete.inc.php
// Security check - Protection if external user
//if ($user->socid > 0) accessforbidden();

View File

@ -51,4 +51,10 @@ SuggestedForTicketsInGroup=Suggested on ticket creation
SetObsolete=Set as obsolete
ConfirmCloseKM=Do you confirm the closing of this article as obsolete ?
ConfirmReopenKM=Do you want to restore this article to status "Validated" ?
ConfirmReopenKM=Do you want to restore this article to status "Validated" ?
BoxLastKnowledgerecordDescription=Last %s articles
BoxLastKnowledgerecord=Last articles
BoxLastKnowledgerecordContent=Last articles
BoxLastKnowledgerecordModifiedContent=Last modified articles
BoxLastModifiedKnowledgerecordDescription=Last %s modified articles
BoxLastModifiedKnowledgerecord=Last modified articles

View File

@ -233,3 +233,4 @@ CreateDolibarrThirdPartyDesc=A thirdparty is the legal entity that will be used
MemberFirstname=Member firstname
MemberLastname=Member lastname
MemberCodeDesc=Member Code, unique for all members
NoRecordedMembers=No registered member

View File

@ -93,7 +93,6 @@ class Mo extends CommonObject
* Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
*/
// BEGIN MODULEBUILDER PROPERTIES
/**
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/
@ -126,6 +125,10 @@ class Mo extends CommonObject
public $rowid;
public $entity;
public $ref;
/**
* @var int mrptype
*/
public $mrptype;
public $label;
public $qty;
@ -154,8 +157,17 @@ class Mo extends CommonObject
public $fk_user_modif;
public $import_key;
public $status;
/**
* @var int ID of product
*/
public $fk_product;
/**
* @var Product product object
*/
public $product;
/**
* @var integer|string date_start_planned
*/
@ -167,10 +179,20 @@ class Mo extends CommonObject
public $date_end_planned;
/**
* @var int ID bom
*/
public $fk_bom;
public $fk_project;
// END MODULEBUILDER PROPERTIES
/**
* @var Bom bom
*/
public $bom;
/**
* @var int ID project
*/
public $fk_project;
// If this object has a subtable with lines
@ -204,12 +226,24 @@ class Mo extends CommonObject
*/
public $lines = array();
/**
* @var MoLine MO line
*/
public $line = array();
/**
* @var integer Mo parent line
* */
/**
* @var int ID of parent line
*/
public $fk_parent_line;
/**
* @var array tpl
*/
public $tpl = array();
/**
* Constructor
@ -1100,6 +1134,9 @@ class Mo extends CommonObject
if (isset($this->label)) {
$datas['label'] = '<br><b>'.$langs->trans('Label').':</b> '.$this->label;
}
if (isset($this->mrptype)) {
$datas['type'] = '<br><b>'.$langs->trans('Type').':</b> '.$this->fields['mrptype']['arrayofkeyval'][$this->mrptype];
}
return $datas;
}
@ -1458,7 +1495,7 @@ class Mo extends CommonObject
* If lines are into a template, title must also be into a template
* But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
*
* @param CommonObjectLine $line Line
* @param MoLine $line Line
* @param string $var Var
* @param string $restrictlist ''=All lines, 'services'=Restrict to services only (strike line if not)
* @param string $defaulttpldir Directory where to find the template
@ -1519,7 +1556,7 @@ class Mo extends CommonObject
/**
* Function used to return childs of Mo
*
* @return array|int array if OK, -1 if KO
* @return Mo[]|int array if OK, -1 if KO
*/
public function getMoChilds()
{
@ -1557,7 +1594,7 @@ class Mo extends CommonObject
/**
* Function used to return childs of Mo
*
* @return Object|int MO object if OK, -1 if KO, 0 if not exist
* @return Mo|int MO object if OK, -1 if KO, 0 if not exist
*/
public function getMoParent()
{
@ -1680,6 +1717,7 @@ class MoLine extends CommonObjectLine
public $qty;
public $qty_frozen;
public $disable_stock_change;
public $efficiency;
public $batch;
public $role;
public $fk_mrp_production;
@ -1689,6 +1727,7 @@ class MoLine extends CommonObjectLine
public $fk_user_creat;
public $fk_user_modif;
public $import_key;
public $fk_parent_line;
/**
* Constructor

View File

@ -115,6 +115,11 @@ class Opensurveysondage extends CommonObject
*/
public $allow_spy;
/**
* @var array fields
*/
public $fields = array();
/**
* Draft status (not used)

View File

@ -5012,6 +5012,7 @@ class Product extends CommonObject
$langs->load('products');
$datas = [];
$nofetch = empty($params['nofetch']) ? false : true;
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
return ['optimize' => $langs->trans("ShowProduct")];
@ -5104,6 +5105,12 @@ class Product extends CommonObject
$datas['accountancybuy'] = $buylabel;
}
}
// show categories for this record only in ajax to not overload lists
if (isModEnabled('categorie') && !$nofetch) {
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$form = new Form($this->db);
$datas['categories'] = '<br>' . $form->showCategories($this->id, Categorie::TYPE_PRODUCT, 1);
}
return $datas;
}
@ -5136,6 +5143,7 @@ class Product extends CommonObject
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
'nofetch' => 1,
];
$classfortooltip = 'classfortooltip';
$dataparams = '';

View File

@ -2612,6 +2612,7 @@ class Societe extends CommonObject
$datas = [];
$option = $params['option'] ?? '';
$nofetch = empty($params['nofetch']) ? false : true;
$name = $this->name;
if (!empty($this->name_alias) && empty($noaliasinname)) {
@ -2724,6 +2725,17 @@ class Societe extends CommonObject
if (isModEnabled('accounting') && $this->fournisseur) {
$datas['accountancysuppliercode'] = '<br><b>'.$langs->trans('SupplierAccountancyCode').':</b> '.$this->code_compta_fournisseur;
}
// show categories for this record only in ajax to not overload lists
if (isModEnabled('categorie') && !$nofetch) {
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$form = new Form($this->db);
if ($this->client) {
$datas['categories_customer'] = '<br>' . $form->showCategories($this->id, Categorie::TYPE_CUSTOMER, 1);
}
if ($this->fournisseur) {
$datas['categories_supplier'] = '<br>' . $form->showCategories($this->id, Categorie::TYPE_SUPPLIER, 1);
}
}
$datas['divclose'] = '</div>';
@ -2789,6 +2801,7 @@ class Societe extends CommonObject
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
'nofetch' => 1,
];
$classfortooltip = 'classfortooltip';
$dataparams = '';

View File

@ -1433,6 +1433,7 @@ class Ticket extends CommonObject
$langs->load('ticket');
$nofetch = empty($params['nofetch']) ? false : true;
$datas = [];
$datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Ticket").'</u>';
$datas['picto'] .= ' '.$this->getLibStatut(4);
@ -1440,10 +1441,16 @@ class Ticket extends CommonObject
$datas['track_id'] = '<br><b>'.$langs->trans('TicketTrackId').':</b> '.$this->track_id;
$datas['subject'] = '<br><b>'.$langs->trans('Subject').':</b> '.$this->subject;
if ($this->date_creation) {
$datas['date_creation'] = '<br><b>'.$langs->trans('DateCreation').':</b> '.$this->date_creation;
$datas['date_creation'] = '<br><b>'.$langs->trans('DateCreation').':</b> '.dol_print_date($this->date_creation, 'dayhour');
}
if ($this->date_modification) {
$datas['date_modification'] = '<br><b>'.$langs->trans('DateModification').':</b> '.$this->date_modification;
$datas['date_modification'] = '<br><b>'.$langs->trans('DateModification').':</b> '.dol_print_date($this->date_modification, 'dayhour');
}
// show categories for this record only in ajax to not overload lists
if (isModEnabled('categorie') && !$nofetch) {
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$form = new Form($this->db);
$datas['categories'] = '<br>' . $form->showCategories($this->id, Categorie::TYPE_TICKET, 1);
}
return $datas;
@ -1474,6 +1481,8 @@ class Ticket extends CommonObject
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
'nofetch' => 1,
];
$classfortooltip = 'classfortooltip';
$dataparams = '';

View File

@ -252,7 +252,7 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) {
$linkback = '<a href="'.dol_buildpath('/ticket/list.php', 1).'"><strong>'.$langs->trans("BackToList").'</strong></a> ';
dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, $param, 0, '', '', 1, '');
dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1, '');
print dol_get_fiche_end();

View File

@ -65,7 +65,7 @@ $object = new Ticket($db);
// Security check
//$result = restrictedArea($user, 'ticket|knowledgemanagement', 0, '', '', '', '');
if (empty($user->rights->ticket->read) && empty($user->rights->knowledgemanagement->knowledgerecord->read)) {
if (empty($user->rights->ticket->read) && !$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) {
accessforbidden('Not enought permissions');
}