Qual: Fix phan notices (ticket,variants,webhook)

This commit is contained in:
MDW 2025-02-19 22:04:38 +01:00
parent a2bf0b5b02
commit 469ced0a8d
No known key found for this signature in database
22 changed files with 149 additions and 154 deletions

View File

@ -9,9 +9,9 @@
*/
return [
// # Issue statistics:
// PhanTypeMismatchArgument : 1470+ occurrences
// PhanTypeMismatchArgument : 1430+ occurrences
// PhanUndeclaredProperty : 500+ occurrences
// PhanTypeMismatchArgumentNullable : 320+ occurrences
// PhanTypeMismatchArgumentNullable : 310+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 170+ occurrences
// PhanTypeMismatchProperty : 120+ occurrences
// PhanPluginUnknownArrayMethodParamType : 110+ occurrences
@ -25,14 +25,14 @@ return [
// PhanUndeclaredConstant : 15+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 10+ occurrences
// PhanUndeclaredMethod : 9 occurrences
// PhanTypeComparisonFromArray : 8 occurrences
// PhanTypeComparisonFromArray : 7 occurrences
// PhanPluginDuplicateExpressionBinaryOp : 6 occurrences
// PhanTypeArraySuspiciousNull : 6 occurrences
// PhanParamTooMany : 5 occurrences
// PhanPluginDuplicateArrayKey : 4 occurrences
// PhanEmptyFQSENInClasslike : 3 occurrences
// PhanInvalidFQSENInClasslike : 3 occurrences
// PhanPluginSuspiciousParamPosition : 3 occurrences
// PhanPluginSuspiciousParamPosition : 2 occurrences
// PhanTypeMismatchDimAssignment : 2 occurrences
// PhanTypeSuspiciousStringExpression : 2 occurrences
// PhanAccessMethodProtected : 1 occurrence
@ -643,19 +643,12 @@ return [
'htdocs/takepos/index.php' => ['PhanPluginUndeclaredVariableIsset'],
'htdocs/takepos/invoice.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'],
'htdocs/takepos/split.php' => ['PhanPluginUndeclaredVariableIsset'],
'htdocs/ticket/agenda.php' => ['PhanTypeMismatchArgument'],
'htdocs/ticket/card.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/ticket/class/actions_ticket.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/ticket/card.php' => ['PhanUndeclaredProperty'],
'htdocs/ticket/class/actions_ticket.class.php' => ['PhanUndeclaredProperty'],
'htdocs/ticket/class/api_tickets.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'],
'htdocs/ticket/class/cticketcategory.class.php' => ['PhanUndeclaredProperty'],
'htdocs/ticket/class/ticket.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/ticket/class/ticketstats.class.php' => ['PhanTypeMismatchArgument'],
'htdocs/ticket/class/ticket.class.php' => ['PhanUndeclaredProperty'],
'htdocs/ticket/contact.php' => ['PhanTypeMismatchArgument'],
'htdocs/ticket/document.php' => ['PhanTypeMismatchArgument'],
'htdocs/ticket/index.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/ticket/list.php' => ['PhanTypeMismatchArgument'],
'htdocs/ticket/messaging.php' => ['PhanTypeMismatchArgument'],
'htdocs/ticket/stats/index.php' => ['PhanTypeMismatchArgument'],
'htdocs/user/bank.php' => ['PhanTypeMismatchArgument'],
'htdocs/user/card.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchProperty'],
'htdocs/user/class/api_users.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchProperty'],
@ -666,19 +659,12 @@ return [
'htdocs/user/group/card.php' => ['PhanTypeMismatchArgument'],
'htdocs/user/list.php' => ['PhanTypeMismatchArgument'],
'htdocs/user/param_ihm.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'],
'htdocs/variants/ajax/get_attribute_values.php' => ['PhanTypeComparisonFromArray'],
'htdocs/variants/card.php' => ['PhanTypeMismatchArgument'],
'htdocs/variants/class/ProductAttribute.class.php' => ['PhanTypeMismatchArgumentNullable'],
'htdocs/variants/class/ProductCombination.class.php' => ['PhanPluginSuspiciousParamPosition', 'PhanTypeMismatchArgument'],
'htdocs/variants/combinations.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchProperty'],
'htdocs/variants/list.php' => ['PhanTypeMismatchArgument'],
'htdocs/variants/tpl/productattributevalueline_edit.tpl.php' => ['PhanUndeclaredProperty'],
'htdocs/variants/tpl/productattributevalueline_view.tpl.php' => ['PhanUndeclaredProperty'],
'htdocs/viewimage.php' => ['PhanUndeclaredMethod'],
'htdocs/webhook/class/api_webhook.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'],
'htdocs/webhook/class/target.class.php' => ['PhanUndeclaredMethod'],
'htdocs/webhook/target_card.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'],
'htdocs/webhook/target_list.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/webhook/target_card.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/webportal/admin/setup.php' => ['PhanTypeMismatchArgument'],
'htdocs/webportal/class/html.formcardwebportal.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredProperty'],
'htdocs/webportal/class/html.formlistwebportal.class.php' => ['PhanTypeInvalidDimOffset', 'PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],

View File

@ -313,7 +313,7 @@ class InterfaceTicketEmail extends DolibarrTriggers
/**
* Return if contact source is external or thirdparty
*
* @param array{source:string,id:int,rowid:int,email:string,civility:string,firstname:string,lastname:string,labeltype:string,libelle:string,socid:int,code:string,status:int,statuscontact:string,fk_c_typecontact:string,phone:string,phone_mobile:string,nom:string} $contact
* @param array{source:string,id:int,rowid:int,email:string,civility:string,firstname:string,lastname:string,labeltype:string,libelle:string,socid:int,code:string,status:int,statuscontact:int,fk_c_typecontact:int,phone:string,phone_mobile:string,phone_perso?:string,nom:string} $contact
* @return bool
*/
static function ($contact) {

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) - 2013-2016 Jean-François FERRY <hello@librethic.io>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2013-2016 Jean-François FERRY <hello@librethic.io>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -214,7 +214,7 @@ if (isModEnabled("societe")) {
if ($action != 'editcustomer' && $permissiontoadd) {
$morehtmlref .= '<a class="editfielda" href="'.$url_page_current.'?action=editcustomer&token='.newToken().'&track_id='.$object->track_id.'">'.img_edit($langs->transnoentitiesnoconv('SetThirdParty'), 0).'</a> ';
}
$morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1);
$morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, (string) $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1);
}
// Project
@ -226,7 +226,7 @@ if (isModEnabled('project')) {
if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
}
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
$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)) {
$morehtmlref .= '<br>';

View File

@ -6,7 +6,7 @@
* Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2022-2023 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2023 Benjamin Falière <benjamin.faliere@altairis.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Irvine FLEITH <irvine.fleith@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -509,7 +509,7 @@ if (empty($reshook)) {
// Set progress status
if ($action == 'set_progression' && $user->hasRight('ticket', 'write')) {
if ($object->fetch(GETPOSTINT('id'), '', GETPOST('track_id', 'alpha')) >= 0) {
$result = $object->setProgression(GETPOST('progress', 'alpha'));
$result = $object->setProgression(GETPOSTINT('progress'));
$url = 'card.php?track_id=' . $object->track_id;
header("Location: " . $url);
@ -985,7 +985,7 @@ if ($action == 'create' || $action == 'presend') {
if ($action != 'editcustomer' && $permissiontoedit) {
$morehtmlref .= '<a class="editfielda" href="'.$url_page_current.'?action=editcustomer&token='.newToken().'&track_id='.$object->track_id.'">'.img_edit($langs->transnoentitiesnoconv('SetThirdParty'), 0).'</a> ';
}
$morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1);
$morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, (string) $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1);
if (!empty($object->socid)) {
$morehtmlref .= ' - <a href="'.DOL_URL_ROOT.'/ticket/list.php?socid='.$object->socid.'&sortfield=t.datec&sortorder=desc'.(getDolGlobalBool('TICKET_CLIENT_OTHER_TICKET_ONLY_OPEN') ? '&search_fk_statut[]=openall' : '').'">'.img_picto($langs->trans("Tickets"), 'ticket', 'class="pictofixedwidth"').' '.$langs->trans("TicketHistory").'</a>';
}
@ -1001,7 +1001,7 @@ if ($action == 'create' || $action == 'presend') {
if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
}
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
$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)) {
$object->fetchProject();
@ -1355,81 +1355,82 @@ if ($action == 'create' || $action == 'presend') {
foreach (array('internal', 'external') as $source) {
$tmpobject = $object;
$tab = $tmpobject->listeContact(-1, $source);
'@phan-var-force array<array{source:string,id:int,rowid:int,email:string,civility:string,firstname:string,lastname:string,labeltype:string,libelle:string,socid:int,code:string,status:int,statuscontact:string,fk_c_typecontact:string,phone:string,phone_mobile:string,phone_perso?:string,nom:string}> $tab';
$num = is_array($tab) ? 0 : count($tab);
// '@phan-var-force array<array{source:string,id:int,rowid:int,email:string,civility:string,firstname:string,lastname:string,labeltype:string,libelle:string,socid:int,code:string,status:int,statuscontact:int,fk_c_typecontact:string,phone:string,phone_mobile:string,phone_perso?:string,nom:string}> $tab';
$num = is_array($tab) ? count($tab) : 0;
$i = 0;
foreach (array_keys($tab) as $i) {
$tab_i = &$tab[$i];
$var = !$var;
print '<div class="tagtr '.($var ? 'pair' : 'impair').'">';
print '<div class="tagtd left">';
if ($tab[$i]['source'] == 'internal') {
if ($tab_i['source'] == 'internal') {
echo $langs->trans("User");
}
if ($tab[$i]['source'] == 'external') {
if ($tab_i['source'] == 'external') {
echo $langs->trans("ThirdPartyContact");
}
print '</div>';
print '<div class="tagtd left">';
if ($tab[$i]['socid'] > 0) {
$companystatic->fetch($tab[$i]['socid']);
if ($tab_i['socid'] > 0) {
$companystatic->fetch($tab_i['socid']);
echo $companystatic->getNomUrl(-1);
}
if ($tab[$i]['socid'] < 0) {
if ($tab_i['socid'] < 0) {
echo getDolGlobalString('MAIN_INFO_SOCIETE_NOM');
}
if (!$tab[$i]['socid']) {
if (!$tab_i['socid']) {
echo '&nbsp;';
}
print '</div>';
print '<div class="tagtd">';
if ($tab[$i]['source'] == 'internal') {
if ($userstatic->fetch($tab[$i]['id'])) {
if ($tab_i['source'] == 'internal') {
if ($userstatic->fetch($tab_i['id'])) {
print $userstatic->getNomUrl(-1);
}
}
if ($tab[$i]['source'] == 'external') {
if ($contactstatic->fetch($tab[$i]['id'])) {
if ($tab_i['source'] == 'external') {
if ($contactstatic->fetch($tab_i['id'])) {
print $contactstatic->getNomUrl(-1);
}
}
print ' </div>
<div class="tagtd">' . $tab[$i]['libelle'].'</div>';
<div class="tagtd">' . $tab_i['libelle'].'</div>';
print '<div class="tagtd">';
print dol_print_phone($tab[$i]['phone'], '', 0, 0, 'AC_TEL').'<br>';
print dol_print_phone($tab_i['phone'], '', 0, 0, 'AC_TEL').'<br>';
if (!empty($tab[$i]['phone_perso'])) {
if (array_key_exists('phone_perso', $tab_i) && !empty($tab_i['phone_perso'])) {
//print img_picto($langs->trans('PhonePerso'),'object_phoning.png','',0,0,0).' ';
print '<br>'.dol_print_phone($tab[$i]['phone_perso'], '', 0, 0, 'AC_TEL').'<br>';
print '<br>'.dol_print_phone((string) $tab_i['phone_perso'], '', 0, 0, 'AC_TEL').'<br>';
}
if (!empty($tab[$i]['phone_mobile'])) {
if (!empty($tab_i['phone_mobile'])) {
//print img_picto($langs->trans('PhoneMobile'),'object_phoning.png','',0,0,0).' ';
print dol_print_phone($tab[$i]['phone_mobile'], '', 0, 0, 'AC_TEL').'<br>';
print dol_print_phone($tab_i['phone_mobile'], '', 0, 0, 'AC_TEL').'<br>';
}
print '</div>';
print '<div class="tagtd center">';
if ($object->status >= 0) {
echo '<a href="contact.php?track_id='.$object->track_id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">';
echo '<a href="contact.php?track_id='.$object->track_id.'&amp;action=swapstatut&amp;ligne='.$tab_i['rowid'].'">';
}
if ($tab[$i]['source'] == 'internal') {
$userstatic->id = $tab[$i]['id'];
$userstatic->lastname = $tab[$i]['lastname'];
$userstatic->firstname = $tab[$i]['firstname'];
echo $userstatic->LibStatut($tab[$i]['statuscontact'], 3);
if ($tab_i['source'] == 'internal') {
$userstatic->id = $tab_i['id'];
$userstatic->lastname = $tab_i['lastname'];
$userstatic->firstname = $tab_i['firstname'];
echo $userstatic->LibStatut($tab_i['statuscontact'], 3);
}
if ($tab[$i]['source'] == 'external') {
$contactstatic->id = $tab[$i]['id'];
$contactstatic->lastname = $tab[$i]['lastname'];
$contactstatic->firstname = $tab[$i]['firstname'];
echo $contactstatic->LibStatut($tab[$i]['statuscontact'], 3);
if ($tab_i['source'] == 'external') {
$contactstatic->id = $tab_i['id'];
$contactstatic->lastname = $tab_i['lastname'];
$contactstatic->firstname = $tab_i['firstname'];
echo $contactstatic->LibStatut($tab_i['statuscontact'], 3);
}
if ($object->status >= 0) {
echo '</a>';
@ -1642,7 +1643,7 @@ if ($action == 'create' || $action == 'presend') {
$codelang = $object->thirdparty->default_lang;
}
print $formfile->showdocuments('ticket', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', 0, '', $codelang);
print $formfile->showdocuments('ticket', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $codelang);
// Show links to link elements
$tmparray = $form->showLinkToObjectBlock($object, array(), array('ticket'), 1);

View File

@ -3,7 +3,7 @@
* Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
* Copyright (C) 2024 Destailleur Laurent <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 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
@ -263,9 +263,9 @@ class ActionsTicket extends CommonHookActions
/**
* View html list of message for ticket
*
* @param boolean $show_private Show private messages
* @param boolean $show_user Show user who make action
* @param Ticket $object Object ticket
* @param bool $show_private Show private messages
* @param bool $show_user Show user who make action
* @param Ticket $object Object ticket
* @return void
*/
public function viewTicketMessages($show_private, $show_user, $object)
@ -412,9 +412,9 @@ class ActionsTicket extends CommonHookActions
/**
* View list of message for ticket with timeline display
*
* @param boolean $show_private Show private messages
* @param boolean $show_user Show user who make action
* @param Ticket $object Object ticket
* @param bool $show_private Show private messages
* @param bool $show_user Show user who make action
* @param Ticket $object Object ticket
* @return void
*/
public function viewTicketTimelineMessages($show_private, $show_user, Ticket $object)

View File

@ -217,7 +217,7 @@ class Ticket extends CommonObject
public $cache_types_tickets;
/**
* @var array<int,array{private:0|1|'0'|'1',fk_user_author:int,fk_contact_author?:int,message:string}> cache msgs ticket
* @var array<int,array{private:0|1|'0'|'1',fk_user_author:int,fk_contact_author?:string,message:string}> cache msgs ticket // fk_contact_author is email, not key in the cache
*/
public $cache_msgs_ticket;
@ -852,9 +852,9 @@ class Ticket extends CommonObject
if (is_array($filter)) {
foreach ($filter as $key => $value) {
if (strpos($key, 'date')) { // To allow $filter['YEAR(s.dated)']=>$year
$sql .= " AND ".$this->db->sanitize($key)." = '".$this->db->escape($value)."'";
$sql .= " AND ".$this->db->sanitize($key)." = '".$this->db->escape((string) $value)."'";
} elseif (($key == 't.fk_user_assign') || ($key == 't.type_code') || ($key == 't.category_code') || ($key == 't.severity_code') || ($key == 't.fk_soc')) {
$sql .= " AND ".$this->db->sanitize($key)." = '".$this->db->escape($value)."'";
$sql .= " AND ".$this->db->sanitize($key)." = '".$this->db->escape((string) $value)."'";
} elseif ($key == 't.fk_statut') {
if (is_array($value) && count($value) > 0) {
$sql .= " AND ".$this->db->sanitize($key)." IN (".$this->db->sanitize(implode(',', $value)).")";
@ -864,7 +864,7 @@ class Ticket extends CommonObject
} elseif ($key == 't.fk_contract') {
$sql .= " AND ".$this->db->sanitize($key).' = '.((int) $value);
} else {
$sql .= " AND ".$this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike($value))."%'";
$sql .= " AND ".$this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike((string) $value))."%'";
}
}
@ -1091,7 +1091,7 @@ class Ticket extends CommonObject
$sql .= " message=".(isset($this->message) ? "'".$this->db->escape($this->message)."'" : "null").",";
$sql .= " fk_statut=".(isset($this->status) ? (int) $this->status : "0").",";
$sql .= " resolution=".(isset($this->resolution) ? (int) $this->resolution : "null").",";
$sql .= " progress=".(isset($this->progress) ? "'".$this->db->escape($this->progress)."'" : "null").",";
$sql .= " progress=".(isset($this->progress) ? "'".$this->db->escape((string) $this->progress)."'" : "null").",";
$sql .= " timing=".(isset($this->timing) ? "'".$this->db->escape($this->timing)."'" : "null").",";
$sql .= " type_code=".(isset($this->type_code) ? "'".$this->db->escape($this->type_code)."'" : "null").",";
$sql .= " category_code=".(isset($this->category_code) ? "'".$this->db->escape($this->category_code)."'" : "null").",";
@ -2274,7 +2274,7 @@ class Ticket extends CommonObject
* Retrieve information about external contacts
*
* @param int $status Status of user or company
* @return array<int|array{source:string,id:int,rowid:int,email:string,civility:string,firstname:string,lastname:string,labeltype:string,libelle:string,socid:int,code:string,status:int,statuscontact:string,fk_c_typecontact:string,phone:string,phone_mobile:string,nom:string}>|int<-1,-1> Array with data : firstname, lastname, socid (-1 for internal users), email, code, libelle, status
* @return array<int|array{source:string,id:int,rowid:int,email:string,civility:string,firstname:string,lastname:string,labeltype:string,libelle:string,socid:int,code:string,status:int,statuscontact:int,fk_c_typecontact:int,phone:string,phone_mobile:string,phone_perso?:string,nom:string}>|int<-1,-1> Array with data : firstname, lastname, socid (-1 for internal users), email, code, libelle, status
*/
public function getInfosTicketExternalContact($status = -1)
{
@ -2345,7 +2345,7 @@ class Ticket extends CommonObject
* @param int $list 0:Return array contains all properties, 1:Return array contains just id
* @param string $code Filter on this code of contact type ('SHIPPING', 'BILLING', ...)
* @param int $status Status of user or company
* @return array<int|array{source:string,id:int,rowid:int,email:string,civility:string,firstname:string,lastname:string,labeltype:string,libelle:string,socid:int,code:string,status:int,statuscontact:string,fk_c_typecontact:string,phone:string,phone_mobile:string,nom:string}>|int<-1,-1> Array of array('email'=>..., 'lastname'=>...)
* @return array<int|array{source:string,id:int,rowid:int,email:string,civility:string,firstname:string,lastname:string,labeltype:string,libelle:string,socid:int,code:string,status:int,statuscontact:int,fk_c_typecontact:int,phone:string,phone_mobile:string,phone_perso?:string,nom:string}>|int<-1,-1> Array of array('email'=>..., 'lastname'=>...)
*/
public function listeContact($statusoflink = -1, $source = 'external', $list = 0, $code = '', $status = -1)
{
@ -2422,22 +2422,25 @@ class Ticket extends CommonObject
$labelType = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->type_contact_label);
$tab[$i] = array(
'source' => $obj->source,
'socid' => $obj->socid,
'id' => $obj->id,
'socid' => (int) $obj->socid,
'id' => (int) $obj->id,
'nom' => $obj->lastname, // For backward compatibility
'civility' => $obj->civility,
'lastname' => $obj->lastname,
'firstname' => $obj->firstname,
'email' => $obj->email,
'rowid' => $obj->rowid,
'rowid' => (int) $obj->rowid,
'code' => $obj->code,
'libelle' => $labelType, // deprecated, replaced with labeltype
'labeltype' => $labelType,
'status' => $obj->statuslink,
'statuscontact' => $obj->statuscontact,
'fk_c_type_contact' => $obj->fk_c_type_contact,
'statuscontact' => (int) $obj->statuscontact,
'fk_c_type_contact' => (int) $obj->fk_c_type_contact,
'phone' => $obj->phone,
'phone_mobile' => $obj->phone_mobile);
if ($source == 'external') {
$tab[$i]['phone_perso'] = $obj->phone_perso;
}
} else {
$tab[$i] = $obj->id;
}
@ -2695,7 +2698,7 @@ class Ticket extends CommonObject
$object->message = GETPOST("message", "restricthtml");
$object->private = GETPOST("private_message", "alpha");
$send_email = GETPOSTINT('send_email');
$send_email = (bool) GETPOSTINT('send_email');
// Copy attached files (saved into $_SESSION) as linked files to ticket. Return array with final name used.
$resarray = $object->copyFilesForTicket();

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2016 Jean-François Ferry <hello@librethic.io>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -125,7 +125,7 @@ class TicketStats extends Stats
{
$sql = "SELECT date_format(datec,'%m') as dm, sum(".$this->field.")";
$sql .= " FROM ".$this->from;
$sql .= " WHERE date_format(datec,'%Y') = '".$this->db->escape($year)."'";
$sql .= " WHERE date_format(datec,'%Y') = '".$this->db->escape((string) $year)."'";
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC');
@ -145,7 +145,7 @@ class TicketStats extends Stats
{
$sql = "SELECT date_format(datec,'%m') as dm, avg(".$this->field.")";
$sql .= " FROM ".$this->from;
$sql .= " WHERE date_format(datec,'%Y') = '".$this->db->escape($year)."'";
$sql .= " WHERE date_format(datec,'%Y') = '".$this->db->escape((string) $year)."'";
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC');

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2011-2016 Jean-François Ferry <hello@librethic.io>
* Copyright (C) 2011 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -262,7 +262,7 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) {
if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
}
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
$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)) {
$morehtmlref .= '<br>';

View File

@ -5,6 +5,7 @@
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013-2016 Jean-François Ferry <hello@librethic.io>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 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
@ -184,7 +185,7 @@ if ($object->id) {
if ($action != 'editcustomer' && $permissiontoadd) {
$morehtmlref .= '<a class="editfielda" href="'.$url_page_current.'?action=editcustomer&token='.newToken().'&track_id='.$object->track_id.'">'.img_edit($langs->transnoentitiesnoconv('SetThirdParty'), 0).'</a> ';
}
$morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1);
$morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, (string) $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1);
}
// Project
@ -196,7 +197,7 @@ if ($object->id) {
if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
}
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
$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)) {
$morehtmlref .= '<br>';

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2013-2016 Jean-François FERRY <hello@librethic.io>
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2021-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 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
@ -110,6 +110,7 @@ $param_year = 'DOLUSERCOOKIE_ticket_by_status_year';
$param_shownb = 'DOLUSERCOOKIE_ticket_by_status_shownb';
$param_showtot = 'DOLUSERCOOKIE_ticket_by_status_showtot';
$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
$showtot = 0;
if (in_array('DOLUSERCOOKIE_ticket_by_status', $autosetarray)) {
$endyear = GETPOSTINT($param_year);
$shownb = GETPOST($param_shownb, 'alpha');
@ -185,6 +186,7 @@ if ($user->socid > 0) {
}
$sql .= " GROUP BY t.fk_statut";
$dataseries = array();
$result = $db->query($sql);
if ($result) {
while ($objp = $db->fetch_object($result)) {
@ -217,7 +219,6 @@ if ($result) {
include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; // This define $badgeStatusX
$dataseries = array();
$colorseries = array();
$dataseries[] = array('label' => $langs->transnoentitiesnoconv($object->labelStatusShort[Ticket::STATUS_NOT_READ]), 'data' => round($tick['unread']));

View File

@ -5,7 +5,7 @@
* Copyright (C) 2019-2021 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2019-2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2023 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
@ -1111,7 +1111,7 @@ while ($i < $imaxinloop) {
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td'.($cssforfield ? ' class="'.$cssforfield.((preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) ? ' classfortooltip' : '').'"' : '');
if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) {
print ' title="'.dol_escape_htmltag($object->$key).'"';
print ' title="'.dol_escape_htmltag((string) $object->$key).'"';
}
print '>';
if ($key == 'fk_statut') {

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) - 2013-2016 Jean-François FERRY <hello@librethic.io>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
/* Copyright (C) 2013-2016 Jean-François FERRY <hello@librethic.io>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -211,7 +211,7 @@ if (isModEnabled("societe")) {
if ($action != 'editcustomer' && $permissiontoadd) {
$morehtmlref .= '<a class="editfielda" href="'.$url_page_current.'?action=editcustomer&token='.newToken().'&track_id='.$object->track_id.'">'.img_edit($langs->transnoentitiesnoconv('SetThirdParty'), 0).'</a> ';
}
$morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1);
$morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, (string) $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1);
}
}
@ -224,7 +224,7 @@ if (isModEnabled('project')) {
if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
}
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
$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);

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2019 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -181,7 +181,7 @@ print '</td></tr>';
// User
print '<tr><td class="left">'.$langs->trans("CreatedBy").'</td><td class="left">';
print img_picto('', 'user', 'class="pictofixedwidth"');
print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
print $form->select_dolusers($userid, 'userid', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
// Status
print '<tr><td class="left">'.$langs->trans("Status").'</td><td class="left">';
$liststatus = $object->fields['fk_statut']['arrayofkeyval'];

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2022 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 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
@ -85,11 +86,4 @@ $prodattrval = new ProductAttributeValue($db);
$res = $prodattrval->fetchAllByProductAttribute($id, false, 1);
if ($res == -1) {
print json_encode(array(
'error' => 'Internal error'
));
exit();
}
print json_encode($res, JSON_PARTIAL_OUTPUT_ON_ERROR);

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2022 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2025 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
@ -50,7 +51,7 @@ $cancel = GETPOST('cancel', 'alpha');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'productattribute'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha');
$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
$lineid = GETPOST('lineid', 'alpha');
$lineid = GETPOSTINT('lineid');
// Security check
if (!isModEnabled('variants')) {
@ -124,14 +125,14 @@ if (empty($reshook)) {
// Action to move up and down lines of object
if ($action == 'up' && $permissiontoedit) {
$object->line_up(GETPOST('rowid'), false);
$object->line_up(GETPOSTINT('rowid'), false);
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid'));
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOSTINT('rowid'));
exit();
} elseif ($action == 'down' && $permissiontoedit) {
$object->line_down(GETPOST('rowid'), false);
$object->line_down(GETPOSTINT('rowid'), false);
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOST('rowid'));
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.GETPOSTINT('rowid'));
exit();
}

View File

@ -1445,8 +1445,8 @@ class ProductAttribute extends CommonObject
* @param int $i I
* @param int $dateSelector 1=Show also date range input fields
* @param Societe $seller Object of seller third party
* @param Societe $buyer Object of buyer third party
* @param int $selected Object line selected
* @param ?Societe $buyer Object of buyer third party
* @param int<0,1> $selected Object line selected
* @param ?Extrafields $extrafields Object of extrafields
* @param string $defaulttpldir Directory where to find the template (deprecated)
* @return void

View File

@ -632,7 +632,7 @@ class ProductCombination
* Retrieves the combination that matches the given features.
*
* @param int $prodid Id of parent product
* @param array<string,string> $features Format: [$attr] => $attr_val
* @param array<int|string,int|string> $features Format: [$attr] => $attr_val
* @return false|ProductCombination False if not found
*/
public function fetchByProductCombination2ValuePairs($prodid, array $features)
@ -985,23 +985,23 @@ class ProductCombination
$prodcomb2val = new ProductCombination2ValuePair($this->db);
//Retrieve all product combinations
$combinations = $this->fetchAllByFkProductParent($origProductId);
$combinationObjects = $this->fetchAllByFkProductParent($origProductId);
foreach ($combinations as $combination) {
$variations = array();
foreach ($combinationObjects as $combinationObject) {
$combinations = array();
foreach ($prodcomb2val->fetchByFkCombination($combination->id) as $tmp_pc2v) {
$variations[$tmp_pc2v->fk_prod_attr] = $tmp_pc2v->fk_prod_attr_val;
foreach ($prodcomb2val->fetchByFkCombination($combinationObject->id) as $tmp_pc2v) {
$combinations[$tmp_pc2v->fk_prod_attr] = $tmp_pc2v->fk_prod_attr_val;
}
$variation_price_percentage = $combination->variation_price_percentage;
$variation_price = $combination->variation_price;
$variation_price_percentage = $combinationObject->variation_price_percentage;
$variation_price = $combinationObject->variation_price;
if (getDolGlobalInt('PRODUIT_MULTIPRICES') && getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT') > 1) {
$variation_price_percentage = [ ];
$variation_price = [ ];
foreach ($combination->combination_price_levels as $productCombinationLevel) {
foreach ($combinationObject->combination_price_levels as $productCombinationLevel) {
$variation_price_percentage[$productCombinationLevel->fk_price_level] = $productCombinationLevel->variation_price_percentage;
$variation_price[$productCombinationLevel->fk_price_level] = $productCombinationLevel->variation_price;
}
@ -1010,11 +1010,11 @@ class ProductCombination
if ($this->createProductCombination(
$user,
$destProduct,
$variations,
$combinations,
array(),
$variation_price_percentage,
$variation_price,
$combination->variation_weight
$combinationObject->variation_weight
) < 0) {
return -1;
}

View File

@ -3,7 +3,7 @@
* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2022 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 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
@ -177,7 +177,7 @@ if (($action == 'add' || $action == 'create') && $usercancreate && empty($massac
//First, sanitize
foreach ($features as $feature) {
$explode = explode('-', $feature);
if ($prodattr->fetch($explode[0]) <= 0 || $prodattr_val->fetch($explode[1]) <= 0) {
if ($prodattr->fetch((int) $explode[0]) <= 0 || $prodattr_val->fetch((int) $explode[1]) <= 0) {
continue;
}
@ -196,7 +196,7 @@ if (($action == 'add' || $action == 'create') && $usercancreate && empty($massac
// sanit_feature is an array with 1 (and only 1) value per attribute.
// For example: Color->blue, Size->Small, Option->2
if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features)) {
$result = $prodcomb->createProductCombination($user, $object, $sanit_features, array(), $level_price_impact_percent, $level_price_impact, $weight_impact, $reference);
$result = $prodcomb->createProductCombination($user, $object, $sanit_features, array(), $level_price_impact_percent, $level_price_impact, (float) $weight_impact, $reference);
if ($result > 0) {
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
unset($_SESSION['addvariant_'.$object->id]);
@ -319,7 +319,7 @@ if (($action == 'add' || $action == 'create') && $usercancreate && empty($massac
// Update product variant ref
$product_child = new Product($db);
$product_child->fetch($prodcomb->fk_product_child);
$product_child->oldcopy = clone $product_child; // @phan-ignore-current-line PhanTypeMismatchProperty
$product_child->oldcopy = clone $product_child; // @phan-suppress-current-line PhanTypeMismatchProperty
$product_child->ref = $reference;
$result = $product_child->update($product_child->id, $user);
@ -438,7 +438,7 @@ if (!empty($id) || !empty($ref)) {
if (isModEnabled("product") && isModEnabled("service")) {
$typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service");
print '<tr><td class="titlefieldcreate">';
print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat) : $langs->trans('Type');
print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', (string) $object->type, $object, (int) $usercancreate, $typeformat) : $langs->trans('Type');
print '</td><td>';
print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat);
print '</td></tr>';
@ -517,7 +517,7 @@ if (!empty($id) || !empty($ref)) {
$toprint = array();
foreach ($features as $feature) {
$explode = explode('-', $feature);
if ($prodattr->fetch($explode[0]) <= 0 || $prodattr_val->fetch($explode[1]) <= 0) {
if ($prodattr->fetch((int) $explode[0]) <= 0 || $prodattr_val->fetch((int) $explode[1]) <= 0) {
continue;
}
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #ddd;">' . $prodattr->label.' : '.$prodattr_val->value .
@ -531,6 +531,8 @@ if (!empty($id) || !empty($ref)) {
$title = $langs->trans('EditProductCombination');
}
$prodattr_alljson = null;
$prodattr_all = null;
if ($action == 'add') {
$prodattr_all = $prodattr->fetchAll();

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2022 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Benjamin Falière <benjamin.faliere@altairis.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
@ -125,8 +125,8 @@ foreach ($object->fields as $key => $val) {
$visible = (int) dol_eval((string) $val['visible'], 1);
$arrayfields['t.'.$key] = array(
'label' => $val['label'],
'checked' => (($visible < 0) ? 0 : 1),
'enabled' => (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)),
'checked' => (($visible < 0) ? '0' : '1'),
'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)),
'position' => $val['position'],
'help' => isset($val['help']) ? $val['help'] : ''
);
@ -134,15 +134,15 @@ foreach ($object->fields as $key => $val) {
}
$arrayfields['nb_of_values'] = array(
'label' => $langs->trans('NbOfDifferentValues'),
'checked' => 1,
'enabled' => 1,
'checked' => '1',
'enabled' => '1',
'position' => 40,
'help' => ''
);
$arrayfields['nb_products'] = array(
'label' => $langs->trans('NbProducts'),
'checked' => 1,
'enabled' => 1,
'checked' => '1',
'enabled' => '1',
'position' => 50,
'help' => ''
);
@ -151,7 +151,6 @@ 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');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan
$permissiontoread = $user->hasRight('variants', 'read');
$permissiontoadd = $user->hasRight('variants', 'write');
@ -754,13 +753,13 @@ while ($i < $imaxinloop) {
if (!empty($arrayfields['t.' . $key]['checked'])) {
print '<td'.($cssforfield ? ' class="'.$cssforfield.((preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) ? ' classfortooltip' : '').'"' : '');
if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) {
print ' title="'.dol_escape_htmltag($object->$key).'"';
print ' title="'.dol_escape_htmltag((string) $object->$key).'"';
}
print '>';
if ($key == 'status') {
print $object->getLibStatut(5);
} elseif ($key == 'rowid') {
print $object->showOutputField($val, $key, $object->id, '');
print $object->showOutputField($val, $key, (string) $object->id, '');
} else {
print $object->showOutputField($val, $key, $object->$key, '');
}

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2022 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 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
@ -41,6 +42,12 @@
* @var int $num
*/
'
@phan-var-force string $action
@phan-var-force int $i
@phan-var-force int $num
';
// Protection to avoid direct call of template
if (empty($object) || !is_object($object)) {
print "Error, template page can't be called as URL";

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 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
@ -158,7 +158,7 @@ if (empty($reshook)) {
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
if ($action == 'set_thirdparty' && $permissiontoadd) {
$object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', '', 'date', '', $user, $triggermodname);
$object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', null, 'date', '', $user, $triggermodname);
}
if ($action == 'classin' && $permissiontoadd) {
$object->setProject(GETPOSTINT('projectid'));

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) ---Put here your own copyright and developer email---
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 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
@ -122,11 +122,11 @@ foreach ($object->fields as $key => $val) {
if (!empty($val['visible'])) {
$visible = (int) dol_eval((string) $val['visible'], 1);
$arrayfields['t.'.$key] = array(
'label'=>$val['label'],
'checked'=>(($visible < 0) ? 0 : 1),
'enabled'=>(abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)),
'position'=>$val['position'],
'help'=> isset($val['help']) ? $val['help'] : ''
'label' => $val['label'],
'checked' => (($visible < 0) ? '0' : '1'),
'enabled' => (string) (int) (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)),
'position' => $val['position'],
'help' => isset($val['help']) ? $val['help'] : ''
);
}
}
@ -563,7 +563,7 @@ foreach ($object->fields as $key => $val) {
} elseif ($key == 'lang') {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
$formadmin = new FormAdmin($db);
print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, null, 1, 0, 0, 'minwidth100imp maxwidth125', 2);
print $formadmin->select_language((isset($search[$key]) ? $search[$key] : ''), 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2);
} else {
print '<input type="text" class="flat maxwidth'.($val['type'] == 'integer' ? '50' : '75').'" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
}
@ -574,7 +574,7 @@ foreach ($object->fields as $key => $val) {
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields);
$parameters = array('arrayfields' => $arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
/*if (!empty($arrayfields['anotherfield']['checked'])) {
@ -621,7 +621,7 @@ foreach ($object->fields as $key => $val) {
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
/*if (!empty($arrayfields['anotherfield']['checked'])) {
@ -727,13 +727,13 @@ while ($i < $imaxinloop) {
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td'.($cssforfield ? ' class="'.$cssforfield.((preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) ? ' classfortooltip' : '').'"' : '');
if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) {
print ' title="'.dol_escape_htmltag($object->$key).'"';
print ' title="'.dol_escape_htmltag((string) $object->$key).'"';
}
print '>';
if ($key == 'status') {
print $object->getLibStatut(5);
} elseif ($key == 'rowid') {
print $object->showOutputField($val, $key, $object->id, '');
print $object->showOutputField($val, $key, (string) $object->id, '');
} else {
print $object->showOutputField($val, $key, $object->$key, '');
}
@ -758,7 +758,7 @@ while ($i < $imaxinloop) {
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
$parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
/*if (!empty($arrayfields['anotherfield']['checked'])) {
@ -803,7 +803,7 @@ if ($num == 0) {
$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;