From e801b5a4313cf3b807dec7165bd4fdc484d420c0 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Wed, 14 Mar 2018 11:38:42 +0100 Subject: [PATCH 01/18] FIX : Delete tasks on project delete will now trigger TASK_DELETE --- htdocs/projet/class/project.class.php | 44 ++++----------------------- 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 84050012a5a..ea304eaabe0 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -629,45 +629,13 @@ class Project extends CommonObject } } - // Delete tasks - if (! $error) - { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_task_time"; - $sql.= " WHERE fk_task IN (SELECT rowid FROM " . MAIN_DB_PREFIX . "projet_task WHERE fk_projet=" . $this->id . ")"; + // Fetch tasks + $this->getLinesArray($user); - $resql = $this->db->query($sql); - if (!$resql) - { - $this->errors[] = $this->db->lasterror(); - $error++; - } - } - - if (! $error) - { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_task_extrafields"; - $sql.= " WHERE fk_object IN (SELECT rowid FROM " . MAIN_DB_PREFIX . "projet_task WHERE fk_projet=" . $this->id . ")"; - - $resql = $this->db->query($sql); - if (!$resql) - { - $this->errors[] = $this->db->lasterror(); - $error++; - } - } - - if (! $error) - { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_task"; - $sql.= " WHERE fk_projet=" . $this->id; - - $resql = $this->db->query($sql); - if (!$resql) - { - $this->errors[] = $this->db->lasterror(); - $error++; - } - } + // Delete tasks + foreach($this->lines as &$task) { + $task->delete($user); + } // Delete project if (! $error) From 9f62ddaf36c89dcfe3514479b444096cb1a964f7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 15 Mar 2018 19:24:34 +0100 Subject: [PATCH 02/18] Fix: missing update of $conf --- htdocs/install/step5.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index df8ec9812c1..ac0c015e0be 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -176,17 +176,20 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action)) $sql = "SELECT u.rowid, u.pass, u.pass_crypted"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $resql=$db->query($sql); - if ($resql) - { - $numrows=$db->num_rows($resql); - if ($numrows == 0) - { - // Define default setup for password encryption - dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_SECURITY_SALT", dol_print_date(dol_now(), 'dayhourlog'), 'chaine', 0, '', 0); // All entities - dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'sha1md5', 'chaine', 0, '', 0); // All entities - } - } + if ($resql) + { + $numrows=$db->num_rows($resql); + if ($numrows == 0) + { + // Define default setup for password encryption + dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_SECURITY_SALT", dol_print_date(dol_now(), 'dayhourlog'), 'chaine', 0, '', 0); // All entities + dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'sha1md5', 'chaine', 0, '', 0); // All entities + + // Update of $conf + $conf->setValues($db); + } + } // Create user used to create the admin user $createuser=new User($db); From 6e585869c77ae5996d607e1e6552c18f17ba717e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 15 Mar 2018 19:33:08 +0100 Subject: [PATCH 03/18] Fix: better method for avoid lost global --- htdocs/install/step5.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index ac0c015e0be..205162a75c3 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -181,13 +181,17 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action)) $numrows=$db->num_rows($resql); if ($numrows == 0) { + $salt = dol_print_date(dol_now(), 'dayhourlog'); + // Define default setup for password encryption dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_SECURITY_SALT", dol_print_date(dol_now(), 'dayhourlog'), 'chaine', 0, '', 0); // All entities + dolibarr_set_const($db, "MAIN_SECURITY_SALT", $salt, 'chaine', 0, '', 0); // All entities dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'sha1md5', 'chaine', 0, '', 0); // All entities - // Update of $conf - $conf->setValues($db); + // Update of $conf->global + $conf->global->DATABASE_PWD_ENCRYPTED = 1; + $conf->global->MAIN_SECURITY_SALT = $salt; + $conf->global->MAIN_SECURITY_HASH_ALGO = 'sha1md5'; } } From 32ce42610a23d03ea9e894a905677864945218a1 Mon Sep 17 00:00:00 2001 From: arnaud Date: Fri, 16 Mar 2018 11:18:00 +0100 Subject: [PATCH 04/18] FIX show status on societe banner --- htdocs/core/lib/functions.lib.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5646de308cb..c5a9896b71c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1318,6 +1318,8 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if (! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { $morehtmlstatus.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased'); + } else { + $morehtmlstatus.=''.$object->getLibStatut(5,0).''; } } elseif ($object->element == 'product') From c0a6ae2195b1077fc68f1a7f52fd1ece09408df8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 16 Mar 2018 18:31:11 +0100 Subject: [PATCH 05/18] Fix: replace with dolibarr_install_syslog --- htdocs/install/step5.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index 205162a75c3..2fa8f07c7ba 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -181,17 +181,12 @@ if ($action == "set" || empty($action) || preg_match('/upgrade/i',$action)) $numrows=$db->num_rows($resql); if ($numrows == 0) { - $salt = dol_print_date(dol_now(), 'dayhourlog'); - // Define default setup for password encryption - dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_SECURITY_SALT", $salt, 'chaine', 0, '', 0); // All entities + dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); // Not All entities ?! + dolibarr_set_const($db, "MAIN_SECURITY_SALT", dol_print_date(dol_now(), 'dayhourlog'), 'chaine', 0, '', 0); // All entities dolibarr_set_const($db, "MAIN_SECURITY_HASH_ALGO", 'sha1md5', 'chaine', 0, '', 0); // All entities - // Update of $conf->global - $conf->global->DATABASE_PWD_ENCRYPTED = 1; - $conf->global->MAIN_SECURITY_SALT = $salt; - $conf->global->MAIN_SECURITY_HASH_ALGO = 'sha1md5'; + dolibarr_install_syslog('step5: DATABASE_PWD_ENCRYPTED = '.$conf->global->DATABASE_PWD_ENCRYPTED.' MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO, LOG_INFO); } } From e55c90b0151af1d7b7d7abe72523bad136c527d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Mar 2018 20:29:36 +0100 Subject: [PATCH 06/18] Fix translation --- htdocs/langs/en_US/accountancy.lang | 3 +-- htdocs/langs/en_US/main.lang | 2 +- htdocs/langs/en_US/margins.lang | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 28a77095084..22724acfc09 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -149,7 +149,6 @@ ACCOUNTING_SERVICE_SOLD_ACCOUNT=Accounting account by default for the sold servi Doctype=Type of document Docdate=Date Docref=Reference -Code_tiers=Thirdparty LabelAccount=Label account LabelOperation=Label operation Sens=Sens @@ -180,7 +179,7 @@ ProductAccountNotDefined=Account for product not defined FeeAccountNotDefined=Account for fee not defined BankAccountNotDefined=Account for bank not defined CustomerInvoicePayment=Payment of invoice customer -ThirdPartyAccount=Thirdparty account +ThirdPartyAccount=Third party account NewAccountingMvt=New transaction NumMvts=Numero of transaction ListeMvts=List of movements diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 6806e648823..75240a2e378 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -897,7 +897,7 @@ Select2MoreCharacters=or more characters Select2MoreCharactersMore=Search syntax:
| OR (a|b)
* Any character (a*b)
^ Start with (^ab)
$ End with (ab$)
Select2LoadingMoreResults=Loading more results... Select2SearchInProgress=Search in progress... -SearchIntoThirdparties=Thirdparties +SearchIntoThirdparties=Third parties SearchIntoContacts=Contacts SearchIntoMembers=Members SearchIntoUsers=Users diff --git a/htdocs/langs/en_US/margins.lang b/htdocs/langs/en_US/margins.lang index 8633d910657..8a8a9f20788 100644 --- a/htdocs/langs/en_US/margins.lang +++ b/htdocs/langs/en_US/margins.lang @@ -41,4 +41,4 @@ rateMustBeNumeric=Rate must be a numeric value markRateShouldBeLesserThan100=Mark rate should be lower than 100 ShowMarginInfos=Show margin infos CheckMargins=Margins detail -MarginPerSaleRepresentativeWarning=The report of margin per user use the link between thirdparties and sale representatives to calculate the margin of each salerepresentaive. Because some thirdparties may not have any ddiated sale representative and some thirdparties may be linked to several, some amounts may not be included into this report (if there is no sale representative) and some may appear on different lines (for each sale representative). +MarginPerSaleRepresentativeWarning=The report of margin per user use the link between third parties and sale representatives to calculate the margin of each salerepresentaive. Because some thirdparties may not have any ddiated sale representative and some thirdparties may be linked to several, some amounts may not be included into this report (if there is no sale representative) and some may appear on different lines (for each sale representative). From 8e50e63243a47dc1b35e5433c8de5185593407d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Mar 2018 20:32:18 +0100 Subject: [PATCH 07/18] Fix translation --- htdocs/accountancy/journal/purchasesjournal.php | 6 +++--- htdocs/accountancy/journal/sellsjournal.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 27f4521de4b..3dadf8ece06 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -627,8 +627,8 @@ if ($action == 'exportcsv') { print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . $langs->trans("Code_tiers") . '"' . $sep; - print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; + print '"' . $langs->trans("Thirdparty") . '"' . $sep; + print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("Thirdparty") . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep; print '"' . $journal . '"' ; @@ -694,7 +694,7 @@ if ($action == 'exportcsv') { print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . $langs->trans("Code_tiers") . '"' . $sep; + print '"' . $langs->trans("Thirdparty") . '"' . $sep; print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . ' NPR"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"'. $sep; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index c10cc2b311f..f56d5c9010e 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -578,8 +578,8 @@ if ($action == 'exportcsv') { print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . $langs->trans("Code_tiers") . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; + print '"' . $langs->trans("Thirdparty") . '"' . $sep; + print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Thirdparty") . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . $journal . '"'; From 8e72ddc89bbd4e668211e41858c61f919c3934f6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 10:18:03 +0100 Subject: [PATCH 08/18] FIX missing email of customer in stripe info payments --- htdocs/public/payment/newpayment.php | 3 ++- htdocs/public/stripe/newpayment.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 74ffcfd120a..179e31d83cf 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -388,7 +388,7 @@ if ($action == 'charge') dol_syslog("POST values: ".join(',', $_POST), LOG_DEBUG, 0, '_stripe'); $stripeToken = GETPOST("stripeToken",'alpha'); - $email = GETPOST("stripeEmail",'alpha'); + $email = GETPOST("email",'alpha'); $vatnumber = GETPOST('vatnumber','alpha'); dol_syslog("stripeToken = ".$stripeToken, LOG_DEBUG, 0, '_stripe'); @@ -1425,6 +1425,7 @@ if (preg_match('/^dopayment/',$action)) print ''."\n"; print ''."\n"; print ''; + print ''; print ' diff --git a/htdocs/public/stripe/newpayment.php b/htdocs/public/stripe/newpayment.php index 36cd64b4f01..812e0b01bd1 100644 --- a/htdocs/public/stripe/newpayment.php +++ b/htdocs/public/stripe/newpayment.php @@ -221,7 +221,7 @@ if ($action == 'charge') dol_syslog("POST values: ".join(',', $_POST), LOG_DEBUG, 0, '_stripe'); $stripeToken = GETPOST("stripeToken",'alpha'); - $email = GETPOST("stripeEmail",'alpha'); + $email = GETPOST("email",'alpha'); $vatnumber = GETPOST('vatnumber','alpha'); dol_syslog("stripeToken = ".$stripeToken, LOG_DEBUG, 0, '_stripe'); @@ -1151,6 +1151,7 @@ if (preg_match('/^dopayment/',$action)) print ''."\n"; print ''."\n"; print ''; + print ''; print '
From 0013e9d83bdb437b4c63e8c7eb3ea2e50d9fba6f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 11:28:55 +0100 Subject: [PATCH 09/18] FIX Make a redirect after the remove_file action to avoid deletion done at next action too. --- htdocs/core/actions_builddoc.inc.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index ff7a89484fa..9d33def496c 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -124,5 +124,13 @@ if ($action == 'remove_file' && $permissioncreate) $ret=dol_delete_file($file,0,0,0,$object); if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors'); + + // Make a redirect to avoid to keep the remove_file into the url that create side effects + $urltoredirect = $_SERVER['REQUEST_URI']; + $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect); + $urltoredirect = preg_replace('/action=remove_file&?/', '', $urltoredirect); + + header('Location: '.$urltoredirect); + exit; } From 890d0b6685b424fb1a8d0a864cda9a3679467c2e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 19 Mar 2018 12:11:59 +0100 Subject: [PATCH 10/18] Fix: replace ldaps:// by ssl:// --- htdocs/core/class/ldap.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 20a9b85cf86..29c8adb0aaa 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -738,6 +738,11 @@ class Ldap */ function serverPing($host, $port=389, $timeout=1) { + // Replace ldaps:// by ssl:// + if (preg_match('/^ldaps/',$host)) { + preg_match('/^ldaps:\/\/([^\/]+)\/?$/', $host, $regs); + $host = 'ssl://'.$regs[1]; + } $op = @fsockopen($host, $port, $errno, $errstr, $timeout); if (!$op) return false; //DC is N/A else { From eb7886ecff7ed8ca0bb09a89ed79d7fc1c7f048c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 12:37:53 +0100 Subject: [PATCH 11/18] Update ldap.class.php --- htdocs/core/class/ldap.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 29c8adb0aaa..3d92d5f9019 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -739,8 +739,7 @@ class Ldap function serverPing($host, $port=389, $timeout=1) { // Replace ldaps:// by ssl:// - if (preg_match('/^ldaps/',$host)) { - preg_match('/^ldaps:\/\/([^\/]+)\/?$/', $host, $regs); + if (preg_match('/^ldaps:\/\/([^\/]+)\/?$/',$host, $regs)) { $host = 'ssl://'.$regs[1]; } $op = @fsockopen($host, $port, $errno, $errstr, $timeout); From 8889e7f4b2111b4fde4a861ce4a2fa4c9858b17c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 13:55:26 +0100 Subject: [PATCH 12/18] FIX translation of holiday types --- htdocs/holiday/card.php | 5 +++-- htdocs/holiday/define_holiday.php | 3 ++- htdocs/holiday/list.php | 5 +++-- htdocs/holiday/view_log.php | 2 +- htdocs/langs/en_US/holiday.lang | 5 ++++- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 59cb522d7d5..6a9b20fd45b 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -858,7 +858,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create $arraytypeleaves=array(); foreach($typeleaves as $key => $val) { - $labeltoshow = $val['label']; + $labeltoshow = ($langs->trans($val['code'])!=$val['code'] ? $langs->trans($val['code']) : $val['label']); $labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':''); $arraytypeleaves[$val['rowid']]=$labeltoshow; } @@ -1076,7 +1076,8 @@ else print ''; print ''; print ''; diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index e5bd8c0e8c0..8f0cb2862a7 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -286,7 +286,8 @@ else { foreach($typeleaves as $key => $val) { - print_liste_field_titre($val['label'], $_SERVER["PHP_SELF"], '', '', '', 'align="center"'); + $labeltype = ($langs->trans($val['code'])!=$val['code']) ? $langs->trans($val['code']) : $langs->trans($val['label']); + print_liste_field_titre($labeltype, $_SERVER["PHP_SELF"], '', '', '', 'align="center"'); } } else diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index cf81d0a98fa..bb2b3c31bf0 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -423,7 +423,7 @@ $typeleaves=$holidaystatic->getTypes(1,-1); $arraytypeleaves=array(); foreach($typeleaves as $key => $val) { - $labeltoshow = $val['label']; + $labeltoshow = ($langs->trans($val['code'])!=$val['code'] ? $langs->trans($val['code']) : $val['label']); //$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':''); $arraytypeleaves[$val['rowid']]=$labeltoshow; } @@ -516,7 +516,8 @@ if (! empty($holiday->holiday)) print ''; print ''; print ''; print ''; print ''; print ''; print ''; diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 0ed06cceb40..316d1887858 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -81,7 +81,10 @@ EmployeeFirstname=Employee first name TypeWasDisabledOrRemoved=Leave type (id %s) was disabled or removed LastHolidays=Latest %s leave requests AllHolidays=All leave requests - +LEAVE_PAID=Paid vacationxx +LEAVE_SICK=Sick leave +LEAVE_OTHER=Other leave +LEAVE_PAID_FR=Paid vacation ## Configuration du Module ## LastUpdateCP=Latest automatic update of leaves allocation MonthOfLastMonthlyUpdate=Month of latest automatic update of leaves allocation From eb03fb75406e2ecdd6246ba5fbab08e3992c9b92 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 15:00:50 +0100 Subject: [PATCH 13/18] Fix trad/compatibility --- htdocs/holiday/card.php | 28 +++++++++++++++------------- htdocs/langs/en_US/holiday.lang | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 6a9b20fd45b..0680799ed35 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -814,21 +814,23 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print '
'."\n"; print ''."\n"; - dol_fiche_head('', '', '', -1); + if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) + { + dol_fiche_head('', '', '', -1); - $out=''; - $typeleaves=$object->getTypes(1,1); - foreach($typeleaves as $key => $val) - { - $nb_type = $object->getCPforUser($user->id, $val['rowid']); - $nb_holiday += $nb_type; - $out .= ' - '.$val['label'].': '.($nb_type?price2num($nb_type):0).'
'; - } - print $langs->trans('SoldeCPUser', round($nb_holiday,5)).'
'; - print $out; - - dol_fiche_end(); + $out=''; + $typeleaves=$object->getTypes(1,1); + foreach($typeleaves as $key => $val) + { + $nb_type = $object->getCPforUser($user->id, $val['rowid']); + $nb_holiday += $nb_type; + $out .= ' - '.$val['label'].': '.($nb_type?price2num($nb_type):0).'
'; + } + print $langs->trans('SoldeCPUser', round($nb_holiday,5)).'
'; + print $out; + dol_fiche_end(); + } dol_fiche_head(); diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 316d1887858..621cc02c758 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -81,7 +81,7 @@ EmployeeFirstname=Employee first name TypeWasDisabledOrRemoved=Leave type (id %s) was disabled or removed LastHolidays=Latest %s leave requests AllHolidays=All leave requests -LEAVE_PAID=Paid vacationxx +LEAVE_PAID=Paid vacation LEAVE_SICK=Sick leave LEAVE_OTHER=Other leave LEAVE_PAID_FR=Paid vacation From e0164884ee285eac2bb6d4c56874075426cc15ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 15:13:36 +0100 Subject: [PATCH 14/18] Better management of hidden option HOLIDAY_HIDE_BALANCE --- htdocs/holiday/card.php | 4 ++++ htdocs/hrm/index.php | 43 ++++++++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 0680799ed35..b84e8599e41 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -831,6 +831,10 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create dol_fiche_end(); } + elseif(! is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) + { + print $langs->trans($conf->global->HOLIDAY_HIDE_BALANCE).'
'; + } dol_fiche_head(); diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index f0e279bb848..2f360dce5c5 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -130,27 +130,34 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele if (! empty($conf->holiday->enabled)) { - $user_id = $user->id; + if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) + { + $user_id = $user->id; - print '
'.$langs->trans("Type").''; $typeleaves=$object->getTypes(1,-1); - print empty($typeleaves[$object->fk_type]['label']) ? $langs->trans("TypeWasDisabledOrRemoved",$object->fk_type) : $typeleaves[$object->fk_type]['label']; + $labeltoshow = (($typeleaves[$object->fk_type]['code'] && $langs->trans($typeleaves[$object->fk_type]['code'])!=$typeleaves[$object->fk_type]['code']) ? $langs->trans($typeleaves[$object->fk_type]['code']) : $typeleaves[$object->fk_type]['label']); + print empty($labeltoshow) ? $langs->trans("TypeWasDisabledOrRemoved",$object->fk_type) : $labeltoshow; print '
'.$userstatic->getNomUrl(-1, 'leave').''.$approbatorstatic->getNomUrl(-1).''; - print empty($typeleaves[$infos_CP['fk_type']]['label']) ? $langs->trans("TypeWasDisabledOrRemoved",$infos_CP['fk_type']) : $typeleaves[$infos_CP['fk_type']]['label']; + $labeltypeleavetoshow = ($langs->trans($typeleaves[$infos_CP['fk_type']]['code'])!=$typeleaves[$infos_CP['fk_type']]['code'] ? $langs->trans($typeleaves[$infos_CP['fk_type']]['code']) : $typeleaves[$infos_CP['fk_type']]['label']); + print empty($typeleaves[$infos_CP['fk_type']]['label']) ? $langs->trans("TypeWasDisabledOrRemoved",$infos_CP['fk_type']) : $labeltypeleavetoshow; print ''; $nbopenedday=num_open_day($infos_CP['date_debut_gmt'], $infos_CP['date_fin_gmt'], 0, 1, $infos_CP['halfday']); diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 69bd6b6a190..d67db73d437 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -117,7 +117,7 @@ foreach($cp->logs as $logs_CP) print ''.$user_update->getNomUrl(-1).''.$logs_CP['type_action'].''; - $label=$alltypeleaves[$logs_CP['fk_type']]['label']; + $label = (($alltypeleaves[$logs_CP['fk_type']]['code'] && $langs->trans($alltypeleaves[$logs_CP['fk_type']]['code'])!=$alltypeleaves[$logs_CP['fk_type']]['code']) ? $langs->trans($alltypeleaves[$logs_CP['fk_type']]['code']) : $alltypeleaves[$logs_CP['fk_type']]['label']); print $label?$label:$logs_CP['fk_type']; print ''.price2num($logs_CP['prev_solde'],5).' '.$langs->trans('days').'
'; - print ''; - print ""; - print ''; + print ''; + print '
'.$langs->trans("Holidays").'
'; + print ''; + print ''; + print ""; + print ''; - print ''; - print '
'.$langs->trans("Holidays").'
'; - $out=''; - $typeleaves=$holiday->getTypes(1,1); - foreach($typeleaves as $key => $val) - { - $nb_type = $holiday->getCPforUser($user->id, $val['rowid']); - $nb_holiday += $nb_type; - $out .= ' - '.$val['label'].': '.($nb_type?price2num($nb_type):0).'
'; - } - print $langs->trans('SoldeCPUser', round($nb_holiday,5)).'
'; - print $out; + $out=''; + $typeleaves=$holiday->getTypes(1,1); + foreach($typeleaves as $key => $val) + { + $nb_type = $holiday->getCPforUser($user->id, $val['rowid']); + $nb_holiday += $nb_type; + $out .= ' - '.$val['label'].': '.($nb_type?price2num($nb_type):0).'
'; + } + print $langs->trans('SoldeCPUser', round($nb_holiday,5)).'
'; + print $out; - print '

'; + print '

'; + } + elseif (! is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) + { + print $langs->trans($conf->global->HOLIDAY_HIDE_BALANCE).'
'; + } } From 91cc3d1b73ed567bc5f429b0312e7f6fcd6946d3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 16:11:42 +0100 Subject: [PATCH 15/18] FIX navigation and filters on holiday list --- htdocs/core/class/html.form.class.php | 3 +- htdocs/holiday/card.php | 24 ++--- htdocs/holiday/class/holiday.class.php | 9 +- htdocs/holiday/list.php | 123 ++++++++++++++----------- htdocs/theme/eldy/style.css.php | 4 +- htdocs/theme/md/style.css.php | 4 +- 6 files changed, 94 insertions(+), 73 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3b773412861..2424523ec0a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1451,7 +1451,7 @@ class Form * @param int $force_entity 0 or Id of environment to force * @param int $maxlength Maximum length of string into list (0=no limit) * @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status - * @param string $morefilter Add more filters into sql request + * @param string $morefilter Add more filters into sql request (Example: 'employee = 1') * @param integer $show_every 0=default list, 1=add also a value "Everybody" at beginning of list * @param string $enableonlytext If option $enableonlytext is set, we use this text to explain into label why record is disabled. Not used if enableonly is empty. * @param string $morecss More css @@ -1524,7 +1524,6 @@ class Form $sql.= " ORDER BY u.lastname ASC"; } - dol_syslog(get_class($this)."::select_dolusers", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index b84e8599e41..14ee964a935 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -852,7 +852,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print $form->select_dolusers($fuserid, 'useridbis', 0, '', 1, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print ''; } - else print $form->select_dolusers(GETPOST('fuserid','int')?GETPOST('fuserid','int'):$user->id,'fuserid',0,'',0); + else print $form->select_dolusers(GETPOST('fuserid','int')?GETPOST('fuserid','int'):$user->id, 'fuserid', 0, '', 0, '', '', 0, 0, 0, 'AND employee = 1'); print ''; print ''; @@ -868,7 +868,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create $labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':''); $arraytypeleaves[$val['rowid']]=$labeltoshow; } - print $form->selectarray('type', $arraytypeleaves, (GETPOST('type')?GETPOST('type'):''), 1); + print $form->selectarray('type', $arraytypeleaves, (GETPOST('type','alpha')?GETPOST('type','alpha'):''), 1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print ''; print ''; @@ -884,11 +884,11 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create if (! GETPOST('date_debut_')) { $form->select_date(-1, 'date_debut_', 0, 0, 0, '', 1, 1); } else { - $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year')); + $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_debut_month','int'), GETPOST('date_debut_day','int'), GETPOST('date_debut_year','int')); $form->select_date($tmpdate, 'date_debut_', 0, 0, 0, '', 1, 1); } print '     '; - print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday')?GETPOST('starthalfday'):'morning')); + print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday','alpha')?GETPOST('starthalfday','alpha'):'morning')); print ''; print ''; @@ -903,11 +903,11 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create if (! GETPOST('date_fin_')) { $form->select_date(-1,'date_fin_', 0, 0, 0, '', 1, 1); } else { - $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year')); + $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_fin_month','int'), GETPOST('date_fin_day','int'), GETPOST('date_fin_year','int')); $form->select_date($tmpdate,'date_fin_', 0, 0, 0, '', 1, 1); } print '     '; - print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday')?GETPOST('endhalfday'):'afternoon')); + print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday','alpha')?GETPOST('endhalfday','alpha'):'afternoon')); print ''; print ''; @@ -915,7 +915,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print ''; print ''.$langs->trans("ReviewedByCP").''; print ''; - print $form->select_dolusers((GETPOST('valideur')>0?GETPOST('valideur'):$user->fk_user), "valideur", 1, ($user->admin ? '' : array($user->id)), 0, '', 0, 0, 0, 0, '', 0, '', '', 1); // By default, hierarchical parent + print $form->select_dolusers((GETPOST('valideur','int')>0?GETPOST('valideur','int'):$user->fk_user), "valideur", 1, ($user->admin ? '' : array($user->id)), 0, '', 0, 0, 0, 0, '', 0, '', '', 1); // By default, hierarchical parent print ''; print ''; @@ -923,7 +923,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print ''; print ''.$langs->trans("DescCP").''; print ''; - $doleditor = new DolEditor('description', GETPOST('description'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('description', GETPOST('description','none'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print ''; @@ -1093,7 +1093,7 @@ else if(!$edit) { print ''; - print ''.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; + print ''.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; print ''.dol_print_date($object->date_debut,'day'); print '     '; print ''.$langs->trans($listhalfday[$starthalfday]).''; @@ -1103,7 +1103,7 @@ else else { print ''; - print ''.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; + print ''.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; print ''; $form->select_date($object->date_debut,'date_debut_'); print '     '; @@ -1115,7 +1115,7 @@ else if (!$edit) { print ''; - print ''.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'; + print ''.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'; print ''.dol_print_date($object->date_fin,'day'); print '     '; print ''.$langs->trans($listhalfday[$endhalfday]).''; @@ -1125,7 +1125,7 @@ else else { print ''; - print ''.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'; + print ''.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'; print ''; $form->select_date($object->date_fin,'date_fin_'); print '     '; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 26551847772..6e230fac7b2 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -957,10 +957,11 @@ class Holiday extends CommonObject /** * Affiche un select HTML des statuts de congés payés * - * @param int $selected int du statut séléctionné par défaut - * @return string affiche le select des statuts + * @param int $selected Id of preselected status + * @param string $select_statut Name of HTML select field + * @return string Show select of status */ - function selectStatutCP($selected='') { + function selectStatutCP($selected='', $htmlname='select_statut') { global $langs; @@ -969,7 +970,7 @@ class Holiday extends CommonObject $nb = count($name)+1; // Select HTML - $statut = ''."\n"; $statut.= ''."\n"; // Boucle des statuts diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index bb2b3c31bf0..e0894ecb355 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -73,18 +73,21 @@ if (! $sortorder) $sortorder="DESC"; $id = GETPOST('id','int'); -$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_ref = GETPOST('search_ref'); -$month_create = GETPOST('month_create'); -$year_create = GETPOST('year_create'); -$month_start = GETPOST('month_start'); -$year_start = GETPOST('year_start'); -$month_end = GETPOST('month_end'); -$year_end = GETPOST('year_end'); -$search_employee = GETPOST('search_employee'); -$search_valideur = GETPOST('search_valideur'); -$search_statut = GETPOST('select_statut'); -$search_type = GETPOST('search_type','int'); +$sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$search_ref = GETPOST('search_ref','alpha'); +$search_day_create = GETPOST('search_day_create','int'); +$search_month_create = GETPOST('search_month_create','int'); +$search_year_create = GETPOST('search_year_create','int'); +$search_day_start = GETPOST('search_day_start','int'); +$search_month_start = GETPOST('search_month_start','int'); +$search_year_start = GETPOST('search_year_start','int'); +$search_day_end = GETPOST('search_day_end','int'); +$search_month_end = GETPOST('search_month_end','int'); +$search_year_end = GETPOST('search_year_end','int'); +$search_employee = GETPOST('search_employee','int'); +$search_valideur = GETPOST('search_valideur','int'); +$search_statut = GETPOST('search_statut','int'); +$search_type = GETPOST('search_type','int'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -115,12 +118,12 @@ if (empty($reshook)) if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_ref=""; - $month_create=""; - $year_create=""; - $month_start=""; - $year_start=""; - $month_end=""; - $year_end=""; + $search_month_create=""; + $search_year_create=""; + $search_month_start=""; + $search_year_start=""; + $search_month_end=""; + $search_year_end=""; $search_employee=""; $search_valideur=""; $search_statut=""; @@ -178,47 +181,47 @@ if(!empty($search_ref)) } // Start date -if($year_start > 0) { - if($month_start > 0) { - $filter .= " AND (cp.date_debut BETWEEN '".$db->idate(dol_get_first_day($year_start,$month_start,1))."' AND '".$db->idate(dol_get_last_day($year_start,$month_start,1))."')"; - //$filter.= " AND date_format(cp.date_debut, '%Y-%m') = '$year_start-$month_start'"; +if($search_year_start > 0) { + if($search_month_start > 0) { + $filter .= " AND (cp.date_debut BETWEEN '".$db->idate(dol_get_first_day($search_year_start,$search_month_start,1))."' AND '".$db->idate(dol_get_last_day($search_year_start,$search_month_start,1))."')"; + //$filter.= " AND date_format(cp.date_debut, '%Y-%m') = '$search_year_start-$search_month_start'"; } else { - $filter .= " AND (cp.date_debut BETWEEN '".$db->idate(dol_get_first_day($year_start,1,1))."' AND '".$db->idate(dol_get_last_day($year_start,12,1))."')"; - //$filter.= " AND date_format(cp.date_debut, '%Y') = '$year_start'"; + $filter .= " AND (cp.date_debut BETWEEN '".$db->idate(dol_get_first_day($search_year_start,1,1))."' AND '".$db->idate(dol_get_last_day($search_year_start,12,1))."')"; + //$filter.= " AND date_format(cp.date_debut, '%Y') = '$search_year_start'"; } } else { - if($month_start > 0) { - $filter.= " AND date_format(cp.date_debut, '%m') = '".$db->escape($month_start)."'"; + if($search_month_start > 0) { + $filter.= " AND date_format(cp.date_debut, '%m') = '".$db->escape($search_month_start)."'"; } } // End date -if($year_end > 0) { - if($month_end > 0) { - $filter .= " AND (cp.date_fin BETWEEN '".$db->idate(dol_get_first_day($year_end,$month_end,1))."' AND '".$db->idate(dol_get_last_day($year_end,$month_end,1))."')"; - //$filter.= " AND date_format(cp.date_fin, '%Y-%m') = '$year_end-$month_end'"; +if($search_year_end > 0) { + if($search_month_end > 0) { + $filter .= " AND (cp.date_fin BETWEEN '".$db->idate(dol_get_first_day($search_year_end,$search_month_end,1))."' AND '".$db->idate(dol_get_last_day($search_year_end,$search_month_end,1))."')"; + //$filter.= " AND date_format(cp.date_fin, '%Y-%m') = '$search_year_end-$search_month_end'"; } else { - $filter .= " AND (cp.date_fin BETWEEN '".$db->idate(dol_get_first_day($year_end,1,1))."' AND '".$db->idate(dol_get_last_day($year_end,12,1))."')"; - //$filter.= " AND date_format(cp.date_fin, '%Y') = '$year_end'"; + $filter .= " AND (cp.date_fin BETWEEN '".$db->idate(dol_get_first_day($search_year_end,1,1))."' AND '".$db->idate(dol_get_last_day($search_year_end,12,1))."')"; + //$filter.= " AND date_format(cp.date_fin, '%Y') = '$search_year_end'"; } } else { - if($month_end > 0) { - $filter.= " AND date_format(cp.date_fin, '%m') = '".$db->escape($month_end)."'"; + if($search_month_end > 0) { + $filter.= " AND date_format(cp.date_fin, '%m') = '".$db->escape($search_month_end)."'"; } } // Create date -if($year_create > 0) { - if($month_create > 0) { - $filter .= " AND (cp.date_create BETWEEN '".$db->idate(dol_get_first_day($year_create,$month_create,1))."' AND '".$db->idate(dol_get_last_day($year_create,$month_create,1))."')"; - //$filter.= " AND date_format(cp.date_create, '%Y-%m') = '$year_create-$month_create'"; +if($search_year_create > 0) { + if($search_month_create > 0) { + $filter .= " AND (cp.date_create BETWEEN '".$db->idate(dol_get_first_day($search_year_create,$search_month_create,1))."' AND '".$db->idate(dol_get_last_day($search_year_create,$search_month_create,1))."')"; + //$filter.= " AND date_format(cp.date_create, '%Y-%m') = '$search_year_create-$search_month_create'"; } else { - $filter .= " AND (cp.date_create BETWEEN '".$db->idate(dol_get_first_day($year_create,1,1))."' AND '".$db->idate(dol_get_last_day($year_create,12,1))."')"; - //$filter.= " AND date_format(cp.date_create, '%Y') = '$year_create'"; + $filter .= " AND (cp.date_create BETWEEN '".$db->idate(dol_get_first_day($search_year_create,1,1))."' AND '".$db->idate(dol_get_last_day($search_year_create,12,1))."')"; + //$filter.= " AND date_format(cp.date_create, '%Y') = '$search_year_create'"; } } else { - if($month_create > 0) { - $filter.= " AND date_format(cp.date_create, '%m') = '".$db->escape($month_create)."'"; + if($search_month_create > 0) { + $filter.= " AND date_format(cp.date_create, '%m') = '".$db->escape($search_month_create)."'"; } } @@ -289,9 +292,23 @@ $num = count($holiday->holiday); $arrayofselected=is_array($toselect)?$toselect:array(); $param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; -if ($optioncss != '') $param.='&optioncss='.$optioncss; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($search_ref) $param.='&search_ref='.urlencode($search_ref); +if ($search_day_create) $param.='&search_day_create='.urlencode($search_day_create); +if ($search_month_create) $param.='&search_month_create='.urlencode($search_month_create); +if ($search_year_create) $param.='&search_year_create='.urlencode($search_year_create); +if ($search_search_day_start) $param.='&search_day_start='.urlencode($search_day_start); +if ($search_month_start) $param.='&search_month_start='.urlencode($search_month_start); +if ($search_year_start) $param.='&search_year_start='.urlencode($search_year_start); +if ($day_end) $param.='&day_end='.urlencode($day_end); +if ($search_month_end) $param.='&search_month_end='.urlencode($search_month_end); +if ($search_year_end) $param.='&search_year_end='.urlencode($search_year_end); +if ($search_employee > 0) $param.='&search_employee='.urlencode($search_employee); +if ($search_valideur > 0) $param.='&search_valideur='.urlencode($search_valideur); +if ($search_type > 0) $param.='&search_type='.urlencode($search_type); +if ($search_statut > 0) $param.='&search_statut='.urlencode($search_statut); // List of mass actions available $arrayofmassactions = array( @@ -380,8 +397,8 @@ print ''; // Create date print ''; -print ''; -$formother->select_year($year_create,'year_create',1, $min_year, 0); +print ''; +$formother->select_year($search_year_create,'search_year_create',1, $min_year, 0); print ''; // User @@ -435,19 +452,19 @@ print ' '; // Start date print ''; -print ''; -$formother->select_year($year_start,'year_start',1, $min_year, $max_year); +print ''; +$formother->select_year($search_year_start,'search_year_start',1, $min_year, $max_year); print ''; // End date print ''; -print ''; -$formother->select_year($year_end,'year_end',1, $min_year, $max_year); +print ''; +$formother->select_year($search_year_end,'search_year_end',1, $min_year, $max_year); print ''; // Status print ''; -$holiday->selectStatutCP($search_statut); +$holiday->selectStatutCP($search_statut, 'search_statut'); print ''; // Actions @@ -468,7 +485,7 @@ print_liste_field_titre("Duration",$_SERVER["PHP_SELF"],'','',$pram,'align="righ print_liste_field_titre("DateDebCP",$_SERVER["PHP_SELF"],"cp.date_debut","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre("DateFinCP",$_SERVER["PHP_SELF"],"cp.date_fin","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"cp.statut","",$param,'align="right"',$sortfield,$sortorder); -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'',$param,'align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; print "\n"; $listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon")); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 8d0936d7d80..6a3daaf6cfb 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -278,7 +278,9 @@ input.select2-input { .liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth], .liste_titre input[name=search_smonth], .liste_titre input[name=search_month], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month], .liste_titre select[name=month], .liste_titre input[name=month_lim], .liste_titre input[name=month_start], .liste_titre input[name=month_end], .liste_titre input[name=month_create], -.liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when] { +.liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when], +.liste_titre input[name=search_month_create], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end] +{ margin-right: 4px; } input[type=submit] { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index b27cf3e5034..c36edde7ddc 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -291,7 +291,9 @@ textarea.cke_source:focus .liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth], .liste_titre input[name=search_smonth], .liste_titre input[name=search_month], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month], .liste_titre input[name=month_lim], .liste_titre input[name=month_start], .liste_titre input[name=month_end], .liste_titre input[name=month_create], -.liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when] { +.liste_titre input[name=search_day_date_when], .liste_titre input[name=search_month_date_when], .liste_titre input[name=search_year_date_when], +.liste_titre input[name=search_month_create], .liste_titre input[name=search_month_start], .liste_titre input[name=search_month_end] +{ margin-right: 4px; } input, input.flat, textarea, textarea.flat, form.flat select, select, select.flat, .dataTables_length label select { From 73eba9175640a3588932f9a96518beed845a29c4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 17:06:59 +0100 Subject: [PATCH 16/18] Fix translation of email message --- htdocs/langs/en_US/trips.lang | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/langs/en_US/trips.lang b/htdocs/langs/en_US/trips.lang index 2b254bf91e7..0f9fcac1d02 100644 --- a/htdocs/langs/en_US/trips.lang +++ b/htdocs/langs/en_US/trips.lang @@ -21,17 +21,17 @@ ListToApprove=Waiting for approval ExpensesArea=Expense reports area ClassifyRefunded=Classify 'Refunded' ExpenseReportWaitingForApproval=A new expense report has been submitted for approval -ExpenseReportWaitingForApprovalMessage=A new expense report has been submitted and is waiting for approval.\n - User: %s\n - Period: %s\nClick here to validate: %s +ExpenseReportWaitingForApprovalMessage=A new expense report has been submitted and is waiting for approval.
- User: %s
- Period: %s
Click here to validate: %s ExpenseReportWaitingForReApproval=An expense report has been submitted for re-approval -ExpenseReportWaitingForReApprovalMessage=An expense report has been submitted and is waiting for re-approval.\nThe %s, you refused to approve the expense report for this reason: %s.\nA new version has been proposed and waiting for your approval.\n - User: %s\n - Period: %s\nClick here to validate: %s +ExpenseReportWaitingForReApprovalMessage=An expense report has been submitted and is waiting for re-approval.
The %s, you refused to approve the expense report for this reason: %s.
A new version has been proposed and waiting for your approval.
- User: %s
- Period: %s
Click here to validate: %s ExpenseReportApproved=An expense report was approved -ExpenseReportApprovedMessage=The expense report %s was approved.\n - User: %s\n - Approved by: %s\nClick here to show the expense report: %s +ExpenseReportApprovedMessage=The expense report %s was approved.
- User: %s
- Approved by: %s
Click here to show the expense report: %s ExpenseReportRefused=An expense report was refused -ExpenseReportRefusedMessage=The expense report %s was refused.\n - User: %s\n - Refused by: %s\n - Motive for refusal: %s\nClick here to show the expense report: %s +ExpenseReportRefusedMessage=The expense report %s was refused.
- User: %s
- Refused by: %s
- Motive for refusal: %s
Click here to show the expense report: %s ExpenseReportCanceled=An expense report was canceled -ExpenseReportCanceledMessage=The expense report %s was canceled.\n - User: %s\n - Canceled by: %s\n - Motive for cancellation: %s\nClick here to show the expense report: %s +ExpenseReportCanceledMessage=The expense report %s was canceled.
- User: %s
- Canceled by: %s
- Motive for cancellation: %s
Click here to show the expense report: %s ExpenseReportPaid=An expense report was paid -ExpenseReportPaidMessage=The expense report %s was paid.\n - User: %s\n - Paid by: %s\nClick here to show the expense report: %s +ExpenseReportPaidMessage=The expense report %s was paid.
- User: %s
- Paid by: %s
Click here to show the expense report: %s TripId=Id expense report AnyOtherInThisListCanValidate=Person to inform for validation. TripSociete=Information company From ee3dcb724fe98c683812b0992b1b2df101f2ffdf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 17:20:44 +0100 Subject: [PATCH 17/18] FIX email use the validate user instead of approver in holiday approval email. --- htdocs/expensereport/card.php | 2 +- .../expensereport/class/expensereport.class.php | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 34b78e4eb80..01f7ee0c838 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -591,7 +591,7 @@ if (empty($reshook)) // FROM $expediteur = new User($db); - $expediteur->fetch($object->fk_user_valid); + $expediteur->fetch($object->fk_user_approve > 0 ? $object->fk_user_approve : $object->fk_user_validator); $emailFrom = $expediteur->email; if ($emailFrom && $emailTo) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 6bbd45eef14..9f51b04a1f1 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -44,7 +44,6 @@ class ExpenseReport extends CommonObject public $date_fin; - var $fk_user_validator; var $status; var $fk_statut; // -- 0=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied var $fk_c_paiement; @@ -78,14 +77,16 @@ class ExpenseReport extends CommonObject var $detail_cancel; var $fk_user_cancel; + var $fk_user_validator; // User that is defined to approve + // Validation - var $date_valid; + var $date_valid; // User making validation var $fk_user_valid; var $user_valid_infos; // Approve var $date_approve; - var $fk_user_approve; + var $fk_user_approve; // User that has approved // Paiement var $user_paid_infos; @@ -179,6 +180,7 @@ class ExpenseReport extends CommonObject $sql.= ",date_create"; $sql.= ",fk_user_author"; $sql.= ",fk_user_validator"; + $sql.= ",fk_user_approve"; $sql.= ",fk_user_modif"; $sql.= ",fk_statut"; $sql.= ",fk_c_paiement"; @@ -196,6 +198,7 @@ class ExpenseReport extends CommonObject $sql.= ", '".$this->db->idate($now)."'"; $sql.= ", ".$fuserid; $sql.= ", ".($this->fk_user_validator > 0 ? $this->fk_user_validator:"null"); + $sql.= ", ".($this->fk_user_approve > 0 ? $this->fk_user_approve:"null"); $sql.= ", ".($this->fk_user_modif > 0 ? $this->fk_user_modif:"null"); $sql.= ", ".($this->fk_statut > 1 ? $this->fk_statut:0); $sql.= ", ".($this->modepaymentid?$this->modepaymentid:"null"); @@ -391,6 +394,7 @@ class ExpenseReport extends CommonObject } $sql.= " , fk_user_validator = ".($this->fk_user_validator > 0 ? $this->fk_user_validator:"null"); $sql.= " , fk_user_valid = ".($this->fk_user_valid > 0 ? $this->fk_user_valid:"null"); + $sql.= " , fk_user_approve = ".($this->fk_user_approve > 0 ? $this->fk_user_approve:"null"); $sql.= " , fk_user_modif = ".$user->id; $sql.= " , fk_statut = ".($this->fk_statut >= 0 ? $this->fk_statut:'0'); $sql.= " , fk_c_paiement = ".($this->fk_c_paiement > 0 ? $this->fk_c_paiement:"null"); @@ -500,7 +504,8 @@ class ExpenseReport extends CommonObject $this->user_author_infos = dolGetFirstLastname($user_author->firstname, $user_author->lastname); $user_approver = new User($this->db); - if ($this->fk_user_validator > 0) $user_approver->fetch($this->fk_user_validator); + if ($this->fk_user_approve > 0) $user_approver->fetch($this->fk_user_approve); + elseif ($this->fk_user_validator > 0) $user_approver->fetch($this->fk_user_validator); // For backward compatibility $this->user_validator_infos = dolGetFirstLastname($user_approver->firstname, $user_approver->lastname); $this->fk_statut = $obj->status; @@ -749,9 +754,9 @@ class ExpenseReport extends CommonObject $this->fk_statut = 5; $this->fk_user_author = $user->id; + $this->fk_user_validator = $user->id; $this->fk_user_valid = $user->id; $this->fk_user_approve = $user->id; - $this->fk_user_validator = $user->id; $this->note_private='Private note'; $this->note_public='SPECIMEN'; From 14e80948b808cdc47e248ccf73e634c44f34991c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 17:53:33 +0100 Subject: [PATCH 18/18] FIX approval date was not visible if leave was canceled after --- htdocs/holiday/card.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 14ee964a935..799b0907a92 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1190,11 +1190,14 @@ else // Validator if (!$edit) { print ''; - print ''.$langs->trans('ReviewedByCP').''; + print ''; + if ($object->statut == 3 || $object->statut == 4) print $langs->trans('ApprovedBy'); + else print $langs->trans('ReviewedByCP'); + print ''; print ''.$valideur->getNomUrl(-1).''; print ''; } else { - print ''; + print ''; print ''.$langs->trans('ReviewedByCP').''; print ''; print $form->select_dolusers($object->fk_validator, "valideur", 1, ($user->admin ? '' : array($user->id))); // By default, hierarchical parent @@ -1206,10 +1209,10 @@ else print ''.$langs->trans('DateCreateCP').''; print ''.dol_print_date($object->date_create,'dayhour').''; print ''; - if ($object->statut == 3) { + if ($object->statut == 3 || $object->statut == 4) { print ''; print ''.$langs->trans('DateValidCP').''; - print ''.dol_print_date($object->date_valid,'dayhour').''; + print ''.dol_print_date($object->date_valid,'dayhour').''; // warning: date_valid is approval date on holiday module print ''; } if ($object->statut == 4) {