dolibarr/htdocs/comm/action/info.php
MDW e23059184f
Qual: Phan/fix for notices seen in #37875 & ci (#37876)
* Qual: Fix phan notice

Fix PhanTypeMismatchArgumentNullable: Argument 1 ($stringtosanitize) is $origin of type ?\CommonObject|?\CommonTrigger|?\DolDeprecationHandler|?array{}|?non-empty-array<mixed,mixed>|?non-empty-string|?string but \DoliDB::sanitize() takes string defined at htdocs/core/db/DoliDB.class.php:187 (expected type to be non-nullable)

* Qual: Fix PhanPluginSuspiciousParamPosition

# Qual: Fix PhanPluginSuspiciousParamPosition

Fix notices by using intermediate variable name that matches the parameter of the called function
where the original parameter name matches the name of a parameter in another position

* Qual: Fix PhanTypeMismatchArgument

# Qual: Fix PhanTypeMismatchArgument

Fix PhanTypeMismatchArgument: Argument 1 ($stringtosanitize) is $local of type int but \DoliDB::sanitize() takes string
in get_localtax_by_third($local) where local is an int already.
So use cast to (int) instead.
Also limit typehint of local to 1 and 2 which are the only allowed values

* Qual: Fix PhanTypeMismatchArgument in cloneCategories()

# Qual: Fix PhanTypeMismatchArgument in cloneCategories()

The argument $toId which is already an integer was passed to DoliDB::sanitize() which expects a string.
So casting to (int) instead to fix this.

* Qual: Ignore complex PhanUndeclaredStaticProperty

# Qual: Ignore complex PhanUndeclaredStaticProperty

Accessing static property provided by a trait on some classes - ignore the phan notice

* Qual: Phan ignore PhanUndeclaredMethod for getPossibleLevels

* Qual: Add typing hints for phan

* Qual: Add typehint for phan

* Qual: Remove redundant semicolon in objectonoff.php

# Qual: Remove redundant semicolon in objectonoff.php

Removed an unnecessary semicolon in the error handling loop of objectonoff.php.

* Qual: Fix PhanPossiblyUndeclaredGlobalVariable

* Qual: Ignore PhanPossiblyUndeclaredGlobalVariable
2026-04-15 17:59:06 +02:00

163 lines
6.8 KiB
PHP

<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2023 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025-2026 MDW <mdeweerd@users.noreply.github.com>
*
* 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/comm/action/info.php
* \ingroup agenda
* \brief Page des information d'une action
*/
// Load Dolibarr environment
require '../../main.inc.php';
/**
* @var Conf $conf
* @var DoliDB $db
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
*/
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
if (isModEnabled('project')) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
}
// Load translation files required by the page
$langs->load("commercial");
$id = GETPOSTINT('id');
$socid = 0;
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$hookmanager->initHooks(array('actioncard', 'globalcard'));
// Security check
if ($user->socid > 0) {
$action = '';
$socid = $user->socid;
}
$result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id');
if ($user->socid && $socid) {
$result = restrictedArea($user, 'societe', $socid);
}
$object = new ActionComm($db);
$object->fetch($id);
$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'));
/*
* View
*/
$form = new Form($db);
$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
llxHeader('', $langs->trans("Agenda"), $help_url);
$object->info($object->id);
$head = actions_prepare_head($object);
print dol_get_fiche_head($head, 'info', $langs->trans("Action"), -1, 'action');
// Link to other agenda views
$linkback = '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">';
$linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="pictoactionview pictofixedwidth"');
$linkback .= '<span class="hideonsmartphone">'.$langs->trans("BackToList").'</span>';
$linkback .= '</a>';
$linkback .= '</li>';
$linkback .= '<li class="noborder litext">';
$linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=show_month&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
$linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview pictofixedwidth"');
$linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewCal").'</span>';
$linkback .= '</a>';
$linkback .= '</li>';
$linkback .= '<li class="noborder litext">';
$linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=show_week&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
$linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview pictofixedwidth"');
$linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewWeek").'</span>';
$linkback .= '</a>';
$linkback .= '</li>';
$linkback .= '<li class="noborder litext">';
$linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
$linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview pictofixedwidth"');
$linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewDay").'</span>';
$linkback .= '</a>';
$linkback .= '</li>';
$linkback .= '<li class="noborder litext">';
$linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?mode=show_peruser&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
$linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview pictofixedwidth"');
$linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewPerUser").'</span>';
$linkback .= '</a>';
// Add more views from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action);
if (empty($reshook)) {
$linkback .= $hookmanager->resPrint;
} elseif ($reshook > 1) {
$linkback = $hookmanager->resPrint;
}
$morehtmlref = '<div class="refidno">';
// Project
if (isModEnabled('project')) {
$langs->load("projects");
//$morehtmlref .= '<br>';
if (0) { // @phpstan-ignore-line
$morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
}
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
} else {
if (!empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref .= $proj->getNomUrl(1);
if ($proj->title) {
$morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
}
}
}
}
$morehtmlref .= '</div>';
dol_banner_tab($object, 'id', $linkback, ($user->socid ? 0 : 1), 'id', 'ref', $morehtmlref);
print '<div class="underbanner clearboth"></div>';
print '<br>';
print '<table width="100%"><tr><td>';
dol_print_object_info($object);
print '</td></tr></table>';
print dol_get_fiche_end();
// End of page
llxFooter();
$db->close();