Merge branch 'develop' into New-file-cache

This commit is contained in:
Lucas Marcouiller 2024-12-19 12:02:38 +01:00 committed by GitHub
commit c18e2346a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
54 changed files with 1174 additions and 860 deletions

View file

@ -18,3 +18,4 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/changed-lines-count-labeler.yml
continue-on-error: true

View file

@ -463,7 +463,7 @@ parameters:
path: ../../htdocs/accountancy/class/accountingaccount.class.php
-
message: '#^Call to function array_key_exists\(\) with ''error'' and array\{ref\: mixed, label\: mixed, acquisition_value_ht\: mixed, depreciation\: non\-empty\-array\<int\|string, array\{date\: mixed, ref\: mixed, lines\: non\-empty\-array\<int\|string, mixed\>\}\>, disposal\?\: array\{date\: mixed, amount\: mixed, subject_to_vat\: bool\}\} will always evaluate to false\.$#'
message: '#^Call to function array_key_exists\(\) with ''error'' and array\{ref\: mixed, label\: mixed, acquisition_value_ht\: mixed, depreciation\: non\-empty\-array\<array\{date\: mixed, ref\: mixed, lines\: non\-empty\-array\<mixed\>\}\>, disposal\?\: array\{date\: mixed, amount\: mixed, subject_to_vat\: bool\}\} will always evaluate to false\.$#'
identifier: function.impossibleType
count: 1
path: ../../htdocs/accountancy/class/accountingjournal.class.php
@ -625,7 +625,7 @@ parameters:
path: ../../htdocs/accountancy/class/lettering.class.php
-
message: '#^Parameter \#1 \$link_by_element of method Lettering\:\:getGroupElements\(\) expects array\<array\<string, int\>\>, array\<int\|string, array\<string, string\>\> given\.$#'
message: '#^Parameter \#1 \$link_by_element of method Lettering\:\:getGroupElements\(\) expects array\<array\<string, int\>\>, array\<array\<string, string\>\> given\.$#'
identifier: argument.type
count: 1
path: ../../htdocs/accountancy/class/lettering.class.php
@ -894,10 +894,16 @@ parameters:
count: 1
path: ../../htdocs/adherents/card.php
-
message: '#^Call to function is_array\(\) with array will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../htdocs/adherents/class/adherent.class.php
-
message: '#^Call to function is_array\(\) with array\<mixed\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 2
count: 1
path: ../../htdocs/adherents/class/adherent.class.php
-
@ -3343,7 +3349,7 @@ parameters:
path: ../../htdocs/categories/class/categorie.class.php
-
message: '#^Method Categorie\:\:get_full_arbo\(\) should return \-1\|array\<int, array\{rowid\: int, id\: int, fk_parent\: int, label\: string, description\: string, color\: string, position\: string, visible\: int, \.\.\.\}\> but returns array\<int\|string, array\{rowid\: mixed, id\: mixed, fk_parent\: mixed, label\: mixed, description\: mixed, color\: mixed, position\: mixed, visible\: mixed, \.\.\.\}\>\.$#'
message: '#^Method Categorie\:\:get_full_arbo\(\) should return \-1\|array\<int, array\{rowid\: int, id\: int, fk_parent\: int, label\: string, description\: string, color\: string, position\: string, visible\: int, \.\.\.\}\> but returns array\<array\{rowid\: mixed, id\: mixed, fk_parent\: mixed, label\: mixed, description\: mixed, color\: mixed, position\: mixed, visible\: mixed, \.\.\.\}\>\.$#'
identifier: return.type
count: 1
path: ../../htdocs/categories/class/categorie.class.php
@ -3361,7 +3367,7 @@ parameters:
path: ../../htdocs/categories/class/categorie.class.php
-
message: '#^Property Categorie\:\:\$cats \(array\<int, array\{rowid\: int, id\: int, fk_parent\: int, label\: string, description\: string, color\: string, position\: string, visible\: int, \.\.\.\}\>\) does not accept array\<int\|string, array\{rowid\: mixed, id\: mixed, fk_parent\: mixed, label\: mixed, description\: mixed, color\: mixed, position\: mixed, visible\: mixed, \.\.\.\}\>\.$#'
message: '#^Property Categorie\:\:\$cats \(array\<int, array\{rowid\: int, id\: int, fk_parent\: int, label\: string, description\: string, color\: string, position\: string, visible\: int, \.\.\.\}\>\) does not accept array\<array\{rowid\: mixed, id\: mixed, fk_parent\: mixed, label\: mixed, description\: mixed, color\: mixed, position\: mixed, visible\: mixed, \.\.\.\}\>\.$#'
identifier: assign.propertyType
count: 2
path: ../../htdocs/categories/class/categorie.class.php
@ -5311,7 +5317,7 @@ parameters:
path: ../../htdocs/compta/cashcontrol/class/cashcontrol.class.php
-
message: '#^Call to function is_array\(\) with non\-empty\-array\<int\|string, \(float\|int\)\> will always evaluate to true\.$#'
message: '#^Call to function is_array\(\) with non\-empty\-array\<\(float\|int\)\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../htdocs/compta/cashcontrol/report.php
@ -6601,7 +6607,7 @@ parameters:
path: ../../htdocs/compta/resultat/index.php
-
message: '#^Call to function is_array\(\) with non\-empty\-array\<int\|string, array\{NP\: mixed, N\?\: \(float\|int\), M\?\: non\-empty\-array\<0\|1\|2\|3\|4\|5\|6\|7\|8\|9\|10\|11, mixed\>\}\> will always evaluate to true\.$#'
message: '#^Call to function is_array\(\) with non\-empty\-array\<array\{NP\: mixed, N\?\: \(float\|int\), M\?\: non\-empty\-array\<0\|1\|2\|3\|4\|5\|6\|7\|8\|9\|10\|11, mixed\>\}\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../htdocs/compta/resultat/result.php
@ -7969,7 +7975,7 @@ parameters:
path: ../../htdocs/core/actions_linkedfiles.inc.php
-
message: '#^Call to function is_array\(\) with non\-empty\-array\<int\|string, array\{paths\: array\{mixed\}, names\: array\{string\}, mimes\: array\{mixed\}\}\> will always evaluate to true\.$#'
message: '#^Call to function is_array\(\) with non\-empty\-array\<array\{paths\: array\{mixed\}, names\: array\{string\}, mimes\: array\{mixed\}\}\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../htdocs/core/actions_massactions.inc.php
@ -10537,7 +10543,7 @@ parameters:
path: ../../htdocs/core/class/notify.class.php
-
message: '#^Call to function is_array\(\) with non\-empty\-array\<int\|string, string\> will always evaluate to true\.$#'
message: '#^Call to function is_array\(\) with non\-empty\-array\<string\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../htdocs/core/class/openid.class.php
@ -13597,7 +13603,7 @@ parameters:
path: ../../htdocs/core/modules/hrm/mod_evaluation_standard.php
-
message: '#^Call to function is_array\(\) with non\-empty\-array will always evaluate to true\.$#'
message: '#^Call to function is_array\(\) with non\-empty\-list\<string\|null\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../htdocs/core/modules/import/import_csv.modules.php
@ -23299,7 +23305,7 @@ parameters:
path: ../../htdocs/master.inc.php
-
message: '#^Call to function is_array\(\) with array\<int\|string, array\{modulenamewithcase\: mixed, moduledescriptorrelpath\: string, moduledescriptorfullpath\: mixed, moduledescriptorrootpath\: mixed, moduletype\?\: ''external''\|''internal''\}\> will always evaluate to true\.$#'
message: '#^Call to function is_array\(\) with array\<array\{modulenamewithcase\: mixed, moduledescriptorrelpath\: string, moduledescriptorfullpath\: mixed, moduledescriptorrootpath\: mixed, moduletype\?\: ''external''\|''internal''\}\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../htdocs/modulebuilder/index.php
@ -30312,12 +30318,6 @@ parameters:
count: 1
path: ../../htdocs/salaries/list.php
-
message: '#^Variable \$resteapayer might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/salaries/list.php
-
message: '#^Variable \$selected might not be defined\.$#'
identifier: variable.undefined
@ -30336,12 +30336,6 @@ parameters:
count: 2
path: ../../htdocs/salaries/paiement_salary.php
-
message: '#^Variable \$sumpaid might not be defined\.$#'
identifier: variable.undefined
count: 3
path: ../../htdocs/salaries/paiement_salary.php
-
message: '#^Negated boolean expression is always false\.$#'
identifier: booleanNot.alwaysFalse
@ -30432,24 +30426,6 @@ parameters:
count: 1
path: ../../htdocs/societe/ajax/company.php
-
message: '#^Variable \$canvas might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/societe/canvas/company/tpl/card_create.tpl.php
-
message: '#^Variable \$canvas might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/societe/canvas/company/tpl/card_edit.tpl.php
-
message: '#^Variable \$canvas might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../htdocs/societe/canvas/company/tpl/card_view.tpl.php
-
message: '#^Variable \$db might not be defined\.$#'
identifier: variable.undefined
@ -30937,7 +30913,7 @@ parameters:
path: ../../htdocs/societe/notify/card.php
-
message: '#^Call to function is_array\(\) with array\<int\|string, array\{available\: mixed, currency\: mixed, pending\?\: \(array\|float\|int\)\}\> will always evaluate to true\.$#'
message: '#^Call to function is_array\(\) with array\<array\{available\: mixed, currency\: mixed, pending\?\: \(array\|float\|int\)\}\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../htdocs/societe/paymentmodes.php

View file

@ -883,7 +883,7 @@ $html .= '<h2><span class="fas fa-code pictofixedwidth"></span>'.$title_security
$html .= '<div class="boxallwidth">'."\n";
$html .= '<div class="div-table-responsive">'."\n";
$html .= '<table class="list_technical_debt centpercent">'."\n";
$html .= '<tr class="trgroup"><td>Commit ID</td><td>Date</td><td style="white-space: nowrap">Reported on<br>Yogosha</td><td style="white-space: nowrap">Reported on<br>GIT</td><td style="white-space: nowrap">Reported on<br>CVE</td><td>Title</td><td>Branch of fix</td></tr>'."\n";
$html .= '<tr class="trgroup"><td>Commit ID</td><td>Date</td><td style="white-space: nowrap">Reported on<br>Yogosha</td><td style="white-space: nowrap">Reported on<br>GIT</td><td style="white-space: nowrap"><a href="https://www.cve.org/CVERecord/SearchResults?query=dolibarr">Reported on<br>CVE</a></td><td>Title</td><td>Branch of fix</td></tr>'."\n";
foreach ($arrayofalerts as $key => $alert) {
$cve = '';
$yogosha = empty($alert['issueidyogosha']) ? '' : $alert['issueidyogosha'];

View file

@ -17,7 +17,7 @@ return [
// PhanTypeMismatchProperty : 130+ occurrences
// PhanPluginUnknownArrayMethodParamType : 120+ occurrences
// PhanPluginUnknownPropertyType : 110+ occurrences
// PhanPossiblyUndeclaredVariable : 80+ occurrences
// PhanPossiblyUndeclaredVariable : 65+ occurrences
// PhanRedefineFunction : 45+ occurrences
// PhanTypeExpectedObjectPropAccess : 45+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 40+ occurrences
@ -507,7 +507,7 @@ return [
'htdocs/recruitment/admin/setup_candidatures.php' => ['PhanEmptyForeach'],
'htdocs/recruitment/class/recruitmentcandidature.class.php' => ['PhanUndeclaredProperty'],
'htdocs/recruitment/class/recruitmentjobposition.class.php' => ['PhanUndeclaredProperty'],
'htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php' => ['PhanPluginSuspiciousParamOrder', 'PhanUndeclaredProperty'],
'htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php' => ['PhanPluginSuspiciousParamOrder', 'PhanUndeclaredProperty'],
'htdocs/recruitment/index.php' => ['PhanUndeclaredGlobalVariable'],
@ -523,7 +523,7 @@ return [
'htdocs/salaries/card.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/salaries/class/api_salaries.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType'],
'htdocs/salaries/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable'],
'htdocs/salaries/paiement_salary.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/salaries/paiement_salary.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/salaries/virement_request.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredProperty'],
'htdocs/societe/admin/societe.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod'],
'htdocs/societe/ajax/company.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],

View file

@ -3,7 +3,8 @@
* Copyright (C) 2015-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2015-2020 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Jose MARTINEZ <jose.martinez@pichinov.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
@ -68,7 +69,7 @@ class BookKeeping extends CommonObject
public $doc_date;
/**
* @var int Deadline for payment
* @var int|null|'' Deadline for payment
*/
public $date_lim_reglement;
@ -324,7 +325,7 @@ class BookKeeping extends CommonObject
$this->piece_num = 0;
// First check if line not yet already in bookkeeping.
// Note that we must include 'doc_type - fk_doc - numero_compte - label' to be sure to have unicity of line (because we may have several lines
// Note that we must include 'doc_type - fk_doc - numero_compte - label - subledger_account (if not empty)' to be sure to have unicity of line (because we may have several lines
// with same doc_type, fk_doc, numero_compte for 1 invoice line when using localtaxes with same account)
// WARNING: This is not reliable, label may have been modified. This is just a small protection.
// The page that make transfer make the test on couple (doc_type - fk_doc) only.
@ -338,6 +339,9 @@ class BookKeeping extends CommonObject
}
$sql .= " AND numero_compte = '".$this->db->escape($this->numero_compte)."'";
$sql .= " AND label_operation = '".$this->db->escape($this->label_operation)."'";
if (!empty($this->subledger_account)) {
$sql .= " AND subledger_account = '".$this->db->escape($this->subledger_account)."'";
}
$sql .= " AND entity = ".$conf->entity; // Do not use getEntity for accounting features
$resql = $this->db->query($sql);
@ -2863,10 +2867,8 @@ class BookKeeping extends CommonObject
$sql = 'SELECT';
$sql .= " t.numero_compte,";
$sql .= " t.label_compte,";
if ($separate_auxiliary_account) {
$sql .= " t.subledger_account,";
$sql .= " t.subledger_label,";
$sql .= " NULLIF(t.subledger_account, '') as subledger_account,"; // fix db issues with Null or "" values
}
$sql .= " aa.pcg_type,";
$sql .= " (SUM(t.credit) - SUM(t.debit)) as opening_balance";
@ -2878,10 +2880,11 @@ class BookKeeping extends CommonObject
$sql .= ' AND aa.pcg_type IN (' . $this->db->sanitize(implode(',', $pcg_type_filter), 1) . ')';
$sql .= " AND DATE(t.doc_date) >= '" . $this->db->idate($fiscal_period->date_start) . "'";
$sql .= " AND DATE(t.doc_date) <= '" . $this->db->idate($fiscal_period->date_end) . "'";
$sql .= ' GROUP BY t.numero_compte, t.label_compte, aa.pcg_type';
$sql .= ' GROUP BY t.numero_compte, aa.pcg_type';
if ($separate_auxiliary_account) {
$sql .= ' ,t.subledger_account, t.subledger_label';
$sql .= " , NULLIF(t.subledger_account, '')";
}
$sql .= ' HAVING (SUM(t.credit) - SUM(t.debit)) != 0 '; // Exclude rows with opening_balance = 0
$sql .= $this->db->order("t.numero_compte", "ASC");
$resql = $this->db->query($sql);
@ -2902,24 +2905,41 @@ class BookKeeping extends CommonObject
$bookkeeping = new BookKeeping($this->db);
$bookkeeping->doc_date = $new_fiscal_period->date_start;
$bookkeeping->date_lim_reglement = 0;
$bookkeeping->doc_ref = $new_fiscal_period->label;
$bookkeeping->date_lim_reglement = '';
$bookkeeping->doc_ref = $fiscal_period->label;
$bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'closure';
$bookkeeping->fk_doc = $new_fiscal_period->id;
$bookkeeping->fk_doc = $fiscal_period->id;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->thirdparty_code = '';
if ($separate_auxiliary_account) {
$bookkeeping->subledger_account = $obj->subledger_account;
$bookkeeping->subledger_label = $obj->subledger_label;
$sql = 'SELECT';
$sql .= " subledger_label";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql .= " WHERE subledger_account = '" . $this->db->escape($obj->subledger_account) . "'";
$sql .= " ORDER BY doc_date DESC";
$sql .= " LIMIT 1";
$result = $this->db->query($sql);
if (!$result) {
$this->errors[] = 'Error: ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
$error++;
}
$objtmp = $this->db->fetch_object($result);
$bookkeeping->subledger_label = $objtmp->subledger_label; // latest subledger label used
} else {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->subledger_account = null;
$bookkeeping->subledger_label = null;
}
$bookkeeping->numero_compte = $obj->numero_compte;
$bookkeeping->label_compte = $obj->label_compte;
$accountingaccount = new AccountingAccount($this->db);
$accountingaccount->fetch(0, $obj->numero_compte);
$bookkeeping->label_compte = $accountingaccount->label; // latest account label used
$bookkeeping->label_operation = $new_fiscal_period->label;
$bookkeeping->montant = $mt;
@ -2933,8 +2953,7 @@ class BookKeeping extends CommonObject
$result = $bookkeeping->create($user);
if ($result < 0) {
$this->error = $bookkeeping->error;
$this->errors = $bookkeeping->errors;
$this->setErrorsFromObject($bookkeeping);
$error++;
break;
}
@ -2949,21 +2968,35 @@ class BookKeeping extends CommonObject
$bookkeeping = new BookKeeping($this->db);
$bookkeeping->doc_date = $new_fiscal_period->date_start;
$bookkeeping->date_lim_reglement = 0;
$bookkeeping->doc_ref = $new_fiscal_period->label;
$bookkeeping->date_lim_reglement = '';
$bookkeeping->doc_ref = $fiscal_period->label;
$bookkeeping->date_creation = $now;
$bookkeeping->doc_type = 'closure';
$bookkeeping->fk_doc = $new_fiscal_period->id;
$bookkeeping->fk_doc = $fiscal_period->id;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->thirdparty_code = '';
if ($separate_auxiliary_account) {
$bookkeeping->subledger_label = '';
$bookkeeping->subledger_account = $obj->subledger_account;
$bookkeeping->subledger_label = $obj->subledger_label;
$sql = 'SELECT';
$sql .= " subledger_label";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql .= " WHERE subledger_account = '" . $this->db->escape($obj->subledger_account) . "'";
$sql .= " ORDER BY doc_date DESC";
$sql .= " LIMIT 1";
$result = $this->db->query($sql);
if (!$result) {
$this->errors[] = 'Error: ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
$error++;
}
$objtmp = $this->db->fetch_object($result);
$bookkeeping->subledger_label = $objtmp->subledger_label; // latest subledger label used
} else {
$bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = '';
$bookkeeping->subledger_account = null;
$bookkeeping->subledger_label = null;
}
$bookkeeping->numero_compte = $accountingaccount->account_number;
@ -2981,8 +3014,7 @@ class BookKeeping extends CommonObject
$result = $bookkeeping->create($user);
if ($result < 0) {
$this->error = $bookkeeping->error;
$this->errors = $bookkeeping->errors;
$this->setErrorsFromObject($bookkeeping);
$error++;
}
}

View file

@ -1546,8 +1546,8 @@ if ($action == 'create') {
$listofuserid[$firstelem['id']]['transparency'] = (GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 0); // 0 by default when refreshing
}
}
print '<div class="assignedtouser">';
print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, array(), 0, '', array(), 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
print '<!-- list of user to assign --><div class="assignedtouser">';
print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, array(), 0, '', array(), 0, 0, 0, 'u.statut:<>:0', 1, $listofuserid, $listofcontactid, $listofotherid);
print '</div>';
print '</td></tr>';
@ -1811,7 +1811,7 @@ if ($action == 'create') {
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
const reminderDefaultEventTypes = '.$reminderDefaultEventTypes.';
const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).'\';
$("#actioncode").change(function(){
var selected_event_type = $("#actioncode option:selected").val();
@ -1820,9 +1820,9 @@ if ($action == 'create') {
$("#addreminder").prop("checked", true);
// Set period with default reminder period
$("[name=\"offsetvalue\"]").val("' . $reminderDefaultOffset . '");
$("[name=\"offsetvalue\"]").val(\'' . dol_escape_js($reminderDefaultOffset) . '\');
$("#select_offsetunittype_duration").select2("destroy");
$("#select_offsetunittype_duration").val("'.$reminderDefaultUnit.'");
$("#select_offsetunittype_duration").val(\''.dol_escape_js($reminderDefaultUnit).'\');
$("#select_offsetunittype_duration").select2();
$("#selectremindertype").select2("destroy");
@ -1832,7 +1832,7 @@ if ($action == 'create') {
// Set default reminder mail model
$("#select_actioncommsendmodel_mail").closest("tr").show();
$("#select_actioncommsendmodel_mail").select2("destroy");
$("#select_actioncommsendmodel_mail").val("'.$reminderDefaultEmailModel.'");
$("#select_actioncommsendmodel_mail").val(\''.dol_escape_js($reminderDefaultEmailModel).'\');
$("#select_actioncommsendmodel_mail").select2();
}
});
@ -1955,6 +1955,8 @@ if ($id > 0) {
}
if ($action == 'edit') {
$caneditdateorowner = ($object->type != 'systemauto');
if (!empty($conf->use_javascript_ajax)) {
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
@ -1972,7 +1974,9 @@ if ($id > 0) {
$(".fulldayendmin").prop("disabled", true).val("59");
}
}
setdatefields();
'.($caneditdateorowner ? ' setdatefields();' : '').'
$("#fullday").change(function() {
setdatefields();
});
@ -2052,7 +2056,8 @@ if ($id > 0) {
print '<tr><td'.(!getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? ' class="fieldrequired titlefieldcreate"' : '').'>'.$langs->trans("Title").'</td><td colspan="3"><input type="text" name="label" class="soixantepercent" value="'.$object->label.'"></td></tr>';
// Full day event
print '<tr><td><span class="fieldrequired">'.$langs->trans("Date").'</span></td><td colspan="3" class="valignmiddle height30 small"><input type="checkbox" id="fullday" name="fullday" '.($object->fulldayevent ? ' checked' : '').'>';
print '<tr><td><span class="fieldrequired">'.$langs->trans("Date").'</span></td><td colspan="3" class="valignmiddle height30 small">';
print '<input '.($caneditdateorowner ? '' : ' disabled').' type="checkbox" id="fullday" name="fullday" '.($object->fulldayevent ? ' checked' : '').'>';
print '<label for="fullday">'.$langs->trans("EventOnFullDay").'</label>';
// // Recurring event
@ -2123,9 +2128,9 @@ if ($id > 0) {
*/
print '</td><td td colspan="3">';
$tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 2, ($caneditdateorowner ? 0 : 1), 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
print ' <span class="hideonsmartphone">&nbsp; &nbsp; - &nbsp; &nbsp;</span> ';
print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 2, ($caneditdateorowner ? 0 : 1), 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
print '</td></tr>';
print '<tr><td class="">&nbsp;</td><td></td></tr>';
@ -2164,7 +2169,7 @@ if ($id > 0) {
print '<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans("ActionAssignedTo").'</td><td colspan="3">';
print '<div class="assignedtouser">';
print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, array(), 0, '', array(), 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, array(), 0, '', array(), 0, 0, 0, 'u.statut:<>:0', 1, $listofuserid, $listofcontactid, $listofotherid, $caneditdateorowner);
print '</div>';
/*if (in_array($user->id,array_keys($listofuserid)))
{
@ -2414,7 +2419,7 @@ if ($id > 0) {
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
const reminderDefaultEventTypes = '.$reminderDefaultEventTypes.';
const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).'\';
$("#actioncode").change(function(){
var selected_event_type = $("#actioncode option:selected").val();
@ -2423,9 +2428,9 @@ if ($id > 0) {
$("#addreminder").prop("checked", true);
// Set period with default reminder period
$("#offsetvalue").val('.$reminderDefaultOffset.');
$("#offsetvalue").val(\''.dol_escape_js($reminderDefaultOffset).'\');
$("#select_offsetunittype_duration").select2("destroy");
$("#select_offsetunittype_duration").val("'.$reminderDefaultUnit.'");
$("#select_offsetunittype_duration").val(\''.dol_escape_js($reminderDefaultUnit).'\');
$("#select_offsetunittype_duration").select2();
$("#selectremindertype").select2("destroy");
@ -2435,7 +2440,7 @@ if ($id > 0) {
// Set default reminder mail model
$("#select_actioncommsendmodel_mail").closest("tr").show();
$("#select_actioncommsendmodel_mail").select2("destroy");
$("#select_actioncommsendmodel_mail").val("'.$reminderDefaultEmailModel.'");
$("#select_actioncommsendmodel_mail").val(\''.dol_escape_js($reminderDefaultEmailModel).'\');
$("#select_actioncommsendmodel_mail").select2();
}
});

View file

@ -569,12 +569,12 @@ $viewmode .= '<span class="marginrightonly"></span>'; // To add a space before t
$newparam = '';
$newcardbutton = '';
if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
$tmpforcreatebutton = dol_getdate(dol_now(), true);
$tmpforcreatebutton = dol_getdate(dol_now('tzuserrel'), true);
$newparam .= '&month='.((int) $month).'&year='.((int) $tmpforcreatebutton['year']).'&mode='.urlencode($mode);
//$param='month='.$monthshown.'&year='.$year;
$hourminsec = dol_print_date(dol_mktime(10, 0, 0, 1, 1, 1970, 'gmt'), '%H', 'gmt').'0000'; // Set $hourminsec to '100000' to auto set hour to 10:00 at creation
//$hourminsec = dol_print_date(dol_mktime(10, 0, 0, 1, 1, 1970, 'gmt'), '%H', 'gmt').'0000'; // Set $hourminsec to '100000' to auto set hour to 10:00 at creation
$urltocreateaction = DOL_URL_ROOT.'/comm/action/card.php?action=create';
$urltocreateaction .= '&apyear='.$tmpforcreatebutton['year'].'&apmonth='.$tmpforcreatebutton['mon'].'&apday='.$tmpforcreatebutton['mday'].'&aphour='.$tmpforcreatebutton['hours'].'&apmin='.$tmpforcreatebutton['minutes'];

View file

@ -736,13 +736,13 @@ $viewmode .= '</div>';
$viewmode .= '<span class="marginrightonly"></span>';
$tmpforcreatebutton = dol_getdate(dol_now(), true);
$tmpforcreatebutton = dol_getdate(dol_now('tzuserrel'), true);
$newparam = '&month='.str_pad((string) $month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
$url = DOL_URL_ROOT.'/comm/action/card.php?action=create';
$url .= '&apyear='.$tmpforcreatebutton['year'].'&apmonth='.$tmpforcreatebutton['mon'].'&apday='.$tmpforcreatebutton['mday'].'&aphour='.$tmpforcreatebutton['hours'].'&apmin='.$tmpforcreatebutton['minutes'];
$url .= '&apyear='.$tmpforcreatebutton['year'].'&apmonth='.$tmpforcreatebutton['mon'].'&apday='.$tmpforcreatebutton['mday'];
$url .= '&aphour='.$tmpforcreatebutton['hours'].'&apmin='.$tmpforcreatebutton['minutes'];
$url .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''));
$newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', (int) ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')));

View file

@ -487,7 +487,7 @@ $viewmode .= '<span class="marginrightonly"></span>';
$newparam = '';
$newcardbutton = '';
if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
$tmpforcreatebutton = dol_getdate(dol_now(), true);
$tmpforcreatebutton = dol_getdate(dol_now('tzuserrel'), true);
$newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];

View file

@ -492,7 +492,7 @@ $viewmode .= '<span class="marginrightonly"></span>';
$newparam = '';
$newcardbutton = '';
if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
$tmpforcreatebutton = dol_getdate(dol_now(), true);
$tmpforcreatebutton = dol_getdate(dol_now('tzuserrel'), true);
$newparam .= '&month='.urlencode(str_pad((string) $month, 2, "0", STR_PAD_LEFT)).'&year='.((int) $tmpforcreatebutton['year']);
if ($begin_h !== '') {

View file

@ -1712,35 +1712,37 @@ if ($object->id > 0) {
}
// Add invoice
if ($user->socid == 0) {
if (isModEnabled('deplacement') && $object->status == 1) {
$langs->load("trips");
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/deplacement/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddTrip").'</a></div>';
}
if (isModEnabled('deplacement') && $object->status == 1) {
$langs->load("trips");
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/deplacement/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddTrip").'</a></div>';
}
if (isModEnabled('invoice') && $object->status == 1) {
if (!$user->hasRight('facture', 'creer')) {
$langs->load("bills");
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
if (isModEnabled('invoice') && $object->status == 1) {
if (!$user->hasRight('facture', 'creer')) {
$langs->load("bills");
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
} else {
$langs->loadLangs(array("orders", "bills"));
if ($object->client != 0 && $object->client != 2) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a></div>';
} else {
$langs->loadLangs(array("orders", "bills"));
if (isModEnabled('order')) {
if ($object->client != 0 && $object->client != 2) {
if (!empty($orders2invoice) && $orders2invoice > 0) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->id.'&search_billed=0&autoselectall=1">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
} else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
}
} else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
}
}
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
}
}
}
if (isModEnabled('invoice') && $object->status == 1) {
if ($user->hasRight('facture', 'creer')) {
if (isModEnabled('order')) {
if ($object->client != 0 && $object->client != 2) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a></div>';
if (!empty($orders2invoice) && $orders2invoice > 0) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->id.'&search_billed=0&autoselectall=1">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
} else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("NoOrdersToInvoice")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
}
} else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("CreateInvoiceForThisCustomer").'</a></div>';
}
}
}

View file

@ -1983,8 +1983,8 @@ while ($i < $imaxinloop) {
}
// Country
if (!empty($arrayfields['country.code_iso']['checked'])) {
print '<td class="center">';
$tmparray = getCountry($obj->fk_pays, 'all');
print '<td class="center tdoverflowmax100" title="'.dolPrintHTML($tmparray['label']).'">';
print $tmparray['label'];
print '</td>';
if (!$i) {

View file

@ -1108,7 +1108,7 @@ if (empty($reshook)) {
$object->fk_incoterms = GETPOSTINT('incoterm_id');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOSTINT('originmulticurrency_tx');
$object->multicurrency_tx = GETPOSTFLOAT('originmulticurrency_tx');
// Special properties of replacement invoice
$object->fk_facture_source = GETPOSTINT('fac_replacement');
@ -1169,7 +1169,7 @@ if (empty($reshook)) {
$object->fk_incoterms = GETPOSTINT('incoterm_id');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOSTINT('originmulticurrency_tx');
$object->multicurrency_tx = GETPOSTFLOAT('originmulticurrency_tx');
// Special properties of replacement invoice
$object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : '';
@ -1408,7 +1408,7 @@ if (empty($reshook)) {
$object->fk_incoterms = GETPOSTINT('incoterm_id');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOSTINT('originmulticurrency_tx');
$object->multicurrency_tx = GETPOSTFLOAT('originmulticurrency_tx');
// Source facture
$object->fac_rec = GETPOSTINT('fac_rec');
@ -1495,7 +1495,7 @@ if (empty($reshook)) {
$object->fk_incoterms = GETPOSTINT('incoterm_id');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOSTINT('originmulticurrency_tx');
$object->multicurrency_tx = GETPOSTFLOAT('originmulticurrency_tx');
if (GETPOST('type') == Facture::TYPE_SITUATION) {
$object->situation_counter = 1;
@ -2766,7 +2766,7 @@ if (empty($reshook)) {
// Invoice situation
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 2) {
$previousprogress = $line->getAllPrevProgress($line->fk_facture);
$fullprogress = price2num(GETPOST('progress', 'alpha'));
$fullprogress = price2num(GETPOST('progress', 'alpha'), 2);
if ($fullprogress < $previousprogress) {
$error++;

View file

@ -398,7 +398,7 @@ class FactureRec extends CommonInvoice
$sql .= ", '".$this->db->escape($facsrc->multicurrency_code)."'";
$sql .= ", ".((float) $facsrc->multicurrency_tx);
$sql .= ", ".((int) $this->suspended);
$sql .= ", ".((int) $this->fk_societe_rib);
$sql .= ", ".(!empty($this->fk_societe_rib) ? ((int) $this->fk_societe_rib) : 'NULL');
$sql .= ")";
if ($this->db->query($sql)) {
@ -571,7 +571,7 @@ class FactureRec extends CommonInvoice
$sql .= " localtax2 = ".((float) $this->total_localtax2).",";
$sql .= " total_ht = ".((float) $this->total_ht).",";
$sql .= " total_ttc = ".((float) $this->total_ttc).",";
$sql .= " fk_societe_rib = ".((int) $this->fk_societe_rib);
$sql .= " fk_societe_rib = ".(!empty($this->fk_societe_rib) ? ((int) $this->fk_societe_rib) : 'NULL');;
// TODO Add missing fields
$sql .= " WHERE rowid = ".((int) $this->id);

View file

@ -312,7 +312,7 @@ print '</td></tr>';
// ThirdParty Type
print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>';
$sortparam_typent = (!getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label.
$sortparam_typent = getDolGlobalString('SOCIETE_SORT_ON_TYPEENT', 'ASC'); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label.
print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 1, 0, 0, '', 0, 0, 0, $sortparam_typent, '', 1);
if ($user->admin) {
print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
@ -342,7 +342,7 @@ if (isModEnabled('category')) {
// User
print '<tr><td>'.$langs->trans("CreatedBy").'</td><td>';
print img_picto('', 'user', 'class="pictofixedwidth"');
print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
print $form->select_dolusers($userid ? $userid : -1, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
print '</td></tr>';
// Status
print '<tr><td>'.$langs->trans("Status").'</td><td>';

View file

@ -455,7 +455,7 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $
print '<tr class="oddeven">';
print '<td class="nowrap"><a href="'.DOL_URL_ROOT.'/compta/localtax/quadri_detail.php?leftmenu=tax_vat&month='.$m.'&year='.$y.'">'.dol_print_date(dol_mktime(0, 0, 0, (int) $m, 1, (int) $y), "%b %Y").'</a></td>';
print '<td class="nowrap"><a href="'.DOL_URL_ROOT.'/compta/localtax/quadri_detail.php?leftmenu=tax_vat&month='.$m.'&year='.$y.'&localTaxType='.$localTaxType.'">'.dol_print_date(dol_mktime(0, 0, 0, (int) $m, 1, (int) $y), "%b %Y").'</a></td>';
$x_coll_sum = 0;
foreach (array_keys($x_coll) as $rate) {

View file

@ -1149,15 +1149,16 @@ class Form
* Return list of types of lines (product or service)
* Example: 0=product, 1=service, 9=other (for external module)
*
* @param string $selected Preselected type
* @param string $htmlname Name of field in html form
* @param int<0,1>|string $showempty Add an empty field
* @param int $hidetext Do not show label 'Type' before combo box (used only if there is at least 2 choices to select)
* @param integer $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, 2=Force to show only Products, 3=Force to show only services, -1=Force none (and set hidden field to 'service')
* @param string $morecss More css
* @param string $selected Preselected type
* @param string $htmlname Name of field in html form
* @param int<0,1>|string $showempty Add an empty field
* @param int $hidetext Do not show label 'Type' before combo box (used only if there is at least 2 choices to select)
* @param integer $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, 2=Force to show only Products, 3=Force to show only services, -1=Force none (and set hidden field to 'service')
* @param string $morecss More css
* @param int $useajaxcombo 1=Use ajaxcombo
* @return void
*/
public function select_type_of_lines($selected = '', $htmlname = 'type', $showempty = 0, $hidetext = 0, $forceall = 0, $morecss = "")
public function select_type_of_lines($selected = '', $htmlname = 'type', $showempty = 0, $hidetext = 0, $forceall = 0, $morecss = "", $useajaxcombo = 1)
{
// phpcs:enable
global $langs;
@ -1166,11 +1167,11 @@ class Form
if ($forceall == 1 || (empty($forceall) && isModEnabled("product") && isModEnabled("service"))
|| (empty($forceall) && !isModEnabled('product') && !isModEnabled('service'))) {
if (empty($hidetext)) {
print $langs->trans("Type") . ': ';
print $langs->trans("Type").'...';
}
print '<select class="flat'.($morecss ? ' '.$morecss : '').'" id="select_' . $htmlname . '" name="' . $htmlname . '">';
if ($showempty) {
print '<option value="-1"';
print '<option value="-1" class="opacitymedium"'.($useajaxcombo ? '' : ' disabled="disabled"');
if ($selected == -1) {
print ' selected';
}
@ -1196,7 +1197,10 @@ class Form
print '>' . $langs->trans("Service");
print '</select>';
print ajax_combobox('select_' . $htmlname);
if ($useajaxcombo) {
print ajax_combobox('select_' . $htmlname);
}
//if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
}
if ((empty($forceall) && !isModEnabled('product') && isModEnabled("service")) || $forceall == 3) {
@ -2228,7 +2232,13 @@ class Form
$sql .= " AND u.fk_soc IS NULL";
}
if (!empty($morefilter)) {
$sql .= " " . $morefilter;
$errormessage = '';
$sql .= forgeSQLFromUniversalSearchCriteria($morefilter, $errormessage);
if ($errormessage) {
$this->errors[] = $errormessage;
dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
return -1;
}
}
//Add hook to filter on user (for example on usergroup define in custom modules)
@ -2425,28 +2435,29 @@ class Form
* Return select list of users. Selected users are stored into session.
* List of users are provided into $_SESSION['assignedtouser'].
*
* @param string $action Value for $action
* @param string $htmlname Field name in form
* @param int<0,1> $show_empty 0=list without the empty value, 1=add empty value
* @param int[] $exclude Array list of users id to exclude
* @param int<0,1> $disabled If select list must be disabled
* @param int[]|string $include Array list of users id to include or 'hierarchy' to have only supervised users
* @param int[]|int $enableonly Array list of users id to be enabled. All other must be disabled
* @param string $force_entity '0' or Ids of environment to force
* @param int $maxlength Maximum length of string into list (0=no limit)
* @param int<0,1> $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status
* @param string $morefilter Add more filters into sql request
* @param int $showproperties Show properties of each attendees
* @param int[] $listofuserid Array with properties of each user
* @param int[] $listofcontactid Array with properties of each contact
* @param int[] $listofotherid Array with properties of each other contact
* @return string HTML select string
* @param string $action Value for $action
* @param string $htmlname Field name in form
* @param int<0,1> $show_empty 0=list without the empty value, 1=add empty value
* @param int[] $exclude Array list of users id to exclude
* @param int<0,1> $disabled If select list must be disabled
* @param int[]|''|'hierarchy'|'hierarchyme' $include Array list of users id to include or 'hierarchy' to have only supervised users
* @param int[]|int $enableonly Array list of users id to be enabled. All other must be disabled
* @param string $force_entity '0' or Ids of environment to force
* @param int $maxlength Maximum length of string into list (0=no limit)
* @param int<0,1> $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status
* @param string $morefilter Add more filters into sql request (Example: '(employee:=:1)'). This value must not come from user input.
* @param int $showproperties Show properties of each attendees
* @param int[] $listofuserid Array with properties of each user
* @param int[] $listofcontactid Array with properties of each contact
* @param int[] $listofotherid Array with properties of each other contact
* @param int $canremoveowner 1 if we can remove owner, 0=no way
* @return string HTML select string
* @see select_dolgroups()
*/
public function select_dolusers_forevent($action = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = array(), $enableonly = array(), $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $showproperties = 0, $listofuserid = array(), $listofcontactid = array(), $listofotherid = array())
public function select_dolusers_forevent($action = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = array(), $enableonly = array(), $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $showproperties = 0, $listofuserid = array(), $listofcontactid = array(), $listofotherid = array(), $canremoveowner = 1)
{
// phpcs:enable
global $langs;
global $langs, $user;
$userstatic = new User($this->db);
$out = '';
@ -2479,8 +2490,25 @@ class Form
$ownerid = $value['id'];
$out .= ' (' . $langs->trans("Owner") . ')';
}
// Add picto to delete owner/assignee
if ($nbassignetouser > 1 && $action != 'view') {
$out .= ' <input type="image" style="border: 0px;" src="' . img_picto($langs->trans("Remove"), 'delete', '', 0, 1) . '" value="' . $userstatic->id . '" class="removedassigned reposition" id="removedassigned_' . $userstatic->id . '" name="removedassigned_' . $userstatic->id . '">';
$canremoveassignee = 1;
if ($i == 0) {
// We are on the owner of the event
if (!$canremoveowner) {
$canremoveassignee = 0;
}
if (!$user->hasRight('agenda', 'allactions', 'create')) {
$canremoveassignee = 0; // Can't remove the owner
}
} else {
// We are not on the owner of the event but on a secondary assignee
}
if ($canremoveassignee) {
// If user has all permission, he should be ableto remove a assignee.
// If user has not all permission, he can onlyremove assignee of other (he can't remove itself)
$out .= ' <input type="image" style="border: 0px;" src="' . img_picto($langs->trans("Remove"), 'delete', '', 0, 1) . '" value="' . $userstatic->id . '" class="removedassigned reposition" id="removedassigned_' . $userstatic->id . '" name="removedassigned_' . $userstatic->id . '">';
}
}
// Show my availability
if ($showproperties) {
@ -7404,6 +7432,7 @@ class Form
$hourend = $hourstart;
}
}
// Show hour
$retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50 ' . ($fullday ? $fullday . 'hour' : '') . '" id="' . $prefix . 'hour" name="' . $prefix . 'hour">';
if ($emptyhours) {
@ -7426,7 +7455,7 @@ class Form
if ($m) {
// Show minutes
$retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50 ' . ($fullday ? $fullday . 'min' : '') . '" id="' . $prefix . 'min" name="' . $prefix . 'min">';
$retstring .= '<select ' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50 ' . ($fullday ? $fullday . 'min' : '') . '" id="' . $prefix . 'min" name="' . $prefix . 'min">';
if ($emptyhours) {
$retstring .= '<option value="-1">&nbsp;</option>';
}
@ -7444,7 +7473,7 @@ class Form
}
// Add a "Now" link
if (!empty($conf->use_javascript_ajax) && $addnowlink) {
if (!empty($conf->use_javascript_ajax) && $addnowlink && !$disabled) {
// Script which will be inserted in the onClick of the "Now" link
$reset_scripts = "";
if ($addnowlink == 2) { // local computer time
@ -7531,7 +7560,7 @@ class Form
}
// Add a "Plus one hour" link
if ($conf->use_javascript_ajax && $addplusone) {
if ($conf->use_javascript_ajax && $addplusone && !$disabled) {
// Script which will be inserted in the onClick of the "Add plusone" link
$reset_scripts = "";
@ -7569,7 +7598,7 @@ class Form
}
// Add a link to set data
if ($conf->use_javascript_ajax && !empty($adddateof)) {
if ($conf->use_javascript_ajax && !empty($adddateof) && !$disabled) {
if (!is_array($adddateof)) {
$arrayofdateof = array(array('adddateof' => $adddateof, 'labeladddateof' => $labeladddateof));
} else {

View file

@ -282,7 +282,7 @@ if (!class_exists('MenuManager')) {
$menufound = 0;
$dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
foreach ($dirmenus as $dirmenu) {
$menufound = dol_include_once($dirmenu."standard/".$file_menu);
$menufound = dol_include_once($dirmenu."standard/".dol_sanitizeFileName($file_menu));
if ($menufound) {
break;
}
@ -290,7 +290,7 @@ if (!class_exists('MenuManager')) {
if (!$menufound) { // If failed to include, we try with standard
dol_syslog("You define a menu manager '".$file_menu."' that can not be loaded.", LOG_WARNING);
$file_menu = 'eldy_menu.php';
include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".$file_menu;
include_once DOL_DOCUMENT_ROOT."/core/menus/standard/".dol_sanitizeFileName($file_menu);
}
}
// @phan-suppress-next-line PhanRedefinedClassReference

View file

@ -1557,11 +1557,13 @@ if (!getDolGlobalString('MAIN_DISABLE_SELECT2_FOCUS_PROTECTION') && !defined('DI
* TODO: Recheck with the select2 GH issue and remove once this is fixed on their side
*/
$(document).on('select2:open', (e) => {
console.log("Execute the focus (click on combo or use space when on component");
console.log("Execute the focus (click on combo or use space when on component)");
const target = $(e.target);
if (target && target.length) {
let id = target[0].id || target[0].name;
if (id.substr(-2) == "[]") id = id.substr(0,id.length-2);
if (id.substr(-2) == "[]") {
id = id.substr(0,id.length-2);
}
document.querySelector('input[aria-controls*='+id+']').focus();
}
});

View file

@ -10586,6 +10586,7 @@ function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring = '1'
while ($scheck && $savescheck != $scheck) {
$savescheck = $scheck;
$scheck = preg_replace('/->[a-zA-Z0-9_]+\(/', '->__METHOD__', $scheck); // accept parenthesis in '...->method(...'
$scheck = preg_replace('/::[a-zA-Z0-9_]+\(/', '->__METHOD__', $scheck); // accept parenthesis in '...::method(...'
$scheck = preg_replace('/^\(/', '__PARENTHESIS__ ', $scheck); // accept parenthesis in '(...'. Must replace with __PARENTHESIS__ with a space after to allow following substitutions
$scheck = preg_replace('/\s\(/', '__PARENTHESIS__ ', $scheck); // accept parenthesis in '... (' like in 'if ($a == 1)'. Must replace with __PARENTHESIS__ with a space after to allow following substitutions
$scheck = preg_replace('/^!?[a-zA-Z0-9_]+\(/', '__FUNCTION__', $scheck); // accept parenthesis in 'function(' and '!function('
@ -10646,22 +10647,26 @@ function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring = '1'
$forbiddenphpstrings = array('$$', '$_', '}[');
$forbiddenphpstrings = array_merge($forbiddenphpstrings, array('_ENV', '_SESSION', '_COOKIE', '_GET', '_POST', '_REQUEST', 'ReflectionFunction'));
// We list all forbidden function as keywords we don't want to see (we don't mind it if is "kewyord(" or just "keyword", we don't want "keyword" at all)
$forbiddenphpfunctions = array();
// @phpcs:ignore
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("base64"."_"."decode", "rawurl"."decode", "url"."decode", "str"."_rot13", "hex"."2bin")); // name of forbidden functions are split to avoid false positive
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "require", "include", "mkdir", "rmdir", "symlink", "touch", "unlink", "umask"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("override_function", "session_id", "session_create_id", "session_regenerate_id"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("get_defined_functions", "get_defined_vars", "get_defined_constants", "get_declared_classes"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("function", "call_user_func"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("function", "call_user_func", "call_user_func_array"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("require", "include", "require_once", "include_once"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("exec", "passthru", "shell_exec", "system", "proc_open", "popen"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("dol_eval", "executeCLI", "verifCond")); // native dolibarr functions
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("eval", "create_function", "assert", "mb_ereg_replace")); // function with eval capabilities
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("dol_compress_dir", "dol_decode", "dol_delete_file", "dol_delete_dir", "dol_delete_dir_recursive", "dol_copy", "archiveOrBackupFile")); // more dolibarr functions
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "mkdir", "rmdir", "symlink", "touch", "unlink", "umask"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("require", "include"));
$forbiddenphpmethods = array('invoke', 'invokeArgs'); // Method of ReflectionFunction to execute a function
$forbiddenphpregex = 'global\s+\$|\b('.implode('|', $forbiddenphpfunctions).')\b';
$forbiddenphpregex = 'global\s*\$';
$forbiddenphpregex .= '|';
$forbiddenphpregex .= '\b('.implode('|', $forbiddenphpfunctions).')\b';
$forbiddenphpmethodsregex = '->('.implode('|', $forbiddenphpmethods).')';

View file

@ -2629,8 +2629,11 @@ function pdf_getLinkedObjects(&$object, $outputlangs)
if (is_object($hookmanager)) {
$parameters = array('linkedobjects' => $linkedobjects, 'outputlangs' => $outputlangs);
$action = '';
$hookmanager->executeHooks('pdf_getLinkedObjects', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if (!empty($hookmanager->resArray)) {
$reshook = $hookmanager->executeHooks('pdf_getLinkedObjects', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook)) {
$linkedobjects = array_replace($linkedobjects, $hookmanager->resArray); // array_replace is used to preserve keys
} elseif ($reshook>0) {
// The array must be reinserted even if it is empty because clearing the array could be one of the actions performed by the hook.
$linkedobjects = $hookmanager->resArray;
}
}

View file

@ -694,8 +694,8 @@ function showWebsiteTemplates(Website $website)
/**
* Check a new string containing only php code (including <php tag)
* - Block if bad code in the new string.
* - Block also if user has no permission to change PHP code.
* - Block if user has no permission to change PHP code.
* - Block also if bad code found in the new string.
*
* @param string $phpfullcodestringold PHP old string (before the change). For example "<?php echo 'a' ?><php echo 'b' ?>"
* @param string $phpfullcodestring PHP new string. For example "<?php echo 'a' ?><php echo 'c' ?>"
@ -722,13 +722,15 @@ function checkPHPCode(&$phpfullcodestringold, &$phpfullcodestring)
// Then check forbidden commands
if (!$error) {
$forbiddenphpstrings = array('$$', '}[');
$forbiddenphpstrings = array_merge($forbiddenphpstrings, array('ReflectionFunction'));
$forbiddenphpstrings = array('$$', '$_', '}[');
//$forbiddenphpstrings = array_merge($forbiddenphpstrings, array('_ENV', '_SESSION', '_COOKIE', '_GET', '_POST', '_REQUEST', 'ReflectionFunction'));
$forbiddenphpstrings = array_merge($forbiddenphpstrings, array('_ENV', 'ReflectionFunction'));
$forbiddenphpfunctions = array();
//$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("base64"."_"."decode", "rawurl"."decode", "url"."decode", "str"."_rot13", "hex"."2bin")); // name of forbidden functions are split to avoid false positive
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("override_function", "session_id", "session_create_id", "session_regenerate_id"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("get_defined_functions", "get_defined_vars", "get_defined_constants", "get_declared_classes"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("call_user_func"));
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("call_user_func", "call_user_func_array"));
//$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("require", "include", "require_once", "include_once"));
if (!getDolGlobalString('WEBSITE_PHP_ALLOW_EXEC')) { // If option is not on, we disallow functions to execute commands
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("exec", "passthru", "shell_exec", "system", "proc_open", "popen"));
@ -736,27 +738,38 @@ function checkPHPCode(&$phpfullcodestringold, &$phpfullcodestring)
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("eval", "create_function", "assert", "mb_ereg_replace")); // function with eval capabilities
}
if (!getDolGlobalString('WEBSITE_PHP_ALLOW_WRITE')) { // If option is not on, we disallow functions to write files
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("dol_compress_dir", "dol_decode", "dol_delete_file", "dol_delete_dir", "dol_delete_dir_recursive", "dol_copy", "archiveOrBackupFile")); // more dolibarr functions
$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("fopen", "file_put_contents", "fputs", "fputscsv", "fwrite", "fpassthru", "mkdir", "rmdir", "symlink", "touch", "unlink", "umask"));
}
//$forbiddenphpfunctions = array_merge($forbiddenphpfunctions, array("require", "include"));
$forbiddenphpmethods = array('invoke', 'invokeArgs'); // Method of ReflectionFunction to execute a function
foreach ($forbiddenphpstrings as $forbiddenphpstring) {
if (preg_match('/'.preg_quote($forbiddenphpstring, '/').'/ms', $phpfullcodestring)) {
if (preg_match('/'.preg_quote($forbiddenphpstring, '/').'/ims', $phpfullcodestring)) {
$error++;
setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpstring), null, 'errors');
break;
}
}
foreach ($forbiddenphpfunctions as $forbiddenphpcommand) {
if (preg_match('/'.$forbiddenphpcommand.'\s*\(/ms', $phpfullcodestring)) {
/* replaced with next block
foreach ($forbiddenphpfunctions as $forbiddenphpfunction) { // Check "function(" but also "'function'(" and "function ("
if (preg_match('/'.$forbiddenphpfunction.'[\'\s]*\(/ims', $phpfullcodestring)) {
$error++;
setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpcommand), null, 'errors');
setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpfunction), null, 'errors');
break;
}
}*/
foreach ($forbiddenphpfunctions as $forbiddenphpfunction) { // Check "function" whatever is "function(" or "function'(" or "function (" or "function"
if (preg_match('/\b'.$forbiddenphpfunction.'\b/ims', $phpfullcodestring)) {
$error++;
setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpfunction), null, 'errors');
break;
}
}
foreach ($forbiddenphpmethods as $forbiddenphpmethod) {
if (preg_match('/->'.$forbiddenphpmethod.'/ms', $phpfullcodestring)) {
if (preg_match('/->'.$forbiddenphpmethod.'/ims', $phpfullcodestring)) {
$error++;
setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpmethod), null, 'errors');
break;
@ -764,14 +777,14 @@ function checkPHPCode(&$phpfullcodestringold, &$phpfullcodestring)
}
}
// This char can be used to execute RCE for example using with echo `ls`
// This char can be used to execute RCE for example by using echo `ls`
if (!$error) {
$forbiddenphpchars = array();
if (!getDolGlobalString('WEBSITE_PHP_ALLOW_DANGEROUS_CHARS')) { // If option is not on, we disallow functions to execute commands
$forbiddenphpchars = array("`");
}
foreach ($forbiddenphpchars as $forbiddenphpchar) {
if (preg_match('/'.$forbiddenphpchar.'/ms', $phpfullcodestring)) {
if (preg_match('/'.$forbiddenphpchar.'/ims', $phpfullcodestring)) {
$error++;
setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpchar), null, 'errors');
break;
@ -779,23 +792,31 @@ function checkPHPCode(&$phpfullcodestringold, &$phpfullcodestring)
}
}
// Deny dynamic functions '${a}(' or '$a[b](' => So we refuse '}(' and ']('
// Deny code to call a function obfuscated with comment, like "exec/*...*/ ('ls')";
if (!$error) {
if (preg_match('/[}\]]\(/ims', $phpfullcodestring)) {
if (preg_match('/\*\/\s*\(/ims', $phpfullcodestring)) {
$error++;
setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpmethod), null, 'errors');
}
}
// Deny dynamic functions '${a}(' or '$a[b](' => So we refuse '}(' and ']('
if (!$error) {
if (preg_match('/[}\]]\s*\(/ims', $phpfullcodestring)) {
$error++;
setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", ']('), null, 'errors');
}
}
// Deny dynamic functions '$xxx('
// Deny dynamic functions '$xxx(' or '$xxx (' or '$xxx" ('
if (!$error) {
if (preg_match('/\$[a-z0-9_\-\/\*]+\(/ims', $phpfullcodestring)) {
if (preg_match('/\$[a-z0-9_\-\/\*\"]+\s*\(/ims', $phpfullcodestring)) {
$error++;
setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", '$...('), null, 'errors');
}
}
// No need to block $conf->global->aaa() because PHP try to run method aaa an not function into $conf->global->aaa.
// No need to block $conf->global->aaa() because PHP try to run the method aaa of $conf->global and not the function into $conf->global->aaa.
// Then check if installmodules does not block dynamic PHP code change.
if ($phpfullcodestringold != $phpfullcodestring) {

File diff suppressed because it is too large Load diff

View file

@ -224,7 +224,7 @@ class InterfaceZapierTriggers extends DolibarrTriggers
case 'ORDER_CLASSIFY_BILLED':
case 'ORDER_SETDRAFT':
case 'LINEORDER_INSERT':
case 'LINEORDER_UPDATE':
case 'LINEORDER_MODIFY':
case 'LINEORDER_DELETE':
break;
// Supplier orders
@ -239,7 +239,7 @@ class InterfaceZapierTriggers extends DolibarrTriggers
// case 'ORDER_SUPPLIER_RECEIVE':
// case 'LINEORDER_SUPPLIER_DISPATCH':
// case 'LINEORDER_SUPPLIER_CREATE':
// case 'LINEORDER_SUPPLIER_UPDATE':
// case 'LINEORDER_SUPPLIER_MODIFY':
// Proposals
// case 'PROPAL_CREATE':
@ -251,7 +251,7 @@ class InterfaceZapierTriggers extends DolibarrTriggers
// case 'PROPAL_CLOSE_REFUSED':
// case 'PROPAL_DELETE':
// case 'LINEPROPAL_INSERT':
// case 'LINEPROPAL_UPDATE':
// case 'LINEPROPAL_MODIFY':
// case 'LINEPROPAL_DELETE':
// SupplierProposal
@ -264,7 +264,7 @@ class InterfaceZapierTriggers extends DolibarrTriggers
// case 'SUPPLIER_PROPOSAL_CLOSE_REFUSED':
// case 'SUPPLIER_PROPOSAL_DELETE':
// case 'LINESUPPLIER_PROPOSAL_INSERT':
// case 'LINESUPPLIER_PROPOSAL_UPDATE':
// case 'LINESUPPLIER_PROPOSAL_MODIFY':
// case 'LINESUPPLIER_PROPOSAL_DELETE':
// Contracts
@ -274,7 +274,7 @@ class InterfaceZapierTriggers extends DolibarrTriggers
// case 'CONTRACT_CLOSE':
// case 'CONTRACT_DELETE':
// case 'LINECONTRACT_INSERT':
// case 'LINECONTRACT_UPDATE':
// case 'LINECONTRACT_MODIFY':
// case 'LINECONTRACT_DELETE':
// Bills
@ -288,19 +288,19 @@ class InterfaceZapierTriggers extends DolibarrTriggers
// case 'BILL_DELETE':
// case 'BILL_PAYED':
// case 'LINEBILL_INSERT':
// case 'LINEBILL_UPDATE':
// case 'LINEBILL_MODIFY':
// case 'LINEBILL_DELETE':
//Supplier Bill
// case 'BILL_SUPPLIER_CREATE':
// case 'BILL_SUPPLIER_UPDATE':
// case 'BILL_SUPPLIER_MODIFY':
// case 'BILL_SUPPLIER_DELETE':
// case 'BILL_SUPPLIER_PAYED':
// case 'BILL_SUPPLIER_UNPAYED':
// case 'BILL_SUPPLIER_VALIDATE':
// case 'BILL_SUPPLIER_UNVALIDATE':
// case 'LINEBILL_SUPPLIER_CREATE':
// case 'LINEBILL_SUPPLIER_UPDATE':
// case 'LINEBILL_SUPPLIER_MODIFY':
// case 'LINEBILL_SUPPLIER_DELETE':
// Payments
@ -316,7 +316,7 @@ class InterfaceZapierTriggers extends DolibarrTriggers
// Donation
// case 'DON_CREATE':
// case 'DON_UPDATE':
// case 'DON_MODIFY':
// case 'DON_DELETE':
// Interventions
@ -325,7 +325,7 @@ class InterfaceZapierTriggers extends DolibarrTriggers
// case 'FICHINTER_VALIDATE':
// case 'FICHINTER_DELETE':
// case 'LINEFICHINTER_CREATE':
// case 'LINEFICHINTER_UPDATE':
// case 'LINEFICHINTER_MODIFY':
// case 'LINEFICHINTER_DELETE':
// Members

View file

@ -1875,7 +1875,7 @@ if ($action == 'create') {
print '</tr>';
}
if ($object->status == $object::STATUS_CLOSED) {
if ($object->status == ExpenseReport::STATUS_CLOSED) {
/* TODO this fields are not yet filled
print '<tr>';
print '<td>'.$langs->trans("AUTHORPAIEMENT").'</td>';
@ -2615,12 +2615,12 @@ if ($action == 'create') {
// Unit price net
print '<td class="right inputpricenet">';
print '<input type="text" class="right maxwidth50" id="value_unit_ht" name="value_unit_ht" value="'.dol_escape_htmltag((!empty($value_unit_ht) ? $value_unit_ht : 0)).'"'.$taxlessUnitPriceDisabled.' />';
print '<input type="text" class="right maxwidth50" id="value_unit_ht" name="value_unit_ht" value="'.dol_escape_htmltag((!empty($value_unit_ht) ? $value_unit_ht : "")).'"'.$taxlessUnitPriceDisabled.' />';
print '</td>';
// Unit price with tax
print '<td class="right inputtax">';
print '<input type="text" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag((!empty($value_unit) ? $value_unit : 0)).'">';
print '<input type="text" class="right maxwidth50" id="value_unit" name="value_unit" value="'.dol_escape_htmltag((!empty($value_unit) ? $value_unit : "")).'">';
print '</td>';
// Quantity

View file

@ -1943,7 +1943,7 @@ class ExpenseReport extends CommonObject
dol_syslog(get_class($this)."::addline qty=$qty, up=$up, fk_c_type_fees=$fk_c_type_fees, vatrate=$vatrate, date=$date, fk_project=$fk_project, type=$type, comments=$comments", LOG_DEBUG);
if ($this->status == self::STATUS_DRAFT) {
if ($this->status == self::STATUS_DRAFT || $this->status == self::STATUS_REFUSED) {
if (empty($qty)) {
$qty = 0;
}
@ -2037,7 +2037,7 @@ class ExpenseReport extends CommonObject
}
} else {
dol_syslog(get_class($this)."::addline status of expense report must be Draft to allow use of ->addline()", LOG_ERR);
$this->error = 'ErrorExpenseNotDraft';
$this->error = 'ErrorExpenseNotDraftAndNotRefused';
return -3;
}
}

View file

@ -474,7 +474,7 @@ if ($step == 1 || !$datatoexport) {
// Affiche les modules d'exports
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
print '<table class="noborder centpercent">';
print '<table class="noborder centpercent nomarginbottom">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Module").'</td>';
print '<td>'.$langs->trans("ExportableDatas").'</td>';
@ -486,16 +486,17 @@ if ($step == 1 || !$datatoexport) {
//var_dump($objexport->array_export_code_for_sort);
//$sortedarrayofmodules = dol_sort_array($objexport->array_export_module, 'module_position', 'asc', 0, 0, 1);
foreach ($objexport->array_export_code_for_sort as $key => $value) {
print '<tr class="oddeven"><td nospan="nospan">';
//print img_object($objexport->array_export_module[$key]->getName(),$export->array_export_module[$key]->picto).' ';
print $objexport->array_export_module[$key]->getName();
$titleofmodule = $objexport->array_export_module[$key]->getName();
print '<tr class="oddeven"><td class="tdoverflowmax200" title="'.dolPrintHTML($titleofmodule).'">';
print dolPrintHTML($titleofmodule);
print '</td><td>';
$entity = preg_replace('/:.*$/', '', $objexport->array_export_icon[$key]);
$entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
$label = $objexport->array_export_label[$key];
//print $value.'-'.$icon.'-'.$label."<br>";
print img_object($objexport->array_export_module[$key]->getName(), $entityicon).' ';
print $label;
print '<div class="twolinesmax-normallineheight minwidth200onall">';
print img_object($objexport->array_export_module[$key]->getName(), $entityicon, 'class="pictofixedwidth"');
print dolPrintHTML($label);
print '</div>';
print '</td><td class="right">';
if ($objexport->array_export_perms[$key]) {
print '<a href="'.DOL_URL_ROOT.'/exports/export.php?step=2&module_position='.$objexport->array_export_module[$key]->module_position.'&datatoexport='.$objexport->array_export_code[$key].'">'.img_picto($langs->trans("NewExport"), 'next', 'class="fa-15"').'</a>';

View file

@ -1025,7 +1025,7 @@ class ProductFournisseur extends Product
}
}
if ($fourn_unitprice < $min || $min == -1) {
if ($fourn_unitprice_with_discount < $min || $min == -1) {
$this->id = $prodid;
$this->product_fourn_price_id = $record["product_fourn_price_id"];
$this->ref_supplier = $record["ref_fourn"];
@ -1050,7 +1050,7 @@ class ProductFournisseur extends Product
$this->fourn_multicurrency_id = $record["fk_multicurrency"];
$this->fourn_multicurrency_code = $record["multicurrency_code"];
$min = $fourn_unitprice;
$min = $fourn_unitprice_with_discount;
}
}
}

View file

@ -844,7 +844,7 @@ if (empty($reshook)) {
$object->fk_incoterms = GETPOSTINT('incoterm_id');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOSTINT('originmulticurrency_tx');
$object->multicurrency_tx = GETPOSTFLOAT('originmulticurrency_tx');
$object->transport_mode_id = GETPOSTINT('transport_mode_id');
// Proprietes particulieres a facture de replacement
@ -4063,7 +4063,7 @@ if ($action == 'create') {
}
// Reverse back money or convert to reduction
if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT || $object->type == FactureFournisseur::TYPE_STANDARD) {
if ($object->status != FactureFournisseur::STATUS_DRAFT && ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT || $object->type == FactureFournisseur::TYPE_STANDARD)) {
// For credit note only
if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && $object->status == 1 && $object->paid == 0) {
if ($resteapayer == 0) {

View file

@ -351,7 +351,7 @@ if ($step == 1 || !$datatoimport) {
// Affiche les modules d'imports
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
print '<table class="noborder centpercent">';
print '<table class="noborder centpercent nomarginbottom">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Module").'</td>';
print '<td>'.$langs->trans("ImportableDatas").'</td>';
@ -362,18 +362,21 @@ if ($step == 1 || !$datatoimport) {
$sortedarrayofmodules = dol_sort_array($objimport->array_import_module, 'position_of_profile', 'asc', 0, 0, 1);
foreach ($sortedarrayofmodules as $key => $value) {
//var_dump($key.' '.$value['position_of_profile'].' '.$value['import_code'].' '.$objimport->array_import_module[$key]['module']->getName().' '.$objimport->array_import_code[$key]);
print '<tr class="oddeven"><td>';
$titleofmodule = $objimport->array_import_module[$key]['module']->getName();
print '<tr class="oddeven"><td class="tdoverflowmax200" title="'.dolPrintHTML($titleofmodule).'">';
// Special case for import common to module/services
if (in_array($objimport->array_import_code[$key], array('produit_supplierprices', 'produit_multiprice', 'produit_languages'))) {
$titleofmodule = $langs->trans("ProductOrService");
}
print $titleofmodule;
print dolPrintHTML($titleofmodule);
print '</td><td>';
$entity = preg_replace('/:.*$/', '', $objimport->array_import_icon[$key]);
$entityicon = strtolower(!empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity);
print img_object($objimport->array_import_module[$key]['module']->getName(), $entityicon).' ';
print $objimport->array_import_label[$key];
$label = $objimport->array_import_label[$key];
print '<div class="twolinesmax-normallineheight minwidth200onall">';
print img_object($objimport->array_import_module[$key]['module']->getName(), $entityicon, 'class="pictofixedwidth"');
print dolPrintHtml($label);
print '</div>';
print '</td><td style="text-align: right">';
if ($objimport->array_import_perms[$key]) {
print '<a href="'.DOL_URL_ROOT.'/imports/import.php?step=2&datatoimport='.$objimport->array_import_code[$key].$param.'">'.img_picto($langs->trans("NewImport"), 'next', 'class="fa-15"').'</a>';

View file

@ -383,8 +383,8 @@ ExportCardToFormat=Export card to format
ContactNotLinkedToCompany=Contact not linked to any third party
DolibarrLogin=Dolibarr login
NoDolibarrAccess=No Dolibarr access
ExportDataset_company_1=Third-parties (companies/foundations/physical people) and their properties
ExportDataset_company_2=Contacts and their properties
ExportDataset_company_1=Third-parties (organizations/natural persons) and attributes
ExportDataset_company_2=Third-parties additional contacts/addresses and attributes
ExportDataset_company_3=Third-parties payment modes (bank accounts)
ImportDataset_company_1=Third-parties and their properties
ImportDataset_company_2=Third-parties additional contacts/addresses and attributes

View file

@ -798,7 +798,7 @@ Notes=Notes
AddNewLine=Add new line
AddFile=Add file
FreeZone=Free-text product
FreeLineOfType=Free-text item, type:
FreeLineOfType=Free-text item, type
CloneMainAttributes=Clone object with its main attributes
ReGeneratePDF=Re-generate PDF
PDFMerge=PDF Merge

View file

@ -143,7 +143,7 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers
//case 'ORDER_CLASSIFY_UNBILLED': // TODO Replace it with ORDER_UNBILLED
//case 'ORDER_SETDRAFT':
//case 'LINEORDER_INSERT':
//case 'LINEORDER_UPDATE':
//case 'LINEORDER_MODIFY':
//case 'LINEORDER_DELETE':
// Supplier orders
@ -160,7 +160,7 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers
//case 'ORDER_SUPPLIER_RECEIVE':
//case 'LINEORDER_SUPPLIER_DISPATCH':
//case 'LINEORDER_SUPPLIER_CREATE':
//case 'LINEORDER_SUPPLIER_UPDATE':
//case 'LINEORDER_SUPPLIER_MODIFY':
//case 'LINEORDER_SUPPLIER_DELETE':
// Proposals
@ -174,7 +174,7 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers
//case 'PROPAL_CLOSE_REFUSED':
//case 'PROPAL_DELETE':
//case 'LINEPROPAL_INSERT':
//case 'LINEPROPAL_UPDATE':
//case 'LINEPROPAL_MODIFY':
//case 'LINEPROPAL_DELETE':
// SupplierProposal
@ -186,7 +186,7 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers
//case 'SUPPLIER_PROPOSAL_CLOSE_REFUSED':
//case 'SUPPLIER_PROPOSAL_DELETE':
//case 'LINESUPPLIER_PROPOSAL_INSERT':
//case 'LINESUPPLIER_PROPOSAL_UPDATE':
//case 'LINESUPPLIER_PROPOSAL_MODIFY':
//case 'LINESUPPLIER_PROPOSAL_DELETE':
// Contracts
@ -197,7 +197,7 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers
//case 'CONTRACT_CLOSE':
//case 'CONTRACT_DELETE':
//case 'LINECONTRACT_INSERT':
//case 'LINECONTRACT_UPDATE':
//case 'LINECONTRACT_MODIFY':
//case 'LINECONTRACT_DELETE':
// Bills
@ -210,7 +210,7 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers
//case 'BILL_DELETE':
//case 'BILL_PAYED':
//case 'LINEBILL_INSERT':
//case 'LINEBILL_UPDATE':
//case 'LINEBILL_MODIFY':
//case 'LINEBILL_DELETE':
// Recurring Bills
@ -222,14 +222,14 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers
//Supplier Bill
//case 'BILL_SUPPLIER_CREATE':
//case 'BILL_SUPPLIER_UPDATE':
//case 'BILL_SUPPLIER_MODIFY':
//case 'BILL_SUPPLIER_DELETE':
//case 'BILL_SUPPLIER_PAYED':
//case 'BILL_SUPPLIER_UNPAYED':
//case 'BILL_SUPPLIER_VALIDATE':
//case 'BILL_SUPPLIER_UNVALIDATE':
//case 'LINEBILL_SUPPLIER_CREATE':
//case 'LINEBILL_SUPPLIER_UPDATE':
//case 'LINEBILL_SUPPLIER_MODIFY':
//case 'LINEBILL_SUPPLIER_DELETE':
// Payments
@ -245,7 +245,7 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers
// Donation
//case 'DON_CREATE':
//case 'DON_UPDATE':
//case 'DON_MODIFY':
//case 'DON_DELETE':
// Interventions
@ -256,7 +256,7 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers
//case 'FICHINTER_CLASSIFY_UNBILLED': // TODO Replace it with FICHINTER_UNBILLED
//case 'FICHINTER_DELETE':
//case 'LINEFICHINTER_CREATE':
//case 'LINEFICHINTER_UPDATE':
//case 'LINEFICHINTER_MODIFY':
//case 'LINEFICHINTER_DELETE':
// Members

View file

@ -1544,7 +1544,7 @@ class Product extends CommonObject
$sql .= ", sell_or_eat_by_mandatory = ".((empty($this->sell_or_eat_by_mandatory) || $this->sell_or_eat_by_mandatory < 0) ? 0 : (int) $this->sell_or_eat_by_mandatory);
$sql .= ", batch_mask = '".$this->db->escape($this->batch_mask)."'";
$sql .= ", finished = ".((!isset($this->finished) || $this->finished < 0 || $this->finished == '') ? "null" : (int) $this->finished);
$sql .= ", finished = ".((!isset($this->finished) || $this->finished < 0 || $this->finished === '') ? "null" : (int) $this->finished);
$sql .= ", fk_default_bom = ".((!isset($this->fk_default_bom) || $this->fk_default_bom < 0 || $this->fk_default_bom == '') ? "null" : (int) $this->fk_default_bom);
$sql .= ", net_measure = ".($this->net_measure != '' ? "'".$this->db->escape($this->net_measure)."'" : 'null');
$sql .= ", net_measure_units = ".($this->net_measure_units != '' ? "'".$this->db->escape($this->net_measure_units)."'" : 'null');
@ -3078,7 +3078,7 @@ class Product extends CommonObject
// Load multiprices array
if ((getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) && empty($ignore_price_load)) { // prices per segment
$produit_multiprices_limit = getDolGlobalString('PRODUIT_MULTIPRICES_LIMIT');
$produit_multiprices_limit = getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT');
for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
$sql = "SELECT price, price_ttc, price_min, price_min_ttc,";
$sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly";
@ -3195,7 +3195,7 @@ class Product extends CommonObject
return -1;
}
} elseif (getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES') && empty($ignore_price_load)) { // prices per customer and quantity
$produit_multiprices_limit = getDolGlobalString('PRODUIT_MULTIPRICES_LIMIT');
$produit_multiprices_limit = getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT');
for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
$sql = "SELECT price, price_ttc, price_min, price_min_ttc,";
$sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly";

View file

@ -98,7 +98,6 @@ if (!isModEnabled('ticket')) {
}
/*
* Actions
*/

View file

@ -647,8 +647,7 @@ class Reception extends CommonObject
if (intval($result) < 0) {
$error++;
$this->errors[] = $mouvS->error;
$this->errors = array_merge($this->errors, $mouvS->errors);
$this->setErrorsFromObject($mouvS);
break;
}
} else {
@ -661,8 +660,7 @@ class Reception extends CommonObject
if (intval($result) < 0) {
$error++;
$this->errors[] = $mouvS->error;
$this->errors = array_merge($this->errors, $mouvS->errors);
$this->setErrorsFromObject($mouvS);
break;
}
}
@ -809,8 +807,7 @@ class Reception extends CommonObject
$ret = $supplierorderdispatch->fetchAll('', '', 0, 0, $filter);
if ($ret < 0) {
$this->error = $supplierorderdispatch->error;
$this->errors = $supplierorderdispatch->errors;
$this->setErrorsFromObject($supplierorderdispatch);
return $ret;
} else {
// build array with quantity received by product in all supplier orders (origin)
@ -895,8 +892,7 @@ class Reception extends CommonObject
$supplierorderline = new CommandeFournisseurLigne($this->db);
$result = $supplierorderline->fetch($id);
if ($result <= 0) {
$this->error = $supplierorderline->error;
$this->errors = $supplierorderline->errors;
$this->setErrorsFromObject($supplierorderline);
return -1;
}

View file

@ -120,6 +120,7 @@ class Salary extends CommonObject
/**
* @var int
* @deprecated see $accountid
* @see $accountid
*/
public $fk_account;
@ -154,7 +155,7 @@ class Salary extends CommonObject
const STATUS_PAID = 1;
/**
* @var string
* @var float amount remain to pay
*/
public $resteapayer;

View file

@ -193,8 +193,8 @@ if ($massaction == 'withdrawrequest') {
$objecttmp = new Salary($db);
$result = $objecttmp->fetch($toselectid);
if ($result > 0) {
$totalpaid = $objecttmp->getSommePaiement();
$objecttmp->resteapayer = price2num((float) $objecttmp->amount - $totalpaid, 'MT');
$totalpaid = (float) $objecttmp->getSommePaiement();
$objecttmp->resteapayer = (float) price2num((float) $objecttmp->amount - $totalpaid, 'MT');
// hook to finalize the remaining amount, considering e.g. cash discount agreements
$parameters = array('remaintopay' => $objecttmp->resteapayer);
@ -211,7 +211,7 @@ if ($massaction == 'withdrawrequest') {
if ($objecttmp->status == Salary::STATUS_PAID || $objecttmp->resteapayer == 0) {
$error++;
setEventMessages($langs->trans("Salary").' '.$objecttmp->ref.' : '.$langs->trans("AlreadyPaid"), $objecttmp->errors, 'errors');
} elseif ($resteapayer < 0) {
} elseif ($objecttmp->resteapayer < 0) {
$error++;
setEventMessages($langs->trans("Salary").' '.$objecttmp->ref.' : '.$langs->trans("AmountMustBePositive"), $objecttmp->errors, 'errors');
}

View file

@ -167,6 +167,7 @@ $help_url = '';
llxHeader('', '', $help_url);
$salary = $object;
$sumpaid = 0.0;
// Formulaire de creation d'un paiement de charge
if ($action == 'create') {
@ -214,7 +215,7 @@ if ($action == 'create') {
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
$sumpaid = $obj->total;
$sumpaid = (float) $obj->total;
$db->free($resql);
}
/*print '<tr><td>'.$langs->trans("AlreadyPaid").'</td><td>'.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';

View file

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2010 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2010 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -18,10 +18,13 @@
*/
/**
* @var Canvas $this
* @var Conf $conf
* @var CommonObject $this
* @var Translate $langs
* @var User $user
*
* @var string $canvas
*/
// Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) {

View file

@ -18,10 +18,12 @@
*/
/**
* @var Canvas $this
* @var Conf $conf
* @var CommonObject $this
* @var Translate $langs
* @var User $user
* @var string $canvas
*/
// Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) {

View file

@ -16,10 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* @var Canvas $this
* @var Conf $conf
* @var CommonObject $this
* @var Translate $langs
* @var User $user
*
* @var string $canvas
*/
// Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) {
@ -37,17 +40,16 @@ $head = societe_prepare_head($soc);
print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company');
?>
<?php if ($this->control->tpl['error']) {
if ($this->control->tpl['error']) {
echo $this->control->tpl['error'];
} ?>
<?php if ($this->control->tpl['action_delete']) {
}
if ($this->control->tpl['action_delete']) {
echo $this->control->tpl['action_delete'];
} ?>
<?php if ($this->control->tpl['js_checkVatPopup']) {
}
if ($this->control->tpl['js_checkVatPopup']) {
echo $this->control->tpl['js_checkVatPopup'];
} ?>
}
?>
<table class="border allwidth">

View file

@ -1960,7 +1960,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
print '<td>'.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).'</td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
// TODO Use select_doluser in multiselect mode
$userlist = $form->select_dolusers($selected, '', 0, null, 0, '', '', '0', 0, 0, 'AND u.statut = 1', 0, '', '', 0, 2);
$userlist = $form->select_dolusers($selected, '', 0, null, 0, '', '', '0', 0, 0, 'u.statut:=:1', 0, '', '', 0, 2);
// Note: If user has no right to "see all thirdparties", we force selection of sale representative to him, so after creation he can see the record.
$selected = (GETPOSTISARRAY('commercial') ? GETPOST('commercial', 'array:int') : (GETPOSTINT('commercial') > 0 ? array(GETPOSTINT('commercial')) : array($user->id)));
print img_picto('', 'user').$form->multiselectarray('commercial', $userlist, $selected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
@ -2812,7 +2812,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
print '<tr>';
print '<td>'.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).'</td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
$userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'AND u.statut = 1', 0, '', '', 0, 1);
$userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'u.statut:=:1', 0, '', '', 0, 1);
$arrayselected = GETPOST('commercial', 'array');
if (empty($arrayselected)) {
$arrayselected = $object->getSalesRepresentatives($user, 1);

View file

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
@ -194,9 +194,6 @@ class Contacts extends DolibarrApi
$sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t";
if ($category > 0) {
$sql .= ", ".MAIN_DB_PREFIX."categorie_contact as c";
}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as te ON te.fk_object = t.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON t.fk_soc = s.rowid";
$sql .= ' WHERE t.entity IN ('.getEntity('contact').')';
@ -213,8 +210,37 @@ class Contacts extends DolibarrApi
}
// Select contacts of given category
if ($category > 0) {
$sql .= " AND c.fk_categorie = ".((int) $category);
$sql .= " AND c.fk_socpeople = t.rowid ";
// Search Contact Categories
$searchCategoryContactList = $category ? array($category) : array();
// $searchCategoryContactOperator = 0;
// Search for tag/category ($searchCategoryContactList is an array of ID)
if (!empty($searchCategoryContactList)) {
$searchCategoryContactSqlList = array();
// $listofcategoryid = '';
foreach ($searchCategoryContactList as $searchCategoryContact) {
if (intval($searchCategoryContact) == -2) {
$searchCategoryContactSqlList[] = "NOT EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE t.rowid = ck.fk_socpeople)";
} elseif (intval($searchCategoryContact) > 0) {
// if ($searchCategoryContactOperator == 0) {
$searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE t.rowid = ck.fk_socpeople AND ck.fk_categorie = ".((int) $searchCategoryContact).")";
// } else {
// $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryContact);
// }
}
}
// if ($listofcategoryid) {
// $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE t.rowid = ck.fk_socpeople AND ck.fk_categorie IN (".$this->db->sanitize($listofcategoryid)."))";
// }
// if ($searchCategoryContactOperator == 1) {
// if (!empty($searchCategoryContactSqlList)) {
// $sql .= " AND (".implode(' OR ', $searchCategoryContactSqlList).")";
// }
// } else {
if (!empty($searchCategoryContactSqlList)) {
$sql .= " AND (".implode(' AND ', $searchCategoryContactSqlList).")";
}
// }
}
}
// Add sql filters

View file

@ -85,6 +85,7 @@ $search_id = GETPOST("search_id", 'int');
$search_nom = trim(GETPOST("search_nom", 'restricthtml'));
$search_alias = trim(GETPOST("search_alias", 'restricthtml'));
$search_nom_only = trim(GETPOST("search_nom_only", 'restricthtml'));
$search_ref_ext = trim(GETPOST("search_ref_ext", 'restricthtml'));
$search_barcode = trim(GETPOST("search_barcode", 'alpha'));
$search_customer_code = trim(GETPOST('search_customer_code', 'alpha'));
$search_supplier_code = trim(GETPOST('search_supplier_code', 'alpha'));
@ -287,7 +288,8 @@ $arrayfields = array(
's.rowid' => array('label' => "TechnicalID", 'position' => 1, 'checked' => -1, 'enabled' => 1),
's.nom' => array('label' => "ThirdPartyName", 'position' => 2, 'checked' => 1),
's.name_alias' => array('label' => "AliasNameShort", 'position' => 3, 'checked' => 1),
's.barcode' => array('label' => "Gencod", 'position' => 5, 'checked' => 1, 'enabled' => (isModEnabled('barcode'))),
's.ref_ext' => array('label' => "RefExt", 'position' => 4, 'checked' => -1, 'enabled' => getDolGlobalInt('MAIN_LIST_SHOW_REF_EXT')),
's.barcode' => array('label' => "Gencod", 'position' => 5, 'checked' => 1, 'enabled' => isModEnabled('barcode')),
's.code_client' => array('label' => "CustomerCodeShort", 'position' => 10, 'checked' => $checkedcustomercode),
's.code_fournisseur' => array('label' => "SupplierCodeShort", 'position' => 11, 'checked' => $checkedsuppliercode, 'enabled' => (isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))),
's.code_compta' => array('label' => "CustomerAccountancyCodeShort", 'position' => 13, 'checked' => $checkedcustomeraccountcode),
@ -411,6 +413,7 @@ if (empty($reshook)) {
$search_id = '';
$search_nom = '';
$search_alias = '';
$search_ref_ext = '';
$search_categ_cus = 0;
$search_categ_sup = 0;
$searchCategoryCustomerOperator = 0;
@ -562,7 +565,7 @@ if ($resql) {
// Build and execute select
// --------------------------------------------------------------------
$sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.address, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,";
$sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.ref_ext, s.barcode, s.address, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,";
$sql .= " s.entity,";
$sql .= " st.libelle as stcomm, st.picto as stcomm_picto, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status, s.note_private, s.note_public,";
$sql .= " s.email, s.phone, s.phone_mobile, s.fax, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,";
@ -715,6 +718,9 @@ if (empty($arrayfields['s.name_alias']['checked']) && $search_nom) {
if ($search_nom_only) {
$sql .= natural_search("s.nom", $search_nom_only);
}
if ($search_ref_ext) {
$sql .= natural_search("s.ref_ext", $search_ref_ext);
}
if ($search_customer_code) {
$sql .= natural_search("s.code_client", $search_customer_code);
}
@ -970,6 +976,9 @@ if ($search_nom != '') {
if ($search_alias != '') {
$param .= "&search_alias=".urlencode($search_alias);
}
if ($search_ref_ext != '') {
$param .= "&search_ref_ext=".urlencode($search_ref_ext);
}
if ($search_address != '') {
$param .= '&search_address='.urlencode($search_address);
}
@ -1281,7 +1290,7 @@ if (empty($type) || $type == 'f') {
}
// If the user can view prospects other than his'
$userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'AND u.statut = 1', 0, '', '', 0, 1);
$userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'u.statut:=:1', 0, '', '', 0, 1);
$userlist[-2] = $langs->trans("NoSalesRepresentativeAffected");
if ($user->hasRight("societe", "client", "voir") || $socid) {
$moreforfilter .= '<div class="divsearchfield">';
@ -1335,6 +1344,11 @@ if (!empty($arrayfields['s.name_alias']['checked'])) {
print '<input class="flat searchstring maxwidth75imp" type="text" name="search_alias" value="'.dol_escape_htmltag($search_alias).'">';
print '</td>';
}
if (!empty($arrayfields['s.ref_ext']['checked'])) {
print '<td class="liste_titre">';
print '<input class="flat searchstring maxwidth75imp" type="text" name="search_ref_ext" value="'.dol_escape_htmltag($search_ref_ext).'">';
print '</td>';
}
// Barcode
if (!empty($arrayfields['s.barcode']['checked'])) {
print '<td class="liste_titre">';
@ -1619,6 +1633,11 @@ if (!empty($arrayfields['s.name_alias']['checked'])) {
print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['s.ref_ext']['checked'])) {
// @phan-suppress-next-line PhanTypeInvalidDimOffset
print_liste_field_titre($arrayfields['s.ref_ext']['label'], $_SERVER["PHP_SELF"], "s.ref_ext", "", $param, "", $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['s.barcode']['checked'])) {
print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode", $param, '', '', $sortfield, $sortorder);
$totalarray['nbfield']++;
@ -1807,6 +1826,7 @@ while ($i < $imaxinloop) {
$companystatic->id = $obj->rowid;
$companystatic->name = $obj->name;
$companystatic->name_alias = $obj->name_alias;
$companystatic->ref_ext = $obj->ref_ext;
$companystatic->logo = $obj->logo;
$companystatic->barcode = $obj->barcode;
$companystatic->canvas = $obj->canvas;
@ -1899,6 +1919,15 @@ while ($i < $imaxinloop) {
$totalarray['nbfield']++;
}
}
// Ref ext
if (!empty($arrayfields['s.ref_ext']['checked'])) {
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->ref_ext).'">';
print dol_escape_htmltag($companystatic->ref_ext);
print "</td>\n";
if (!$i) {
$totalarray['nbfield']++;
}
}
// Barcode
if (!empty($arrayfields['s.barcode']['checked'])) {
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->barcode).'">'.dol_escape_htmltag($companystatic->barcode).'</td>';

View file

@ -748,8 +748,12 @@ input:-webkit-autofill {
/* CSS for placeholder */
.placeholder { color: #ccc; }
select.placeholder { color: #ccc; }
::-webkit-input-placeholder { color: #ccc; }
input:-moz-placeholder { color: #ccc; }
select.placeholder option:not(.opacitymediumbycolor):not(.opacitymedium) {
color: var(--colortext);
}
input[name=price], input[name=weight], input[name=volume], input[name=surface], input[name=sizeheight], input[name=net_measure], select[name=incoterm_id] { margin-right: 6px; }
fieldset {
@ -766,6 +770,7 @@ input#onlinepaymenturl, input#directdownloadlink {
opacity: 0.7;
}
.formconsumeproduce {
background: #f3f3f3;
padding: 20px 0px 0px 0px;
@ -1712,7 +1717,7 @@ select.flat.selectlimit {
-webkit-line-clamp: 2;
overflow: hidden;
}
.twolinesmax {
.twolinesmax, .twolinesmax-normallineheight { /* To be used into a <div class="twolinesmax-normallineheight minwidth200onall"> into a td for example */
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
@ -1720,6 +1725,9 @@ select.flat.selectlimit {
height: auto !important;
word-break: break-word;
}
.twolinesmax-normallineheight {
line-height: normal;
}
.tenlinesmax {
display: -webkit-box;
-webkit-box-orient: vertical;
@ -4481,8 +4489,8 @@ table.tableforfield td, .tagtr.table-border-row .tagtd {
}
table.liste td, table.noborder td, div.noborder form div, table.tableforservicepart1 td, table.tableforservicepart2 td {
padding: 6px 10px 6px 12px; /* t r b l */
/* line-height: 22px; This create trouble on cell login on list of last events of a contract*/
height: 30px;
/* line-height: 22px; This create trouble on cell login on list of last events of a contract */
height: 32px;
}
table.liste tr.trkanban td {
padding: 12px 15px 12px 15px; /* t r b l */

View file

@ -107,14 +107,15 @@ div.mainmenu.generic4::before {
text-align: center;
}
.menu_titre .em092 {
.em092 {
font-size: 0.92em;
}
.menu_titre .em088 {
.em088 {
font-size: 0.88em;
}
.menu_titre .em080 {
.em080 {
font-size: 0.80em;
}

View file

@ -933,11 +933,15 @@ input[type=checkbox], input[type=radio] {
/* CSS for placeholder */
.placeholder { color: #ccc; }
select.placeholder { color: #ccc; }
::-webkit-input-placeholder { color:#ccc; }
:-moz-placeholder { color:#bbb; } /* firefox 18- */
::-moz-placeholder { color:#bbb; } /* firefox 19+ */
:-ms-input-placeholder { color:#ccc; } /* ie */
input:-moz-placeholder { color:#ccc; }
select.placeholder option:not(.opacitymediumbycolor):not(.opacitymedium) {
color: var(--colortext);
}
input[name=price], input[name=weight], input[name=volume], input[name=surface], input[name=sizeheight], input[name=net_measure], select[name=incoterm_id] { margin-right: 6px; }
fieldset {
@ -1863,7 +1867,7 @@ select.flat.selectlimit {
-webkit-line-clamp: 2;
overflow: hidden;
}
.twolinesmax {
.twolinesmax, .twolinesmax-normallineheight { /* To be used into a <div class="twolinesmax-normallineheight minwidth200onall"> into a td for example */
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
@ -1871,6 +1875,9 @@ select.flat.selectlimit {
height: auto !important;
word-break: break-word;
}
.twolinesmax-normallineheight {
line-height: normal;
}
.tenlinesmax {
display: -webkit-box;
-webkit-box-orient: vertical;
@ -4487,7 +4494,7 @@ tr.liste_titre_filter td.liste_titre {
padding-top: 4px;
padding-bottom: 3px;
}
.liste_titre_create td, .liste_titre_create th, .liste_titre_create .tagtd
.liste_titre_create td:not(.linecoldescription), .liste_titre_create th, .liste_titre_create .tagtd
{
border-top-width: 1px;
border-top-color: var(--colortopbordertitle1);
@ -4509,13 +4516,17 @@ tr#trlinefordates td {
border-top-style: solid;
}
td.linecoldescription {
padding: 6px 10px 6px 12px !important; /* t r b l */
}
table.liste th, table.noborder th, table.noborder tr.liste_titre td, table.noborder tr.box_titre td {
padding: 8px 8px 8px 10px; /* t r b l */
}
table.liste td, table.noborder td, div.noborder form div, table.tableforservicepart1 td, table.tableforservicepart2 td {
padding: 4px 8px 4px 10px; /* t r b l */
height: 22px;
height: 28px;
}
table.liste tr.trkanban td {
padding: 12px 15px 12px 15px; /* t r b l */

View file

@ -550,13 +550,13 @@ class ProductCombination
// MultiPrix
if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
$produit_multiprices_limit = getDolGlobalString('PRODUIT_MULTIPRICES_LIMIT');
$produit_multiprices_limit = getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT');
for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
if ($parent->multiprices[$i] != '' || isset($this->combination_price_levels[$i]->variation_price)) {
$new_type = empty($parent->multiprices_base_type[$i]) ? 'HT' : $parent->multiprices_base_type[$i];
$new_min_price = $parent->multiprices_min[$i];
$variation_price = (float) (!isset($this->combination_price_levels[$i]->variation_price) ? $this->variation_price : $this->combination_price_levels[$i]->variation_price);
$variation_price_percentage = (float) (!isset($this->combination_price_levels[$i]->variation_price_percentage) ? $this->variation_price_percentage : $this->combination_price_levels[$i]->variation_price_percentage);
$variation_price_percentage = (bool) (!isset($this->combination_price_levels[$i]->variation_price_percentage) ? $this->variation_price_percentage : $this->combination_price_levels[$i]->variation_price_percentage);
if ($parent->prices_by_qty_list[$i]) {
$new_psq = 1;
@ -867,14 +867,14 @@ class ProductCombination
$newproduct->description .= '<strong>'.$prodattr->label.':</strong> '.$prodattrval->value;
}
$newcomb->variation_price_percentage = $price_var_percent[1];
$newcomb->variation_price_percentage = (bool) $price_var_percent[1];
$newcomb->variation_price = $price_impact[1];
$newcomb->variation_weight = $weight_impact;
$newcomb->variation_ref_ext = $this->db->escape($ref_ext);
// Init price level
if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
$produit_multiprices_limit = getDolGlobalString('PRODUIT_MULTIPRICES_LIMIT');
$produit_multiprices_limit = getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT');
for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
$productCombinationLevel = new ProductCombinationLevel($this->db);
$productCombinationLevel->fk_product_attribute_combination = $newcomb->id;
@ -882,7 +882,7 @@ class ProductCombination
$productCombinationLevel->variation_price = $price_impact[$i];
if (is_array($price_var_percent)) {
$productCombinationLevel->variation_price_percentage = (empty($price_var_percent[$i]) ? false : $price_var_percent[$i]);
$productCombinationLevel->variation_price_percentage = (bool) $price_var_percent[$i] ;
} else {
$productCombinationLevel->variation_price_percentage = $price_var_percent;
}

View file

@ -302,7 +302,8 @@ if (($action == 'add' || $action == 'create') && $usercancreate && empty($massac
if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
$prodcomb->combination_price_levels = array();
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
$maxi = getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT');
for ($i = 1; $i <= $maxi; $i++) {
$productCombinationLevel = new ProductCombinationLevel($db);
$productCombinationLevel->fk_product_attribute_combination = $prodcomb->id;
$productCombinationLevel->fk_price_level = $i;
@ -723,14 +724,16 @@ if (!empty($id) || !empty($ref)) {
<tr>
<td><label for="price_impact"><?php echo $langs->trans('PriceImpact') ?></label></td>
<td><input type="text" id="price_impact" name="price_impact" value="<?php echo price($price_impact) ?>">
<input type="checkbox" id="price_impact_percent" name="price_impact_percent" <?php echo $price_impact_percent ? ' checked' : '' ?>> <label for="price_impact_percent"><?php echo $langs->trans('PercentageVariation') ?></label>
<input type="checkbox" id="price_impact_percent" name="price_impact_percent" <?php echo ($price_impact_percent ? ' checked' : '') ?>> <label for="price_impact_percent"><?php echo $langs->trans('PercentageVariation') ?></label>
</td>
</tr>
<?php
} else {
$prodcomb->fetchCombinationPriceLevels();
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
$maxi = getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT');
for ($i = 1; $i <= $maxi; $i++) {
$keyforlabel = 'PRODUIT_MULTIPRICES_LABEL'.$i;
$text = $langs->trans('ImpactOnPriceLevel', $i).' - '.getDolGlobalString($keyforlabel);
print '<tr>';
@ -740,7 +743,7 @@ if (!empty($id) || !empty($ref)) {
}
print '</td>';
print '<td><input type="text" class="level_price_impact" id="level_price_impact_'.$i.'" name="level_price_impact['.$i.']" value="'.price($prodcomb->combination_price_levels[$i]->variation_price).'">';
print '<input type="checkbox" class="level_price_impact_percent" id="level_price_impact_percent_'.$i.'" name="level_price_impact_percent['.$i.']" '.(!empty($prodcomb->combination_price_levels[$i]->variation_price_percentage) ? ' checked' : '').'> <label for="level_price_impact_percent_'.$i.'">'.$langs->trans('PercentageVariation').'</label>';
print '<input type="checkbox" class="level_price_impact_percent" id="level_price_impact_percent_'.$i.'" name="level_price_impact_percent['.$i.']" '.($prodcomb->combination_price_levels[$i]->variation_price_percentage ? ' checked' : '').'> <label for="level_price_impact_percent_'.$i.'">'.$langs->trans('PercentageVariation').'</label>';
print '</td>';
print '</tr>';
@ -767,7 +770,7 @@ if (!empty($id) || !empty($ref)) {
let priceImpact = $( "#level_price_impact_1" ).val();
let priceImpactPrecent = $( "#level_price_impact_percent_1" ).prop("checked");
var multipricelimit = <?php print intval($conf->global->PRODUIT_MULTIPRICES_LIMIT); ?>
let multipricelimit = <?php print getDolGlobalInt('PRODUIT_MULTIPRICES_LIMIT'); ?>
for (let i = 2; i <= multipricelimit; i++) {
$( "#level_price_impact_" + i ).val(priceImpact);

View file

@ -134,6 +134,8 @@ class AllTests
$suite->addTestSuite('SecurityTest');
require_once dirname(__FILE__).'/SecurityGETPOSTTest.php';
$suite->addTestSuite('SecurityGETPOSTTest');
require_once dirname(__FILE__).'/SecurityLoginTest.php';
$suite->addTestSuite('SecurityLoginTest');
require_once dirname(__FILE__).'/UserTest.php';
$suite->addTestSuite('UserTest');

View file

@ -0,0 +1,106 @@
<?php
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2023 Alexandre Janniaux <alexandre.janniaux@gmail.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* or see https://www.gnu.org/
*/
/**
* \file test/phpunit/SecurityTest.php
* \ingroup test
* \brief PHPUnit test
* \remarks To run this script as CLI: phpunit filename.php
*/
global $conf,$user,$langs,$db;
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
//require_once 'PHPUnit/Autoload.php';
if (! defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (! defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', '1');
}
if (! defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1');
}
if (! defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1'); // If there is no menu to show
}
if (! defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
}
if (! defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (! defined("NOLOGIN")) {
define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
}
if (! defined("NOSESSION")) {
define("NOSESSION", '1');
}
require_once dirname(__FILE__).'/../../htdocs/main.inc.php'; // We force include of main.inc.php instead of master.inc.php even if we are in CLI mode because it contains a lot of security components we want to test.
require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php';
require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php';
require_once dirname(__FILE__).'/CommonClassTest.class.php';
if (empty($user->id)) {
print "Load permissions for admin user nb 1\n";
$user->fetch(1);
$user->loadRights();
}
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
/**
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
*/
class SecurityLoginTest extends CommonClassTest
{
/**
* testCheckLoginPassEntity
*
* @return void
*/
public function testCheckLoginPassEntity()
{
$login = checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr'));
print __METHOD__." login=".$login."\n";
$this->assertEquals($login, '');
$login = checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr'));
print __METHOD__." login=".$login."\n";
$this->assertEquals($login, '');
$login = checkLoginPassEntity('admin', 'admin', 1, array('dolibarr')); // Should works because admin/admin exists
print __METHOD__." login=".$login."\n";
$this->assertEquals($login, 'admin', 'The test to check if pass of user "admin" is "admin" has failed');
$login = checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr')); // Should work because of second authentication method
print __METHOD__." login=".$login."\n";
$this->assertEquals($login, 'admin');
$login = checkLoginPassEntity('admin', 'admin', 1, array('forceuser'));
print __METHOD__." login=".$login."\n";
$this->assertEquals('', $login, 'Error'); // Expected '' because should failed because login 'auto' does not exists
}
}

View file

@ -636,13 +636,13 @@ class SecurityTest extends CommonClassTest
$this->assertEquals('Bad string syntax to evaluate: new __forbiddenstring__(\'abc\')', $result);
$result = (string) dol_eval('$a=function() { }; $a;', 1, 1, '0');
print "result5 = ".$result."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', $result);
$result = dol_eval('$a=function() { }; $a', 1, 1, '0'); // result of dol_eval may be an object Closure
print "result5 = ".json_encode($result)."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', json_encode($result));
$result = (string) dol_eval('$a=function() { }; $a;', 1, 1, '1');
print "result6 = ".$result."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', $result);
$result = dol_eval('$a=function() { }; $a();', 1, 1, '1');
print "result6 = ".json_encode($result)."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', json_encode($result));
$result = (string) dol_eval('$a=exec("ls");', 1, 1);
print "result7 = ".$result."\n";
@ -723,6 +723,11 @@ class SecurityTest extends CommonClassTest
$result = (string) dol_eval('($a = "ex") && ($b = "ec") && ($cmd = "$a$b") && $cmd ("curl localhost:5555")', 1, 0);
print "result22 = ".$result."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', $result, 'Test 22');
$result = (string) dol_eval('\'exec\'("aaa")', 1, 0);
print "result1 = ".$result."\n";
$this->assertStringContainsString('Bad string syntax to evaluate', json_encode($result), 'Cant find the string Bad string syntaxwhen i should');
}
/**
@ -966,33 +971,4 @@ class SecurityTest extends CommonClassTest
return 0;
}
/**
* testCheckLoginPassEntity
*
* @return void
*/
public function testCheckLoginPassEntity()
{
$login = checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr'));
print __METHOD__." login=".$login."\n";
$this->assertEquals($login, '');
$login = checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr'));
print __METHOD__." login=".$login."\n";
$this->assertEquals($login, '');
$login = checkLoginPassEntity('admin', 'admin', 1, array('dolibarr')); // Should works because admin/admin exists
print __METHOD__." login=".$login."\n";
$this->assertEquals($login, 'admin', 'The test to check if pass of user "admin" is "admin" has failed');
$login = checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr')); // Should work because of second authentication method
print __METHOD__." login=".$login."\n";
$this->assertEquals($login, 'admin');
$login = checkLoginPassEntity('admin', 'admin', 1, array('forceuser'));
print __METHOD__." login=".$login."\n";
$this->assertEquals('', $login, 'Error'); // Expected '' because should failed because login 'auto' does not exists
}
}

View file

@ -65,11 +65,11 @@ if (empty($user->id)) {
print "Load permissions for admin user nb 1\n";
$user->fetch(1);
$user->loadRights();
if (empty($user->rights->website)) {
$user->rights->website = new stdClass();
}
}
if (empty($user->rights->website)) {
$user->rights->website = new stdClass();
}
$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
@ -132,22 +132,61 @@ class WebsiteTest extends CommonClassTest
*/
public function testCheckPHPCode()
{
global $user;
global $conf, $user;
// Force permission so this is not the permission that will affect result of checkPHPCode
$user->rights->website->writephp = 1;
// Legitimate
$t = '';
$s = '<?php execu ?>';
$result = checkPHPCode($t, $s);
print __METHOD__." result checkPHPCode=".$result."\n";
$this->assertEquals($result, 0, 'checkPHPCode detect string as dangerous when it is legitimate');
// Dangerous
$t = '';
$s = '<?php exec("eee"); ?>';
$result = checkPHPCode($t, $s);
print __METHOD__." result checkPHPCode=".$result."\n";
$this->assertEquals($result, 1, 'checkPHPCode did not detect the string was dangerous');
$t = '';
$s = '<?php eXec ("eee"); ?>';
$result = checkPHPCode($t, $s);
print __METHOD__." result checkPHPCode=".$result."\n";
$this->assertEquals($result, 1, 'checkPHPCode did not detect the string was dangerous');
$t = '';
$s = '<?php $a="xec"; "e$a" ("ee"); ?>';
$result = checkPHPCode($t, $s);
print __METHOD__." result checkPHPCode=".$result."\n";
$this->assertEquals($result, 1, 'checkPHPCode did not detect the string was dangerous');
$t = '';
$s = '<?php $a=\'exec\'("ee"); ?>';
$result = checkPHPCode($t, $s);
print __METHOD__." result checkPHPCode=".$result."\n";
$this->assertEquals($result, 1, 'checkPHPCode did not detect the string was dangerous');
$t = '';
$s = '<?php $_="{"; $_=($_^"<").($_^">;").($_^"/"); ?><?=${\'_\'.$_}["_"](${\'_\'.$_}["__"]);?>';
$result = checkPHPCode($t, $s);
print __METHOD__." result checkPHPCode=".$result."\n";
$this->assertEquals($result, 1, 'checkPHPCode did not detect the string was dangerous');
// Dangerous but legitimate due to option WEBSITE_PHP_ALLOW_EXEC
$conf->global->WEBSITE_PHP_ALLOW_EXEC = 1;
$t = '';
$s = '<?php exec("eee"); ?>';
$result = checkPHPCode($t, $s);
print __METHOD__." result checkPHPCode=".$result."\n";
$this->assertEquals($result, 0, 'checkPHPCode did not accept the exec. it should when WEBSITE_PHP_ALLOW_EXEC is set.');
}
/**