Qual: Fix 'SqlInjection' notices (#39228)

* Fix(ci): Add exceptions for 'mouvement' (codespell)

* Qual: Fix 'SqlInjection' notices

# Qual: Fix 'SqlInjection' notices

Batch of 25 files with changes to fix 'SqlInjection' Notices
This commit is contained in:
MDW 2026-07-20 15:26:30 +02:00 committed by GitHub
parent 63a2b0fe49
commit a801fb5229
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 260 additions and 251 deletions

View file

@ -1,16 +1,16 @@
$objMod->dictionaries = $objMod->{"dictionnaries"}; // For backward compatibility $objMod->dictionaries = $objMod->{"dictionnaries"}; // For backward compatibility
if (empty($objMod->dictionaries) && !empty($objMod->{"dictionnaries"})) { if (empty($objMod->dictionaries) && !empty($objMod->{"dictionnaries"})) {
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&id_entrepot='.$entrepotstatic->id.'&action=transfert&pdluoid='.$pdluo->id.'&token='.newToken().'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&id_entrepot='.$entrepotstatic->id.'&action=transfert&pdluoid='.$pdluo->id.'&token='.newToken().'">';
$dateemail = dol_stringtotime((string) $overview[0]->udate, 'gmt');
$reponsesadd = str_split($obj->reponses); $reponsesadd = str_split($obj->reponses);
$sql .= " SET reponses = '".$db->escape($reponsesadd)."'"; $sql .= " SET reponses = '".$db->escape($reponsesadd)."'";
$sql .= " SET reponses = '0".$db->escape($obj->reponses)."'"; $sql .= " SET reponses = '0".$db->escape($obj->reponses)."'";
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0);
dol_syslog("msgid=".$overview[0]->message_id." date=".dol_print_date($overview[0]->udate, 'dayrfc', 'gmt')." from=".$overview[0]->from." to=".$overview[0]->to." subject=".$overview[0]->subject);
print '<td class="center"><a href="'.DOL_URL_ROOT.'/product/stock/product.php?dwid='.$object->id.'&id='.$objp->rowid.'&action=transfert&token='.newToken().'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id).'">'; print '<td class="center"><a href="'.DOL_URL_ROOT.'/product/stock/product.php?dwid='.$object->id.'&id='.$objp->rowid.'&action=transfert&token='.newToken().'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id).'">';
$dateemail = dol_stringtotime((string) $overview[0]->udate, 'gmt');
$pice = '<i class="fas fa-briefcase inline-block"></i>'; $pice = '<i class="fas fa-briefcase inline-block"></i>';
$typea = ($data[$j]->typea == 'birth') ? $picb : $pice; $typea = ($data[$j]->typea == 'birth') ? $picb : $pice;
GETPOSTINT("mouvement"), GETPOSTINT("mouvement"),
dol_syslog("msgid=".$overview[0]->message_id." date=".dol_print_date($overview[0]->udate, 'dayrfc', 'gmt')." from=".$overview[0]->from." to=".$overview[0]->to." subject=".$overview[0]->subject);
jQuery("#mouvement option").removeAttr("selected").change(); jQuery("#mouvement option").removeAttr("selected").change();
jQuery("#mouvement option[value=0]").attr("selected","selected").trigger("change"); jQuery("#mouvement option[value=0]").attr("selected","selected").trigger("change");
jQuery("#mouvement option[value=1]").attr("selected","selected").trigger("change"); jQuery("#mouvement option[value=1]").attr("selected","selected").trigger("change");
@ -46,6 +46,7 @@
$sql2 .= " SET reponses = '".$db->escape($newcar)."'"; $sql2 .= " SET reponses = '".$db->escape($newcar)."'";
$this->category->childs = array(); $this->category->childs = array();
$tmpcrit = preg_replace('/^.*(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:)/', '\1', $tmpcrit); // the condition after the name of the field $tmpcrit = preg_replace('/^.*(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:)/', '\1', $tmpcrit); // the condition after the name of the field
$user->rights->accounting->mouvements = new stdClass();
// mise a jour des reponses utilisateurs dans la base // mise a jour des reponses utilisateurs dans la base
if ($user->hasRight('stock', 'mouvement', 'lire')) { if ($user->hasRight('stock', 'mouvement', 'lire')) {
if (empty($reyear) || empty($remonth) || empty($reday)) { if (empty($reyear) || empty($remonth) || empty($reday)) {
@ -66,6 +67,7 @@
$head[$tab][1] = $langs->trans("Referers"); $head[$tab][1] = $langs->trans("Referers");
$out .= "<b>".$langs->trans("Referer").":</b> ".(isset($_SERVER["HTTP_REFERER"]) ? dol_htmlentities($_SERVER["HTTP_REFERER"], ENT_COMPAT) : '')."<br>\n"; $out .= "<b>".$langs->trans("Referer").":</b> ".(isset($_SERVER["HTTP_REFERER"]) ? dol_htmlentities($_SERVER["HTTP_REFERER"], ENT_COMPAT) : '')."<br>\n";
$reday = GETPOSTINT('reday'); $reday = GETPOSTINT('reday');
$savpermexport = $user->hasRight('accounting', 'mouvements', 'export');
$sql .= " (cs.periode IS NOT NULL AND cs.periode between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; $sql .= " (cs.periode IS NOT NULL AND cs.periode between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
$sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; $sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
$sql .= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode as period, cs.import_key"; $sql .= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode as period, cs.import_key";
@ -78,10 +80,14 @@
$this->periode = $this->date_creation + 3600 * 24 * 30; $this->periode = $this->date_creation + 3600 * 24 * 30;
$title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Referers'); $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Referers');
$title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Referers'); $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Referers');
$user->rights->accounting->mouvements->export = $savpermexport;
$user->rights->accounting->mouvements->export = 0;
$user->rights->accounting->mouvements->export = 1;
if (!empty($arrayfields['cs.periode']['checked'])) { if (!empty($arrayfields['cs.periode']['checked'])) {
if ($newamount == 0 || empty($this->date_ech) || (empty($this->period) && empty($this->periode))) { if ($newamount == 0 || empty($this->date_ech) || (empty($this->period) && empty($this->periode))) {
if ($user->hasRight('stock', 'mouvement', 'creer')) { if ($user->hasRight('stock', 'mouvement', 'creer')) {
if (GETPOSTISSET("reday") && GETPOSTISSET("remonth") && GETPOSTISSET("reyear")) { if (GETPOSTISSET("reday") && GETPOSTISSET("remonth") && GETPOSTISSET("reyear")) {
if (empty($user->rights->accounting->mouvements)) {
* @param float|string $selectedrate Force preselected vat rate. Can be '8.5' or '8.5 (NOO)' for example. Use '' for no forcing. * @param float|string $selectedrate Force preselected vat rate. Can be '8.5' or '8.5 (NOO)' for example. Use '' for no forcing.
$datepaid = dol_mktime(12, 0, 0, GETPOSTINT("remonth"), GETPOSTINT("reday"), GETPOSTINT("reyear")); $datepaid = dol_mktime(12, 0, 0, GETPOSTINT("remonth"), GETPOSTINT("reday"), GETPOSTINT("reyear"));
$datepaye = dol_mktime(12, 0, 0, GETPOSTINT("remonth"), GETPOSTINT("reday"), GETPOSTINT("reyear")); $datepaye = dol_mktime(12, 0, 0, GETPOSTINT("remonth"), GETPOSTINT("reday"), GETPOSTINT("reyear"));

View file

@ -561,7 +561,7 @@ if ($refresh === true) {
$sql .= "SELECT SUM(amount) as mm, date_format(tva.datev,'%Y-%m') as dm, 'claimed' as mode"; $sql .= "SELECT SUM(amount) as mm, date_format(tva.datev,'%Y-%m') as dm, 'claimed' as mode";
$sql .= " FROM " . MAIN_DB_PREFIX . "tva as tva"; $sql .= " FROM " . MAIN_DB_PREFIX . "tva as tva";
$sql .= " WHERE tva.entity = " . $conf->entity; $sql .= " WHERE tva.entity = " . ((int) $conf->entity);
$sql .= " AND (tva.datev >= '" . $db->idate($date_start) . "' AND tva.datev <= '" . $db->idate($date_end) . "')"; $sql .= " AND (tva.datev >= '" . $db->idate($date_start) . "' AND tva.datev <= '" . $db->idate($date_end) . "')";
$sql .= " GROUP BY dm"; $sql .= " GROUP BY dm";
@ -570,7 +570,7 @@ if ($refresh === true) {
$sql .= "SELECT SUM(ptva.amount) as mm, date_format(tva.datev,'%Y-%m') as dm, 'paid' as mode"; $sql .= "SELECT SUM(ptva.amount) as mm, date_format(tva.datev,'%Y-%m') as dm, 'paid' as mode";
$sql .= " FROM " . MAIN_DB_PREFIX . "tva as tva"; $sql .= " FROM " . MAIN_DB_PREFIX . "tva as tva";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "payment_vat as ptva ON (tva.rowid = ptva.fk_tva)"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "payment_vat as ptva ON (tva.rowid = ptva.fk_tva)";
$sql .= " WHERE tva.entity = " . $conf->entity; $sql .= " WHERE tva.entity = " . ((int) $conf->entity);
$sql .= " AND (tva.datev >= '" . $db->idate($date_start) . "' AND tva.datev <= '" . $db->idate($date_end) . "')"; $sql .= " AND (tva.datev >= '" . $db->idate($date_start) . "' AND tva.datev <= '" . $db->idate($date_end) . "')";
$sql .= " GROUP BY dm"; $sql .= " GROUP BY dm";

View file

@ -77,7 +77,7 @@ class box_accountancy_last_manual_entries extends ModeleBoxes
$sql .= ", b.code_journal"; $sql .= ", b.code_journal";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
$sql .= " WHERE b.fk_doc = 0"; $sql .= " WHERE b.fk_doc = 0";
$sql .= " AND b.entity = ".$conf->entity; $sql .= " AND b.entity = ".((int) $conf->entity);
$sql .= " ORDER BY b.piece_num DESC "; $sql .= " ORDER BY b.piece_num DESC ";
$sql .= $this->db->plimit($max, 0); $sql .= $this->db->plimit($max, 0);

View file

@ -75,7 +75,7 @@ class box_accountancy_suspense_account extends ModeleBoxes
$sql = "SELECT COUNT(*) as nb_suspense_account"; $sql = "SELECT COUNT(*) as nb_suspense_account";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
$sql .= " WHERE b.numero_compte = '".$this->db->escape($suspenseAccount)."'"; $sql .= " WHERE b.numero_compte = '".$this->db->escape($suspenseAccount)."'";
$sql .= " AND b.entity = ".$conf->entity; $sql .= " AND b.entity = ".((int) $conf->entity);
$result = $this->db->query($sql); $result = $this->db->query($sql);
$nbSuspenseAccount = 0; $nbSuspenseAccount = 0;

View file

@ -91,7 +91,7 @@ class box_boms extends ModeleBoxes
$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
$sql .= ", ".MAIN_DB_PREFIX."bom_bom as c"; $sql .= ", ".MAIN_DB_PREFIX."bom_bom as c";
$sql .= " WHERE c.fk_product = p.rowid"; $sql .= " WHERE c.fk_product = p.rowid";
$sql .= " AND c.entity = ".$conf->entity; $sql .= " AND c.entity = ".((int) $conf->entity);
$sql .= " ORDER BY c.tms DESC, c.ref DESC"; $sql .= " ORDER BY c.tms DESC, c.ref DESC";
$sql .= $this->db->plimit($max, 0); $sql .= $this->db->plimit($max, 0);

View file

@ -80,7 +80,7 @@ class box_bookmarks extends ModeleBoxes
$sql = "SELECT b.title, b.url, b.target, b.favicon"; $sql = "SELECT b.title, b.url, b.target, b.favicon";
$sql .= " FROM ".MAIN_DB_PREFIX."bookmark as b"; $sql .= " FROM ".MAIN_DB_PREFIX."bookmark as b";
$sql .= " WHERE fk_user = ".((int) $user->id); $sql .= " WHERE fk_user = ".((int) $user->id);
$sql .= " AND b.entity = ".$conf->entity; $sql .= " AND b.entity = ".((int) $conf->entity);
$sql .= $this->db->order("position", "ASC"); $sql .= $this->db->order("position", "ASC");
$sql .= $this->db->plimit($max, 0); $sql .= $this->db->plimit($max, 0);

View file

@ -90,7 +90,7 @@ class box_comptes extends ModeleBoxes
$sql .= ', aj.code as accountancy_journal'; $sql .= ', aj.code as accountancy_journal';
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid = b.fk_accountancy_journal'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_journal as aj ON aj.rowid = b.fk_accountancy_journal';
$sql .= " WHERE b.entity = ".$conf->entity; $sql .= " WHERE b.entity = ".((int) $conf->entity);
$sql .= " AND clos = 0"; $sql .= " AND clos = 0";
$sql .= " ORDER BY label"; $sql .= " ORDER BY label";

View file

@ -84,7 +84,7 @@ class box_contracts extends ModeleBoxes
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
} }
$sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity = ".$conf->entity; $sql .= " AND c.entity = ".((int) $conf->entity);
if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
} }

View file

@ -94,7 +94,7 @@ class box_customers_outstanding_bill_reached extends ModeleBoxes
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
} }
if ($user->socid) { if ($user->socid) {
$sql .= " AND s.rowid = $user->socid"; $sql .= " AND s.rowid = ".((int) $user->socid);
} }
$sql .= " AND s.outstanding_limit > 0"; $sql .= " AND s.outstanding_limit > 0";
$sql .= " AND s.rowid IN (SELECT fk_soc from ".MAIN_DB_PREFIX."facture as f WHERE f.fk_statut = 1 and f.fk_soc = s.rowid)"; $sql .= " AND s.rowid IN (SELECT fk_soc from ".MAIN_DB_PREFIX."facture as f WHERE f.fk_statut = 1 and f.fk_soc = s.rowid)";

View file

@ -88,7 +88,7 @@ class box_ficheinter extends ModeleBoxes
} }
$sql .= ", ".MAIN_DB_PREFIX."fichinter as f"; $sql .= ", ".MAIN_DB_PREFIX."fichinter as f";
$sql .= " WHERE f.fk_soc = s.rowid "; $sql .= " WHERE f.fk_soc = s.rowid ";
$sql .= " AND f.entity = ".$conf->entity; $sql .= " AND f.entity = ".((int) $conf->entity);
if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) { if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
} }

View file

@ -91,7 +91,7 @@ class box_mos extends ModeleBoxes
$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
$sql .= ", ".MAIN_DB_PREFIX."mrp_mo as c"; $sql .= ", ".MAIN_DB_PREFIX."mrp_mo as c";
$sql .= " WHERE c.fk_product = p.rowid"; $sql .= " WHERE c.fk_product = p.rowid";
$sql .= " AND c.entity = ".$conf->entity; $sql .= " AND c.entity = ".((int) $conf->entity);
$sql .= " ORDER BY c.tms DESC, c.ref DESC"; $sql .= " ORDER BY c.tms DESC, c.ref DESC";
$sql .= $this->db->plimit($max, 0); $sql .= $this->db->plimit($max, 0);

View file

@ -79,7 +79,7 @@ class box_scheduled_jobs extends ModeleBoxes
$sql .= " t.label, t.status, t.test, t.lastresult, t.processing"; $sql .= " t.label, t.status, t.test, t.lastresult, t.processing";
$sql .= " FROM " . MAIN_DB_PREFIX . "cronjob as t"; $sql .= " FROM " . MAIN_DB_PREFIX . "cronjob as t";
$sql .= " WHERE status <> ".$cronstatic::STATUS_DISABLED; $sql .= " WHERE status <> ".$cronstatic::STATUS_DISABLED;
$sql .= " AND entity IN (0, ".$conf->entity.")"; $sql .= " AND entity IN (0, ".((int) $conf->entity).")";
$sql .= $this->db->order("t.datelastrun", "DESC"); $sql .= $this->db->order("t.datelastrun", "DESC");
$result = $this->db->query($sql); $result = $this->db->query($sql);

View file

@ -84,7 +84,7 @@ class box_services_expired extends ModeleBoxes
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
} }
$sql .= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'"; $sql .= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'";
$sql .= " AND c.entity = ".$conf->entity; $sql .= " AND c.entity = ".((int) $conf->entity);
$sql .= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0"; $sql .= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0";
if ($user->socid) { if ($user->socid) {
$sql .= ' AND c.fk_soc = '.((int) $user->socid); $sql .= ' AND c.fk_soc = '.((int) $user->socid);

View file

@ -158,7 +158,7 @@ class box_task extends ModeleBoxes
} }
$sql .= " WHERE "; $sql .= " WHERE ";
$sql .= " pt.entity = ".$conf->entity; $sql .= " pt.entity = ".((int) $conf->entity);
$sql .= " AND p.fk_statut = ".Project::STATUS_VALIDATED; $sql .= " AND p.fk_statut = ".Project::STATUS_VALIDATED;
$sql .= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed $sql .= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed
$sql .= " AND p.usage_task = 1 "; $sql .= " AND p.usage_task = 1 ";

View file

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -372,7 +372,7 @@ class CUnits extends CommonDict
$sql .= " short_label=".(isset($this->short_label) ? "'".$this->db->escape($this->short_label)."'" : "null").","; $sql .= " short_label=".(isset($this->short_label) ? "'".$this->db->escape($this->short_label)."'" : "null").",";
$sql .= " unit_type=".(isset($this->unit_type) ? "'".$this->db->escape($this->unit_type)."'" : "null").","; $sql .= " unit_type=".(isset($this->unit_type) ? "'".$this->db->escape($this->unit_type)."'" : "null").",";
$sql .= " scale=".(isset($this->scale) ? "'".$this->db->escape((string) $this->scale)."'" : "null").","; $sql .= " scale=".(isset($this->scale) ? "'".$this->db->escape((string) $this->scale)."'" : "null").",";
$sql .= " active=".(isset($this->active) ? $this->active : "null"); $sql .= " active=".(isset($this->active) ? ((int) $this->active) : "null");
$sql .= " WHERE rowid=".((int) $this->id); $sql .= " WHERE rowid=".((int) $this->id);
$this->db->begin(); $this->db->begin();

View file

@ -11,6 +11,7 @@
* Copyright (C) 2017 Nicolas ZABOURI <info@inovea-conseil.com> * Copyright (C) 2017 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2018-2022 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2022 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2022 Antonin MARCHAL <antonin@letempledujeu.fr> * Copyright (C) 2022 Antonin MARCHAL <antonin@letempledujeu.fr>
* Copyright (C) 2026 MDW <mdeweerd@users.noreply.github.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -499,7 +500,7 @@ class FieldsManager
$fieldInfos->size = $attributes['length'] ?? ''; $fieldInfos->size = $attributes['length'] ?? '';
$fieldInfos->label = $attributes['label'] ?? ''; $fieldInfos->label = $attributes['label'] ?? '';
$fieldInfos->langFile = $attributes['langfile'] ?? ''; $fieldInfos->langFile = $attributes['langfile'] ?? '';
$fieldInfos->sqlAlias = $attributes['alias'] ?? null; $fieldInfos->sqlAlias = $attributes['alias'] ?? null; // @phan-suppress-current-line SqlInjection
$fieldInfos->picto = $attributes['picto'] ?? ''; $fieldInfos->picto = $attributes['picto'] ?? '';
$fieldInfos->position = $attributes['position'] ?? 0; $fieldInfos->position = $attributes['position'] ?? 0;
$fieldInfos->required = ($attributes['notnull'] ?? 0) > 0; $fieldInfos->required = ($attributes['notnull'] ?? 0) > 0;

View file

@ -2,7 +2,7 @@
/* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -109,10 +109,10 @@ class mod_commande_marbre extends ModeleNumRefCommandes
$max = ''; $max = '';
$posindice = strlen($this->prefix) + 6; $posindice = strlen($this->prefix) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".((int) $posindice).") AS SIGNED)) as max";
$sql .= " FROM ".MAIN_DB_PREFIX."commande"; $sql .= " FROM ".MAIN_DB_PREFIX."commande";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".((int) $conf->entity);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
@ -144,7 +144,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes
// First, we get the max value // First, we get the max value
$posindice = strlen($this->prefix) + 6; $posindice = strlen($this->prefix) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".((int) $posindice).") AS SIGNED)) as max";
$sql .= " FROM ".MAIN_DB_PREFIX."commande"; $sql .= " FROM ".MAIN_DB_PREFIX."commande";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql .= " AND entity IN (".getEntity('ordernumber', 1, $object).")"; $sql .= " AND entity IN (".getEntity('ordernumber', 1, $object).")";

View file

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* *
* This file is an example to follow to add your own email selector inside * This file is an example to follow to add your own email selector inside
@ -258,7 +258,7 @@ class mailing_advthirdparties extends MailingTargets
$sql .= " FROM ".MAIN_DB_PREFIX."categorie"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie";
$sql .= " WHERE type in (1,2)"; // We keep only categories for suppliers and customers/prospects $sql .= " WHERE type in (1,2)"; // We keep only categories for suppliers and customers/prospects
// $sql.= " AND visible > 0"; // We ignore the property visible because third party's categories does not use this property (only products categories use it). // $sql.= " AND visible > 0"; // We ignore the property visible because third party's categories does not use this property (only products categories use it).
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".((int) $conf->entity);
$sql .= " ORDER BY label"; $sql .= " ORDER BY label";
//print $sql; //print $sql;

View file

@ -182,7 +182,7 @@ class mailing_fraise extends MailingTargets
$sql .= " FROM ".MAIN_DB_PREFIX."categorie"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie";
$sql .= " WHERE type = 3"; // We keep only categories for members $sql .= " WHERE type = 3"; // We keep only categories for members
// $sql.= " AND visible > 0"; // We ignore the property visible because member's categories does not use this property (only products categories use it). // $sql.= " AND visible > 0"; // We ignore the property visible because member's categories does not use this property (only products categories use it).
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".((int) $conf->entity);
$sql .= " ORDER BY label"; $sql .= " ORDER BY label";
//print $sql; //print $sql;

View file

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -88,7 +88,7 @@ class mailing_pomme extends MailingTargets
$sql .= " count(distinct(u.email)) as nb"; $sql .= " count(distinct(u.email)) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE u.email != ''"; // u.email IS NOT NULL est implicit dans ce test $sql .= " WHERE u.email != ''"; // u.email IS NOT NULL est implicit dans ce test
$sql .= " AND u.entity IN (0,".$conf->entity.")"; $sql .= " AND u.entity IN (0,".((int) $conf->entity).")";
$statssql[0] = $sql; $statssql[0] = $sql;
@ -111,7 +111,7 @@ class mailing_pomme extends MailingTargets
$sql = "SELECT count(distinct(u.email)) as nb"; $sql = "SELECT count(distinct(u.email)) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE u.email != ''"; // u.email IS NOT NULL est implicit dans ce test $sql .= " WHERE u.email != ''"; // u.email IS NOT NULL est implicit dans ce test
$sql .= " AND u.entity IN (0,".$conf->entity.")"; $sql .= " AND u.entity IN (0,".((int) $conf->entity).")";
if (empty($this->evenunsubscribe)) { if (empty($this->evenunsubscribe)) {
$sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = u.email and mu.entity = ".((int) $conf->entity).")"; $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = u.email and mu.entity = ".((int) $conf->entity).")";
} }
@ -184,7 +184,7 @@ class mailing_pomme extends MailingTargets
$sql .= " u.lastname, u.firstname as firstname, u.civility as civility_id, u.login, u.office_phone"; $sql .= " u.lastname, u.firstname as firstname, u.civility as civility_id, u.login, u.office_phone";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE u.email <> ''"; // u.email IS NOT NULL est implicit dans ce test $sql .= " WHERE u.email <> ''"; // u.email IS NOT NULL est implicit dans ce test
$sql .= " AND u.entity IN (0,".$conf->entity.")"; $sql .= " AND u.entity IN (0,".((int) $conf->entity).")";
$sql .= " AND u.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")"; $sql .= " AND u.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")";
if (GETPOSTISSET("filter") && GETPOST("filter") == '1') { if (GETPOSTISSET("filter") && GETPOST("filter") == '1') {
$sql .= " AND u.statut=1"; $sql .= " AND u.statut=1";

View file

@ -3,7 +3,7 @@
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com> * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2019 Maxime Kohlhaas <maxime@atm-consulting.fr> * Copyright (C) 2019 Maxime Kohlhaas <maxime@atm-consulting.fr>
* Copyright (C) 2021 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2021 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Rafael San José <rsanjose@alxarafe.com> * Copyright (C) 2024 Rafael San José <rsanjose@alxarafe.com>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
* *
@ -342,7 +342,7 @@ class modBom extends DolibarrModules
// Add extra fields // Add extra fields
$import_extrafield_sample = array(); $import_extrafield_sample = array();
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'bom_bom' AND entity IN (0, ".$conf->entity.")"; $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'bom_bom' AND entity IN (0, ".((int) $conf->entity).")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
@ -413,7 +413,7 @@ class modBom extends DolibarrModules
); );
// Add extra fields // Add extra fields
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'bom_bomline' AND entity IN (0, ".$conf->entity.")"; $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'bom_bomline' AND entity IN (0, ".((int) $conf->entity).")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
while ($obj = $this->db->fetch_object($resql)) { while ($obj = $this->db->fetch_object($resql)) {

View file

@ -3,7 +3,7 @@
* Copyright (C) 2018-2019 Nicolas ZABOURI <info@inovea-conseil.com> * Copyright (C) 2018-2019 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2021 SuperAdmin * Copyright (C) 2021 SuperAdmin
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -468,10 +468,10 @@ class modKnowledgeManagement extends DolibarrModules
} }
$sql = array_merge($sql, array( $sql = array_merge($sql, array(
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".((int) $conf->entity), "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".$this->db->escape(strtolower($myTmpObjectKey))."' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity),
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."','".strtolower($myTmpObjectKey)."',".((int) $conf->entity).")", "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".$this->db->escape(strtolower($myTmpObjectKey))."','".$this->db->escape(strtolower($myTmpObjectKey))."',".((int) $conf->entity).")",
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey)."_odt' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".((int) $conf->entity), "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'generic_".$this->db->escape(strtolower($myTmpObjectKey))."_odt' AND type = '".$this->db->escape(strtolower($myTmpObjectKey))."' AND entity = ".((int) $conf->entity),
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".strtolower($myTmpObjectKey)."', ".((int) $conf->entity).")" "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".$this->db->escape(strtolower($myTmpObjectKey))."_odt', '".$this->db->escape(strtolower($myTmpObjectKey))."', ".((int) $conf->entity).")"
)); ));
} }
} }

View file

@ -4,6 +4,7 @@
* Copyright (C) 2019-2025 Frédéric France <frederic.france@free.fr> * Copyright (C) 2019-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2019 Destailleur Laurent <eldy@users.sourceforge.net> * Copyright (C) 2019 Destailleur Laurent <eldy@users.sourceforge.net>
* Copyright (C) 2024 Charlene Benke <charlene@patas-monkey.com> * Copyright (C) 2024 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2026 MDW <mdeweerd@users.noreply.github.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -136,8 +137,8 @@ class modMrp extends DolibarrModules
// ); // );
$this->const = array( $this->const = array(
//1=>array('MRP_MO_ADDON_PDF', 'chaine', 'vinci', 'Name of default PDF model of MO', 0), //1=>array('MRP_MO_ADDON_PDF', 'chaine', 'vinci', 'Name of default PDF model of MO', 0),
2=>array('MRP_MO_ADDON', 'chaine', 'mod_mo_standard', 'Name of numbering rules of MO', 0), 2 => array('MRP_MO_ADDON', 'chaine', 'mod_mo_standard', 'Name of numbering rules of MO', 0),
3=>array('MRP_MO_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT'.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/mrps', '', 0) 3 => array('MRP_MO_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT'.($conf->entity > 1 ? '/'.$conf->entity : '').'/doctemplates/mrps', '', 0)
); );
// Some keys to add into the overwriting translation tables // Some keys to add into the overwriting translation tables
@ -245,59 +246,59 @@ class modMrp extends DolibarrModules
// Exports profiles provided by this module // Exports profiles provided by this module
$r = 1; $r = 1;
$this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_code[$r] = $this->rights_class.'_'.$r;
$this->export_label[$r]='MOs'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_label[$r] = 'MOs'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='mrp'; $this->export_icon[$r] = 'mrp';
$this->export_fields_array[$r] = array( $this->export_fields_array[$r] = array(
'm.rowid'=>"Id", 'm.rowid' => "Id",
'm.ref'=>"Ref", 'm.ref' => "Ref",
'm.label'=>"Label", 'm.label' => "Label",
'm.fk_project'=>'Project', 'm.fk_project' => 'Project',
'm.fk_bom'=>"Bom", 'm.fk_bom' => "Bom",
'm.date_start_planned'=>"DateStartPlanned", 'm.date_start_planned' => "DateStartPlanned",
'm.date_end_planned'=>"DateEndPlanned", 'm.date_end_planned' => "DateEndPlanned",
'm.fk_product'=>"Product", 'm.fk_product' => "Product",
'm.status'=>'Status', 'm.status' => 'Status',
'm.model_pdf'=>'Model', 'm.model_pdf' => 'Model',
'm.fk_user_valid'=>'ValidatedById', 'm.fk_user_valid' => 'ValidatedById',
'm.fk_user_modif'=>'ModifiedById', 'm.fk_user_modif' => 'ModifiedById',
'm.fk_user_creat'=>'CreatedById', 'm.fk_user_creat' => 'CreatedById',
'm.date_valid'=>'DateValidation', 'm.date_valid' => 'DateValidation',
'm.note_private'=>'NotePrivate', 'm.note_private' => 'NotePrivate',
'm.note_public'=>'Note', 'm.note_public' => 'Note',
'm.fk_soc'=>'ThirdParty:ID', 'm.fk_soc' => 'ThirdParty:ID',
'm.qty'=>'Qty', 'm.qty' => 'Qty',
'm.date_creation'=>'DateCreation', 'm.date_creation' => 'DateCreation',
'm.tms'=>'DateModification', 'm.tms' => 'DateModification',
'm.fk_warehouse'=>'WarehouseForProduction:ID', 'm.fk_warehouse' => 'WarehouseForProduction:ID',
'e.ref'=>'WarehouseForProduction:Ref' 'e.ref' => 'WarehouseForProduction:Ref'
); );
$keyforselect = 'mrp_mo'; $keyforselect = 'mrp_mo';
$keyforelement = 'mrp_mo'; $keyforelement = 'mrp_mo';
$keyforaliasextra = 'extra'; $keyforaliasextra = 'extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_TypeFields_array[$r] = array( $this->export_TypeFields_array[$r] = array(
'm.ref'=>"Text", 'm.ref' => "Text",
'm.label'=>"Text", 'm.label' => "Text",
'm.fk_project'=>'Numeric', 'm.fk_project' => 'Numeric',
'm.fk_bom'=>"Numeric", 'm.fk_bom' => "Numeric",
'm.date_end_planned'=>"Date", 'm.date_end_planned' => "Date",
'm.date_start_planned'=>"Date", 'm.date_start_planned' => "Date",
'm.fk_product'=>"Numeric", 'm.fk_product' => "Numeric",
'm.status'=>'Numeric', 'm.status' => 'Numeric',
'm.model_pdf'=>'Text', 'm.model_pdf' => 'Text',
'm.fk_user_valid'=>'Numeric', 'm.fk_user_valid' => 'Numeric',
'm.fk_user_modif'=>'Numeric', 'm.fk_user_modif' => 'Numeric',
'm.fk_user_creat'=>'Numeric', 'm.fk_user_creat' => 'Numeric',
'm.date_valid'=>'Date', 'm.date_valid' => 'Date',
'm.note_private'=>'Text', 'm.note_private' => 'Text',
'm.note_public'=>'Text', 'm.note_public' => 'Text',
'm.fk_soc'=>'Numeric', 'm.fk_soc' => 'Numeric',
'm.qty'=>'Numeric', 'm.qty' => 'Numeric',
'm.date_creation'=>'Date', 'm.date_creation' => 'Date',
'm.tms'=>'Date', 'm.tms' => 'Date',
'm.fk_warehouse'=>'Numeric', 'm.fk_warehouse' => 'Numeric',
'e.ref'=>'Text', 'e.ref' => 'Text',
); );
$this->export_entities_array[$r] = array('m.fk_warehouse' => 'warehouse', 'e.ref' => 'warehouse'); // We define here only fields that use another icon that the one defined into import_icon $this->export_entities_array[$r] = array('m.fk_warehouse' => 'warehouse', 'e.ref' => 'warehouse'); // We define here only fields that use another icon that the one defined into import_icon
$this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_start[$r] = 'SELECT DISTINCT ';
@ -308,30 +309,30 @@ class modMrp extends DolibarrModules
// Export of MO + liste of consumption / production // Export of MO + liste of consumption / production
$r++; $r++;
$this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_code[$r] = $this->rights_class.'_'.$r;
$this->export_label[$r]='ConsumptionAndProductionInMos'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_label[$r] = 'ConsumptionAndProductionInMos'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='mrp'; $this->export_icon[$r] = 'mrp';
$this->export_fields_array[$r] = array( $this->export_fields_array[$r] = array(
'm.rowid'=>"Id", 'm.rowid' => "Id",
'm.ref'=>"Ref", 'm.ref' => "Ref",
'm.label'=>"Label", 'm.label' => "Label",
'm.fk_project'=>'ProjectId', 'm.fk_project' => 'ProjectId',
'm.fk_bom'=>"Bom:ID", 'm.fk_bom' => "Bom:ID",
'm.date_start_planned'=>"DateStartPlanned", 'm.date_start_planned' => "DateStartPlanned",
'm.date_end_planned'=>"DateEndPlanned", 'm.date_end_planned' => "DateEndPlanned",
'm.fk_product'=>"Product", 'm.fk_product' => "Product",
'm.status'=>'Status', 'm.status' => 'Status',
'm.model_pdf'=>'Model', 'm.model_pdf' => 'Model',
'm.fk_user_valid'=>'ValidatedById', 'm.fk_user_valid' => 'ValidatedById',
'm.fk_user_modif'=>'ModifiedById', 'm.fk_user_modif' => 'ModifiedById',
'm.fk_user_creat'=>'CreatedById', 'm.fk_user_creat' => 'CreatedById',
'm.date_valid'=>'DateValidation', 'm.date_valid' => 'DateValidation',
'm.note_private'=>'NotePrivate', 'm.note_private' => 'NotePrivate',
'm.note_public'=>'Note', 'm.note_public' => 'Note',
'm.fk_soc'=>'ThirdParty', 'm.fk_soc' => 'ThirdParty',
'm.qty'=>'Qty', 'm.qty' => 'Qty',
'm.date_creation'=>'DateCreation', 'm.date_creation' => 'DateCreation',
'm.tms'=>'DateModification', 'm.tms' => 'DateModification',
//'e.rowid'=>'WarehouseId', //'e.rowid'=>'WarehouseId',
//'e.ref'=>'WarehouseRef', //'e.ref'=>'WarehouseRef',
); );
@ -356,27 +357,27 @@ class modMrp extends DolibarrModules
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_TypeFields_array[$r] = array( $this->export_TypeFields_array[$r] = array(
'm.ref'=>"Text", 'm.ref' => "Text",
'm.label'=>"Text", 'm.label' => "Text",
'm.fk_project'=>'Numeric', 'm.fk_project' => 'Numeric',
'm.fk_bom'=>"Numeric", 'm.fk_bom' => "Numeric",
'm.date_end_planned'=>"Date", 'm.date_end_planned' => "Date",
'm.date_start_planned'=>"Date", 'm.date_start_planned' => "Date",
'm.fk_product'=>"Numeric", 'm.fk_product' => "Numeric",
'm.status'=>'Numeric', 'm.status' => 'Numeric',
'm.model_pdf'=>'Text', 'm.model_pdf' => 'Text',
'm.fk_user_valid'=>'Numeric', 'm.fk_user_valid' => 'Numeric',
'm.fk_user_modif'=>'Numeric', 'm.fk_user_modif' => 'Numeric',
'm.fk_user_creat'=>'Numeric', 'm.fk_user_creat' => 'Numeric',
'm.date_valid'=>'Date', 'm.date_valid' => 'Date',
'm.note_private'=>'Text', 'm.note_private' => 'Text',
'm.note_public'=>'Text', 'm.note_public' => 'Text',
'm.fk_soc'=>'Numeric', 'm.fk_soc' => 'Numeric',
'm.qty'=>'Numeric', 'm.qty' => 'Numeric',
'm.date_creation'=>'Date', 'm.date_creation' => 'Date',
'm.tms'=>'Date', 'm.tms' => 'Date',
'e.fk_warehouse'=>'Numeric', 'e.fk_warehouse' => 'Numeric',
'e.ref'=>'Text', 'e.ref' => 'Text',
'mp.qty' => 'Numeric', 'mp.qty' => 'Numeric',
'mp.batch' => 'Text', 'mp.batch' => 'Text',
'mp.fk_product' => 'Numeric', 'mp.fk_product' => 'Numeric',
@ -427,39 +428,39 @@ class modMrp extends DolibarrModules
$r++; */ $r++; */
/* END MODULEBUILDER IMPORT MO */ /* END MODULEBUILDER IMPORT MO */
$r++; $r++;
$this->import_code[$r]=$this->rights_class.'_'.$r; $this->import_code[$r] = $this->rights_class.'_'.$r;
$this->import_label[$r]='MOs'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->import_label[$r] = 'MOs'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->import_icon[$r]='mrp'; $this->import_icon[$r] = 'mrp';
$this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon $this->import_entities_array[$r] = array(); // We define here only fields that use a different icon from the one defined in import_icon
$this->import_tables_array[$r] = array('m'=>MAIN_DB_PREFIX.'mrp_mo', 'extra'=>MAIN_DB_PREFIX.'mrp_mo_extrafields'); $this->import_tables_array[$r] = array('m' => MAIN_DB_PREFIX.'mrp_mo', 'extra' => MAIN_DB_PREFIX.'mrp_mo_extrafields');
$this->import_tables_creator_array[$r] = array('m'=>'fk_user_creat'); // Fields to store import user id $this->import_tables_creator_array[$r] = array('m' => 'fk_user_creat'); // Fields to store import user id
$this->import_fields_array[$r] = array( $this->import_fields_array[$r] = array(
'm.ref' => "Ref*", 'm.ref' => "Ref*",
'm.label' => "Label*", 'm.label' => "Label*",
'm.fk_project'=>'Project', 'm.fk_project' => 'Project',
'm.fk_bom'=>"Bom", 'm.fk_bom' => "Bom",
'm.date_start_planned'=>"DateStartPlanned", 'm.date_start_planned' => "DateStartPlanned",
'm.date_end_planned'=>"DateEndPlanned", 'm.date_end_planned' => "DateEndPlanned",
'm.fk_product'=>"Product*", 'm.fk_product' => "Product*",
'm.status'=>'Status', 'm.status' => 'Status',
'm.model_pdf'=>'Model', 'm.model_pdf' => 'Model',
'm.fk_user_valid'=>'ValidatedById', 'm.fk_user_valid' => 'ValidatedById',
'm.fk_user_modif'=>'ModifiedById', 'm.fk_user_modif' => 'ModifiedById',
'm.fk_user_creat'=>'CreatedById', 'm.fk_user_creat' => 'CreatedById',
'm.date_valid'=>'DateValidation', 'm.date_valid' => 'DateValidation',
'm.note_private'=>'NotePrivate', 'm.note_private' => 'NotePrivate',
'm.note_public'=>'Note', 'm.note_public' => 'Note',
'm.fk_soc'=>'ThirdParty', 'm.fk_soc' => 'ThirdParty',
'm.fk_warehouse'=>'Warehouse', 'm.fk_warehouse' => 'Warehouse',
'm.qty'=>'Qty*', 'm.qty' => 'Qty*',
'm.date_creation'=>'DateCreation', 'm.date_creation' => 'DateCreation',
'm.tms'=>'DateModification', 'm.tms' => 'DateModification',
); );
$import_sample = array(); $import_sample = array();
// Add extra fields // Add extra fields
$import_extrafield_sample = array(); $import_extrafield_sample = array();
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'mrp_mo' AND entity IN (0, ".$conf->entity.")"; $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'mrp_mo' AND entity IN (0, ".((int) $conf->entity).")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {

View file

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2013-2014 Jean-François Ferry <jfefe@aternatik.fr> /* Copyright (C) 2013-2014 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2026 Frédéric France <frederic.france@free.fr> * Copyright (C) 2026 Frédéric France <frederic.france@free.fr>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -274,7 +274,7 @@ class modResource extends DolibarrModules
$this->import_tables_array[$r] = array('r' => MAIN_DB_PREFIX.'resource', 'extra' => MAIN_DB_PREFIX.'resource_extrafields'); // List of tables to insert into (insert done in same order) $this->import_tables_array[$r] = array('r' => MAIN_DB_PREFIX.'resource', 'extra' => MAIN_DB_PREFIX.'resource_extrafields'); // List of tables to insert into (insert done in same order)
$this->import_fields_array[$r] = array('r.ref' => "ResourceFormLabel_ref*", 'r.fk_code_type_resource' => 'ResourceTypeCode', 'r.description' => 'ResourceFormLabel_description', 'r.note_private' => "NotePrivate", 'r.note_public' => "NotePublic", 'r.asset_number' => 'AssetNumber', 'r.datec' => 'DateCreation'); $this->import_fields_array[$r] = array('r.ref' => "ResourceFormLabel_ref*", 'r.fk_code_type_resource' => 'ResourceTypeCode', 'r.description' => 'ResourceFormLabel_description', 'r.note_private' => "NotePrivate", 'r.note_public' => "NotePublic", 'r.asset_number' => 'AssetNumber', 'r.datec' => 'DateCreation');
// Add extra fields // Add extra fields
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'resource' AND entity IN (0,".$conf->entity.")"; $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'resource' AND entity IN (0,".((int) $conf->entity).")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { // This can fail when class is used on old database (during migration for example) if ($resql) { // This can fail when class is used on old database (during migration for example)
while ($obj = $this->db->fetch_object($resql)) { while ($obj = $this->db->fetch_object($resql)) {

View file

@ -3,6 +3,7 @@
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2024 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2024 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2026 Frédéric France <frederic.france@free.fr> * Copyright (C) 2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2026 MDW <mdeweerd@users.noreply.github.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -78,9 +79,9 @@ class modUser extends DolibarrModules
// Boxes // Boxes
$this->boxes = [ $this->boxes = [
['file'=>'box_lastlogin.php', 'enabledbydefaulton'=>'Home'], ['file' => 'box_lastlogin.php', 'enabledbydefaulton' => 'Home'],
['file'=>'box_birthdays.php', 'enabledbydefaulton'=>'Home'], ['file' => 'box_birthdays.php', 'enabledbydefaulton' => 'Home'],
['file'=>'box_dolibarr_state_board.php', 'enabledbydefaulton'=>'Home'], ['file' => 'box_dolibarr_state_board.php', 'enabledbydefaulton' => 'Home'],
]; ];
// Permissions // Permissions
@ -207,55 +208,55 @@ class modUser extends DolibarrModules
$this->export_label[$r] = 'List of users and attributes'; // Translation key (used only if key ExportDataset_user_1 not found) $this->export_label[$r] = 'List of users and attributes'; // Translation key (used only if key ExportDataset_user_1 not found)
$this->export_permission[$r] = array(array("user", "user", "export")); $this->export_permission[$r] = array(array("user", "user", "export"));
$this->export_fields_array[$r] = array( $this->export_fields_array[$r] = array(
'u.rowid'=>"Id", 'u.login'=>"Login", 'u.lastname'=>"Lastname", 'u.firstname'=>"Firstname", 'u.employee'=>"Employee", 'u.job'=>"PostOrFunction", 'u.gender'=>"Gender", 'u.rowid' => "Id", 'u.login' => "Login", 'u.lastname' => "Lastname", 'u.firstname' => "Firstname", 'u.employee' => "Employee", 'u.job' => "PostOrFunction", 'u.gender' => "Gender",
'u.accountancy_code'=>"UserAccountancyCode", 'u.accountancy_code' => "UserAccountancyCode",
'u.address'=>"Address", 'u.zip'=>"Zip", 'u.town'=>"Town", 'u.address' => "Address", 'u.zip' => "Zip", 'u.town' => "Town",
'u.office_phone'=>'Phone', 'u.user_mobile'=>"Mobile", 'u.office_fax'=>'Fax', 'u.office_phone' => 'Phone', 'u.user_mobile' => "Mobile", 'u.office_fax' => 'Fax',
'u.email'=>"Email", 'u.note_public'=>"NotePublic", 'u.note_private'=>"NotePrivate", 'u.signature'=>'Signature', 'u.email' => "Email", 'u.note_public' => "NotePublic", 'u.note_private' => "NotePrivate", 'u.signature' => 'Signature',
'u.fk_user'=>'HierarchicalResponsible', 'u.thm'=>'THM', 'u.tjm'=>'TJM', 'u.weeklyhours'=>'WeeklyHours', 'u.fk_user' => 'HierarchicalResponsible', 'u.thm' => 'THM', 'u.tjm' => 'TJM', 'u.weeklyhours' => 'WeeklyHours',
'u.dateemployment'=>'DateEmploymentStart', 'u.dateemploymentend'=>'DateEmploymentEnd', 'u.salary'=>'Salary', 'u.color'=>'Color', 'u.api_key'=>'ApiKey', 'u.dateemployment' => 'DateEmploymentStart', 'u.dateemploymentend' => 'DateEmploymentEnd', 'u.salary' => 'Salary', 'u.color' => 'Color', 'u.api_key' => 'ApiKey',
'u.birth'=>'DateOfBirth', 'u.birth' => 'DateOfBirth',
'u.datec'=>"DateCreation", 'u.tms'=>"DateLastModification", 'u.datec' => "DateCreation", 'u.tms' => "DateLastModification",
'u.admin'=>"Administrator", 'u.statut'=>'Status', 'u.datelastlogin'=>'LastConnexion', 'u.datepreviouslogin'=>'PreviousConnexion', 'u.admin' => "Administrator", 'u.statut' => 'Status', 'u.datelastlogin' => 'LastConnexion', 'u.datepreviouslogin' => 'PreviousConnexion',
'u.fk_socpeople'=>"IdContact", 'u.fk_soc'=>"IdCompany", 'u.fk_socpeople' => "IdContact", 'u.fk_soc' => "IdCompany",
'u.fk_member'=>"MemberId", 'u.fk_member' => "MemberId",
"a.firstname"=>"MemberFirstname", "a.firstname" => "MemberFirstname",
"a.lastname"=>"MemberLastname", "a.lastname" => "MemberLastname",
'g.nom'=>"Group" 'g.nom' => "Group"
); );
$this->export_TypeFields_array[$r] = array( $this->export_TypeFields_array[$r] = array(
'u.rowid'=>'Numeric', 'u.login'=>"Text", 'u.lastname'=>"Text", 'u.firstname'=>"Text", 'u.employee'=>'Boolean', 'u.job'=>'Text', 'u.rowid' => 'Numeric', 'u.login' => "Text", 'u.lastname' => "Text", 'u.firstname' => "Text", 'u.employee' => 'Boolean', 'u.job' => 'Text',
'u.accountancy_code'=>'Text', 'u.accountancy_code' => 'Text',
'u.address'=>"Text", 'u.zip'=>"Text", 'u.town'=>"Text", 'u.address' => "Text", 'u.zip' => "Text", 'u.town' => "Text",
'u.office_phone'=>'Text', 'u.user_mobile'=>'Text', 'u.office_fax'=>'Text', 'u.office_phone' => 'Text', 'u.user_mobile' => 'Text', 'u.office_fax' => 'Text',
'u.email'=>'Text', 'u.datec'=>"Date", 'u.tms'=>"Date", 'u.admin'=>"Boolean", 'u.statut'=>'Status', 'u.note_public'=>"Text", 'u.note_private'=>"Text", 'u.signature'=>"Text", 'u.datelastlogin'=>'Date', 'u.email' => 'Text', 'u.datec' => "Date", 'u.tms' => "Date", 'u.admin' => "Boolean", 'u.statut' => 'Status', 'u.note_public' => "Text", 'u.note_private' => "Text", 'u.signature' => "Text", 'u.datelastlogin' => 'Date',
'u.fk_user'=>"FormSelect:select_dolusers", 'u.fk_user' => "FormSelect:select_dolusers",
'u.birth'=>'Date', 'u.birth' => 'Date',
'u.datepreviouslogin'=>'Date', 'u.datepreviouslogin' => 'Date',
'u.fk_socpeople'=>'FormSelect:selectcontacts', 'u.fk_socpeople' => 'FormSelect:selectcontacts',
'u.fk_soc'=>"FormSelect:select_company", 'u.fk_soc' => "FormSelect:select_company",
'u.tjm'=>"Numeric", 'u.thm'=>"Numeric", 'u.fk_member'=>"Numeric", 'u.tjm' => "Numeric", 'u.thm' => "Numeric", 'u.fk_member' => "Numeric",
'u.weeklyhours'=>"Numeric", 'u.weeklyhours' => "Numeric",
'u.dateemployment'=>"Date", 'u.dateemploymentend'=>"Date", 'u.salary'=>"Numeric", 'u.dateemployment' => "Date", 'u.dateemploymentend' => "Date", 'u.salary' => "Numeric",
'u.color'=>'Text', 'u.api_key'=>'Text', 'u.color' => 'Text', 'u.api_key' => 'Text',
'a.firstname'=>'Text', 'a.firstname' => 'Text',
'a.lastname'=>'Text', 'a.lastname' => 'Text',
'g.nom'=>"Text" 'g.nom' => "Text"
); );
$this->export_entities_array[$r] = array( $this->export_entities_array[$r] = array(
'u.rowid'=>"user", 'u.login'=>"user", 'u.lastname'=>"user", 'u.firstname'=>"user", 'u.employee'=>'user', 'u.job'=>'user', 'u.gender'=>'user', 'u.rowid' => "user", 'u.login' => "user", 'u.lastname' => "user", 'u.firstname' => "user", 'u.employee' => 'user', 'u.job' => 'user', 'u.gender' => 'user',
'u.accountancy_code'=>'user', 'u.accountancy_code' => 'user',
'u.address'=>"user", 'u.zip'=>"user", 'u.town'=>"user", 'u.address' => "user", 'u.zip' => "user", 'u.town' => "user",
'u.office_phone'=>'user', 'u.user_mobile'=>'user', 'u.office_fax'=>'user', 'u.office_phone' => 'user', 'u.user_mobile' => 'user', 'u.office_fax' => 'user',
'u.email'=>'user', 'u.note_public'=>"user", 'u.note_private'=>"user", 'u.signature'=>'user', 'u.email' => 'user', 'u.note_public' => "user", 'u.note_private' => "user", 'u.signature' => 'user',
'u.fk_user'=>'user', 'u.thm'=>'user', 'u.tjm'=>'user', 'u.weeklyhours'=>'user', 'u.fk_user' => 'user', 'u.thm' => 'user', 'u.tjm' => 'user', 'u.weeklyhours' => 'user',
'u.dateemployment'=>'user', 'u.dateemploymentend'=>'user', 'u.salary'=>'user', 'u.color'=>'user', 'u.api_key'=>'user', 'u.dateemployment' => 'user', 'u.dateemploymentend' => 'user', 'u.salary' => 'user', 'u.color' => 'user', 'u.api_key' => 'user',
'u.birth'=>'user', 'u.birth' => 'user',
'u.datec'=>"user", 'u.tms'=>"user", 'u.datec' => "user", 'u.tms' => "user",
'u.admin'=>"user", 'u.statut'=>'user', 'u.datelastlogin'=>'user', 'u.datepreviouslogin'=>'user', 'u.admin' => "user", 'u.statut' => 'user', 'u.datelastlogin' => 'user', 'u.datepreviouslogin' => 'user',
'u.fk_socpeople'=>"contact", 'u.fk_soc'=>"company", 'u.fk_member'=>"member", 'u.fk_socpeople' => "contact", 'u.fk_soc' => "company", 'u.fk_member' => "member",
'a.firstname'=>"member", 'a.lastname'=>"member", 'a.firstname' => "member", 'a.lastname' => "member",
'g.nom'=>"Group" 'g.nom' => "Group"
); );
$keyforselect = 'user'; $keyforselect = 'user';
$keyforelement = 'user'; $keyforelement = 'user';
@ -279,28 +280,28 @@ class modUser extends DolibarrModules
$this->export_label[$r] = 'List of security events'; // Translation key (used only if key ExportDataset_user_2 not found) $this->export_label[$r] = 'List of security events'; // Translation key (used only if key ExportDataset_user_2 not found)
$this->export_permission[$r] = array(array("user")); // Only admin $this->export_permission[$r] = array(array("user")); // Only admin
$this->export_fields_array[$r] = array( $this->export_fields_array[$r] = array(
'e.rowid'=>"Id", 'e.type'=>"Type", 'e.rowid' => "Id", 'e.type' => "Type",
'e.dateevent'=>"Date", 'e.dateevent' => "Date",
'e.description'=>'Description', 'e.description' => 'Description',
'e.ip'=>'IPAddress', 'e.user_agent'=>'UserAgent', 'e.ip' => 'IPAddress', 'e.user_agent' => 'UserAgent',
'e.authentication_method' => 'AuthenticationMode', 'e.authentication_method' => 'AuthenticationMode',
'e.fk_user'=>"UserID", 'u.login'=>"Login", 'e.fk_user' => "UserID", 'u.login' => "Login",
); );
$this->export_TypeFields_array[$r] = array( $this->export_TypeFields_array[$r] = array(
'e.rowid'=>'Numeric', 'e.type'=>"Text", 'e.rowid' => 'Numeric', 'e.type' => "Text",
'e.dateevent'=>"Date", 'e.dateevent' => "Date",
'e.description'=>'Text', 'e.description' => 'Text',
'e.ip'=>'Text', 'e.user_agent'=>'Text', 'e.ip' => 'Text', 'e.user_agent' => 'Text',
'e.authentication_method' => 'Text', 'e.authentication_method' => 'Text',
'e.fk_user'=>"Numeric", 'u.login'=>"Text", 'e.fk_user' => "Numeric", 'u.login' => "Text",
); );
$this->export_entities_array[$r] = array( $this->export_entities_array[$r] = array(
'e.rowid'=>'securityevent', 'e.type'=>"securityevent", 'e.rowid' => 'securityevent', 'e.type' => "securityevent",
'e.dateevent'=>"securityevent", 'e.dateevent' => "securityevent",
'e.description'=>'securityevent', 'e.description' => 'securityevent',
'e.ip'=>'securityevent', 'e.user_agent'=>'securityevent', 'e.ip' => 'securityevent', 'e.user_agent' => 'securityevent',
'e.authentication_method' => 'securityevent', 'e.authentication_method' => 'securityevent',
'e.fk_user'=>"user", 'u.login'=>"user", 'e.fk_user' => "user", 'u.login' => "user",
); );
$this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'events as e'; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'events as e';
@ -317,22 +318,22 @@ class modUser extends DolibarrModules
$this->import_label[$r] = 'ImportDataset_user_1'; $this->import_label[$r] = 'ImportDataset_user_1';
$this->import_icon[$r] = 'user'; $this->import_icon[$r] = 'user';
$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r] = array('u'=>MAIN_DB_PREFIX.'user', 'extra'=>MAIN_DB_PREFIX.'user_extrafields'); // List of tables to insert into (insert done in same order) $this->import_tables_array[$r] = array('u' => MAIN_DB_PREFIX.'user', 'extra' => MAIN_DB_PREFIX.'user_extrafields'); // List of tables to insert into (insert done in same order)
$this->import_fields_array[$r] = array( $this->import_fields_array[$r] = array(
'u.login'=>"Login*", 'u.lastname'=>"Name*", 'u.firstname'=>"Firstname", 'u.employee'=>"Employee*", 'u.job'=>"PostOrFunction", 'u.gender'=>"Gender", 'u.login' => "Login*", 'u.lastname' => "Name*", 'u.firstname' => "Firstname", 'u.employee' => "Employee*", 'u.job' => "PostOrFunction", 'u.gender' => "Gender",
'u.accountancy_code'=>"UserAccountancyCode", 'u.accountancy_code' => "UserAccountancyCode",
'u.pass_crypted'=>"Password", 'u.admin'=>"Administrator", 'u.fk_soc'=>"Company*", 'u.address'=>"Address", 'u.zip'=>"Zip", 'u.town'=>"Town", 'u.pass_crypted' => "Password", 'u.admin' => "Administrator", 'u.fk_soc' => "Company*", 'u.address' => "Address", 'u.zip' => "Zip", 'u.town' => "Town",
'u.fk_state'=>"StateId", 'u.fk_country'=>"CountryCode", 'u.fk_state' => "StateId", 'u.fk_country' => "CountryCode",
'u.office_phone'=>"Phone", 'u.user_mobile'=>"Mobile", 'u.office_fax'=>"Fax", 'u.office_phone' => "Phone", 'u.user_mobile' => "Mobile", 'u.office_fax' => "Fax",
'u.email'=>"Email", 'u.note_public'=>"NotePublic", 'u.note_private'=>"NotePrivate", 'u.signature'=>'Signature', 'u.email' => "Email", 'u.note_public' => "NotePublic", 'u.note_private' => "NotePrivate", 'u.signature' => 'Signature',
'u.fk_user'=>'HierarchicalResponsible', 'u.thm'=>'THM', 'u.tjm'=>'TJM', 'u.weeklyhours'=>'WeeklyHours', 'u.fk_user' => 'HierarchicalResponsible', 'u.thm' => 'THM', 'u.tjm' => 'TJM', 'u.weeklyhours' => 'WeeklyHours',
'u.dateemployment'=>'DateEmploymentStart', 'u.dateemploymentend'=>'DateEmploymentEnd', 'u.salary'=>'Salary', 'u.color'=>'Color', 'u.api_key'=>'ApiKey', 'u.dateemployment' => 'DateEmploymentStart', 'u.dateemploymentend' => 'DateEmploymentEnd', 'u.salary' => 'Salary', 'u.color' => 'Color', 'u.api_key' => 'ApiKey',
'u.birth'=>'DateOfBirth', 'u.birth' => 'DateOfBirth',
'u.datec'=>"DateCreation", 'u.datec' => "DateCreation",
'u.statut'=>'Status' 'u.statut' => 'Status'
); );
// Add extra fields // Add extra fields
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'user' AND entity IN (0,".$conf->entity.")"; $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'user' AND entity IN (0,".((int) $conf->entity).")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { // This can fail when class is used on old database (during migration for example) if ($resql) { // This can fail when class is used on old database (during migration for example)
while ($obj = $this->db->fetch_object($resql)) { while ($obj = $this->db->fetch_object($resql)) {
@ -342,28 +343,28 @@ class modUser extends DolibarrModules
} }
} }
// End add extra fields // End add extra fields
$this->import_fieldshidden_array[$r] = array('u.fk_user_creat'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'user'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_fieldshidden_array[$r] = array('u.fk_user_creat' => 'user->id', 'extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'user'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_convertvalue_array[$r] = array( $this->import_convertvalue_array[$r] = array(
'u.fk_state'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/cstate.class.php', 'class'=>'Cstate', 'method'=>'fetch', 'dict'=>'DictionaryState'), 'u.fk_state' => array('rule' => 'fetchidfromcodeid', 'classfile' => '/core/class/cstate.class.php', 'class' => 'Cstate', 'method' => 'fetch', 'dict' => 'DictionaryState'),
'u.fk_country'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/ccountry.class.php', 'class'=>'Ccountry', 'method'=>'fetch', 'dict'=>'DictionaryCountry'), 'u.fk_country' => array('rule' => 'fetchidfromcodeid', 'classfile' => '/core/class/ccountry.class.php', 'class' => 'Ccountry', 'method' => 'fetch', 'dict' => 'DictionaryCountry'),
'u.salary'=>array('rule'=>'numeric') 'u.salary' => array('rule' => 'numeric')
); );
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
$this->import_regex_array[$r] = array( $this->import_regex_array[$r] = array(
'u.employee'=>'^[0|1]', 'u.employee' => '^[0|1]',
'u.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$', 'u.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$',
'u.dateemployment'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'u.dateemployment' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
'u.birth'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$' 'u.birth' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'
); );
$this->import_examplevalues_array[$r] = array( $this->import_examplevalues_array[$r] = array(
'u.lastname'=>"Doe", 'u.firstname'=>'John', 'u.login'=>'jdoe', 'u.employee'=>'0 or 1', 'u.job'=>'CTO', 'u.gender'=>'man or woman', 'u.lastname' => "Doe", 'u.firstname' => 'John', 'u.login' => 'jdoe', 'u.employee' => '0 or 1', 'u.job' => 'CTO', 'u.gender' => 'man or woman',
'u.pass_crypted'=>'Encrypted password', 'u.pass_crypted' => 'Encrypted password',
'u.fk_soc'=>'0 (internal user) or company name (external user)', 'u.address'=>"61 jump street", 'u.fk_soc' => '0 (internal user) or company name (external user)', 'u.address' => "61 jump street",
'u.zip'=>"123456", 'u.town'=>"Big town", 'u.fk_country'=>'US, FR, DE...', 'u.office_phone'=>"0101010101", 'u.office_fax'=>"0101010102", 'u.zip' => "123456", 'u.town' => "Big town", 'u.fk_country' => 'US, FR, DE...', 'u.office_phone' => "0101010101", 'u.office_fax' => "0101010102",
'u.email'=>"test@mycompany.com", 'u.salary'=>"10000", 'u.note_public'=>"This is an example of public note for record", 'u.note_private'=>"This is an example of private note for record", 'u.datec'=>"2015-01-01 or 2015-01-01 12:30:00", 'u.email' => "test@mycompany.com", 'u.salary' => "10000", 'u.note_public' => "This is an example of public note for record", 'u.note_private' => "This is an example of private note for record", 'u.datec' => "2015-01-01 or 2015-01-01 12:30:00",
'u.statut'=>"0 (closed) or 1 (active)", 'u.statut' => "0 (closed) or 1 (active)",
); );
$this->import_updatekeys_array[$r] = array('u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'u.login'=>'Login'); $this->import_updatekeys_array[$r] = array('u.lastname' => 'Lastname', 'u.firstname' => 'Firstname', 'u.login' => 'Login');
} }

View file

@ -2,7 +2,7 @@
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -99,10 +99,10 @@ class mod_propale_marbre extends ModeleNumRefPropales
$max = ''; $max = '';
$posindice = strlen($this->prefix) + 6; $posindice = strlen($this->prefix) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".((int) $posindice).") AS SIGNED)) as max";
$sql .= " FROM ".MAIN_DB_PREFIX."propal"; $sql .= " FROM ".MAIN_DB_PREFIX."propal";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".((int) $conf->entity);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
@ -135,7 +135,7 @@ class mod_propale_marbre extends ModeleNumRefPropales
// First, we get the max value // First, we get the max value
$posindice = strlen($this->prefix) + 6; $posindice = strlen($this->prefix) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".((int) $posindice).") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."propal"; $sql .= " FROM ".MAIN_DB_PREFIX."propal";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql .= " AND entity IN (".getEntity('proposalnumber', 1, $propal).")"; $sql .= " AND entity IN (".getEntity('proposalnumber', 1, $propal).")";