2
0
forked from Wavyzz/dolibarr

Merge branch 'develop' into addLayoutForWebsite

This commit is contained in:
Laurent Destailleur
2024-03-24 02:28:07 +01:00
committed by GitHub
269 changed files with 4604 additions and 2102 deletions

View File

@@ -147,18 +147,18 @@ abstract class CommonDocGenerator
public $emetteur;
/**
* @var array Minimum version of PHP required by module.
* @var array{0:int,1:int} Minimum version of PHP required by module.
* e.g.: PHP ≥ 7.1 = array(7, 1)
*/
public $phpmin = array(7, 1);
/**
* @var array Array of columns
* @var array<string,array{rank:int,width:float|int,title:array{textkey:string,label:string,align:string,padding:array{0:float,1:float,2:float,3:float}},content:array{align:string,padding:array{0:float,1:float,2:float,3:float}}}> Array of columns
*/
public $cols;
/**
* @var array Array with result of doc generation. content is array('fullpath'=>$file)
* @var array{fullpath:string} Array with result of doc generation. content is array('fullpath'=>$file)
*/
public $result;
@@ -856,7 +856,7 @@ abstract class CommonDocGenerator
include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
$object->list_delivery_methods($object->shipping_method_id);
$calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
$calculatedVolume = ((float) $object->trueWidth * (float) $object->trueHeight * (float) $object->trueDepth);
$array_shipment = array(
$array_key.'_id' => $object->id,

View File

@@ -3861,7 +3861,7 @@ abstract class CommonObject
if ($forcedroundingmode == '1') { // Check if we need adjustment onto line for vat. TODO This works on the company currency but not on foreign currency
$tmpvat = price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1);
$diff = price2num($total_tva_by_vats[$obj->vatrate] - $tmpvat, 'MT', 1);
$diff = price2num($total_tva_by_vats[$obj->vatrate] - (float) $tmpvat, 'MT', 1);
//print 'Line '.$i.' rowid='.$obj->rowid.' vat_rate='.$obj->vatrate.' total_ht='.$obj->total_ht.' total_tva='.$obj->total_tva.' total_ttc='.$obj->total_ttc.' total_ht_by_vats='.$total_ht_by_vats[$obj->vatrate].' total_tva_by_vats='.$total_tva_by_vats[$obj->vatrate].' (new calculation = '.$tmpvat.') total_ttc_by_vats='.$total_ttc_by_vats[$obj->vatrate].($diff?" => DIFF":"")."<br>\n";
if ($diff) {
if (abs((float) $diff) > (10 * pow(10, -1 * getDolGlobalInt('MAIN_MAX_DECIMALS_TOT', 0)))) {
@@ -3872,7 +3872,7 @@ abstract class CommonObject
$error++;
break;
}
$sqlfix = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldtva." = ".price2num($obj->total_tva - $diff).", total_ttc = ".price2num($obj->total_ttc - $diff)." WHERE rowid = ".((int) $obj->rowid);
$sqlfix = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldtva." = ".price2num($obj->total_tva - (float) $diff).", total_ttc = ".price2num($obj->total_ttc - (float) $diff)." WHERE rowid = ".((int) $obj->rowid);
dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix);
$resqlfix = $this->db->query($sqlfix);
@@ -3881,10 +3881,10 @@ abstract class CommonObject
dol_print_error($this->db, 'Failed to update line');
}
$this->total_tva = (float) price2num($this->total_tva - $diff, '', 1);
$this->total_ttc = (float) price2num($this->total_ttc - $diff, '', 1);
$total_tva_by_vats[$obj->vatrate] = (float) price2num($total_tva_by_vats[$obj->vatrate] - $diff, '', 1);
$total_ttc_by_vats[$obj->vatrate] = (float) price2num($total_ttc_by_vats[$obj->vatrate] - $diff, '', 1);
$this->total_tva = (float) price2num($this->total_tva - (float) $diff, '', 1);
$this->total_ttc = (float) price2num($this->total_ttc - (float) $diff, '', 1);
$total_tva_by_vats[$obj->vatrate] = (float) price2num($total_tva_by_vats[$obj->vatrate] - (float) $diff, '', 1);
$total_ttc_by_vats[$obj->vatrate] = (float) price2num($total_ttc_by_vats[$obj->vatrate] - (float) $diff, '', 1);
}
}

View File

@@ -754,7 +754,7 @@ class Conf extends stdClass
// MAIN_HTML_TITLE
if (!isset($this->global->MAIN_HTML_TITLE)) {
$this->global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly';
$this->global->MAIN_HTML_TITLE = 'thirdpartynameonly,contactnameonly,projectnameonly';
}
// conf->liste_limit = constante de taille maximale des listes

View File

@@ -64,7 +64,7 @@ class DefaultValues extends CommonObject
* Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
* 'label' the translation key.
* 'picto' is code of a picto to show before value in forms
* 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM)
* 'enabled' is a condition when the field must be managed (Example: 1 or 'getDolGlobalString("MY_SETUP_PARAM")'
* 'position' is the sort order of field.
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)

View File

@@ -6920,8 +6920,8 @@ class Form
} elseif ($usecalendar == 'jquery' || $usecalendar == 'html') {
if (!$disabled && $usecalendar != 'html') {
// Output javascript for datepicker
$minYear = getDolGlobalInt('MIN_YEAR_SELECT_DATE', (date('Y') - 100));
$maxYear = getDolGlobalInt('MAX_YEAR_SELECT_DATE', (date('Y') + 100));
$minYear = getDolGlobalInt('MIN_YEAR_SELECT_DATE', (idate('Y') - 100));
$maxYear = getDolGlobalInt('MAX_YEAR_SELECT_DATE', (idate('Y') + 100));
$retstring .= '<script nonce="' . getNonce() . '" type="text/javascript">';
$retstring .= "$(function(){ $('#" . $prefix . "').datepicker({
@@ -7006,7 +7006,8 @@ class Form
} else {
$retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth75imp" id="' . $prefix . 'year" name="' . $prefix . 'year">';
for ($year = $syear - 10; $year < $syear + 10; $year++) {
$syear = (int) $syear;
for ($year = $syear - 10; $year < (int) $syear + 10; $year++) {
$retstring .= '<option value="' . $year . '"' . ($year == $syear ? ' selected' : '') . '>' . $year . '</option>';
}
$retstring .= "</select>\n";
@@ -8165,7 +8166,7 @@ class Form
$oldValueForShowOnCombobox = 0;
foreach ($objecttmp->fields as $fieldK => $fielV) {
if (!$fielV['showoncombobox'] || empty($objecttmp->$fieldK)) {
if (empty($fielV['showoncombobox']) || empty($objecttmp->$fieldK)) {
continue;
}

View File

@@ -11,6 +11,7 @@
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 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
* it under the terms of the GNU General Public License as published by
@@ -1043,13 +1044,13 @@ class FormOther
global $langs;
$week = array(
0=>$langs->trans("Day0"),
1=>$langs->trans("Day1"),
2=>$langs->trans("Day2"),
3=>$langs->trans("Day3"),
4=>$langs->trans("Day4"),
5=>$langs->trans("Day5"),
6=>$langs->trans("Day6")
0 => $langs->trans("Day0"),
1 => $langs->trans("Day1"),
2 => $langs->trans("Day2"),
3 => $langs->trans("Day3"),
4 => $langs->trans("Day4"),
5 => $langs->trans("Day5"),
6 => $langs->trans("Day6")
);
$select_week = '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
@@ -1164,7 +1165,7 @@ class FormOther
{
$out = '';
$currentyear = date("Y") + $offset;
$currentyear = idate("Y") + $offset;
$max_year = $currentyear + $max_year;
$min_year = $currentyear - $min_year;
if (empty($selected) && empty($useempty)) {
@@ -1252,7 +1253,7 @@ class FormOther
if (preg_match('/graph/', $box->class) && $conf->browser->layout != 'phone') {
$label = $label.' <span class="fas fa-chart-bar"></span>';
}
$arrayboxtoactivatelabel[$box->id] = array('label'=>$label, 'data-html'=>img_picto('', $box->boximg, 'class="pictofixedwidth"').$langs->trans($label)); // We keep only boxes not shown for user, to show into combo list
$arrayboxtoactivatelabel[$box->id] = array('label' => $label, 'data-html' => img_picto('', $box->boximg, 'class="pictofixedwidth"').$langs->trans($label)); // We keep only boxes not shown for user, to show into combo list
}
foreach ($boxidactivatedforuser as $boxid) {
if (empty($boxorder)) {
@@ -1271,7 +1272,7 @@ class FormOther
$selectboxlist .= '<input type="hidden" name="userid" value="'.$user->id.'">';
$selectboxlist .= '<input type="hidden" name="areacode" value="'.$areacode.'">';
$selectboxlist .= '<input type="hidden" name="boxorder" value="'.$boxorder.'">';
$selectboxlist .= Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd").'...', 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth150onsmartphone hideonprint', 0, 'hidden selected', 0, 0);
$selectboxlist .= Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd").'...', 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth300 hideonprint', 0, 'hidden selected', 0, 0);
if (empty($conf->use_javascript_ajax)) {
$selectboxlist .= ' <input type="submit" class="button" value="'.$langs->trans("AddBox").'">';
}
@@ -1433,7 +1434,7 @@ class FormOther
$boxlistb .= "<!-- End box right container -->\n";
}
return array('selectboxlist'=>count($boxactivated) ? $selectboxlist : '', 'boxactivated'=>$boxactivated, 'boxlista'=>$boxlista, 'boxlistb'=>$boxlistb);
return array('selectboxlist' => count($boxactivated) ? $selectboxlist : '', 'boxactivated' => $boxactivated, 'boxlista' => $boxlista, 'boxlistb' => $boxlistb);
}

View File

@@ -27,6 +27,9 @@ class FormSetup
*/
public $db;
/** @var int */
public $entity;
/** @var FormSetupItem[] */
public $items = array();
@@ -92,7 +95,8 @@ class FormSetup
*/
public function __construct($db, $outputLangs = null)
{
global $langs;
global $conf, $langs;
$this->db = $db;
$this->form = new Form($this->db);
@@ -101,6 +105,8 @@ class FormSetup
$this->formHiddenInputs['token'] = newToken();
$this->formHiddenInputs['action'] = 'update';
$this->entity = (is_null($this->entity) ? $conf->entity : $this->entity);
if ($outputLangs) {
$this->langs = $outputLangs;
} else {
@@ -461,6 +467,8 @@ class FormSetup
{
$item = new FormSetupItem($confKey);
$item->entity = $this->entity;
// set item rank if not defined as last item
if (empty($item->rank)) {
$item->rank = $this->getCurentItemMaxRank() + 1;
@@ -657,7 +665,7 @@ class FormSetupItem
/**
* Constructor
*
* @param string $confKey the conf key used in database
* @param string $confKey the conf key used in database
*/
public function __construct($confKey)
{
@@ -671,7 +679,7 @@ class FormSetupItem
}
$this->langs = $langs;
$this->entity = $conf->entity;
$this->entity = (is_null($this->entity) ? $conf->entity : ((int) $this->entity));
$this->confKey = $confKey;
$this->loadValueFromConf();
@@ -1184,7 +1192,7 @@ class FormSetupItem
$out .= $this->generateOutputFieldColor();
} elseif ($this->type == 'yesno') {
if (!empty($conf->use_javascript_ajax)) {
$out .= ajax_constantonoff($this->confKey);
$out .= ajax_constantonoff($this->confKey, array(), $this->entity); // TODO possibility to add $input parameter
} else {
if ($this->fieldValue == 1) {
$out .= $langs->trans('yes');

View File

@@ -1228,7 +1228,7 @@ class Utils
} elseif (is_string($row[$j]) && $row[$j] == '') {
// if it's an empty string, we set it as an empty string
$row[$j] = "''";
} elseif (is_numeric($row[$j]) && !strcmp((string) $row[$j], (string) ($row[$j] + 0))) { // test if it's a numeric type and the numeric version ($nb+0) == string version (eg: if we have 01, it's probably not a number but rather a string, else it would not have any leading 0)
} elseif (is_numeric($row[$j]) && !strcmp((string) $row[$j], (string) ((float) $row[$j] + 0))) { // test if it's a numeric type and the numeric version ($nb+0) == string version (eg: if we have 01, it's probably not a number but rather a string, else it would not have any leading 0)
// if it's a number, we return it as-is
// $row[$j] = $row[$j];
} else { // else for all other cases we escape the value and put quotes around

View File

@@ -115,9 +115,9 @@ class Diff
*
* @param string $sequence1 the first sequence
* @param string $sequence2 the second sequence
* @param string $start the starting index
* @param string $end1 the ending index for the first sequence
* @param string $end2 the ending index for the second sequence
* @param int $start the starting index
* @param int $end1 the ending index for the first sequence
* @param int $end2 the ending index for the second sequence
* @return array<array<int>> array of diff
*/
private static function computeTable($sequence1, $sequence2, $start, $end1, $end2)
@@ -157,7 +157,7 @@ class Diff
* @param array<array{0:string,1:int<0,2>}> $table the table returned by the computeTable function
* @param string $sequence1 the first sequence
* @param string $sequence2 the second sequence
* @param string $start the starting index
* @param int $start the starting index
* @return array<array{0:string,1:int<0,2>}> array of diff
*/
private static function generatePartialDiff($table, $sequence1, $sequence2, $start)