From de62e4cdb893bd071421f3cda1605a9186c07c42 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 3 Jul 2016 11:11:43 +0200 Subject: [PATCH 01/37] CSV import : refactor SQL insert construction --- .../modules/import/import_csv.modules.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 895ed6de89d..3fbbae17a9e 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -557,22 +557,22 @@ class ImportCsv extends ModeleImports if ($listfields) { //var_dump($objimport->array_import_convertvalue); exit; + + // Build SQL UPDATE request + $sqlstart = 'UPDATE '.$tablename; - // Build SQL request - if (empty($tablewithentity_cache[$tablename])) - { - $sql ='INSERT INTO '.$tablename.'('.$listfields.', import_key'; - if (! empty($objimport->array_import_tables_creator[0][$alias])) $sql.=', '.$objimport->array_import_tables_creator[0][$alias]; - $sql.=') VALUES('.$listvalues.", '".$importid."'"; + // Build SQL INSERT request + $sqlstart = 'INSERT INTO '.$tablename.'('.$listfields.', import_key'; + $sqlend = ') VALUES('.$listvalues.", '".$importid."'"; + if (! empty($tablewithentity_cache[$tablename])) { + $sqlstart.= ', entity'; + $sqlend.= ', '.$conf->entity; + } + if (! empty($objimport->array_import_tables_creator[0][$alias])) { + $sqlstart.= ', '.$objimport->array_import_tables_creator[0][$alias]; + $sqlend.=', '.$user->id; } - else - { - $sql ='INSERT INTO '.$tablename.'('.$listfields.', import_key, entity'; - if (! empty($objimport->array_import_tables_creator[0][$alias])) $sql.=', '.$objimport->array_import_tables_creator[0][$alias]; - $sql.=') VALUES('.$listvalues.", '".$importid."', ".$conf->entity ; - } - if (! empty($objimport->array_import_tables_creator[0][$alias])) $sql.=', '.$user->id; - $sql.=')'; + $sql = $sqlstart.$sqlend.')'; dol_syslog("import_csv.modules", LOG_DEBUG); //print '> '.join(',',$arrayrecord); From 142aedc0cd7551c712bc62b105b4b280e69571b3 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 3 Jul 2016 11:15:28 +0200 Subject: [PATCH 02/37] CSV import : listfields and listvalues are now arrays --- .../modules/import/import_csv.modules.php | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 3fbbae17a9e..0a78f59ab03 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -304,8 +304,8 @@ class ImportCsv extends ModeleImports { // Build sql request $sql=''; - $listfields=''; - $listvalues=''; + $listfields=array(); + $listvalues=array(); $i=0; $errorforthistable=0; @@ -514,36 +514,34 @@ class ImportCsv extends ModeleImports } // Define $listfields and $listvalues to build SQL request - if ($listfields) { $listfields.=', '; $listvalues.=', '; } - $listfields.=$fieldname; + $listfields[] = $fieldname; // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert - if (empty($newval) && $arrayrecord[($key-1)]['type'] < 0) $listvalues.=($newval=='0'?$newval:"null"); - elseif (empty($newval) && $arrayrecord[($key-1)]['type'] == 0) $listvalues.="''"; - else $listvalues.="'".$this->db->escape($newval)."'"; + if (empty($newval) && $arrayrecord[($key-1)]['type'] < 0) $listvalues[] = ($newval=='0'?$newval:"null"); + elseif (empty($newval) && $arrayrecord[($key-1)]['type'] == 0) $listvalues[] = "''"; + else $listvalues[] = "'".$this->db->escape($newval)."'"; } $i++; } // We add hidden fields (but only if there is at least one field to add into table) - if ($listfields && is_array($objimport->array_import_fieldshidden[0])) + if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) { // Loop on each hidden fields to add them into listfields/listvalues foreach($objimport->array_import_fieldshidden[0] as $key => $val) { if (! preg_match('/^'.preg_quote($alias).'\./', $key)) continue; // Not a field of current table - if ($listfields) { $listfields.=', '; $listvalues.=', '; } if ($val == 'user->id') { - $listfields.=preg_replace('/^'.preg_quote($alias).'\./','',$key); - $listvalues.=$user->id; + $listfields[] = preg_replace('/^'.preg_quote($alias).'\./','',$key); + $listvalues[] = $user->id; } elseif (preg_match('/^lastrowid-/',$val)) { $tmp=explode('-',$val); $lastinsertid=(isset($last_insert_id_array[$tmp[1]]))?$last_insert_id_array[$tmp[1]]:0; - $listfields.=preg_replace('/^'.preg_quote($alias).'\./','',$key); - $listvalues.=$lastinsertid; + $listfields[] = preg_replace('/^'.preg_quote($alias).'\./','',$key); + $listvalues[] = $lastinsertid; //print $key."-".$val."-".$listfields."-".$listvalues."
";exit; } } @@ -554,7 +552,7 @@ class ImportCsv extends ModeleImports if (! $errorforthistable) { //print "$alias/$tablename/$listfields/$listvalues
"; - if ($listfields) + if (!empty($listfields)) { //var_dump($objimport->array_import_convertvalue); exit; @@ -562,8 +560,8 @@ class ImportCsv extends ModeleImports $sqlstart = 'UPDATE '.$tablename; // Build SQL INSERT request - $sqlstart = 'INSERT INTO '.$tablename.'('.$listfields.', import_key'; - $sqlend = ') VALUES('.$listvalues.", '".$importid."'"; + $sqlstart = 'INSERT INTO '.$tablename.'('.implode(', ', $listfields).', import_key'; + $sqlend = ') VALUES('.implode(', ', $listvalues).", '".$importid."'"; if (! empty($tablewithentity_cache[$tablename])) { $sqlstart.= ', entity'; $sqlend.= ', '.$conf->entity; From a950eb399c0490d6963eac79e3467edecaf1555e Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 7 Jul 2016 18:55:15 +0200 Subject: [PATCH 03/37] =?UTF-8?q?Commit=20nul=20pour=20des=20CRLF,=20?= =?UTF-8?q?=C3=A0=20reverter=20+=20tard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../phpoffice/phpexcel/Classes/PHPExcel/locale/cs/config | 2 +- .../phpoffice/phpexcel/Classes/PHPExcel/locale/cs/functions | 2 +- .../phpoffice/phpexcel/Classes/PHPExcel/locale/da/config | 4 ++-- .../phpoffice/phpexcel/Classes/PHPExcel/locale/da/functions | 2 +- .../phpoffice/phpexcel/Classes/PHPExcel/locale/de/config | 4 ++-- .../phpoffice/phpexcel/Classes/PHPExcel/locale/de/functions | 2 +- .../phpoffice/phpexcel/Classes/PHPExcel/locale/en/uk/config | 2 +- .../phpoffice/phpexcel/Classes/PHPExcel/locale/es/config | 4 ++-- .../phpoffice/phpexcel/Classes/PHPExcel/locale/es/functions | 2 +- .../phpoffice/phpexcel/Classes/PHPExcel/locale/fi/config | 4 ++-- .../phpoffice/phpexcel/Classes/PHPExcel/locale/fi/functions | 2 +- .../phpoffice/phpexcel/Classes/PHPExcel/locale/fr/config | 4 ++-- .../phpoffice/phpexcel/Classes/PHPExcel/locale/fr/functions | 2 +- .../phpoffice/phpexcel/Classes/PHPExcel/locale/hu/config | 2 +- .../phpoffice/phpexcel/Classes/PHPExcel/locale/hu/functions | 2 +- .../phpoffice/phpexcel/Classes/PHPExcel/locale/it/config | 4 ++-- .../phpoffice/phpexcel/Classes/PHPExcel/locale/it/functions | 2 +- .../phpoffice/phpexcel/Classes/PHPExcel/locale/nl/config | 4 ++-- .../phpoffice/phpexcel/Classes/PHPExcel/locale/nl/functions | 2 +- .../phpoffice/phpexcel/Classes/PHPExcel/locale/no/config | 4 ++-- .../phpoffice/phpexcel/Classes/PHPExcel/locale/no/functions | 2 +- .../phpoffice/phpexcel/Classes/PHPExcel/locale/pl/config | 4 ++-- .../phpoffice/phpexcel/Classes/PHPExcel/locale/pl/functions | 2 +- .../phpoffice/phpexcel/Classes/PHPExcel/locale/pt/br/config | 4 ++-- .../phpoffice/phpexcel/Classes/PHPExcel/locale/pt/config | 4 ++-- .../phpoffice/phpexcel/Classes/PHPExcel/locale/ru/config | 4 ++-- .../phpoffice/phpexcel/Classes/PHPExcel/locale/ru/functions | 2 +- .../phpoffice/phpexcel/Classes/PHPExcel/locale/sv/config | 4 ++-- .../phpoffice/phpexcel/Classes/PHPExcel/locale/tr/config | 4 ++-- .../phpoffice/phpexcel/Classes/PHPExcel/locale/tr/functions | 2 +- 30 files changed, 44 insertions(+), 44 deletions(-) diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/cs/config b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/cs/config index 500460e8ab5..8992916acaf 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/cs/config +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/cs/config @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/cs/functions b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/cs/functions index b648e20c2b0..f9d69784ae2 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/cs/functions +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/cs/functions @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/da/config b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/da/config index b959379b133..cef47e9502d 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/da/config +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/da/config @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or @@ -37,7 +37,7 @@ currencySymbol = kr ## -## Excel Error Codes (For future use) +## Excel Error Codes (For future use) ## NULL = #NUL! DIV0 = #DIVISION/0! diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/da/functions b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/da/functions index 1599ccd1815..1db4d30bb1c 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/da/functions +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/da/functions @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/de/config b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/de/config index 7e2ba9d2891..ff7e29899cc 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/de/config +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/de/config @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or @@ -36,7 +36,7 @@ currencySymbol = € ## -## Excel Error Codes (For future use) +## Excel Error Codes (For future use) ## NULL = #NULL! DIV0 = #DIV/0! diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/de/functions b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/de/functions index 8214f384878..ce85641a3c9 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/de/functions +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/de/functions @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/en/uk/config b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/en/uk/config index 00acff8bc34..f008e61cc90 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/en/uk/config +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/en/uk/config @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/es/config b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/es/config index 8f7d9e084ec..fa16f5639df 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/es/config +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/es/config @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or @@ -36,7 +36,7 @@ currencySymbol = $ ## I'm surprised that the Excel Documentation suggests $ rath ## -## Excel Error Codes (For future use) +## Excel Error Codes (For future use) ## NULL = #¡NULO! DIV0 = #¡DIV/0! diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/es/functions b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/es/functions index aa065969f3d..51ce48b3153 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/es/functions +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/es/functions @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/fi/config b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/fi/config index 36bc3fc70b8..a481864a6fa 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/fi/config +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/fi/config @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or @@ -36,7 +36,7 @@ currencySymbol = $ # Symbol not known, should it be a € (Euro)? ## -## Excel Error Codes (For future use) +## Excel Error Codes (For future use) ## NULL = #TYHJÄ! DIV0 = #JAKO/0! diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/fi/functions b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/fi/functions index c10b3b9f381..7bed722a641 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/fi/functions +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/fi/functions @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/fr/config b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/fr/config index 80f7d5411a6..2240d6b9f8b 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/fr/config +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/fr/config @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or @@ -36,7 +36,7 @@ currencySymbol = € ## -## Excel Error Codes (For future use) +## Excel Error Codes (For future use) ## NULL = #NUL! DIV0 = #DIV/0! diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/fr/functions b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/fr/functions index cce977b15bc..8d25f6ac193 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/fr/functions +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/fr/functions @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/hu/config b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/hu/config index c6c315814c4..dec7cbde15d 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/hu/config +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/hu/config @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/hu/functions b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/hu/functions index 941c1b740d0..4abce13b91b 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/hu/functions +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/hu/functions @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/it/config b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/it/config index 97af8b9a570..f862a02d72d 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/it/config +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/it/config @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or @@ -36,7 +36,7 @@ currencySymbol = € ## -## Excel Error Codes (For future use) +## Excel Error Codes (For future use) ## NULL = #NULLO! DIV0 = #DIV/0! diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/it/functions b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/it/functions index 862cf8302c8..b9219a6a4ce 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/it/functions +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/it/functions @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/nl/config b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/nl/config index a14b476c945..7377a181df0 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/nl/config +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/nl/config @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or @@ -36,7 +36,7 @@ currencySymbol = € ## -## Excel Error Codes (For future use) +## Excel Error Codes (For future use) ## NULL = #LEEG! DIV0 = #DEEL/0! diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/nl/functions b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/nl/functions index 79b7acd1ef9..b6b8296ef04 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/nl/functions +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/nl/functions @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/no/config b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/no/config index e3e3cc4f786..15fcc128640 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/no/config +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/no/config @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or @@ -36,7 +36,7 @@ currencySymbol = kr ## -## Excel Error Codes (For future use) +## Excel Error Codes (For future use) ## NULL = #NULL! DIV0 = #DIV/0! diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/no/functions b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/no/functions index 3cccce42a1d..57a80a7a406 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/no/functions +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/no/functions @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/pl/config b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/pl/config index ea111797270..fb1e7b13d9d 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/pl/config +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/pl/config @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or @@ -36,7 +36,7 @@ currencySymbol = zł ## -## Excel Error Codes (For future use) +## Excel Error Codes (For future use) ## NULL = #ZERO! DIV0 = #DZIEL/0! diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/pl/functions b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/pl/functions index 5607f8f672c..2e5697973c1 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/pl/functions +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/pl/functions @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/pt/br/config b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/pt/br/config index d39c5c63438..e99aad6bea4 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/pt/br/config +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/pt/br/config @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or @@ -36,7 +36,7 @@ currencySymbol = R$ ## -## Excel Error Codes (For future use) +## Excel Error Codes (For future use) ## NULL = #NULO! DIV0 = #DIV/0! diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/pt/config b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/pt/config index 5e486bb29ff..36df63cc012 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/pt/config +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/pt/config @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or @@ -36,7 +36,7 @@ currencySymbol = € ## -## Excel Error Codes (For future use) +## Excel Error Codes (For future use) ## NULL = #NULO! DIV0 = #DIV/0! diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/ru/config b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/ru/config index 098c8075d29..205c342ada4 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/ru/config +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/ru/config @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or @@ -36,7 +36,7 @@ currencySymbol = р ## -## Excel Error Codes (For future use) +## Excel Error Codes (For future use) ## NULL = #ПУСТО! DIV0 = #ДЕЛ/0! diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/ru/functions b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/ru/functions index 86bcd4f63a7..324c3df2a81 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/ru/functions +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/ru/functions @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/sv/config b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/sv/config index c2094c06249..454e52ef52f 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/sv/config +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/sv/config @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or @@ -36,7 +36,7 @@ currencySymbol = kr ## -## Excel Error Codes (For future use) +## Excel Error Codes (For future use) ## NULL = #Skärning! DIV0 = #Division/0! diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/tr/config b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/tr/config index cca084b2ba5..8a103d3c196 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/tr/config +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/tr/config @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or @@ -36,7 +36,7 @@ currencySymbol = YTL ## -## Excel Error Codes (For future use) +## Excel Error Codes (For future use) ## NULL = #BOŞ! DIV0 = #SAYI/0! diff --git a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/tr/functions b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/tr/functions index 3e7c225f402..79645214714 100644 --- a/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/tr/functions +++ b/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/locale/tr/functions @@ -1,6 +1,6 @@ ## ## PHPExcel -## +## ## Copyright (c) 2006 - 2013 PHPExcel ## ## This library is free software; you can redistribute it and/or From e6411dd246e1cadc6ca3dc397a706fdf800667fb Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 22 Aug 2016 12:25:03 +0200 Subject: [PATCH 04/37] Start work to allow updates in import module --- .../modules/import/import_csv.modules.php | 108 ++++++++++++------ htdocs/core/modules/modSociete.class.php | 1 + htdocs/imports/class/import.class.php | 3 + htdocs/imports/import.php | 28 ++++- 4 files changed, 98 insertions(+), 42 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 0a78f59ab03..bf923828c76 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -268,7 +268,7 @@ class ImportCsv extends ModeleImports * @param string $importid Import key * @return int <0 if KO, >0 if OK */ - function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$maxfields,$importid) + function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$maxfields,$importid,$updatekeys) { global $langs,$conf,$user; global $thirdparty_static; // Specific to thirdparty import @@ -551,47 +551,79 @@ class ImportCsv extends ModeleImports // If no error for this $alias/$tablename, we have a complete $listfields and $listvalues that are defined if (! $errorforthistable) { - //print "$alias/$tablename/$listfields/$listvalues
"; + //print "$alias/$tablename/$listfields/$listvalues
"; if (!empty($listfields)) { - //var_dump($objimport->array_import_convertvalue); exit; - - // Build SQL UPDATE request - $sqlstart = 'UPDATE '.$tablename; - - // Build SQL INSERT request - $sqlstart = 'INSERT INTO '.$tablename.'('.implode(', ', $listfields).', import_key'; - $sqlend = ') VALUES('.implode(', ', $listvalues).", '".$importid."'"; - if (! empty($tablewithentity_cache[$tablename])) { - $sqlstart.= ', entity'; - $sqlend.= ', '.$conf->entity; - } - if (! empty($objimport->array_import_tables_creator[0][$alias])) { - $sqlstart.= ', '.$objimport->array_import_tables_creator[0][$alias]; - $sqlend.=', '.$user->id; - } - $sql = $sqlstart.$sqlend.')'; - dol_syslog("import_csv.modules", LOG_DEBUG); - - //print '> '.join(',',$arrayrecord); - //print 'sql='.$sql; - //print '
'."\n"; - - // Run insert request - if ($sql) - { - $resql=$this->db->query($sql); - $last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that dependent tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr). - if ($resql) - { - //print '.'; + $updatedone = false; + if(!empty($updatekeys)) { + // Build SQL UPDATE request + $sqlstart = 'UPDATE '.$tablename; + + $data = array_combine($listfields, $listvalues); + $set = array(); + foreach ($data as $key => $val) { + $set[] = $key.' = '.$val; } - else + $sqlstart.= ' SET '.implode(', ', $set); + + $where = array(); + foreach ($updatekeys as $key) { + $key=preg_replace('/^.*\./i','',$key); + $where[] = $key.' = '.$data[$key]; + } + $sqlend = ' WHERE '.implode(' AND ', $where); + + $sql = $sqlstart.$sqlend; + + // Run update request + $resql=$this->db->query($sql); + if($resql) { + echo $sql; + echo '
';
+								//print_r($this->db);
+								//print_r($this->db->db);
+								echo '
'; + echo ''.var_dump($this->db->db->affected_rows).''; + if($this->db->db->affected_rows > 0) { + $this->nbupdate++; + $updatedone = true; + } + } + } + + // Update not done, we do insert + if(!$updatedone) { + // Build SQL INSERT request + $sqlstart = 'INSERT INTO '.$tablename.'('.implode(', ', $listfields).', import_key'; + $sqlend = ') VALUES('.implode(', ', $listvalues).", '".$importid."'"; + if (! empty($tablewithentity_cache[$tablename])) { + $sqlstart.= ', entity'; + $sqlend.= ', '.$conf->entity; + } + if (! empty($objimport->array_import_tables_creator[0][$alias])) { + $sqlstart.= ', '.$objimport->array_import_tables_creator[0][$alias]; + $sqlend.=', '.$user->id; + } + $sql = $sqlstart.$sqlend.')'; + echo $sql; + dol_syslog("import_csv.modules", LOG_DEBUG); + + // Run insert request + if ($sql) { - //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; - $error++; + $resql=$this->db->query($sql); + $last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that dependent tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr). + if ($resql) + { + $this->nbinsert++; + } + else + { + //print 'E'; + $this->errors[$error]['lib']=$this->db->lasterror(); + $this->errors[$error]['type']='SQL'; + $error++; + } } } } diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index baf680f0352..a72ae8c8adf 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -340,6 +340,7 @@ class modSociete extends DolibarrModules //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); $this->import_regex_array[$r]=array('s.status'=>'^[0|1]','s.client'=>'^[0|1|2|3]','s.fournisseur'=>'^[0|1]','s.fk_typent'=>'id@'.MAIN_DB_PREFIX.'c_typent','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$'); $this->import_examplevalues_array[$r]=array('s.nom'=>"MyBigCompany",'s.status'=>"0 (closed) or 1 (active)",'s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 or 1','s.datec'=>dol_print_date(dol_now(),'%Y-%m-%d'),'s.code_client'=>'CU01-0001 or empty or "auto"','s.code_fournisseur'=>'SU01-0001 or empty or "auto"','s.address'=>"61 jump street",'s.zip'=>"123456",'s.town'=>"Big town",'s.fk_pays'=>'US, FR, DE...','s.phone'=>"0101010101",'s.fax'=>"0101010102",'s.url'=>"http://mycompany.com",'s.email'=>"test@mycompany.com",'s.siret'=>"",'s.siren'=>"",'s.ape'=>"",'s.idprof4'=>"",'s.idprof5'=>"",'s.idprof6'=>"",'s.tva_intra'=>"FR0123456789",'s.capital'=>"10000",'s.note_private'=>"This is an example of private note for record",'s.note_public'=>"This is an example of public note for record",'s.fk_typent'=>"2",'s.fk_effectif'=>"3","s.fk_forme_juridique"=>"1",'s.fk_prospectlevel'=>'PL_MEDIUM','s.fk_stcomm'=>'0','s.default_lang'=>'en_US','s.barcode'=>'123456789','s.datec'=>"2015-01-01 or 2015-01-01 12:30:00"); + $this->import_updatekeys_array[$r]=array('s.nom'=>'Name','s.code_client'=>'CustomerCode','s.code_fournisseur'=>'SupplierCode','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode'); // Import list of contact and attributes $r++; diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 254628b38fa..828e0f53719 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -38,6 +38,7 @@ class Import var $array_import_fieldshidden; var $array_import_entities; var $array_import_regex; + var $array_import_updatekeys; var $array_import_examplevalues; var $array_import_convertvalue; var $array_import_run_sql_after; @@ -153,6 +154,8 @@ class Import $this->array_import_entities[$i]=$module->import_entities_array[$r]; // Tableau des alias a exporter (cle=champ, valeur=alias) $this->array_import_regex[$i]=$module->import_regex_array[$r]; + // Array of columns allowed as UPDATE options + $this->array_import_updatekeys[$i]=$module->import_updatekeys_array[$r]; // Array of examples $this->array_import_examplevalues[$i]=$module->import_examplevalues_array[$r]; // Tableau des regles de conversion d'une valeur depuis une autre source (cle=champ, valeur=tableau des regles) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 89d69974577..3eefa101aea 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -76,7 +76,8 @@ $import_name = GETPOST('import_name'); $hexa = GETPOST('hexa'); $importmodelid = GETPOST('importmodelid'); $excludefirstline = (GETPOST('excludefirstline') ? GETPOST('excludefirstline') : 1); -$endatlinenb = (GETPOST('endatlinenb') ? GETPOST('endatlinenb') : ''); +$endatlinenb = (GETPOST('endatlinenb') ? GETPOST('endatlinenb') : ''); +$updatekeys = (GETPOST('updatekeys') ? GETPOST('updatekeys') : array()); $separator = (GETPOST('separator') ? GETPOST('separator') : (! empty($conf->global->IMPORT_CSV_SEPARATOR_TO_USE)?$conf->global->IMPORT_CSV_SEPARATOR_TO_USE:',')); $enclosure = (GETPOST('enclosure') ? GETPOST('enclosure') : '"'); @@ -1165,8 +1166,9 @@ if ($step == 5 && $datatoimport) $param='&leftmenu=import&format='.$format.'&datatoimport='.$datatoimport.'&filetoimport='.urlencode($filetoimport).'&nboflines='.$nboflines.'&separator='.urlencode($separator).'&enclosure='.urlencode($enclosure); $param2 = $param; // $param2 = $param without excludefirstline and endatlinenb - if ($excludefirstline) $param.='&excludefirstline='.$excludefirstline; - if ($endatlinenb) $param.='&endatlinenb='.$endatlinenb; + if ($excludefirstline) $param.='&excludefirstline='.$excludefirstline; + if ($endatlinenb) $param.='&endatlinenb='.$endatlinenb; + if (!empty($updatekeys)) $param.='&updatekeys[]='.implode('&updatekeys[]=', $updatekeys); llxHeader('',$langs->trans("NewImport"),'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones'); @@ -1272,6 +1274,24 @@ if ($step == 5 && $datatoimport) } print ''; + print ''; + print $langs->trans("KeysToUseForUpdates"); + print ''; + if($action=='launchsimu') { + print $form->multiselectarray('updatekeysbis', $objimport->array_import_updatekeys[0], $updatekeys, 0, 0, '', 1, '', 'disabled'); + foreach($updatekeys as $val) { + print ''; + } + print '   '.$langs->trans("Modify").''; + } else { + print $form->multiselectarray('updatekeys', $objimport->array_import_updatekeys[0], $updatekeys, 0, 0, '', 1, '80%'); + print $form->textwithpicto("", $langs->trans("SelectColumnsOfYourFileForUpdateAttempt")); + } + /*echo '
';
+	print_r($objimport->array_import_updatekeys);
+	echo '
';*/ + print ''; + print ''; print '
'; @@ -1405,7 +1425,7 @@ if ($step == 5 && $datatoimport) if ($endatlinenb && ($sourcelinenb > $endatlinenb)) continue; // Run import - $result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,count($fieldssource),$importid); + $result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,count($fieldssource),$importid,$updatekeys); if (count($obj->errors)) $arrayoferrors[$sourcelinenb]=$obj->errors; if (count($obj->warnings)) $arrayofwarnings[$sourcelinenb]=$obj->warnings; From 578cab9a70e8e86752e9492320ef184d65884c82 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 2 Oct 2016 19:14:28 +0200 Subject: [PATCH 05/37] Error management + show nb insert/update + langs --- .../core/modules/import/import_csv.modules.php | 17 ++++++++++------- htdocs/imports/import.php | 8 ++++++-- htdocs/langs/en_US/exports.lang | 4 ++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index bf923828c76..012ef84f5f1 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -54,6 +54,9 @@ class ImportCsv extends ModeleImports var $cacheconvert=array(); // Array to cache list of value found after a convertion var $cachefieldtable=array(); // Array to cache list of value found into fields@tables + + var $nbinsert = 0; // # of insert done during the import + var $nbupdate = 0; // # of update done during the import /** @@ -578,17 +581,18 @@ class ImportCsv extends ModeleImports // Run update request $resql=$this->db->query($sql); if($resql) { - echo $sql; - echo '
';
-								//print_r($this->db);
-								//print_r($this->db->db);
-								echo '
'; - echo ''.var_dump($this->db->db->affected_rows).''; if($this->db->db->affected_rows > 0) { $this->nbupdate++; $updatedone = true; } } + else + { + //print 'E'; + $this->errors[$error]['lib']=$this->db->lasterror(); + $this->errors[$error]['type']='SQL'; + $error++; + } } // Update not done, we do insert @@ -605,7 +609,6 @@ class ImportCsv extends ModeleImports $sqlend.=', '.$user->id; } $sql = $sqlstart.$sqlend.')'; - echo $sql; dol_syslog("import_csv.modules", LOG_DEBUG); // Run insert request diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 3eefa101aea..141c83c1ba0 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1461,7 +1461,11 @@ if ($step == 5 && $datatoimport) $db->rollback(); // We force rollback because this was just a simulation. // Show OK - if (! count($arrayoferrors) && ! count($arrayofwarnings)) print img_picto($langs->trans("OK"),'tick').' '.$langs->trans("NoError").'

'; + if (! count($arrayoferrors) && ! count($arrayofwarnings)) { + print img_picto($langs->trans("OK"),'tick').' '.$langs->trans("NoError").'
'; + print $langs->trans("NbInsert", $obj->nbinsert).'
'; + print $langs->trans("NbUpdate", $obj->nbupdate).'

'; + } else print $langs->trans("NbOfLinesOK",$nbok).'

'; // Show Errors @@ -1768,7 +1772,7 @@ if ($step == 6 && $datatoimport) if ($endatlinenb && ($sourcelinenb > $endatlinenb)) continue; // Run import - $result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,count($fieldssource),$importid); + $result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,count($fieldssource),$importid,$updatekeys); if (count($obj->errors)) $arrayoferrors[$sourcelinenb]=$obj->errors; if (count($obj->warnings)) $arrayofwarnings[$sourcelinenb]=$obj->warnings; diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index 55e592dc91d..2011a8a0d8e 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -122,3 +122,7 @@ SelectFilterFields=If you want to filter on some values, just input values here. FilteredFields=Filtered fields FilteredFieldsValues=Value for filter FormatControlRule=Format control rule +## imports updates +KeysToUseForUpdates=Key to use for updating data +NbInsert=Number of inserted lines: %s +NbUpdate=Number of updated lines: %s \ No newline at end of file From f995768f24cee4f5db3c1cb048b720ff3dcb6df6 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 2 Oct 2016 19:17:22 +0200 Subject: [PATCH 06/37] Show import results --- htdocs/imports/import.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 141c83c1ba0..ce8e0c1f316 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1818,7 +1818,9 @@ if ($step == 6 && $datatoimport) // Show result print '
'; print '
'; - print $langs->trans("NbOfLinesImported",$nbok).'

'; + print $langs->trans("NbOfLinesImported",$nbok).'
'; + print $langs->trans("NbInsert", $obj->nbinsert).'
'; + print $langs->trans("NbUpdate", $obj->nbupdate).'

'; print $langs->trans("FileWasImported",$importid).'
'; print $langs->trans("YouCanUseImportIdToFindRecord",$importid).'
'; print '
'; From c4b96925758a7ec0e3a5c230203182067fcf0267 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 3 Oct 2016 09:46:31 +0200 Subject: [PATCH 07/37] Missing comment --- htdocs/core/modules/import/import_csv.modules.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 012ef84f5f1..79f10cc5551 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -269,6 +269,7 @@ class ImportCsv extends ModeleImports * @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...) * @param int $maxfields Max number of fields to use * @param string $importid Import key + * @param array $updatekeys Array of keys to use to try to do update * @return int <0 if KO, >0 if OK */ function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$maxfields,$importid,$updatekeys) From 5f704fe5e5cbde3c8c009362a7ad915e0de0fa60 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 13 Nov 2016 09:03:34 +0100 Subject: [PATCH 08/37] Import update, new way of working with a select --- .../modules/import/import_csv.modules.php | 110 ++++++++++++------ htdocs/langs/en_US/exports.lang | 3 +- 2 files changed, 77 insertions(+), 36 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index a07d67d9a0e..d0cc94ede9e 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -303,6 +303,8 @@ class ImportCsv extends ModeleImports else { $last_insert_id_array = array(); // store the last inserted auto_increment id for each table, so that dependent tables can be inserted with the appropriate id (eg: extrafields fk_object will be set with the last inserted object's id) + $updatedone = false; + $insertdone = false; // For each table to insert, me make a separate insert foreach($objimport->array_import_tables[0] as $alias => $tablename) { @@ -548,7 +550,8 @@ class ImportCsv extends ModeleImports { $tmp=explode('-',$val); $lastinsertid=(isset($last_insert_id_array[$tmp[1]]))?$last_insert_id_array[$tmp[1]]:0; - $listfields[] = preg_replace('/^'.preg_quote($alias).'\./','',$key); + $keyfield = preg_replace('/^'.preg_quote($alias).'\./','',$key); + $listfields[] = $keyfield; $listvalues[] = $lastinsertid; //print $key."-".$val."-".$listfields."-".$listvalues."
";exit; } @@ -563,45 +566,79 @@ class ImportCsv extends ModeleImports if (!empty($listfields)) { $updatedone = false; + $insertdone = false; if(!empty($updatekeys)) { - // Build SQL UPDATE request - $sqlstart = 'UPDATE '.$tablename; - - $data = array_combine($listfields, $listvalues); - $set = array(); - foreach ($data as $key => $val) { - $set[] = $key.' = '.$val; - } - $sqlstart.= ' SET '.implode(', ', $set); - - $where = array(); - foreach ($updatekeys as $key) { - $key=preg_replace('/^.*\./i','',$key); - $where[] = $key.' = '.$data[$key]; - } - $sqlend = ' WHERE '.implode(' AND ', $where); - - $sql = $sqlstart.$sqlend; - - // Run update request - $resql=$this->db->query($sql); - if($resql) { - if($this->db->db->affected_rows > 0) { - $this->nbupdate++; - $updatedone = true; + // We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields) + if(empty($lastinsertid)) { + $sqlSelect = 'SELECT rowid FROM '.$tablename; + + $data = array_combine($listfields, $listvalues); + $where = array(); + $filters = array(); + foreach ($updatekeys as $key) { + $col = $objimport->array_import_updatekeys[0][$key]; + $key=preg_replace('/^.*\./i','',$key); + $where[] = $key.' = '.$data[$key]; + $filters[] = $col.' = '.$data[$key]; + } + $sqlSelect.= ' WHERE '.implode(' AND ', $where); + + $resql=$this->db->query($sqlSelect); + if($resql) { + $res = $this->db->fetch_object($resql); + if($resql->num_rows == 1) { + $lastinsertid = $res->rowid; + $last_insert_id_array[$tablename] = $lastinsertid; + } else { + $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode($filter, ', ')); + $this->errors[$error]['type']='SQL'; + $error++; + } + } + else + { + //print 'E'; + $this->errors[$error]['lib']=$this->db->lasterror(); + $this->errors[$error]['type']='SQL'; + $error++; } } - else - { - //print 'E'; - $this->errors[$error]['lib']=$this->db->lasterror(); - $this->errors[$error]['type']='SQL'; - $error++; + + if(!empty($lastinsertid)) { + // Build SQL UPDATE request + $sqlstart = 'UPDATE '.$tablename; + + $data = array_combine($listfields, $listvalues); + $set = array(); + foreach ($data as $key => $val) { + $set[] = $key.' = '.$val; + } + $sqlstart.= ' SET '.implode(', ', $set); + + if(empty($keyfield)) $keyfield = 'rowid'; + $sqlend = ' WHERE '.$keyfield.' = '.$lastinsertid; + + $sql = $sqlstart.$sqlend; + + // Run update request + $resql=$this->db->query($sql); + if($resql) { + if($this->db->db->affected_rows > 0) { + $updatedone = true; + } + } + else + { + //print 'E'; + $this->errors[$error]['lib']=$this->db->lasterror(); + $this->errors[$error]['type']='SQL'; + $error++; + } } } // Update not done, we do insert - if(!$updatedone) { + if(!$error && !$updatedone) { // Build SQL INSERT request $sqlstart = 'INSERT INTO '.$tablename.'('.implode(', ', $listfields).', import_key'; $sqlend = ') VALUES('.implode(', ', $listvalues).", '".$importid."'"; @@ -615,7 +652,7 @@ class ImportCsv extends ModeleImports } $sql = $sqlstart.$sqlend.')'; dol_syslog("import_csv.modules", LOG_DEBUG); - + // Run insert request if ($sql) { @@ -623,7 +660,7 @@ class ImportCsv extends ModeleImports $last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that dependent tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr). if ($resql) { - $this->nbinsert++; + $insertdone = true; } else { @@ -643,6 +680,9 @@ class ImportCsv extends ModeleImports if ($error) break; } + + if($updatedone) $this->nbupdate++; + if($insertdone) $this->nbinsert++; } return 1; diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index 7e08acbecfc..7c95f12a30d 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -123,4 +123,5 @@ FormatControlRule=Format control rule ## imports updates KeysToUseForUpdates=Key to use for updating data NbInsert=Number of inserted lines: %s -NbUpdate=Number of updated lines: %s \ No newline at end of file +NbUpdate=Number of updated lines: %s +MultipleRecordFoundWithTheseFilters=Multiple records have been found with these filters: %s \ No newline at end of file From 1dcecf487306546e22f8ea1921d6b923fcff70f4 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 13 Nov 2016 09:32:43 +0100 Subject: [PATCH 09/37] Fix select and update done check --- htdocs/core/modules/import/import_csv.modules.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index d0cc94ede9e..494dd84ab91 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -589,10 +589,12 @@ class ImportCsv extends ModeleImports if($resql->num_rows == 1) { $lastinsertid = $res->rowid; $last_insert_id_array[$tablename] = $lastinsertid; - } else { - $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode($filter, ', ')); + } else if($resql->num_rows > 1) { + $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode($filters, ', ')); $this->errors[$error]['type']='SQL'; $error++; + } else { + // No record found with filters, insert will be tried below } } else @@ -623,9 +625,8 @@ class ImportCsv extends ModeleImports // Run update request $resql=$this->db->query($sql); if($resql) { - if($this->db->db->affected_rows > 0) { - $updatedone = true; - } + // No error, update has been done. $this->db->db->affected_rows can be 0 if data hasn't changed + $updatedone = true; } else { From edef8f883b8a14ed7a311f16edba698333b24fea Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 13 Nov 2016 09:40:09 +0100 Subject: [PATCH 10/37] Add update option on product module --- htdocs/core/modules/modProduct.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 4ff68ae8d6b..330349b0842 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -248,6 +248,7 @@ class modProduct extends DolibarrModules $this->import_regex_array[$r]=array('p.ref'=>'[^ ]','p.tosell'=>'^[0|1]$','p.tobuy'=>'^[0|1]$','p.fk_product_type'=>'^[0|1]$','p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','p.recuperableonly'=>'^[0|1]$'); $import_sample=array('p.ref'=>"PREF123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.tosell'=>"0 or 1",'p.tobuy'=>"0 or 1",'p.fk_product_type'=>"0 for product/1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31','p.recuperableonly'=>'0 or 1'); $this->import_examplevalues_array[$r]=array_merge($import_sample,$import_extrafield_sample); + $this->import_updatekeys_array[$r]=array('p.ref'=>'Ref','p.barcode'=>'BarCode'); if (! empty($conf->fournisseur->enabled)) { @@ -276,6 +277,7 @@ class modProduct extends DolibarrModules 'sp.unitprice'=>'50', 'sp.remise_percent'=>'0' ); + $this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef'); } if (! empty($conf->global->PRODUIT_MULTIPRICES)) From c2bee0f9375035cd96645f3e9bebe968342d667a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 7 Dec 2016 12:44:56 +0100 Subject: [PATCH 11/37] FIX #6088 --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 52c3b2f5cb9..420f6529758 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -729,7 +729,7 @@ class ExtraFields } elseif ($type == 'price') { - $out=' '.$langs->getCurrencySymbol($conf->currency); + $out=' '.$langs->getCurrencySymbol($conf->currency); } elseif ($type == 'double') { From 829ff2299e7a6e3ae01abf8fef953e14d0750190 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Sat, 10 Dec 2016 12:46:26 +0100 Subject: [PATCH 12/37] Fix: Delete surplus migration file --- .../install/mysql/migration/3.8.0-3.9.0.sql | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 htdocs/install/mysql/migration/3.8.0-3.9.0.sql diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql deleted file mode 100644 index c3e6b5b091e..00000000000 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ /dev/null @@ -1,30 +0,0 @@ --- --- Be carefull to requests order. --- This file must be loaded by calling /install/index.php page --- when current version is 3.9.0 or higher. --- --- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; --- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; --- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); --- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; --- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); --- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; --- To restrict request to Mysql version x.y use -- VMYSQLx.y --- To restrict request to Pgsql version x.y use -- VPGSQLx.y --- To make pk to be auto increment (mysql): VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; --- To make pk to be auto increment (postgres): VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE --- To set a field as NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; --- To set a field as default NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; --- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user); --- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); - --- Fix bad data -update llx_opensurvey_sondage set format = 'D' where format = 'D+'; -update llx_opensurvey_sondage set format = 'A' where format = 'A+'; - -INSERT INTO llx_const (name, value, type, note, visible) values ('MAIN_DELAY_EXPENSEREPORTS_TO_PAY','31','chaine','Tolérance de retard avant alerte (en jours) sur les notes de frais impayées',0); - -ALTER TABLE llx_accounting_system MODIFY COLUMN pcg_version varchar(32); -ALTER TABLE llx_accountingaccount MODIFY COLUMN fk_pcg_version varchar(32); - - From 97e21cb7758d9ad24534f4c639eaa0e01da40b48 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 10 Dec 2016 13:05:46 +0100 Subject: [PATCH 13/37] Fix : delete product was not possible if batch stock --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 78ea0cb39c7..6b53fea0347 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -879,7 +879,7 @@ class Product extends CommonObject // Delete all child tables if (! $error) { - $elements = array('product_fournisseur_price','product_price','product_lang','categorie_product','product_stock','product_customer_price'); + $elements = array('product_fournisseur_price','product_price','product_lang','categorie_product','product_stock','product_customer_price','product_batch'); foreach($elements as $table) { if (! $error) From 5a2b8ff53cce86971b56299c7b6592819df1bb75 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Sat, 10 Dec 2016 22:41:53 +0100 Subject: [PATCH 14/37] FIX #5853 $conf->global->$calc==0 || $conf->global->$calc==1 --- htdocs/compta/localtax/clients.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index b4cea5b4982..5c21b67a891 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -106,7 +106,7 @@ $fsearch.=' '; $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; // Affiche en-tete du rapport -if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice for goods and services +if ($calc==0 || $calc==1) // Calculate on invoice for goods and services { $nom=$langs->transcountry($local==1?"LT1ReportByCustomersInInputOutputMode":"LT2ReportByCustomersInInputOutputMode",$mysoc->country_code); $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec"); @@ -124,7 +124,7 @@ if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice $productsup=$langs->trans("Description"); $amountsup=$langs->trans("AmountHT"); } -if ($conf->global->$calc==2) // Invoice for goods, payment for services +if ($calc==2) // Invoice for goods, payment for services { $nom=$langs->transcountry($local==1?"LT1ReportByCustomersInInputOutputMode":"LT2ReportByCustomersInInputOutputMode",$mysoc->country_code); $calcmode=$langs->trans("CalcModeLT2Debt"); @@ -149,7 +149,7 @@ $vatcust=$langs->transcountry($local==1?"LT1":"LT2",$mysoc->country_code); $vatsup=$langs->transcountry($local==1?"LT1":"LT2",$mysoc->country_code); // IRPF that the customer has retained me -if($conf->global->$calc ==0 || $conf->global->$calc == 2) +if($calc ==0 || $calc == 2) { print ""; print ""; @@ -232,7 +232,7 @@ if($conf->global->$calc ==0 || $conf->global->$calc == 2) } // IRPF I retained my supplier -if($conf->global->$calc ==0 || $conf->global->$calc == 1){ +if($calc ==0 || $calc == 1){ print "
"; print ""; print '"; @@ -309,7 +309,7 @@ if($conf->global->$calc ==0 || $conf->global->$calc == 1){ } } -if($conf->global->$calc ==0){ +if($calc ==0){ // Total to pay print '

'; print '
'.$langs->trans("Num")."
'; From 56aafa4660cb7b5e262943cff1b561c09d73c07c Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Sat, 10 Dec 2016 23:25:13 +0100 Subject: [PATCH 15/37] Fix #5646 Error editing Sell Price on products/services --- htdocs/product/price.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 8c3ad45c90c..88c6c3e57b1 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -5,7 +5,7 @@ * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2014 Florian Henry - * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014-2016 Juanjo Menent * Copyright (C) 2014-2015 Philippe Grand * Copyright (C) 2014 Ion agorria * Copyright (C) 2015 Alexandre Spangaro @@ -246,8 +246,8 @@ if (empty($reshook)) { $obj = $db->fetch_object($resql); $npr = $obj->recuperableonly; - $localtax1 = $obj->localtax1; - $localtax2 = $obj->localtax2; + $localtax1 = get_localtax($tva_tx,1); + $localtax2 = get_localtax($tva_tx,2); $localtax1_type = $obj->localtax1_type; $localtax2_type = $obj->localtax2_type; } From 7fd75c793aea3b0b003f40c4d97be86c4f29dc43 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Dec 2016 10:39:48 +0100 Subject: [PATCH 16/37] FIX Regression when deleting product --- htdocs/product/class/product.class.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 9bf8bcbd3f0..1d8d17d6c8f 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -908,10 +908,26 @@ class Product extends CommonObject // End call triggers } + // Delete from product_batch on product delete + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX.'product_batch'; + $sql.= " WHERE fk_product_stock IN ("; + $sql.= "SELECT rowid FROM ".MAIN_DB_PREFIX.'product_stock'; + $sql.= " WHERE fk_product = ".$id.")"; + dol_syslog(get_class($this).'::delete', LOG_DEBUG); + $result = $this->db->query($sql); + if (! $result) + { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + // Delete all child tables if (! $error) { - $elements = array('product_fournisseur_price','product_price','product_lang','categorie_product','product_stock','product_customer_price','product_batch'); + $elements = array('product_fournisseur_price','product_price','product_lang','categorie_product','product_stock','product_customer_price'); foreach($elements as $table) { if (! $error) From 4e86e59fb312a54ce4f32d29986c1b2e66d98f9a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Dec 2016 13:02:54 +0100 Subject: [PATCH 17/37] Fix responsive --- htdocs/admin/dict.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 4ef2a35e8a7..b47986d786b 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1784,10 +1784,10 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') print ''; } elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i',$fieldlist[$field])) { - print ''; + print ''; } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { - print ''; + print ''; } elseif ($fieldlist[$field]=='unit') { print '
'; @@ -1827,8 +1827,8 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') { print ''; $size=''; $class=''; - if ($fieldlist[$field]=='code') $size='size="8" '; - if ($fieldlist[$field]=='position') $size='size="4" '; + if ($fieldlist[$field]=='code') $class='maxwidth100'; + if ($fieldlist[$field]=='position') $class='maxwidth50'; if ($fieldlist[$field]=='libelle') $class='quatrevingtpercent'; if ($fieldlist[$field]=='tracking') $class='quatrevingtpercent'; if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" '; From 24914e8e4fbb8ee2b5316a1f242f587036237079 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Dec 2016 13:18:32 +0100 Subject: [PATCH 18/37] Fix css and missing warning --- htdocs/societe/rib.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index f6149690b7e..0d61c0d98fa 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -355,7 +355,6 @@ if ($socid && $action != 'edit' && $action != "create") dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); - print '
'; print load_fiche_titre($langs->trans("DefaultRIB"), '', ''); @@ -425,16 +424,14 @@ if ($socid && $action != 'edit' && $action != "create") print '
'; - print ""; - - dol_fiche_end(); - + print '
'; + /* * List of bank accounts */ - print load_fiche_titre($langs->trans("AllRIB")); + print load_fiche_titre($langs->trans("AllRIB"), '', ''); $rib_list = $object->get_all_rib(); $var = false; @@ -485,6 +482,14 @@ if ($socid && $action != 'edit' && $action != "create") $string .= $rib->iban.' ';*/ } } + if (! empty($rib->label)) { + if (! checkBanForAccount($rib)) { + $string.= ' '.img_picto($langs->trans("ValueIsNotValid"),'warning'); + } else { + $string.= ' '.img_picto($langs->trans("ValueIsValid"),'info'); + } + } + print $string; print ''; // IBAN @@ -613,6 +618,9 @@ if ($socid && $action != 'edit' && $action != "create") dol_print_error($db); } + dol_fiche_end(); + + if ($socid && $action != 'edit' && $action != 'create') { From 71d2ee3aa9646e5fe8818cf106123b201b0ecadc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 12 Dec 2016 20:30:21 +0100 Subject: [PATCH 19/37] Fix default of a column --- htdocs/install/mysql/migration/4.0.0-5.0.0.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index 2fd59793a09..b94d289de31 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -8,6 +8,7 @@ -- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); -- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; -- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); +-- To set a DEFAULT value: ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT (0|NULL|...); -- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; -- To drop an index: -- VMYSQL4.0 DROP INDEX nomindex on llx_table -- To drop an index: -- VPGSQL8.0 DROP INDEX nomindex @@ -19,7 +20,6 @@ -- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; -- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; -- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; --- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; -- Note: fields with type BLOB/TEXT can't have default value. -- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user); -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); @@ -32,6 +32,8 @@ UPDATE llx_const SET name = __ENCRYPT('THIRDPARTY_DEFAULT_CREATE_CONTACT')__ WHE ALTER TABLE llx_product_lot MODIFY COLUMN entity integer DEFAULT 1; UPDATE llx_product_lot SET entity = 1 WHERE entity IS NULL; +ALTER TABLE llx_societe ALTER COLUMN fk_stcomm SET DEFAULT 0; + ALTER TABLE llx_c_actioncomm ADD COLUMN picto varchar(48); ALTER TABLE llx_facturedet ADD INDEX idx_facturedet_fk_code_ventilation (fk_code_ventilation); From d2d0e66c5cdeee8176d817a8f058a3400cd99d2c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Dec 2016 01:19:33 +0100 Subject: [PATCH 20/37] Fix style fo ECM module --- htdocs/core/ajax/ajaxdirpreview.php | 2 +- htdocs/core/class/html.formfile.class.php | 6 +++--- htdocs/ecm/docdir.php | 7 ++----- htdocs/ecm/index.php | 3 ++- htdocs/ecm/index_auto.php | 2 +- htdocs/theme/eldy/style.css.php | 1 + htdocs/theme/md/style.css.php | 1 + 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 4ff36a1e88b..28f78e22ef4 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -138,7 +138,7 @@ if (! dol_is_dir($upload_dir)) exit;*/ } -print ''."\n"; +print ''."\n"; print ''."\n"; $param=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:''); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 60ed409fc7f..95b7b41da4d 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -932,7 +932,7 @@ class FormFile print ''; print ''; } - print ''."\n"; + print '
'."\n"; print ''; print_liste_field_titre($langs->trans("Documents2"),$url,"name","",$param,'align="left"',$sortfield,$sortorder); @@ -1087,7 +1087,7 @@ class FormFile } if ($nboffiles == 0) { - print ''; @@ -1130,7 +1130,7 @@ class FormFile // Show list of documents if (empty($useinecm)) print load_fiche_titre($langs->trans("AttachedFiles")); if (empty($url)) $url=$_SERVER["PHP_SELF"]; - print '
'; + print '
'; if (empty($textifempty)) print $langs->trans("NoFileFound"); else print $textifempty; print '
'."\n"; + print '
'."\n"; print ''; $sortref="fullname"; if ($modulepart == 'invoice_supplier') $sortref='level1name'; diff --git a/htdocs/ecm/docdir.php b/htdocs/ecm/docdir.php index 26372b7994d..1b36d0433d1 100644 --- a/htdocs/ecm/docdir.php +++ b/htdocs/ecm/docdir.php @@ -117,8 +117,7 @@ if ($action == 'add' && $user->rights->ecm->setup) else { $langs->load("errors"); - setEventMessages($langs->trans($ecmdir->error), null, 'errors'); - setEventMessages($ecmdir->error, $ecmdir->errors, 'errors'); + setEventMessages($langs->trans($ecmdir->error), $ecmdir->errors, 'errors'); $action = 'create'; } } @@ -173,9 +172,7 @@ if ($action == 'create') print ''; print ''."\n"; - print ''."\n"; - - print '

'; + print ''; dol_fiche_end(); diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 8236693f37f..18157ee60ba 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -494,7 +494,7 @@ if ($action == 'delete_section') if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$action) || $action == 'delete') { - print ''."\n"; + print '
'."\n"; print ''."\n"; print ''."\n"; @@ -721,6 +721,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti $mode='noajax'; +$url=DOL_URL_ROOT.'/ecm/index.php'; include_once DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php'; diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index 8964f3b0534..5119c66194a 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -480,7 +480,7 @@ if ($action == 'delete_section') if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$action) || $action == 'delete') { - print '
'."\n"; + print '
'."\n"; print ''."\n"; print ''."\n"; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 9f101b43294..73015308521 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1934,6 +1934,7 @@ img.toolbarbutton { } .ecm-in-layout-south { + border-top: 0px !important; border-left: 0px !important; border-right: 0px !important; border-bottom: 0px !important; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 5a6b5a48297..fd22ef5520d 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1946,6 +1946,7 @@ img.toolbarbutton { } .ecm-in-layout-south { + border-top: 0px !important; border-left: 0px !important; border-right: 0px !important; border-bottom: 0px !important; From 76195f9e451e1be3a6531ea3da254f40bd6f77a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Dec 2016 01:58:28 +0100 Subject: [PATCH 21/37] Fix translation --- htdocs/install/fileconf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 3f597c794d1..a2416f2e098 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -337,7 +337,7 @@ if (! empty($force_install_message)) -
trans("Server"); ?> + trans("DatabaseServer"); ?> Date: Tue, 13 Dec 2016 02:18:14 +0100 Subject: [PATCH 22/37] Fix responsive --- htdocs/install/default.css | 57 +++++++++++++++++++++++++++++++++---- htdocs/install/fileconf.php | 6 ++-- htdocs/install/inc.php | 2 +- 3 files changed, 55 insertions(+), 10 deletions(-) diff --git a/htdocs/install/default.css b/htdocs/install/default.css index 76a71e079d8..4d1f9259813 100644 --- a/htdocs/install/default.css +++ b/htdocs/install/default.css @@ -1,5 +1,5 @@ -/* Copyright (C) 2004 Rodolphe Quiedeville - * Copyright (C) 2009 Laurent Destailleur +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2009-2016 Laurent Destailleur * * 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 @@ -13,9 +13,50 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ +.minwidth100 { min-width: 100px; } +.minwidth200 { min-width: 200px; } +.minwidth300 { min-width: 300px; } +.minwidth400 { min-width: 400px; } +.minwidth500 { min-width: 500px; } +.minwidth50imp { min-width: 50px !important; } +.minwidth100imp { min-width: 100px !important; } +.minwidth200imp { min-width: 200px !important; } +.minwidth300imp { min-width: 300px !important; } +.minwidth400imp { min-width: 400px !important; } +.minwidth500imp { min-width: 500px !important; } + +/* Force values for small screen 570 */ +@media only screen and (max-width: 570px) +{ + input, input[type=text], input[type=password], select, textarea { + min-width: 20px; + min-height: 1.4em; + line-height: 1.4em; + padding: .4em .1em; + border: 1px solid #BBB; + /* max-width: inherit; why this ? */ + } + + .hideonsmartphone { display: none; } + .noenlargeonsmartphone { width : 50px !important; display: inline !important; } + .maxwidthonsmartphone { max-width: 100px; } + .maxwidth50onsmartphone { max-width: 40px; } + .maxwidth75onsmartphone { max-width: 50px; } + .maxwidth100onsmartphone { max-width: 70px; } + .maxwidth150onsmartphone { max-width: 120px; } + .maxwidth200onsmartphone { max-width: 200px; } + .maxwidth300onsmartphone { max-width: 300px; } + .maxwidth400onsmartphone { max-width: 400px; } + .minwidth50imp { min-width: 50px !important; } + .minwidth100imp { min-width: 50px !important; } + .minwidth200imp { min-width: 50px !important; } + .minwidth300imp { min-width: 50px !important; } + .minwidth400imp { min-width: 50px !important; } + .minwidth500imp { min-width: 50px !important; } +} + body { font-size:13px; font-family: Verdana, Arial, Helvetica, Tahoma, sans-serif; @@ -94,6 +135,11 @@ input:focus, textarea:focus, button:focus, select:focus { } input[type=text], input[type=password] { border: 1px solid #ACBCBB; + padding: 4px; +} +select { + padding: 4px; + background-color: #fff; } input[type=text]:focus, input[type=password]:focus, textarea:focus, select:focus { border: 1px solid #ACBCBB; @@ -244,12 +290,11 @@ td.comment { padding: 5px 5px 5px 5px; margin: 0 0 0 0; text-decoration:none; - font-size: 11px; + font-size: 12px; border-bottom: 1px solid #CCCCDB; } - table { - font-size: 12px; + font-size: 13px; } .install diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index a2416f2e098..73357faa5db 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -127,7 +127,7 @@ if (! empty($force_install_message)) ?> '."\n"; - print '
'."\n"; + print ''."\n"; print ''."\n"; print ''."\n"; From 43d18cd70cb19b2e552fa3179ccf7b3564b1a6f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Dec 2016 13:22:24 +0100 Subject: [PATCH 23/37] FIX if a supplier price reference is changed after creating an order, we can't clone order. --- .../class/fournisseur.commande.class.php | 52 +++++++++++-------- .../fourn/class/fournisseur.facture.class.php | 10 ++-- htdocs/product/class/product.class.php | 8 +-- 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index df3b5efa75a..b2f2d3dc3c3 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -324,10 +324,10 @@ class CommandeFournisseur extends CommonOrder $line->product_label = $objp->product_label; $line->product_desc = $objp->product_desc; - $line->ref = $objp->product_ref; - $line->product_ref = $objp->product_ref; - $line->ref_fourn = $objp->ref_supplier; - $line->ref_supplier = $objp->ref_supplier; + $line->ref = $objp->product_ref; // Ref of product + $line->product_ref = $objp->product_ref; // Ref of product + $line->ref_fourn = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since + $line->ref_supplier = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since $line->date_start = $this->db->jdate($objp->date_start); $line->date_end = $this->db->jdate($objp->date_end); @@ -1139,7 +1139,7 @@ class CommandeFournisseur extends CommonOrder $this->lines[$i]->localtax2_tx, $this->lines[$i]->fk_product, 0, - $this->lines[$i]->ref_fourn, + $this->lines[$i]->ref_fourn, // $this->lines[$i]->ref_fourn comes from field ref into table of lines. Value may ba a ref that does not exists anymore, so we first try with value of product $this->lines[$i]->remise_percent, 'HT', 0, @@ -1295,7 +1295,7 @@ class CommandeFournisseur extends CommonOrder * @param float $txlocaltax2 Localtax2 tax * @param int $fk_product Id product * @param int $fk_prod_fourn_price Id supplier price - * @param string $fourn_ref Supplier reference + * @param string $fourn_ref Supplier reference price * @param float $remise_percent Remise * @param string $price_base_type HT or TTC * @param float $pu_ttc Unit price TTC @@ -1341,7 +1341,8 @@ class CommandeFournisseur extends CommonOrder $pu=$pu_ttc; } $desc=trim($desc); - + $ref=''; // Ref of supplier price when we add line + // Check parameters if ($qty < 1 && ! $fk_product) { @@ -1363,15 +1364,28 @@ class CommandeFournisseur extends CommonOrder $prod = new Product($this->db, $fk_product); if ($prod->fetch($fk_product) > 0) { - $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, $fourn_ref); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$fourn_ref + $product_type = $prod->type; + $label = $prod->libelle; + + // We use 'none' instead of $fourn_ref, because fourn_ref may not exists anymore. So we will take the first supplier price ok. + // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. + $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', $this->fk_soc); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$fourn_ref/$this->fk_soc if ($result > 0) { - $label = $prod->libelle; - $pu = $prod->fourn_pu; - $ref = $prod->ref_fourn; - $product_type = $prod->type; + $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice + $ref = $prod->ref_fourn; // Ref supplier price set by get_buyprice } - if ($result == 0 || $result == -1) + if ($result == 0) // If result == 0, we failed to found the supplier reference price + { + $langs->load("errors"); + $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); + $this->db->rollback(); + dol_syslog(get_class($this)."::addline we did not found supplier price, so we can't guess unit price"); + //$pu = $prod->fourn_pu; // We do not overwrite unit price + //$ref = $prod->ref_fourn; // We do not overwrite ref supplier price + return -1; + } + if ($result == -1) { $langs->load("errors"); $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); @@ -1424,7 +1438,7 @@ class CommandeFournisseur extends CommonOrder $subprice = price2num($pu,'MU'); - // TODO We should use here $this->line=new CommandeFournisseurLigne($this->db); and $this->line->insert(); to work loke other object (proposal, order, invoice) + // TODO We should use here $this->line=new CommandeFournisseurLigne($this->db); and $this->line->insert(); to work like other object (proposal, order, invoice) $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet"; $sql.= " (fk_commande, label, description, date_start, date_end,"; $sql.= " fk_product, product_type,"; @@ -2708,15 +2722,7 @@ class CommandeFournisseurLigne extends CommonOrderLine // From llx_product_fournisseur_price /** - * Supplier ref - * @var string - * @deprecated Use ref_supplier - * @see ref_supplier - */ - public $ref_fourn; - - /** - * Supplier reference + * Supplier reference of price when we added the line. May have been changed after line was added. * @var string */ public $ref_supplier; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 8c1a86b03a5..bc7f5bfdca6 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1219,11 +1219,11 @@ class FactureFournisseur extends CommonInvoice $txtva=price2num($txtva); $txlocaltax1=price2num($txlocaltax1); $txlocaltax2=price2num($txlocaltax2); - + $ref=''; // Ref of supplier price when we add line + // Check parameters if ($type < 0) return -1; - $this->db->begin(); $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn)'; @@ -1954,12 +1954,14 @@ class SupplierInvoiceLine extends CommonObjectLine * @var string */ public $product_ref; + /** - * Reference product supplier - * TODO Rename field ref to ref_supplier into table llx_facture_fourn_det and llx_commande_fournisseurdet and update fields it into updateline + * Supplier reference of price when we added the line. May have been changed after line was added. + * TODO Rename field ref to ref_supplier into table llx_facture_fourn_det and llx_commande_fournisseurdet and update fields into updateline * @var string */ public $ref_supplier; + /** * @deprecated * @see label diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 2d222829812..fe432b5dc5e 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1334,10 +1334,11 @@ class Product extends CommonObject * @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price * @param double $qty Quantity asked or -1 to get first entry found * @param int $product_id Filter on a particular product id - * @param string $fourn_ref Filter on a supplier ref. 'none' to exclude ref in search. + * @param string $fourn_ref Filter on a supplier price ref. 'none' to exclude ref in search. + * @param int $fk_soc If of supplier * @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...) */ - function get_buyprice($prodfournprice, $qty, $product_id=0, $fourn_ref='') + function get_buyprice($prodfournprice, $qty, $product_id=0, $fourn_ref='', $fk_soc=0) { global $conf; $result = 0; @@ -1383,12 +1384,13 @@ class Product extends CommonObject } else // If not found { - // We do a second search by doing a select again but searching with qty and id product + // We do a second search by doing a select again but searching with less reliable criteria: couple qty/id product, and if set fourn_ref or fk_soc. $sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,"; $sql.= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.tva_tx, pfp.fk_supplier_price_expression"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE pfp.fk_product = ".$product_id; if ($fourn_ref != 'none') $sql.= " AND pfp.ref_fourn = '".$fourn_ref."'"; + if ($fk_soc > 0) $sql.= " AND pfp.fk_soc = ".$fk_soc; if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty; $sql.= " ORDER BY pfp.quantity DESC"; $sql.= " LIMIT 1"; From 9f0528f5f18c0b6710dfd231a6f90d615c0d5ecb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Dec 2016 23:59:26 +0100 Subject: [PATCH 24/37] Complete work on dol_banner --- htdocs/expensereport/card.php | 19 +- htdocs/holiday/card.php | 390 +++++++++++++------------ htdocs/holiday/class/holiday.class.php | 15 +- htdocs/holiday/document.php | 180 ++++++++---- htdocs/langs/en_US/holiday.lang | 1 + htdocs/langs/en_US/trips.lang | 12 +- 6 files changed, 338 insertions(+), 279 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 7206dc532a5..a2f8e54bf6b 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1350,10 +1350,10 @@ else print ''; } - print ''; - $linkback = ''.$langs->trans("BackToList").''; + print '
'; + print ''; print ''; print '
'.$langs->trans("User").''; @@ -1564,12 +1564,6 @@ else print ''; - // Ref - /* - print '';*/ - // Author print ''; print ''; @@ -1586,7 +1580,7 @@ else print ''; print ''; print ''; print ''; if (! empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) @@ -1596,13 +1590,6 @@ else print ''; print ''; } - // Status - /* - print ''; - print ''; - print ''; - print ''; - */ // Amount print ''; diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index d0dc205fc0e..e8e4d3b9c12 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -54,7 +54,7 @@ $now=dol_now(); // If create a request if ($action == 'create') { - $cp = new Holiday($db); + $object = new Holiday($db); // If no right to create a request if (($userid == $user->id && empty($user->rights->holiday->write)) || ($userid != $user->id && empty($user->rights->holiday->write_all))) @@ -115,7 +115,7 @@ if ($action == 'create') } // Check if there is already holiday for this period - $verifCP = $cp->verifDateHolidayCP($userID, $date_debut, $date_fin, $halfday); + $verifCP = $object->verifDateHolidayCP($userID, $date_debut, $date_fin, $halfday); if (! $verifCP) { setEventMessages($langs->trans("alreadyCPexist"), null, 'errors'); @@ -145,15 +145,15 @@ if ($action == 'create') if (! $error) { - $cp->fk_user = $userid; - $cp->description = $description; - $cp->date_debut = $date_debut; - $cp->date_fin = $date_fin; - $cp->fk_validator = $valideur; - $cp->halfday = $halfday; - $cp->fk_type = $type; + $object->fk_user = $userid; + $object->description = $description; + $object->date_debut = $date_debut; + $object->date_fin = $date_fin; + $object->fk_validator = $valideur; + $object->halfday = $halfday; + $object->fk_type = $type; - $result = $cp->create($user); + $result = $object->create($user); } // If no SQL error we redirect to the request card @@ -161,7 +161,7 @@ if ($action == 'create') { $db->commit(); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else @@ -191,13 +191,13 @@ if ($action == 'update') exit; } - $cp = new Holiday($db); - $cp->fetch($id); + $object = new Holiday($db); + $object->fetch($id); - $canedit=(($user->id == $cp->fk_user && $user->rights->holiday->write) || ($user->id != $cp->fk_user && $user->rights->holiday->write_all)); + $canedit=(($user->id == $object->fk_user && $user->rights->holiday->write) || ($user->id != $object->fk_user && $user->rights->holiday->write_all)); // If under validation - if ($cp->statut == 1) + if ($object->statut == 1) { // If this is the requestor or has read/write rights if ($canedit) @@ -207,25 +207,25 @@ if ($action == 'update') // If no start date if (empty($_POST['date_debut_'])) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id.'&action=edit&error=nodatedebut'); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=nodatedebut'); exit; } // If no end date if (empty($_POST['date_fin_'])) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id.'&action=edit&error=nodatefin'); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=nodatefin'); exit; } // If start date after end date if ($date_debut > $date_fin) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id.'&action=edit&error=datefin'); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=datefin'); exit; } // If no validator designated if ($valideur < 1) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id.'&action=edit&error=Valideur'); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=Valideur'); exit; } @@ -233,32 +233,32 @@ if ($action == 'update') $nbopenedday=num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday); if ($nbopenedday < 0.5) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id.'&action=edit&error=DureeHoliday'); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=DureeHoliday'); exit; } - $cp->description = $description; - $cp->date_debut = $date_debut; - $cp->date_fin = $date_fin; - $cp->fk_validator = $valideur; - $cp->halfday = $halfday; + $object->description = $description; + $object->date_debut = $date_debut; + $object->date_fin = $date_fin; + $object->fk_validator = $valideur; + $object->halfday = $halfday; // Update - $verif = $cp->update($user->id); + $verif = $object->update($user->id); if ($verif > 0) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { // Otherwise we display the request form with the SQL error message - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id.'&action=edit&error=SQL_Create&msg='.$cp->error); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&error=SQL_Create&msg='.$object->error); exit; } } } else { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } } @@ -270,18 +270,18 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights- $db->begin(); - $cp = new Holiday($db); - $cp->fetch($id); + $object = new Holiday($db); + $object->fetch($id); - $canedit=(($user->id == $cp->fk_user && $user->rights->holiday->write) || ($user->id != $cp->fk_user && $user->rights->holiday->write_all)); + $canedit=(($user->id == $object->fk_user && $user->rights->holiday->write) || ($user->id != $object->fk_user && $user->rights->holiday->write_all)); // If this is a rough draft - if ($cp->statut == 1 || $cp->statut == 3) + if ($object->statut == 1 || $object->statut == 3) { // Si l'utilisateur à le droit de lire cette demande, il peut la supprimer if ($canedit) { - $result=$cp->delete($cp->id); + $result=$object->delete($object->id); } else { @@ -304,36 +304,36 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights- // Si envoi de la demande if ($action == 'confirm_send') { - $cp = new Holiday($db); - $cp->fetch($id); + $object = new Holiday($db); + $object->fetch($id); - $canedit=(($user->id == $cp->fk_user && $user->rights->holiday->write) || ($user->id != $cp->fk_user && $user->rights->holiday->write_all)); + $canedit=(($user->id == $object->fk_user && $user->rights->holiday->write) || ($user->id != $object->fk_user && $user->rights->holiday->write_all)); // Si brouillon et créateur - if($cp->statut == 1 && $canedit) + if($object->statut == 1 && $canedit) { - $cp->statut = 2; + $object->statut = 2; - $verif = $cp->update($user->id); + $verif = $object->update($user->id); // Si pas d'erreur SQL on redirige vers la fiche de la demande if ($verif > 0) { // To $destinataire = new User($db); - $destinataire->fetch($cp->fk_validator); + $destinataire->fetch($object->fk_validator); $emailTo = $destinataire->email; if (!$emailTo) { dol_syslog("Expected validator has no email, so we redirect directly to finished page without sending email"); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } // From $expediteur = new User($db); - $expediteur->fetch($cp->fk_user); + $expediteur->fetch($object->fk_user); $emailFrom = $expediteur->email; // Subject @@ -347,26 +347,26 @@ if ($action == 'confirm_send') $message.= "\n"; $message.= $langs->transnoentities("HolidaysToValidateBody")."\n"; - $delayForRequest = $cp->getConfCP('delayForRequest'); + $delayForRequest = $object->getConfCP('delayForRequest'); //$delayForRequest = $delayForRequest * (60*60*24); $nextMonth = dol_time_plus_duree($now, $delayForRequest, 'd'); // Si l'option pour avertir le valideur en cas de délai trop court - if($cp->getConfCP('AlertValidatorDelay')) + if($object->getConfCP('AlertValidatorDelay')) { - if($cp->date_debut < $nextMonth) + if($object->date_debut < $nextMonth) { $message.= "\n"; - $message.= $langs->transnoentities("HolidaysToValidateDelay",$cp->getConfCP('delayForRequest'))."\n"; + $message.= $langs->transnoentities("HolidaysToValidateDelay",$object->getConfCP('delayForRequest'))."\n"; } } // Si l'option pour avertir le valideur en cas de solde inférieur à la demande - if ($cp->getConfCP('AlertValidatorSolde')) + if ($object->getConfCP('AlertValidatorSolde')) { - $nbopenedday=num_open_day($cp->date_debut_gmt,$cp->date_fin_gmt,0,1,$cp->halfday); - if ($nbopenedday > $cp->getCPforUser($cp->fk_user, $cp->fk_type)) + $nbopenedday=num_open_day($object->date_debut_gmt,$object->date_fin_gmt,0,1,$object->halfday); + if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type)) { $message.= "\n"; $message.= $langs->transnoentities("HolidaysToValidateAlertSolde")."\n"; @@ -375,8 +375,8 @@ if ($action == 'confirm_send') $message.= "\n"; $message.= "- ".$langs->transnoentitiesnoconv("Name")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; - $message.= "- ".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($cp->date_debut,'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($cp->date_fin,'day')."\n"; - $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$cp->id."\n\n"; + $message.= "- ".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($object->date_debut,'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($object->date_fin,'day')."\n"; + $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; $message.= "\n"; $mail = new CMailFile($subject,$emailTo,$emailFrom,$message); @@ -386,16 +386,16 @@ if ($action == 'confirm_send') if (!$result) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id.'&error=mail&error_content='.$mail->error); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=mail&error_content='.$mail->error); exit; } - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { // Sinon on affiche le formulaire de demande avec le message d'erreur SQL - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id.'&error=SQL_Create&msg='.$cp->error); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=SQL_Create&msg='.$object->error); exit; } } @@ -405,48 +405,48 @@ if ($action == 'confirm_send') // Si Validation de la demande if ($action == 'confirm_valid') { - $cp = new Holiday($db); - $cp->fetch($id); + $object = new Holiday($db); + $object->fetch($id); // Si statut en attente de validation et valideur = utilisateur - if ($cp->statut == 2 && $user->id == $cp->fk_validator) + if ($object->statut == 2 && $user->id == $object->fk_validator) { - $cp->date_valid = dol_now(); - $cp->fk_user_valid = $user->id; - $cp->statut = 3; + $object->date_valid = dol_now(); + $object->fk_user_valid = $user->id; + $object->statut = 3; - $verif = $cp->update($user->id); + $verif = $object->update($user->id); // Si pas d'erreur SQL on redirige vers la fiche de la demande if ($verif > 0) { // Calculcate number of days consummed - $nbopenedday=num_open_day($cp->date_debut_gmt,$cp->date_fin_gmt,0,1,$cp->halfday); + $nbopenedday=num_open_day($object->date_debut_gmt,$object->date_fin_gmt,0,1,$object->halfday); - $soldeActuel = $cp->getCpforUser($cp->fk_user, $cp->fk_type); - $newSolde = $soldeActuel - ($nbopenedday * $cp->getConfCP('nbHolidayDeducted')); + $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type); + $newSolde = $soldeActuel - ($nbopenedday * $object->getConfCP('nbHolidayDeducted')); // On ajoute la modification dans le LOG - $cp->addLogCP($user->id, $cp->fk_user, $langs->transnoentitiesnoconv("Holidays"), $newSolde, $cp->fk_type); + $object->addLogCP($user->id, $object->fk_user, $langs->transnoentitiesnoconv("Holidays"), $newSolde, $object->fk_type); // Mise à jour du solde - $cp->updateSoldeCP($cp->fk_user, $newSolde, $cp->fk_type); + $object->updateSoldeCP($object->fk_user, $newSolde, $object->fk_type); // To $destinataire = new User($db); - $destinataire->fetch($cp->fk_user); + $destinataire->fetch($object->fk_user); $emailTo = $destinataire->email; if (!$emailTo) { dol_syslog("User that request leave has no email, so we redirect directly to finished page without sending email"); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } // From $expediteur = new User($db); - $expediteur->fetch($cp->fk_validator); + $expediteur->fetch($object->fk_validator); $emailFrom = $expediteur->email; // Subject @@ -458,11 +458,11 @@ if ($action == 'confirm_valid') // Content $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; $message.= "\n"; - $message.= $langs->transnoentities("HolidaysValidatedBody", dol_print_date($cp->date_debut,'day'),dol_print_date($cp->date_fin,'day'))."\n"; + $message.= $langs->transnoentities("HolidaysValidatedBody", dol_print_date($object->date_debut,'day'),dol_print_date($object->date_fin,'day'))."\n"; $message.= "- ".$langs->transnoentitiesnoconv("ValidatedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; - $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$cp->id."\n\n"; + $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; $message.= "\n"; $mail = new CMailFile($subject,$emailTo,$emailFrom,$message); @@ -471,15 +471,15 @@ if ($action == 'confirm_valid') $result=$mail->sendfile(); if(!$result) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id.'&error=mail&error_content='.$mail->error); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=mail&error_content='.$mail->error); exit; } - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { // Sinon on affiche le formulaire de demande avec le message d'erreur SQL - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id.'&error=SQL_Create&msg='.$cp->error); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=SQL_Create&msg='.$object->error); exit; } @@ -491,36 +491,36 @@ if ($action == 'confirm_refuse') { if (! empty($_POST['detail_refuse'])) { - $cp = new Holiday($db); - $cp->fetch($id); + $object = new Holiday($db); + $object->fetch($id); // Si statut en attente de validation et valideur = utilisateur - if ($cp->statut == 2 && $user->id == $cp->fk_validator) + if ($object->statut == 2 && $user->id == $object->fk_validator) { - $cp->date_refuse = date('Y-m-d H:i:s', time()); - $cp->fk_user_refuse = $user->id; - $cp->statut = 5; - $cp->detail_refuse = $_POST['detail_refuse']; + $object->date_refuse = date('Y-m-d H:i:s', time()); + $object->fk_user_refuse = $user->id; + $object->statut = 5; + $object->detail_refuse = $_POST['detail_refuse']; - $verif = $cp->update($user->id); + $verif = $object->update($user->id); // Si pas d'erreur SQL on redirige vers la fiche de la demande if ($verif > 0) { // To $destinataire = new User($db); - $destinataire->fetch($cp->fk_user); + $destinataire->fetch($object->fk_user); $emailTo = $destinataire->email; if (!$emailTo) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } // From $expediteur = new User($db); - $expediteur->fetch($cp->fk_validator); + $expediteur->fetch($object->fk_validator); $emailFrom = $expediteur->email; // Subject @@ -532,12 +532,12 @@ if ($action == 'confirm_refuse') // Content $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; $message.= "\n"; - $message.= $langs->transnoentities("HolidaysRefusedBody", dol_print_date($cp->date_debut,'day'), dol_print_date($cp->date_fin,'day'))."\n"; + $message.= $langs->transnoentities("HolidaysRefusedBody", dol_print_date($object->date_debut,'day'), dol_print_date($object->date_fin,'day'))."\n"; $message.= GETPOST('detail_refuse','alpha')."\n\n"; $message.= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; - $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$cp->id."\n\n"; + $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; $message.= "\n"; $mail = new CMailFile($subject,$emailTo,$emailFrom,$message); @@ -546,22 +546,22 @@ if ($action == 'confirm_refuse') $result=$mail->sendfile(); if(!$result) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id.'&error=mail&error_content='.$mail->error); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=mail&error_content='.$mail->error); exit; } - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { // Sinon on affiche le formulaire de demande avec le message d'erreur SQL - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id.'&error=SQL_Create&msg='.$cp->error); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=SQL_Create&msg='.$object->error); exit; } } } else { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id.'&error=NoMotifRefuse'); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=NoMotifRefuse'); exit; } } @@ -569,34 +569,34 @@ if ($action == 'confirm_refuse') // Si Validation de la demande if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') { - $cp = new Holiday($db); - $cp->fetch($id); + $object = new Holiday($db); + $object->fetch($id); // Si statut en attente de validation et valideur = utilisateur - if (($cp->statut == 2 || $cp->statut == 3) && ($user->id == $cp->fk_validator || $user->id == $cp->fk_user)) + if (($object->statut == 2 || $object->statut == 3) && ($user->id == $object->fk_validator || $user->id == $object->fk_user)) { $db->begin(); - $oldstatus = $cp->statut; - $cp->date_cancel = dol_now(); - $cp->fk_user_cancel = $user->id; - $cp->statut = 4; + $oldstatus = $object->statut; + $object->date_cancel = dol_now(); + $object->fk_user_cancel = $user->id; + $object->statut = 4; - $result = $cp->update($user->id); + $result = $object->update($user->id); if ($result >= 0 && $oldstatus == 3) // holiday was already validated, status 3, so we must increase back sold { // Calculcate number of days consummed - $nbopenedday=num_open_day($cp->date_debut_gmt,$cp->date_fin_gmt,0,1,$cp->halfday); + $nbopenedday=num_open_day($object->date_debut_gmt,$object->date_fin_gmt,0,1,$object->halfday); - $soldeActuel = $cp->getCpforUser($cp->fk_user, $cp->fk_type); - $newSolde = $soldeActuel + ($nbopenedday * $cp->getConfCP('nbHolidayDeducted')); + $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type); + $newSolde = $soldeActuel + ($nbopenedday * $object->getConfCP('nbHolidayDeducted')); // On ajoute la modification dans le LOG - $result1=$cp->addLogCP($user->id, $cp->fk_user, $langs->transnoentitiesnoconv("HolidaysCancelation"), $newSolde, $cp->fk_type); + $result1=$object->addLogCP($user->id, $object->fk_user, $langs->transnoentitiesnoconv("HolidaysCancelation"), $newSolde, $object->fk_type); // Mise à jour du solde - $result2=$cp->updateSoldeCP($cp->fk_user, $newSolde, $cp->fk_type); + $result2=$object->updateSoldeCP($object->fk_user, $newSolde, $object->fk_type); if ($result1 < 0 || $result2 < 0) { @@ -618,18 +618,18 @@ if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') { // To $destinataire = new User($db); - $destinataire->fetch($cp->fk_user); + $destinataire->fetch($object->fk_user); $emailTo = $destinataire->email; if (!$emailTo) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } // From $expediteur = new User($db); - $expediteur->fetch($cp->fk_user_cancel); + $expediteur->fetch($object->fk_user_cancel); $emailFrom = $expediteur->email; // Subject @@ -642,10 +642,10 @@ if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; $message.= "\n"; - $message.= $langs->transnoentities("HolidaysCanceledBody", dol_print_date($cp->date_debut,'day'), dol_print_date($cp->date_fin,'day'))."\n"; + $message.= $langs->transnoentities("HolidaysCanceledBody", dol_print_date($object->date_debut,'day'), dol_print_date($object->date_fin,'day'))."\n"; $message.= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; - $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$cp->id."\n\n"; + $message.= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; $message.= "\n"; $mail = new CMailFile($subject,$emailTo,$emailFrom,$message); @@ -655,17 +655,17 @@ if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') if(!$result) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id.'&error=mail&error_content='.$mail->error); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=mail&error_content='.$mail->error); exit; } - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { // Sinon on affiche le formulaire de demande avec le message d'erreur SQL - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$cp->id.'&error=SQL_Create&msg='.$cp->error); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=SQL_Create&msg='.$object->error); exit; } @@ -680,7 +680,7 @@ if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') */ $form = new Form($db); -$cp = new Holiday($db); +$object = new Holiday($db); $listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon")); @@ -732,7 +732,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create } - $delayForRequest = $cp->getConfCP('delayForRequest'); + $delayForRequest = $object->getConfCP('delayForRequest'); //$delayForRequest = $delayForRequest * (60*60*24); $nextMonth = dol_time_plus_duree($now, $delayForRequest, 'd'); @@ -774,10 +774,10 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create dol_fiche_head(); $out=''; - $typeleaves=$cp->getTypes(1,1); + $typeleaves=$object->getTypes(1,1); foreach($typeleaves as $key => $val) { - $nb_type = $cp->getCPforUser($user->id, $val['rowid']); + $nb_type = $object->getCPforUser($user->id, $val['rowid']); $nb_holiday += $nb_type; $out .= ' - '.$val['label'].': '.($nb_type?price2num($nb_type):0).'
'; } @@ -789,7 +789,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create dol_fiche_head(); - //print ''.$langs->trans('DelayToRequestCP',$cp->getConfCP('delayForRequest')).'

'; + //print ''.$langs->trans('DelayToRequestCP',$object->getConfCP('delayForRequest')).'

'; print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); - print '
'.$langs->trans("User").'
'.$langs->trans("Period").''; - print get_date_range($object->date_debut,$object->date_fin,'',$langs,0); + print get_date_range($object->date_debut,$object->date_fin,'day',$langs,0); print '
'.$object->libelle_paiement.'
'.$langs->trans("Statut").''.$object->getLibStatut(4).'
'; print ''; @@ -811,7 +811,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print ''; print ''; print '
'.$langs->trans("Type").''; - $typeleaves=$cp->getTypes(1,-1); + $typeleaves=$object->getTypes(1,-1); $arraytypeleaves=array(); foreach($typeleaves as $key => $val) { @@ -900,15 +900,15 @@ else // Affichage de la fiche d'une demande de congés payés if ($id > 0) { - $cp->fetch($id); + $object->fetch($id); - $canedit=(($user->id == $cp->fk_user && $user->rights->holiday->write) || ($user->id != $cp->fk_user && $user->rights->holiday->write_all)); + $canedit=(($user->id == $object->fk_user && $user->rights->holiday->write) || ($user->id != $object->fk_user && $user->rights->holiday->write_all)); $valideur = new User($db); - $valideur->fetch($cp->fk_validator); + $valideur->fetch($object->fk_validator); $userRequest = new User($db); - $userRequest->fetch($cp->fk_user); + $userRequest->fetch($object->fk_user); //print load_fiche_titre($langs->trans('TitreRequestCP')); @@ -956,61 +956,62 @@ else { if ($user->rights->holiday->delete) { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$cp->id,$langs->trans("TitleDeleteCP"),$langs->trans("ConfirmDeleteCP"),"confirm_delete", '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleDeleteCP"),$langs->trans("ConfirmDeleteCP"),"confirm_delete", '', 0, 1); } } // Si envoi en validation - if ($action == 'sendToValidate' && $cp->statut == 1) + if ($action == 'sendToValidate' && $object->statut == 1) { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$cp->id,$langs->trans("TitleToValidCP"),$langs->trans("ConfirmToValidCP"),"confirm_send", '', 1, 1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleToValidCP"),$langs->trans("ConfirmToValidCP"),"confirm_send", '', 1, 1); } // Si validation de la demande if ($action == 'valid') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$cp->id,$langs->trans("TitleValidCP"),$langs->trans("ConfirmValidCP"),"confirm_valid", '', 1, 1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleValidCP"),$langs->trans("ConfirmValidCP"),"confirm_valid", '', 1, 1); } // Si refus de la demande if ($action == 'refuse') { $array_input = array(array('type'=>"text",'label'=> $langs->trans('DetailRefusCP'),'name'=>"detail_refuse",'size'=>"50",'value'=>"")); - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$cp->id."&action=confirm_refuse", $langs->trans("TitleRefuseCP"), $langs->trans('ConfirmRefuseCP'), "confirm_refuse", $array_input, 1, 0); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&action=confirm_refuse", $langs->trans("TitleRefuseCP"), $langs->trans('ConfirmRefuseCP'), "confirm_refuse", $array_input, 1, 0); } // Si annulation de la demande if ($action == 'cancel') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$cp->id,$langs->trans("TitleCancelCP"),$langs->trans("ConfirmCancelCP"),"confirm_cancel", '', 1, 1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleCancelCP"),$langs->trans("ConfirmCancelCP"),"confirm_cancel", '', 1, 1); } - $head=holiday_prepare_head($cp); + $head=holiday_prepare_head($object); - if ($action == 'edit' && $cp->statut == 1) + if ($action == 'edit' && $object->statut == 1) { $edit = true; - print ''."\n"; + print ''."\n"; print ''."\n"; - print ''."\n"; + print ''."\n"; } dol_fiche_head($head,'card',$langs->trans("CPTitreMenu"),0,'holiday'); - print ''; + $linkback=''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref'); + + + print '
'; + print '
'; + print '
'; + + print '
'; print ''; - $linkback=''.$langs->trans("BackToList").''; - print ''; - print ''; - print ''; - print ''; - - print ''; + print ''; print ''; @@ -1019,19 +1020,19 @@ else print ''; print ''; print ''; print ''; - $starthalfday=($cp->halfday == -1 || $cp->halfday == 2)?'afternoon':'morning'; - $endhalfday=($cp->halfday == 1 || $cp->halfday == 2)?'morning':'afternoon'; + $starthalfday=($object->halfday == -1 || $object->halfday == 2)?'afternoon':'morning'; + $endhalfday=($object->halfday == 1 || $object->halfday == 2)?'morning':'afternoon'; if(!$edit) { print ''; print ''; - print ''; @@ -1042,7 +1043,7 @@ else print ''; print ''; print ''; @@ -1053,7 +1054,7 @@ else { print ''; print ''; - print ''; @@ -1064,7 +1065,7 @@ else print ''; print ''; print ''; @@ -1072,19 +1073,14 @@ else } print ''; print ''; - print ''; + print ''; print ''; - // Status - print ''; - print ''; - print ''; - print ''; - if ($cp->statut == 5) + if ($object->statut == 5) { print ''; print ''; - print ''; + print ''; print ''; } @@ -1093,84 +1089,92 @@ else { print ''; print ''; - print ''; + print ''; print ''; } else { print ''; print ''; - print ''; + print ''; print ''; } print ''; print '
'.$langs->trans("Ref").''; - print $form->showrefnav($cp, 'id', $linkback, 1, 'rowid', 'ref'); - print '
'.$langs->trans("User").''.$langs->trans("User").''; print $userRequest->getNomUrl(-1, 'leave'); print '
'.$langs->trans("Type").''; - $typeleaves=$cp->getTypes(1,-1); - print $typeleaves[$cp->fk_type]['label']; + $typeleaves=$object->getTypes(1,-1); + print empty($typeleaves[$object->fk_type]['label']) ? $langs->trans("TypeWasDisabledOrRemoved",$object->fk_type) : $typeleaves[$object->fk_type]['label']; print '
'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'.dol_print_date($cp->date_debut,'day'); + print ''.dol_print_date($object->date_debut,'day'); print '     '; print $langs->trans($listhalfday[$starthalfday]); print '
'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; - $form->select_date($cp->date_debut,'date_debut_'); + $form->select_date($object->date_debut,'date_debut_'); print '     '; print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday')?GETPOST('starthalfday'):$starthalfday)); print '
'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'.dol_print_date($cp->date_fin,'day'); + print ''.dol_print_date($object->date_fin,'day'); print '     '; print $langs->trans($listhalfday[$endhalfday]); print '
'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'; - $form->select_date($cp->date_fin,'date_fin_'); + $form->select_date($object->date_fin,'date_fin_'); print '     '; print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday')?GETPOST('endhalfday'):$endhalfday)); print '
'.$langs->trans('NbUseDaysCP').''.num_open_day($cp->date_debut_gmt, $cp->date_fin_gmt, 0, 1, $cp->halfday).''.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).'
'.$langs->trans('StatutCP').''.$cp->getLibStatut(2).'
'.$langs->trans('DetailRefusCP').''.$cp->detail_refuse.''.$object->detail_refuse.'
'.$langs->trans('DescCP').''.nl2br($cp->description).''.nl2br($object->description).'
'.$langs->trans('DescCP').'
'."\n"; - print '

'; - + print ''; + print '
'; + print '
'; + + print '
'; + // Info workflow - print ''."\n"; + print '
'."\n"; print ''; - print ''; - print ''; - print ''; - if (! empty($cp->fk_user_create)) + if (! empty($object->fk_user_create)) { $userCreate=new User($db); - $userCreate->fetch($cp->fk_user_create); + $userCreate->fetch($object->fk_user_create); print ''; - print ''; + print ''; print ''; print ''; } if (!$edit) { print ''; - print ''; + print ''; print ''; print ''; } else { print ''; - print ''; + print ''; print ''; print ''; } print ''; print ''; - print ''; + print ''; print ''; - if ($cp->statut == 3) { + if ($object->statut == 3) { print ''; print ''; - print ''; + print ''; print ''; } - if ($cp->statut == 4) { + if ($object->statut == 4) { print ''; print ''; - print ''; + print ''; print ''; } - if ($cp->statut == 5) { + if ($object->statut == 5) { print ''; print ''; - print ''; + print ''; print ''; } print ''; print '
'.$langs->trans("InfosWorkflowCP").'
'.$langs->trans('RequestByCP').''.$langs->trans('RequestByCP').''.$userCreate->getNomUrl(-1).'
'.$langs->trans('ReviewedByCP').''.$langs->trans('ReviewedByCP').''.$valideur->getNomUrl(-1).'
'.$langs->trans('ReviewedByCP').''.$langs->trans('ReviewedByCP').''; - print $form->select_dolusers($cp->fk_user, "valideur", 1, ($user->admin ? '' : array($user->id))); // By default, hierarchical parent + print $form->select_dolusers($object->fk_user, "valideur", 1, ($user->admin ? '' : array($user->id))); // By default, hierarchical parent print '
'.$langs->trans('DateCreateCP').''.dol_print_date($cp->date_create,'dayhour').''.dol_print_date($object->date_create,'dayhour').'
'.$langs->trans('DateValidCP').''.dol_print_date($cp->date_valid,'dayhour').''.dol_print_date($object->date_valid,'dayhour').'
'.$langs->trans('DateCancelCP').''.dol_print_date($cp->date_cancel,'dayhour').''.dol_print_date($object->date_cancel,'dayhour').'
'.$langs->trans('DateRefusCP').''.dol_print_date($cp->date_refuse,'dayhour').''.dol_print_date($object->date_refuse,'dayhour').'
'; + print '
'; + print '
'; + print ''; + + print '
'; + dol_fiche_end(); - if ($action == 'edit' && $cp->statut == 1) + + if ($action == 'edit' && $object->statut == 1) { print '
'; - if ($canedit && $cp->statut == 1) + if ($canedit && $object->statut == 1) { print ''; } @@ -1185,28 +1189,28 @@ else print '
'; // Boutons d'actions - if ($canedit && $cp->statut == 1) + if ($canedit && $object->statut == 1) { - print ''.$langs->trans("EditCP").''; + print ''.$langs->trans("EditCP").''; } - if ($canedit && $cp->statut == 1) + if ($canedit && $object->statut == 1) { - print ''.$langs->trans("Validate").''; + print ''.$langs->trans("Validate").''; } - if ($user->rights->holiday->delete && $cp->statut == 1) // If draft + if ($user->rights->holiday->delete && $object->statut == 1) // If draft { - print ''.$langs->trans("DeleteCP").''; + print ''.$langs->trans("DeleteCP").''; } - if ($user->id == $cp->fk_validator && $cp->statut == 2) + if ($user->id == $object->fk_validator && $object->statut == 2) { - print ''.$langs->trans("Approve").''; - print ''.$langs->trans("ActionRefuseCP").''; + print ''.$langs->trans("Approve").''; + print ''.$langs->trans("ActionRefuseCP").''; } - if (($user->id == $cp->fk_validator || $user->id == $cp->fk_user) && ($cp->statut == 2 || $cp->statut == 3)) // Status validated or approved + if (($user->id == $object->fk_validator || $user->id == $object->fk_user) && ($object->statut == 2 || $object->statut == 3)) // Status validated or approved { - if (($cp->date_debut > dol_now()) || $user->admin) print ''.$langs->trans("ActionCancelCP").''; + if (($object->date_debut > dol_now()) || $user->admin) print ''.$langs->trans("ActionCancelCP").''; else print ''.$langs->trans("ActionCancelCP").''; } diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index dc9adcd7725..78bc1582a65 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -36,7 +36,8 @@ class Holiday extends CommonObject public $table_element='holiday'; protected $isnolinkedbythird = 1; // No field fk_soc protected $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - + public $picto = 'holiday'; + /** * @deprecated * @see id @@ -785,7 +786,17 @@ class Holiday extends CommonObject if ($statut == 4) return $langs->trans('CancelCP').' '.img_picto($langs->trans('CancelCP'),'statut5'); if ($statut == 5) return $langs->trans('RefuseCP').' '.img_picto($langs->trans('RefuseCP'),'statut5'); } - + if ($mode == 6) + { + $pictoapproved='statut6'; + if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4'; + if ($statut == 1) return $langs->trans('DraftCP').' '.img_picto($langs->trans('DraftCP'),'statut0'); // Draft + if ($statut == 2) return $langs->trans('ToReviewCP').' '.img_picto($langs->trans('ToReviewCP'),'statut1'); // Waiting approval + if ($statut == 3) return $langs->trans('ApprovedCP').' '.img_picto($langs->trans('ApprovedCP'),$pictoapproved); + if ($statut == 4) return $langs->trans('CancelCP').' '.img_picto($langs->trans('CancelCP'),'statut5'); + if ($statut == 5) return $langs->trans('RefuseCP').' '.img_picto($langs->trans('RefuseCP'),'statut5'); + } + return $statut; } diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php index edc85ca0060..1d30e33f189 100644 --- a/htdocs/holiday/document.php +++ b/htdocs/holiday/document.php @@ -108,28 +108,29 @@ if ($object->id) } - print ''; - - $linkback=''.$langs->trans("BackToList").''; - + $linkback=''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref'); + + + print '
'; + //print '
'; + print '
'; + + print '
'; + print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; + print ''; + print ''; // Type print ''; print ''; print ''; print ''; @@ -138,57 +139,52 @@ if ($object->id) if(!$edit) { - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; } else { - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; } if (!$edit) { - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; } else { - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; } print ''; print ''; print ''; print ''; - // Status - print ''; - print ''; - print ''; - print ''; if ($object->statut == 5) { print ''; @@ -200,25 +196,93 @@ if ($object->id) // Description if (!$edit) { - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; } else { - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; } print ''; print ''; + + print ''; + print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref'); - print '
'.$langs->trans("User").''; - print $userRequest->getNomUrl(-1); - print '
'.$langs->trans("User").''; + print $userRequest->getNomUrl(-1, 'leave'); + print '
'.$langs->trans("Type").''; $typeleaves=$object->getTypes(1,-1); - print $typeleaves[$object->fk_type]['label']; + print empty($typeleaves[$object->fk_type]['label']) ? $langs->trans("TypeWasDisabledOrRemoved",$object->fk_type) : $typeleaves[$object->fk_type]['label']; print '
'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'.dol_print_date($object->date_debut,'day'); - print '     '; - print $langs->trans($listhalfday[$starthalfday]); - print '
'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'.dol_print_date($object->date_debut,'day'); + print '     '; + print $langs->trans($listhalfday[$starthalfday]); + print '
'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; - $form->select_date($object->date_debut,'date_debut_'); - print '     '; - print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday')?GETPOST('starthalfday'):$starthalfday)); - print '
'.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; + $form->select_date($object->date_debut,'date_debut_'); + print '     '; + print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday')?GETPOST('starthalfday'):$starthalfday)); + print '
'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'.dol_print_date($object->date_fin,'day'); - print '     '; - print $langs->trans($listhalfday[$endhalfday]); - print '
'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'.dol_print_date($object->date_fin,'day'); + print '     '; + print $langs->trans($listhalfday[$endhalfday]); + print '
'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'; - $form->select_date($object->date_fin,'date_fin_'); - print '     '; - print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday')?GETPOST('endhalfday'):$endhalfday)); - print '
'.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'; + $form->select_date($object->date_fin,'date_fin_'); + print '     '; + print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday')?GETPOST('endhalfday'):$endhalfday)); + print '
'.$langs->trans('NbUseDaysCP').''.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).'
'.$langs->trans('StatutCP').''.$object->getLibStatut(2).'
'.$langs->trans('DescCP').''.nl2br($object->description).'
'.$langs->trans('DescCP').''.nl2br($object->description).'
'.$langs->trans('DescCP').'
'.$langs->trans('DescCP').'
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'."\n"; +/* + print '
'; + print '
'; + print '
'; + + print '
'; + + // Info workflow + print ''."\n"; + print ''; + if (! empty($object->fk_user_create)) + { + $userCreate=new User($db); + $userCreate->fetch($object->fk_user_create); + print ''; + print ''; + print ''; + print ''; + } + + if (!$edit) { + print ''; + print ''; + print ''; + print ''; + } else { + print ''; + print ''; + print ''; + print ''; + } + + print ''; + print ''; + print ''; + print ''; + if ($object->statut == 3) { + print ''; + print ''; + print ''; + print ''; + } + if ($object->statut == 4) { + print ''; + print ''; + print ''; + print ''; + } + if ($object->statut == 5) { + print ''; + print ''; + print ''; + print ''; + } + print ''; print '
'.$langs->trans('RequestByCP').''.$userCreate->getNomUrl(-1).'
'.$langs->trans('ReviewedByCP').''.$valideur->getNomUrl(-1).'
'.$langs->trans('ReviewedByCP').''; + print $form->select_dolusers($object->fk_user, "valideur", 1, ($user->admin ? '' : array($user->id))); // By default, hierarchical parent + print '
'.$langs->trans('DateCreateCP').''.dol_print_date($object->date_create,'dayhour').'
'.$langs->trans('DateValidCP').''.dol_print_date($object->date_valid,'dayhour').'
'.$langs->trans('DateCancelCP').''.dol_print_date($object->date_cancel,'dayhour').'
'.$langs->trans('DateRefusCP').''.dol_print_date($object->date_refuse,'dayhour').'
'; + print '
'; + print '
'; */ + print '
'; + + print '
'; + dol_fiche_end(); + + $modulepart = 'holiday'; $permission = $user->rights->holiday->write; diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 38dc854b5f9..7933be96aba 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -78,6 +78,7 @@ ManualUpdate=Manual update HolidaysCancelation=Leave request cancelation EmployeeLastname=Employee lastname EmployeeFirstname=Employee firstname +TypeWasDisabledOrRemoved=Leave type (id %s) was disabled or removed ## Configuration du Module ## LastUpdateCP=Latest automatic update of leaves allocation diff --git a/htdocs/langs/en_US/trips.lang b/htdocs/langs/en_US/trips.lang index 900b424f3e7..9cb992f6af3 100644 --- a/htdocs/langs/en_US/trips.lang +++ b/htdocs/langs/en_US/trips.lang @@ -59,31 +59,23 @@ DATE_REFUS=Deny date DATE_SAVE=Validation date DATE_CANCEL=Cancelation date DATE_PAIEMENT=Payment date - BROUILLONNER=Reopen ValidateAndSubmit=Validate and submit for approval ValidatedWaitingApproval=Validated (waiting for approval) - NOT_AUTHOR=You are not the author of this expense report. Operation cancelled. - ConfirmRefuseTrip=Are you sure you want to deny this expense report? - ValideTrip=Approve expense report ConfirmValideTrip=Are you sure you want to approve this expense report? - PaidTrip=Pay an expense report ConfirmPaidTrip=Are you sure you want to change status of this expense report to "Paid"? - ConfirmCancelTrip=Are you sure you want to cancel this expense report? - BrouillonnerTrip=Move back expense report to status "Draft" ConfirmBrouillonnerTrip=Are you sure you want to move this expense report to status "Draft"? - SaveTrip=Validate expense report ConfirmSaveTrip=Are you sure you want to validate this expense report? - NoTripsToExportCSV=No expense report to export for this period. ExpenseReportPayment=Expense report payment - ExpenseReportsToApprove=Expense reports to approve ExpenseReportsToPay=Expense reports to pay +CloneExpenseReport=Clone expese report +ConfirmCloneExpenseReport=Are you sure you want to clone this expense report ? \ No newline at end of file From 530d3503f5b11fb29aa662b942f87180631493f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Dec 2016 10:32:10 +0100 Subject: [PATCH 25/37] FIX Introduce hidden option MAIL_PREFIX_FOR_EMAIL_ID to solve pb of tracking email. --- htdocs/core/lib/functions.lib.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index aaff894fcf9..e0acccfe0c0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -290,8 +290,15 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) */ function dol_getprefix() { + global $conf; + if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"])) { + if (! empty($conf->gobal->MAIL_PREFIX_FOR_EMAIL_ID)) + { + if ($conf->gobal->MAIL_PREFIX_FOR_EMAIL_ID == 'SERVER_NAME') return $_SERVER["SERVER_NAME"]; + return $conf->gobal->MAIL_PREFIX_FOR_EMAIL_ID; + } return dol_hash($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT); // Use this for a "clear" cookie name //return dol_sanitizeFileName($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT); From 56b3f2c011a11d898fbcbd759325daf18361d53f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Dec 2016 10:36:11 +0100 Subject: [PATCH 26/37] FIX Introduce hidden option MAIL_PREFIX_FOR_EMAIL_ID to solve pb of tracking email. --- htdocs/core/lib/functions.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e0acccfe0c0..bce67604ee7 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -294,10 +294,10 @@ function dol_getprefix() if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"])) { - if (! empty($conf->gobal->MAIL_PREFIX_FOR_EMAIL_ID)) + if (! empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) { - if ($conf->gobal->MAIL_PREFIX_FOR_EMAIL_ID == 'SERVER_NAME') return $_SERVER["SERVER_NAME"]; - return $conf->gobal->MAIL_PREFIX_FOR_EMAIL_ID; + if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID == 'SERVER_NAME') return $_SERVER["SERVER_NAME"]; + return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID; } return dol_hash($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT); // Use this for a "clear" cookie name From af407a094a2b4ff8e03393e2ba1feabb55de6ae2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Dec 2016 11:20:44 +0100 Subject: [PATCH 27/37] FIX Introduce hidden option MAIL_PREFIX_FOR_EMAIL_ID to solve pb of tracking email. --- htdocs/core/class/smtps.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index dd2726d2306..6dd5f8214c2 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -1126,6 +1126,8 @@ class SMTPs $host=preg_replace('@tcp://@i','',$host); // Remove prefix $host=preg_replace('@ssl://@i','',$host); // Remove prefix + $host.=dol_getprefix().'-'.$host; + //NOTE: Message-ID should probably contain the username of the user who sent the msg $_header .= 'Subject: ' . $this->getSubject() . "\r\n"; $_header .= 'Date: ' . date("r") . "\r\n"; From e4dd0208874d20508c9db3acc810680417ee1810 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Dec 2016 11:23:55 +0100 Subject: [PATCH 28/37] Fix bad concat --- htdocs/core/class/smtps.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 6dd5f8214c2..a46672443ac 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -1126,7 +1126,7 @@ class SMTPs $host=preg_replace('@tcp://@i','',$host); // Remove prefix $host=preg_replace('@ssl://@i','',$host); // Remove prefix - $host.=dol_getprefix().'-'.$host; + $host=dol_getprefix().'-'.$host; //NOTE: Message-ID should probably contain the username of the user who sent the msg $_header .= 'Subject: ' . $this->getSubject() . "\r\n"; From d32fd7aa116ee016c6a1bda7979d3f396151013c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Dec 2016 10:25:06 +0100 Subject: [PATCH 29/37] FIX javascript xss injection and a translation --- .../install/mysql/data/llx_c_payment_term.sql | 2 +- htdocs/langs/en_US/bills.lang | 4 +- htdocs/main.inc.php | 4 +- test/phpunit/CoreTest.php | 54 +++++++++++++------ 4 files changed, 42 insertions(+), 22 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_payment_term.sql b/htdocs/install/mysql/data/llx_c_payment_term.sql index 68aae57ff4f..083c4419277 100644 --- a/htdocs/install/mysql/data/llx_c_payment_term.sql +++ b/htdocs/install/mysql/data/llx_c_payment_term.sql @@ -27,7 +27,7 @@ -- de l'install et tous les sigles '--' sont supprimés. -- -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, fdm, nbjour) values (1,'RECEP', 1,1, 'A réception de facture','Réception de facture',0,1); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, fdm, nbjour) values (1,'RECEP', 1,1, 'Due Upon Receipt','Due Upon Receipt',0,1); insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, fdm, nbjour) values (2,'30D', 2,1, '30 jours','Réglement à 30 jours',0,30); insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, fdm, nbjour) values (3,'30DENDMONTH', 3,1, '30 jours fin de mois','Réglement à 30 jours fin de mois',1,30); insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, fdm, nbjour) values (4,'60D', 4,1, '60 jours','Réglement à 60 jours',0,60); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 65a93b573e3..9636b18d09c 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -329,8 +329,8 @@ GeneratedFromRecurringInvoice=Generated from template recurring invoice %s DateIsNotEnough=Date not reached yet InvoiceGeneratedFromTemplate=Invoice %s generated from recurring template invoice %s # PaymentConditions -PaymentConditionShortRECEP=Immediate -PaymentConditionRECEP=Immediate +PaymentConditionShortRECEP=Due Upon Receipt +PaymentConditionRECEP=Due Upon Receipt PaymentConditionShort30D=30 days PaymentCondition30D=30 days PaymentConditionShort30DENDMONTH=30 days of month-end diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 5e83b1e6cf8..5105a8eef32 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -89,7 +89,6 @@ function test_sql_and_script_inject($val, $type) $sql_inj += preg_match('/union.+select/i', $val); $sql_inj += preg_match('/into\s+(outfile|dumpfile)/i', $val); $sql_inj += preg_match('/(\.\.%2f)+/i', $val); - $sql_inj += preg_match('/onerror=/i', $val); } // For XSS Injection done by adding javascript with script // This is all cases a browser consider text is javascript: @@ -98,7 +97,8 @@ function test_sql_and_script_inject($val, $type) $sql_inj += preg_match('/