Qual: Fix phan notices (resource+salary)

This commit is contained in:
MDW 2025-02-14 01:09:38 +01:00
parent c405666765
commit 78f5938485
No known key found for this signature in database
17 changed files with 114 additions and 127 deletions

View File

@ -9,8 +9,8 @@
*/
return [
// # Issue statistics:
// PhanTypeMismatchArgument : 1730+ occurrences
// PhanUndeclaredProperty : 510+ occurrences
// PhanTypeMismatchArgument : 1690+ occurrences
// PhanUndeclaredProperty : 500+ occurrences
// PhanTypeMismatchArgumentNullable : 350+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 170+ occurrences
// PhanUndeclaredGlobalVariable : 160+ occurrences
@ -636,23 +636,10 @@ return [
'htdocs/recruitment/recruitmentjobposition_card.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/recruitment/recruitmentjobposition_document.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/recruitment/recruitmentjobposition_note.php' => ['PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/resource/card.php' => ['PhanTypeMismatchArgument'],
'htdocs/resource/class/dolresource.class.php' => ['PhanTypeMismatchArgumentNullable'],
'htdocs/resource/class/html.formresource.class.php' => ['PhanTypeMismatchArgument'],
'htdocs/resource/element_resource.php' => ['PhanTypeMismatchArgument'],
'htdocs/resource/list.php' => ['PhanTypeMismatchArgument'],
'htdocs/salaries/admin/salaries.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/salaries/card.php' => ['PhanTypeMismatchArgument'],
'htdocs/salaries/class/api_salaries.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'],
'htdocs/salaries/class/paymentsalary.class.php' => ['PhanTypeMismatchArgument'],
'htdocs/salaries/class/salariesstats.class.php' => ['PhanTypeMismatchArgument'],
'htdocs/salaries/class/salary.class.php' => ['PhanTypeMismatchArgument'],
'htdocs/salaries/document.php' => ['PhanTypeMismatchArgument'],
'htdocs/salaries/info.php' => ['PhanTypeMismatchArgument'],
'htdocs/salaries/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'],
'htdocs/salaries/paiement_salary.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/salaries/stats/index.php' => ['PhanTypeMismatchArgument'],
'htdocs/salaries/virement_request.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/salaries/paiement_salary.php' => ['PhanUndeclaredProperty'],
'htdocs/salaries/virement_request.php' => ['PhanUndeclaredProperty'],
'htdocs/societe/admin/societe.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod'],
'htdocs/societe/ajax/company.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/societe/canvas/actions_card_common.class.php' => ['PhanTypeMismatchArgument'],

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2013-2014 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2023-2024 William Mead <william.mead@manchenumerique.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
@ -290,7 +290,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) {
print '<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
print dol_escape_htmltag(GETPOSTISSET('address') ? GETPOST('address') : $object->address, 0, 1);
print '</textarea>';
print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent');
print $form->widgetForTranslation("address", $object, (bool) $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent');
print '</td></tr>';
// Zip
@ -302,13 +302,13 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) {
// Town
print '<tr>';
print '<td>'.$form->editfieldkey('Town', 'town', '', $object, 0).'</td><td>';
print $formresource->select_ziptown(GETPOSTISSET('town') ? GETPOST('town') : $object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent');
print $formresource->select_ziptown(GETPOSTISSET('town') ? GETPOST('town') : $object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
print $form->widgetForTranslation("town", $object, (bool) $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent');
print '</td></tr>';
// Origin country
print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td>';
print $form->select_country(GETPOSTISSET('country_id') ? GETPOSTINT('country_id') : $object->country_id, 'country_id');
print $form->select_country(GETPOSTISSET('country_id') ? (string) GETPOSTINT('country_id') : (string) $object->country_id, 'country_id');
if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2013-2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2023-2024 William Mead <william.mead@manchenumerique.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
@ -127,7 +127,7 @@ class Dolresource extends CommonObject
public $objelement;
/**
* @var array<int,array{code:string,label:string,active:int}> Cache of type of resources. TODO Use $conf->cache['type_of_resources'] instead
* @var array<int,array{code:string,label:string,active:int}> Cache of type of resources. TODO Use->cache['type_of_resources'] instead
*/
public $cache_code_type_resource;
@ -148,9 +148,9 @@ class Dolresource extends CommonObject
/**
* Create object in database
*
* @param User $user User that creates
* @param int $no_trigger 0=launch triggers after, 1=disable triggers
* @return int if KO: <0 || if OK: Id of created object
* @param User $user User that creates
* @param int<0,1> $no_trigger 0=launch triggers after, 1=disable triggers
* @return int if KO: <0 || if OK: Id of created object
*/
public function create(User $user, int $no_trigger = 0)
{
@ -412,7 +412,7 @@ class Dolresource extends CommonObject
$this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error) {
if (!$error && $user !== null) {
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('RESOURCE_MODIFY', $user);
@ -517,9 +517,9 @@ class Dolresource extends CommonObject
/**
* Delete a resource object
*
* @param User $user User making the change
* @param int $notrigger Disable all triggers
* @return int if OK: >0 || if KO: <0
* @param User $user User making the change
* @param int<0,1> $notrigger Disable all triggers
* @return int if OK: >0 || if KO: <0
*/
public function delete(User $user, int $notrigger = 0)
{
@ -759,7 +759,7 @@ class Dolresource extends CommonObject
$this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error) {
if (!$error && $user !== null) {
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('RESOURCE_MODIFY', $user);
@ -913,12 +913,12 @@ class Dolresource extends CommonObject
/**
* Return clickable link of object (with optional picto)
*
* @param int $withpicto Add picto into link
* @param string $option Where point the link ('compta', 'expedition', 'document', ...)
* @param string $get_params Parameters added to url
* @param int $notooltip 1=Disable tooltip
* @param string $morecss Add more css on link
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @param int<0,2> $withpicto Add picto into link
* @param string $option Where point the link ('compta', 'expedition', 'document', ...)
* @param string $get_params Parameters added to url
* @param int<0,1> $notooltip 1=Disable tooltip
* @param string $morecss Add more css on link
* @param int<-1,1> $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string String with URL
*/
public function getNomUrl($withpicto = 0, string $option = '', string $get_params = '', int $notooltip = 0, string $morecss = '', int $save_lastsearch_value = -1)
@ -995,7 +995,7 @@ class Dolresource extends CommonObject
/**
* Get status label
*
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @param int<0,6> $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status
*/
public function getLibStatut(int $mode = 0)
@ -1006,8 +1006,8 @@ class Dolresource extends CommonObject
/**
* Get status
*
* @param int $status Id status
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto
* @param int $status Id status
* @param int<0,6> $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto
* @return string Label of status
*/
public static function getLibStatusLabel(int $status, int $mode = 0)

View File

@ -3,7 +3,7 @@
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2022 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2023 William Mead <william.mead@manchenumerique.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
@ -73,18 +73,18 @@ class FormResource
/**
* Output html form to select a resource
*
* @param int $selected Preselected resource id
* @param string $htmlname Name of field in form
* @param string $filter Optional filters criteria (example: 's.rowid <> x')
* @param int $showempty Add an empty field
* @param int $showtype Show third party type in combo list (customer, prospect or supplier)
* @param int $forcecombo Force to use combo box
* @param int $selected Preselected resource id
* @param string $htmlname Name of field in form
* @param string $filter Optional filters criteria (example: 's.rowid <> x')
* @param int<0,1> $showempty Add an empty field
* @param int<0,1> $showtype Show third party type in combo list (customer, prospect or supplier)
* @param int<0,1> $forcecombo Force to use combo box
* @param array<array{method:string,url:string,htmlname:string,params:array<string,string>}> $event Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param string $filterkey Filter on key value
* @param string $filterkey Filter on key value
* @param int<0,2> $outputmode 0=HTML select string, 1=Array, 2=without form tag
* @param int $limit Limit number of answers, 0 for no limit
* @param string $morecss More css
* @param bool $multiple add [] in the name of element and add 'multiple' attribute
* @param int $limit Limit number of answers, 0 for no limit
* @param string $morecss More css
* @param bool $multiple add [] in the name of element and add 'multiple' attribute
* @return string|array<array{key:int,value:int,label:string}> HTML string with
*/
public function select_resource_list($selected = 0, $htmlname = 'fk_resource', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $event = [], $filterkey = '', $outputmode = 0, $limit = 20, $morecss = 'minwidth100', $multiple = false)
@ -175,15 +175,15 @@ class FormResource
/**
* Return html list of tickets type
*
* @param string $selected Id du type pre-selectionne
* @param string $htmlname Nom de la zone select
* @param string $filtertype To filter on field type in llx_c_ticket_type (array('code'=>xx,'label'=>zz))
* @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code
* @param int $empty 1=peut etre vide, 0 sinon
* @param int $noadmininfo 0=Add admin info, 1=Disable admin info
* @param int $maxlength Max length of label
* @param int $usejscombo 1=Use jscombo, 0=No js combo
* @param string $morecss Add more css
* @param string $selected Id du type pre-selectionne
* @param string $htmlname Nom de la zone select
* @param string $filtertype To filter on field type in llx_c_ticket_type (array('code'=>xx,'label'=>zz))
* @param int<0,3> $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code
* @param int<0,1> $empty 1=peut etre vide, 0 sinon
* @param int<0,1> $noadmininfo 0=Add admin info, 1=Disable admin info
* @param int $maxlength Max length of label
* @param int<0,1> $usejscombo 1=Use jscombo, 0=No js combo
* @param string $morecss Add more css
* @return void
*/
public function select_types_resource($selected = '', $htmlname = 'type_resource', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $usejscombo = 0, $morecss = 'minwidth100')
@ -263,7 +263,7 @@ class FormResource
* @param string $htmlname HTML select name
* @param string[] $fields Array with key of fields to refresh after selection
* @param int $fieldsize Field size
* @param int $disableautocomplete 1 To disable ajax autocomplete features (browser autocomplete may still occurs)
* @param int<0,1> $disableautocomplete 1 To disable ajax autocomplete features (browser autocomplete may still occurs)
* @param string $moreattrib Add more attribute on HTML input field
* @param string $morecss More css
* @return string
@ -297,7 +297,7 @@ class FormResource
* Thus the links with the departments are done on a department independently of its name.
*
* @param int $selected Code state preselected (mus be state id)
* @param integer $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show
* @param int $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show
* @param string $htmlname Id of department. If '', we want only the string with <option>
* @param string $morecss Add more css
* @return string String with HTML select
@ -320,7 +320,7 @@ class FormResource
$sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid";
$sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1";
if ($country_codeid && is_numeric($country_codeid)) {
$sql .= " AND c.rowid = '" . $this->db->escape($country_codeid) . "'";
$sql .= " AND c.rowid = '" . $this->db->escape((string) $country_codeid) . "'";
}
if ($country_codeid && !is_numeric($country_codeid)) {
$sql .= " AND c.code = '" . $this->db->escape($country_codeid) . "'";

View File

@ -4,7 +4,7 @@
* Copyright (C) 2019 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2021-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2023 William Mead <william.mead@manchenumerique.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
@ -399,7 +399,7 @@ if (!$ret) {
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);
@ -491,7 +491,7 @@ if (!$ret) {
$listofcontactid = array(); // not used yet
$listofotherid = array(); // not used yet
print '<div class="assignedtouser">';
print $form->select_dolusers_forevent('view', 'assignedtouser', 1, array(), 0, '', array(), 0, 0, 0, '', ($act->datep != $act->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
print $form->select_dolusers_forevent('view', 'assignedtouser', 1, array(), 0, '', array(), '0', 0, 0, '', ($act->datep != $act->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
print '</div>';
/*if (in_array($user->id,array_keys($listofuserid)))
{
@ -580,7 +580,7 @@ if (!$ret) {
if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$fichinter->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
}
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$fichinter->id, $fichinter->socid, $fichinter->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$fichinter->id, $fichinter->socid, (string) $fichinter->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
} else {
if (!empty($fichinter->fk_project)) {
$proj = new Project($db);

View File

@ -3,7 +3,7 @@
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.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
@ -107,57 +107,57 @@ $pagenext = $page + 1;
$arrayfields = array(
't.ref' => array(
'label' => $langs->trans("Ref"),
'checked' => 1,
'checked' => '1',
'position' => 1
),
'ty.label' => array(
'label' => $langs->trans("Type"),
'checked' => 1,
'checked' => '1',
'position' => 2
),
't.address' => array(
'label' => $langs->trans("Address"),
'checked' => 0,
'checked' => '0',
'position' => 3
),
't.zip' => array(
'label' => $langs->trans("Zip"),
'checked' => 0,
'checked' => '0',
'position' => 4
),
't.town' => array(
'label' => $langs->trans("Town"),
'checked' => 1,
'checked' => '1',
'position' => 5
),
'st.nom' => array(
'label' => $langs->trans("State"),
'checked' => 0,
'checked' => '0',
'position' => 6
),
'co.label' => array(
'label' => $langs->trans("Country"),
'checked' => 1,
'checked' => '1',
'position' => 7
),
't.phone' => array(
'label' => $langs->trans("Phone"),
'checked' => 0,
'checked' => '0',
'position' => 8
),
't.email' => array(
'label' => $langs->trans("Email"),
'checked' => 0,
'checked' => '0',
'position' => 9
),
't.max_users' => array(
'label' => $langs->trans("MaxUsersLabel"),
'checked' => 1,
'checked' => '1',
'position' => 10
),
't.url' => array(
'label' => $langs->trans("URL"),
'checked' => 0,
'checked' => '0',
'position' => 11
),
);
@ -166,7 +166,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
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2014-2019 Alexandre Spangaro <aspangaro@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
@ -130,7 +131,7 @@ foreach ($list as $key) {
// Value
print '<td>';
if (isModEnabled('accounting')) {
print $formaccounting->select_account(getDolGlobalString($key), $key, 1, '', 1, 1);
print $formaccounting->select_account(getDolGlobalString($key), $key, 1, array(), 1, 1);
} else {
print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
}

View File

@ -93,8 +93,8 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$hookmanager->initHooks(array('salarycard', 'globalcard'));
if ($id > 0 || !empty($ref)) {
$object->fetch($id, $ref);
if ($id > 0) {
$object->fetch($id);
// Check current user can read this salary
$canread = 0;
@ -580,7 +580,7 @@ if ($action == 'create' && $permissiontoadd) {
print '<tr><td class="titlefieldcreate">';
print $form->editfieldkey('Employee', 'fk_user', '', $object, 0, 'string', '', 1).'</td><td>';
$noactive = 0; // We keep active and unactive users
print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers(GETPOSTINT('fk_user'), 'fk_user', 1, '', 0, '', '', 0, 0, 0, 'employee:=:1', 0, '', 'maxwidth300', $noactive);
print img_picto('', 'user', 'class="pictofixedwidth"').$form->select_dolusers(GETPOSTINT('fk_user'), 'fk_user', 1, null, 0, '', '', '0', 0, 0, 'employee:=:1', 0, '', 'maxwidth300', $noactive);
print '</td></tr>';
// Label
@ -884,7 +884,7 @@ if ($id > 0) {
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, -1, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, -1, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
} else {
if (!empty($object->fk_project)) {
$proj = new Project($db);
@ -960,9 +960,9 @@ if ($id > 0) {
print '</td><td>';
if ($action == 'editmode') {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->type_payment, 'mode_reglement_id');
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->type_payment, 'mode_reglement_id');
} else {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->type_payment, 'none');
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->type_payment, 'none');
}
print '</td></tr>';
@ -978,9 +978,9 @@ if ($id > 0) {
print '</tr></table>';
print '</td><td>';
if ($action == 'editbankaccount') {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->fk_account, 'fk_account', 1);
} else {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->fk_account, 'none');
}
print '</td>';
print '</tr>';

View File

@ -636,7 +636,7 @@ class PaymentSalary extends CommonObject
// Insert payment into llx_bank
$bank_line_id = $acc->addline(
$this->datep,
$this->fk_typepayment, // Payment mode id or code ("CHQ or VIR for example")
(string) $this->fk_typepayment, // Payment mode id or code ("CHQ or VIR for example")
$label,
-$total,
$this->num_payment,

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (c) 2018 Fidesio <contact@fidesio.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.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
@ -128,7 +128,7 @@ class SalariesStats extends Stats
{
$sql = "SELECT date_format(dateep,'%m') as dm, sum(".$this->field.")";
$sql .= " FROM ".$this->from;
$sql .= " WHERE date_format(dateep,'%Y') = '".$this->db->escape($year)."'";
$sql .= " WHERE date_format(dateep,'%Y') = '".((int) $year)."'";
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC');
@ -148,7 +148,7 @@ class SalariesStats extends Stats
{
$sql = "SELECT date_format(dateep,'%m') as dm, avg(".$this->field.")";
$sql .= " FROM ".$this->from;
$sql .= " WHERE date_format(dateep,'%Y') = '".$this->db->escape($year)."'";
$sql .= " WHERE date_format(dateep,'%Y') = '".((int) $year)."'";
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC');

View File

@ -457,7 +457,7 @@ class Salary extends CommonObject
$sql .= ", entity";
$sql .= ") ";
$sql .= " VALUES (";
$sql .= "'".$this->db->escape($this->fk_user)."'";
$sql .= "'".((int) $this->fk_user)."'";
//$sql .= ", '".$this->db->idate($this->datep)."'";
//$sql .= ", '".$this->db->idate($this->datev)."'";
$sql .= ", ".((float) $this->amount);
@ -471,7 +471,7 @@ class Salary extends CommonObject
$sql .= ", '".$this->db->escape($this->label)."'";
$sql .= ", '".$this->db->idate($this->datesp)."'";
$sql .= ", '".$this->db->idate($this->dateep)."'";
$sql .= ", '".$this->db->escape($user->id)."'";
$sql .= ", '".((int) $user->id)."'";
$sql .= ", '".$this->db->idate($now)."'";
$sql .= ", NULL";
$sql .= ", ".((int) $conf->entity);

View File

@ -8,7 +8,7 @@
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015-2023 Alexandre Spangaro <aspangaro@easya.solutions>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.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
@ -91,8 +91,8 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$hookmanager->initHooks(array('salarydoc', 'globalcard'));
if ($id > 0 || !empty($ref)) {
$object->fetch($id, $ref);
if ($id > 0) {
$object->fetch($id);
// Check current user can read this salary
$canread = 0;
@ -203,7 +203,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, -1, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, -1, (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

@ -4,6 +4,7 @@
* Copyright (C) 2017-2023 Alexandre Spangaro <aspangaro@easya.solutions>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.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
@ -71,8 +72,8 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$hookmanager->initHooks(array('salaryinfo', 'globalcard'));
$object = new Salary($db);
if ($id > 0 || !empty($ref)) {
$object->fetch($id, $ref);
if ($id > 0) {
$object->fetch($id);
// Check current user can read this salary
$canread = 0;
@ -168,7 +169,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, -1, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, -1, (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

@ -3,7 +3,7 @@
* Copyright (C) 2015-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.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>
* Copyright (C) 2024 Nick Fragoulis
*
@ -227,6 +227,7 @@ if ($massaction == 'withdrawrequest') {
$rsql .= " AND pfd.traite = 0";
$rsql .= " ORDER BY pfd.date_demande DESC";
$numprlv = 0;
$result_sql = $db->query($rsql);
if ($result_sql) {
$numprlv = $db->num_rows($result_sql);
@ -256,7 +257,7 @@ if ($massaction == 'withdrawrequest') {
$nbwithdrawrequestok++;
} else {
$db->rollback();
setEventMessages($aBill->error, $aBill->errors, 'errors');
setEventMessages($salary->error, $salary->errors, 'errors');
}
}
if ($nbwithdrawrequestok > 0) {

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.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
@ -50,8 +50,8 @@ $ref = GETPOST('ref', 'alpha');
$amounts = array();
$object = new Salary($db);
if ($id > 0 || !empty($ref)) {
$object->fetch($id, $ref);
if ($id > 0) {
$object->fetch($id);
}
// Security check
@ -172,9 +172,8 @@ $sumpaid = 0.0;
// Formulaire de creation d'un paiement de charge
if ($action == 'create') {
$salary->accountid = $salary->fk_account ? $salary->fk_account : $salary->accountid;
$salary->paiementtype = $salary->mode_reglement_id ? $salary->mode_reglement_id : $salary->paiementtype;
$salary->fk_typepayment = $salary->mode_reglement_id ? $salary->mode_reglement_id : $salary->paiementtype;
$total = $salary->amount;
if (!empty($conf->use_javascript_ajax)) {
print "\n".'<script type="text/javascript">';
@ -273,7 +272,6 @@ if ($action == 'create') {
print '<td class="center">'.$langs->trans("Amount").'</td>';
print "</tr>\n";
$total = 0;
$total_ttc = 0.;
$totalrecu = 0;
@ -312,9 +310,8 @@ if ($action == 'create') {
print "</td>";
print "</tr>\n";
$total += $objp->total;
$total_ttc += $objp->total_ttc;
$totalrecu += $objp->am;
$totalrecu += $objp->amount;
$i++;
}
if ($i > 1) {
@ -335,7 +332,7 @@ if ($action == 'create') {
// Bouton Save payment
print '<div class="center">';
print '<div class="paddingbottom"><input type="checkbox" checked name="closepaidsalary" id="closepaidsalary"><label for="closepaidsalary">'.$langs->trans("ClosePaidSalaryAutomatically").'</label></div>';
print $form->buttonsSaveCancel("ToMakePayment", "Cancel", '', true);
print $form->buttonsSaveCancel("ToMakePayment", "Cancel", array(), true);
print '</div>';

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Fidesio <contact@fidesio.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.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
@ -175,7 +175,7 @@ if (!$mesg) {
$px3->SetLegend($legend);
$px3->SetYLabel($langs->trans("AmountAverage"));
$px3->SetMaxValue($px3->GetCeilMaxValue());
$px3->SetMinValue($px3->GetFloorMinValue());
$px3->SetMinValue((int) $px3->GetFloorMinValue());
$px3->SetWidth($WIDTH);
$px3->SetHeight($HEIGHT);
$px3->SetShading(3);
@ -222,7 +222,7 @@ print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->tra
// User
print '<tr><td>'.$langs->trans("Employee").'</td><td>';
print img_picto('', 'user', 'class="pictofixedwidth"');
print $form->select_dolusers(($userid ? $userid : -1), 'userid', 1, '', 0, !$user->hasRight('salaries', 'readall') ? 'hierarchyme' : '', '', 0, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
print $form->select_dolusers(($userid ? $userid : -1), 'userid', 1, null, 0, !$user->hasRight('salaries', 'readall') ? 'hierarchyme' : '', '', '0', 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
print '</td></tr>';
// Year
print '<tr><td>'.$langs->trans("Year").'</td><td>';

View File

@ -97,8 +97,8 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$hookmanager->initHooks(array('salaryinfo', 'globalcard'));
$object = new Salary($db);
if ($id > 0 || !empty($ref)) {
$object->fetch($id, $ref);
if ($id > 0) {
$object->fetch($id);
// Check current user can read this salary
$canread = 0;
@ -126,8 +126,8 @@ if ($type == 'bank-transfer') {
}
// Load object
if ($id > 0 || !empty($ref)) {
$ret = $object->fetch($id, $ref);
if ($id > 0) {
$ret = $object->fetch($id);
$isdraft = (($obj->status == FactureFournisseur::STATUS_DRAFT) ? 1 : 0);
if ($ret > 0) {
$object->fetch_thirdparty();
@ -171,7 +171,7 @@ if ($action == "add" && $permissiontoadd) {
$sourcetype = 'salaire';
$newtype = 'salaire';
$paymentservice = GETPOST('paymentservice');
$result = $object->demande_prelevement($user, price2num(GETPOST('request_transfer', 'alpha')), $newtype, $sourcetype);
$result = $object->demande_prelevement($user, (float) price2num(GETPOST('request_transfer', 'alpha')), $newtype, $sourcetype);
if ($result > 0) {
$db->commit();
@ -251,7 +251,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);
@ -315,9 +315,9 @@ print '</tr></table>';
print '</td><td>';
if ($action == 'editmode') {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->type_payment, 'mode_reglement_id');
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->type_payment, 'mode_reglement_id');
} else {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->type_payment, 'none');
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->type_payment, 'none');
}
print '</td></tr>';
@ -333,9 +333,9 @@ if (isModEnabled("bank")) {
print '</tr></table>';
print '</td><td>';
if ($action == 'editbankaccount') {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->fk_account, 'fk_account', 1);
} else {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->fk_account, 'none');
}
print '</td>';
print '</tr>';
@ -675,6 +675,7 @@ $sql .= " AND pfd.traite = 1";
$sql .= " AND pfd.type = 'ban'";
$sql .= " ORDER BY pfd.date_demande DESC";
$numOfBp = 0;
$resql = $db->query($sql);
if ($resql) {
$numOfBp = $db->num_rows($resql);