2007-01-25 21:12:45 +01:00
|
|
|
<?php
|
2012-03-17 16:05:58 +01:00
|
|
|
/* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
|
|
|
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2018-10-27 14:43:12 +02:00
|
|
|
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
|
2018-05-28 16:38:11 +02:00
|
|
|
* Copyright (C) 2016 Gilles Poirier <glgpoirier@gmail.com>
|
|
|
|
|
* Copyright (C) 2018 charlene Benke <charlie@patas-monkey.com>
|
2024-03-13 00:29:48 +01:00
|
|
|
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
2018-05-28 16:38:11 +02:00
|
|
|
|
2007-01-25 21:12:45 +01:00
|
|
|
*
|
|
|
|
|
* 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
|
2013-01-16 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2007-01-25 21:12:45 +01:00
|
|
|
* (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
|
2019-09-23 21:55:30 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
* or see https://www.gnu.org/
|
2007-01-25 21:12:45 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2011-10-24 12:59:44 +02:00
|
|
|
* \file htdocs/core/lib/fichinter.lib.php
|
2024-01-13 19:48:20 +01:00
|
|
|
* \brief Ensemble de functions de base pour le module fichinter
|
2008-12-11 21:12:44 +01:00
|
|
|
* \ingroup fichinter
|
|
|
|
|
*/
|
2007-01-25 21:12:45 +01:00
|
|
|
|
2012-02-04 10:48:47 +01:00
|
|
|
/**
|
|
|
|
|
* Prepare array with list of tabs
|
|
|
|
|
*
|
|
|
|
|
* @param Object $object Object related to tabs
|
2014-08-30 05:30:37 +02:00
|
|
|
* @return array Array of tabs to show
|
2012-02-04 10:48:47 +01:00
|
|
|
*/
|
2010-12-19 12:05:07 +01:00
|
|
|
function fichinter_prepare_head($object)
|
2007-01-25 21:12:45 +01:00
|
|
|
{
|
2016-01-23 17:19:34 +01:00
|
|
|
global $db, $langs, $conf, $user;
|
2008-12-11 21:12:44 +01:00
|
|
|
$langs->load("fichinter");
|
|
|
|
|
|
|
|
|
|
$h = 0;
|
|
|
|
|
$head = array();
|
|
|
|
|
|
2014-09-18 21:18:25 +02:00
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/fichinter/card.php?id='.$object->id;
|
2020-05-17 13:34:16 +02:00
|
|
|
$head[$h][1] = $langs->trans("Intervention");
|
2008-12-11 21:12:44 +01:00
|
|
|
$head[$h][2] = 'card';
|
|
|
|
|
$h++;
|
2012-12-01 15:45:05 +01:00
|
|
|
|
2023-11-27 11:39:32 +01:00
|
|
|
if (!getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
|
|
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
|
2012-07-02 19:30:37 +02:00
|
|
|
$head[$h][1] = $langs->trans('InterventionContact');
|
2021-02-23 22:03:23 +01:00
|
|
|
if ($nbContact > 0) {
|
|
|
|
|
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
|
|
|
|
|
}
|
2012-07-02 19:30:37 +02:00
|
|
|
$head[$h][2] = 'contact';
|
2012-03-17 16:05:58 +01:00
|
|
|
$h++;
|
|
|
|
|
}
|
2008-12-11 21:12:44 +01:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
// Show more tabs from modules
|
|
|
|
|
// Entries must be declared in modules descriptor with line
|
|
|
|
|
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
|
|
|
|
// $this->tabs = array('entity:-tabname); to remove a tab
|
2022-09-22 14:06:50 +02:00
|
|
|
complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention', 'add', 'core');
|
2012-12-01 15:45:05 +01:00
|
|
|
|
2016-02-01 16:09:58 +01:00
|
|
|
// Tab to link resources
|
2022-06-09 22:10:51 +02:00
|
|
|
if (isModEnabled('resource')) {
|
2016-12-09 15:59:31 +01:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
|
2019-09-20 17:58:22 +02:00
|
|
|
$objectres = new Dolresource($db);
|
|
|
|
|
$linked_resources = $objectres->getElementResources('fichinter', $object->id);
|
2023-12-04 12:05:28 +01:00
|
|
|
$nbResource = (is_array($linked_resources) ? count($linked_resources) : 0);
|
2019-09-20 17:58:22 +02:00
|
|
|
// if (is_array($objectres->available_resources))
|
|
|
|
|
// {
|
2021-02-23 22:03:23 +01:00
|
|
|
// foreach ($objectres->available_resources as $modresources => $resources)
|
2019-09-20 17:58:22 +02:00
|
|
|
// {
|
|
|
|
|
// $resources=(array) $resources; // To be sure $resources is an array
|
|
|
|
|
// foreach($resources as $resource_obj)
|
|
|
|
|
// {
|
|
|
|
|
// $linked_resources = $object->getElementResources('fichinter', $object->id, $resource_obj);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2018-08-15 17:34:35 +02:00
|
|
|
|
2021-02-23 22:03:23 +01:00
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id;
|
2016-02-01 16:09:58 +01:00
|
|
|
$head[$h][1] = $langs->trans("Resources");
|
2021-02-23 22:03:23 +01:00
|
|
|
if ($nbResource > 0) {
|
|
|
|
|
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbResource.'</span>';
|
|
|
|
|
}
|
2016-02-01 16:09:58 +01:00
|
|
|
$head[$h][2] = 'resource';
|
|
|
|
|
$h++;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-27 11:39:32 +01:00
|
|
|
if (!getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$nbNote = 0;
|
2021-02-23 22:03:23 +01:00
|
|
|
if (!empty($object->note_private)) {
|
|
|
|
|
$nbNote++;
|
|
|
|
|
}
|
|
|
|
|
if (!empty($object->note_public)) {
|
|
|
|
|
$nbNote++;
|
|
|
|
|
}
|
2020-10-31 14:32:18 +01:00
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id;
|
|
|
|
|
$head[$h][1] = $langs->trans('Notes');
|
2021-02-23 22:03:23 +01:00
|
|
|
if ($nbNote > 0) {
|
|
|
|
|
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
|
|
|
|
}
|
2020-10-31 14:32:18 +01:00
|
|
|
$head[$h][2] = 'note';
|
|
|
|
|
$h++;
|
|
|
|
|
}
|
2008-12-11 21:12:44 +01:00
|
|
|
|
2013-07-20 09:07:10 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
2020-10-31 14:32:18 +01:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
2020-04-10 10:59:32 +02:00
|
|
|
$upload_dir = $conf->ficheinter->dir_output."/".dol_sanitizeFileName($object->ref);
|
2019-01-27 11:55:16 +01:00
|
|
|
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
2020-10-31 14:32:18 +01:00
|
|
|
$nbLinks = Link::count($db, $object->element, $object->id);
|
2010-12-19 12:05:07 +01:00
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id;
|
2009-01-21 18:39:21 +01:00
|
|
|
$head[$h][1] = $langs->trans("Documents");
|
2021-02-23 22:03:23 +01:00
|
|
|
if (($nbFiles + $nbLinks) > 0) {
|
|
|
|
|
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
|
|
|
|
|
}
|
2009-01-21 18:39:21 +01:00
|
|
|
$head[$h][2] = 'documents';
|
|
|
|
|
$h++;
|
|
|
|
|
|
2023-03-12 13:55:33 +01:00
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/fichinter/agenda.php?id='.$object->id;
|
|
|
|
|
$head[$h][1] = $langs->trans('Events');
|
2024-03-13 00:29:48 +01:00
|
|
|
if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
|
2023-03-12 13:55:33 +01:00
|
|
|
$nbEvent = 0;
|
|
|
|
|
// Enable caching of thirdparty count actioncomm
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
|
|
|
|
|
$cachekey = 'count_events_fichinter_'.$object->id;
|
|
|
|
|
$dataretrieved = dol_getcache($cachekey);
|
|
|
|
|
if (!is_null($dataretrieved)) {
|
|
|
|
|
$nbEvent = $dataretrieved;
|
|
|
|
|
} else {
|
|
|
|
|
$sql = "SELECT COUNT(id) as nb";
|
|
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm";
|
|
|
|
|
$sql .= " WHERE fk_element = ".((int) $object->id);
|
|
|
|
|
$sql .= " AND elementtype = 'fichinter'";
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if ($resql) {
|
|
|
|
|
$obj = $db->fetch_object($resql);
|
|
|
|
|
$nbEvent = $obj->nb;
|
|
|
|
|
} else {
|
|
|
|
|
dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
|
|
|
|
|
}
|
|
|
|
|
dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$head[$h][1] .= '/';
|
|
|
|
|
$head[$h][1] .= $langs->trans("Agenda");
|
|
|
|
|
if ($nbEvent > 0) {
|
|
|
|
|
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbEvent.'</span>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$head[$h][2] = 'agenda';
|
2007-06-22 14:36:50 +02:00
|
|
|
$h++;
|
2008-12-11 21:12:44 +01:00
|
|
|
|
2022-09-22 14:06:50 +02:00
|
|
|
complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention', 'add', 'external');
|
|
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention', 'remove');
|
2012-12-01 15:45:05 +01:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
return $head;
|
2007-01-25 21:12:45 +01:00
|
|
|
}
|
|
|
|
|
|
2013-05-18 13:00:36 +02:00
|
|
|
/**
|
2024-01-13 19:48:20 +01:00
|
|
|
* Return array head with list of tabs to view object information.
|
2013-05-18 13:00:36 +02:00
|
|
|
*
|
|
|
|
|
* @return array head array with tabs
|
|
|
|
|
*/
|
|
|
|
|
function fichinter_admin_prepare_head()
|
|
|
|
|
{
|
2022-10-20 12:30:10 +02:00
|
|
|
global $langs, $conf, $user, $db;
|
|
|
|
|
|
|
|
|
|
$extrafields = new ExtraFields($db);
|
|
|
|
|
$extrafields->fetch_name_optionals_label('fichinter');
|
|
|
|
|
$extrafields->fetch_name_optionals_label('fichinterdet');
|
2013-05-18 13:00:36 +02:00
|
|
|
|
|
|
|
|
$h = 0;
|
|
|
|
|
$head = array();
|
|
|
|
|
|
|
|
|
|
$head[$h][0] = DOL_URL_ROOT."/admin/fichinter.php";
|
|
|
|
|
$head[$h][1] = $langs->trans("Interventions");
|
|
|
|
|
$head[$h][2] = 'ficheinter';
|
|
|
|
|
$h++;
|
|
|
|
|
|
|
|
|
|
// Show more tabs from modules
|
|
|
|
|
// Entries must be declared in modules descriptor with line
|
|
|
|
|
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
|
|
|
|
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
2019-01-27 11:55:16 +01:00
|
|
|
complete_head_from_modules($conf, $langs, null, $head, $h, 'fichinter_admin');
|
2013-05-18 13:00:36 +02:00
|
|
|
|
|
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinter_extrafields.php';
|
|
|
|
|
$head[$h][1] = $langs->trans("ExtraFields");
|
2022-10-20 12:30:10 +02:00
|
|
|
$nbExtrafields = $extrafields->attributes['fichinter']['count'];
|
|
|
|
|
if ($nbExtrafields > 0) {
|
|
|
|
|
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
|
|
|
|
|
}
|
2020-10-31 14:32:18 +01:00
|
|
|
$head[$h][2] = 'attributes';
|
|
|
|
|
$h++;
|
2013-05-18 13:00:36 +02:00
|
|
|
|
2014-08-26 11:50:02 +02:00
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinterdet_extrafields.php';
|
2014-09-03 09:55:06 +02:00
|
|
|
$head[$h][1] = $langs->trans("ExtraFieldsLines");
|
2022-10-20 12:30:10 +02:00
|
|
|
$nbExtrafields = $extrafields->attributes['fichinterdet']['count'];
|
|
|
|
|
if ($nbExtrafields > 0) {
|
|
|
|
|
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
|
|
|
|
|
}
|
2020-10-31 14:32:18 +01:00
|
|
|
$head[$h][2] = 'attributesdet';
|
|
|
|
|
$h++;
|
2014-08-26 11:50:02 +02:00
|
|
|
|
2019-01-27 11:55:16 +01:00
|
|
|
complete_head_from_modules($conf, $langs, null, $head, $h, 'fichinter_admin', 'remove');
|
2013-05-18 13:00:36 +02:00
|
|
|
|
2022-10-20 12:30:10 +02:00
|
|
|
return $head;
|
2013-05-18 13:00:36 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-31 22:25:11 +02:00
|
|
|
/**
|
|
|
|
|
* Prepare array with list of tabs
|
|
|
|
|
*
|
|
|
|
|
* @param Object $object Object related to tabs
|
|
|
|
|
* @return array Array of tabs to show
|
|
|
|
|
*/
|
2018-08-15 17:34:35 +02:00
|
|
|
function fichinter_rec_prepare_head($object)
|
2018-05-28 16:38:11 +02:00
|
|
|
{
|
|
|
|
|
global $langs, $conf; //, $user;
|
2018-08-15 17:34:35 +02:00
|
|
|
|
2018-05-28 16:38:11 +02:00
|
|
|
$h = 0;
|
|
|
|
|
$head = array();
|
2018-08-15 17:34:35 +02:00
|
|
|
|
2018-05-28 16:38:11 +02:00
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$object->id;
|
|
|
|
|
$head[$h][1] = $langs->trans("CardFichinter");
|
|
|
|
|
$head[$h][2] = 'card';
|
|
|
|
|
$h++;
|
|
|
|
|
|
|
|
|
|
complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention-rec');
|
|
|
|
|
|
2019-01-27 11:55:16 +01:00
|
|
|
complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention-rec', 'remove');
|
2018-05-28 16:38:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
return $head;
|
|
|
|
|
}
|