From 0950df7b63422e13af1ed24b6c06a37cb07c0db7 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 2 Feb 2023 17:28:47 +0100 Subject: [PATCH 01/84] Add options in function pdf_pagefoot & pdf_pagehead of pdf.lib.php --- htdocs/core/lib/pdf.lib.php | 75 ++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 4d9569a1cc4..1a9e2a0b44a 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -724,11 +724,13 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height) $filepath = $conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF; if (file_exists($filepath)) { $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image + if (getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF_ALPHA')) { $pdf->SetAlpha($conf->global->MAIN_USE_BACKGROUND_ON_PDF_ALPHA); } // Option for change opacity of background $pdf->Image($filepath, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height); - $pdf->SetPageMark(); // This option avoid to have the images missing on some pages + if (getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF_ALPHA')) { $pdf->SetAlpha(1); } $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak } } + $pdf->SetPageMark(); // This option avoid to have the images missing on some pages } @@ -1246,49 +1248,54 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $pdf->SetY(-$posy); - // Hide footer line if footer background color is set - if (!getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR')) { - $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy); - } + // Option for hide all footer (page number will no hidden) + if (getDolGlobalInt('PDF_FOOTER_HIDDEN') !== 1) { - // Option for set top margin height of footer after freetext - if (getDolGlobalString('PDF_FOOTER_TOP_MARGIN') || getDolGlobalInt('PDF_FOOTER_TOP_MARGIN') === 0) { - $posy -= floatval(getDolGlobalString('PDF_FOOTER_TOP_MARGIN')); - } else { - $posy--; - } + // Hide footer line if footer background color is set + if (!getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR')) { + $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy); + } - if (!empty($line1)) { - $pdf->SetFont('', 'B', 7); - $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line1, 0, 'C', 0); - $posy -= 3; - $pdf->SetFont('', '', 7); - } + // Option for set top margin height of footer after freetext + if (getDolGlobalString('PDF_FOOTER_TOP_MARGIN') || getDolGlobalInt('PDF_FOOTER_TOP_MARGIN') === 0) { + $posy -= floatval(getDolGlobalString('PDF_FOOTER_TOP_MARGIN')); + } else { + $posy--; + } - if (!empty($line2)) { - $pdf->SetFont('', 'B', 7); - $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line2, 0, 'C', 0); - $posy -= 3; - $pdf->SetFont('', '', 7); - } + if (!empty($line1)) { + $pdf->SetFont('', 'B', 7); + $pdf->SetXY($dims['lm'], -$posy); + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line1, 0, 'C', 0); + $posy -= 3; + $pdf->SetFont('', '', 7); + } - if (!empty($line3)) { - $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line3, 0, 'C', 0); - } + if (!empty($line2)) { + $pdf->SetFont('', 'B', 7); + $pdf->SetXY($dims['lm'], -$posy); + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line2, 0, 'C', 0); + $posy -= 3; + $pdf->SetFont('', '', 7); + } - if (!empty($line4)) { - $posy -= 3; - $pdf->SetXY($dims['lm'], -$posy); - $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line4, 0, 'C', 0); + if (!empty($line3)) { + $pdf->SetXY($dims['lm'], -$posy); + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line3, 0, 'C', 0); + } + + if (!empty($line4)) { + $posy -= 3; + $pdf->SetXY($dims['lm'], -$posy); + $pdf->MultiCell($dims['wk'] - $dims['rm'] - $dims['lm'], 2, $line4, 0, 'C', 0); + } } } } // Show page nb only on iso languages (so default Helvetica font) if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') { - $pdf->SetXY($dims['wk'] - $dims['rm'] - 18, -$posy); + // Option for change XY position of the page number + $pdf->SetXY($dims['wk'] - $dims['rm'] - 18 - ( getDolGlobalString('PDF_FOOTER_PAGE_NUMBER_X') ? floatval(getDolGlobalString('PDF_FOOTER_PAGE_NUMBER_X')) : 0 ) , -$posy - ( getDolGlobalString('PDF_FOOTER_PAGE_NUMBER_Y') ? floatval(getDolGlobalString('PDF_FOOTER_PAGE_NUMBER_Y')) : 0 )); //$pdf->MultiCell(18, 2, $pdf->getPageNumGroupAlias().' / '.$pdf->getPageGroupAlias(), 0, 'R', 0); $pdf->MultiCell(18, 2, $pdf->PageNo().' / '.$pdf->getAliasNbPages(), 0, 'R', 0); } From bce25eaff1db9d96443951ae6231b5e0f31c066b Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 2 Feb 2023 16:44:09 +0000 Subject: [PATCH 02/84] Fixing style errors. --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 1a9e2a0b44a..cf22b70f772 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1295,7 +1295,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // Show page nb only on iso languages (so default Helvetica font) if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') { // Option for change XY position of the page number - $pdf->SetXY($dims['wk'] - $dims['rm'] - 18 - ( getDolGlobalString('PDF_FOOTER_PAGE_NUMBER_X') ? floatval(getDolGlobalString('PDF_FOOTER_PAGE_NUMBER_X')) : 0 ) , -$posy - ( getDolGlobalString('PDF_FOOTER_PAGE_NUMBER_Y') ? floatval(getDolGlobalString('PDF_FOOTER_PAGE_NUMBER_Y')) : 0 )); + $pdf->SetXY($dims['wk'] - $dims['rm'] - 18 - ( getDolGlobalString('PDF_FOOTER_PAGE_NUMBER_X') ? floatval(getDolGlobalString('PDF_FOOTER_PAGE_NUMBER_X')) : 0 ), -$posy - ( getDolGlobalString('PDF_FOOTER_PAGE_NUMBER_Y') ? floatval(getDolGlobalString('PDF_FOOTER_PAGE_NUMBER_Y')) : 0 )); //$pdf->MultiCell(18, 2, $pdf->getPageNumGroupAlias().' / '.$pdf->getPageGroupAlias(), 0, 'R', 0); $pdf->MultiCell(18, 2, $pdf->PageNo().' / '.$pdf->getAliasNbPages(), 0, 'R', 0); } From 3a8fbd3aa8dfbb8847abbe5e162a29ddbcb633ab Mon Sep 17 00:00:00 2001 From: Guenter Lukas Date: Mon, 6 Feb 2023 10:32:54 +0100 Subject: [PATCH 03/84] update --- htdocs/comm/action/card.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 545088e47e9..1412890b3d8 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -142,9 +142,6 @@ if (!empty($conf->global->AGENDA_REMINDER_EMAIL)) { $TDurationTypes = array('y'=>$langs->trans('Years'), 'm'=>$langs->trans('Month'), 'w'=>$langs->trans('Weeks'), 'd'=>$langs->trans('Days'), 'h'=>$langs->trans('Hours'), 'i'=>$langs->trans('Minutes')); $result = restrictedArea($user, 'agenda', $object->id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); -if ($user->socid && $socid) { - $result = restrictedArea($user, 'societe', $socid); -} /* From 329d8d01a67bf6e24da0c252221202c33d38388f Mon Sep 17 00:00:00 2001 From: habot-it <58470575+habot-it@users.noreply.github.com> Date: Sat, 11 Feb 2023 14:30:58 +0100 Subject: [PATCH 04/84] Add options in function pdf_pagefoot & pdf_pagehead of pdf.lib.php - Revision 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hello @eldy, In pdf_pagehead function : Add MAIN_USE_BACKGROUND_ON_PDF_ALPHA option for change opacity of the background ̶S̶e̶t̶P̶a̶g̶e̶M̶a̶r̶k̶ ̶m̶o̶v̶e̶d̶ ̶t̶o̶ ̶f̶i̶x̶e̶ ̶t̶h̶e̶ ̶s̶a̶m̶e̶ ̶p̶r̶o̶b̶l̶e̶m̶ ̶o̶f̶ ̶M̶A̶I̶N̶_̶U̶S̶E̶_̶B̶A̶C̶K̶G̶R̶O̶U̶N̶D̶_̶O̶N̶_̶P̶D̶F̶ ̶b̶u̶t̶ ̶f̶o̶r̶ ̶M̶A̶I̶N̶_̶A̶D̶D̶_̶P̶D̶F̶_̶B̶A̶C̶K̶G̶R̶O̶U̶N̶D̶ ̶t̶o̶o̶ In pdf_pagefoot function : Add PDF_FOOTER_HIDDEN to hide all footer (page number will no hidden) Add PDF_FOOTER_PAGE_NUMBER_X & PDF_FOOTER_PAGE_NUMBER_Y to change XY position of the page number Best regards, Alban --- htdocs/core/lib/pdf.lib.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index cf22b70f772..3da0dd889d6 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -727,10 +727,10 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height) if (getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF_ALPHA')) { $pdf->SetAlpha($conf->global->MAIN_USE_BACKGROUND_ON_PDF_ALPHA); } // Option for change opacity of background $pdf->Image($filepath, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height); if (getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF_ALPHA')) { $pdf->SetAlpha(1); } + $pdf->SetPageMark(); // This option avoid to have the images missing on some pages $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak } } - $pdf->SetPageMark(); // This option avoid to have the images missing on some pages } @@ -1250,7 +1250,6 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ // Option for hide all footer (page number will no hidden) if (getDolGlobalInt('PDF_FOOTER_HIDDEN') !== 1) { - // Hide footer line if footer background color is set if (!getDolGlobalString('PDF_FOOTER_BACKGROUND_COLOR')) { $pdf->line($dims['lm'], $dims['hk'] - $posy, $dims['wk'] - $dims['rm'], $dims['hk'] - $posy); From 728c2ef2381b82e1fe97848fb1eef465adaa8981 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 11 Feb 2023 18:02:28 +0100 Subject: [PATCH 05/84] Add options in function pdf_pagefoot & pdf_pagehead of pdf.lib.php - Revision 2 --- htdocs/core/lib/pdf.lib.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 3da0dd889d6..ab9664f10c7 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -731,6 +731,9 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height) $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak } } + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND) && ($conf->global->MAIN_ADD_PDF_BACKGROUND != '-1')) { + $pdf->SetPageMark(); // This option avoid to have the images missing on some pages + } } From 6163f84d258df4cf87e01cebdf7b11a549bbe9b1 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Wed, 15 Feb 2023 22:10:03 +0100 Subject: [PATCH 06/84] move log after variable updates to get good informations in logs --- htdocs/core/class/CMailFile.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 94fb05d5346..47f8fd900cb 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -184,9 +184,6 @@ class CMailFile // On defini alternative_boundary $this->alternative_boundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3); // Force md5 hash (does not contains special chars) - dol_syslog("CMailFile::CMailfile: sendmode=".$this->sendmode." charset=".$conf->file->character_set_client." from=$from, to=$to, addr_cc=$addr_cc, addr_bcc=$addr_bcc, errors_to=$errors_to, replyto=$replyto trackid=$trackid sendcontext=$sendcontext", LOG_DEBUG); - dol_syslog("CMailFile::CMailfile: subject=".$subject.", deliveryreceipt=".$deliveryreceipt.", msgishtml=".$msgishtml, LOG_DEBUG); - if (empty($subject)) { dol_syslog("CMailFile::CMailfile: Try to send an email with empty subject"); $this->error = 'ErrorSubjectIsRequired'; @@ -314,6 +311,9 @@ class CMailFile } } + dol_syslog("CMailFile::CMailfile: sendmode=".$this->sendmode." charset=".$conf->file->character_set_client." from=$from, to=$to, addr_cc=$addr_cc, addr_bcc=$addr_bcc, errors_to=$errors_to, replyto=$replyto trackid=$trackid sendcontext=$sendcontext", LOG_DEBUG); + dol_syslog("CMailFile::CMailfile: subject=".$subject.", deliveryreceipt=".$deliveryreceipt.", msgishtml=".$msgishtml, LOG_DEBUG); + // We set all data according to choosed sending method. // We also set a value for ->msgid if ($this->sendmode == 'mail') { From 3a58e025badea87a7758d149d7d435b017032fc8 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Thu, 16 Feb 2023 21:44:38 +0100 Subject: [PATCH 07/84] better logs --- htdocs/core/class/CMailFile.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 47f8fd900cb..0269b25fd6c 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -142,6 +142,9 @@ class CMailFile { global $conf, $dolibarr_main_data_root, $user; + dol_syslog("CMailFile::CMailfile: charset=".$conf->file->character_set_client." from=$from, to=$to, addr_cc=$addr_cc, errors_to=$errors_to, replyto=$replyto trackid=$trackid sendcontext=$sendcontext", LOG_DEBUG); + dol_syslog("CMailFile::CMailfile: subject=".$subject.", deliveryreceipt=".$deliveryreceipt.", msgishtml=".$msgishtml, LOG_DEBUG); + // Clean values of $mimefilename_list if (is_array($mimefilename_list)) { foreach ($mimefilename_list as $key => $val) { @@ -311,8 +314,7 @@ class CMailFile } } - dol_syslog("CMailFile::CMailfile: sendmode=".$this->sendmode." charset=".$conf->file->character_set_client." from=$from, to=$to, addr_cc=$addr_cc, addr_bcc=$addr_bcc, errors_to=$errors_to, replyto=$replyto trackid=$trackid sendcontext=$sendcontext", LOG_DEBUG); - dol_syslog("CMailFile::CMailfile: subject=".$subject.", deliveryreceipt=".$deliveryreceipt.", msgishtml=".$msgishtml, LOG_DEBUG); + dol_syslog("CMailFile::CMailfile: sendmode=".$this->sendmode." addr_bcc=$addr_bcc, replyto=$replyto", LOG_DEBUG); // We set all data according to choosed sending method. // We also set a value for ->msgid From 86e2f46fe7a4cebc24de3039c23e4e07891ac82b Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Thu, 16 Feb 2023 21:46:27 +0100 Subject: [PATCH 08/84] addr_bcc could be set --- htdocs/core/class/CMailFile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 0269b25fd6c..90c16dc589f 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -142,7 +142,7 @@ class CMailFile { global $conf, $dolibarr_main_data_root, $user; - dol_syslog("CMailFile::CMailfile: charset=".$conf->file->character_set_client." from=$from, to=$to, addr_cc=$addr_cc, errors_to=$errors_to, replyto=$replyto trackid=$trackid sendcontext=$sendcontext", LOG_DEBUG); + dol_syslog("CMailFile::CMailfile: charset=".$conf->file->character_set_client." from=$from, to=$to, addr_cc=$addr_cc, addr_bcc=$addr_bcc, errors_to=$errors_to, replyto=$replyto trackid=$trackid sendcontext=$sendcontext", LOG_DEBUG); dol_syslog("CMailFile::CMailfile: subject=".$subject.", deliveryreceipt=".$deliveryreceipt.", msgishtml=".$msgishtml, LOG_DEBUG); // Clean values of $mimefilename_list From 36e73280bf50d85e5503131d5fc3ba81bb0f91aa Mon Sep 17 00:00:00 2001 From: Guenter Lukas Date: Mon, 20 Feb 2023 12:51:15 +0100 Subject: [PATCH 09/84] FIX:#23966 Error "Param dbt_keyfield is required but not defined" --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 798ba265643..264ed290f58 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -682,7 +682,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl // Array to define rules of checks to do $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for societe object - $checkother = array('contact', 'agenda'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). + $checkother = array('contact', 'agenda', 'contrat'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet', 'project'); // Test for project object $checktask = array('projet_task'); // Test for task object $checkhierarchy = array('expensereport', 'holiday'); From 3c883c4b319c1742fa8d4403200081b0119a4f3a Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Sat, 18 Feb 2023 14:06:58 +0100 Subject: [PATCH 10/84] NEW inc.php: handle parameters from argv This commit adds support for --help and --config to provide a different config file when running upgrade.php from commandline. The argv array is patched afterwards as if the options were never given so that it stays transparent for the code path that are not aware of those arguments. The intention behind is incrementally move the usage of argc/argv to this location and force help/usage from there, in particular for upgrading. The rationale for the --config addition is to be able to provide a different path for conf.php when multiple dolibarr instance are using the same readonly htdocs folder, which is already possible by modifying the `include_path` from PHP for the htdocs/ directory but not for the htdocs/install directory since relative paths are used to fetch the config file. Since the use-case is to upgrade/migrate a Dolibarr instance from CLI, it makes sense to be able to select for which instance (and database parameters) the upgrade should take place. --- htdocs/install/inc.php | 87 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 970fd40261b..bf675ae0a36 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -6,6 +6,7 @@ * Copyright (C) 2012 Marcos García * Copyright (C) 2016 Raphaël Doursenaud * Copyright (C) 2021 Charlene Benke + * Copyright (C) 2023 Alexandre Janniaux * * 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 @@ -70,6 +71,92 @@ $conffiletoshow = "htdocs/conf/conf.php"; //$conffile = "/etc/dolibarr/conf.php"; //$conffiletoshow = "/etc/dolibarr/conf.php"; +$short_options = "c:h"; +$long_options = array( + "config:", + "help", +); + +/** + * Print the usage when executing scripts from install/. + * + * Print the help text exposing the available options when executing + * update or install script (ie. from htdocs/install/) from CLI with + * the `php` executable. This function does not `exit` the program and + * the caller should then call `exit` themselves since they should + * determine whether it was an error or not. + * + * @param string $program the script that was originally run + * @param string $header the message to signal to the user + * @return void + */ +function usage($program, $header) +{ + echo $header."\n"; + echo " php ".$program." [options] previous_version new_version [script options]\n"; + echo "\n"; + echo "Script options when using upgrade.php:\n"; + echo "\n"; + echo " dirmodule:\n"; + echo " Specify dirmodule to provide a path for an external module\n"; + echo " so the migration is done using a script from a module.\n"; + echo "\n"; + echo " ignoredbversion:\n"; + echo " Allow to run migration even if database version does\n"; + echo " not match start version of migration.\n"; + echo "\n"; + echo "Script options when using upgrade2.php:\n"; + echo "\n"; + echo " MODULE_NAME1_TO_ENABLE,MODULE_NAME2_TO_ENABLE:\n"; + echo " Specify a list of module-name to enable, joined by comma.\n"; + echo "\n"; + echo "Options:\n"; + echo " -c, --config :\n"; + echo " Provide a different conf.php file to use.\n"; + echo "\n"; + echo " -h, --help:\n"; + echo " Display this help message.\n"; +} + +if (php_sapi_name() === "cli") { + $rest_index = 0; + $opts = getopt($short_options, $long_options, $rest_index); + + foreach ($opts as $opt => $arg) switch ($opt) { + case 'c': + case 'config': + $conffile = $arg; + $conffiletoshow = $arg; + break; + case 'h': + case 'help': + usage($argv[0], "Usage:"); + exit(0); + } + + // In the following test, only dash-prefixed arguments will trigger an + // error, given that scripts options can allow a variable number of + // additional non-prefixed argument and we mostly want to check for + // typo right now. + if ($rest_index < $argc && $argv[$rest_index][0] == "-") { + usage($argv[0], "Unknown option ".$argv[$rest_index]. ", usage:"); + exit(1); + } + + // Currently, scripts using inc.php will require addtional arguments, + // see help above for more details. + if ($rest_index > $argc - 2) { + usage($argv[0], "Missing mandatory arguments, usage:"); + exit(1); + } + + // Tricky argument list hack, should be removed someday. + // Reset argv to remove the argument that were parsed. This is needed + // currently because some install code, like in upgrade.php, are using + // $argv[] directly with fixed index to fetch some arguments. + $argv = array_merge(array($argv[0]), array_slice($argv, $rest_index)); + $argc = count($argv); +} // Load conf file if it is already defined if (!defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) > 8) { // Test on filesize is to ensure that conf file is more that an empty template with just Date: Wed, 1 Mar 2023 08:33:52 +0100 Subject: [PATCH 11/84] Allow FileUpload to be used when $fk_element and $element are null but enforce a valid upload_dir --- htdocs/core/class/fileupload.class.php | 71 ++++++++++++++++---------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index 75662d57f94..7eb76032183 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -104,36 +104,40 @@ class FileUpload $dir_output = $conf->$element->dir_output; } - dol_include_once('/'.$pathname.'/class/'.$filename.'.class.php'); + // If pathname and filename are null then we can still upload files + // IF we have specified upload_dir on $this->options + if ($pathname !== null && $filename !== null) { + dol_include_once('/'.$pathname.'/class/'.$filename.'.class.php'); - $classname = ucfirst($filename); + $classname = ucfirst($filename); - if ($element == 'order_supplier') { - $classname = 'CommandeFournisseur'; - } elseif ($element == 'invoice_supplier') { - $classname = 'FactureFournisseur'; - } - - $object = new $classname($db); - - $object->fetch($fk_element); - if (!empty($parentForeignKey)) { - dol_include_once('/'.$parentElement.'/class/'.$parentObject.'.class.php'); - $parent = new $parentClass($db); - $parent->fetch($object->$parentForeignKey); - if (!empty($parent->socid)) { - $parent->fetch_thirdparty(); + if ($element == 'order_supplier') { + $classname = 'CommandeFournisseur'; + } elseif ($element == 'invoice_supplier') { + $classname = 'FactureFournisseur'; } - $object->$parentObject = clone $parent; - } else { - $object->fetch_thirdparty(); - } - $object_ref = dol_sanitizeFileName($object->ref); - if ($element == 'invoice_supplier') { - $object_ref = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$object_ref; - } elseif ($element == 'project_task') { - $object_ref = $object->project->ref.'/'.$object_ref; + $object = new $classname($db); + + $object->fetch($fk_element); + if (!empty($parentForeignKey)) { + dol_include_once('/'.$parentElement.'/class/'.$parentObject.'.class.php'); + $parent = new $parentClass($db); + $parent->fetch($object->$parentForeignKey); + if (!empty($parent->socid)) { + $parent->fetch_thirdparty(); + } + $object->$parentObject = clone $parent; + } else { + $object->fetch_thirdparty(); + } + + $object_ref = dol_sanitizeFileName($object->ref); + if ($element == 'invoice_supplier') { + $object_ref = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$object_ref; + } elseif ($element == 'project_task') { + $object_ref = $object->project->ref.'/'.$object_ref; + } } $this->options = array( @@ -195,6 +199,21 @@ class FileUpload if ($options) { $this->options = array_replace_recursive($this->options, $options); } + + // At this point we should have a valid upload_dir in options + //if ($pathname === null && $filename === null) { // OR or AND??? + if ($pathname === null || $filename === null) { + if (!key_exists("upload_dir", $this->options)) { + setEventMessage('If $fk_element = null or $element = null you must specify upload_dir on $options', 'errors'); + throw new Exception('If $fk_element = null or $element = null you must specify upload_dir on $options'); + } elseif (is_dir($this->options['upload_dir'])) { + setEventMessage('The directory '$this->options['upload_dir'].' doesn\'t exists', 'errors'); + throw new Exception('The directory '$this->options['upload_dir'].' doesn\'t exists'); + } elseif (is_writable($this->options['upload_dir'])) { + setEventMessage('The directory '$this->options['upload_dir'].' is not writable', 'errors'); + throw new Exception('The directory '$this->options['upload_dir'].' is not writable'); + } + } } /** From 2a706411cf34367902349b68344dfe37f80ba07f Mon Sep 17 00:00:00 2001 From: David Pareja Rodriguez Date: Wed, 1 Mar 2023 08:44:06 +0100 Subject: [PATCH 12/84] fix wrong string concatenation --- htdocs/core/class/fileupload.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index 7eb76032183..feb35e660d7 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -207,11 +207,11 @@ class FileUpload setEventMessage('If $fk_element = null or $element = null you must specify upload_dir on $options', 'errors'); throw new Exception('If $fk_element = null or $element = null you must specify upload_dir on $options'); } elseif (is_dir($this->options['upload_dir'])) { - setEventMessage('The directory '$this->options['upload_dir'].' doesn\'t exists', 'errors'); - throw new Exception('The directory '$this->options['upload_dir'].' doesn\'t exists'); + setEventMessage('The directory '.$this->options['upload_dir'].' doesn\'t exists', 'errors'); + throw new Exception('The directory '.$this->options['upload_dir'].' doesn\'t exists'); } elseif (is_writable($this->options['upload_dir'])) { - setEventMessage('The directory '$this->options['upload_dir'].' is not writable', 'errors'); - throw new Exception('The directory '$this->options['upload_dir'].' is not writable'); + setEventMessage('The directory '.$this->options['upload_dir'].' is not writable', 'errors'); + throw new Exception('The directory '.$this->options['upload_dir'].' is not writable'); } } } From 0e9451e10081a012e192ad5572ff79fc3fc28595 Mon Sep 17 00:00:00 2001 From: David Pareja Rodriguez Date: Wed, 1 Mar 2023 10:11:55 +0100 Subject: [PATCH 13/84] fix should check the negative --- htdocs/core/class/fileupload.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index feb35e660d7..aff9fd4d412 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -206,10 +206,10 @@ class FileUpload if (!key_exists("upload_dir", $this->options)) { setEventMessage('If $fk_element = null or $element = null you must specify upload_dir on $options', 'errors'); throw new Exception('If $fk_element = null or $element = null you must specify upload_dir on $options'); - } elseif (is_dir($this->options['upload_dir'])) { + } elseif (!is_dir($this->options['upload_dir'])) { setEventMessage('The directory '.$this->options['upload_dir'].' doesn\'t exists', 'errors'); throw new Exception('The directory '.$this->options['upload_dir'].' doesn\'t exists'); - } elseif (is_writable($this->options['upload_dir'])) { + } elseif (!is_writable($this->options['upload_dir'])) { setEventMessage('The directory '.$this->options['upload_dir'].' is not writable', 'errors'); throw new Exception('The directory '.$this->options['upload_dir'].' is not writable'); } From 919d87a49ef1b3471e3207a59a1385d4deeb3f81 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 3 Mar 2023 10:22:18 +0100 Subject: [PATCH 14/84] fix: remove invoice line id and invoice on time spend when delete line --- htdocs/compta/facture/class/facture.class.php | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b5332b033ef..2a3f8b4a17f 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4230,19 +4230,6 @@ class Facture extends CommonInvoice $this->db->begin(); - // Free discount linked to invoice line - $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql .= ' SET fk_facture_line = NULL'; - $sql .= ' WHERE fk_facture_line = '.((int) $rowid); - - dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); - $result = $this->db->query($sql); - if (!$result) { - $this->error = $this->db->error(); - $this->db->rollback(); - return -1; - } - // Memorize previous line for triggers $staticline = clone $line; $line->oldline = $staticline; @@ -6441,13 +6428,38 @@ class FactureLigne extends CommonInvoiceLine return -1; } - $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".((int) $this->rowid); + // Free discount linked to invoice line + $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; + $sql .= ' SET fk_facture_line = NULL'; + $sql .= ' WHERE fk_facture_line = '.((int) $this->id); + + dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); + $result = $this->db->query($sql); + if (!$result) { + $this->error = $this->db->error(); + $this->errors[] = $this->error; + $this->db->rollback(); + return -1; + } + + $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time'; + $sql .= ' SET invoice_id = NULL, invoice_line_id = NULL'; + $sql .= ' WHERE invoice_line_id = '.((int) $this->id); + if (!$this->db->query($sql)) { + $this->error = $this->db->error()." sql=".$sql; + $this->errors[] = $this->error; + $this->db->rollback(); + return -1; + } + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".((int) $this->id); if ($this->db->query($sql)) { $this->db->commit(); return 1; } else { $this->error = $this->db->error()." sql=".$sql; + $this->errors[] = $this->error; $this->db->rollback(); return -1; } From 942467a90037a48d0ae4d8e1052a26dc38d8fb4a Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 3 Mar 2023 16:27:28 +0100 Subject: [PATCH 15/84] NEW : table llx_element_time to store time spent on several elements (mo, ticket...) --- .../install/mysql/tables/llx_element_time.sql | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_element_time.sql diff --git a/htdocs/install/mysql/tables/llx_element_time.sql b/htdocs/install/mysql/tables/llx_element_time.sql new file mode 100644 index 00000000000..cf346a48ec0 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_element_time.sql @@ -0,0 +1,38 @@ +-- Copyright (C) 2023 Gauthier VERDOL +-- +-- 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/. + + +CREATE TABLE llx_element_time( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + fk_element integer NOT NULL, + elementtype varchar(32) NOT NULL, + element_date date, + element_datehour datetime, + element_date_withhour integer, + element_duration double, + fk_product integer, + fk_user integer, + thm double(24,8), + invoice_id integer DEFAULT NULL, + invoice_line_id integer DEFAULT NULL, + intervention_id integer DEFAULT NULL, + intervention_line_id integer DEFAULT NULL, + import_key varchar(14), + datec datetime, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + note text + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; From e480c3f440f544293b7191a0c8a6c70d9b3c77ab Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 6 Mar 2023 09:31:39 +0100 Subject: [PATCH 16/84] FIX missing drop foreign key before modify field --- htdocs/install/mysql/migration/16.0.0-17.0.0.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql index 4ec2e7228b2..a1e24fa6d2c 100644 --- a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql +++ b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql @@ -33,8 +33,9 @@ -- Missing in v16 or lower - +ALTER TABLE llx_accounting_account DROP FOREIGN KEY fk_accounting_account_fk_pcg_version; ALTER TABLE llx_accounting_system MODIFY COLUMN pcg_version varchar(32) NOT NULL; +ALTER TABLE llx_accounting_account ADD CONSTRAINT fk_accounting_account_fk_pcg_version FOREIGN KEY (fk_pcg_version) REFERENCES llx_accounting_system (pcg_version); ALTER TABLE llx_c_action_trigger MODIFY elementtype VARCHAR(64); From 551a8336961616fc1e612a7fa9c3770f1e8d96b1 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 6 Mar 2023 11:19:39 +0100 Subject: [PATCH 17/84] NEW : migration script + delete old table + rename fields and indexes --- .../install/mysql/migration/17.0.0-18.0.0.sql | 17 +++++++++ ..._time.key.sql => llx_element_time.key.sql} | 7 ++-- .../mysql/tables/llx_projet_task_time.sql | 38 ------------------- 3 files changed, 21 insertions(+), 41 deletions(-) rename htdocs/install/mysql/tables/{llx_projet_task_time.key.sql => llx_element_time.key.sql} (73%) delete mode 100644 htdocs/install/mysql/tables/llx_projet_task_time.sql diff --git a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql index 9c2643688dd..8b62b4f7b4d 100644 --- a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql +++ b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql @@ -87,3 +87,20 @@ ALTER TABLE llx_ecm_files ADD COLUMN share_pass varchar(32) after share; ALTER TABLE llx_prelevement_demande ADD COLUMN type varchar(12) DEFAULT ''; UPDATE llx_prelevement_demande SET type = 'ban' WHERE ext_payment_id IS NULL AND type = ''; + +-- Element time +ALTER TABLE llx_projet_task_time RENAME TO llx_element_time; +ALTER TABLE llx_element_time CHANGE COLUMN fk_task fk_element integer NOT NULL; +ALTER TABLE llx_element_time CHANGE COLUMN task_date element_date date; +ALTER TABLE llx_element_time CHANGE COLUMN task_datehour element_datehour datetime; +ALTER TABLE llx_element_time CHANGE COLUMN task_date_withhour element_date_withhour integer; +ALTER TABLE llx_element_time CHANGE COLUMN task_duration element_duration double; +ALTER TABLE llx_element_time ADD COLUMN elementtype varchar(32) NOT NULL DEFAULT 'task' AFTER fk_element; + +DROP INDEX idx_projet_task_time_task on llx_element_time; +DROP INDEX idx_projet_task_time_date on llx_element_time; +DROP INDEX idx_projet_task_time_datehour on llx_element_time; + +ALTER TABLE llx_element_time ADD INDEX idx_element_time_task (fk_element); +ALTER TABLE llx_element_time ADD INDEX idx_element_time_date (element_date); +ALTER TABLE llx_element_time ADD INDEX idx_element_time_datehour (element_datehour); diff --git a/htdocs/install/mysql/tables/llx_projet_task_time.key.sql b/htdocs/install/mysql/tables/llx_element_time.key.sql similarity index 73% rename from htdocs/install/mysql/tables/llx_projet_task_time.key.sql rename to htdocs/install/mysql/tables/llx_element_time.key.sql index 5acb17bb712..5de06450e75 100644 --- a/htdocs/install/mysql/tables/llx_projet_task_time.key.sql +++ b/htdocs/install/mysql/tables/llx_element_time.key.sql @@ -1,5 +1,6 @@ -- =========================================================================== -- Copyright (C) 2014 Laurent Destailleur +-- Copyright (C) 2023 Gauthier VERDOL -- -- 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 @@ -16,7 +17,7 @@ -- -- =========================================================================== -ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_task (fk_task); -ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_date (task_date); -ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_datehour (task_datehour); +ALTER TABLE llx_element_time ADD INDEX idx_element_time_task (fk_element); +ALTER TABLE llx_element_time ADD INDEX idx_element_time_date (element_date); +ALTER TABLE llx_element_time ADD INDEX idx_element_time_datehour (element_datehour); diff --git a/htdocs/install/mysql/tables/llx_projet_task_time.sql b/htdocs/install/mysql/tables/llx_projet_task_time.sql deleted file mode 100644 index e91e50b5721..00000000000 --- a/htdocs/install/mysql/tables/llx_projet_task_time.sql +++ /dev/null @@ -1,38 +0,0 @@ --- =========================================================================== --- Copyright (C) 2005 Rodolphe Quiedeville --- --- 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 . --- --- =========================================================================== - -create table llx_projet_task_time -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_task integer NOT NULL, - task_date date, -- only the day - task_datehour datetime, -- day + hour - task_date_withhour integer DEFAULT 0, -- 0 by default, 1 if date was entered with start hour - task_duration double, - fk_product integer NULL, - fk_user integer, - thm double(24,8), - invoice_id integer DEFAULT NULL, -- If we need to invoice each line of timespent, we can save invoice id here - invoice_line_id integer DEFAULT NULL, -- If we need to invoice each line of timespent, we can save invoice line id here - intervention_id integer DEFAULT NULL, -- If we need to have an intervention line for each line of timespent, we can save intervention id here - intervention_line_id integer DEFAULT NULL, -- If we need to have an intervention line of timespent line, we can save intervention line id here - import_key varchar(14), -- Import key - datec datetime, -- date creation time - tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- last modification date - note text -- A comment -)ENGINE=innodb; From 8fc1805f6543db6f8cbb5a365193b59025d5bdc0 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Mon, 6 Mar 2023 13:51:53 +0100 Subject: [PATCH 18/84] NEW adapt category and product pictures sizes on takepos --- htdocs/takepos/css/pos.css.php | 8 ++++++++ htdocs/takepos/index.php | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php index 5a773fc3347..769c343f1fe 100644 --- a/htdocs/takepos/css/pos.css.php +++ b/htdocs/takepos/css/pos.css.php @@ -248,6 +248,9 @@ div.wrapper{ text-align: center; box-sizing: border-box; background-color:#fff; + display: flex; + align-items: center; + justify-content: center; } div.wrapper2{ @@ -262,10 +265,14 @@ div.wrapper2{ text-align: center; box-sizing: border-box; background-color:#fff; + display: flex; + align-items: center; + justify-content: center; } img.imgwrapper { max-width: 100%; + max-height: 100%; } button:active{ @@ -927,6 +934,7 @@ div#moreinfo, div#infowarehouse { display: inline-flex; align-items: center; padding: 10px; + justify-content: normal; } .div5 .wrapper2.divempty { diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index fb3049715cf..bbbf9e0cd33 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -1388,7 +1388,7 @@ if (!empty($conf->global->TAKEPOS_WEIGHING_SCALE)) { echo ''; } else { if (!getDolGlobalString('TAKEPOS_HIDE_CATEGORY_IMAGES')) { - echo ''; + echo ''; } } ?> @@ -1433,7 +1433,7 @@ if (!empty($conf->global->TAKEPOS_WEIGHING_SCALE)) { echo ''; } else { print '
'; - print ''; + print ''; } } ?> From e5c9e14c0f1263ca12b638c73c4bc1415c15cab4 Mon Sep 17 00:00:00 2001 From: kkhelifa Date: Mon, 6 Mar 2023 14:57:07 +0100 Subject: [PATCH 19/84] NEW - Add origin info when create a product batch when created from a movement stock --- htdocs/product/stock/class/mouvementstock.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 62526483542..f8c075b228c 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -368,6 +368,8 @@ class MouvementStock extends CommonObject } } else { // If not found, we add record $productlot = new Productlot($this->db); + $productlot->origin = !empty($this->origin) ? (empty($this->origin->origin_type) ? $this->origin->element : $this->origin->origin_type) : ''; + $productlot->origin_id = !empty($this->origin) ? $this->origin->id : 0; $productlot->entity = $conf->entity; $productlot->fk_product = $fk_product; $productlot->batch = $batch; From 8fd991d51d9731bdff5ae92a3fe9e6508615564d Mon Sep 17 00:00:00 2001 From: Maximilien Rozniecki Date: Mon, 6 Mar 2023 15:41:58 +0100 Subject: [PATCH 20/84] add extrafields_view.tpl.php inside public_ticket_view --- htdocs/public/ticket/view.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php index 1bfc235ff65..67b582c0afd 100644 --- a/htdocs/public/ticket/view.php +++ b/htdocs/public/ticket/view.php @@ -218,6 +218,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; $form = new Form($db); $formticket = new FormTicket($db); +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('ticketpublicview', 'globalcard')); + if (!$conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) { print '
'.$langs->trans('TicketPublicInterfaceForbidden').'
'; $db->close(); @@ -332,6 +335,9 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a print ($object->dao->progress > 0 ? dol_escape_htmltag($object->dao->progress) : '0').'%'; print ''; + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + print ''; print ''; From 61fd3d3c25ee00900280af826ee4543e890fb565 Mon Sep 17 00:00:00 2001 From: Quentin-Seekness <72733832+Quentin-Seekness@users.noreply.github.com> Date: Tue, 7 Mar 2023 10:10:19 +0100 Subject: [PATCH 21/84] Search all on projects Search all using client code and thirdparty name alias --- htdocs/projet/list.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 1f203113b3a..d0075b57ed7 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -192,6 +192,8 @@ foreach ($object->fields as $key => $val) { // Add name object fields to "search in all" $fieldstosearchall['s.nom'] = "ThirdPartyName"; +$fieldstosearchall['s.name_alias'] = "AliasNameShort"; +$fieldstosearchall['s.code_client'] = "CustomerCode"; // Definition of array of fields for columns $arrayfields = array(); From b197607fb724b18499ccd4f29a098a456731e946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 7 Mar 2023 10:25:27 +0100 Subject: [PATCH 22/84] Fix translation --- htdocs/core/modules/modFacture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 23b9ea85639..0929cc94000 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -240,7 +240,7 @@ class modFacture extends DolibarrModules 'f.ref' => 'InvoiceRef*', 'f.ref_ext' => 'ExternalRef', 'f.ref_int' => 'ExternalRef', - 'f.ref_client' => 'CustomerRef', + 'f.ref_client' => 'RefCustomer', 'f.type' => 'Type*', 'f.fk_soc' => 'Customer*', 'f.datec' => 'InvoiceDateCreation', From 2863481629e1c75d76e029b2852e508ed7d34ba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 7 Mar 2023 10:26:21 +0100 Subject: [PATCH 23/84] Update list.php --- htdocs/comm/propal/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 5a9f91ea71a..0b2d382960b 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -187,7 +187,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // List of fields to search into when doing a "search in all" $fieldstosearchall = array( 'p.ref'=>'Ref', - 'p.ref_client'=>'CustomerRef', + 'p.ref_client'=>'RefCustomer', 'pd.description'=>'Description', 's.nom'=>"ThirdParty", 's.name_alias'=>"AliasNameShort", From f4e1ce4c73c8e503d5ffd54ddf422962d7073fce Mon Sep 17 00:00:00 2001 From: kkhelifa Date: Tue, 7 Mar 2023 14:58:55 +0100 Subject: [PATCH 24/84] NEW - Add a trigger when create a shipping line batch and fix propagate missing errors --- htdocs/expedition/class/expedition.class.php | 3 ++- .../class/expeditionlinebatch.class.php | 20 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 417ac943493..7b1c8ae6df7 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -530,6 +530,7 @@ class Expedition extends CommonObject foreach ($tab as $detbatch) { if ($detbatch->entrepot_id == $stockLocation) { if (!($detbatch->create($line_id) > 0)) { // Create an ExpeditionLineBatch + $this->errors = $detbatch->errors; $error++; } } @@ -3020,7 +3021,7 @@ class ExpeditionLigne extends CommonObjectLine $shipmentLot->qty = $this->detail_batch->qty; $shipmentLot->fk_origin_stock = $batch_id; if ($shipmentLot->create($this->id) < 0) { - $this->errors[] = $shipmentLot->errors; + $this->errors = $shipmentLot->errors; $error++; } } diff --git a/htdocs/expedition/class/expeditionlinebatch.class.php b/htdocs/expedition/class/expeditionlinebatch.class.php index ab1d9123830..b010564768f 100644 --- a/htdocs/expedition/class/expeditionlinebatch.class.php +++ b/htdocs/expedition/class/expeditionlinebatch.class.php @@ -103,11 +103,16 @@ class ExpeditionLineBatch extends CommonObject * Create an expeditiondet_batch DB record link to an expedtiondet record * * @param int $id_line_expdet rowid of expedtiondet record + * @param User $f_user User that create + * @param int $notrigger 1 = disable triggers * @return int <0 if KO, Id of record (>0) if OK */ - public function create($id_line_expdet) + public function create($id_line_expdet, $f_user = null, $notrigger = 0) { + global $user; + $error = 0; + if (!is_object($f_user)) $f_user = $user; $id_line_expdet = (int) $id_line_expdet; @@ -137,13 +142,24 @@ class ExpeditionLineBatch extends CommonObject $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $this->fk_expeditiondet = $id_line_expdet; + } + + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('EXPEDITIONLINEBATCH_CREATE', $f_user); + if ($result < 0) { + $error++; + } + // End call triggers + } + + if (!$error) { return $this->id; } else { foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } - $this->db->rollback(); return -1 * $error; } } From 78842f56a3be7f4e63e426665edd85dd135f1b97 Mon Sep 17 00:00:00 2001 From: GregM Date: Tue, 7 Mar 2023 15:27:37 +0100 Subject: [PATCH 25/84] fix invalid argument for foreach --- htdocs/core/class/commonobject.class.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5f0741b26d4..cb3af5db5e3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6090,13 +6090,15 @@ abstract class CommonObject // If field is a computed field, value must become result of compute (regardless of whether a row exists // in the element's extrafields table) - foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { - if (!empty($extrafields->attributes[$this->table_element]) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) { - //var_dump($conf->disable_compute); - if (empty($conf->disable_compute)) { - global $objectoffield; // We set a global variable to $objectoffield so - $objectoffield = $this; // we can use it inside computed formula - $this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, ''); + if (is_array($extrafields->attributes[$this->table_element]['label'])){ + foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { + if (!empty($extrafields->attributes[$this->table_element]) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) { + //var_dump($conf->disable_compute); + if (empty($conf->disable_compute)) { + global $objectoffield; // We set a global variable to $objectoffield so + $objectoffield = $this; // we can use it inside computed formula + $this->array_options['options_' . $key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, ''); + } } } } From 7f10ef5215fc4c784a61f819ac3702c85b118992 Mon Sep 17 00:00:00 2001 From: kkhelifa Date: Tue, 7 Mar 2023 17:33:59 +0100 Subject: [PATCH 26/84] NEW - Provide the oldcopy value when calling setValueFrom() function with a trigger key --- htdocs/core/class/commonobject.class.php | 35 +++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e3c3dff2b7c..097530c6aa5 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2089,10 +2089,6 @@ abstract class CommonObject $id_field = 'rowid'; } - $error = 0; - - $this->db->begin(); - // Special case if ($table == 'product' && $field == 'note_private') { $field = 'note'; @@ -2101,6 +2097,32 @@ abstract class CommonObject $fk_user_field = 'fk_user_mod'; } + if ($trigkey) { + $oldvalue = null; + + $sql = "SELECT " . $field; + $sql .= " FROM " . MAIN_DB_PREFIX . $table; + $sql .= " WHERE " . $id_field . " = " . ((int)$id); + + $resql = $this->db->query($sql); + if ($resql) { + if ($obj = $this->db->fetch_object($resql)) { + if ($format == 'date') { + $oldvalue = $this->db->jdate($obj->$field); + } else { + $oldvalue = $obj->$field; + } + } + } else { + $this->error = $this->db->lasterror(); + return -1; + } + } + + $error = 0; + + $this->db->begin(); + $sql = "UPDATE ".$this->db->prefix().$table." SET "; if ($format == 'text') { @@ -2133,6 +2155,11 @@ abstract class CommonObject } else { $result = $this->fetchCommon($id); } + $this->oldcopy = clone $this; + if (property_exists($this->oldcopy, $field)) { + $this->oldcopy->$field = $oldvalue; + } + if ($result >= 0) { $result = $this->call_trigger($trigkey, (!empty($fuser) && is_object($fuser)) ? $fuser : $user); // This may set this->errors } From 4291560577cc393a11243362c5a0c75d7b370b15 Mon Sep 17 00:00:00 2001 From: jpb Date: Tue, 7 Mar 2023 17:36:40 +0100 Subject: [PATCH 27/84] fix search_project_user --- htdocs/projet/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 15fc35f9e84..f5c25f6a516 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -839,7 +839,7 @@ if ($search_project_user > 0) { $param .= '&search_project_user='.urlencode($search_project_user); } if ($search_project_contact != '') { - $param .= '&search_project_user='.urlencode($search_project_contact); + $param .= '&search_project_contact='.urlencode($search_project_contact); } if ($search_sale > 0) { $param .= '&search_sale='.urlencode($search_sale); From 30aa377528c6899a56715fd2003235c74007128a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 8 Mar 2023 08:50:19 +0100 Subject: [PATCH 28/84] use isModEnabled --- htdocs/product/card.php | 8 ++++---- htdocs/variants/combinations.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 241aec60d8e..b42384e934d 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -207,7 +207,7 @@ if ($cancel) { $action = ''; } -$createbarcode = empty($conf->barcode->enabled) ? 0 : 1; +$createbarcode = isModEnabled('barcode'); if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->creer_advance)) { $createbarcode = 0; } @@ -1419,7 +1419,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } } - $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; + $showbarcode = isModEnabled('barcode'); if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { $showbarcode = 0; } @@ -1984,7 +1984,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } // Barcode - $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; + $showbarcode = isModEnabled('barcode'); if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { $showbarcode = 0; } @@ -2312,7 +2312,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } else { // Fiche en mode visu - $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; + $showbarcode = isModEnabled('barcode'); if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { $showbarcode = 0; } diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 4c2b77ce766..7424f7474c0 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -377,7 +377,7 @@ llxHeader("", $title); if (!empty($id) || !empty($ref)) { - $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; + $showbarcode = isModEnabled('barcode'); if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { $showbarcode = 0; } From 3fbb744d55fc1c10935f6e513f2ee957d39ab503 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Wed, 8 Mar 2023 10:21:19 +0100 Subject: [PATCH 29/84] FIX: holiday counter massaction: ErrorBadValueForParamNotAString and PHP 8 warning when no approval user right --- htdocs/holiday/define_holiday.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 2d47467319d..c19defa8ba3 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -363,6 +363,7 @@ if (count($typeleaves) == 0) { print_liste_field_titre((empty($user->rights->holiday->define_holiday) ? '' : 'Note'), $_SERVER["PHP_SELF"]); print_liste_field_titre(''); + $selectedfields = ''; if ($massactionbutton) { $selectedfields = $form->showCheckAddButtons('checkforselect', 1); } From 49d79a4c7c737e0d05163a4ee6b5f6bddfb74d80 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Wed, 8 Mar 2023 10:48:38 +0100 Subject: [PATCH 30/84] FIX: installation superadmin creation: PHP 8 warning --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index d1d0d7ed7d0..5a610090be2 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -257,7 +257,7 @@ function dol_verifyHash($chain, $hash, $type = '0') global $conf; if ($type == '0' && !empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_verify')) { - if ($hash[0] == '$') { + if (! empty($hash[0]) && $hash[0] == '$') { return password_verify($chain, $hash); } elseif (strlen($hash) == 32) { return dol_verifyHash($chain, $hash, '3'); // md5 From 9769fe54a20ddaeb40bd24975beb58b0a56674ac Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 8 Mar 2023 11:00:58 +0100 Subject: [PATCH 31/84] NEW : element time integration code --- htdocs/compta/facture/class/facture.class.php | 4 +- htdocs/core/boxes/box_validated_projects.php | 3 +- htdocs/core/class/commonobject.class.php | 5 +- htdocs/core/class/timespent.class.php | 1134 +++++++++++++++++ htdocs/core/lib/project.lib.php | 10 +- htdocs/core/modules/modProjet.class.php | 11 +- .../doc/doc_generic_project_odt.modules.php | 12 +- .../task/doc/doc_generic_task_odt.modules.php | 12 +- htdocs/install/mysql/migration/repair.sql | 10 +- htdocs/install/pgsql/functions/functions.sql | 3 +- htdocs/install/repair.php | 5 +- htdocs/install/upgrade2.php | 31 +- htdocs/projet/activity/index.php | 41 +- htdocs/projet/class/project.class.php | 57 +- htdocs/projet/class/task.class.php | 228 ++-- htdocs/projet/element.php | 5 +- htdocs/projet/tasks/list.php | 5 +- htdocs/projet/tasks/time.php | 151 +-- 18 files changed, 1436 insertions(+), 291 deletions(-) create mode 100755 htdocs/core/class/timespent.class.php diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ed4d8bfd498..07456b3b579 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -18,7 +18,7 @@ * Copyright (C) 2018-2022 Alexandre Spangaro * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2022 Sylvain Legrand - * Copyright (C) 2022 Gauthier VERDOL + * Copyright (C) 2023 Gauthier VERDOL * * 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 @@ -2690,7 +2690,7 @@ class Facture extends CommonInvoice return -5; } - $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time'; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'element_time'; $sql .= ' SET invoice_id = NULL, invoice_line_id = NULL'; $sql .= ' WHERE invoice_id = '.((int) $rowid); diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index bab64d5a000..f071871d0d4 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -4,6 +4,7 @@ * Copyright (C) 2015 Frederic France * Copyright (C) 2016 Juan José Menent * Copyright (C) 2020 Pierre Ardoin + * Copyright (C) 2023 Gauthier VERDOL * * 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 @@ -119,7 +120,7 @@ class box_validated_projects extends ModeleBoxes if ($projectsListId) { $sql .= ' AND p.rowid IN ('.$this->db->sanitize($projectsListId).')'; // Only projects that are allowed } - $sql .= " AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_user = ".((int) $user->id).")"; + $sql .= " AND t.rowid NOT IN (SELECT fk_element FROM ".MAIN_DB_PREFIX."element_time WHERE elementtype = 'task' AND fk_user = ".((int) $user->id).")"; $sql .= " GROUP BY p.rowid, p.ref, p.fk_soc, p.dateo"; $sql .= " ORDER BY p.dateo ASC"; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e3c3dff2b7c..eabcfda8491 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -14,7 +14,7 @@ * Copyright (C) 2017 Rui Strecht * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2018 Josep Lluís Amador - * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2023 Gauthier VERDOL * Copyright (C) 2021 Grégory Blémand * Copyright (C) 2023 Lenin Rivas * @@ -4637,6 +4637,9 @@ abstract class CommonObject if (!empty($element['parent']) && !empty($element['parentkey'])) { $sql.= " AND c.".$element['parentkey']." = p.rowid"; } + if (!empty($element['parent']) && !empty($element['parenttypefield']) && !empty($element['parenttypevalue'])) { + $sql.= " AND c.".$element['parenttypefield']." = '".$element['parenttypevalue']."'"; + } if (!empty($entity)) { if (!empty($element['parent']) && !empty($element['parentkey'])) { $sql.= " AND p.entity = ".((int) $entity); diff --git a/htdocs/core/class/timespent.class.php b/htdocs/core/class/timespent.class.php new file mode 100755 index 00000000000..f6ae2b45c71 --- /dev/null +++ b/htdocs/core/class/timespent.class.php @@ -0,0 +1,1134 @@ + + * Copyright (C) 2023 Frédéric France + * Copyright (C) 2023 Gauthier VERDOL + * + * 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 . + */ + +/** + * \file class/timespent.class.php + * \ingroup timespent + * \brief This file is a CRUD class file for TimeSpent (Create/Read/Update/Delete) + */ + +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + +/** + * Class for TimeSpent + */ +class TimeSpent extends CommonObject +{ + /** + * @var string ID of module. + */ + public $module = 'timespent'; + + /** + * @var string ID to identify managed object. + */ + public $element = 'timespent'; + + /** + * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management. + */ + public $table_element = 'element_time'; + + /** + * @var int Does this object support multicompany module ? + * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table + */ + public $ismultientitymanaged = 0; + + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 0; + + /** + * @var string String with name of icon for timespent. Must be a 'fa-xxx' fontawesome code (or 'fa-xxx_fa_color_size') or 'timespent@timespent' if picto is file 'img/object_timespent.png'. + */ + public $picto = 'fa-file'; + + + const STATUS_DRAFT = 0; + const STATUS_VALIDATED = 1; + const STATUS_CANCELED = 9; + + + /** + * 'type' field format: + * 'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]', + * 'select' (list of values are in 'options'), + * 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]', + * 'chkbxlst:...', + * 'varchar(x)', + * 'text', 'text:none', 'html', + * 'double(24,8)', 'real', 'price', + * 'date', 'datetime', 'timestamp', 'duration', + * 'boolean', 'checkbox', 'radio', 'array', + * 'mail', 'phone', 'url', 'password', 'ip' + * Note: Filter must be a Dolibarr filter syntax string. Example: "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.status:!=:0) 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' or 'isModEnabled("multicurrency")' ...) + * '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) + * 'noteditable' says if field is not editable (1 or 0) + * 'alwayseditable' says if field can be modified also when status is not draft ('1' or '0') + * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 or 2 if field can be used for measure. Field type must be summable like integer or double(24,8). Use 1 in most cases, or 2 if you don't want to see the column total into list (for example for percentage) + * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200' + * 'help' and 'helplist' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. + * 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar' + * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1. + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * 'validate' is 1 if need to validate with $this->validateField() + * 'copytoclipboard' is 1 or 2 to allow to add a picto to copy value into clipboard (1=picto after label, 2=picto after value) + * + * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. + */ + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>17, 'notnull'=>0, 'visible'=>-2,), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'import_key', 'enabled'=>'1', 'position'=>15, 'notnull'=>0, 'visible'=>-1,), + 'fk_element' => array('type'=>'integer', 'label'=>'fk_element', 'enabled'=>'1', 'position'=>2, 'notnull'=>1, 'visible'=>-1,), + 'elementtype' => array('type'=>'varchar(32)', 'label'=>'elementtype', 'enabled'=>'1', 'position'=>3, 'notnull'=>1, 'visible'=>-1,), + 'element_date' => array('type'=>'date', 'label'=>'element_date', 'enabled'=>'1', 'position'=>4, 'notnull'=>0, 'visible'=>-1,), + 'element_datehour' => array('type'=>'datetime', 'label'=>'element_datehour', 'enabled'=>'1', 'position'=>5, 'notnull'=>0, 'visible'=>-1,), + 'element_date_withhour' => array('type'=>'integer', 'label'=>'element_date_withhour', 'enabled'=>'1', 'position'=>6, 'notnull'=>0, 'visible'=>-1,), + 'element_duration' => array('type'=>'double', 'label'=>'element_duration', 'enabled'=>'1', 'position'=>7, 'notnull'=>0, 'visible'=>-1,), + 'fk_product' => array('type'=>'integer', 'label'=>'fk_product', 'enabled'=>'1', 'position'=>8, 'notnull'=>0, 'visible'=>-1,), + 'fk_user' => array('type'=>'integer', 'label'=>'fk_user', 'enabled'=>'1', 'position'=>9, 'notnull'=>0, 'visible'=>-1,), + 'thm' => array('type'=>'double(24,8)', 'label'=>'thm', 'enabled'=>'1', 'position'=>10, 'notnull'=>0, 'visible'=>-1,), + 'invoice_id' => array('type'=>'integer', 'label'=>'invoice_id', 'enabled'=>'1', 'position'=>11, 'notnull'=>0, 'visible'=>-1, 'default'=>'NULL',), + 'invoice_line_id' => array('type'=>'integer', 'label'=>'invoice_line_id', 'enabled'=>'1', 'position'=>12, 'notnull'=>0, 'visible'=>-1, 'default'=>'NULL',), + 'intervention_id' => array('type'=>'integer', 'label'=>'intervention_id', 'enabled'=>'1', 'position'=>13, 'notnull'=>0, 'visible'=>-1, 'default'=>'NULL',), + 'intervention_line_id' => array('type'=>'integer', 'label'=>'intervention_line_id', 'enabled'=>'1', 'position'=>14, 'notnull'=>0, 'visible'=>-1, 'default'=>'NULL',), + 'datec' => array('type'=>'datetime', 'label'=>'datec', 'enabled'=>'1', 'position'=>16, 'notnull'=>0, 'visible'=>-1,), + 'note' => array('type'=>'text', 'label'=>'note', 'enabled'=>'1', 'position'=>18, 'notnull'=>0, 'visible'=>-1,), + ); + public $rowid; + public $tms; + public $import_key; + public $fk_element; + public $elementtype; + public $element_date; + public $element_datehour; + public $element_date_withhour; + public $element_duration; + public $fk_product; + public $fk_user; + public $thm; + public $invoice_id; + public $invoice_line_id; + public $intervention_id; + public $intervention_line_id; + public $datec; + public $note; + // END MODULEBUILDER PROPERTIES + + + // If this object has a subtable with lines + + // /** + // * @var string Name of subtable line + // */ + // public $table_element_line = 'timespent_timespentline'; + + // /** + // * @var string Field with ID of parent key if this object has a parent + // */ + // public $fk_element = 'fk_timespent'; + + // /** + // * @var string Name of subtable class that manage subtable lines + // */ + // public $class_element_line = 'TimeSpentline'; + + // /** + // * @var array List of child tables. To test if we can delete object. + // */ + // protected $childtables = array(); + + // /** + // * @var array List of child tables. To know object to delete on cascade. + // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will + // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object + // */ + // protected $childtablesoncascade = array('timespent_timespentdet'); + + // /** + // * @var TimeSpentLine[] Array of subtable lines + // */ + // public $lines = array(); + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid']) && !empty($this->fields['ref'])) { + $this->fields['rowid']['visible'] = 0; + } + if (!isModEnabled('multicompany') && isset($this->fields['entity'])) { + $this->fields['entity']['enabled'] = 0; + } + + // Example to show how to set values of fields definition dynamically + /*if ($user->rights->timespent->timespent->read) { + $this->fields['myfield']['visible'] = 1; + $this->fields['myfield']['noteditable'] = 0; + }*/ + + // Unset fields that are disabled + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { + unset($this->fields[$key]); + } + } + + // Translate some data of arrayofkeyval + if (is_object($langs)) { + foreach ($this->fields as $key => $val) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + foreach ($val['arrayofkeyval'] as $key2 => $val2) { + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); + } + } + } + } + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + $resultcreate = $this->createCommon($user, $notrigger); + + //$resultvalidate = $this->validate($user, $notrigger); + + return $resultcreate; + } + + /** + * Clone an object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $extrafields; + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $result = $object->fetchCommon($fromid); + if ($result > 0 && !empty($object->table_element_line)) { + $object->fetchLines(); + } + + // get lines so they will be clone + //foreach($this->lines as $line) + // $line->fetch_optionals(); + + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); + + // Clear fields + if (property_exists($object, 'ref')) { + $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; + } + if (property_exists($object, 'label')) { + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; + } + if (property_exists($object, 'status')) { + $object->status = self::STATUS_DRAFT; + } + if (property_exists($object, 'date_creation')) { + $object->date_creation = dol_now(); + } + if (property_exists($object, 'date_modification')) { + $object->date_modification = null; + } + // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) { + $extrafields->fetch_name_optionals_label($this->table_element); + foreach ($object->array_options as $key => $option) { + $shortkey = preg_replace('/options_/', '', $key); + if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) { + //var_dump($key); + //var_dump($clonedObj->array_options[$key]); exit; + unset($object->array_options[$key]); + } + } + } + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } + + if (!$error) { + // copy internal contacts + if ($this->copy_linked_contact($object, 'internal') < 0) { + $error++; + } + } + + if (!$error) { + // copy external contacts if same company + if (!empty($object->socid) && property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) { + if ($this->copy_linked_contact($object, 'external') < 0) { + $error++; + } + } + } + + unset($object->context['createfromclone']); + + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && !empty($this->table_element_line)) { + $this->fetchLines(); + } + return $result; + } + + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetchLines() + { + $this->lines = array(); + + $result = $this->fetchLinesCommon(); + return $result; + } + + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records = array(); + + $sql = "SELECT "; + $sql .= $this->getFieldList('t'); + $sql .= " FROM ".$this->db->prefix().$this->table_element." as t"; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { + $sql .= " WHERE t.entity IN (".getEntity($this->element).")"; + } else { + $sql .= " WHERE 1 = 1"; + } + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid') { + $sqlwhere[] = $key." = ".((int) $value); + } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { + $sqlwhere[] = $key." = '".$this->db->idate($value)."'"; + } elseif ($key == 'customsql') { + $sqlwhere[] = $value; + } elseif (strpos($value, '%') === false) { + $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")"; + } else { + $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")"; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= $this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < ($limit ? min($limit, $num) : $num)) { + $obj = $this->db->fetch_object($resql); + + $record = new self($this->db); + $record->setVarsFromFetchObj($obj); + + $records[$record->id] = $record; + + $i++; + } + $this->db->free($resql); + + return $records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); + } + + /** + * Delete a line of object in database + * + * @param User $user User that delete + * @param int $idline Id of line to delete + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int >0 if OK, <0 if KO + */ + public function deleteLine(User $user, $idline, $notrigger = false) + { + if ($this->status < 0) { + $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; + return -2; + } + + return $this->deleteLineCommon($user, $idline, $notrigger); + } + + + /** + * Validate object + * + * @param User $user User making status change + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int <=0 if OK, 0=Nothing done, >0 if KO + */ + public function validate($user, $notrigger = 0) + { + global $conf, $langs; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $error = 0; + + // Protection + if ($this->status == self::STATUS_VALIDATED) { + dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->timespent->timespent->write)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->timespent->timespent->timespent_advance->validate)))) + { + $this->error='NotEnoughPermissions'; + dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); + return -1; + }*/ + + $now = dol_now(); + + $this->db->begin(); + + // Define new ref + if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life + $num = $this->getNextNumRef(); + } else { + $num = $this->ref; + } + $this->newref = $num; + + if (!empty($num)) { + // Validate + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET ref = '".$this->db->escape($num)."',"; + $sql .= " status = ".self::STATUS_VALIDATED; + if (!empty($this->fields['date_validation'])) { + $sql .= ", date_validation = '".$this->db->idate($now)."'"; + } + if (!empty($this->fields['fk_user_valid'])) { + $sql .= ", fk_user_valid = ".((int) $user->id); + } + $sql .= " WHERE rowid = ".((int) $this->id); + + dol_syslog(get_class($this)."::validate()", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + dol_print_error($this->db); + $this->error = $this->db->lasterror(); + $error++; + } + + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('timespent_VALIDATE', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + } + + if (!$error) { + $this->oldref = $this->ref; + + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) { + // Now we rename also files into index + $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'timespent/".$this->db->escape($this->newref)."'"; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'timespent/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $resql = $this->db->query($sql); + if (!$resql) { + $error++; $this->error = $this->db->lasterror(); + } + + // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->timespent->dir_output.'/timespent/'.$oldref; + $dirdest = $conf->timespent->dir_output.'/timespent/'.$newref; + if (!$error && file_exists($dirsource)) { + dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); + + if (@rename($dirsource, $dirdest)) { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles = dol_dir_list($conf->timespent->dir_output.'/timespent/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach ($listoffiles as $fileentry) { + $dirsource = $fileentry['name']; + $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource = $fileentry['path'].'/'.$dirsource; + $dirdest = $fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } + } + } + } + } + + // Set new ref and current status + if (!$error) { + $this->ref = $num; + $this->status = self::STATUS_VALIDATED; + } + + if (!$error) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + return -1; + } + } + + + /** + * Set draft status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, >0 if OK + */ + public function setDraft($user, $notrigger = 0) + { + // Protection + if ($this->status <= self::STATUS_DRAFT) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->timespent->write)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->timespent->timespent_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'timespent_UNVALIDATE'); + } + + /** + * Set cancel status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function cancel($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_VALIDATED) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->timespent->write)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->timespent->timespent_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'timespent_CANCEL'); + } + + /** + * Set back to validated status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function reopen($user, $notrigger = 0) + { + // Protection + if ($this->status == self::STATUS_VALIDATED) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->timespent->write)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->timespent->timespent_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'timespent_REOPEN'); + } + + /** + * getTooltipContentArray + * @param array $params params to construct tooltip data + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs, $user; + + $datas = []; + + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + return ['optimize' => $langs->trans("ShowTimeSpent")]; + } + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("TimeSpent").''; + if (isset($this->status)) { + $datas['picto'] .= ' '.$this->getLibStatut(5); + } + $datas['ref'] .= '
'.$langs->trans('Ref').': '.$this->ref; + + return $datas; + } + + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $conf, $langs, $hookmanager; + + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } + + $result = ''; + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = " data-params='".json_encode($params)."'"; + // $label = $langs->trans('Loading'); + } + $label = implode($this->getTooltipContentArray($params)); + + $url = dol_buildpath('/timespent/timespent_card.php', 1).'?id='.$this->id; + + if ($option != 'nolink') { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($url && $add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } + } + + $linkclose = ''; + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $label = $langs->trans("ShowTimeSpent"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } + + if ($option == 'nolink' || empty($url)) { + $linkstart = ''; + if ($option == 'nolink' || empty($url)) { + $linkend = ''; + } else { + $linkend = ''; + } + + $result .= $linkstart; + + if (empty($this->showphoto_on_popup)) { + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + } + } else { + if ($withpicto) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + list($class, $module) = explode('@', $this->picto); + $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref); + $filearray = dol_dir_list($upload_dir, "files"); + $filename = $filearray[0]['name']; + if (!empty($filename)) { + $pospoint = strpos($filearray[0]['name'], '.'); + + $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); + if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + $result .= '
No photo
'; + } else { + $result .= '
No photo
'; + } + + $result .= ''; + } else { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + } + } + + if ($withpicto != 2) { + $result .= $this->ref; + } + + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action, $hookmanager; + $hookmanager->initHooks(array($this->element.'dao')); + $parameters = array('id'=>$this->id, 'getnomurl' => &$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } + + return $result; + } + + /** + * Return a thumb for kanban views + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $conf, $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'label')) { + $return .= '
'.$this->label.'
'; + } + if (property_exists($this, 'amount')) { + $return .= '
'; + $return .= ''.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + + return $return; + } + + /** + * Return the label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLabelStatus($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + /** + * Return the label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { + global $langs; + //$langs->load("timespent@timespent"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled'); + $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled'); + $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled'); + } + + $statusType = 'status'.$status; + //if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; + if ($status == self::STATUS_CANCELED) { + $statusType = 'status6'; + } + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); + } + + /** + * Load the info information in the object + * + * @param int $id Id of object + * @return void + */ + public function info($id) + { + $sql = "SELECT rowid,"; + $sql .= " date_creation as datec, tms as datem,"; + $sql .= " fk_user_creat, fk_user_modif"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + $sql .= " WHERE t.rowid = ".((int) $id); + + $result = $this->db->query($sql); + if ($result) { + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); + + $this->id = $obj->rowid; + + $this->user_creation_id = $obj->fk_user_creat; + $this->user_modification_id = $obj->fk_user_modif; + if (!empty($obj->fk_user_valid)) { + $this->user_validation_id = $obj->fk_user_valid; + } + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem); + if (!empty($obj->datev)) { + $this->date_validation = empty($obj->datev) ? '' : $this->db->jdate($obj->datev); + } + } + + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + // Set here init that are not commonf fields + // $this->property1 = ... + // $this->property2 = ... + + $this->initAsSpecimenCommon(); + } + + /** + * Create an array of lines + * + * @return array|int array of lines if OK, <0 if KO + */ + public function getLinesArray() + { + $this->lines = array(); + + $objectline = new TimeSpentLine($this->db); + $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_timespent = '.((int) $this->id))); + + if (is_numeric($result)) { + $this->error = $objectline->error; + $this->errors = $objectline->errors; + return $result; + } else { + $this->lines = $result; + return $this->lines; + } + } + + /** + * Returns the reference to the following non used object depending on the active numbering module. + * + * @return string Object free reference + */ + public function getNextNumRef() + { + global $langs, $conf; + $langs->load("timespent@timespent"); + + if (empty($conf->global->TIMESPENT_timespent_ADDON)) { + $conf->global->TIMESPENT_timespent_ADDON = 'mod_timespent_standard'; + } + + if (!empty($conf->global->TIMESPENT_timespent_ADDON)) { + $mybool = false; + + $file = $conf->global->TIMESPENT_timespent_ADDON.".php"; + $classname = $conf->global->TIMESPENT_timespent_ADDON; + + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $dir = dol_buildpath($reldir."core/modules/timespent/"); + + // Load file with numbering class (if found) + $mybool |= @include_once $dir.$file; + } + + if ($mybool === false) { + dol_print_error('', "Failed to include file ".$file); + return ''; + } + + if (class_exists($classname)) { + $obj = new $classname(); + $numref = $obj->getNextValue($this); + + if ($numref != '' && $numref != '-1') { + return $numref; + } else { + $this->error = $obj->error; + //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); + return ""; + } + } else { + print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname; + return ""; + } + } else { + print $langs->trans("ErrorNumberingModuleNotSetup", $this->element); + return ""; + } + } + + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force template to use ('' to not force) + * @param Translate $outputlangs objet lang a utiliser pour traduction + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @param null|array $moreparams Array to provide more information + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) + { + global $conf, $langs; + + $result = 0; + $includedocgeneration = 0; + + $langs->load("timespent@timespent"); + + if (!dol_strlen($modele)) { + $modele = 'standard_timespent'; + + if (!empty($this->model_pdf)) { + $modele = $this->model_pdf; + } elseif (!empty($conf->global->timespent_ADDON_PDF)) { + $modele = $conf->global->timespent_ADDON_PDF; + } + } + + $modelpath = "core/modules/timespent/doc/"; + + if ($includedocgeneration && !empty($modele)) { + $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + } + + return $result; + } + + /** + * Action executed by scheduler + * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' + * Use public function doScheduledJob($param1, $param2, ...) to get parameters + * + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + */ + public function doScheduledJob() + { + //global $conf, $langs; + + //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; + + $error = 0; + $this->output = ''; + $this->error = ''; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $now = dol_now(); + + $this->db->begin(); + + // ... + + $this->db->commit(); + + return $error; + } +} diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 8aa8b6d93b7..71c0cd7c0c6 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -4,6 +4,7 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2022 Charlene Benke + * Copyright (C) 2023 Gauthier VERDOL * * 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 @@ -100,8 +101,9 @@ function project_prepare_head(Project $project, $moreparam = '') $sql = "SELECT t.rowid"; //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt"; - $sql .= " WHERE t.fk_task = pt.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_time as t, ".MAIN_DB_PREFIX."projet_task as pt"; + $sql .= " WHERE t.fk_element = pt.rowid"; + $sql .= " AND t.elementtype = 'task'"; $sql .= " AND pt.fk_projet =".((int) $project->id); $resql = $db->query($sql); if ($resql) { @@ -372,8 +374,8 @@ function task_prepare_head($object) $sql = "SELECT t.rowid"; //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; - $sql .= " WHERE t.fk_task = ".((int) $object->id); + $sql .= " FROM ".MAIN_DB_PREFIX."element_time as t"; + $sql .= " WHERE t.elementtype='task' AND t.fk_element = ".((int) $object->id); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 8bc8e03adb2..be6c641f852 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -5,7 +5,8 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Florian Henry - * Copyright (C) 2014 Charles-Fr BENKE + * Copyright (C) 2014 Charles-Fr BENKE + * Copyright (C) 2023 Gauthier VERDOL * * 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 @@ -230,7 +231,7 @@ class modProjet extends DolibarrModules 'p.usage_opportunity'=>'Boolean', 'p.usage_task'=>'Boolean', 'p.usage_bill_time'=>'Boolean', 'p.datec'=>"Date", 'p.dateo'=>"Date", 'p.datee'=>"Date", 'p.fk_statut'=>'Status', 'cls.code'=>"Text", 'p.opp_percent'=>'Numeric', 'p.opp_amount'=>'Numeric', 'p.description'=>"Text", 'p.entity'=>'Numeric', 'p.budget_amount'=>'Numeric', 'pt.rowid'=>'Numeric', 'pt.ref'=>'Text', 'pt.label'=>'Text', 'pt.dateo'=>"Date", 'pt.datee'=>"Date", 'pt.duration_effective'=>"Duree", 'pt.planned_workload'=>"Numeric", 'pt.progress'=>"Numeric", 'pt.description'=>"Text", - 'ptt.rowid'=>'Numeric', 'ptt.task_date'=>'Date', 'ptt.task_duration'=>"Duree", 'ptt.fk_user'=>"FormSelect:select_dolusers", 'ptt.note'=>"Text" + 'ptt.rowid'=>'Numeric', 'ptt.element_date'=>'Date', 'ptt.element_duration'=>"Duree", 'ptt.fk_user'=>"FormSelect:select_dolusers", 'ptt.note'=>"Text" ); $this->export_entities_array[$r] = array( 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 's.fk_pays'=>'company', @@ -272,8 +273,8 @@ class modProjet extends DolibarrModules $keyforaliasextra = 'extra2'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; // End add extra fields - $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime', 'ptt.task_date'=>'TaskTimeDate', 'ptt.task_duration'=>"TimesSpent", 'ptt.fk_user'=>"TaskTimeUser", 'ptt.note'=>"TaskTimeNote")); - $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time', 'ptt.task_date'=>'task_time', 'ptt.task_duration'=>"task_time", 'ptt.fk_user'=>"task_time", 'ptt.note'=>"task_time")); + $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime', 'ptt.element_date'=>'TaskTimeDate', 'ptt.element_duration'=>"TimesSpent", 'ptt.fk_user'=>"TaskTimeUser", 'ptt.note'=>"TaskTimeNote")); + $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time', 'ptt.element_date'=>'task_time', 'ptt.element_duration'=>"task_time", 'ptt.fk_user'=>"task_time", 'ptt.note'=>"task_time")); if (empty($conf->global->PROJECT_HIDE_TASKS)) { $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('f.ref'=>"Billed")); $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('f.ref'=>"task_time")); @@ -284,7 +285,7 @@ class modProjet extends DolibarrModules $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet"; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task"; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."element_time as ptt ON (pt.rowid = ptt.fk_element AND ptt.elementtype = 'task')"; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid'; if (empty($conf->global->PROJECT_HIDE_TASKS)) { $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON ptt.invoice_id = f.rowid'; diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 635a627d0a1..16a197f42b9 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -3,7 +3,8 @@ * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018 Frédéric France + * Copyright (C) 2023 Gauthier VERDOL * * 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 @@ -749,13 +750,14 @@ class doc_generic_project_odt extends ModelePDFProjects } //Time ressources - $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note"; + $sql = "SELECT t.rowid, t.element_date as task_date, t.element_duration as task_duration, t.fk_user, t.note"; $sql .= ", u.lastname, u.firstname, t.thm"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_time as t"; $sql .= " , ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE t.fk_task =".((int) $task->id); + $sql .= " WHERE t.fk_element =".((int) $task->id); + $sql .= " AND t.elementtype = 'task'"; $sql .= " AND t.fk_user = u.rowid"; - $sql .= " ORDER BY t.task_date DESC"; + $sql .= " ORDER BY t.element_date DESC"; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index 49522a01d33..983d6f9b97a 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -3,7 +3,8 @@ * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018 Frédéric France + * Copyright (C) 2023 Gauthier VERDOL * * 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 @@ -662,13 +663,14 @@ class doc_generic_task_odt extends ModelePDFTask } // Time ressources - $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note"; + $sql = "SELECT t.rowid, t.element_date as task_date, t.element_duration as task_duration, t.fk_user, t.note"; $sql .= ", u.lastname, u.firstname"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_time as t"; $sql .= " , ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE t.fk_task =".((int) $object->id); + $sql .= " WHERE t.fk_element =".((int) $object->id); + $sql .= " AND t.elementtype = 'task'"; $sql .= " AND t.fk_user = u.rowid"; - $sql .= " ORDER BY t.task_date DESC"; + $sql .= " ORDER BY t.element_date DESC"; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 26469449a0b..25be39f2c87 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -315,7 +315,7 @@ UPDATE llx_actioncomm set fk_user_action = fk_user_done where fk_user_done > 0 a UPDATE llx_actioncomm set fk_user_action = fk_user_author where fk_user_author > 0 and (fk_user_action is null or fk_user_action = 0); -UPDATE llx_projet_task_time set task_datehour = task_date where task_datehour IS NULL and task_date IS NOT NULL; +UPDATE llx_element_time set element_datehour = element_date where element_datehour IS NULL and element_date IS NOT NULL; UPDATE llx_projet set fk_opp_status = NULL where fk_opp_status = -1; UPDATE llx_projet set fk_opp_status = (SELECT rowid FROM llx_c_lead_status WHERE code='PROSP') where fk_opp_status IS NULL and opp_amount > 0; @@ -389,8 +389,8 @@ update llx_expedition set date_valid = date_creation where fk_statut = 1 and dat update llx_expedition set date_valid = NOW() where fk_statut = 1 and date_valid IS NULL; -- Detect bad consistency between duraction_effective of a task and sum of time of tasks --- select pt.rowid, pt.duration_effective, SUM(ptt.task_duration) as y from llx_projet_task as pt, llx_projet_task_time as ptt where ptt.fk_task = pt.rowid group by pt.rowid, pt.duration_effective having pt.duration_effective <> y; -update llx_projet_task as pt set pt.duration_effective = (select SUM(ptt.task_duration) as y from llx_projet_task_time as ptt where ptt.fk_task = pt.rowid) where pt.duration_effective <> (select SUM(ptt.task_duration) as y from llx_projet_task_time as ptt where ptt.fk_task = pt.rowid); +-- select pt.rowid, pt.duration_effective, SUM(ptt.element_duration) as y from llx_projet_task as pt, llx_element_time as ptt where ptt.fk_element = pt.rowid and ptt.elementtype = 'task' group by pt.rowid, pt.duration_effective having pt.duration_effective <> y; +update llx_projet_task as pt set pt.duration_effective = (select SUM(ptt.element_duration) as y from llx_element_time as ptt where ptt.fk_element = pt.rowid and ptt.elementtype = 'task') where pt.duration_effective <> (select SUM(ptt.element_duration) as y from llx_element_time as ptt where ptt.fk_element = pt.rowid and ptt.elementtype = 'task'); -- Remove duplicate of shipment mode (keep the one with tracking defined) @@ -422,7 +422,7 @@ UPDATE llx_facture_fourn_det SET fk_code_ventilation = 0 WHERE fk_code_ventilati UPDATE llx_expensereport_det SET fk_code_ventilation = 0 WHERE fk_code_ventilation > 0 AND fk_code_ventilation NOT IN (select rowid FROM llx_accounting_account); --- VMYSQL4.1 update llx_projet_task_time set task_datehour = task_date where task_datehour < task_date or task_datehour > DATE_ADD(task_date, interval 1 day); +-- VMYSQL4.1 update llx_element_time set element_datehour = element_date where element_datehour < element_date or element_datehour > DATE_ADD(element_date, interval 1 day); -- Clean product prices @@ -487,7 +487,7 @@ UPDATE llx_chargesociales SET date_creation = tms WHERE date_creation IS NULL; -- Backport a change of value into the hourly rate. --- update llx_projet_task_time as ptt set ptt.thm = (SELECT thm from llx_user as u where ptt.fk_user = u.rowid) where (ptt.thm is null) +-- update llx_element_time as ptt set ptt.thm = (SELECT thm from llx_user as u where ptt.fk_user = u.rowid) where (ptt.thm is null) -- select * from llx_facturedet as fd, llx_product as p where fd.fk_product = p.rowid AND fd.product_type != p.fk_product_type; diff --git a/htdocs/install/pgsql/functions/functions.sql b/htdocs/install/pgsql/functions/functions.sql index 35bc4e05c11..918d17385eb 100644 --- a/htdocs/install/pgsql/functions/functions.sql +++ b/htdocs/install/pgsql/functions/functions.sql @@ -1,6 +1,7 @@ -- ============================================================================ -- Copyright (C) 2004 Benoit Mortier -- Copyright (C) 2010 Laurent Destailleur +-- Copyright (C) 2023 Gauthier VERDOL -- -- 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 @@ -150,7 +151,7 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_projet FOR EACH ROW CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_projet_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_projet_task FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_projet_task_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_projet_task_time FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_element_time FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_propal FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_propal_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_propal_merge_pdf_product FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index c40f4a69e89..70be057b7b8 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2021 Frédéric France + * Copyright (C) 2023 Gauthier VERDOL * * 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 @@ -1030,7 +1031,7 @@ if ($ok && GETPOST('set_empty_time_spent_amount', 'alpha')) { print '
*** Set value of time spent without amount'; $sql = "SELECT COUNT(ptt.rowid) as nb, u.rowid as user_id, u.login, u.thm as user_thm"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as ptt, ".MAIN_DB_PREFIX."user as u"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_time as ptt, ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE ptt.fk_user = u.rowid"; $sql .= " AND ptt.thm IS NULL and u.thm > 0"; $sql .= " GROUP BY u.rowid, u.login, u.thm"; @@ -1048,7 +1049,7 @@ if ($ok && GETPOST('set_empty_time_spent_amount', 'alpha')) { $db->begin(); if (GETPOST('set_empty_time_spent_amount') == 'confirmed') { - $sql2 = "UPDATE ".MAIN_DB_PREFIX."projet_task_time"; + $sql2 = "UPDATE ".MAIN_DB_PREFIX."element_time"; $sql2 .= " SET thm = ".$obj->user_thm." WHERE thm IS NULL AND fk_user = ".((int) $obj->user_id); $resql2 = $db->query($sql2); if (!$resql2) { diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 7f76261bcea..65629284af3 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2015-2016 Raphaël Doursenaud + * Copyright (C) 2023 Gauthier VERDOL * * 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 @@ -339,7 +340,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $afterversionarray = explode('.', '2.8.9'); $beforeversionarray = explode('.', '2.9.9'); if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) { - migrate_project_task_time($db, $langs, $conf); + migrate_element_time($db, $langs, $conf); migrate_customerorder_shipping($db, $langs, $conf); @@ -2901,9 +2902,9 @@ function migrate_relationship_tables($db, $langs, $conf, $table, $fk_source, $so * @param Conf $conf Object conf * @return void */ -function migrate_project_task_time($db, $langs, $conf) +function migrate_element_time($db, $langs, $conf) { - dolibarr_install_syslog("upgrade2::migrate_project_task_time"); + dolibarr_install_syslog("upgrade2::migrate_element_time"); print ''; @@ -2914,8 +2915,8 @@ function migrate_project_task_time($db, $langs, $conf) $db->begin(); - $sql = "SELECT rowid, fk_task, task_duration"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time"; + $sql = "SELECT rowid, fk_element, element_duration"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_time"; $resql = $db->query($sql); if ($resql) { $i = 0; @@ -2928,16 +2929,16 @@ function migrate_project_task_time($db, $langs, $conf) while ($i < $num) { $obj = $db->fetch_object($resql); - if ($obj->task_duration > 0) { + if ($obj->element_duration > 0) { // convert to second // only for int time and float time ex: 1,75 for 1h45 - list($hour, $min) = explode('.', $obj->task_duration); + list($hour, $min) = explode('.', $obj->element_duration); $hour = $hour * 60 * 60; $min = ($min / 100) * 60 * 60; $newtime = $hour + $min; - $sql2 = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET"; - $sql2 .= " task_duration = ".((int) $newtime); + $sql2 = "UPDATE ".MAIN_DB_PREFIX."element_time SET"; + $sql2 .= " element_duration = ".((int) $newtime); $sql2 .= " WHERE rowid = ".((int) $obj->rowid); $resql2 = $db->query($sql2); @@ -2947,16 +2948,16 @@ function migrate_project_task_time($db, $langs, $conf) } print ". "; $oldtime++; - if (!empty($totaltime[$obj->fk_task])) { - $totaltime[$obj->fk_task] += $newtime; + if (!empty($totaltime[$obj->fk_element])) { + $totaltime[$obj->fk_element] += $newtime; } else { - $totaltime[$obj->fk_task] = $newtime; + $totaltime[$obj->fk_element] = $newtime; } } else { - if (!empty($totaltime[$obj->fk_task])) { - $totaltime[$obj->fk_task] += $obj->task_duration; + if (!empty($totaltime[$obj->fk_element])) { + $totaltime[$obj->fk_element] += $obj->element_duration; } else { - $totaltime[$obj->fk_task] = $obj->task_duration; + $totaltime[$obj->fk_element] = $obj->element_duration; } } diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index bbd9442f876..8f69a8afada 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2006-2015 Laurent Destailleur * Copyright (C) 2010 Regis Houssin * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2023 Gauthier VERDOL * * 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 @@ -116,15 +117,16 @@ print ''.$langs->trans('ActivityOnProjectToday').''; print ''.$langs->trans("Time").''; print "\n"; -$sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; +$sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; -$sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; +$sql .= ", ".MAIN_DB_PREFIX."element_time as tt"; $sql .= " WHERE t.fk_projet = p.rowid"; $sql .= " AND p.entity = ".((int) $conf->entity); -$sql .= " AND tt.fk_task = t.rowid"; +$sql .= " AND tt.fk_element = t.rowid"; +$sql .= " AND tt.elementtype = 'task'"; $sql .= " AND tt.fk_user = ".((int) $user->id); -$sql .= " AND task_date BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; +$sql .= " AND element_date BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; $sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")"; $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; @@ -169,15 +171,16 @@ print ''.$langs->trans('ActivityOnProjectYesterday').''; print ''.$langs->trans("Time").''; print "\n"; -$sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; +$sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; -$sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; +$sql .= ", ".MAIN_DB_PREFIX."element_time as tt"; $sql .= " WHERE t.fk_projet = p.rowid"; $sql .= " AND p.entity = ".((int) $conf->entity); -$sql .= " AND tt.fk_task = t.rowid"; +$sql .= " AND tt.fk_element = t.rowid"; +$sql .= " AND tt.elementtype = 'task'"; $sql .= " AND tt.fk_user = ".((int) $user->id); -$sql .= " AND task_date BETWEEN '".$db->idate(dol_time_plus_duree(dol_mktime(0, 0, 0, $month, $day, $year), -1, 'd'))."' AND '".$db->idate(dol_time_plus_duree(dol_mktime(23, 59, 59, $month, $day, $year), -1, 'd'))."'"; +$sql .= " AND element_date BETWEEN '".$db->idate(dol_time_plus_duree(dol_mktime(0, 0, 0, $month, $day, $year), -1, 'd'))."' AND '".$db->idate(dol_time_plus_duree(dol_mktime(23, 59, 59, $month, $day, $year), -1, 'd'))."'"; $sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")"; $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; @@ -281,15 +284,16 @@ if (!empty($conf->global->PROJECT_TASK_TIME_MONTH)) { print ''.$langs->trans("Time").''; print "\n"; - $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; + $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; + $sql .= ", ".MAIN_DB_PREFIX."element_time as tt"; $sql .= " WHERE t.fk_projet = p.rowid"; $sql .= " AND p.entity = ".((int) $conf->entity); - $sql .= " AND tt.fk_task = t.rowid"; + $sql .= " AND tt.fk_element = t.rowid"; + $sql .= " AND tt.elementtype = 'task'"; $sql .= " AND tt.fk_user = ".((int) $user->id); - $sql .= " AND task_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'"; + $sql .= " AND element_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'"; $sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")"; $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; @@ -327,15 +331,16 @@ if (!empty($conf->global->PROJECT_TASK_TIME_YEAR)) { print ''.$langs->trans("Time").''; print "\n"; - $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; + $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.element_duration) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql .= ", ".MAIN_DB_PREFIX."projet_task_time as tt"; + $sql .= ", ".MAIN_DB_PREFIX."element_time as tt"; $sql .= " WHERE t.fk_projet = p.rowid"; $sql .= " AND p.entity = ".((int) $conf->entity); - $sql .= " AND tt.fk_task = t.rowid"; + $sql .= " AND tt.fk_element = t.rowid"; + $sql .= " AND tt.elementtype = 'task'"; $sql .= " AND tt.fk_user = ".((int) $user->id); - $sql .= " AND YEAR(task_date) = '".strftime("%Y", $now)."'"; + $sql .= " AND YEAR(element_date) = '".strftime("%Y", $now)."'"; $sql .= " AND p.rowid in (".$db->sanitize($projectsListId).")"; $sql .= " GROUP BY p.rowid, p.ref, p.title, p.public"; @@ -407,11 +412,11 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_SH $max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA) ? 1000 : $conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA); $sql = "SELECT p.ref, p.title, p.rowid as projectid, p.fk_statut as status, p.fk_opp_status as opp_status, p.public, p.dateo as projdateo, p.datee as projdatee,"; - $sql .= " t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent"; + $sql .= " t.label, t.rowid as taskid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee, SUM(tasktime.element_duration) as timespent"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_time as tasktime on (tasktime.fk_element = t.rowid AND tasktime.elementtype = 'task')"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid"; if ($mine) { $sql .= ", ".MAIN_DB_PREFIX."element_contact as ect"; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index c9a811ad245..e2faef3da8e 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -7,6 +7,7 @@ * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2019 Juanjo Menent * Copyright (C) 2022 Charlene Benke + * Copyright (C) 2023 Gauthier VERDOL * * 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 @@ -782,8 +783,8 @@ class Project extends CommonObject $sql = "SELECT ed.rowid FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND e.entity IN (".getEntity('expensereport').") AND ed.fk_projet IN (".$this->db->sanitize($ids).")"; } elseif ($type == 'project_task') { $sql = "SELECT DISTINCT pt.rowid FROM ".MAIN_DB_PREFIX."projet_task as pt WHERE pt.fk_projet IN (".$this->db->sanitize($ids).")"; - } elseif ($type == 'project_task_time') { // Case we want to duplicate line foreach user - $sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet IN (".$this->db->sanitize($ids).")"; + } elseif ($type == 'element_time') { // Case we want to duplicate line foreach user + $sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."element_time as ptt WHERE pt.rowid = ptt.fk_element AND ptt.elementtype = 'task' AND pt.fk_projet IN (".$this->db->sanitize($ids).")"; } elseif ($type == 'stock_mouvement') { $sql = "SELECT ms.rowid, ms.fk_user_author as fk_user FROM ".MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin IN (".$this->db->sanitize($ids).") AND ms.type_mouvement = 1"; } elseif ($type == 'loan') { @@ -1041,8 +1042,8 @@ class Project extends CommonObject $sql = "SELECT COUNT(ed.rowid) as nb FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."expensereport_det as ed WHERE e.rowid = ed.fk_expensereport AND e.entity IN (".getEntity('expensereport').") AND ed.fk_projet = ".((int) $this->id); } elseif ($type == 'project_task') { $sql = "SELECT DISTINCT COUNT(pt.rowid) as nb FROM ".MAIN_DB_PREFIX."projet_task as pt WHERE pt.fk_projet = ".((int) $this->id); - } elseif ($type == 'project_task_time') { // Case we want to duplicate line foreach user - $sql = "SELECT DISTINCT COUNT(pt.rowid) as nb FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet = ".((int) $this->id); + } elseif ($type == 'element_time') { // Case we want to duplicate line foreach user + $sql = "SELECT DISTINCT COUNT(pt.rowid) as nb FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."element_time as ptt WHERE pt.rowid = ptt.fk_element AND ptt.elementtype = 'task' AND pt.fk_projet = ".((int) $this->id); } elseif ($type == 'stock_mouvement') { $sql = "SELECT COUNT(ms.rowid) as nb FROM ".MAIN_DB_PREFIX."stock_mouvement as ms, ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = ms.fk_entrepot AND e.entity IN (".getEntity('stock').") AND ms.origintype = 'project' AND ms.fk_origin = ".((int) $this->id)." AND ms.type_mouvement = 1"; } elseif ($type == 'loan') { @@ -2017,14 +2018,15 @@ class Project extends CommonObject dol_print_error('', 'Error datestart parameter is empty'); } - $sql = "SELECT ptt.rowid as taskid, ptt.task_duration, ptt.task_date, ptt.task_datehour, ptt.fk_task"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt"; - $sql .= " WHERE ptt.fk_task = pt.rowid"; + $sql = "SELECT ptt.rowid as taskid, ptt.element_duration, ptt.element_date, ptt.element_datehour, ptt.fk_element"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt"; + $sql .= " WHERE ptt.fk_element = pt.rowid"; + $sql .= " AND ptt.elementtype = 'task'"; $sql .= " AND pt.fk_projet = ".((int) $this->id); - $sql .= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' "; - $sql .= " AND ptt.task_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'w') - 1)."')"; + $sql .= " AND (ptt.element_date >= '".$this->db->idate($datestart)."' "; + $sql .= " AND ptt.element_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'w') - 1)."')"; if ($taskid) { - $sql .= " AND ptt.fk_task=".((int) $taskid); + $sql .= " AND ptt.fk_element=".((int) $taskid); } if (is_numeric($userid)) { $sql .= " AND ptt.fk_user=".((int) $userid); @@ -2040,13 +2042,13 @@ class Project extends CommonObject // Loop on each record found, so each couple (project id, task id) while ($i < $num) { $obj = $this->db->fetch_object($resql); - $day = $this->db->jdate($obj->task_date); // task_date is date without hours + $day = $this->db->jdate($obj->element_date); // task_date is date without hours if (empty($daylareadyfound[$day])) { - $this->weekWorkLoad[$day] = $obj->task_duration; - $this->weekWorkLoadPerTask[$day][$obj->fk_task] = $obj->task_duration; + $this->weekWorkLoad[$day] = $obj->element_duration; + $this->weekWorkLoadPerTask[$day][$obj->fk_element] = $obj->element_duration; } else { - $this->weekWorkLoad[$day] += $obj->task_duration; - $this->weekWorkLoadPerTask[$day][$obj->fk_task] += $obj->task_duration; + $this->weekWorkLoad[$day] += $obj->element_duration; + $this->weekWorkLoadPerTask[$day][$obj->fk_element] += $obj->element_duration; } $daylareadyfound[$day] = 1; $i++; @@ -2080,14 +2082,15 @@ class Project extends CommonObject dol_print_error('', 'Error datestart parameter is empty'); } - $sql = "SELECT ptt.rowid as taskid, ptt.task_duration, ptt.task_date, ptt.task_datehour, ptt.fk_task"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt"; - $sql .= " WHERE ptt.fk_task = pt.rowid"; + $sql = "SELECT ptt.rowid as taskid, ptt.element_duration, ptt.element_date, ptt.element_datehour, ptt.fk_element"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt"; + $sql .= " WHERE ptt.fk_element = pt.rowid"; + $sql .= " AND ptt.elementtype = 'task'"; $sql .= " AND pt.fk_projet = ".((int) $this->id); - $sql .= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' "; - $sql .= " AND ptt.task_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'm') - 1)."')"; + $sql .= " AND (ptt.element_date >= '".$this->db->idate($datestart)."' "; + $sql .= " AND ptt.element_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'm') - 1)."')"; if ($taskid) { - $sql .= " AND ptt.fk_task=".((int) $taskid); + $sql .= " AND ptt.fk_element=".((int) $taskid); } if (is_numeric($userid)) { $sql .= " AND ptt.fk_user=".((int) $userid); @@ -2103,16 +2106,16 @@ class Project extends CommonObject // Loop on each record found, so each couple (project id, task id) while ($i < $num) { $obj = $this->db->fetch_object($resql); - if (!empty($obj->task_date)) { - $date = explode('-', $obj->task_date); + if (!empty($obj->element_date)) { + $date = explode('-', $obj->element_date); $week_number = getWeekNumber($date[2], $date[1], $date[0]); } if (empty($weekalreadyfound[$week_number])) { - $this->monthWorkLoad[$week_number] = $obj->task_duration; - $this->monthWorkLoadPerTask[$week_number][$obj->fk_task] = $obj->task_duration; + $this->monthWorkLoad[$week_number] = $obj->element_duration; + $this->monthWorkLoadPerTask[$week_number][$obj->fk_element] = $obj->element_duration; } else { - $this->monthWorkLoad[$week_number] += $obj->task_duration; - $this->monthWorkLoadPerTask[$week_number][$obj->fk_task] += $obj->task_duration; + $this->monthWorkLoad[$week_number] += $obj->element_duration; + $this->monthWorkLoadPerTask[$week_number][$obj->fk_element] += $obj->element_duration; } $weekalreadyfound[$week_number] = 1; $i++; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 596d828ff97..a303f8708fa 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2018-2023 Frédéric France * Copyright (C) 2020 Juanjo Menent * Copyright (C) 2022 Charlene Benke + * Copyright (C) 2023 Gauthier VERDOL * * 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 @@ -29,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/timespent.class.php'; /** @@ -49,7 +51,7 @@ class Task extends CommonObjectLine /** * @var string Field with ID of parent key if this field has a parent */ - public $fk_element = 'fk_task'; + public $fk_element = 'fk_element'; /** * @var string String with name of icon for myobject. @@ -60,7 +62,7 @@ class Task extends CommonObjectLine * @var array List of child tables. To test if we can delete object. */ protected $childtables = array( - 'projet_task_time' => array('name' => 'Task', 'parent' => 'projet_task', 'parentkey' => 'fk_task') + 'element_time' => array('name' => 'Task', 'parent' => 'projet_task', 'parentkey' => 'fk_element', 'parenttypefield' => 'elementtype', 'parenttypevalue' => 'task') ); /** @@ -556,8 +558,8 @@ class Task extends CommonObjectLine } if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_time"; - $sql .= " WHERE fk_task = ".((int) $this->id); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_time"; + $sql .= " WHERE fk_element = ".((int) $this->id)." AND elementtype = 'task'"; $resql = $this->db->query($sql); if (!$resql) { @@ -673,8 +675,9 @@ class Task extends CommonObjectLine $ret = 0; $sql = "SELECT COUNT(*) as nb"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time"; - $sql .= " WHERE fk_task = ".((int) $this->id); + $sql .= " FROM ".MAIN_DB_PREFIX."element_time"; + $sql .= " WHERE fk_element = ".((int) $this->id); + $sql .= " AND elementtype = 'task'"; dol_syslog(get_class($this)."::hasTimeSpent", LOG_DEBUG); $resql = $this->db->query($sql); @@ -877,7 +880,7 @@ class Task extends CommonObjectLine } } if ($includebilltime) { - $sql .= ", SUM(tt.task_duration * ".$this->db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.task_duration * ".$this->db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; + $sql .= ", SUM(tt.element_duration * ".$this->db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.element_duration * ".$this->db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; } $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; @@ -891,7 +894,7 @@ class Task extends CommonObjectLine } $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; if ($includebilltime) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype='task')"; } if ($filterontaskuser > 0) { $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec2"; @@ -908,14 +911,14 @@ class Task extends CommonObjectLine if ($filterontaskuser > 0) { $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; if ($includebilltime) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype='task')"; } $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec2"; $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as ctc2"; } else { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; if ($includebilltime) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype = 'task')"; } } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)"; @@ -1261,31 +1264,20 @@ class Task extends CommonObjectLine $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_time ("; - $sql .= "fk_task"; - $sql .= ", task_date"; - $sql .= ", task_datehour"; - $sql .= ", task_date_withhour"; - $sql .= ", task_duration"; - $sql .= ", fk_user"; - $sql .= ", fk_product"; - $sql .= ", note"; - $sql .= ", datec"; - $sql .= ") VALUES ("; - $sql .= ((int) $this->id); - $sql .= ", '".$this->db->idate($this->timespent_date)."'"; - $sql .= ", '".$this->db->idate($this->timespent_datehour)."'"; - $sql .= ", ".(empty($this->timespent_withhour) ? 0 : 1); - $sql .= ", ".((int) $this->timespent_duration); - $sql .= ", ".((int) $this->timespent_fk_user); - $sql .= ", ".((int) $this->timespent_fk_product); - $sql .= ", ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null"); - $sql .= ", '".$this->db->idate($now)."'"; - $sql .= ")"; + $timespent = new TimeSpent($this->db); + $timespent->fk_element = $this->id; + $timespent->elementtype = 'task'; + $timespent->element_date = $this->timespent_date; + $timespent->element_datehour = $this->timespent_datehour; + $timespent->element_date_withhour = $this->timespent_withhour; + $timespent->element_duration = $this->timespent_duration; + $timespent->fk_user = $this->timespent_fk_user; + $timespent->fk_product = $this->timespent_fk_product; + $timespent->note = $this->timespent_note; + $timespent->datec = $this->db->idate($now); - $resql = $this->db->query($sql); - if ($resql) { - $tasktime_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_time"); + if ($timespent->create($user) > 0) { + $tasktime_id = $this->db->last_insert_id(MAIN_DB_PREFIX."element_time"); $ret = $tasktime_id; $this->timespent_id = $ret; @@ -1305,7 +1297,7 @@ class Task extends CommonObjectLine if ($ret > 0) { // Recalculate amount of time spent for task and update denormalized field $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql .= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".((int) $this->id).")"; + $sql .= " SET duration_effective = (SELECT SUM(element_duration) FROM ".MAIN_DB_PREFIX."element_time as ptt where ptt.elementtype = 'task' AND ptt.fk_element = ".((int) $this->id).")"; if (isset($this->progress)) { $sql .= ", progress = ".((float) $this->progress); // Do not overwrite value if not provided } @@ -1318,12 +1310,15 @@ class Task extends CommonObjectLine } // Update hourly rate of this time spent entry - $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time"; - $sql .= " SET thm = (SELECT thm FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".((int) $this->timespent_fk_user).")"; // set average hour rate of user - $sql .= " WHERE rowid = ".((int) $tasktime_id); + $resql_thm_user = $this->db->query("SELECT thm FROM " . MAIN_DB_PREFIX . "user WHERE rowid = " . ((int)$timespent->fk_user)); + if (!empty($resql_thm_user)) { + $obj_thm_user = $this->db->fetch_object($resql_thm_user); + $timespent->thm = $obj_thm_user->thm; + } + $res_update = $timespent->update($user); dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); - if (!$this->db->query($sql)) { + if ($res_update <= 0) { $this->error = $this->db->lasterror(); $ret = -2; } @@ -1354,11 +1349,11 @@ class Task extends CommonObjectLine $sql .= " s.nom as thirdparty_name,"; $sql .= " s.email as thirdparty_email,"; $sql .= " ptt.rowid,"; - $sql .= " ptt.fk_task,"; - $sql .= " ptt.task_date,"; - $sql .= " ptt.task_datehour,"; - $sql .= " ptt.task_date_withhour,"; - $sql .= " ptt.task_duration,"; + $sql .= " ptt.fk_element as fk_task,"; + $sql .= " ptt.element_date as task_date,"; + $sql .= " ptt.element_datehour as task_datehour,"; + $sql .= " ptt.element_date_withhour as task_date_withhour,"; + $sql .= " ptt.element_duration as task_duration,"; $sql .= " ptt.fk_user,"; $sql .= " ptt.note,"; $sql .= " ptt.thm,"; @@ -1369,9 +1364,10 @@ class Task extends CommonObjectLine $sql .= " p.ref as project_ref,"; $sql .= " p.title as project_label,"; $sql .= " p.public as public"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as ptt, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet as p"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_time as ptt, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; - $sql .= " WHERE ptt.fk_task = pt.rowid AND pt.fk_projet = p.rowid"; + $sql .= " WHERE ptt.fk_element = pt.rowid AND pt.fk_projet = p.rowid"; + $sql .= " AND ptt.elementtype = 'task'"; $sql .= " AND pt.rowid = ".((int) $this->id); $sql .= " AND pt.entity IN (".getEntity('project').")"; if ($morewherefilter) { @@ -1452,19 +1448,19 @@ class Task extends CommonObjectLine $result = array(); $sql = "SELECT"; - $sql .= " MIN(t.task_datehour) as min_date,"; - $sql .= " MAX(t.task_datehour) as max_date,"; - $sql .= " SUM(t.task_duration) as total_duration,"; - $sql .= " SUM(t.task_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as total_amount,"; + $sql .= " MIN(t.element_datehour) as min_date,"; + $sql .= " MAX(t.element_datehour) as max_date,"; + $sql .= " SUM(t.element_duration) as total_duration,"; + $sql .= " SUM(t.element_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as total_amount,"; $sql .= " COUNT(t.rowid) as nblines,"; $sql .= " SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; - $sql .= " WHERE 1 = 1"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_time as t"; + $sql .= " WHERE t.elementtype='task'"; if ($morewherefilter) { $sql .= $morewherefilter; } if ($id > 0) { - $sql .= " AND t.fk_task = ".((int) $id); + $sql .= " AND t.fk_element = ".((int) $id); } if ($userid > 0) { $sql .= " AND t.fk_user = ".((int) $userid); @@ -1512,19 +1508,19 @@ class Task extends CommonObjectLine $result = array(); $sql = "SELECT"; - $sql .= " SUM(t.task_duration) as nbseconds,"; - $sql .= " SUM(t.task_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as amount, SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; - $sql .= " WHERE t.fk_task = ".((int) $id); + $sql .= " SUM(t.element_duration) as nbseconds,"; + $sql .= " SUM(t.element_duration / 3600 * ".$this->db->ifsql("t.thm IS NULL", 0, "t.thm").") as amount, SUM(".$this->db->ifsql("t.thm IS NULL", 1, 0).") as nblinesnull"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_time as t"; + $sql .= " WHERE t.elementtype='task' AND t.fk_element = ".((int) $id); if (is_object($fuser) && $fuser->id > 0) { $sql .= " AND fk_user = ".((int) $fuser->id); } if ($dates > 0) { - $datefieldname = "task_datehour"; + $datefieldname = "element_datehour"; $sql .= " AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; } if ($datee > 0) { - $datefieldname = "task_datehour"; + $datefieldname = "element_datehour"; $sql .= " AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; } //print $sql; @@ -1556,45 +1552,30 @@ class Task extends CommonObjectLine { global $langs; - $sql = "SELECT"; - $sql .= " t.rowid,"; - $sql .= " t.fk_task,"; - $sql .= " t.task_date,"; - $sql .= " t.task_datehour,"; - $sql .= " t.task_date_withhour,"; - $sql .= " t.task_duration,"; - $sql .= " t.fk_user,"; - $sql .= " t.fk_product,"; - $sql .= " t.thm,"; - $sql .= " t.note"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; - $sql .= " WHERE t.rowid = ".((int) $id); + $timespent = new TimeSpent($this->db); + $timespent->fetch($id); dol_syslog(get_class($this)."::fetchTimeSpent", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - if ($this->db->num_rows($resql)) { - $obj = $this->db->fetch_object($resql); - $this->timespent_id = $obj->rowid; - $this->id = $obj->fk_task; - $this->timespent_date = $this->db->jdate($obj->task_date); - $this->timespent_datehour = $this->db->jdate($obj->task_datehour); - $this->timespent_withhour = $obj->task_date_withhour; - $this->timespent_duration = $obj->task_duration; - $this->timespent_fk_user = $obj->fk_user; - $this->timespent_fk_product = $obj->fk_product; - $this->timespent_thm = $obj->thm; // hourly rate - $this->timespent_note = $obj->note; - } + if ($timespent->id > 0) { - $this->db->free($resql); + $this->timespent_id = $timespent->id; + $this->id = $timespent->fk_element; + $this->timespent_date = $this->db->jdate($timespent->element_date); + $this->timespent_datehour = $this->db->jdate($timespent->element_datehour); + $this->timespent_withhour = $timespent->element_date_withhour; + $this->timespent_duration = $timespent->element_duration; + $this->timespent_fk_user = $timespent->fk_user; + $this->timespent_fk_product = $timespent->fk_product; + $this->timespent_thm = $timespent->thm; // hourly rate + $this->timespent_note = $timespent->note; return 1; - } else { - $this->error = "Error ".$this->db->lasterror(); - return -1; + } + + return 0; + } /** @@ -1613,11 +1594,11 @@ class Task extends CommonObjectLine $sql .= " s.nom as thirdparty_name,"; $sql .= " s.email as thirdparty_email,"; $sql .= " ptt.rowid,"; - $sql .= " ptt.fk_task,"; - $sql .= " ptt.task_date,"; - $sql .= " ptt.task_datehour,"; - $sql .= " ptt.task_date_withhour,"; - $sql .= " ptt.task_duration,"; + $sql .= " ptt.fk_element as fk_task,"; + $sql .= " ptt.element_date as task_date,"; + $sql .= " ptt.element_datehour as task_datehour,"; + $sql .= " ptt.element_date_withhour as task_date_withhour,"; + $sql .= " ptt.element_duration as task_duration,"; $sql .= " ptt.fk_user,"; $sql .= " ptt.note,"; $sql .= " ptt.thm,"; @@ -1628,9 +1609,10 @@ class Task extends CommonObjectLine $sql .= " p.ref as project_ref,"; $sql .= " p.title as project_label,"; $sql .= " p.public as public"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as ptt, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet as p"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_time as ptt, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; - $sql .= " WHERE ptt.fk_task = pt.rowid AND pt.fk_projet = p.rowid"; + $sql .= " WHERE ptt.fk_element = pt.rowid AND pt.fk_projet = p.rowid"; + $sql .= " AND ptt.elementtype = 'task'"; $sql .= " AND ptt.fk_user = ".((int) $userobj->id); $sql .= " AND pt.entity IN (".getEntity('project').")"; if ($morewherefilter) { @@ -1729,18 +1711,18 @@ class Task extends CommonObjectLine $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET"; - $sql .= " task_date = '".$this->db->idate($this->timespent_date)."',"; - $sql .= " task_datehour = '".$this->db->idate($this->timespent_datehour)."',"; - $sql .= " task_date_withhour = ".(empty($this->timespent_withhour) ? 0 : 1).","; - $sql .= " task_duration = ".((int) $this->timespent_duration).","; - $sql .= " fk_user = ".((int) $this->timespent_fk_user).","; - $sql .= " fk_product = ".((int) $this->timespent_fk_product).","; - $sql .= " note = ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null"); - $sql .= " WHERE rowid = ".((int) $this->timespent_id); + $timespent = new TimeSpent($this->db); + $timespent->fetch($this->timespent_id); + $timespent->element_date = $this->timespent_date; + $timespent->element_datehour = $this->timespent_datehour; + $timespent->element_date_withhour = $this->timespent_withhour; + $timespent->element_duration = $this->timespent_duration; + $timespent->fk_user = $this->timespent_fk_user; + $timespent->fk_product = $this->timespent_fk_product; + $timespent->note = $this->timespent_note; dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG); - if ($this->db->query($sql)) { + if ($timespent->update($user) > 0) { if (!$notrigger) { // Call trigger $result = $this->call_trigger('TASK_TIMESPENT_MODIFY', $user); @@ -1764,7 +1746,7 @@ class Task extends CommonObjectLine if ($this->timespent_old_duration != $this->timespent_duration) { // Recalculate amount of time spent for task and update denormalized field $sql = "UPDATE " . MAIN_DB_PREFIX . "projet_task"; - $sql .= " SET duration_effective = (SELECT SUM(task_duration) FROM " . MAIN_DB_PREFIX . "projet_task_time as ptt where ptt.fk_task = " . ((int) $this->id) . ")"; + $sql .= " SET duration_effective = (SELECT SUM(element_duration) FROM " . MAIN_DB_PREFIX . "element_time as ptt where ptt.elementtype = 'task' AND ptt.fk_element = " . ((int) $this->id) . ")"; if (isset($this->progress)) { $sql .= ", progress = " . ((float) $this->progress); // Do not overwrite value if not provided } @@ -1779,15 +1761,18 @@ class Task extends CommonObjectLine } // Update hourly rate of this time spent entry, but only if it was not set initialy - $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time"; - $sql .= " SET thm = (SELECT thm FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".((int) $this->timespent_fk_user).")"; // set average hour rate of user - $sql .= " WHERE rowid = ".((int) $this->timespent_id); - if (empty($conf->global->TIMESPENT_ALWAYS_UPDATE_THM)) { // then if not empty we always update, in case of new thm for user, or change user of task time line - $sql .= " AND (thm IS NULL OR thm = 0)"; + $res_update = 1; + if(empty($timespent->thm) || !empty($conf->global->TIMESPENT_ALWAYS_UPDATE_THM)) { + $resql_thm_user = $this->db->query("SELECT thm FROM " . MAIN_DB_PREFIX . "user WHERE rowid = " . ((int)$timespent->fk_user)); + if (!empty($resql_thm_user)) { + $obj_thm_user = $this->db->fetch_object($resql_thm_user); + $timespent->thm = $obj_thm_user->thm; + } + $res_update = $timespent->update($user); } - dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); - if (!$this->db->query($sql)) { + dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG); + if ($res_update <= 0) { $this->error = $this->db->lasterror(); $ret = -2; } @@ -1835,12 +1820,13 @@ class Task extends CommonObjectLine } if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_time"; - $sql .= " WHERE rowid = ".((int) $this->timespent_id); - dol_syslog(get_class($this)."::delTimeSpent", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { + $timespent = new TimeSpent($this->db); + $timespent->fetch($this->timespent_id); + + $res_del = $timespent->delete($user); + + if ($res_del < 0) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 935275bfe54..b680e29399a 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -8,6 +8,7 @@ * Copyright (C) 2016 Josep Lluís Amador * Copyright (C) 2021 Gauthier VERDOL * Copyright (C) 2021 Noé Cendrier + * Copyright (C) 2023 Gauthier VERDOL * * 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 @@ -575,7 +576,7 @@ $listofreferent = array( 'class'=>'Task', 'margin'=>'minus', 'table'=>'projet_task', - 'datefieldname'=>'task_date', + 'datefieldname'=>'element_date', 'disableamount'=>0, 'urlnew'=>DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&action=createtime&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'buttonnew'=>'AddTimeSpent', @@ -1337,7 +1338,7 @@ foreach ($listofreferent as $key => $value) { $tmpuser2->fetch($element->fk_user_author); print $tmpuser2->getNomUrl(1, '', 48); } - } elseif ($tablename == 'projet_task' && $key == 'project_task_time') { // if $key == 'project_task', we don't want details per user + } elseif ($tablename == 'projet_task' && $key == 'element_time') { // if $key == 'project_task', we don't want details per user print $elementuser->getNomUrl(1); } print ''; diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 00449a30a17..a860f1205c7 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -4,6 +4,7 @@ * Copyright (C) 2006-2010 Regis Houssin * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2021 Alexandre Spangaro + * Copyright (C) 2023 Gauthier VERDOL * * 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 @@ -345,7 +346,7 @@ $sql .= " t.description, t.fk_task_parent"; $sql .= " ,t.budget_amount"; // Add sum fields if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) { - $sql .= " , SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; + $sql .= " , SUM(tt.element_duration * ".$db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.element_duration * ".$db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; } // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -361,7 +362,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype = 'task')"; } if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 85d83031ccd..088807f02fc 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -6,6 +6,7 @@ * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2018 Frédéric France * Copyright (C) 2019-2021 Christophe Battarel + * Copyright (C) 2023 Gauthier VERDOL * * 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 @@ -104,7 +105,7 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortfield) { - $sortfield = 't.task_date,t.task_datehour,t.rowid'; + $sortfield = 't.element_date,t.element_datehour,t.rowid'; } if (!$sortorder) { $sortorder = 'DESC,DESC,DESC'; @@ -561,7 +562,7 @@ if ($action == 'confirm_generateinvoice') { } // Update lineid into line of timespent - $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); + $sql = 'UPDATE '.MAIN_DB_PREFIX.'element_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid); $result = $db->query($sql); if (!$result) { @@ -665,7 +666,7 @@ if ($action == 'confirm_generateinvoice') { //var_dump($lineid);exit; // Update lineid into line of timespent - $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); + $sql = 'UPDATE '.MAIN_DB_PREFIX.'element_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid); $result = $db->query($sql); if (!$result) { @@ -764,7 +765,7 @@ if ($action == 'confirm_generateinvoice') { if (!$error) { // Update lineid into line of timespent - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'projet_task_time SET invoice_line_id = ' . ((int) $lineid) . ', invoice_id = ' . ((int) $tmpinvoice->id); + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'element_time SET invoice_line_id = ' . ((int) $lineid) . ', invoice_id = ' . ((int) $tmpinvoice->id); $sql .= ' WHERE rowid IN (' . $db->sanitize(join(',', $toselect)) . ')'; $result = $db->query($sql); if (!$result) { @@ -1262,7 +1263,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser // Definition of fields for list $arrayfields = array(); - $arrayfields['t.task_date'] = array('label'=>$langs->trans("Date"), 'checked'=>1); + $arrayfields['t.element_date'] = array('label'=>$langs->trans("Date"), 'checked'=>1); $arrayfields['p.fk_soc'] = array('label'=>$langs->trans("ThirdParty"), 'type'=>'integer:Societe:/societe/class/societe.class.php:1','checked'=>1); $arrayfields['s.name_alias'] = array('label'=>$langs->trans("AliasNameShort"), 'type'=>'integer:Societe:/societe/class/societe.class.php:1'); if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task @@ -1270,15 +1271,15 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $arrayfields['p.project_ref'] = ['label' => $langs->trans('RefProject'), 'checked' => 1]; $arrayfields['p.project_label'] = ['label' => $langs->trans('ProjectLabel'), 'checked' => 1]; } - $arrayfields['t.task_ref'] = array('label'=>$langs->trans("RefTask"), 'checked'=>1); - $arrayfields['t.task_label'] = array('label'=>$langs->trans("LabelTask"), 'checked'=>1); + $arrayfields['t.element_ref'] = array('label'=>$langs->trans("RefTask"), 'checked'=>1); + $arrayfields['t.element_label'] = array('label'=>$langs->trans("LabelTask"), 'checked'=>1); } $arrayfields['author'] = array('label'=>$langs->trans("By"), 'checked'=>1); $arrayfields['t.note'] = array('label'=>$langs->trans("Note"), 'checked'=>1); if (isModEnabled('service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { $arrayfields['t.fk_product'] = array('label' => $langs->trans("Product"), 'checked' => 1); } - $arrayfields['t.task_duration'] = array('label'=>$langs->trans("Duration"), 'checked'=>1); + $arrayfields['t.element_duration'] = array('label'=>$langs->trans("Duration"), 'checked'=>1); $arrayfields['value'] = array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>(empty($conf->salaries->enabled) ? 0 : 1)); $arrayfields['valuebilled'] = array('label'=>$langs->trans("Billed"), 'checked'=>1, 'enabled'=>(((!empty($conf->global->PROJECT_HIDE_TASKS) || empty($conf->global->PROJECT_BILL_TIME_SPENT)) ? 0 : 1) && $projectstatic->usage_bill_time)); // Extra fields @@ -1547,7 +1548,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields - $sql = "SELECT t.rowid, t.fk_task, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm,"; + $sql = "SELECT t.rowid, t.fk_element, t.element_date, t.element_datehour, t.element_date_withhour, t.element_duration, t.fk_user, t.note, t.thm,"; $sql .= " t.fk_product,"; $sql .= " pt.ref, pt.label, pt.fk_projet,"; $sql .= " u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,"; @@ -1558,11 +1559,11 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."element_time as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facturedet as il ON il.rowid = t.invoice_line_id"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as inv ON inv.rowid = il.fk_facture"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as prod ON prod.rowid = t.fk_product"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."projet_task as pt ON pt.rowid = t.fk_task"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."projet_task as pt ON pt.rowid = t.fk_element"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = pt.fk_projet"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON t.fk_user = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; @@ -1571,10 +1572,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; - $sql .= " WHERE 1 = 1 "; + $sql .= " WHERE elementtype='task' "; if (empty($projectidforalltimes) && empty($allprojectforuser)) { // Limit on one task - $sql .= " AND t.fk_task =".((int) $object->id); + $sql .= " AND t.fk_element =".((int) $object->id); } elseif (!empty($projectidforalltimes)) { // Limit on one project $sql .= " AND pt.fk_projet IN (".$db->sanitize($projectidforalltimes).")"; @@ -1625,27 +1626,27 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } if ($search_date_start) { - $sql .= " AND t.task_date >= '".$db->idate($search_date_start)."'"; + $sql .= " AND t.element_date >= '".$db->idate($search_date_start)."'"; } if ($search_date_end) { - $sql .= " AND t.task_date <= '".$db->idate($search_date_end)."'"; + $sql .= " AND t.element_date <= '".$db->idate($search_date_end)."'"; } - if (!empty($arrayfields['t.task_duration']['checked'])) { + if (!empty($arrayfields['t.element_duration']['checked'])) { if ($search_timespent_starthour || $search_timespent_startmin) { $timespent_duration_start = $search_timespent_starthour * 60 * 60; // We store duration in seconds $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60; // We store duration in seconds - $sql .= " AND t.task_duration >= " . $timespent_duration_start; + $sql .= " AND t.element_duration >= " . $timespent_duration_start; } if ($search_timespent_endhour || $search_timespent_endmin) { $timespent_duration_end = $search_timespent_endhour * 60 * 60; // We store duration in seconds $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60; // We store duration in seconds - $sql .= " AND t.task_duration <= " . $timespent_duration_end; + $sql .= " AND t.element_duration <= " . $timespent_duration_end; } } - $sql .= dolSqlDateFilter('t.task_datehour', $search_day, $search_month, $search_year); + $sql .= dolSqlDateFilter('t.element_datehour', $search_day, $search_month, $search_year); // Add where from hooks $parameters = array(); @@ -1873,7 +1874,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; } // Date - if (!empty($arrayfields['t.task_date']['checked'])) { + if (!empty($arrayfields['t.element_date']['checked'])) { print ''; print '
'; print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); @@ -1903,10 +1904,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } // Task if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task - if (!empty($arrayfields['t.task_ref']['checked'])) { + if (!empty($arrayfields['t.element_ref']['checked'])) { print ''; } - if (!empty($arrayfields['t.task_label']['checked'])) { + if (!empty($arrayfields['t.element_label']['checked'])) { print ''; } } @@ -1919,7 +1920,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; } // Duration - if (!empty($arrayfields['t.task_duration']['checked'])) { + if (!empty($arrayfields['t.element_duration']['checked'])) { // Duration - Time spent print ''; @@ -1975,12 +1976,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'width="80"', $sortfield, $sortorder, 'center maxwidthsearch '); } - if (!empty($arrayfields['t.task_date']['checked'])) { - print_liste_field_titre($arrayfields['t.task_date']['label'], $_SERVER['PHP_SELF'], 't.task_date,t.task_datehour,t.rowid', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.element_date']['checked'])) { + print_liste_field_titre($arrayfields['t.element_date']['label'], $_SERVER['PHP_SELF'], 't.element_date,t.element_datehour,t.rowid', '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['p.fk_soc']['checked'])) { - print_liste_field_titre($arrayfields['p.fk_soc']['label'], $_SERVER['PHP_SELF'], 't.task_date,t.task_datehour,t.rowid', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['p.fk_soc']['label'], $_SERVER['PHP_SELF'], 't.element_date,t.element_datehour,t.rowid', '', $param, '', $sortfield, $sortorder); } 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); @@ -1994,11 +1995,11 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } } if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task - if (!empty($arrayfields['t.task_ref']['checked'])) { - print_liste_field_titre($arrayfields['t.task_ref']['label'], $_SERVER['PHP_SELF'], 'pt.ref', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.element_ref']['checked'])) { + print_liste_field_titre($arrayfields['t.element_ref']['label'], $_SERVER['PHP_SELF'], 'pt.ref', '', $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields['t.task_label']['checked'])) { - print_liste_field_titre($arrayfields['t.task_label']['label'], $_SERVER['PHP_SELF'], 'pt.label', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.element_label']['checked'])) { + print_liste_field_titre($arrayfields['t.element_label']['label'], $_SERVER['PHP_SELF'], 'pt.label', '', $param, '', $sortfield, $sortorder); } } if (!empty($arrayfields['author']['checked'])) { @@ -2007,8 +2008,8 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (!empty($arrayfields['t.note']['checked'])) { print_liste_field_titre($arrayfields['t.note']['label'], $_SERVER['PHP_SELF'], 't.note', '', $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields['t.task_duration']['checked'])) { - print_liste_field_titre($arrayfields['t.task_duration']['label'], $_SERVER['PHP_SELF'], 't.task_duration', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['t.element_duration']['checked'])) { + print_liste_field_titre($arrayfields['t.element_duration']['label'], $_SERVER['PHP_SELF'], 't.element_duration', '', $param, '', $sortfield, $sortorder, 'right '); } if (!empty($arrayfields['t.fk_product']['checked'])) { print_liste_field_titre($arrayfields['t.fk_product']['label'], $_SERVER['PHP_SELF'], 't.fk_product', '', $param, '', $sortfield, $sortorder); @@ -2046,8 +2047,8 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser break; } - $date1 = $db->jdate($task_time->task_date); - $date2 = $db->jdate($task_time->task_datehour); + $date1 = $db->jdate($task_time->element_date); + $date2 = $db->jdate($task_time->element_datehour); print ''; @@ -2068,11 +2069,11 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; } - print 'rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; + print 'rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; print img_edit('default', 0, 'class="pictofixedwidth paddingleft"'); print ''; - print 'rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; + print 'rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; print img_delete('default', 'class="pictodelete paddingleft"'); print ''; @@ -2088,16 +2089,16 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } } // Date - if (!empty($arrayfields['t.task_date']['checked'])) { + if (!empty($arrayfields['t.element_date']['checked'])) { print ''; if ($action == 'editline' && GETPOST('lineid', 'int') == $task_time->rowid) { - if (empty($task_time->task_date_withhour)) { + if (empty($task_time->element_date_withhour)) { print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 3, 3, 2, "timespent_date", 1, 0); } else { print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 1, 1, 2, "timespent_date", 1, 0); } } else { - print dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ? 'dayhour' : 'day')); + print dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ? 'dayhour' : 'day')); } print ''; if (!$i) { @@ -2178,13 +2179,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } // Task ref - if (!empty($arrayfields['t.task_ref']['checked'])) { + if (!empty($arrayfields['t.element_ref']['checked'])) { if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task print ''; if ($action == 'editline' && GETPOST('lineid', 'int') == $task_time->rowid) { - $formproject->selectTasks(-1, GETPOST('taskid', 'int') ? GETPOST('taskid', 'int') : $task_time->fk_task, 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, ''); + $formproject->selectTasks(-1, GETPOST('taskid', 'int') ? GETPOST('taskid', 'int') : $task_time->fk_element, 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, ''); } else { - $tasktmp->id = $task_time->fk_task; + $tasktmp->id = $task_time->fk_element; $tasktmp->ref = $task_time->ref; $tasktmp->label = $task_time->label; print $tasktmp->getNomUrl(1, 'withproject', 'time'); @@ -2199,7 +2200,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } // Task label - if (!empty($arrayfields['t.task_label']['checked'])) { + if (!empty($arrayfields['t.element_label']['checked'])) { if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task print ''; print dol_escape_htmltag($task_time->label); @@ -2258,33 +2259,33 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } // Time spent - if (!empty($arrayfields['t.task_duration']['checked'])) { + if (!empty($arrayfields['t.element_duration']['checked'])) { print ''; if ($action == 'editline' && GETPOST('lineid', 'int') == $task_time->rowid) { - print ''; - print $form->select_duration('new_duration', $task_time->task_duration, 0, 'text'); + print ''; + print $form->select_duration('new_duration', $task_time->element_duration, 0, 'text'); } else { - print convertSecondToTime($task_time->task_duration, 'allhourmin'); + print convertSecondToTime($task_time->element_duration, 'allhourmin'); } print ''; if (!$i) { $totalarray['nbfield']++; } if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.task_duration'; + $totalarray['pos'][$totalarray['nbfield']] = 't.element_duration'; } - if (empty($totalarray['val']['t.task_duration'])) { - $totalarray['val']['t.task_duration'] = $task_time->task_duration; + if (empty($totalarray['val']['t.element_duration'])) { + $totalarray['val']['t.element_duration'] = $task_time->element_duration; } else { - $totalarray['val']['t.task_duration'] += $task_time->task_duration; + $totalarray['val']['t.element_duration'] += $task_time->element_duration; } if (!$i) { $totalarray['totaldurationfield'] = $totalarray['nbfield']; } if (empty($totalarray['totalduration'])) { - $totalarray['totalduration'] = $task_time->task_duration; + $totalarray['totalduration'] = $task_time->element_duration; } else { - $totalarray['totalduration'] += $task_time->task_duration; + $totalarray['totalduration'] += $task_time->element_duration; } } @@ -2308,7 +2309,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser // Value spent if (!empty($arrayfields['value']['checked'])) { $langs->load("salaries"); - $value = price2num($task_time->thm * $task_time->task_duration / 3600, 'MT', 1); + $value = price2num($task_time->thm * $task_time->element_duration / 3600, 'MT', 1); print ''; print 'thm).'">'; @@ -2386,11 +2387,11 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; } - print 'rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; + print 'rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; print img_edit('default', 0, 'class="pictofixedwidth paddingleft"'); print ''; - print 'rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; + print 'rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; print img_delete('default', 'class="pictodelete paddingleft"'); print ''; @@ -2419,16 +2420,16 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; // Date - if (!empty($arrayfields['t.task_date']['checked'])) { + if (!empty($arrayfields['t.element_date']['checked'])) { print ''; if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { - if (empty($task_time->task_date_withhour)) { + if (empty($task_time->element_date_withhour)) { print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 3, 3, 2, "timespent_date", 1, 0); } else { print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 1, 1, 2, "timespent_date", 1, 0); } } else { - print dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ? 'dayhour' : 'day')); + print dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ? 'dayhour' : 'day')); } print ''; } @@ -2442,10 +2443,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } // Task ref - if (!empty($arrayfields['t.task_ref']['checked'])) { + if (!empty($arrayfields['t.element_ref']['checked'])) { if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task print ''; - $tasktmp->id = $task_time->fk_task; + $tasktmp->id = $task_time->fk_element; $tasktmp->ref = $task_time->ref; $tasktmp->label = $task_time->label; print $tasktmp->getNomUrl(1, 'withproject', 'time'); @@ -2454,7 +2455,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } // Task label - if (!empty($arrayfields['t.task_label']['checked'])) { + if (!empty($arrayfields['t.element_label']['checked'])) { if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task print ''; print dol_escape_htmltag($task_time->label); @@ -2504,13 +2505,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } // Time spent - if (!empty($arrayfields['t.task_duration']['checked'])) { + if (!empty($arrayfields['t.element_duration']['checked'])) { print ''; if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { - print ''; - print $form->select_duration('new_duration', $task_time->task_duration, 0, 'text'); + print ''; + print $form->select_duration('new_duration', $task_time->element_duration, 0, 'text'); } else { - print convertSecondToTime($task_time->task_duration, 'allhourmin'); + print convertSecondToTime($task_time->element_duration, 'allhourmin'); } print ''; } @@ -2519,7 +2520,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (!empty($arrayfields['value']['checked'])) { print ''; print ''; - $value = price2num($task_time->thm * $task_time->task_duration / 3600, 'MT', 1); + $value = price2num($task_time->thm * $task_time->element_duration / 3600, 'MT', 1); print price($value, 1, $langs, 1, -1, -1, $conf->currency); print ''; print ''; @@ -2557,16 +2558,16 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; // Date - if (!empty($arrayfields['t.task_date']['checked'])) { + if (!empty($arrayfields['t.element_date']['checked'])) { print ''; if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { - if (empty($task_time->task_date_withhour)) { + if (empty($task_time->element_date_withhour)) { print $form->selectDate(($date2 ? $date2 : $date1), 'timeline_2', 3, 3, 2, "timespent_date", 1, 0); } else { print $form->selectDate(($date2 ? $date2 : $date1), 'timeline_2', 1, 1, 2, "timespent_date", 1, 0); } } else { - print dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ? 'dayhour' : 'day')); + print dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ? 'dayhour' : 'day')); } print ''; } @@ -2580,10 +2581,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } // Task ref - if (!empty($arrayfields['t.task_ref']['checked'])) { + if (!empty($arrayfields['t.element_ref']['checked'])) { if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task print ''; - $tasktmp->id = $task_time->fk_task; + $tasktmp->id = $task_time->fk_element; $tasktmp->ref = $task_time->ref; $tasktmp->label = $task_time->label; print $tasktmp->getNomUrl(1, 'withproject', 'time'); @@ -2592,7 +2593,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } // Task label - if (!empty($arrayfields['t.task_label']['checked'])) { + if (!empty($arrayfields['t.element_label']['checked'])) { if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task print ''; print $task_time->label; @@ -2642,13 +2643,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } // Time spent - if (!empty($arrayfields['t.task_duration']['checked'])) { + if (!empty($arrayfields['t.element_duration']['checked'])) { print ''; if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { print ''; print $form->select_duration('new_duration_2', 0, 0, 'text'); } else { - print convertSecondToTime($task_time->task_duration, 'allhourmin'); + print convertSecondToTime($task_time->element_duration, 'allhourmin'); } print ''; } From e6a5cd94611db1d3409b742ba7301bd17a35ce8e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 8 Mar 2023 10:08:08 +0000 Subject: [PATCH 32/84] Fixing style errors. --- htdocs/projet/class/project.class.php | 4 ++-- htdocs/projet/class/task.class.php | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index e2faef3da8e..e25f06ed6a4 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -2021,7 +2021,7 @@ class Project extends CommonObject $sql = "SELECT ptt.rowid as taskid, ptt.element_duration, ptt.element_date, ptt.element_datehour, ptt.fk_element"; $sql .= " FROM ".MAIN_DB_PREFIX."element_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt"; $sql .= " WHERE ptt.fk_element = pt.rowid"; - $sql .= " AND ptt.elementtype = 'task'"; + $sql .= " AND ptt.elementtype = 'task'"; $sql .= " AND pt.fk_projet = ".((int) $this->id); $sql .= " AND (ptt.element_date >= '".$this->db->idate($datestart)."' "; $sql .= " AND ptt.element_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'w') - 1)."')"; @@ -2085,7 +2085,7 @@ class Project extends CommonObject $sql = "SELECT ptt.rowid as taskid, ptt.element_duration, ptt.element_date, ptt.element_datehour, ptt.fk_element"; $sql .= " FROM ".MAIN_DB_PREFIX."element_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt"; $sql .= " WHERE ptt.fk_element = pt.rowid"; - $sql .= " AND ptt.elementtype = 'task'"; + $sql .= " AND ptt.elementtype = 'task'"; $sql .= " AND pt.fk_projet = ".((int) $this->id); $sql .= " AND (ptt.element_date >= '".$this->db->idate($datestart)."' "; $sql .= " AND ptt.element_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'm') - 1)."')"; diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index a303f8708fa..2c2c0580a9b 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1310,7 +1310,7 @@ class Task extends CommonObjectLine } // Update hourly rate of this time spent entry - $resql_thm_user = $this->db->query("SELECT thm FROM " . MAIN_DB_PREFIX . "user WHERE rowid = " . ((int)$timespent->fk_user)); + $resql_thm_user = $this->db->query("SELECT thm FROM " . MAIN_DB_PREFIX . "user WHERE rowid = " . ((int) $timespent->fk_user)); if (!empty($resql_thm_user)) { $obj_thm_user = $this->db->fetch_object($resql_thm_user); $timespent->thm = $obj_thm_user->thm; @@ -1571,11 +1571,9 @@ class Task extends CommonObjectLine $this->timespent_note = $timespent->note; return 1; - } return 0; - } /** @@ -1762,8 +1760,8 @@ class Task extends CommonObjectLine // Update hourly rate of this time spent entry, but only if it was not set initialy $res_update = 1; - if(empty($timespent->thm) || !empty($conf->global->TIMESPENT_ALWAYS_UPDATE_THM)) { - $resql_thm_user = $this->db->query("SELECT thm FROM " . MAIN_DB_PREFIX . "user WHERE rowid = " . ((int)$timespent->fk_user)); + if (empty($timespent->thm) || !empty($conf->global->TIMESPENT_ALWAYS_UPDATE_THM)) { + $resql_thm_user = $this->db->query("SELECT thm FROM " . MAIN_DB_PREFIX . "user WHERE rowid = " . ((int) $timespent->fk_user)); if (!empty($resql_thm_user)) { $obj_thm_user = $this->db->fetch_object($resql_thm_user); $timespent->thm = $obj_thm_user->thm; From 5064ee178a44e58dd74aa3813e943a4466ecc0ab Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 8 Mar 2023 11:59:32 +0100 Subject: [PATCH 33/84] FIX : travis + stickler --- htdocs/core/class/commonobject.class.php | 2 +- htdocs/projet/class/task.class.php | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index eabcfda8491..ea4561abdce 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4638,7 +4638,7 @@ abstract class CommonObject $sql.= " AND c.".$element['parentkey']." = p.rowid"; } if (!empty($element['parent']) && !empty($element['parenttypefield']) && !empty($element['parenttypevalue'])) { - $sql.= " AND c.".$element['parenttypefield']." = '".$element['parenttypevalue']."'"; + $sql.= " AND c.".$element['parenttypefield']." = '".$this->db->escape($element['parenttypevalue'])."'"; } if (!empty($entity)) { if (!empty($element['parent']) && !empty($element['parentkey'])) { diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index a303f8708fa..cd822b9864c 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1558,7 +1558,6 @@ class Task extends CommonObjectLine dol_syslog(get_class($this)."::fetchTimeSpent", LOG_DEBUG); if ($timespent->id > 0) { - $this->timespent_id = $timespent->id; $this->id = $timespent->fk_element; $this->timespent_date = $this->db->jdate($timespent->element_date); @@ -1571,7 +1570,6 @@ class Task extends CommonObjectLine $this->timespent_note = $timespent->note; return 1; - } return 0; From 9147f0cba174e7db51f66098819f989cedf64aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 9 Mar 2023 14:10:43 +0100 Subject: [PATCH 34/84] typo in fr_FR --- htdocs/langs/fr_FR/boxes.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/fr_FR/boxes.lang b/htdocs/langs/fr_FR/boxes.lang index 75c6ccb9ed9..f15f7b2bccc 100644 --- a/htdocs/langs/fr_FR/boxes.lang +++ b/htdocs/langs/fr_FR/boxes.lang @@ -49,7 +49,7 @@ BoxTitleLastActionsToDo=Les %s derniers événements à réaliser BoxTitleLastContracts=Les %s derniers contrats modifiés BoxTitleLastModifiedDonations=Les %s derniers dons modifiés BoxTitleLastModifiedExpenses=Les %s dernières notes de frais modifiées -BoxTitleLatestModifiedBoms=Les %s derières BOMS modifiées +BoxTitleLatestModifiedBoms=Les %s dernières BOMS modifiées BoxTitleLatestModifiedMos=Les %s derniers ordres de fabrication modifiés BoxTitleLastOutstandingBillReached=Clients dont l'en-cours autorisé est dépassé BoxGlobalActivity=Activité globale (factures, propositions, commandes) From 04f463259f0986fbea2d874b7b0df72c6cb2e92e Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Thu, 9 Mar 2023 15:26:59 +0100 Subject: [PATCH 35/84] Add Extrafields in Notes Add support of extrafields in notes if its specified in extrafield's settings. --- .../modules/supplier_proposal/doc/pdf_aurore.modules.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 70467c49f58..be81381924d 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -393,6 +393,13 @@ class pdf_aurore extends ModelePDFSupplierProposal } } } + + // Extrafields in note + $extranote = $this->getExtrafieldsInHtml($object, $outputlangs); + if (!empty($extranote)) { + $notetoshow = dol_concatdesc($notetoshow, $extranote); + } + if ($notetoshow) { $tab_top -= 2; From e0aa056845d4a08d608d3e0a1fea9898a2e26717 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 9 Mar 2023 14:40:43 +0000 Subject: [PATCH 36/84] Fixing style errors. --- .../core/modules/supplier_proposal/doc/pdf_aurore.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index be81381924d..e031a10dbf8 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -393,13 +393,13 @@ class pdf_aurore extends ModelePDFSupplierProposal } } } - + // Extrafields in note $extranote = $this->getExtrafieldsInHtml($object, $outputlangs); if (!empty($extranote)) { $notetoshow = dol_concatdesc($notetoshow, $extranote); } - + if ($notetoshow) { $tab_top -= 2; From e47c395fe73688de5f4bf6491c6a33265630f95f Mon Sep 17 00:00:00 2001 From: kkhelifa Date: Fri, 10 Mar 2023 09:14:33 +0100 Subject: [PATCH 37/84] Fix stickler-ci --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 097530c6aa5..bf05df918ce 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2102,7 +2102,7 @@ abstract class CommonObject $sql = "SELECT " . $field; $sql .= " FROM " . MAIN_DB_PREFIX . $table; - $sql .= " WHERE " . $id_field . " = " . ((int)$id); + $sql .= " WHERE " . $id_field . " = " . ((int) $id); $resql = $this->db->query($sql); if ($resql) { From 7996ecf4f8d8111554074469e698d1fbabbbc8b5 Mon Sep 17 00:00:00 2001 From: GregM Date: Fri, 10 Mar 2023 10:42:00 +0100 Subject: [PATCH 38/84] Fix expensereport add ndf --- htdocs/expensereport/class/expensereport_ik.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/expensereport/class/expensereport_ik.class.php b/htdocs/expensereport/class/expensereport_ik.class.php index 0d374f1c722..2cbfe90b586 100644 --- a/htdocs/expensereport/class/expensereport_ik.class.php +++ b/htdocs/expensereport/class/expensereport_ik.class.php @@ -198,9 +198,9 @@ class ExpenseReportIk extends CommonObject $default_range = (int) $userauthor->default_range; // if not defined, then 0 $ranges = $this->getRangesByCategory($fk_c_exp_tax_cat); // prevent out of range -1 indice - $indice = $default_range > 0 ? $default_range - 1 : 0; + $indice = $default_range - 1; // substract 1 because array start from 0 - if (empty($ranges) || !isset($ranges[$indice])) { + if (empty($ranges) || $indice < 0 || !isset($ranges[$indice])) { return false; } else { return $ranges[$indice]; From a1d339aa68d4cdd36f12a329c8564a9808835174 Mon Sep 17 00:00:00 2001 From: bomuux Date: Wed, 8 Mar 2023 10:39:50 +0100 Subject: [PATCH 39/84] Update contact.php --- htdocs/comm/propal/contact.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 45f2d175f9a..cdbf513e6a8 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -65,7 +65,6 @@ if (!$error) { // Security check if (!empty($user->socid)) { $socid = $user->socid; - $object->id = $user->socid; } restrictedArea($user, 'propal', $object->id); From 12e9e3c3eb5d0a082a31fc99d1801bf8adfb7fcd Mon Sep 17 00:00:00 2001 From: bomuux Date: Wed, 8 Mar 2023 10:46:34 +0100 Subject: [PATCH 40/84] Update document.php --- htdocs/comm/propal/document.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index f1b6b2221e6..82a7a253ae9 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -45,13 +45,6 @@ $confirm = GETPOST('confirm', 'alpha'); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -// Security check -$socid = ''; -if (!empty($user->socid)) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'propal', $id); - // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -86,7 +79,6 @@ $permissiontoadd = $user->rights->propal->creer; // Security check if (!empty($user->socid)) { $socid = $user->socid; - $object->id = $user->socid; } restrictedArea($user, 'propal', $object->id); From efcaa0780af31af52c12f43c4c1c764026d4bdda Mon Sep 17 00:00:00 2001 From: bomuux Date: Wed, 8 Mar 2023 10:47:21 +0100 Subject: [PATCH 41/84] Update note.php --- htdocs/comm/propal/note.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 4a772dae1d2..7eaf3e02716 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -51,7 +51,6 @@ if ($id > 0 || !empty($ref)) { // Security check if ($user->socid > 0) { $socid = $user->socid; - $object->id = $user->socid; } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context From 60000b7d37edc2dca4fb4d5d810240955ba1013d Mon Sep 17 00:00:00 2001 From: bomuux Date: Wed, 8 Mar 2023 10:56:04 +0100 Subject: [PATCH 42/84] Update note.php --- htdocs/comm/propal/note.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 7eaf3e02716..ace4556fb62 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -49,6 +49,7 @@ if ($id > 0 || !empty($ref)) { } // Security check +$socid = ''; if ($user->socid > 0) { $socid = $user->socid; } From d92f6bb4fbca7e56dc777faffbaa847410f01ff6 Mon Sep 17 00:00:00 2001 From: bomuux Date: Wed, 8 Mar 2023 10:57:00 +0100 Subject: [PATCH 43/84] Update contact.php --- htdocs/comm/propal/contact.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index cdbf513e6a8..efad4303a0d 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -63,6 +63,7 @@ if (!$error) { } // Security check +$socid = ''; if (!empty($user->socid)) { $socid = $user->socid; } From a655faf08d99ee7c23d69cff8893b4d852e44df4 Mon Sep 17 00:00:00 2001 From: bomuux Date: Wed, 8 Mar 2023 10:58:05 +0100 Subject: [PATCH 44/84] Update document.php --- htdocs/comm/propal/document.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 82a7a253ae9..0a7584248c0 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -77,6 +77,7 @@ $object->fetch($id, $ref); $permissiontoadd = $user->rights->propal->creer; // Security check +$socid = ''; if (!empty($user->socid)) { $socid = $user->socid; } From 353d451e5ac5d10a63912758b63c5bebea20c8d5 Mon Sep 17 00:00:00 2001 From: noec764 <58433943+noec764@users.noreply.github.com> Date: Fri, 10 Mar 2023 15:48:26 +0100 Subject: [PATCH 45/84] Correct dolForgeCriteriaCallback --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c275e4fd310..06990a3dbd4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -10757,7 +10757,7 @@ function dolForgeCriteriaCallback($matches) $operand = preg_replace('/[^a-z0-9\._]/i', '', trim($tmp[0])); - $operator = strtoupper(preg_replace('/[^a-z<>=]/i', '', trim($tmp[1]))); + $operator = strtoupper(preg_replace('/[^a-z<>!=]/i', '', trim($tmp[1]))); if ($operator == 'NOTLIKE') { $operator = 'NOT LIKE'; } From a3db19c47bd371caf59d1c79f344b0bfb7286b66 Mon Sep 17 00:00:00 2001 From: atm-gauthier Date: Fri, 10 Mar 2023 19:19:54 +0100 Subject: [PATCH 46/84] Update 17.0.0-18.0.0.sql FIX : drop index in mysql and pgsql --- htdocs/install/mysql/migration/17.0.0-18.0.0.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql index 1c2b90046ce..583db12ae23 100644 --- a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql +++ b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql @@ -109,9 +109,12 @@ ALTER TABLE llx_element_time CHANGE COLUMN task_date_withhour element_date_withh ALTER TABLE llx_element_time CHANGE COLUMN task_duration element_duration double; ALTER TABLE llx_element_time ADD COLUMN elementtype varchar(32) NOT NULL DEFAULT 'task' AFTER fk_element; -DROP INDEX idx_projet_task_time_task on llx_element_time; -DROP INDEX idx_projet_task_time_date on llx_element_time; -DROP INDEX idx_projet_task_time_datehour on llx_element_time; +-- VMYSQL4.1 DROP INDEX idx_projet_task_time_task on llx_element_time; +-- VMYSQL4.1 DROP INDEX idx_projet_task_time_date on llx_element_time; +-- VMYSQL4.1 DROP INDEX idx_projet_task_time_datehour on llx_element_time; +-- VPGSQL8.2 DROP INDEX idx_projet_task_time_task; +-- VPGSQL8.2 DROP INDEX idx_projet_task_time_date; +-- VPGSQL8.2 DROP INDEX idx_projet_task_time_datehour; ALTER TABLE llx_element_time ADD INDEX idx_element_time_task (fk_element); ALTER TABLE llx_element_time ADD INDEX idx_element_time_date (element_date); From 6969cde52d4640dd79960453cdbd36f339eaace8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Mar 2023 19:20:02 +0100 Subject: [PATCH 47/84] Fix transaction balance --- htdocs/expedition/class/expeditionlinebatch.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/expedition/class/expeditionlinebatch.class.php b/htdocs/expedition/class/expeditionlinebatch.class.php index 5d99d1c7a74..a277e5f96f4 100644 --- a/htdocs/expedition/class/expeditionlinebatch.class.php +++ b/htdocs/expedition/class/expeditionlinebatch.class.php @@ -143,7 +143,6 @@ class ExpeditionLineBatch extends CommonObject dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } - $this->db->rollback(); return -1 * $error; } } From 23f32933b6fcec5db0b822f96bfb1e7125104e89 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 10 Mar 2023 18:42:22 +0000 Subject: [PATCH 48/84] Fixing style errors. --- htdocs/projet/class/task.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 3b2e61dec19..eb2f0f35069 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1719,8 +1719,8 @@ class Task extends CommonObjectLine $timespent->fk_user = $this->timespent_fk_user; $timespent->fk_product = $this->timespent_fk_product; $timespent->note = $this->timespent_note; - $timespent->invoice_id = $this->timespent_invoiceid; - $timespent->invoice_line_id = $this->timespent_invoicelineid; + $timespent->invoice_id = $this->timespent_invoiceid; + $timespent->invoice_line_id = $this->timespent_invoicelineid; dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG); if ($timespent->update($user) > 0) { From cfd48c20a9e2e7ccaa19f4051d2e945f2396d94f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Mar 2023 01:09:22 +0100 Subject: [PATCH 49/84] CSS v18 --- htdocs/core/class/dolgraph.class.php | 2 +- htdocs/core/customreports.php | 4 ++-- htdocs/theme/eldy/global.inc.php | 8 ++++++-- htdocs/theme/md/style.css.php | 9 ++++++++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 7c76dc9b36b..38bfbd840d8 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -1144,7 +1144,7 @@ class DolGraph if (isset($this->type[$firstlot])) { $cssfordiv .= ' dolgraphchar' . $this->type[$firstlot]; } - $this->stringtoshow .= '
' . "\n"; + $this->stringtoshow .= '
' . "\n"; $this->stringtoshow .= '\n"; + + $msg .= ajax_event($htmlname, $events); + + return $msg; +} + + +/** + * Add event management script. + * + * @param string $htmlname Name of html select field ('myid' or '.myclass') + * @param array $events Add some Ajax events option on change of $htmlname component to call ajax to autofill a HTML element (select#htmlname and #inputautocompletehtmlname) + * Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) + * @return string Return JS string to manage event + */ +function ajax_event($htmlname, $events) +{ + $out = ''; + + if (is_array($events) && count($events)) { // If an array of js events to do were provided. + $out = ' + '; } - $msg .= '});'."\n"; - $msg .= "\n"; - - return $msg; + return $out; } + /** * On/off button for constant * From 11fd351b3df1eae856b56b4f8d97f7348694fc2b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 12 Mar 2023 21:31:33 +0100 Subject: [PATCH 69/84] Some steps to merge manually #22960 --- htdocs/core/lib/payments.lib.php | 2 +- htdocs/core/lib/ticket.lib.php | 11 +++++++---- htdocs/public/ticket/create_ticket.php | 2 +- htdocs/public/ticket/index.php | 2 +- htdocs/public/ticket/list.php | 5 ++--- htdocs/public/ticket/view.php | 5 +++-- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 3dfccc88ea5..db1d0a13db6 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -487,7 +487,7 @@ function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, print '
'; - print '
'."\n"; + print '
'."\n"; if ($addformmessage) { print ''; print '
'; diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 2c218421543..4b61fe2eb2e 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -203,7 +203,7 @@ function generate_random_id($car = 16) } /** - * Show header for public pages + * Show http header, open body tag and show HTML header banner for public pages for tickets * * @param string $title Title * @param string $head Head array @@ -216,11 +216,14 @@ function generate_random_id($car = 16) function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '') { global $user, $conf, $langs, $mysoc; + $urllogo = ""; top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss, 0, 1); // Show html headers print ''; - print '
'; + print '
'; + + print '
'; // Define urllogo if (getDolGlobalInt('TICKET_SHOW_COMPANY_LOGO') || getDolGlobalString('TICKET_PUBLIC_INTERFACE_TOPIC')) { @@ -264,7 +267,7 @@ function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $ print '
'; } - print '
'; + print ''; - print '
'; + //print '
'; } diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 80ea664292b..2bb574def50 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -512,7 +512,7 @@ $arrayofcss = array('/opensurvey/css/style.css', '/ticket/css/styles.css.php'); llxHeaderTicket($langs->trans("CreateTicket"), "", 0, 0, $arrayofjs, $arrayofcss); -print '
'; +print '
'; if ($action != "infos_success") { $formticket->withfromsocid = isset($socid) ? $socid : $user->socid; diff --git a/htdocs/public/ticket/index.php b/htdocs/public/ticket/index.php index 97af18c0bb6..a36a0023324 100644 --- a/htdocs/public/ticket/index.php +++ b/htdocs/public/ticket/index.php @@ -80,7 +80,7 @@ $arrayofcss = array('/ticket/css/styles.css.php'); llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss); -print '
'; +print '
'; print '

'.(getDolGlobalString("TICKET_PUBLIC_TEXT_HOME", ''.$langs->trans("TicketPublicDesc")).'

').'

'; print '
'; diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index aafea0365e0..6f6bdacadb6 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -193,9 +193,8 @@ $arrayofcss = array('/ticket/css/styles.css.php'); llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss); - if ($action == "view_ticketlist") { - print '
'; + print '
'; print '
'; if ($display_ticket_list) { @@ -724,7 +723,7 @@ if ($action == "view_ticketlist") { print '
'; } else { - print '
'; + print '
'; print '

'.$langs->trans("TicketPublicMsgViewLogIn").'

'; print '
'; diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php index 67b582c0afd..142c704bb67 100644 --- a/htdocs/public/ticket/view.php +++ b/htdocs/public/ticket/view.php @@ -232,7 +232,7 @@ $arrayofcss = array('/ticket/css/styles.css.php'); llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss); -print '
'; +print '
'; if ($action == "view_ticket" || $action == "presend" || $action == "close" || $action == "confirm_public_close") { if ($display_ticket) { @@ -396,10 +396,11 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a print ''; } } else { - print '
'.$langs->trans("TicketPublicMsgViewLogIn").'
'; + print '
'.$langs->trans("TicketPublicMsgViewLogIn").'
'; print '
'; print '
'; + print ''; print ''; From 843411ef5d362996f99564b4664ab5fbe2c31243 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 12 Mar 2023 22:02:40 +0100 Subject: [PATCH 70/84] Fix CSS public interface of tickets --- htdocs/core/class/html.formticket.class.php | 4 ++-- htdocs/core/lib/ticket.lib.php | 8 ++++---- htdocs/public/ticket/list.php | 2 ++ htdocs/ticket/css/styles.css.php | 6 ++++++ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 1ba3ba27fb5..15634a761d4 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -427,7 +427,7 @@ class FormTicket $toolbarname = 'dolibarr_notes'; if ($this->ispublic) { $toolbarname = 'dolibarr_details'; - print '
'.(getDolGlobalString("TICKET_PUBLIC_TEXT_HELP_MESSAGE", $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'))).'
'; + print '
'.(getDolGlobalString("TICKET_PUBLIC_TEXT_HELP_MESSAGE", $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'))).'
'; } include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $uselocalbrowser = true; @@ -455,7 +455,7 @@ class FormTicket if (count($cate_arbo)) { // Categories - print ''.$langs->trans("Categories").''; + print ''.$langs->trans("Categories").''; print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print ""; } diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 2c218421543..cd665728af2 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -239,21 +239,21 @@ function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $ } // Output html code for logo - if ($urllogo || getDolGlobalInt('TICKET_PUBLIC_INTERFACE_TOPIC')) { + if ($urllogo || getDolGlobalString('TICKET_PUBLIC_INTERFACE_TOPIC')) { print '
'; print '
'; if ($urllogo) { - print ''; + print ''; print ''; print ''; } - if (getDolGlobalInt('TICKET_PUBLIC_INTERFACE_TOPIC')) { + if (getDolGlobalString('TICKET_PUBLIC_INTERFACE_TOPIC')) { print '
'.(getDolGlobalString('TICKET_PUBLIC_INTERFACE_TOPIC') ? getDolGlobalString('TICKET_PUBLIC_INTERFACE_TOPIC') : $langs->trans("TicketSystem")).''; } print '
'; if (!getDolGlobalInt('MAIN_HIDE_POWERED_BY')) { - print ''; + print ''; } print '
'; } diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index aafea0365e0..9ac4b25cb04 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -195,6 +195,7 @@ llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss); if ($action == "view_ticketlist") { + print '
'; print '
'; print '
'; @@ -723,6 +724,7 @@ if ($action == "view_ticketlist") { } print '
'; + print '
'; } else { print '
'; diff --git a/htdocs/ticket/css/styles.css.php b/htdocs/ticket/css/styles.css.php index 81d7d21748f..2ebc3420a14 100644 --- a/htdocs/ticket/css/styles.css.php +++ b/htdocs/ticket/css/styles.css.php @@ -124,4 +124,10 @@ div.ticketform .index_create, div.ticketform .index_display { @media only screen and (max-width: 767px) { #form_create_ticket input.text, #form_create_ticket textarea { width: unset;} + + #form_create_ticket, #form_view_ticket + { + margin-left: 0; + margin-right: 0; + } } From d6e0d745a8369816fa93fe1ecbd8bd9ecf59e877 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 12 Mar 2023 22:11:58 +0100 Subject: [PATCH 71/84] FIX token error when closing ticket from public interface --- htdocs/public/ticket/view.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php index edf2504fb0c..9f2eee2a6ea 100644 --- a/htdocs/public/ticket/view.php +++ b/htdocs/public/ticket/view.php @@ -376,7 +376,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a // Close ticket if ($object->dao->fk_statut >= Ticket::STATUS_NOT_READ && $object->dao->fk_statut < Ticket::STATUS_CLOSED) { - print ''; + print ''; } } From 800c2b477979999533603ab80110d0b2a07aabad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Mar 2023 09:33:31 +0100 Subject: [PATCH 72/84] Look and feel v18 --- htdocs/holiday/class/holiday.class.php | 6 +- htdocs/holiday/list.php | 1231 ++++++++++++------------ 2 files changed, 646 insertions(+), 591 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 341b0c700e1..93e443bad69 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1497,9 +1497,11 @@ class Holiday extends CommonObject } $out .= ''."\n"; - $out .= ajax_combobox($htmlname); - print $out; + $showempty= 0; + $out .= ajax_combobox($htmlname, array(), 0, 0, 'resolve', ($showempty < 0 ? (string) $showempty : '-1'), $morecss); + + return $out; } /** diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 3f8f9d69131..ed5c222f7c8 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -143,7 +143,13 @@ if ($user->socid > 0) { // Protection if external user accessforbidden(); } -if (empty($conf->holiday->enabled)) accessforbidden('Module not enabled'); +$permissiontoread = $user->hasRight('holiday', 'read'); +$permissiontodelete = $user->hasRight('holiday', 'delete'); +$permissiontoapprove = $user->hasRight('holiday', 'approve'); + +if (!ismodEnabled('holiday')) { + accessforbidden('Module holiday not enabled'); +} $result = restrictedArea($user, 'holiday', '', ''); // If we are on the view of a specific user @@ -152,10 +158,10 @@ if ($id > 0) { if ($id == $user->id) { $canread = 1; } - if (!empty($user->rights->holiday->readall)) { + if ($user->hasRight('holiday', 'readall')) { $canread = 1; } - if (!empty($user->rights->holiday->read) && in_array($id, $childids)) { + if ($user->hasRight('holiday', 'read') && in_array($id, $childids)) { $canread = 1; } if (!$canread) { @@ -165,13 +171,13 @@ if ($id > 0) { - /* * Actions */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; @@ -211,9 +217,6 @@ if (empty($reshook)) { // Mass actions $objectclass = 'Holiday'; $objectlabel = 'Holiday'; - $permissiontoread = $user->hasRight('holiday', 'read'); - $permissiontodelete = $user->hasRight('holiday', 'delete'); - $permissiontoapprove = $user->hasRight('holiday', 'approve'); $uploaddir = $conf->holiday->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -236,6 +239,8 @@ $holidaystatic = new Holiday($db); $result = $object->updateBalance(); $title = $langs->trans('CPTitreMenu'); +$help_url = ''; + llxHeader('', $title); $max_year = 5; @@ -304,7 +309,8 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; +$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total @@ -357,7 +363,7 @@ if ($id > 0) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; // Count total nb of records @@ -374,7 +380,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { dol_print_error($db); } - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -389,656 +395,703 @@ if ($limit) { //print $sql; $resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); +if (!$resql) { + dol_print_error($db); + exit; +} - $arrayofselected = is_array($toselect) ? $toselect : array(); +$num = $db->num_rows($resql); - $param = ''; - if (!empty($mode)) { - $param .= '&mode='.urlencode($mode); - } - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); - } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); - } - if ($search_ref) { - $param .= '&search_ref='.urlencode($search_ref); - } - if ($search_day_create) { - $param .= '&search_day_create='.urlencode($search_day_create); - } - if ($search_month_create) { - $param .= '&search_month_create='.urlencode($search_month_create); - } - if ($search_year_create) { - $param .= '&search_year_create='.urlencode($search_year_create); - } - if ($search_day_start) { - $param .= '&search_day_start='.urlencode($search_day_start); - } - if ($search_month_start) { - $param .= '&search_month_start='.urlencode($search_month_start); - } - if ($search_year_start) { - $param .= '&search_year_start='.urlencode($search_year_start); - } - if ($search_day_end) { - $param .= '&search_day_end='.urlencode($search_day_end); - } - if ($search_month_end) { - $param .= '&search_month_end='.urlencode($search_month_end); - } - if ($search_year_end) { - $param .= '&search_year_end='.urlencode($search_year_end); - } - if ($search_employee > 0) { - $param .= '&search_employee='.urlencode($search_employee); - } - if ($search_valideur > 0) { - $param .= '&search_valideur='.urlencode($search_valideur); - } - if ($search_type > 0) { - $param .= '&search_type='.urlencode($search_type); - } - if ($search_status > 0) { - $param .= '&search_status='.urlencode($search_status); - } - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +$arrayofselected = is_array($toselect) ? $toselect : array(); - // List of mass actions available - $arrayofmassactions = array( - //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), - //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), - //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), - ); - if (!empty($user->rights->holiday->delete)) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); - } - if (!empty($user->rights->holiday->approve)) { - $arrayofmassactions['preapproveleave'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Approve"); - } - if (in_array($massaction, array('presend', 'predelete'))) { - $arrayofmassactions = array(); - } - $massactionbutton = $form->selectMassAction('', $arrayofmassactions); +$param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.((int) $limit); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} +if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); +} +if ($search_day_create) { + $param .= '&search_day_create='.urlencode($search_day_create); +} +if ($search_month_create) { + $param .= '&search_month_create='.urlencode($search_month_create); +} +if ($search_year_create) { + $param .= '&search_year_create='.urlencode($search_year_create); +} +if ($search_day_start) { + $param .= '&search_day_start='.urlencode($search_day_start); +} +if ($search_month_start) { + $param .= '&search_month_start='.urlencode($search_month_start); +} +if ($search_year_start) { + $param .= '&search_year_start='.urlencode($search_year_start); +} +if ($search_day_end) { + $param .= '&search_day_end='.urlencode($search_day_end); +} +if ($search_month_end) { + $param .= '&search_month_end='.urlencode($search_month_end); +} +if ($search_year_end) { + $param .= '&search_year_end='.urlencode($search_year_end); +} +if ($search_employee > 0) { + $param .= '&search_employee='.urlencode($search_employee); +} +if ($search_valideur > 0) { + $param .= '&search_valideur='.urlencode($search_valideur); +} +if ($search_type > 0) { + $param .= '&search_type='.urlencode($search_type); +} +if ($search_status > 0) { + $param .= '&search_status='.urlencode($search_status); +} +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - // Lines of title fields - print ''."\n"; - if ($optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; +// List of mass actions available +$arrayofmassactions = array( + //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), + //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), + //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), +); +if (!empty($permissiontodelete)) { + $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); +} +if (!empty($permissiontoapprove)) { + $arrayofmassactions['preapproveleave'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Approve"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); - if ($id > 0) { - print ''; +print ''."\n"; +if ($optioncss != '') { + print ''; +} +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +if ($id > 0) { + print ''; +} + +if ($id > 0) { // For user tab + $title = $langs->trans("User"); + $linkback = ''.$langs->trans("BackToList").''; + $head = user_prepare_head($fuser); + + print dol_get_fiche_head($head, 'paidholidays', $title, -1, 'user'); + + dol_banner_tab($fuser, 'id', $linkback, $user->rights->user->user->lire || $user->admin); + + if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) { + print '
'; + + print '
'; + + showMyBalance($object, $user_id); } - if ($id > 0) { // For user tab - $title = $langs->trans("User"); - $linkback = ''.$langs->trans("BackToList").''; - $head = user_prepare_head($fuser); + print dol_get_fiche_end(); - print dol_get_fiche_head($head, 'paidholidays', $title, -1, 'user'); + // Buttons for actions - dol_banner_tab($fuser, 'id', $linkback, $user->rights->user->user->lire || $user->admin); + print '
'; - if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) { - print '
'; - - print '
'; - - showMyBalance($object, $user_id); - } - - print dol_get_fiche_end(); - - // Buttons for actions - - print '
'; - - $cancreate = 0; - if (!empty($user->rights->holiday->writeall)) { - $cancreate = 1; - } - if (!empty($user->rights->holiday->write) && in_array($user_id, $childids)) { - $cancreate = 1; - } - - if ($cancreate) { - print ''.$langs->trans("AddCP").''; - } - - print '
'; - } else { - $title = $langs->trans("ListeCP"); - - - $newcardbutton = ''; - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); - $newcardbutton .= dolGetButtonTitle($langs->trans('MenuAddCP'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/holiday/card.php?action=create', '', $user->rights->holiday->write); - - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_hrm', 0, $newcardbutton, '', $limit, 0, 0, 1); + $cancreate = 0; + if (!empty($user->rights->holiday->writeall)) { + $cancreate = 1; + } + if (!empty($user->rights->holiday->write) && in_array($user_id, $childids)) { + $cancreate = 1; } - $topicmail = "Information"; - $modelmail = "leaverequest"; - $objecttmp = new Holiday($db); - $trackid = 'leav'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - - if ($sall) { - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - } - print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; + if ($cancreate) { + print ''.$langs->trans("AddCP").''; } - $moreforfilter = ''; + print '
'; +} else { + $title = $langs->trans("ListeCP"); - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; - } else { - $moreforfilter = $hookmanager->resPrint; + + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitleSeparator(); + $newcardbutton .= dolGetButtonTitle($langs->trans('MenuAddCP'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/holiday/card.php?action=create', '', $user->rights->holiday->write); + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_hrm', 0, $newcardbutton, '', $limit, 0, 0, 1); +} + +$topicmail = "Information"; +$modelmail = "leaverequest"; +$objecttmp = new Holiday($db); +$trackid = 'leav'.$object->id; +include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + +if ($sall) { + $setupstring = ''; + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + $setupstring .= $key."=".$val.";"; + } + print ''."\n"; + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; +} + +$moreforfilter = ''; + +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} + +if (!empty($moreforfilter)) { + print '
'; + print $moreforfilter; + $parameters = array('type'=>$type); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
'; +} + +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +$include = ''; +if (empty($user->rights->holiday->readall)) { + $include = 'hierarchyme'; // Can see only its hierarchyl +} + +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print ''."\n"; + +// Fields title search +// -------------------------------------------------------------------- +print ''; +// Action column +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} +if (!empty($arrayfields['cp.ref']['checked'])) { + print ''; +} + +if (!empty($arrayfields['cp.fk_user']['checked'])) { + $morefilter = ''; + if (!empty($conf->global->HOLIDAY_HIDE_FOR_NON_SALARIES)) { + $morefilter = 'AND employee = 1'; } - if (!empty($moreforfilter)) { - print '
'; - print $moreforfilter; - print '
'; + // User + $disabled = 0; + // If into the tab holiday of a user ($id is set in such a case) + if ($id && !GETPOSTISSET('search_employee')) { + $search_employee = $id; + $disabled = 1; } - $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields - $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); - - - $include = ''; - if (empty($user->rights->holiday->readall)) { - $include = 'hierarchyme'; // Can see only its hierarchyl - } - - print '
'; - print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; + print ''; + print '
'."\n"; - - - // Filters - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - if (!empty($arrayfields['cp.ref']['checked'])) { - print ''; - } - - if (!empty($arrayfields['cp.fk_user']['checked'])) { - $morefilter = ''; - if (!empty($conf->global->HOLIDAY_HIDE_FOR_NON_SALARIES)) { - $morefilter = 'AND employee = 1'; - } - - // User - $disabled = 0; - // If into the tab holiday of a user ($id is set in such a case) - if ($id && !GETPOSTISSET('search_employee')) { - $search_employee = $id; - $disabled = 1; - } + print ''; +} +// Approver +if (!empty($arrayfields['cp.fk_validator']['checked'])) { + if ($user->hasRight('holiday', 'readall')) { print ''; - } - - // Approver - if (!empty($arrayfields['cp.fk_validator']['checked'])) { - if ($user->hasRight('holiday', 'readall')) { - print ''; - } else { - print ''; - } - } - - // Type - if (!empty($arrayfields['cp.fk_type']['checked'])) { - print ''; - } - - // Duration - if (!empty($arrayfields['duration']['checked'])) { + } else { print ''; } +} - // Start date - if (!empty($arrayfields['cp.date_debut']['checked'])) { - print ''; +// Type +if (!empty($arrayfields['cp.fk_type']['checked'])) { + print ''; +} - // End date - if (!empty($arrayfields['cp.date_fin']['checked'])) { - print ''; - } +// Duration +if (!empty($arrayfields['duration']['checked'])) { + print ''; +} - // Date validation - if (!empty($arrayfields['cp.date_valid']['checked'])) { - print ''; - } +// Start date +if (!empty($arrayfields['cp.date_debut']['checked'])) { + print ''; +} - // Date appoval - if (!empty($arrayfields['cp.date_approval']['checked'])) { - print ''; - } +// End date +if (!empty($arrayfields['cp.date_fin']['checked'])) { + print ''; +} - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields); - $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; +// Date validation +if (!empty($arrayfields['cp.date_valid']['checked'])) { + print ''; +} - // Create date - if (!empty($arrayfields['cp.date_create']['checked'])) { - print ''; - } +// Date appoval +if (!empty($arrayfields['cp.date_approval']['checked'])) { + print ''; +} - // Create date - if (!empty($arrayfields['cp.tms']['checked'])) { - print ''; - } +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - // Status - if (!empty($arrayfields['cp.statut']['checked'])) { - print ''; - } +// Fields from hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } +// Create date +if (!empty($arrayfields['cp.date_create']['checked'])) { + print ''; +} - print "\n"; +// Create date +if (!empty($arrayfields['cp.tms']['checked'])) { + print ''; +} - print ''; - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center '); - } - if (!empty($arrayfields['cp.ref']['checked'])) { - print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], "cp.ref", "", $param, '', $sortfield, $sortorder); - } - if (!empty($arrayfields['cp.fk_user']['checked'])) { - print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], "cp.fk_user", "", $param, '', $sortfield, $sortorder); - } - if (!empty($arrayfields['cp.fk_validator']['checked'])) { - print_liste_field_titre($arrayfields['cp.fk_validator']['label'], $_SERVER["PHP_SELF"], "cp.fk_validator", "", $param, '', $sortfield, $sortorder); - } - if (!empty($arrayfields['cp.fk_type']['checked'])) { - print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - } - if (!empty($arrayfields['duration']['checked'])) { - print_liste_field_titre($arrayfields['duration']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right maxwidth100'); - } - if (!empty($arrayfields['cp.date_debut']['checked'])) { - print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], "cp.date_debut", "", $param, '', $sortfield, $sortorder, 'center '); - } - if (!empty($arrayfields['cp.date_fin']['checked'])) { - print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], "cp.date_fin", "", $param, '', $sortfield, $sortorder, 'center '); - } - if (!empty($arrayfields['cp.date_valid']['checked'])) { - print_liste_field_titre($arrayfields['cp.date_valid']['label'], $_SERVER["PHP_SELF"], "cp.date_valid", "", $param, '', $sortfield, $sortorder, 'center '); - } - if (!empty($arrayfields['cp.date_approval']['checked'])) { - print_liste_field_titre($arrayfields['cp.date_approval']['label'], $_SERVER["PHP_SELF"], "cp.date_approval", "", $param, '', $sortfield, $sortorder, 'center '); - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - // Hook fields - $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); - $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (!empty($arrayfields['cp.date_create']['checked'])) { - print_liste_field_titre($arrayfields['cp.date_create']['label'], $_SERVER["PHP_SELF"], "cp.date_create", "", $param, '', $sortfield, $sortorder, 'center '); - } - if (!empty($arrayfields['cp.tms']['checked'])) { - print_liste_field_titre($arrayfields['cp.tms']['label'], $_SERVER["PHP_SELF"], "cp.tms", "", $param, '', $sortfield, $sortorder, 'center '); - } - if (!empty($arrayfields['cp.statut']['checked'])) { - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cp.statut", "", $param, '', $sortfield, $sortorder, 'right '); - } - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center '); - } - print "\n"; +// Status +if (!empty($arrayfields['cp.statut']['checked'])) { + print ''; +} - $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon")); +// Action column +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} + +print ''."\n"; + +$totalarray = array(); +$totalarray['nbfield'] = 0; + +// Fields title label +// -------------------------------------------------------------------- +print ''; +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; +} +if (!empty($arrayfields['cp.ref']['checked'])) { + print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], "cp.ref", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['cp.fk_user']['checked'])) { + print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], "cp.fk_user", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['cp.fk_validator']['checked'])) { + print_liste_field_titre($arrayfields['cp.fk_validator']['label'], $_SERVER["PHP_SELF"], "cp.fk_validator", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['cp.fk_type']['checked'])) { + print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['duration']['checked'])) { + print_liste_field_titre($arrayfields['duration']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right maxwidth100'); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['cp.date_debut']['checked'])) { + print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], "cp.date_debut", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['cp.date_fin']['checked'])) { + print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], "cp.date_fin", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['cp.date_valid']['checked'])) { + print_liste_field_titre($arrayfields['cp.date_valid']['label'], $_SERVER["PHP_SELF"], "cp.date_valid", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['cp.date_approval']['checked'])) { + print_liste_field_titre($arrayfields['cp.date_approval']['label'], $_SERVER["PHP_SELF"], "cp.date_approval", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (!empty($arrayfields['cp.date_create']['checked'])) { + print_liste_field_titre($arrayfields['cp.date_create']['label'], $_SERVER["PHP_SELF"], "cp.date_create", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['cp.tms']['checked'])) { + print_liste_field_titre($arrayfields['cp.tms']['label'], $_SERVER["PHP_SELF"], "cp.tms", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} +if (!empty($arrayfields['cp.statut']['checked'])) { + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cp.statut", "", $param, '', $sortfield, $sortorder, 'right '); + $totalarray['nbfield']++; +} +// Action column +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; +} +print ''."\n"; + +$listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->trans("Afternoon")); - // If we ask a dedicated card and not allow to see it, we force on user. - if ($id && empty($user->rights->holiday->readall) && !in_array($id, $childids)) { - $langs->load("errors"); - print ''; - $result = 0; - } elseif ($num > 0 && !empty($mysoc->country_id)) { - // Lines - $userstatic = new User($db); - $approbatorstatic = new User($db); +// Loop on record +// -------------------------------------------------------------------- - $typeleaves = $object->getTypes(1, -1); +// If we ask a dedicated card and not allow to see it, we force on user. +if ($id && empty($user->rights->holiday->readall) && !in_array($id, $childids)) { + $langs->load("errors"); + print ''; + $result = 0; +} elseif ($num > 0 && !empty($mysoc->country_id)) { + // Lines + $userstatic = new User($db); + $approbatorstatic = new User($db); - $i = 0; - $totalarray = array(); - $totalarray['nbfield'] = 0; - $totalduration = 0; - $imaxinloop = ($limit ? min($num, $limit) : $num); - while ($i < $imaxinloop) { - $obj = $db->fetch_object($resql); + $typeleaves = $object->getTypes(1, -1); - // Leave request - $holidaystatic->id = $obj->rowid; - $holidaystatic->ref = ($obj->ref ? $obj->ref : $obj->rowid); - $holidaystatic->statut = $obj->status; - $holidaystatic->date_debut = $obj->date_debut; - $holidaystatic->date_fin = $obj->date_fin; + $i = 0; + $savnbfield = $totalarray['nbfield']; + $totalarray = array(); + $totalarray['nbfield'] = 0; + $totalduration = 0; + $imaxinloop = ($limit ? min($num, $limit) : $num); + while ($i < $imaxinloop) { + $obj = $db->fetch_object($resql); + if (empty($obj)) { + break; // Should not happen + } - // User - $userstatic->id = $obj->fk_user; - $userstatic->lastname = $obj->user_lastname; - $userstatic->firstname = $obj->user_firstname; - $userstatic->admin = $obj->user_admin; - $userstatic->email = $obj->user_email; - $userstatic->login = $obj->user_login; - $userstatic->statut = $obj->user_status; - $userstatic->photo = $obj->user_photo; + // Leave request + $holidaystatic->id = $obj->rowid; + $holidaystatic->ref = ($obj->ref ? $obj->ref : $obj->rowid); + $holidaystatic->statut = $obj->status; + $holidaystatic->date_debut = $obj->date_debut; + $holidaystatic->date_fin = $obj->date_fin; - // Validator - $approbatorstatic->id = $obj->fk_validator; - $approbatorstatic->lastname = $obj->validator_lastname; - $approbatorstatic->firstname = $obj->validator_firstname; - $approbatorstatic->admin = $obj->validator_admin; - $approbatorstatic->email = $obj->validator_email; - $approbatorstatic->login = $obj->validator_login; - $approbatorstatic->statut = $obj->validator_status; - $approbatorstatic->photo = $obj->validator_photo; + // User + $userstatic->id = $obj->fk_user; + $userstatic->lastname = $obj->user_lastname; + $userstatic->firstname = $obj->user_firstname; + $userstatic->admin = $obj->user_admin; + $userstatic->email = $obj->user_email; + $userstatic->login = $obj->user_login; + $userstatic->statut = $obj->user_status; + $userstatic->photo = $obj->user_photo; - $date = $obj->date_create; - $date_modif = $obj->date_update; + // Validator + $approbatorstatic->id = $obj->fk_validator; + $approbatorstatic->lastname = $obj->validator_lastname; + $approbatorstatic->firstname = $obj->validator_firstname; + $approbatorstatic->admin = $obj->validator_admin; + $approbatorstatic->email = $obj->validator_email; + $approbatorstatic->login = $obj->validator_login; + $approbatorstatic->statut = $obj->validator_status; + $approbatorstatic->photo = $obj->validator_photo; - $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning'; - $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon'; + $date = $obj->date_create; + $date_modif = $obj->date_update; - $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); // user jdate(..., 1) because num_open_day need UTC dates - $totalduration += $nbopenedday; + $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning'; + $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon'; - if ($mode == 'kanban') { - if ($i == 0) { - print ''; + } + } else { + // Show here line of result + $j = 0; + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; - } - } else { - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - if (!empty($arrayfields['cp.ref']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.fk_user']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.fk_validator']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.fk_type']['checked'])) { - if (empty($typeleaves[$obj->fk_type])) { - $labeltypeleavetoshow = $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type); - } else { - $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']); - } - - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['duration']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.date_debut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.date_fin']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date validation - if (!empty($arrayfields['cp.date_valid']['checked'])) { // date_valid is both date_valid but also date_approval - print ''; - if (!$i) $totalarray['nbfield']++; - } - // Date approval - if (!empty($arrayfields['cp.date_approval']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Date creation - if (!empty($arrayfields['cp.date_create']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.statut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + print ''; } + print ''; if (!$i) { $totalarray['nbfield']++; } - - print ''."\n"; } - $i++; - } - - // Add a line for total if there is a total to show - if (!empty($arrayfields['duration']['checked'])) { - print ''; - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { - if ($key == 'duration') { - print ''; - } else { - print ''; - } + if (!empty($arrayfields['cp.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; } } - // status - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + if (!empty($arrayfields['cp.fk_user']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; + if (!empty($arrayfields['cp.fk_validator']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.fk_type']['checked'])) { + if (empty($typeleaves[$obj->fk_type])) { + $labeltypeleavetoshow = $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type); + } else { + $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']); + } + + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['duration']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.date_debut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.date_fin']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date validation + if (!empty($arrayfields['cp.date_valid']['checked'])) { // date_valid is both date_valid but also date_approval + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Date approval + if (!empty($arrayfields['cp.date_approval']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Date creation + if (!empty($arrayfields['cp.date_create']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.statut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + print ''."\n"; } + $i++; } - // Si il n'y a pas d'enregistrement suite à une recherche - if ($num == 0) { - $colspan = 1; + // Add a line for total if there is a total to show + if (!empty($arrayfields['duration']['checked'])) { + print ''; + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) { - $colspan++; + if ($key == 'duration') { + print ''; + } else { + print ''; + } } } - print ''; + // status + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + print ''; } - - print '
'; - $searchpicto = $form->showFilterButtons('left'); - print $searchpicto; - print ''; - print ''; - print ''; + print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, $include, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth125'); + print ''; - print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, $include, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth125'); - print ''; - $validator = new UserGroup($db); - $excludefilter = $user->admin ? '' : 'u.rowid <> '.$user->id; - $valideurobjects = $validator->listUsersForGroup($excludefilter, 1); - $valideurarray = array(); - foreach ($valideurobjects as $val) { - $valideurarray[$val] = $val; - } - print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth125'); - print ' '; - if (empty($mysoc->country_id)) { - setEventMessages(null, array($langs->trans("ErrorSetACountryFirst"), $langs->trans("CompanyFoundation")), 'errors'); - } else { - $typeleaves = $holidaystatic->getTypes(1, -1); - $arraytypeleaves = array(); - foreach ($typeleaves as $key => $val) { - $labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']); - //$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':''); - $arraytypeleaves[$val['rowid']] = $labeltoshow; - } - print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1); + $validator = new UserGroup($db); + $excludefilter = $user->admin ? '' : 'u.rowid <> '.$user->id; + $valideurobjects = $validator->listUsersForGroup($excludefilter, 1); + $valideurarray = array(); + foreach ($valideurobjects as $val) { + $valideurarray[$val] = $val; } + print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth125'); print ' '; - print ''; - print $formother->selectyear($search_year_start, 'search_year_start', 1, $min_year, $max_year); - print ''; + if (empty($mysoc->country_id)) { + setEventMessages(null, array($langs->trans("ErrorSetACountryFirst"), $langs->trans("CompanyFoundation")), 'errors'); + } else { + $typeleaves = $holidaystatic->getTypes(1, -1); + $arraytypeleaves = array(); + foreach ($typeleaves as $key => $val) { + $labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']); + //$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':''); + $arraytypeleaves[$val['rowid']] = $labeltoshow; + } + print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1); } + print ''; - print ''; - print $formother->selectyear($search_year_end, 'search_year_end', 1, $min_year, $max_year); - print ' '; - print ''; + print ''; + print $formother->selectyear($search_year_start, 'search_year_start', 1, $min_year, $max_year); + print ''; - print ''; + print ''; + print $formother->selectyear($search_year_end, 'search_year_end', 1, $min_year, $max_year); + print ''; + print ''; - print ''; - print $formother->selectyear($search_year_create, 'search_year_create', 1, $min_year, 0); - print ''; + print ''; - print ''; - print $formother->selectyear($search_year_update, 'search_year_update', 1, $min_year, 0); - print ''; - $object->selectStatutCP($search_status, 'search_status', 'minwidth125'); - print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print ''; + print ''; + print $formother->selectyear($search_year_create, 'search_year_create', 1, $min_year, 0); + print '
'; + print ''; + print $formother->selectyear($search_year_update, 'search_year_update', 1, $min_year, 0); + print '
'; + print $object->selectStatutCP($search_status, 'search_status', 'search_status width100 onrightofpage'); + print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'.$langs->trans("NotEnoughPermissions").'
'.$langs->trans("NotEnoughPermissions").'
'; - print '
'; + $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); // user jdate(..., 1) because num_open_day need UTC dates + $totalduration += $nbopenedday; + + if ($mode == 'kanban') { + if ($i == 0) { + print '
'; + print '
'; + } + + $holidaystatic->fk_type = $typeleaves[$obj->fk_type]['rowid']; + + // Output Kanban + if ($massactionbutton || $massaction) { + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + if (empty($typeleaves[$obj->fk_type])) { + $labeltypeleavetoshow = $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type); + } else { + $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']); } - $holidaystatic->fk_type = $typeleaves[$obj->fk_type]['rowid']; - - // Output Kanban - if ($massactionbutton || $massaction) { + $arraydata = array('user'=>$userstatic, 'labeltype'=>$labeltypeleavetoshow); + } + print $holidaystatic->getKanbanView('', $arraydata); + if ($i == ($imaxinloop - 1)) { + print '
'; + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($object->id, $arrayofselected)) { + if (in_array($obj->rowid, $arrayofselected)) { $selected = 1; } - if (empty($typeleaves[$obj->fk_type])) { - $labeltypeleavetoshow = $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type); - } else { - $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']); - } - - $arraydata = array('user'=>$userstatic, 'labeltype'=>$labeltypeleavetoshow); - print $holidaystatic->getKanbanView('', $arraydata); - } - if ($i == ($imaxinloop - 1)) { - print ''; - print '
'; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - print $holidaystatic->getNomUrl(1, 1); - print ''.$userstatic->getNomUrl(-1, 'leave').''.$approbatorstatic->getNomUrl(-1).''; - print $labeltypeleavetoshow; - print ''; - $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); // user jdate(..., 1) because num_open_day need UTC dates - $totalduration += $nbopenedday; - print $nbopenedday; - //print ' '.$langs->trans('DurationDays'); - print ''; - print dol_print_date($db->jdate($obj->date_debut), 'day'); - print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; - print ''; - print dol_print_date($db->jdate($obj->date_fin), 'day'); - print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; - print ''; - print dol_print_date($db->jdate($obj->date_valid), 'day'); - print ''; - print dol_print_date($db->jdate($obj->date_approval), 'day'); - print ''.dol_print_date($date, 'dayhour').''.dol_print_date($date_modif, 'dayhour').''.$holidaystatic->getLibStatut(5).''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print '
'.$totalduration.' '.$langs->trans('DurationDays').''; + print $holidaystatic->getNomUrl(1, 1); + print ''.$userstatic->getNomUrl(-1, 'leave').'
'.$approbatorstatic->getNomUrl(-1).''; + print $labeltypeleavetoshow; + print ''; + $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); // user jdate(..., 1) because num_open_day need UTC dates + $totalduration += $nbopenedday; + print $nbopenedday; + //print ' '.$langs->trans('DurationDays'); + print ''; + print dol_print_date($db->jdate($obj->date_debut), 'day'); + print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; + print ''; + print dol_print_date($db->jdate($obj->date_fin), 'day'); + print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; + print ''; + print dol_print_date($db->jdate($obj->date_valid), 'day'); + print ''; + print dol_print_date($db->jdate($obj->date_approval), 'day'); + print ''.dol_print_date($date, 'dayhour').''.dol_print_date($date_modif, 'dayhour').''.$holidaystatic->getLibStatut(5).''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'.$totalduration.' '.$langs->trans('DurationDays').'
'.$langs->trans("NoRecordFound").'
'; - print '
'; - - print ''; -} else { - dol_print_error($db); } +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''.$langs->trans("NoRecordFound").''; +} + +$db->free($resql); + +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print ''."\n"; +print '
'."\n"; + +print ''."\n"; + // End of page llxFooter(); $db->close(); From 8208884af4bffa25e7b79e332a1e4cf7085c0c11 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Mar 2023 09:45:47 +0100 Subject: [PATCH 73/84] Work on kanban views --- htdocs/holiday/class/holiday.class.php | 2 +- htdocs/holiday/list.php | 8 ++++---- htdocs/modulebuilder/template/myobject_list.php | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 93e443bad69..f3c7130e7f8 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -2490,7 +2490,7 @@ class Holiday extends CommonObject $return .= ''; if (property_exists($this, 'fk_type')) { $return .= '
'.$langs->trans("Type").' : '; - $return .= ''.arraydata['labeltype'].''; + $return .= ''.$arraydata['labeltype'].''; } if (property_exists($this, 'date_debut') && property_exists($this, 'date_fin')) { $return .= '
'.dol_print_date($this->date_debut, 'day').''; diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index ed5c222f7c8..42556f8704c 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -582,7 +582,7 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields +$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); $include = ''; @@ -745,7 +745,7 @@ $totalarray['nbfield'] = 0; // -------------------------------------------------------------------- print ''; if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; $totalarray['nbfield']++; } if (!empty($arrayfields['cp.ref']['checked'])) { @@ -804,7 +804,7 @@ if (!empty($arrayfields['cp.statut']['checked'])) { } // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; $totalarray['nbfield']++; } print ''."\n"; @@ -1048,7 +1048,7 @@ if ($id && empty($user->rights->holiday->readall) && !in_array($id, $childids)) } // Add a line for total if there is a total to show - if (!empty($arrayfields['duration']['checked'])) { + if ($mode != 'kanban' && !empty($arrayfields['duration']['checked'])) { print ''; if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index ec5d8c979ed..7a3aae33d9c 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -554,7 +554,7 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields +$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table @@ -631,7 +631,7 @@ $totalarray['nbfield'] = 0; // -------------------------------------------------------------------- print ''; if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; $totalarray['nbfield']++; } foreach ($object->fields as $key => $val) { @@ -663,7 +663,7 @@ print $hookmanager->resPrint; }*/ // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; $totalarray['nbfield']++; } print ''."\n"; From f84a8361bc27004b78fb394462a1f62e37f5c74b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Mar 2023 10:05:00 +0100 Subject: [PATCH 74/84] Look and feel v18 --- htdocs/core/lib/payments.lib.php | 10 ++++++---- htdocs/holiday/list.php | 2 +- htdocs/public/users/view.php | 2 -- htdocs/ticket/card.php | 6 ++++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index db1d0a13db6..93c7a17de2f 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -146,7 +146,7 @@ function payment_supplier_prepare_head(Paiement $object) */ function getValidOnlinePaymentMethods($paymentmethod = '') { - global $conf, $langs, $hookmanager, $action; + global $langs, $hookmanager, $action; $validpaymentmethod = array(); @@ -434,6 +434,8 @@ function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, { global $conf; + $reg = array(); + // Juridical status $line1 = ""; if ($fromcompany->forme_juridique_code) { @@ -485,9 +487,8 @@ function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, print ''."\n"; + print '
'."\n"; print '
'; - - print '
'."\n"; if ($addformmessage) { print ''; print '
'; @@ -519,5 +520,6 @@ function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, print ' - '; } print $line2; - print '
'."\n"; + print ''; + print '
'."\n"; } diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 42556f8704c..0be113d8205 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -881,7 +881,7 @@ if ($id && empty($user->rights->holiday->readall) && !in_array($id, $childids)) print '
'; } - $holidaystatic->fk_type = $typeleaves[$obj->fk_type]['rowid']; + $holidaystatic->fk_type = empty($typeleaves[$obj->fk_type]['rowid']) ? 0 : $typeleaves[$obj->fk_type]['rowid']; // Output Kanban if ($massactionbutton || $massaction) { diff --git a/htdocs/public/users/view.php b/htdocs/public/users/view.php index 0eaeb1b6c8f..30b76404472 100644 --- a/htdocs/public/users/view.php +++ b/htdocs/public/users/view.php @@ -451,8 +451,6 @@ print '
'."\n"; print '
'; -//htmlPrintOnlinePaymentFooter($mysoc, $langs); - print '
'; print '
'; print ''; diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 42afd27304b..8e2114f9bae 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -1248,10 +1248,12 @@ if ($action == 'create' || $action == 'presend') { } print ''; // Group - print ''.$langs->trans("TicketCategory").''; + $s = ''; if (!empty($object->category_code)) { - print $langs->getLabelFromKey($db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code); + $s = $langs->getLabelFromKey($db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code); } + print ''.$langs->trans("TicketCategory").''; + print dol_escape_htmltag($s); print ''; // Severity print ''.$langs->trans("TicketSeverity").''; From 2ef0f08c97df0263b3198b69f4a73df10900bfe1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Mar 2023 10:20:03 +0100 Subject: [PATCH 75/84] PHPunit --- test/phpunit/FunctionsLibTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 11eff71d4c6..7508c539208 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -180,7 +180,7 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase // An attempt for SQL injection $filter='if(now()=sysdate()%2Csleep(6)%2C0)'; $sql = forgeSQLFromUniversalSearchCriteria($filter); - $this->assertEquals($sql, '1 = 3'); + $this->assertEquals($sql, 'Filter syntax error'); // A real search string $filter='(((statut:=:1) or (entity:in:__AAA__)) and (abc:<:2.0) and (abc:!=:1.23))'; From 04c6cb22a15e545f99c190da8a9211c8ac62999c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Mar 2023 10:22:40 +0100 Subject: [PATCH 76/84] Fix universal filter for != --- htdocs/core/lib/functions.lib.php | 2 +- test/phpunit/FunctionsLibTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 74947d9dd71..4eeb5994334 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -11685,7 +11685,7 @@ function dolForgeCriteriaCallback($matches) return ''; } - $operator = strtoupper(preg_replace('/[^a-z<>=]/i', '', trim($tmp[1]))); + $operator = strtoupper(preg_replace('/[^a-z<>=!]/i', '', trim($tmp[1]))); if ($operator == 'NOTLIKE') { $operator = 'NOT LIKE'; } diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 7508c539208..f398aef1050 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -185,7 +185,7 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase // A real search string $filter='(((statut:=:1) or (entity:in:__AAA__)) and (abc:<:2.0) and (abc:!=:1.23))'; $sql = forgeSQLFromUniversalSearchCriteria($filter); - $this->assertEquals($sql, ' AND (((statut = 1 or entity IN (__AAA__)) and abc < 2 and abc = 1.23))'); + $this->assertEquals($sql, ' AND (((statut = 1 or entity IN (__AAA__)) and abc < 2 and abc <> 1.23))'); $filter="(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.date_creation:<:'2016-01-01 12:30:00') or (t.nature:is:NULL)"; $sql = forgeSQLFromUniversalSearchCriteria($filter); From d369a640de4752fce27091bf0685b5fcfb6df2b5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Mar 2023 12:48:25 +0100 Subject: [PATCH 77/84] Fix encryption of api_key --- htdocs/api/class/api_access.class.php | 10 ++++++---- htdocs/api/class/api_login.class.php | 3 ++- htdocs/core/lib/security.lib.php | 12 ++++++++++-- htdocs/user/class/user.class.php | 6 ++++-- htdocs/user/list.php | 9 ++++++--- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 7839cf14efc..d54b5771514 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -113,15 +113,15 @@ class DolibarrApiAccess implements iAuthenticate $sql = "SELECT u.login, u.datec, u.api_key, "; $sql .= " u.tms as date_modification, u.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE u.api_key = '".$this->db->escape($api_key)."'"; - // TODO Check if 2 users has same API key. + $sql .= " WHERE u.api_key = '".$this->db->escape($api_key)."' OR u.api_key = '".$this->db->escape(dolEncrypt($api_key, '', '', 'dolibarr'))."'"; $result = $this->db->query($sql); if ($result) { - if ($this->db->num_rows($result)) { + $nbrows = $this->db->num_rows($result); + if ($nbrows == 1) { $obj = $this->db->fetch_object($result); $login = $obj->login; - $stored_key = $obj->api_key; + $stored_key = dolDecrypt($obj->api_key); $userentity = $obj->entity; if (!defined("DOLENTITY") && $conf->entity != ($obj->entity ? $obj->entity : 1)) { // If API was not forced with HTTP_DOLENTITY, and user is on another entity, so we reset entity to entity of user @@ -130,6 +130,8 @@ class DolibarrApiAccess implements iAuthenticate dol_syslog("Entity was not set on http header with HTTP_DOLAPIENTITY (recommanded for performance purpose), so we switch now on entity of user (".$conf->entity.") and we have to reload configuration.", LOG_WARNING); $conf->setValues($this->db); } + } elseif ($nbrows > 1) { + throw new RestException(503, 'Error when fetching user api_key : More than 1 user with this apikey'); } } else { throw new RestException(503, 'Error when fetching user api_key :'.$this->db->error_msg); diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index d5362f4ac56..bf4f7ffd318 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -18,6 +18,7 @@ use Luracast\Restler\RestException; +require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; /** @@ -149,7 +150,7 @@ class Login // We store API token into database $sql = "UPDATE ".MAIN_DB_PREFIX."user"; - $sql .= " SET api_key = '".$this->db->escape($token)."'"; + $sql .= " SET api_key = '".$this->db->escape(dolEncrypt($token, '', '', 'dolibarr'))."'"; $sql .= " WHERE login = '".$this->db->escape($login)."'"; dol_syslog(get_class($this)."::login", LOG_DEBUG); // No log diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 5a610090be2..7ee9f7ce9b5 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -113,10 +113,11 @@ function dolGetRandomBytes($length) * @param string $chain string to encode * @param string $key If '', we use $dolibarr_main_instance_unique_id * @param string $ciphering Default ciphering algorithm + * @param string $forceseed To force the seed * @return string encoded string * @see dolDecrypt(), dol_hash() */ -function dolEncrypt($chain, $key = '', $ciphering = "AES-256-CTR") +function dolEncrypt($chain, $key = '', $ciphering = 'AES-256-CTR', $forceseed = '') { global $dolibarr_main_instance_unique_id; global $dolibarr_disable_dolcrypt_for_debug; @@ -134,6 +135,9 @@ function dolEncrypt($chain, $key = '', $ciphering = "AES-256-CTR") if (empty($key)) { $key = $dolibarr_main_instance_unique_id; } + if (empty($ciphering)) { + $ciphering = 'AES-256-CTR'; + } $newchain = $chain; @@ -145,7 +149,11 @@ function dolEncrypt($chain, $key = '', $ciphering = "AES-256-CTR") if ($ivlen === false || $ivlen < 1 || $ivlen > 32) { $ivlen = 16; } - $ivseed = dolGetRandomBytes($ivlen); + if (empty($forceseed)) { + $ivseed = dolGetRandomBytes($ivlen); + } else { + $ivseed = dol_trunc(md5($forceseed), $ivlen, 'right', 'UTF-8', 1); + } $newchain = openssl_encrypt($chain, $ciphering, $key, 0, $ivseed); return 'dolcrypt:'.$ciphering.':'.$ivseed.':'.$newchain; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 46b4b12a25e..5bea5b9f754 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -35,9 +35,11 @@ * \ingroup core */ +require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; + /** * Class to manage Dolibarr users */ @@ -526,7 +528,7 @@ class User extends CommonObject $this->pass_indatabase_crypted = $obj->pass_crypted; $this->pass = $obj->pass; $this->pass_temp = $obj->pass_temp; - $this->api_key = $obj->api_key; + $this->api_key = dolDecrypt($obj->api_key); $this->address = $obj->address; $this->zip = $obj->zip; @@ -1977,7 +1979,7 @@ class User extends CommonObject $sql .= ", national_registration_number = '".$this->db->escape($this->national_registration_number)."'"; $sql .= ", employee = ".(int) $this->employee; $sql .= ", login = '".$this->db->escape($this->login)."'"; - $sql .= ", api_key = ".($this->api_key ? "'".$this->db->escape($this->api_key)."'" : "null"); + $sql .= ", api_key = ".($this->api_key ? "'".$this->db->escape(dolEncrypt($this->api_key, '', '', 'dolibarr'))."'" : "null"); $sql .= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman' $sql .= ", birth=".(strval($this->birth) != '' ? "'".$this->db->idate($this->birth, 'tzserver')."'" : 'null'); if (!empty($user->admin)) { diff --git a/htdocs/user/list.php b/htdocs/user/list.php index a269a93fb7b..19022cceccf 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -1127,10 +1127,13 @@ while ($i < $imaxinloop) { } } if (!empty($arrayfields['u.api_key']['checked'])) { - print ''; - if ($obj->api_key) { + $api_key = dolDecrypt($obj->api_key); + print ''; + if ($api_key) { if ($canreadsecretapi) { - print dol_escape_htmltag($obj->api_key); + print ''; + print showValueWithClipboardCPButton($object->api_key, 1, dol_trunc($api_key, 3)); // TODO Add an option to also reveal the hash, not only copy paste + print ''; } else { print ''.$langs->trans("Hidden").''; } From f29d5c784401f0adef68c9de4a4cadd659edae38 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Mar 2023 13:17:49 +0100 Subject: [PATCH 78/84] Bettr order for mass action --- htdocs/commande/list.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 177f68a1fbb..c665166b0af 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -223,6 +223,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +$error = 0; /* @@ -1284,24 +1285,24 @@ if ($resql) { if ($permissiontovalidate) { $arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"); } - if ($permissiontosendbymail) { - $arrayofmassactions['presend'] = img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"); - } if ($permissiontoclose) { $arrayofmassactions['preshipped'] = img_picto('', 'dollyrevert', 'class="pictofixedwidth"').$langs->trans("ClassifyShipped"); } - if ($permissiontocancel) { - $arrayofmassactions['cancelorders'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"); - } - if (isModEnabled('facture') && $user->hasRight("facture", "creer")) { - $arrayofmassactions['createbills'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("CreateInvoiceForThisCustomer"); - } if ($permissiontoclose) { $arrayofmassactions['setbilled'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("ClassifyBilled"); } + if ($permissiontocancel) { + $arrayofmassactions['cancelorders'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"); + } if ($permissiontodelete) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } + if (isModEnabled('facture') && $user->hasRight("facture", "creer")) { + $arrayofmassactions['createbills'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("CreateInvoiceForThisCustomer"); + } + if ($permissiontosendbymail) { + $arrayofmassactions['presend'] = img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"); + } if (in_array($massaction, array('presend', 'predelete', 'createbills'))) { $arrayofmassactions = array(); } From dc1ba8f447b8ceb02f14042e04c25fa7c0be0e3b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Mar 2023 13:19:24 +0100 Subject: [PATCH 79/84] Fix phpunit --- test/phpunit/FunctionsLibTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index d910a9f9d57..92b75c5aa97 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -185,7 +185,7 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase // A real search string $filter='(((statut:=:1) or (entity:in:__AAA__)) and (abc:<:2.0) and (abc:!=:1.23))'; $sql = forgeSQLFromUniversalSearchCriteria($filter); - $this->assertEquals($sql, ' AND (((statut = 1 or entity IN (__AAA__)) and abc < 2 and abc = 1.23))'); + $this->assertEquals($sql, ' AND (((statut = 1 or entity IN (__AAA__)) and abc < 2 and abc <> 1.23))'); $filter="(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.date_creation:<:'2016-01-01 12:30:00') or (t.nature:is:NULL)"; $sql = forgeSQLFromUniversalSearchCriteria($filter); From 7a1404c4430cbda3a65f4486672239865d03dd83 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Mar 2023 13:21:48 +0100 Subject: [PATCH 80/84] Fix sql --- .../install/mysql/data/llx_00_c_country.sql | 498 +++++++++--------- 1 file changed, 249 insertions(+), 249 deletions(-) diff --git a/htdocs/install/mysql/data/llx_00_c_country.sql b/htdocs/install/mysql/data/llx_00_c_country.sql index bbc0be55335..829d6ffe8cb 100644 --- a/htdocs/install/mysql/data/llx_00_c_country.sql +++ b/htdocs/install/mysql/data/llx_00_c_country.sql @@ -279,255 +279,255 @@ INSERT INTO llx_c_country (rowid, code, code_iso, label, active, favorite) VALUE -UPDATE llx_c_country SET numeric_code = '004' WHERE code_iso = "AFG"; -UPDATE llx_c_country SET numeric_code = '248' WHERE code_iso = "ALA"; -UPDATE llx_c_country SET numeric_code = '008' WHERE code_iso = "ALB"; -UPDATE llx_c_country SET numeric_code = '276' WHERE code_iso = "DEU"; -UPDATE llx_c_country SET numeric_code = '020' WHERE code_iso = "AND"; -UPDATE llx_c_country SET numeric_code = '024' WHERE code_iso = "AGO"; -UPDATE llx_c_country SET numeric_code = '660' WHERE code_iso = "AIA"; -UPDATE llx_c_country SET numeric_code = '010' WHERE code_iso = "ATA"; -UPDATE llx_c_country SET numeric_code = '028' WHERE code_iso = "ATG"; -UPDATE llx_c_country SET numeric_code = '682' WHERE code_iso = "SAU"; -UPDATE llx_c_country SET numeric_code = '012' WHERE code_iso = "DZA"; -UPDATE llx_c_country SET numeric_code = '032' WHERE code_iso = "ARG"; -UPDATE llx_c_country SET numeric_code = '051' WHERE code_iso = "ARM"; -UPDATE llx_c_country SET numeric_code = '533' WHERE code_iso = "ABW"; -UPDATE llx_c_country SET numeric_code = '036' WHERE code_iso = "AUS"; -UPDATE llx_c_country SET numeric_code = '040' WHERE code_iso = "AUT"; -UPDATE llx_c_country SET numeric_code = '031' WHERE code_iso = "AZE"; -UPDATE llx_c_country SET numeric_code = '044' WHERE code_iso = "BHS"; -UPDATE llx_c_country SET numeric_code = '050' WHERE code_iso = "BGD"; -UPDATE llx_c_country SET numeric_code = '052' WHERE code_iso = "BRB"; -UPDATE llx_c_country SET numeric_code = '048' WHERE code_iso = "BHR"; -UPDATE llx_c_country SET numeric_code = '056' WHERE code_iso = "BEL"; -UPDATE llx_c_country SET numeric_code = '084' WHERE code_iso = "BLZ"; -UPDATE llx_c_country SET numeric_code = '204' WHERE code_iso = "BEN"; -UPDATE llx_c_country SET numeric_code = '060' WHERE code_iso = "BMU"; -UPDATE llx_c_country SET numeric_code = '112' WHERE code_iso = "BLR"; -UPDATE llx_c_country SET numeric_code = '068' WHERE code_iso = "BOL"; -UPDATE llx_c_country SET numeric_code = '535' WHERE code_iso = "BES"; -UPDATE llx_c_country SET numeric_code = '070' WHERE code_iso = "BIH"; -UPDATE llx_c_country SET numeric_code = '072' WHERE code_iso = "BWA"; -UPDATE llx_c_country SET numeric_code = '076' WHERE code_iso = "BRA"; -UPDATE llx_c_country SET numeric_code = '096' WHERE code_iso = "BRN"; -UPDATE llx_c_country SET numeric_code = '100' WHERE code_iso = "BGR"; -UPDATE llx_c_country SET numeric_code = '854' WHERE code_iso = "BFA"; -UPDATE llx_c_country SET numeric_code = '108' WHERE code_iso = "BDI"; -UPDATE llx_c_country SET numeric_code = '064' WHERE code_iso = "BTN"; -UPDATE llx_c_country SET numeric_code = '132' WHERE code_iso = "CPV"; -UPDATE llx_c_country SET numeric_code = '116' WHERE code_iso = "KHM"; -UPDATE llx_c_country SET numeric_code = '120' WHERE code_iso = "CMR"; -UPDATE llx_c_country SET numeric_code = '124' WHERE code_iso = "CAN"; -UPDATE llx_c_country SET numeric_code = '634' WHERE code_iso = "QAT"; -UPDATE llx_c_country SET numeric_code = '148' WHERE code_iso = "TCD"; -UPDATE llx_c_country SET numeric_code = '152' WHERE code_iso = "CHL"; -UPDATE llx_c_country SET numeric_code = '156' WHERE code_iso = "CHN"; -UPDATE llx_c_country SET numeric_code = '196' WHERE code_iso = "CYP"; -UPDATE llx_c_country SET numeric_code = '170' WHERE code_iso = "COL"; -UPDATE llx_c_country SET numeric_code = '174' WHERE code_iso = "COM"; -UPDATE llx_c_country SET numeric_code = '408' WHERE code_iso = "PRK"; -UPDATE llx_c_country SET numeric_code = '410' WHERE code_iso = "KOR"; -UPDATE llx_c_country SET numeric_code = '384' WHERE code_iso = "CIV"; -UPDATE llx_c_country SET numeric_code = '188' WHERE code_iso = "CRI"; -UPDATE llx_c_country SET numeric_code = '191' WHERE code_iso = "HRV"; -UPDATE llx_c_country SET numeric_code = '192' WHERE code_iso = "CUB"; -UPDATE llx_c_country SET numeric_code = '531' WHERE code_iso = "CUW"; -UPDATE llx_c_country SET numeric_code = '208' WHERE code_iso = "DNK"; -UPDATE llx_c_country SET numeric_code = '212' WHERE code_iso = "DMA"; -UPDATE llx_c_country SET numeric_code = '218' WHERE code_iso = "ECU"; -UPDATE llx_c_country SET numeric_code = '818' WHERE code_iso = "EGY"; -UPDATE llx_c_country SET numeric_code = '222' WHERE code_iso = "SLV"; -UPDATE llx_c_country SET numeric_code = '784' WHERE code_iso = "ARE"; -UPDATE llx_c_country SET numeric_code = '232' WHERE code_iso = "ERI"; -UPDATE llx_c_country SET numeric_code = '703' WHERE code_iso = "SVK"; -UPDATE llx_c_country SET numeric_code = '705' WHERE code_iso = "SVN"; -UPDATE llx_c_country SET numeric_code = '724' WHERE code_iso = "ESP"; -UPDATE llx_c_country SET numeric_code = '840' WHERE code_iso = "USA"; -UPDATE llx_c_country SET numeric_code = '233' WHERE code_iso = "EST"; -UPDATE llx_c_country SET numeric_code = '231' WHERE code_iso = "ETH"; -UPDATE llx_c_country SET numeric_code = '608' WHERE code_iso = "PHL"; -UPDATE llx_c_country SET numeric_code = '246' WHERE code_iso = "FIN"; -UPDATE llx_c_country SET numeric_code = '242' WHERE code_iso = "FJI"; -UPDATE llx_c_country SET numeric_code = '250' WHERE code_iso = "FRA"; -UPDATE llx_c_country SET numeric_code = '266' WHERE code_iso = "GAB"; -UPDATE llx_c_country SET numeric_code = '270' WHERE code_iso = "GMB"; -UPDATE llx_c_country SET numeric_code = '268' WHERE code_iso = "GEO"; -UPDATE llx_c_country SET numeric_code = '288' WHERE code_iso = "GHA"; -UPDATE llx_c_country SET numeric_code = '292' WHERE code_iso = "GIB"; -UPDATE llx_c_country SET numeric_code = '308' WHERE code_iso = "GRD"; -UPDATE llx_c_country SET numeric_code = '300' WHERE code_iso = "GRC"; -UPDATE llx_c_country SET numeric_code = '304' WHERE code_iso = "GRL"; -UPDATE llx_c_country SET numeric_code = '312' WHERE code_iso = "GLP"; -UPDATE llx_c_country SET numeric_code = '316' WHERE code_iso = "GUM"; -UPDATE llx_c_country SET numeric_code = '320' WHERE code_iso = "GTM"; -UPDATE llx_c_country SET numeric_code = '254' WHERE code_iso = "GUF"; -UPDATE llx_c_country SET numeric_code = '831' WHERE code_iso = "GGY"; -UPDATE llx_c_country SET numeric_code = '324' WHERE code_iso = "GIN"; -UPDATE llx_c_country SET numeric_code = '624' WHERE code_iso = "GNB"; -UPDATE llx_c_country SET numeric_code = '226' WHERE code_iso = "GNQ"; -UPDATE llx_c_country SET numeric_code = '328' WHERE code_iso = "GUY"; -UPDATE llx_c_country SET numeric_code = '332' WHERE code_iso = "HTI"; -UPDATE llx_c_country SET numeric_code = '340' WHERE code_iso = "HND"; -UPDATE llx_c_country SET numeric_code = '344' WHERE code_iso = "HKG"; -UPDATE llx_c_country SET numeric_code = '348' WHERE code_iso = "HUN"; -UPDATE llx_c_country SET numeric_code = '356' WHERE code_iso = "IND"; -UPDATE llx_c_country SET numeric_code = '360' WHERE code_iso = "IDN"; -UPDATE llx_c_country SET numeric_code = '368' WHERE code_iso = "IRQ"; -UPDATE llx_c_country SET numeric_code = '364' WHERE code_iso = "IRN"; -UPDATE llx_c_country SET numeric_code = '372' WHERE code_iso = "IRL"; -UPDATE llx_c_country SET numeric_code = '074' WHERE code_iso = "BVT"; -UPDATE llx_c_country SET numeric_code = '833' WHERE code_iso = "IMN"; -UPDATE llx_c_country SET numeric_code = '162' WHERE code_iso = "CXR"; -UPDATE llx_c_country SET numeric_code = '352' WHERE code_iso = "ISL"; -UPDATE llx_c_country SET numeric_code = '136' WHERE code_iso = "CYM"; -UPDATE llx_c_country SET numeric_code = '166' WHERE code_iso = "CCK"; -UPDATE llx_c_country SET numeric_code = '184' WHERE code_iso = "COK"; -UPDATE llx_c_country SET numeric_code = '234' WHERE code_iso = "FRO"; -UPDATE llx_c_country SET numeric_code = '239' WHERE code_iso = "SGS"; -UPDATE llx_c_country SET numeric_code = '334' WHERE code_iso = "HMD"; -UPDATE llx_c_country SET numeric_code = '238' WHERE code_iso = "FLK"; -UPDATE llx_c_country SET numeric_code = '580' WHERE code_iso = "MNP"; -UPDATE llx_c_country SET numeric_code = '584' WHERE code_iso = "MHL"; -UPDATE llx_c_country SET numeric_code = '612' WHERE code_iso = "PCN"; -UPDATE llx_c_country SET numeric_code = '090' WHERE code_iso = "SLB"; -UPDATE llx_c_country SET numeric_code = '796' WHERE code_iso = "TCA"; -UPDATE llx_c_country SET numeric_code = '581' WHERE code_iso = "UMI"; -UPDATE llx_c_country SET numeric_code = '092' WHERE code_iso = "VGB"; -UPDATE llx_c_country SET numeric_code = '850' WHERE code_iso = "VIR"; -UPDATE llx_c_country SET numeric_code = '376' WHERE code_iso = "ISR"; -UPDATE llx_c_country SET numeric_code = '380' WHERE code_iso = "ITA"; -UPDATE llx_c_country SET numeric_code = '388' WHERE code_iso = "JAM"; -UPDATE llx_c_country SET numeric_code = '392' WHERE code_iso = "JPN"; -UPDATE llx_c_country SET numeric_code = '832' WHERE code_iso = "JEY"; -UPDATE llx_c_country SET numeric_code = '400' WHERE code_iso = "JOR"; -UPDATE llx_c_country SET numeric_code = '398' WHERE code_iso = "KAZ"; -UPDATE llx_c_country SET numeric_code = '404' WHERE code_iso = "KEN"; -UPDATE llx_c_country SET numeric_code = '417' WHERE code_iso = "KGZ"; -UPDATE llx_c_country SET numeric_code = '296' WHERE code_iso = "KIR"; -UPDATE llx_c_country SET numeric_code = '414' WHERE code_iso = "KWT"; -UPDATE llx_c_country SET numeric_code = '418' WHERE code_iso = "LAO"; -UPDATE llx_c_country SET numeric_code = '426' WHERE code_iso = "LSO"; -UPDATE llx_c_country SET numeric_code = '428' WHERE code_iso = "LVA"; -UPDATE llx_c_country SET numeric_code = '422' WHERE code_iso = "LBN"; -UPDATE llx_c_country SET numeric_code = '430' WHERE code_iso = "LBR"; -UPDATE llx_c_country SET numeric_code = '434' WHERE code_iso = "LBY"; -UPDATE llx_c_country SET numeric_code = '438' WHERE code_iso = "LIE"; -UPDATE llx_c_country SET numeric_code = '440' WHERE code_iso = "LTU"; -UPDATE llx_c_country SET numeric_code = '442' WHERE code_iso = "LUX"; -UPDATE llx_c_country SET numeric_code = '446' WHERE code_iso = "MAC"; -UPDATE llx_c_country SET numeric_code = '807' WHERE code_iso = "MKD"; -UPDATE llx_c_country SET numeric_code = '450' WHERE code_iso = "MDG"; -UPDATE llx_c_country SET numeric_code = '458' WHERE code_iso = "MYS"; -UPDATE llx_c_country SET numeric_code = '454' WHERE code_iso = "MWI"; -UPDATE llx_c_country SET numeric_code = '462' WHERE code_iso = "MDV"; -UPDATE llx_c_country SET numeric_code = '466' WHERE code_iso = "MLI"; -UPDATE llx_c_country SET numeric_code = '470' WHERE code_iso = "MLT"; -UPDATE llx_c_country SET numeric_code = '504' WHERE code_iso = "MAR"; -UPDATE llx_c_country SET numeric_code = '474' WHERE code_iso = "MTQ"; -UPDATE llx_c_country SET numeric_code = '480' WHERE code_iso = "MUS"; -UPDATE llx_c_country SET numeric_code = '478' WHERE code_iso = "MRT"; -UPDATE llx_c_country SET numeric_code = '175' WHERE code_iso = "MYT"; -UPDATE llx_c_country SET numeric_code = '484' WHERE code_iso = "MEX"; -UPDATE llx_c_country SET numeric_code = '583' WHERE code_iso = "FSM"; -UPDATE llx_c_country SET numeric_code = '498' WHERE code_iso = "MDA"; -UPDATE llx_c_country SET numeric_code = '492' WHERE code_iso = "MCO"; -UPDATE llx_c_country SET numeric_code = '496' WHERE code_iso = "MNG"; -UPDATE llx_c_country SET numeric_code = '499' WHERE code_iso = "MNE"; -UPDATE llx_c_country SET numeric_code = '500' WHERE code_iso = "MSR"; -UPDATE llx_c_country SET numeric_code = '508' WHERE code_iso = "MOZ"; -UPDATE llx_c_country SET numeric_code = '104' WHERE code_iso = "MMR"; -UPDATE llx_c_country SET numeric_code = '516' WHERE code_iso = "NAM"; -UPDATE llx_c_country SET numeric_code = '520' WHERE code_iso = "NRU"; -UPDATE llx_c_country SET numeric_code = '524' WHERE code_iso = "NPL"; -UPDATE llx_c_country SET numeric_code = '558' WHERE code_iso = "NIC"; -UPDATE llx_c_country SET numeric_code = '562' WHERE code_iso = "NER"; -UPDATE llx_c_country SET numeric_code = '566' WHERE code_iso = "NGA"; -UPDATE llx_c_country SET numeric_code = '570' WHERE code_iso = "NIU"; -UPDATE llx_c_country SET numeric_code = '574' WHERE code_iso = "NFK"; -UPDATE llx_c_country SET numeric_code = '578' WHERE code_iso = "NOR"; -UPDATE llx_c_country SET numeric_code = '540' WHERE code_iso = "NCL"; -UPDATE llx_c_country SET numeric_code = '554' WHERE code_iso = "NZL"; -UPDATE llx_c_country SET numeric_code = '512' WHERE code_iso = "OMN"; -UPDATE llx_c_country SET numeric_code = '528' WHERE code_iso = "NLD"; -UPDATE llx_c_country SET numeric_code = '586' WHERE code_iso = "PAK"; -UPDATE llx_c_country SET numeric_code = '585' WHERE code_iso = "PLW"; -UPDATE llx_c_country SET numeric_code = '275' WHERE code_iso = "PSE"; -UPDATE llx_c_country SET numeric_code = '591' WHERE code_iso = "PAN"; -UPDATE llx_c_country SET numeric_code = '598' WHERE code_iso = "PNG"; -UPDATE llx_c_country SET numeric_code = '600' WHERE code_iso = "PRY"; -UPDATE llx_c_country SET numeric_code = '604' WHERE code_iso = "PER"; -UPDATE llx_c_country SET numeric_code = '258' WHERE code_iso = "PYF"; -UPDATE llx_c_country SET numeric_code = '616' WHERE code_iso = "POL"; -UPDATE llx_c_country SET numeric_code = '620' WHERE code_iso = "PRT"; -UPDATE llx_c_country SET numeric_code = '630' WHERE code_iso = "PRI"; -UPDATE llx_c_country SET numeric_code = '826' WHERE code_iso = "GBR"; -UPDATE llx_c_country SET numeric_code = '732' WHERE code_iso = "ESH"; -UPDATE llx_c_country SET numeric_code = '140' WHERE code_iso = "CAF"; -UPDATE llx_c_country SET numeric_code = '203' WHERE code_iso = "CZE"; -UPDATE llx_c_country SET numeric_code = '178' WHERE code_iso = "COG"; -UPDATE llx_c_country SET numeric_code = '180' WHERE code_iso = "COD"; -UPDATE llx_c_country SET numeric_code = '214' WHERE code_iso = "DOM"; -UPDATE llx_c_country SET numeric_code = '638' WHERE code_iso = "REU"; -UPDATE llx_c_country SET numeric_code = '646' WHERE code_iso = "RWA"; -UPDATE llx_c_country SET numeric_code = '642' WHERE code_iso = "ROU"; -UPDATE llx_c_country SET numeric_code = '643' WHERE code_iso = "RUS"; -UPDATE llx_c_country SET numeric_code = '882' WHERE code_iso = "WSM"; -UPDATE llx_c_country SET numeric_code = '016' WHERE code_iso = "ASM"; -UPDATE llx_c_country SET numeric_code = '652' WHERE code_iso = "BLM"; -UPDATE llx_c_country SET numeric_code = '659' WHERE code_iso = "KNA"; -UPDATE llx_c_country SET numeric_code = '674' WHERE code_iso = "SMR"; -UPDATE llx_c_country SET numeric_code = '663' WHERE code_iso = "MAF"; -UPDATE llx_c_country SET numeric_code = '666' WHERE code_iso = "SPM"; -UPDATE llx_c_country SET numeric_code = '670' WHERE code_iso = "VCT"; -UPDATE llx_c_country SET numeric_code = '654' WHERE code_iso = "SHN"; -UPDATE llx_c_country SET numeric_code = '662' WHERE code_iso = "LCA"; -UPDATE llx_c_country SET numeric_code = '678' WHERE code_iso = "STP"; -UPDATE llx_c_country SET numeric_code = '686' WHERE code_iso = "SEN"; -UPDATE llx_c_country SET numeric_code = '688' WHERE code_iso = "SRB"; -UPDATE llx_c_country SET numeric_code = '690' WHERE code_iso = "SYC"; -UPDATE llx_c_country SET numeric_code = '694' WHERE code_iso = "SLE"; -UPDATE llx_c_country SET numeric_code = '702' WHERE code_iso = "SGP"; -UPDATE llx_c_country SET numeric_code = '534' WHERE code_iso = "SXM"; -UPDATE llx_c_country SET numeric_code = '760' WHERE code_iso = "SYR"; -UPDATE llx_c_country SET numeric_code = '706' WHERE code_iso = "SOM"; -UPDATE llx_c_country SET numeric_code = '144' WHERE code_iso = "LKA"; -UPDATE llx_c_country SET numeric_code = '748' WHERE code_iso = "SWZ"; -UPDATE llx_c_country SET numeric_code = '710' WHERE code_iso = "ZAF"; -UPDATE llx_c_country SET numeric_code = '729' WHERE code_iso = "SDN"; -UPDATE llx_c_country SET numeric_code = '728' WHERE code_iso = "SSD"; -UPDATE llx_c_country SET numeric_code = '752' WHERE code_iso = "SWE"; -UPDATE llx_c_country SET numeric_code = '756' WHERE code_iso = "CHE"; -UPDATE llx_c_country SET numeric_code = '740' WHERE code_iso = "SUR"; -UPDATE llx_c_country SET numeric_code = '744' WHERE code_iso = "SJM"; -UPDATE llx_c_country SET numeric_code = '764' WHERE code_iso = "THA"; -UPDATE llx_c_country SET numeric_code = '158' WHERE code_iso = "TWN"; -UPDATE llx_c_country SET numeric_code = '834' WHERE code_iso = "TZA"; -UPDATE llx_c_country SET numeric_code = '762' WHERE code_iso = "TJK"; -UPDATE llx_c_country SET numeric_code = '086' WHERE code_iso = "IOT"; -UPDATE llx_c_country SET numeric_code = '260' WHERE code_iso = "ATF"; -UPDATE llx_c_country SET numeric_code = '626' WHERE code_iso = "TLS"; -UPDATE llx_c_country SET numeric_code = '768' WHERE code_iso = "TGO"; -UPDATE llx_c_country SET numeric_code = '772' WHERE code_iso = "TKL"; -UPDATE llx_c_country SET numeric_code = '776' WHERE code_iso = "TON"; -UPDATE llx_c_country SET numeric_code = '780' WHERE code_iso = "TTO"; -UPDATE llx_c_country SET numeric_code = '788' WHERE code_iso = "TUN"; -UPDATE llx_c_country SET numeric_code = '795' WHERE code_iso = "TKM"; -UPDATE llx_c_country SET numeric_code = '792' WHERE code_iso = "TUR"; -UPDATE llx_c_country SET numeric_code = '798' WHERE code_iso = "TUV"; -UPDATE llx_c_country SET numeric_code = '804' WHERE code_iso = "UKR"; -UPDATE llx_c_country SET numeric_code = '800' WHERE code_iso = "UGA"; -UPDATE llx_c_country SET numeric_code = '858' WHERE code_iso = "URY"; -UPDATE llx_c_country SET numeric_code = '860' WHERE code_iso = "UZB"; -UPDATE llx_c_country SET numeric_code = '548' WHERE code_iso = "VUT"; -UPDATE llx_c_country SET numeric_code = '336' WHERE code_iso = "VAT"; -UPDATE llx_c_country SET numeric_code = '862' WHERE code_iso = "VEN"; -UPDATE llx_c_country SET numeric_code = '704' WHERE code_iso = "VNM"; -UPDATE llx_c_country SET numeric_code = '876' WHERE code_iso = "WLF"; -UPDATE llx_c_country SET numeric_code = '887' WHERE code_iso = "YEM"; -UPDATE llx_c_country SET numeric_code = '262' WHERE code_iso = "DJI"; -UPDATE llx_c_country SET numeric_code = '894' WHERE code_iso = "ZMB"; -UPDATE llx_c_country SET numeric_code = '716' WHERE code_iso = "ZWE"; +UPDATE llx_c_country SET numeric_code = '004' WHERE code_iso = 'AFG'; +UPDATE llx_c_country SET numeric_code = '248' WHERE code_iso = 'ALA'; +UPDATE llx_c_country SET numeric_code = '008' WHERE code_iso = 'ALB'; +UPDATE llx_c_country SET numeric_code = '276' WHERE code_iso = 'DEU'; +UPDATE llx_c_country SET numeric_code = '020' WHERE code_iso = 'AND'; +UPDATE llx_c_country SET numeric_code = '024' WHERE code_iso = 'AGO'; +UPDATE llx_c_country SET numeric_code = '660' WHERE code_iso = 'AIA'; +UPDATE llx_c_country SET numeric_code = '010' WHERE code_iso = 'ATA'; +UPDATE llx_c_country SET numeric_code = '028' WHERE code_iso = 'ATG'; +UPDATE llx_c_country SET numeric_code = '682' WHERE code_iso = 'SAU'; +UPDATE llx_c_country SET numeric_code = '012' WHERE code_iso = 'DZA'; +UPDATE llx_c_country SET numeric_code = '032' WHERE code_iso = 'ARG'; +UPDATE llx_c_country SET numeric_code = '051' WHERE code_iso = 'ARM'; +UPDATE llx_c_country SET numeric_code = '533' WHERE code_iso = 'ABW'; +UPDATE llx_c_country SET numeric_code = '036' WHERE code_iso = 'AUS'; +UPDATE llx_c_country SET numeric_code = '040' WHERE code_iso = 'AUT'; +UPDATE llx_c_country SET numeric_code = '031' WHERE code_iso = 'AZE'; +UPDATE llx_c_country SET numeric_code = '044' WHERE code_iso = 'BHS'; +UPDATE llx_c_country SET numeric_code = '050' WHERE code_iso = 'BGD'; +UPDATE llx_c_country SET numeric_code = '052' WHERE code_iso = 'BRB'; +UPDATE llx_c_country SET numeric_code = '048' WHERE code_iso = 'BHR'; +UPDATE llx_c_country SET numeric_code = '056' WHERE code_iso = 'BEL'; +UPDATE llx_c_country SET numeric_code = '084' WHERE code_iso = 'BLZ'; +UPDATE llx_c_country SET numeric_code = '204' WHERE code_iso = 'BEN'; +UPDATE llx_c_country SET numeric_code = '060' WHERE code_iso = 'BMU'; +UPDATE llx_c_country SET numeric_code = '112' WHERE code_iso = 'BLR'; +UPDATE llx_c_country SET numeric_code = '068' WHERE code_iso = 'BOL'; +UPDATE llx_c_country SET numeric_code = '535' WHERE code_iso = 'BES'; +UPDATE llx_c_country SET numeric_code = '070' WHERE code_iso = 'BIH'; +UPDATE llx_c_country SET numeric_code = '072' WHERE code_iso = 'BWA'; +UPDATE llx_c_country SET numeric_code = '076' WHERE code_iso = 'BRA'; +UPDATE llx_c_country SET numeric_code = '096' WHERE code_iso = 'BRN'; +UPDATE llx_c_country SET numeric_code = '100' WHERE code_iso = 'BGR'; +UPDATE llx_c_country SET numeric_code = '854' WHERE code_iso = 'BFA'; +UPDATE llx_c_country SET numeric_code = '108' WHERE code_iso = 'BDI'; +UPDATE llx_c_country SET numeric_code = '064' WHERE code_iso = 'BTN'; +UPDATE llx_c_country SET numeric_code = '132' WHERE code_iso = 'CPV'; +UPDATE llx_c_country SET numeric_code = '116' WHERE code_iso = 'KHM'; +UPDATE llx_c_country SET numeric_code = '120' WHERE code_iso = 'CMR'; +UPDATE llx_c_country SET numeric_code = '124' WHERE code_iso = 'CAN'; +UPDATE llx_c_country SET numeric_code = '634' WHERE code_iso = 'QAT'; +UPDATE llx_c_country SET numeric_code = '148' WHERE code_iso = 'TCD'; +UPDATE llx_c_country SET numeric_code = '152' WHERE code_iso = 'CHL'; +UPDATE llx_c_country SET numeric_code = '156' WHERE code_iso = 'CHN'; +UPDATE llx_c_country SET numeric_code = '196' WHERE code_iso = 'CYP'; +UPDATE llx_c_country SET numeric_code = '170' WHERE code_iso = 'COL'; +UPDATE llx_c_country SET numeric_code = '174' WHERE code_iso = 'COM'; +UPDATE llx_c_country SET numeric_code = '408' WHERE code_iso = 'PRK'; +UPDATE llx_c_country SET numeric_code = '410' WHERE code_iso = 'KOR'; +UPDATE llx_c_country SET numeric_code = '384' WHERE code_iso = 'CIV'; +UPDATE llx_c_country SET numeric_code = '188' WHERE code_iso = 'CRI'; +UPDATE llx_c_country SET numeric_code = '191' WHERE code_iso = 'HRV'; +UPDATE llx_c_country SET numeric_code = '192' WHERE code_iso = 'CUB'; +UPDATE llx_c_country SET numeric_code = '531' WHERE code_iso = 'CUW'; +UPDATE llx_c_country SET numeric_code = '208' WHERE code_iso = 'DNK'; +UPDATE llx_c_country SET numeric_code = '212' WHERE code_iso = 'DMA'; +UPDATE llx_c_country SET numeric_code = '218' WHERE code_iso = 'ECU'; +UPDATE llx_c_country SET numeric_code = '818' WHERE code_iso = 'EGY'; +UPDATE llx_c_country SET numeric_code = '222' WHERE code_iso = 'SLV'; +UPDATE llx_c_country SET numeric_code = '784' WHERE code_iso = 'ARE'; +UPDATE llx_c_country SET numeric_code = '232' WHERE code_iso = 'ERI'; +UPDATE llx_c_country SET numeric_code = '703' WHERE code_iso = 'SVK'; +UPDATE llx_c_country SET numeric_code = '705' WHERE code_iso = 'SVN'; +UPDATE llx_c_country SET numeric_code = '724' WHERE code_iso = 'ESP'; +UPDATE llx_c_country SET numeric_code = '840' WHERE code_iso = 'USA'; +UPDATE llx_c_country SET numeric_code = '233' WHERE code_iso = 'EST'; +UPDATE llx_c_country SET numeric_code = '231' WHERE code_iso = 'ETH'; +UPDATE llx_c_country SET numeric_code = '608' WHERE code_iso = 'PHL'; +UPDATE llx_c_country SET numeric_code = '246' WHERE code_iso = 'FIN'; +UPDATE llx_c_country SET numeric_code = '242' WHERE code_iso = 'FJI'; +UPDATE llx_c_country SET numeric_code = '250' WHERE code_iso = 'FRA'; +UPDATE llx_c_country SET numeric_code = '266' WHERE code_iso = 'GAB'; +UPDATE llx_c_country SET numeric_code = '270' WHERE code_iso = 'GMB'; +UPDATE llx_c_country SET numeric_code = '268' WHERE code_iso = 'GEO'; +UPDATE llx_c_country SET numeric_code = '288' WHERE code_iso = 'GHA'; +UPDATE llx_c_country SET numeric_code = '292' WHERE code_iso = 'GIB'; +UPDATE llx_c_country SET numeric_code = '308' WHERE code_iso = 'GRD'; +UPDATE llx_c_country SET numeric_code = '300' WHERE code_iso = 'GRC'; +UPDATE llx_c_country SET numeric_code = '304' WHERE code_iso = 'GRL'; +UPDATE llx_c_country SET numeric_code = '312' WHERE code_iso = 'GLP'; +UPDATE llx_c_country SET numeric_code = '316' WHERE code_iso = 'GUM'; +UPDATE llx_c_country SET numeric_code = '320' WHERE code_iso = 'GTM'; +UPDATE llx_c_country SET numeric_code = '254' WHERE code_iso = 'GUF'; +UPDATE llx_c_country SET numeric_code = '831' WHERE code_iso = 'GGY'; +UPDATE llx_c_country SET numeric_code = '324' WHERE code_iso = 'GIN'; +UPDATE llx_c_country SET numeric_code = '624' WHERE code_iso = 'GNB'; +UPDATE llx_c_country SET numeric_code = '226' WHERE code_iso = 'GNQ'; +UPDATE llx_c_country SET numeric_code = '328' WHERE code_iso = 'GUY'; +UPDATE llx_c_country SET numeric_code = '332' WHERE code_iso = 'HTI'; +UPDATE llx_c_country SET numeric_code = '340' WHERE code_iso = 'HND'; +UPDATE llx_c_country SET numeric_code = '344' WHERE code_iso = 'HKG'; +UPDATE llx_c_country SET numeric_code = '348' WHERE code_iso = 'HUN'; +UPDATE llx_c_country SET numeric_code = '356' WHERE code_iso = 'IND'; +UPDATE llx_c_country SET numeric_code = '360' WHERE code_iso = 'IDN'; +UPDATE llx_c_country SET numeric_code = '368' WHERE code_iso = 'IRQ'; +UPDATE llx_c_country SET numeric_code = '364' WHERE code_iso = 'IRN'; +UPDATE llx_c_country SET numeric_code = '372' WHERE code_iso = 'IRL'; +UPDATE llx_c_country SET numeric_code = '074' WHERE code_iso = 'BVT'; +UPDATE llx_c_country SET numeric_code = '833' WHERE code_iso = 'IMN'; +UPDATE llx_c_country SET numeric_code = '162' WHERE code_iso = 'CXR'; +UPDATE llx_c_country SET numeric_code = '352' WHERE code_iso = 'ISL'; +UPDATE llx_c_country SET numeric_code = '136' WHERE code_iso = 'CYM'; +UPDATE llx_c_country SET numeric_code = '166' WHERE code_iso = 'CCK'; +UPDATE llx_c_country SET numeric_code = '184' WHERE code_iso = 'COK'; +UPDATE llx_c_country SET numeric_code = '234' WHERE code_iso = 'FRO'; +UPDATE llx_c_country SET numeric_code = '239' WHERE code_iso = 'SGS'; +UPDATE llx_c_country SET numeric_code = '334' WHERE code_iso = 'HMD'; +UPDATE llx_c_country SET numeric_code = '238' WHERE code_iso = 'FLK'; +UPDATE llx_c_country SET numeric_code = '580' WHERE code_iso = 'MNP'; +UPDATE llx_c_country SET numeric_code = '584' WHERE code_iso = 'MHL'; +UPDATE llx_c_country SET numeric_code = '612' WHERE code_iso = 'PCN'; +UPDATE llx_c_country SET numeric_code = '090' WHERE code_iso = 'SLB'; +UPDATE llx_c_country SET numeric_code = '796' WHERE code_iso = 'TCA'; +UPDATE llx_c_country SET numeric_code = '581' WHERE code_iso = 'UMI'; +UPDATE llx_c_country SET numeric_code = '092' WHERE code_iso = 'VGB'; +UPDATE llx_c_country SET numeric_code = '850' WHERE code_iso = 'VIR'; +UPDATE llx_c_country SET numeric_code = '376' WHERE code_iso = 'ISR'; +UPDATE llx_c_country SET numeric_code = '380' WHERE code_iso = 'ITA'; +UPDATE llx_c_country SET numeric_code = '388' WHERE code_iso = 'JAM'; +UPDATE llx_c_country SET numeric_code = '392' WHERE code_iso = 'JPN'; +UPDATE llx_c_country SET numeric_code = '832' WHERE code_iso = 'JEY'; +UPDATE llx_c_country SET numeric_code = '400' WHERE code_iso = 'JOR'; +UPDATE llx_c_country SET numeric_code = '398' WHERE code_iso = 'KAZ'; +UPDATE llx_c_country SET numeric_code = '404' WHERE code_iso = 'KEN'; +UPDATE llx_c_country SET numeric_code = '417' WHERE code_iso = 'KGZ'; +UPDATE llx_c_country SET numeric_code = '296' WHERE code_iso = 'KIR'; +UPDATE llx_c_country SET numeric_code = '414' WHERE code_iso = 'KWT'; +UPDATE llx_c_country SET numeric_code = '418' WHERE code_iso = 'LAO'; +UPDATE llx_c_country SET numeric_code = '426' WHERE code_iso = 'LSO'; +UPDATE llx_c_country SET numeric_code = '428' WHERE code_iso = 'LVA'; +UPDATE llx_c_country SET numeric_code = '422' WHERE code_iso = 'LBN'; +UPDATE llx_c_country SET numeric_code = '430' WHERE code_iso = 'LBR'; +UPDATE llx_c_country SET numeric_code = '434' WHERE code_iso = 'LBY'; +UPDATE llx_c_country SET numeric_code = '438' WHERE code_iso = 'LIE'; +UPDATE llx_c_country SET numeric_code = '440' WHERE code_iso = 'LTU'; +UPDATE llx_c_country SET numeric_code = '442' WHERE code_iso = 'LUX'; +UPDATE llx_c_country SET numeric_code = '446' WHERE code_iso = 'MAC'; +UPDATE llx_c_country SET numeric_code = '807' WHERE code_iso = 'MKD'; +UPDATE llx_c_country SET numeric_code = '450' WHERE code_iso = 'MDG'; +UPDATE llx_c_country SET numeric_code = '458' WHERE code_iso = 'MYS'; +UPDATE llx_c_country SET numeric_code = '454' WHERE code_iso = 'MWI'; +UPDATE llx_c_country SET numeric_code = '462' WHERE code_iso = 'MDV'; +UPDATE llx_c_country SET numeric_code = '466' WHERE code_iso = 'MLI'; +UPDATE llx_c_country SET numeric_code = '470' WHERE code_iso = 'MLT'; +UPDATE llx_c_country SET numeric_code = '504' WHERE code_iso = 'MAR'; +UPDATE llx_c_country SET numeric_code = '474' WHERE code_iso = 'MTQ'; +UPDATE llx_c_country SET numeric_code = '480' WHERE code_iso = 'MUS'; +UPDATE llx_c_country SET numeric_code = '478' WHERE code_iso = 'MRT'; +UPDATE llx_c_country SET numeric_code = '175' WHERE code_iso = 'MYT'; +UPDATE llx_c_country SET numeric_code = '484' WHERE code_iso = 'MEX'; +UPDATE llx_c_country SET numeric_code = '583' WHERE code_iso = 'FSM'; +UPDATE llx_c_country SET numeric_code = '498' WHERE code_iso = 'MDA'; +UPDATE llx_c_country SET numeric_code = '492' WHERE code_iso = 'MCO'; +UPDATE llx_c_country SET numeric_code = '496' WHERE code_iso = 'MNG'; +UPDATE llx_c_country SET numeric_code = '499' WHERE code_iso = 'MNE'; +UPDATE llx_c_country SET numeric_code = '500' WHERE code_iso = 'MSR'; +UPDATE llx_c_country SET numeric_code = '508' WHERE code_iso = 'MOZ'; +UPDATE llx_c_country SET numeric_code = '104' WHERE code_iso = 'MMR'; +UPDATE llx_c_country SET numeric_code = '516' WHERE code_iso = 'NAM'; +UPDATE llx_c_country SET numeric_code = '520' WHERE code_iso = 'NRU'; +UPDATE llx_c_country SET numeric_code = '524' WHERE code_iso = 'NPL'; +UPDATE llx_c_country SET numeric_code = '558' WHERE code_iso = 'NIC'; +UPDATE llx_c_country SET numeric_code = '562' WHERE code_iso = 'NER'; +UPDATE llx_c_country SET numeric_code = '566' WHERE code_iso = 'NGA'; +UPDATE llx_c_country SET numeric_code = '570' WHERE code_iso = 'NIU'; +UPDATE llx_c_country SET numeric_code = '574' WHERE code_iso = 'NFK'; +UPDATE llx_c_country SET numeric_code = '578' WHERE code_iso = 'NOR'; +UPDATE llx_c_country SET numeric_code = '540' WHERE code_iso = 'NCL'; +UPDATE llx_c_country SET numeric_code = '554' WHERE code_iso = 'NZL'; +UPDATE llx_c_country SET numeric_code = '512' WHERE code_iso = 'OMN'; +UPDATE llx_c_country SET numeric_code = '528' WHERE code_iso = 'NLD'; +UPDATE llx_c_country SET numeric_code = '586' WHERE code_iso = 'PAK'; +UPDATE llx_c_country SET numeric_code = '585' WHERE code_iso = 'PLW'; +UPDATE llx_c_country SET numeric_code = '275' WHERE code_iso = 'PSE'; +UPDATE llx_c_country SET numeric_code = '591' WHERE code_iso = 'PAN'; +UPDATE llx_c_country SET numeric_code = '598' WHERE code_iso = 'PNG'; +UPDATE llx_c_country SET numeric_code = '600' WHERE code_iso = 'PRY'; +UPDATE llx_c_country SET numeric_code = '604' WHERE code_iso = 'PER'; +UPDATE llx_c_country SET numeric_code = '258' WHERE code_iso = 'PYF'; +UPDATE llx_c_country SET numeric_code = '616' WHERE code_iso = 'POL'; +UPDATE llx_c_country SET numeric_code = '620' WHERE code_iso = 'PRT'; +UPDATE llx_c_country SET numeric_code = '630' WHERE code_iso = 'PRI'; +UPDATE llx_c_country SET numeric_code = '826' WHERE code_iso = 'GBR'; +UPDATE llx_c_country SET numeric_code = '732' WHERE code_iso = 'ESH'; +UPDATE llx_c_country SET numeric_code = '140' WHERE code_iso = 'CAF'; +UPDATE llx_c_country SET numeric_code = '203' WHERE code_iso = 'CZE'; +UPDATE llx_c_country SET numeric_code = '178' WHERE code_iso = 'COG'; +UPDATE llx_c_country SET numeric_code = '180' WHERE code_iso = 'COD'; +UPDATE llx_c_country SET numeric_code = '214' WHERE code_iso = 'DOM'; +UPDATE llx_c_country SET numeric_code = '638' WHERE code_iso = 'REU'; +UPDATE llx_c_country SET numeric_code = '646' WHERE code_iso = 'RWA'; +UPDATE llx_c_country SET numeric_code = '642' WHERE code_iso = 'ROU'; +UPDATE llx_c_country SET numeric_code = '643' WHERE code_iso = 'RUS'; +UPDATE llx_c_country SET numeric_code = '882' WHERE code_iso = 'WSM'; +UPDATE llx_c_country SET numeric_code = '016' WHERE code_iso = 'ASM'; +UPDATE llx_c_country SET numeric_code = '652' WHERE code_iso = 'BLM'; +UPDATE llx_c_country SET numeric_code = '659' WHERE code_iso = 'KNA'; +UPDATE llx_c_country SET numeric_code = '674' WHERE code_iso = 'SMR'; +UPDATE llx_c_country SET numeric_code = '663' WHERE code_iso = 'MAF'; +UPDATE llx_c_country SET numeric_code = '666' WHERE code_iso = 'SPM'; +UPDATE llx_c_country SET numeric_code = '670' WHERE code_iso = 'VCT'; +UPDATE llx_c_country SET numeric_code = '654' WHERE code_iso = 'SHN'; +UPDATE llx_c_country SET numeric_code = '662' WHERE code_iso = 'LCA'; +UPDATE llx_c_country SET numeric_code = '678' WHERE code_iso = 'STP'; +UPDATE llx_c_country SET numeric_code = '686' WHERE code_iso = 'SEN'; +UPDATE llx_c_country SET numeric_code = '688' WHERE code_iso = 'SRB'; +UPDATE llx_c_country SET numeric_code = '690' WHERE code_iso = 'SYC'; +UPDATE llx_c_country SET numeric_code = '694' WHERE code_iso = 'SLE'; +UPDATE llx_c_country SET numeric_code = '702' WHERE code_iso = 'SGP'; +UPDATE llx_c_country SET numeric_code = '534' WHERE code_iso = 'SXM'; +UPDATE llx_c_country SET numeric_code = '760' WHERE code_iso = 'SYR'; +UPDATE llx_c_country SET numeric_code = '706' WHERE code_iso = 'SOM'; +UPDATE llx_c_country SET numeric_code = '144' WHERE code_iso = 'LKA'; +UPDATE llx_c_country SET numeric_code = '748' WHERE code_iso = 'SWZ'; +UPDATE llx_c_country SET numeric_code = '710' WHERE code_iso = 'ZAF'; +UPDATE llx_c_country SET numeric_code = '729' WHERE code_iso = 'SDN'; +UPDATE llx_c_country SET numeric_code = '728' WHERE code_iso = 'SSD'; +UPDATE llx_c_country SET numeric_code = '752' WHERE code_iso = 'SWE'; +UPDATE llx_c_country SET numeric_code = '756' WHERE code_iso = 'CHE'; +UPDATE llx_c_country SET numeric_code = '740' WHERE code_iso = 'SUR'; +UPDATE llx_c_country SET numeric_code = '744' WHERE code_iso = 'SJM'; +UPDATE llx_c_country SET numeric_code = '764' WHERE code_iso = 'THA'; +UPDATE llx_c_country SET numeric_code = '158' WHERE code_iso = 'TWN'; +UPDATE llx_c_country SET numeric_code = '834' WHERE code_iso = 'TZA'; +UPDATE llx_c_country SET numeric_code = '762' WHERE code_iso = 'TJK'; +UPDATE llx_c_country SET numeric_code = '086' WHERE code_iso = 'IOT'; +UPDATE llx_c_country SET numeric_code = '260' WHERE code_iso = 'ATF'; +UPDATE llx_c_country SET numeric_code = '626' WHERE code_iso = 'TLS'; +UPDATE llx_c_country SET numeric_code = '768' WHERE code_iso = 'TGO'; +UPDATE llx_c_country SET numeric_code = '772' WHERE code_iso = 'TKL'; +UPDATE llx_c_country SET numeric_code = '776' WHERE code_iso = 'TON'; +UPDATE llx_c_country SET numeric_code = '780' WHERE code_iso = 'TTO'; +UPDATE llx_c_country SET numeric_code = '788' WHERE code_iso = 'TUN'; +UPDATE llx_c_country SET numeric_code = '795' WHERE code_iso = 'TKM'; +UPDATE llx_c_country SET numeric_code = '792' WHERE code_iso = 'TUR'; +UPDATE llx_c_country SET numeric_code = '798' WHERE code_iso = 'TUV'; +UPDATE llx_c_country SET numeric_code = '804' WHERE code_iso = 'UKR'; +UPDATE llx_c_country SET numeric_code = '800' WHERE code_iso = 'UGA'; +UPDATE llx_c_country SET numeric_code = '858' WHERE code_iso = 'URY'; +UPDATE llx_c_country SET numeric_code = '860' WHERE code_iso = 'UZB'; +UPDATE llx_c_country SET numeric_code = '548' WHERE code_iso = 'VUT'; +UPDATE llx_c_country SET numeric_code = '336' WHERE code_iso = 'VAT'; +UPDATE llx_c_country SET numeric_code = '862' WHERE code_iso = 'VEN'; +UPDATE llx_c_country SET numeric_code = '704' WHERE code_iso = 'VNM'; +UPDATE llx_c_country SET numeric_code = '876' WHERE code_iso = 'WLF'; +UPDATE llx_c_country SET numeric_code = '887' WHERE code_iso = 'YEM'; +UPDATE llx_c_country SET numeric_code = '262' WHERE code_iso = 'DJI'; +UPDATE llx_c_country SET numeric_code = '894' WHERE code_iso = 'ZMB'; +UPDATE llx_c_country SET numeric_code = '716' WHERE code_iso = 'ZWE'; From 4f7c54c125f8f88a7d183078f49f978013950e50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Mar 2023 15:57:36 +0100 Subject: [PATCH 81/84] Debug v18 --- htdocs/core/ajax/security.php | 2 +- htdocs/core/lib/security2.lib.php | 3 + .../install/mysql/migration/17.0.0-18.0.0.sql | 498 +++++++++--------- htdocs/user/card.php | 12 +- 4 files changed, 260 insertions(+), 255 deletions(-) diff --git a/htdocs/core/ajax/security.php b/htdocs/core/ajax/security.php index b01c952662e..2a836359e1c 100644 --- a/htdocs/core/ajax/security.php +++ b/htdocs/core/ajax/security.php @@ -36,7 +36,7 @@ if (!defined('NOREQUIREAJAX')) { if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } -// We need langs because the getRandomPassword may use user language to define some rules of pass generation +// We need langs because the getRandomPassword may use the user language to define some rules of pass generation /*if (!defined('NOREQUIRETRAN')) { define('NOREQUIRETRAN', '1'); }*/ diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index c68bb49d93b..b60054b9701 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -581,6 +581,9 @@ function dolJSToSetRandomPassword($htmlname, $htmlnameofbutton = 'generate_token token: \''.dol_escape_js(newToken()).'\' }, function(result) { + if ($("input#'.dol_escape_js($htmlname).'").attr("type") == "password") { + $("input#'.dol_escape_js($htmlname).'").attr("type", "text"); + } $("#'.dol_escape_js($htmlname).'").val(result); }); }); diff --git a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql index e1830c6473b..1299e5f3a13 100644 --- a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql +++ b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql @@ -123,254 +123,254 @@ ALTER TABLE llx_element_time ADD INDEX idx_element_time_datehour (element_dateho ALTER TABLE llx_c_country ADD COLUMN numeric_code VARCHAR(3); -UPDATE llx_c_country SET numeric_code = '004' WHERE code_iso = "AFG"; -UPDATE llx_c_country SET numeric_code = '248' WHERE code_iso = "ALA"; -UPDATE llx_c_country SET numeric_code = '008' WHERE code_iso = "ALB"; -UPDATE llx_c_country SET numeric_code = '276' WHERE code_iso = "DEU"; -UPDATE llx_c_country SET numeric_code = '020' WHERE code_iso = "AND"; -UPDATE llx_c_country SET numeric_code = '024' WHERE code_iso = "AGO"; -UPDATE llx_c_country SET numeric_code = '660' WHERE code_iso = "AIA"; -UPDATE llx_c_country SET numeric_code = '010' WHERE code_iso = "ATA"; -UPDATE llx_c_country SET numeric_code = '028' WHERE code_iso = "ATG"; -UPDATE llx_c_country SET numeric_code = '682' WHERE code_iso = "SAU"; -UPDATE llx_c_country SET numeric_code = '012' WHERE code_iso = "DZA"; -UPDATE llx_c_country SET numeric_code = '032' WHERE code_iso = "ARG"; -UPDATE llx_c_country SET numeric_code = '051' WHERE code_iso = "ARM"; -UPDATE llx_c_country SET numeric_code = '533' WHERE code_iso = "ABW"; -UPDATE llx_c_country SET numeric_code = '036' WHERE code_iso = "AUS"; -UPDATE llx_c_country SET numeric_code = '040' WHERE code_iso = "AUT"; -UPDATE llx_c_country SET numeric_code = '031' WHERE code_iso = "AZE"; -UPDATE llx_c_country SET numeric_code = '044' WHERE code_iso = "BHS"; -UPDATE llx_c_country SET numeric_code = '050' WHERE code_iso = "BGD"; -UPDATE llx_c_country SET numeric_code = '052' WHERE code_iso = "BRB"; -UPDATE llx_c_country SET numeric_code = '048' WHERE code_iso = "BHR"; -UPDATE llx_c_country SET numeric_code = '056' WHERE code_iso = "BEL"; -UPDATE llx_c_country SET numeric_code = '084' WHERE code_iso = "BLZ"; -UPDATE llx_c_country SET numeric_code = '204' WHERE code_iso = "BEN"; -UPDATE llx_c_country SET numeric_code = '060' WHERE code_iso = "BMU"; -UPDATE llx_c_country SET numeric_code = '112' WHERE code_iso = "BLR"; -UPDATE llx_c_country SET numeric_code = '068' WHERE code_iso = "BOL"; -UPDATE llx_c_country SET numeric_code = '535' WHERE code_iso = "BES"; -UPDATE llx_c_country SET numeric_code = '070' WHERE code_iso = "BIH"; -UPDATE llx_c_country SET numeric_code = '072' WHERE code_iso = "BWA"; -UPDATE llx_c_country SET numeric_code = '076' WHERE code_iso = "BRA"; -UPDATE llx_c_country SET numeric_code = '096' WHERE code_iso = "BRN"; -UPDATE llx_c_country SET numeric_code = '100' WHERE code_iso = "BGR"; -UPDATE llx_c_country SET numeric_code = '854' WHERE code_iso = "BFA"; -UPDATE llx_c_country SET numeric_code = '108' WHERE code_iso = "BDI"; -UPDATE llx_c_country SET numeric_code = '064' WHERE code_iso = "BTN"; -UPDATE llx_c_country SET numeric_code = '132' WHERE code_iso = "CPV"; -UPDATE llx_c_country SET numeric_code = '116' WHERE code_iso = "KHM"; -UPDATE llx_c_country SET numeric_code = '120' WHERE code_iso = "CMR"; -UPDATE llx_c_country SET numeric_code = '124' WHERE code_iso = "CAN"; -UPDATE llx_c_country SET numeric_code = '634' WHERE code_iso = "QAT"; -UPDATE llx_c_country SET numeric_code = '148' WHERE code_iso = "TCD"; -UPDATE llx_c_country SET numeric_code = '152' WHERE code_iso = "CHL"; -UPDATE llx_c_country SET numeric_code = '156' WHERE code_iso = "CHN"; -UPDATE llx_c_country SET numeric_code = '196' WHERE code_iso = "CYP"; -UPDATE llx_c_country SET numeric_code = '170' WHERE code_iso = "COL"; -UPDATE llx_c_country SET numeric_code = '174' WHERE code_iso = "COM"; -UPDATE llx_c_country SET numeric_code = '408' WHERE code_iso = "PRK"; -UPDATE llx_c_country SET numeric_code = '410' WHERE code_iso = "KOR"; -UPDATE llx_c_country SET numeric_code = '384' WHERE code_iso = "CIV"; -UPDATE llx_c_country SET numeric_code = '188' WHERE code_iso = "CRI"; -UPDATE llx_c_country SET numeric_code = '191' WHERE code_iso = "HRV"; -UPDATE llx_c_country SET numeric_code = '192' WHERE code_iso = "CUB"; -UPDATE llx_c_country SET numeric_code = '531' WHERE code_iso = "CUW"; -UPDATE llx_c_country SET numeric_code = '208' WHERE code_iso = "DNK"; -UPDATE llx_c_country SET numeric_code = '212' WHERE code_iso = "DMA"; -UPDATE llx_c_country SET numeric_code = '218' WHERE code_iso = "ECU"; -UPDATE llx_c_country SET numeric_code = '818' WHERE code_iso = "EGY"; -UPDATE llx_c_country SET numeric_code = '222' WHERE code_iso = "SLV"; -UPDATE llx_c_country SET numeric_code = '784' WHERE code_iso = "ARE"; -UPDATE llx_c_country SET numeric_code = '232' WHERE code_iso = "ERI"; -UPDATE llx_c_country SET numeric_code = '703' WHERE code_iso = "SVK"; -UPDATE llx_c_country SET numeric_code = '705' WHERE code_iso = "SVN"; -UPDATE llx_c_country SET numeric_code = '724' WHERE code_iso = "ESP"; -UPDATE llx_c_country SET numeric_code = '840' WHERE code_iso = "USA"; -UPDATE llx_c_country SET numeric_code = '233' WHERE code_iso = "EST"; -UPDATE llx_c_country SET numeric_code = '231' WHERE code_iso = "ETH"; -UPDATE llx_c_country SET numeric_code = '608' WHERE code_iso = "PHL"; -UPDATE llx_c_country SET numeric_code = '246' WHERE code_iso = "FIN"; -UPDATE llx_c_country SET numeric_code = '242' WHERE code_iso = "FJI"; -UPDATE llx_c_country SET numeric_code = '250' WHERE code_iso = "FRA"; -UPDATE llx_c_country SET numeric_code = '266' WHERE code_iso = "GAB"; -UPDATE llx_c_country SET numeric_code = '270' WHERE code_iso = "GMB"; -UPDATE llx_c_country SET numeric_code = '268' WHERE code_iso = "GEO"; -UPDATE llx_c_country SET numeric_code = '288' WHERE code_iso = "GHA"; -UPDATE llx_c_country SET numeric_code = '292' WHERE code_iso = "GIB"; -UPDATE llx_c_country SET numeric_code = '308' WHERE code_iso = "GRD"; -UPDATE llx_c_country SET numeric_code = '300' WHERE code_iso = "GRC"; -UPDATE llx_c_country SET numeric_code = '304' WHERE code_iso = "GRL"; -UPDATE llx_c_country SET numeric_code = '312' WHERE code_iso = "GLP"; -UPDATE llx_c_country SET numeric_code = '316' WHERE code_iso = "GUM"; -UPDATE llx_c_country SET numeric_code = '320' WHERE code_iso = "GTM"; -UPDATE llx_c_country SET numeric_code = '254' WHERE code_iso = "GUF"; -UPDATE llx_c_country SET numeric_code = '831' WHERE code_iso = "GGY"; -UPDATE llx_c_country SET numeric_code = '324' WHERE code_iso = "GIN"; -UPDATE llx_c_country SET numeric_code = '624' WHERE code_iso = "GNB"; -UPDATE llx_c_country SET numeric_code = '226' WHERE code_iso = "GNQ"; -UPDATE llx_c_country SET numeric_code = '328' WHERE code_iso = "GUY"; -UPDATE llx_c_country SET numeric_code = '332' WHERE code_iso = "HTI"; -UPDATE llx_c_country SET numeric_code = '340' WHERE code_iso = "HND"; -UPDATE llx_c_country SET numeric_code = '344' WHERE code_iso = "HKG"; -UPDATE llx_c_country SET numeric_code = '348' WHERE code_iso = "HUN"; -UPDATE llx_c_country SET numeric_code = '356' WHERE code_iso = "IND"; -UPDATE llx_c_country SET numeric_code = '360' WHERE code_iso = "IDN"; -UPDATE llx_c_country SET numeric_code = '368' WHERE code_iso = "IRQ"; -UPDATE llx_c_country SET numeric_code = '364' WHERE code_iso = "IRN"; -UPDATE llx_c_country SET numeric_code = '372' WHERE code_iso = "IRL"; -UPDATE llx_c_country SET numeric_code = '074' WHERE code_iso = "BVT"; -UPDATE llx_c_country SET numeric_code = '833' WHERE code_iso = "IMN"; -UPDATE llx_c_country SET numeric_code = '162' WHERE code_iso = "CXR"; -UPDATE llx_c_country SET numeric_code = '352' WHERE code_iso = "ISL"; -UPDATE llx_c_country SET numeric_code = '136' WHERE code_iso = "CYM"; -UPDATE llx_c_country SET numeric_code = '166' WHERE code_iso = "CCK"; -UPDATE llx_c_country SET numeric_code = '184' WHERE code_iso = "COK"; -UPDATE llx_c_country SET numeric_code = '234' WHERE code_iso = "FRO"; -UPDATE llx_c_country SET numeric_code = '239' WHERE code_iso = "SGS"; -UPDATE llx_c_country SET numeric_code = '334' WHERE code_iso = "HMD"; -UPDATE llx_c_country SET numeric_code = '238' WHERE code_iso = "FLK"; -UPDATE llx_c_country SET numeric_code = '580' WHERE code_iso = "MNP"; -UPDATE llx_c_country SET numeric_code = '584' WHERE code_iso = "MHL"; -UPDATE llx_c_country SET numeric_code = '612' WHERE code_iso = "PCN"; -UPDATE llx_c_country SET numeric_code = '090' WHERE code_iso = "SLB"; -UPDATE llx_c_country SET numeric_code = '796' WHERE code_iso = "TCA"; -UPDATE llx_c_country SET numeric_code = '581' WHERE code_iso = "UMI"; -UPDATE llx_c_country SET numeric_code = '092' WHERE code_iso = "VGB"; -UPDATE llx_c_country SET numeric_code = '850' WHERE code_iso = "VIR"; -UPDATE llx_c_country SET numeric_code = '376' WHERE code_iso = "ISR"; -UPDATE llx_c_country SET numeric_code = '380' WHERE code_iso = "ITA"; -UPDATE llx_c_country SET numeric_code = '388' WHERE code_iso = "JAM"; -UPDATE llx_c_country SET numeric_code = '392' WHERE code_iso = "JPN"; -UPDATE llx_c_country SET numeric_code = '832' WHERE code_iso = "JEY"; -UPDATE llx_c_country SET numeric_code = '400' WHERE code_iso = "JOR"; -UPDATE llx_c_country SET numeric_code = '398' WHERE code_iso = "KAZ"; -UPDATE llx_c_country SET numeric_code = '404' WHERE code_iso = "KEN"; -UPDATE llx_c_country SET numeric_code = '417' WHERE code_iso = "KGZ"; -UPDATE llx_c_country SET numeric_code = '296' WHERE code_iso = "KIR"; -UPDATE llx_c_country SET numeric_code = '414' WHERE code_iso = "KWT"; -UPDATE llx_c_country SET numeric_code = '418' WHERE code_iso = "LAO"; -UPDATE llx_c_country SET numeric_code = '426' WHERE code_iso = "LSO"; -UPDATE llx_c_country SET numeric_code = '428' WHERE code_iso = "LVA"; -UPDATE llx_c_country SET numeric_code = '422' WHERE code_iso = "LBN"; -UPDATE llx_c_country SET numeric_code = '430' WHERE code_iso = "LBR"; -UPDATE llx_c_country SET numeric_code = '434' WHERE code_iso = "LBY"; -UPDATE llx_c_country SET numeric_code = '438' WHERE code_iso = "LIE"; -UPDATE llx_c_country SET numeric_code = '440' WHERE code_iso = "LTU"; -UPDATE llx_c_country SET numeric_code = '442' WHERE code_iso = "LUX"; -UPDATE llx_c_country SET numeric_code = '446' WHERE code_iso = "MAC"; -UPDATE llx_c_country SET numeric_code = '807' WHERE code_iso = "MKD"; -UPDATE llx_c_country SET numeric_code = '450' WHERE code_iso = "MDG"; -UPDATE llx_c_country SET numeric_code = '458' WHERE code_iso = "MYS"; -UPDATE llx_c_country SET numeric_code = '454' WHERE code_iso = "MWI"; -UPDATE llx_c_country SET numeric_code = '462' WHERE code_iso = "MDV"; -UPDATE llx_c_country SET numeric_code = '466' WHERE code_iso = "MLI"; -UPDATE llx_c_country SET numeric_code = '470' WHERE code_iso = "MLT"; -UPDATE llx_c_country SET numeric_code = '504' WHERE code_iso = "MAR"; -UPDATE llx_c_country SET numeric_code = '474' WHERE code_iso = "MTQ"; -UPDATE llx_c_country SET numeric_code = '480' WHERE code_iso = "MUS"; -UPDATE llx_c_country SET numeric_code = '478' WHERE code_iso = "MRT"; -UPDATE llx_c_country SET numeric_code = '175' WHERE code_iso = "MYT"; -UPDATE llx_c_country SET numeric_code = '484' WHERE code_iso = "MEX"; -UPDATE llx_c_country SET numeric_code = '583' WHERE code_iso = "FSM"; -UPDATE llx_c_country SET numeric_code = '498' WHERE code_iso = "MDA"; -UPDATE llx_c_country SET numeric_code = '492' WHERE code_iso = "MCO"; -UPDATE llx_c_country SET numeric_code = '496' WHERE code_iso = "MNG"; -UPDATE llx_c_country SET numeric_code = '499' WHERE code_iso = "MNE"; -UPDATE llx_c_country SET numeric_code = '500' WHERE code_iso = "MSR"; -UPDATE llx_c_country SET numeric_code = '508' WHERE code_iso = "MOZ"; -UPDATE llx_c_country SET numeric_code = '104' WHERE code_iso = "MMR"; -UPDATE llx_c_country SET numeric_code = '516' WHERE code_iso = "NAM"; -UPDATE llx_c_country SET numeric_code = '520' WHERE code_iso = "NRU"; -UPDATE llx_c_country SET numeric_code = '524' WHERE code_iso = "NPL"; -UPDATE llx_c_country SET numeric_code = '558' WHERE code_iso = "NIC"; -UPDATE llx_c_country SET numeric_code = '562' WHERE code_iso = "NER"; -UPDATE llx_c_country SET numeric_code = '566' WHERE code_iso = "NGA"; -UPDATE llx_c_country SET numeric_code = '570' WHERE code_iso = "NIU"; -UPDATE llx_c_country SET numeric_code = '574' WHERE code_iso = "NFK"; -UPDATE llx_c_country SET numeric_code = '578' WHERE code_iso = "NOR"; -UPDATE llx_c_country SET numeric_code = '540' WHERE code_iso = "NCL"; -UPDATE llx_c_country SET numeric_code = '554' WHERE code_iso = "NZL"; -UPDATE llx_c_country SET numeric_code = '512' WHERE code_iso = "OMN"; -UPDATE llx_c_country SET numeric_code = '528' WHERE code_iso = "NLD"; -UPDATE llx_c_country SET numeric_code = '586' WHERE code_iso = "PAK"; -UPDATE llx_c_country SET numeric_code = '585' WHERE code_iso = "PLW"; -UPDATE llx_c_country SET numeric_code = '275' WHERE code_iso = "PSE"; -UPDATE llx_c_country SET numeric_code = '591' WHERE code_iso = "PAN"; -UPDATE llx_c_country SET numeric_code = '598' WHERE code_iso = "PNG"; -UPDATE llx_c_country SET numeric_code = '600' WHERE code_iso = "PRY"; -UPDATE llx_c_country SET numeric_code = '604' WHERE code_iso = "PER"; -UPDATE llx_c_country SET numeric_code = '258' WHERE code_iso = "PYF"; -UPDATE llx_c_country SET numeric_code = '616' WHERE code_iso = "POL"; -UPDATE llx_c_country SET numeric_code = '620' WHERE code_iso = "PRT"; -UPDATE llx_c_country SET numeric_code = '630' WHERE code_iso = "PRI"; -UPDATE llx_c_country SET numeric_code = '826' WHERE code_iso = "GBR"; -UPDATE llx_c_country SET numeric_code = '732' WHERE code_iso = "ESH"; -UPDATE llx_c_country SET numeric_code = '140' WHERE code_iso = "CAF"; -UPDATE llx_c_country SET numeric_code = '203' WHERE code_iso = "CZE"; -UPDATE llx_c_country SET numeric_code = '178' WHERE code_iso = "COG"; -UPDATE llx_c_country SET numeric_code = '180' WHERE code_iso = "COD"; -UPDATE llx_c_country SET numeric_code = '214' WHERE code_iso = "DOM"; -UPDATE llx_c_country SET numeric_code = '638' WHERE code_iso = "REU"; -UPDATE llx_c_country SET numeric_code = '646' WHERE code_iso = "RWA"; -UPDATE llx_c_country SET numeric_code = '642' WHERE code_iso = "ROU"; -UPDATE llx_c_country SET numeric_code = '643' WHERE code_iso = "RUS"; -UPDATE llx_c_country SET numeric_code = '882' WHERE code_iso = "WSM"; -UPDATE llx_c_country SET numeric_code = '016' WHERE code_iso = "ASM"; -UPDATE llx_c_country SET numeric_code = '652' WHERE code_iso = "BLM"; -UPDATE llx_c_country SET numeric_code = '659' WHERE code_iso = "KNA"; -UPDATE llx_c_country SET numeric_code = '674' WHERE code_iso = "SMR"; -UPDATE llx_c_country SET numeric_code = '663' WHERE code_iso = "MAF"; -UPDATE llx_c_country SET numeric_code = '666' WHERE code_iso = "SPM"; -UPDATE llx_c_country SET numeric_code = '670' WHERE code_iso = "VCT"; -UPDATE llx_c_country SET numeric_code = '654' WHERE code_iso = "SHN"; -UPDATE llx_c_country SET numeric_code = '662' WHERE code_iso = "LCA"; -UPDATE llx_c_country SET numeric_code = '678' WHERE code_iso = "STP"; -UPDATE llx_c_country SET numeric_code = '686' WHERE code_iso = "SEN"; -UPDATE llx_c_country SET numeric_code = '688' WHERE code_iso = "SRB"; -UPDATE llx_c_country SET numeric_code = '690' WHERE code_iso = "SYC"; -UPDATE llx_c_country SET numeric_code = '694' WHERE code_iso = "SLE"; -UPDATE llx_c_country SET numeric_code = '702' WHERE code_iso = "SGP"; -UPDATE llx_c_country SET numeric_code = '534' WHERE code_iso = "SXM"; -UPDATE llx_c_country SET numeric_code = '760' WHERE code_iso = "SYR"; -UPDATE llx_c_country SET numeric_code = '706' WHERE code_iso = "SOM"; -UPDATE llx_c_country SET numeric_code = '144' WHERE code_iso = "LKA"; -UPDATE llx_c_country SET numeric_code = '748' WHERE code_iso = "SWZ"; -UPDATE llx_c_country SET numeric_code = '710' WHERE code_iso = "ZAF"; -UPDATE llx_c_country SET numeric_code = '729' WHERE code_iso = "SDN"; -UPDATE llx_c_country SET numeric_code = '728' WHERE code_iso = "SSD"; -UPDATE llx_c_country SET numeric_code = '752' WHERE code_iso = "SWE"; -UPDATE llx_c_country SET numeric_code = '756' WHERE code_iso = "CHE"; -UPDATE llx_c_country SET numeric_code = '740' WHERE code_iso = "SUR"; -UPDATE llx_c_country SET numeric_code = '744' WHERE code_iso = "SJM"; -UPDATE llx_c_country SET numeric_code = '764' WHERE code_iso = "THA"; -UPDATE llx_c_country SET numeric_code = '158' WHERE code_iso = "TWN"; -UPDATE llx_c_country SET numeric_code = '834' WHERE code_iso = "TZA"; -UPDATE llx_c_country SET numeric_code = '762' WHERE code_iso = "TJK"; -UPDATE llx_c_country SET numeric_code = '086' WHERE code_iso = "IOT"; -UPDATE llx_c_country SET numeric_code = '260' WHERE code_iso = "ATF"; -UPDATE llx_c_country SET numeric_code = '626' WHERE code_iso = "TLS"; -UPDATE llx_c_country SET numeric_code = '768' WHERE code_iso = "TGO"; -UPDATE llx_c_country SET numeric_code = '772' WHERE code_iso = "TKL"; -UPDATE llx_c_country SET numeric_code = '776' WHERE code_iso = "TON"; -UPDATE llx_c_country SET numeric_code = '780' WHERE code_iso = "TTO"; -UPDATE llx_c_country SET numeric_code = '788' WHERE code_iso = "TUN"; -UPDATE llx_c_country SET numeric_code = '795' WHERE code_iso = "TKM"; -UPDATE llx_c_country SET numeric_code = '792' WHERE code_iso = "TUR"; -UPDATE llx_c_country SET numeric_code = '798' WHERE code_iso = "TUV"; -UPDATE llx_c_country SET numeric_code = '804' WHERE code_iso = "UKR"; -UPDATE llx_c_country SET numeric_code = '800' WHERE code_iso = "UGA"; -UPDATE llx_c_country SET numeric_code = '858' WHERE code_iso = "URY"; -UPDATE llx_c_country SET numeric_code = '860' WHERE code_iso = "UZB"; -UPDATE llx_c_country SET numeric_code = '548' WHERE code_iso = "VUT"; -UPDATE llx_c_country SET numeric_code = '336' WHERE code_iso = "VAT"; -UPDATE llx_c_country SET numeric_code = '862' WHERE code_iso = "VEN"; -UPDATE llx_c_country SET numeric_code = '704' WHERE code_iso = "VNM"; -UPDATE llx_c_country SET numeric_code = '876' WHERE code_iso = "WLF"; -UPDATE llx_c_country SET numeric_code = '887' WHERE code_iso = "YEM"; -UPDATE llx_c_country SET numeric_code = '262' WHERE code_iso = "DJI"; -UPDATE llx_c_country SET numeric_code = '894' WHERE code_iso = "ZMB"; -UPDATE llx_c_country SET numeric_code = '716' WHERE code_iso = "ZWE"; +UPDATE llx_c_country SET numeric_code = '004' WHERE code_iso = 'AFG'; +UPDATE llx_c_country SET numeric_code = '248' WHERE code_iso = 'ALA'; +UPDATE llx_c_country SET numeric_code = '008' WHERE code_iso = 'ALB'; +UPDATE llx_c_country SET numeric_code = '276' WHERE code_iso = 'DEU'; +UPDATE llx_c_country SET numeric_code = '020' WHERE code_iso = 'AND'; +UPDATE llx_c_country SET numeric_code = '024' WHERE code_iso = 'AGO'; +UPDATE llx_c_country SET numeric_code = '660' WHERE code_iso = 'AIA'; +UPDATE llx_c_country SET numeric_code = '010' WHERE code_iso = 'ATA'; +UPDATE llx_c_country SET numeric_code = '028' WHERE code_iso = 'ATG'; +UPDATE llx_c_country SET numeric_code = '682' WHERE code_iso = 'SAU'; +UPDATE llx_c_country SET numeric_code = '012' WHERE code_iso = 'DZA'; +UPDATE llx_c_country SET numeric_code = '032' WHERE code_iso = 'ARG'; +UPDATE llx_c_country SET numeric_code = '051' WHERE code_iso = 'ARM'; +UPDATE llx_c_country SET numeric_code = '533' WHERE code_iso = 'ABW'; +UPDATE llx_c_country SET numeric_code = '036' WHERE code_iso = 'AUS'; +UPDATE llx_c_country SET numeric_code = '040' WHERE code_iso = 'AUT'; +UPDATE llx_c_country SET numeric_code = '031' WHERE code_iso = 'AZE'; +UPDATE llx_c_country SET numeric_code = '044' WHERE code_iso = 'BHS'; +UPDATE llx_c_country SET numeric_code = '050' WHERE code_iso = 'BGD'; +UPDATE llx_c_country SET numeric_code = '052' WHERE code_iso = 'BRB'; +UPDATE llx_c_country SET numeric_code = '048' WHERE code_iso = 'BHR'; +UPDATE llx_c_country SET numeric_code = '056' WHERE code_iso = 'BEL'; +UPDATE llx_c_country SET numeric_code = '084' WHERE code_iso = 'BLZ'; +UPDATE llx_c_country SET numeric_code = '204' WHERE code_iso = 'BEN'; +UPDATE llx_c_country SET numeric_code = '060' WHERE code_iso = 'BMU'; +UPDATE llx_c_country SET numeric_code = '112' WHERE code_iso = 'BLR'; +UPDATE llx_c_country SET numeric_code = '068' WHERE code_iso = 'BOL'; +UPDATE llx_c_country SET numeric_code = '535' WHERE code_iso = 'BES'; +UPDATE llx_c_country SET numeric_code = '070' WHERE code_iso = 'BIH'; +UPDATE llx_c_country SET numeric_code = '072' WHERE code_iso = 'BWA'; +UPDATE llx_c_country SET numeric_code = '076' WHERE code_iso = 'BRA'; +UPDATE llx_c_country SET numeric_code = '096' WHERE code_iso = 'BRN'; +UPDATE llx_c_country SET numeric_code = '100' WHERE code_iso = 'BGR'; +UPDATE llx_c_country SET numeric_code = '854' WHERE code_iso = 'BFA'; +UPDATE llx_c_country SET numeric_code = '108' WHERE code_iso = 'BDI'; +UPDATE llx_c_country SET numeric_code = '064' WHERE code_iso = 'BTN'; +UPDATE llx_c_country SET numeric_code = '132' WHERE code_iso = 'CPV'; +UPDATE llx_c_country SET numeric_code = '116' WHERE code_iso = 'KHM'; +UPDATE llx_c_country SET numeric_code = '120' WHERE code_iso = 'CMR'; +UPDATE llx_c_country SET numeric_code = '124' WHERE code_iso = 'CAN'; +UPDATE llx_c_country SET numeric_code = '634' WHERE code_iso = 'QAT'; +UPDATE llx_c_country SET numeric_code = '148' WHERE code_iso = 'TCD'; +UPDATE llx_c_country SET numeric_code = '152' WHERE code_iso = 'CHL'; +UPDATE llx_c_country SET numeric_code = '156' WHERE code_iso = 'CHN'; +UPDATE llx_c_country SET numeric_code = '196' WHERE code_iso = 'CYP'; +UPDATE llx_c_country SET numeric_code = '170' WHERE code_iso = 'COL'; +UPDATE llx_c_country SET numeric_code = '174' WHERE code_iso = 'COM'; +UPDATE llx_c_country SET numeric_code = '408' WHERE code_iso = 'PRK'; +UPDATE llx_c_country SET numeric_code = '410' WHERE code_iso = 'KOR'; +UPDATE llx_c_country SET numeric_code = '384' WHERE code_iso = 'CIV'; +UPDATE llx_c_country SET numeric_code = '188' WHERE code_iso = 'CRI'; +UPDATE llx_c_country SET numeric_code = '191' WHERE code_iso = 'HRV'; +UPDATE llx_c_country SET numeric_code = '192' WHERE code_iso = 'CUB'; +UPDATE llx_c_country SET numeric_code = '531' WHERE code_iso = 'CUW'; +UPDATE llx_c_country SET numeric_code = '208' WHERE code_iso = 'DNK'; +UPDATE llx_c_country SET numeric_code = '212' WHERE code_iso = 'DMA'; +UPDATE llx_c_country SET numeric_code = '218' WHERE code_iso = 'ECU'; +UPDATE llx_c_country SET numeric_code = '818' WHERE code_iso = 'EGY'; +UPDATE llx_c_country SET numeric_code = '222' WHERE code_iso = 'SLV'; +UPDATE llx_c_country SET numeric_code = '784' WHERE code_iso = 'ARE'; +UPDATE llx_c_country SET numeric_code = '232' WHERE code_iso = 'ERI'; +UPDATE llx_c_country SET numeric_code = '703' WHERE code_iso = 'SVK'; +UPDATE llx_c_country SET numeric_code = '705' WHERE code_iso = 'SVN'; +UPDATE llx_c_country SET numeric_code = '724' WHERE code_iso = 'ESP'; +UPDATE llx_c_country SET numeric_code = '840' WHERE code_iso = 'USA'; +UPDATE llx_c_country SET numeric_code = '233' WHERE code_iso = 'EST'; +UPDATE llx_c_country SET numeric_code = '231' WHERE code_iso = 'ETH'; +UPDATE llx_c_country SET numeric_code = '608' WHERE code_iso = 'PHL'; +UPDATE llx_c_country SET numeric_code = '246' WHERE code_iso = 'FIN'; +UPDATE llx_c_country SET numeric_code = '242' WHERE code_iso = 'FJI'; +UPDATE llx_c_country SET numeric_code = '250' WHERE code_iso = 'FRA'; +UPDATE llx_c_country SET numeric_code = '266' WHERE code_iso = 'GAB'; +UPDATE llx_c_country SET numeric_code = '270' WHERE code_iso = 'GMB'; +UPDATE llx_c_country SET numeric_code = '268' WHERE code_iso = 'GEO'; +UPDATE llx_c_country SET numeric_code = '288' WHERE code_iso = 'GHA'; +UPDATE llx_c_country SET numeric_code = '292' WHERE code_iso = 'GIB'; +UPDATE llx_c_country SET numeric_code = '308' WHERE code_iso = 'GRD'; +UPDATE llx_c_country SET numeric_code = '300' WHERE code_iso = 'GRC'; +UPDATE llx_c_country SET numeric_code = '304' WHERE code_iso = 'GRL'; +UPDATE llx_c_country SET numeric_code = '312' WHERE code_iso = 'GLP'; +UPDATE llx_c_country SET numeric_code = '316' WHERE code_iso = 'GUM'; +UPDATE llx_c_country SET numeric_code = '320' WHERE code_iso = 'GTM'; +UPDATE llx_c_country SET numeric_code = '254' WHERE code_iso = 'GUF'; +UPDATE llx_c_country SET numeric_code = '831' WHERE code_iso = 'GGY'; +UPDATE llx_c_country SET numeric_code = '324' WHERE code_iso = 'GIN'; +UPDATE llx_c_country SET numeric_code = '624' WHERE code_iso = 'GNB'; +UPDATE llx_c_country SET numeric_code = '226' WHERE code_iso = 'GNQ'; +UPDATE llx_c_country SET numeric_code = '328' WHERE code_iso = 'GUY'; +UPDATE llx_c_country SET numeric_code = '332' WHERE code_iso = 'HTI'; +UPDATE llx_c_country SET numeric_code = '340' WHERE code_iso = 'HND'; +UPDATE llx_c_country SET numeric_code = '344' WHERE code_iso = 'HKG'; +UPDATE llx_c_country SET numeric_code = '348' WHERE code_iso = 'HUN'; +UPDATE llx_c_country SET numeric_code = '356' WHERE code_iso = 'IND'; +UPDATE llx_c_country SET numeric_code = '360' WHERE code_iso = 'IDN'; +UPDATE llx_c_country SET numeric_code = '368' WHERE code_iso = 'IRQ'; +UPDATE llx_c_country SET numeric_code = '364' WHERE code_iso = 'IRN'; +UPDATE llx_c_country SET numeric_code = '372' WHERE code_iso = 'IRL'; +UPDATE llx_c_country SET numeric_code = '074' WHERE code_iso = 'BVT'; +UPDATE llx_c_country SET numeric_code = '833' WHERE code_iso = 'IMN'; +UPDATE llx_c_country SET numeric_code = '162' WHERE code_iso = 'CXR'; +UPDATE llx_c_country SET numeric_code = '352' WHERE code_iso = 'ISL'; +UPDATE llx_c_country SET numeric_code = '136' WHERE code_iso = 'CYM'; +UPDATE llx_c_country SET numeric_code = '166' WHERE code_iso = 'CCK'; +UPDATE llx_c_country SET numeric_code = '184' WHERE code_iso = 'COK'; +UPDATE llx_c_country SET numeric_code = '234' WHERE code_iso = 'FRO'; +UPDATE llx_c_country SET numeric_code = '239' WHERE code_iso = 'SGS'; +UPDATE llx_c_country SET numeric_code = '334' WHERE code_iso = 'HMD'; +UPDATE llx_c_country SET numeric_code = '238' WHERE code_iso = 'FLK'; +UPDATE llx_c_country SET numeric_code = '580' WHERE code_iso = 'MNP'; +UPDATE llx_c_country SET numeric_code = '584' WHERE code_iso = 'MHL'; +UPDATE llx_c_country SET numeric_code = '612' WHERE code_iso = 'PCN'; +UPDATE llx_c_country SET numeric_code = '090' WHERE code_iso = 'SLB'; +UPDATE llx_c_country SET numeric_code = '796' WHERE code_iso = 'TCA'; +UPDATE llx_c_country SET numeric_code = '581' WHERE code_iso = 'UMI'; +UPDATE llx_c_country SET numeric_code = '092' WHERE code_iso = 'VGB'; +UPDATE llx_c_country SET numeric_code = '850' WHERE code_iso = 'VIR'; +UPDATE llx_c_country SET numeric_code = '376' WHERE code_iso = 'ISR'; +UPDATE llx_c_country SET numeric_code = '380' WHERE code_iso = 'ITA'; +UPDATE llx_c_country SET numeric_code = '388' WHERE code_iso = 'JAM'; +UPDATE llx_c_country SET numeric_code = '392' WHERE code_iso = 'JPN'; +UPDATE llx_c_country SET numeric_code = '832' WHERE code_iso = 'JEY'; +UPDATE llx_c_country SET numeric_code = '400' WHERE code_iso = 'JOR'; +UPDATE llx_c_country SET numeric_code = '398' WHERE code_iso = 'KAZ'; +UPDATE llx_c_country SET numeric_code = '404' WHERE code_iso = 'KEN'; +UPDATE llx_c_country SET numeric_code = '417' WHERE code_iso = 'KGZ'; +UPDATE llx_c_country SET numeric_code = '296' WHERE code_iso = 'KIR'; +UPDATE llx_c_country SET numeric_code = '414' WHERE code_iso = 'KWT'; +UPDATE llx_c_country SET numeric_code = '418' WHERE code_iso = 'LAO'; +UPDATE llx_c_country SET numeric_code = '426' WHERE code_iso = 'LSO'; +UPDATE llx_c_country SET numeric_code = '428' WHERE code_iso = 'LVA'; +UPDATE llx_c_country SET numeric_code = '422' WHERE code_iso = 'LBN'; +UPDATE llx_c_country SET numeric_code = '430' WHERE code_iso = 'LBR'; +UPDATE llx_c_country SET numeric_code = '434' WHERE code_iso = 'LBY'; +UPDATE llx_c_country SET numeric_code = '438' WHERE code_iso = 'LIE'; +UPDATE llx_c_country SET numeric_code = '440' WHERE code_iso = 'LTU'; +UPDATE llx_c_country SET numeric_code = '442' WHERE code_iso = 'LUX'; +UPDATE llx_c_country SET numeric_code = '446' WHERE code_iso = 'MAC'; +UPDATE llx_c_country SET numeric_code = '807' WHERE code_iso = 'MKD'; +UPDATE llx_c_country SET numeric_code = '450' WHERE code_iso = 'MDG'; +UPDATE llx_c_country SET numeric_code = '458' WHERE code_iso = 'MYS'; +UPDATE llx_c_country SET numeric_code = '454' WHERE code_iso = 'MWI'; +UPDATE llx_c_country SET numeric_code = '462' WHERE code_iso = 'MDV'; +UPDATE llx_c_country SET numeric_code = '466' WHERE code_iso = 'MLI'; +UPDATE llx_c_country SET numeric_code = '470' WHERE code_iso = 'MLT'; +UPDATE llx_c_country SET numeric_code = '504' WHERE code_iso = 'MAR'; +UPDATE llx_c_country SET numeric_code = '474' WHERE code_iso = 'MTQ'; +UPDATE llx_c_country SET numeric_code = '480' WHERE code_iso = 'MUS'; +UPDATE llx_c_country SET numeric_code = '478' WHERE code_iso = 'MRT'; +UPDATE llx_c_country SET numeric_code = '175' WHERE code_iso = 'MYT'; +UPDATE llx_c_country SET numeric_code = '484' WHERE code_iso = 'MEX'; +UPDATE llx_c_country SET numeric_code = '583' WHERE code_iso = 'FSM'; +UPDATE llx_c_country SET numeric_code = '498' WHERE code_iso = 'MDA'; +UPDATE llx_c_country SET numeric_code = '492' WHERE code_iso = 'MCO'; +UPDATE llx_c_country SET numeric_code = '496' WHERE code_iso = 'MNG'; +UPDATE llx_c_country SET numeric_code = '499' WHERE code_iso = 'MNE'; +UPDATE llx_c_country SET numeric_code = '500' WHERE code_iso = 'MSR'; +UPDATE llx_c_country SET numeric_code = '508' WHERE code_iso = 'MOZ'; +UPDATE llx_c_country SET numeric_code = '104' WHERE code_iso = 'MMR'; +UPDATE llx_c_country SET numeric_code = '516' WHERE code_iso = 'NAM'; +UPDATE llx_c_country SET numeric_code = '520' WHERE code_iso = 'NRU'; +UPDATE llx_c_country SET numeric_code = '524' WHERE code_iso = 'NPL'; +UPDATE llx_c_country SET numeric_code = '558' WHERE code_iso = 'NIC'; +UPDATE llx_c_country SET numeric_code = '562' WHERE code_iso = 'NER'; +UPDATE llx_c_country SET numeric_code = '566' WHERE code_iso = 'NGA'; +UPDATE llx_c_country SET numeric_code = '570' WHERE code_iso = 'NIU'; +UPDATE llx_c_country SET numeric_code = '574' WHERE code_iso = 'NFK'; +UPDATE llx_c_country SET numeric_code = '578' WHERE code_iso = 'NOR'; +UPDATE llx_c_country SET numeric_code = '540' WHERE code_iso = 'NCL'; +UPDATE llx_c_country SET numeric_code = '554' WHERE code_iso = 'NZL'; +UPDATE llx_c_country SET numeric_code = '512' WHERE code_iso = 'OMN'; +UPDATE llx_c_country SET numeric_code = '528' WHERE code_iso = 'NLD'; +UPDATE llx_c_country SET numeric_code = '586' WHERE code_iso = 'PAK'; +UPDATE llx_c_country SET numeric_code = '585' WHERE code_iso = 'PLW'; +UPDATE llx_c_country SET numeric_code = '275' WHERE code_iso = 'PSE'; +UPDATE llx_c_country SET numeric_code = '591' WHERE code_iso = 'PAN'; +UPDATE llx_c_country SET numeric_code = '598' WHERE code_iso = 'PNG'; +UPDATE llx_c_country SET numeric_code = '600' WHERE code_iso = 'PRY'; +UPDATE llx_c_country SET numeric_code = '604' WHERE code_iso = 'PER'; +UPDATE llx_c_country SET numeric_code = '258' WHERE code_iso = 'PYF'; +UPDATE llx_c_country SET numeric_code = '616' WHERE code_iso = 'POL'; +UPDATE llx_c_country SET numeric_code = '620' WHERE code_iso = 'PRT'; +UPDATE llx_c_country SET numeric_code = '630' WHERE code_iso = 'PRI'; +UPDATE llx_c_country SET numeric_code = '826' WHERE code_iso = 'GBR'; +UPDATE llx_c_country SET numeric_code = '732' WHERE code_iso = 'ESH'; +UPDATE llx_c_country SET numeric_code = '140' WHERE code_iso = 'CAF'; +UPDATE llx_c_country SET numeric_code = '203' WHERE code_iso = 'CZE'; +UPDATE llx_c_country SET numeric_code = '178' WHERE code_iso = 'COG'; +UPDATE llx_c_country SET numeric_code = '180' WHERE code_iso = 'COD'; +UPDATE llx_c_country SET numeric_code = '214' WHERE code_iso = 'DOM'; +UPDATE llx_c_country SET numeric_code = '638' WHERE code_iso = 'REU'; +UPDATE llx_c_country SET numeric_code = '646' WHERE code_iso = 'RWA'; +UPDATE llx_c_country SET numeric_code = '642' WHERE code_iso = 'ROU'; +UPDATE llx_c_country SET numeric_code = '643' WHERE code_iso = 'RUS'; +UPDATE llx_c_country SET numeric_code = '882' WHERE code_iso = 'WSM'; +UPDATE llx_c_country SET numeric_code = '016' WHERE code_iso = 'ASM'; +UPDATE llx_c_country SET numeric_code = '652' WHERE code_iso = 'BLM'; +UPDATE llx_c_country SET numeric_code = '659' WHERE code_iso = 'KNA'; +UPDATE llx_c_country SET numeric_code = '674' WHERE code_iso = 'SMR'; +UPDATE llx_c_country SET numeric_code = '663' WHERE code_iso = 'MAF'; +UPDATE llx_c_country SET numeric_code = '666' WHERE code_iso = 'SPM'; +UPDATE llx_c_country SET numeric_code = '670' WHERE code_iso = 'VCT'; +UPDATE llx_c_country SET numeric_code = '654' WHERE code_iso = 'SHN'; +UPDATE llx_c_country SET numeric_code = '662' WHERE code_iso = 'LCA'; +UPDATE llx_c_country SET numeric_code = '678' WHERE code_iso = 'STP'; +UPDATE llx_c_country SET numeric_code = '686' WHERE code_iso = 'SEN'; +UPDATE llx_c_country SET numeric_code = '688' WHERE code_iso = 'SRB'; +UPDATE llx_c_country SET numeric_code = '690' WHERE code_iso = 'SYC'; +UPDATE llx_c_country SET numeric_code = '694' WHERE code_iso = 'SLE'; +UPDATE llx_c_country SET numeric_code = '702' WHERE code_iso = 'SGP'; +UPDATE llx_c_country SET numeric_code = '534' WHERE code_iso = 'SXM'; +UPDATE llx_c_country SET numeric_code = '760' WHERE code_iso = 'SYR'; +UPDATE llx_c_country SET numeric_code = '706' WHERE code_iso = 'SOM'; +UPDATE llx_c_country SET numeric_code = '144' WHERE code_iso = 'LKA'; +UPDATE llx_c_country SET numeric_code = '748' WHERE code_iso = 'SWZ'; +UPDATE llx_c_country SET numeric_code = '710' WHERE code_iso = 'ZAF'; +UPDATE llx_c_country SET numeric_code = '729' WHERE code_iso = 'SDN'; +UPDATE llx_c_country SET numeric_code = '728' WHERE code_iso = 'SSD'; +UPDATE llx_c_country SET numeric_code = '752' WHERE code_iso = 'SWE'; +UPDATE llx_c_country SET numeric_code = '756' WHERE code_iso = 'CHE'; +UPDATE llx_c_country SET numeric_code = '740' WHERE code_iso = 'SUR'; +UPDATE llx_c_country SET numeric_code = '744' WHERE code_iso = 'SJM'; +UPDATE llx_c_country SET numeric_code = '764' WHERE code_iso = 'THA'; +UPDATE llx_c_country SET numeric_code = '158' WHERE code_iso = 'TWN'; +UPDATE llx_c_country SET numeric_code = '834' WHERE code_iso = 'TZA'; +UPDATE llx_c_country SET numeric_code = '762' WHERE code_iso = 'TJK'; +UPDATE llx_c_country SET numeric_code = '086' WHERE code_iso = 'IOT'; +UPDATE llx_c_country SET numeric_code = '260' WHERE code_iso = 'ATF'; +UPDATE llx_c_country SET numeric_code = '626' WHERE code_iso = 'TLS'; +UPDATE llx_c_country SET numeric_code = '768' WHERE code_iso = 'TGO'; +UPDATE llx_c_country SET numeric_code = '772' WHERE code_iso = 'TKL'; +UPDATE llx_c_country SET numeric_code = '776' WHERE code_iso = 'TON'; +UPDATE llx_c_country SET numeric_code = '780' WHERE code_iso = 'TTO'; +UPDATE llx_c_country SET numeric_code = '788' WHERE code_iso = 'TUN'; +UPDATE llx_c_country SET numeric_code = '795' WHERE code_iso = 'TKM'; +UPDATE llx_c_country SET numeric_code = '792' WHERE code_iso = 'TUR'; +UPDATE llx_c_country SET numeric_code = '798' WHERE code_iso = 'TUV'; +UPDATE llx_c_country SET numeric_code = '804' WHERE code_iso = 'UKR'; +UPDATE llx_c_country SET numeric_code = '800' WHERE code_iso = 'UGA'; +UPDATE llx_c_country SET numeric_code = '858' WHERE code_iso = 'URY'; +UPDATE llx_c_country SET numeric_code = '860' WHERE code_iso = 'UZB'; +UPDATE llx_c_country SET numeric_code = '548' WHERE code_iso = 'VUT'; +UPDATE llx_c_country SET numeric_code = '336' WHERE code_iso = 'VAT'; +UPDATE llx_c_country SET numeric_code = '862' WHERE code_iso = 'VEN'; +UPDATE llx_c_country SET numeric_code = '704' WHERE code_iso = 'VNM'; +UPDATE llx_c_country SET numeric_code = '876' WHERE code_iso = 'WLF'; +UPDATE llx_c_country SET numeric_code = '887' WHERE code_iso = 'YEM'; +UPDATE llx_c_country SET numeric_code = '262' WHERE code_iso = 'DJI'; +UPDATE llx_c_country SET numeric_code = '894' WHERE code_iso = 'ZMB'; +UPDATE llx_c_country SET numeric_code = '716' WHERE code_iso = 'ZWE'; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 8db29a87449..dfd90b4dc0f 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1046,13 +1046,13 @@ if ($action == 'create' || $action == 'adduserldap') { if (preg_match('/http/', $dolibarr_main_authentication)) { $valuetoshow .= ($valuetoshow ? ' + ' : '').$langs->trans("HTTPBasicPassword"); } - if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { + if (preg_match('/dolibarr/', $dolibarr_main_authentication) || preg_match('/forceuser/', $dolibarr_main_authentication)) { if (!empty($ldap_pass)) { // For very old system comaptibilty. Now clear password can't be viewed from LDAP read $valuetoshow .= ($valuetoshow ? ' + ' : '').''; // Dolibarr password is preffiled with LDAP known password $valuetoshow .= preg_replace('/./i', '*', $ldap_pass); } else { // We do not use a field password but a field text to show new password to use. - $valuetoshow .= ($valuetoshow ? ' + '.$langs->trans("DolibarrPassword") : '').''; + $valuetoshow .= ($valuetoshow ? ' + '.$langs->trans("DolibarrPassword") : '').''; if (!empty($conf->use_javascript_ajax)) { $valuetoshow .= ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_password" class="linkobject"'); } @@ -1076,7 +1076,7 @@ if ($action == 'create' || $action == 'adduserldap') { //$generated_password = getRandomPassword(false); print ''.$langs->trans("ApiKey").''; print ''; - print ''; + print ''; if (!empty($conf->use_javascript_ajax)) { print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"'); } @@ -2423,14 +2423,16 @@ if ($action == 'create' || $action == 'adduserldap') { if (preg_match('/http/', $dolibarr_main_authentication)) { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$form->textwithpicto($text, $langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless", $dolibarr_main_authentication), 1, 'warning'); } - if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { + if (preg_match('/dolibarr/', $dolibarr_main_authentication) || preg_match('/forceuser/', $dolibarr_main_authentication)) { if ($caneditpassword) { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''; + if (!empty($conf->use_javascript_ajax)) { + $valuetoshow .= ' '.img_picto((getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? $langs->trans('NoPasswordGenerationRuleConfigured') : $langs->trans('Generate')), 'refresh', 'id="generate_password" class="'.(getDolGlobalString('USER_PASSWORD_GENERATED') === 'none' ? ' opacitymedium' : ' linkobject').'"'); + } } else { $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').preg_replace('/./i', '*', $object->pass); } } - // Other form for user password $parameters = array('valuetoshow' => $valuetoshow, 'caneditpassword' => $caneditpassword); $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook From ca096089fb8c5d26d0fdb2914f0a79ffbfa0e931 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Mar 2023 16:28:58 +0100 Subject: [PATCH 82/84] Debug v18 --- htdocs/public/users/view.php | 15 ++++++++++++++- htdocs/user/class/user.class.php | 7 ++++++- htdocs/user/virtualcard.php | 7 ++++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/htdocs/public/users/view.php b/htdocs/public/users/view.php index 30b76404472..c62420c76d8 100644 --- a/htdocs/public/users/view.php +++ b/htdocs/public/users/view.php @@ -205,7 +205,7 @@ $arrayofjs = array(); $arrayofcss = array(); $replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
' : '').'
'; -llxHeader($head, $object->getFullName($langs).' - '.$langs->trans("PublicVirtualCard"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'.(GETPOST('mode')=='preview' ? ' scalepreview nopointervent' : ''), $replacemainarea, 1, 1); +llxHeader($head, $object->getFullName($langs).' - '.$langs->trans("PublicVirtualCard"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'.(GETPOST('mode')=='preview' ? ' scalepreview cursorpointer virtualcardpreview' : ''), $replacemainarea, 1, 1); print ''."\n"; print '
'."\n"; @@ -463,6 +463,19 @@ print '
'; //print '
'; print '
'; +$fullexternaleurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'external'); +$fullinternalurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'internal'); + +print ''; + llxFooter('', 'public'); $db->close(); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index fac112bd7b4..1186cf7a914 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -3869,9 +3869,10 @@ class User extends CommonObject * Return string with full Url to virtual card * * @param string $mode Mode for link + * @param string $typeofurl 'external' or 'internal' * @return string Url string link */ - public function getOnlineVirtualCardUrl($mode = '') + public function getOnlineVirtualCardUrl($mode = '', $typeofurl = 'external') { global $dolibarr_main_instance_unique_id, $dolibarr_main_url_root; global $conf; @@ -3887,6 +3888,10 @@ class User extends CommonObject $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + if ($typeofurl == 'internal') { + $urlwithroot = DOL_URL_ROOT; + } + return $urlwithroot.'/public/users/view.php?id='.$this->id.'&securekey='.$encodedsecurekey.$entity_qr.($mode ? '&mode='.urlencode($mode) : ''); } diff --git a/htdocs/user/virtualcard.php b/htdocs/user/virtualcard.php index 252ae3aca80..55d63c3d40a 100644 --- a/htdocs/user/virtualcard.php +++ b/htdocs/user/virtualcard.php @@ -165,7 +165,8 @@ if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) { //print $langs->trans('FollowingLinksArePublic').'
'; print img_picto('', 'globe').' '.$langs->trans('PublicVirtualCardUrl').'
'; - $fullexternaleurltovirtualcard = $object->getOnlineVirtualCardUrl(); + $fullexternaleurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'external'); + $fullinternalurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'internal'); print '