From 3f2aa6a4fb993b970f9aba87827d68d9fdef9e7b Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 8 Mar 2018 06:52:31 +0100 Subject: [PATCH 01/50] New : On invoice card, show accounting account linked --- htdocs/compta/facture/class/facture.class.php | 19 +++++++++++++------ htdocs/core/tpl/objectline_view.tpl.php | 9 +++++++++ htdocs/langs/en_US/compta.lang | 1 + 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7c49ff909d6..1697216cc09 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -13,8 +13,9 @@ * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2013 Cedric Gross - * Copyright (C) 2013 Florian Henry - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2018 Alexandre Spangaro * * 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 @@ -43,6 +44,9 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php'; require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; + /** * Class to manage invoices */ @@ -1457,6 +1461,9 @@ class Facture extends CommonInvoice $line->fk_prev_id = $objp->fk_prev_id; $line->fk_unit = $objp->fk_unit; + // Accountancy + $line->fk_accounting_account = $objp->fk_code_ventilation; + // Multicurrency $line->fk_multicurrency = $objp->fk_multicurrency; $line->multicurrency_code = $objp->multicurrency_code; @@ -1584,10 +1591,10 @@ class Facture extends CommonInvoice $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").","; $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").","; $sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").","; - $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); - $sql.= ", situation_cycle_ref=".$this->situation_cycle_ref; - $sql.= ", situation_counter=".$this->situation_counter; - $sql.= ", situation_final=".$this->situation_final; + $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").","; + $sql.= " situation_cycle_ref=".$this->situation_cycle_ref.","; + $sql.= " situation_counter=".$this->situation_counter.","; + $sql.= " situation_final=".$this->situation_final; $sql.= " WHERE rowid=".$this->id; diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 8d5b13ece7c..1d9e81fe1ee 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -285,6 +285,15 @@ if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0; +accounting->enabled)) + { + $accountingaccount=new AccountingAccount($this->db); + $accountingaccount->fetch($line->fk_accounting_account); + echo '' . $langs->trans('AccountingAffectation') . ': ' . $accountingaccount->getNomUrl(0,1,1) . ''; + } +?> + Date: Wed, 14 Mar 2018 11:38:42 +0100 Subject: [PATCH 02/50] 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 03/50] 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 04/50] 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 05/50] 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 06/50] 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 93b087dbe0d213d8d612542391b8fc07748817ec Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 18 Mar 2018 06:09:50 +0100 Subject: [PATCH 07/50] NEW Add a tab to specify accountant/auditor of the company --- htdocs/admin/accountant.php | 260 ++++++++++++++++++++++++++++++++++ htdocs/admin/company.php | 6 +- htdocs/core/lib/admin.lib.php | 27 ++++ htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/main.lang | 1 + 5 files changed, 293 insertions(+), 2 deletions(-) create mode 100644 htdocs/admin/accountant.php diff --git a/htdocs/admin/accountant.php b/htdocs/admin/accountant.php new file mode 100644 index 00000000000..155534c5f3d --- /dev/null +++ b/htdocs/admin/accountant.php @@ -0,0 +1,260 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/accountant.php + * \ingroup accountant + * \brief Setup page to configure accountant / auditor + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; + +$action=GETPOST('action','aZ09'); + +$langs->load("admin"); +$langs->load("companies"); + +if (! $user->admin) accessforbidden(); + +$error=0; + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$contextpage=array('adminaccoutant','globaladmin'); +$hookmanager->initHooks($contextpage); + +/* + * Actions + */ + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) +|| ($action == 'updateedit') ) +{ + $tmparray=getCountry(GETPOST('country_id','int'),'all',$db,$langs,0); + if (! empty($tmparray['id'])) + { + $mysoc->country_id =$tmparray['id']; + $mysoc->country_code =$tmparray['code']; + $mysoc->country_label=$tmparray['label']; + + $s=$mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label; + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_COUNTRY", $s,'chaine',0,'',$conf->entity); + + activateModulesRequiredByCountry($mysoc->country_code); + } + + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_TOWN", GETPOST("town",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ZIP", GETPOST("zipcode",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_STATE", GETPOST("state_id",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_REGION", GETPOST("region_code",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_PHONE", GETPOST("tel",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_FAX", GETPOST("fax",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_MAIL", GETPOST("mail",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_WEB", GETPOST("web",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NOTE", GETPOST("note",'none'),'chaine',0,'',$conf->entity); + + if ($action != 'updateedit' && ! $error) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } +} + +/* + * View + */ + +$help_url=''; +llxHeader('',$langs->trans("CompanyFoundation"),$help_url); + +print load_fiche_titre($langs->trans("CompanyFoundation"),'','title_setup'); + +$head = company_admin_prepare_head(); + +dol_fiche_head($head, 'accountant', $langs->trans("Company"), -1, 'company'); + +$form=new Form($db); +$formother=new FormOther($db); +$formcompany=new FormCompany($db); + +$countrynotdefined=''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; + +print $langs->trans("AccountantDesc")."
\n"; +print "
\n"; + +if ($action == 'edit' || $action == 'updateedit') +{ + /** + * Edit parameters + */ + print "\n".''."\n"; + + print '
'; + print ''; + print ''; + + print ''; + print ''."\n"; + + // Name + print ''."\n"; + + // Address + print ''."\n"; + + print ''."\n"; + + print ''."\n"; + + // Country + print ''."\n"; + + print ''."\n"; + + print ''; + print ''."\n"; + + print ''; + print ''."\n"; + + print ''; + print ''."\n"; + + // Web + print ''; + print ''."\n"; + + // Note + print ''; + print ''; + + print '
'.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
'; + print '
'; + print '
'; + print '
'; + print '
'; + //if (empty($country_selected)) $country_selected=substr($langs->defaultlang,-2); // By default, country of localization + print $form->select_country($mysoc->country_id, 'country_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + print '
'; + $formcompany->select_departement($conf->global->MAIN_INFO_ACCOUNTANT_STATE, $mysoc->country_code, 'state_id'); + print '
'; + print '
'; + print '
'; + print '
'; + print '
'; + print '
'; + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + print '
'; + + print '
'; +} +else +{ + /* + * Show parameters + */ + + // Actions buttons + //print '
'; + //print ''.$langs->trans("Modify").''; + //print '

'; + + print '
'; + print ''; + print ''; + + + print ''; + + + print ''; + + + print ''; + + + print ''; + + + print ''; + + + if (! empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT)) print ''; + + print ''; + + print ''; + + print ''; + + // Web + + print ''; + + print ''; + + print '
'.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
'.$langs->trans("CompanyName").''; + print $conf->global->MAIN_INFO_ACCOUNTANT_NAME; + print '
'.$langs->trans("CompanyAddress").'' . nl2br(empty($conf->global->MAIN_INFO_ACCOUNTANT_ADDRESS)?'':$conf->global->MAIN_INFO_ACCOUNTANT_ADDRESS) . '
'.$langs->trans("CompanyZip").'' . (empty($conf->global->MAIN_INFO_ACCOUNTANT_ZIP)?'':$conf->global->MAIN_INFO_ACCOUNTANT_ZIP) . '
'.$langs->trans("CompanyTown").'' . (empty($conf->global->MAIN_INFO_ACCOUNTANT_TOWN)?'':$conf->global->MAIN_INFO_ACCOUNTANT_TOWN) . '
'.$langs->trans("CompanyCountry").''; + if ($mysoc->country_code) + { + $img=picto_from_langcode($mysoc->country_code); + print $img?$img.' ':''; + print getCountry($mysoc->country_code,1); + } + else print img_warning().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; + print '
'.$langs->trans("Region-State").''; + else print '
'.$langs->trans("State").''; + if (! empty($conf->global->MAIN_INFO_ACCOUNTANT_STATE)) print getState($conf->global->MAIN_INFO_ACCOUNTANT_STATE,$conf->global->MAIN_SHOW_STATE_CODE,0,$conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT); + else print ' '; + print '
'.$langs->trans("Phone").'' . dol_print_phone($conf->global->MAIN_INFO_ACCOUNTANT_PHONE,$mysoc->country_code) . '
'.$langs->trans("Fax").'' . dol_print_phone($conf->global->MAIN_INFO_ACCOUNTANT_FAX,$mysoc->country_code) . '
'.$langs->trans("Mail").'' . dol_print_email($conf->global->MAIN_INFO_ACCOUNTANT_MAIL,0,0,0,80) . '
'.$langs->trans("Web").'' . dol_print_url($conf->global->MAIN_INFO_ACCOUNTANT_WEB,'_blank',80) . '
'.$langs->trans("Note").'' . (! empty($conf->global->MAIN_INFO_ACCOUNTANT_NOTE) ? nl2br($conf->global->MAIN_INFO_ACCOUNTANT_NOTE) : '') . '
'; + print "
"; + + print ''; + + // Actions buttons + print '
'; + print ''; + print '
'; +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 64e515ac76f..655a10f5735 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -295,6 +295,10 @@ $countrynotdefined=''.$langs->trans("ErrorSetACountryFirst") print load_fiche_titre($langs->trans("CompanyFoundation"),'','title_setup'); +$head = company_admin_prepare_head(); + +dol_fiche_head($head, 'company', $langs->trans("Company"), -1, 'company'); + print $langs->trans("CompanyFundationDesc")."
\n"; print "
\n"; @@ -1134,8 +1138,6 @@ else print '
'; print ''; print '
'; - - print '
'; } diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 7c21b89ae3c..7cf10b486b7 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1612,6 +1612,33 @@ function phpinfo_array() return $info_arr; } +/** + * Return array head with list of tabs to view object informations. + * + * @return array head array with tabs + */ +function company_admin_prepare_head() +{ + global $langs, $conf, $user; + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT."/admin/company.php"; + $head[$h][1] = $langs->trans("Company"); + $head[$h][2] = 'company'; + $h++; + + $head[$h][0] = DOL_URL_ROOT."/admin/accountant.php"; + $head[$h][1] = $langs->trans("Accountant"); + $head[$h][2] = 'accountant'; + $h++; + + complete_head_from_modules($conf,$langs,null,$head,$h,'company_admin','remove'); + + return $head; +} + /** * Return array head with list of tabs to view object informations. * diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index b9e4c33f227..da58499482a 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1054,6 +1054,7 @@ AreaForAdminOnly=Setup parameters can be set by administrator users only. SystemInfoDesc=System information is miscellaneous technical information you get in read only mode and visible for administrators only. SystemAreaForAdminOnly=This area is available for administrator users only. None of the Dolibarr permissions can reduce this limit. CompanyFundationDesc=Edit on this page all known information of the company or foundation you need to manage (For this, click on "Modify" or "Save" button at bottom of page) +AccountantDesc=Edit on this page all known information of your accountant/auditor to manage (For this, click on "Modify" or "Save" button at bottom of page) DisplayDesc=You can choose each parameter related to the Dolibarr look and feel here AvailableModules=Available app/modules ToActivateModule=To activate modules, go on setup Area (Home->Setup->Modules). diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c1027e20466..ce29459e022 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -426,6 +426,7 @@ ActionDoneShort=Finished ActionUncomplete=Uncomplete LatestLinkedEvents=Latest %s linked events CompanyFoundation=Company/Organization +Accountant=Accountant ContactsForCompany=Contacts for this third party ContactsAddressesForCompany=Contacts/addresses for this third party AddressesForCompany=Addresses for this third party From e55c90b0151af1d7b7d7abe72523bad136c527d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Mar 2018 20:29:36 +0100 Subject: [PATCH 08/50] 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 09/50] 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 10/50] 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 9aa4a905438e87a47efc24f78534a0b0a7b7cb8c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 10:57:19 +0100 Subject: [PATCH 11/50] NEW Stripe online payments reuse the same stripe customer account --- htdocs/langs/en_US/stripe.lang | 2 +- htdocs/public/payment/newpayment.php | 162 ++++++++++++++++++++------- htdocs/public/stripe/newpayment.php | 4 +- htdocs/societe/card.php | 6 +- 4 files changed, 125 insertions(+), 49 deletions(-) diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang index dcf94d4a17b..536fb3f940d 100644 --- a/htdocs/langs/en_US/stripe.lang +++ b/htdocs/langs/en_US/stripe.lang @@ -39,7 +39,7 @@ STRIPE_TEST_WEBHOOK_KEY=Webhook test key STRIPE_LIVE_SECRET_KEY=Secret live key STRIPE_LIVE_PUBLISHABLE_KEY=Publishable live key STRIPE_LIVE_WEBHOOK_KEY=Webhook live key -ONLINE_PAYMENT_WAREHOUSE=Stock to use for stock decrease when payment online payment is done
(TODO When option to decrease stock is done on an action on invoice and the online payment generate itself the invoice ?) +ONLINE_PAYMENT_WAREHOUSE=Stock to use for stock decrease when online payment is done
(TODO When option to decrease stock is done on an action on invoice and the online payment generate itself the invoice ?) StripeLiveEnabled=Stripe live enabled (otherwise test/sandbox mode) StripeImportPayment=Import Stripe payments ExampleOfTestCreditCard=Example of credit card for test: %s (valid), %s (error CVC), %s (expired), %s (charge fails) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 7230170e1aa..96baf02c7d8 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -41,17 +41,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; // Security check // No check on module enabled. Done later according to $validpaymentmethod -$langs->load("main"); -$langs->load("other"); -$langs->load("dict"); -$langs->load("bills"); -$langs->load("companies"); -$langs->load("errors"); -$langs->load("paybox"); // File with generic data +$langs->loadLangs(array("main","other","dict","bills","companies","errors","paybox")); // File with generic data $action=GETPOST('action','aZ09'); @@ -273,16 +268,17 @@ if ($action == 'dopayment') $PAYPAL_PAYMENT_TYPE='Sale'; $origfulltag=GETPOST("fulltag",'alpha'); - $shipToName=GETPOST("shipToName"); - $shipToStreet=GETPOST("shipToStreet"); - $shipToCity=GETPOST("shipToCity"); - $shipToState=GETPOST("shipToState"); - $shipToCountryCode=GETPOST("shipToCountryCode"); - $shipToZip=GETPOST("shipToZip"); - $shipToStreet2=GETPOST("shipToStreet2"); - $phoneNum=GETPOST("phoneNum"); - $email=GETPOST("email"); + $shipToName=GETPOST("shipToName",'alpha'); + $shipToStreet=GETPOST("shipToStreet",'alpha'); + $shipToCity=GETPOST("shipToCity",'alpha'); + $shipToState=GETPOST("shipToState",'alpha'); + $shipToCountryCode=GETPOST("shipToCountryCode",'alpha'); + $shipToZip=GETPOST("shipToZip",'alpha'); + $shipToStreet2=GETPOST("shipToStreet2",'alpha'); + $phoneNum=GETPOST("phoneNum",'alpha'); + $email=GETPOST("email",'alpha'); $desc=GETPOST("desc",'alpha'); + $thirdparty_id=GETPOST('thirdparty_id', 'int'); $mesg=''; if (empty($PAYPAL_API_PRICE) || ! is_numeric($PAYPAL_API_PRICE)) @@ -347,7 +343,8 @@ if ($action == 'dopayment') if ($paymentmethod == 'paybox') { $PRICE=price2num(GETPOST("newamount"),'MT'); - $email=GETPOST("email"); + $email=GETPOST("email",'alpha'); + $thirdparty_id=GETPOST('thirdparty_id', 'int'); $origfulltag=GETPOST("fulltag",'alpha'); @@ -388,7 +385,7 @@ if ($action == 'dopayment') // Called when choosing Stripe mode, after the 'dopayment' -if ($action == 'charge') +if ($action == 'charge' && ! empty($conf->stripe->enabled)) { $amountstripe = $amount; @@ -401,36 +398,112 @@ 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'); + $thirdparty_id=GETPOST('thirdparty_id', 'int'); $vatnumber = GETPOST('vatnumber','alpha'); dol_syslog("stripeToken = ".$stripeToken, LOG_DEBUG, 0, '_stripe'); dol_syslog("email = ".$email, LOG_DEBUG, 0, '_stripe'); + dol_syslog("thirdparty_id = ".$thirdparty_id, LOG_DEBUG, 0, '_stripe'); dol_syslog("vatnumber = ".$vatnumber, LOG_DEBUG, 0, '_stripe'); $error = 0; try { - dol_syslog("Create customer card profile", LOG_DEBUG, 0, '_stripe'); - $customer = \Stripe\Customer::create(array( - 'email' => $email, - 'description' => ($email?'Customer card profile for '.$email:null), - 'metadata' => array('ipaddress'=>$_SERVER['REMOTE_ADDR']), - 'business_vat_id' => ($vatnumber?$vatnumber:null), - 'source' => $stripeToken // source can be a token OR array('object'=>'card', 'exp_month'=>xx, 'exp_year'=>xxxx, 'number'=>xxxxxxx, 'cvc'=>xxx, 'name'=>'Cardholder's full name', zip ?) - )); - // Return $customer = array('id'=>'cus_XXXX', ...) + $metadata = array( + 'dol_version'=>DOL_VERSION, + 'dol_entity'=>$conf->entity, + 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR']) + ); + if (! empty($dol_id)) $metadata["dol_id"] = $dol_id; + if (! empty($dol_type)) $metadata["dol_type"] = $dol_type; + if (! empty($thirdparty_id)) $metadata["dol_thirdparty_id"] = $thirdparty_id; - dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); - $charge = \Stripe\Charge::create(array( - 'customer' => $customer->id, - 'amount' => price2num($amountstripe, 'MU'), - 'currency' => $currency, - 'description' => 'Stripe payment: '.$FULLTAG, - 'metadata' => array("FULLTAG" => $FULLTAG, 'Recipient' => $mysoc->name), - 'statement_descriptor' => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 6, 'right', 'UTF-8', 1).' '.$FULLTAG, 22, 'right', 'UTF-8', 1) // 22 chars that appears on bank receipt - )); - // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) + if ($thirdparty_id > 0) + { + dol_syslog("Search existing customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0, '_stripe'); + + $service = 'StripeTest'; + $servicestatus = 0; + if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha')) + { + $service = 'StripeLive'; + $servicestatus = 1; + } + $stripeacc = null; // No Oauth/connect use for public pages + + $thirdparty = new Societe($db); + $thirdparty->fetch($thirdparty_id); + + include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; + $stripe = new Stripe($db); + $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1); + + $card = $customer->sources->create(array("source" => $stripeToken, "metadata" => $metadata)); + + if (empty($card)) + { + $error++; + dol_syslog('Failed to create card record', LOG_WARNING, 0, '_stripe'); + setEventMessages('Failed to create card record', null, 'errors'); + $action=''; + } + else + { + dol_syslog("Create charge on card ".$card->id, LOG_DEBUG, 0, '_stripe'); + $charge = \Stripe\Charge::create(array( + 'amount' => price2num($amountstripe, 'MU'), + 'currency' => $currency, + 'capture' => true, // Charge immediatly + 'description' => 'Stripe payment: '.$FULLTAG, + 'metadata' => array("FULLTAG" => $FULLTAG, 'Recipient' => $mysoc->name, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR'])), + 'customer' => $customer->id, + 'source' => $card, + 'statement_descriptor' => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 6, 'right', 'UTF-8', 1).' '.$FULLTAG, 22, 'right', 'UTF-8', 1) // 22 chars that appears on bank receipt + )); + // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) + if (empty($charge)) + { + $error++; + dol_syslog('Failed to charge card', LOG_WARNING, 0, '_stripe'); + setEventMessages('Failed to charge card', null, 'errors'); + $action=''; + } + } + } + else + { + dol_syslog("Create anonymous customer card profile", LOG_DEBUG, 0, '_stripe'); + $customer = \Stripe\Customer::create(array( + 'email' => $email, + 'description' => ($email?'Anonymous customer for '.$email:'Anonymous customer'), + 'metadata' => $metadata, + 'business_vat_id' => ($vatnumber?$vatnumber:null), + 'source' => $stripeToken // source can be a token OR array('object'=>'card', 'exp_month'=>xx, 'exp_year'=>xxxx, 'number'=>xxxxxxx, 'cvc'=>xxx, 'name'=>'Cardholder's full name', zip ?) + )); + // Return $customer = array('id'=>'cus_XXXX', ...) + + // The customer was just created with a source, so we can make a charge + // with no card defined, the source just used for customer creation will be used. + dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); + $charge = \Stripe\Charge::create(array( + 'customer' => $customer->id, + 'amount' => price2num($amountstripe, 'MU'), + 'currency' => $currency, + 'capture' => true, // Charge immediatly + 'description' => 'Stripe payment: '.$FULLTAG, + 'metadata' => array("FULLTAG" => $FULLTAG, 'Recipient' => $mysoc->name, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR'])), + 'statement_descriptor' => dol_trunc(dol_trunc(dol_string_unaccent($mysoc->name), 6, 'right', 'UTF-8', 1).' '.$FULLTAG, 22, 'right', 'UTF-8', 1) // 22 chars that appears on bank receipt + )); + // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) + if (empty($charge)) + { + $error++; + dol_syslog('Failed to charge card', LOG_WARNING, 0, '_stripe'); + setEventMessages('Failed to charge card', null, 'errors'); + $action=''; + } + } } catch(\Stripe\Error\Card $e) { // Since it's a decline, \Stripe\Error\Card will be caught $body = $e->getJsonBody(); @@ -444,8 +517,8 @@ if ($action == 'charge') print('Message is:' . $err['message'] . "\n"); $error++; - setEventMessages($e->getMessage(), null, 'errors'); dol_syslog($e->getMessage(), LOG_WARNING, 0, '_stripe'); + setEventMessages($e->getMessage(), null, 'errors'); $action=''; } catch (\Stripe\Error\RateLimit $e) { // Too many requests made to the API too quickly @@ -794,8 +867,9 @@ if ($source == 'order') { print ''."\n"; } + print ''."\n"; print ''."\n"; - print ''."\n"; + print ''."\n"; $labeldesc=$langs->trans("Order").' '.$order->ref; if (GETPOST('desc','alpha')) $labeldesc=GETPOST('desc','alpha'); print ''."\n"; @@ -928,8 +1002,9 @@ if ($source == 'invoice') { print ''."\n"; } + print ''."\n"; print ''."\n"; - print ''."\n"; + print ''."\n"; $labeldesc=$langs->trans("Invoice").' '.$invoice->ref; if (GETPOST('desc','alpha')) $labeldesc=GETPOST('desc','alpha'); print ''."\n"; @@ -1135,8 +1210,9 @@ if ($source == 'contractline') { print ''."\n"; } + print ''."\n"; print ''."\n"; - print ''."\n"; + print ''."\n"; $labeldesc=$langs->trans("Contract").' '.$contract->ref; if (GETPOST('desc','alpha')) $labeldesc=GETPOST('desc','alpha'); print ''."\n"; @@ -1438,6 +1514,8 @@ if (preg_match('/^dopayment/',$action)) print ''."\n"; print ''."\n"; print ''; + print ''; + print ''; print '
diff --git a/htdocs/public/stripe/newpayment.php b/htdocs/public/stripe/newpayment.php index fc04ef87f1a..9291b2af615 100644 --- a/htdocs/public/stripe/newpayment.php +++ b/htdocs/public/stripe/newpayment.php @@ -219,7 +219,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'); @@ -1149,6 +1149,8 @@ if (preg_match('/^dopayment/',$action)) print ''."\n"; print ''."\n"; print ''; + print ''; + print ''; print '
diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index e515818cd3d..4a5f3ab87bd 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -46,11 +46,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -$langs->load("companies"); -$langs->load("commercial"); -$langs->load("bills"); -$langs->load("banks"); -$langs->load("users"); +$langs->loadLangs(array("companies","commercial","bills","banks","users")); if (! empty($conf->categorie->enabled)) $langs->load("categories"); if (! empty($conf->incoterm->enabled)) $langs->load("incoterm"); if (! empty($conf->notification->enabled)) $langs->load("mails"); From 6ca40bcbd46adfc487910a30019757679d9a46d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 11:01:44 +0100 Subject: [PATCH 12/50] Fix translation --- htdocs/langs/en_US/companies.lang | 8 ++++---- htdocs/langs/en_US/mails.lang | 2 +- htdocs/langs/en_US/main.lang | 2 +- htdocs/langs/en_US/margins.lang | 2 +- htdocs/langs/en_US/ticketsup.lang | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index f195da762a8..aec9c1e1a93 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -389,8 +389,8 @@ NoDolibarrAccess=No Dolibarr access ExportDataset_company_1=Third parties (Companies / foundations / physical people) and properties ExportDataset_company_2=Contacts and properties ImportDataset_company_1=Third parties (Companies / foundations / physical people) and properties -ImportDataset_company_2=Contacts/Addresses (of thirdparties or not) and attributes -ImportDataset_company_3=Bank accounts of thirdparties +ImportDataset_company_2=Contacts/Addresses (of third parties or not) and attributes +ImportDataset_company_3=Bank accounts of third parties ImportDataset_company_4=Third parties/Sales representatives (Assign sales representatives users to companies) PriceLevel=Price level DeliveryAddress=Delivery address @@ -425,9 +425,9 @@ ManagingDirectors=Manager(s) name (CEO, director, president...) MergeOriginThirdparty=Duplicate third party (third party you want to delete) MergeThirdparties=Merge third parties ConfirmMergeThirdparties=Are you sure you want to merge this third party into the current one? All linked objects (invoices, orders, ...) will be moved to current third party, then the thirdparty will be deleted. -ThirdpartiesMergeSuccess=Thirdparties have been merged +ThirdpartiesMergeSuccess=Third parties have been merged SaleRepresentativeLogin=Login of sales representative SaleRepresentativeFirstname=First name of sales representative SaleRepresentativeLastname=Last name of sales representative -ErrorThirdpartiesMerge=There was an error when deleting the thirdparties. Please check the log. Changes have been reverted. +ErrorThirdpartiesMerge=There was an error when deleting the third parties. Please check the log. Changes have been reverted. NewCustomerSupplierCodeProposed=New customer or supplier code suggested on duplicate code diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 8e2b093fdc2..3c512ca7286 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -135,7 +135,7 @@ NbOfTargetedContacts=Current number of targeted contact emails UseFormatFileEmailToTarget=Imported file must have format email;name;firstname;other UseFormatInputEmailToTarget=Enter a string with format email;name;firstname;other MailAdvTargetRecipients=Recipients (advanced selection) -AdvTgtTitle=Fill input fields to preselect the thirdparties or contacts/addresses to target +AdvTgtTitle=Fill input fields to preselect the third parties or contacts/addresses to target AdvTgtSearchTextHelp=Use %% as magic caracters. For exemple to find all item like jean, joe, jim, you can input j%%, you can also use ; as separator for value, and use ! for except this value. For exemple jean;joe;jim%%;!jimo;!jima% will target all jean, joe, start with jim but not jimo and not everythnig taht start by jima AdvTgtSearchIntHelp=Use interval to select int or float value AdvTgtMinVal=Minimum value diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c1027e20466..52dd0aba17e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -904,7 +904,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). diff --git a/htdocs/langs/en_US/ticketsup.lang b/htdocs/langs/en_US/ticketsup.lang index 60f98a8e543..cabf1c39ec3 100644 --- a/htdocs/langs/en_US/ticketsup.lang +++ b/htdocs/langs/en_US/ticketsup.lang @@ -25,7 +25,7 @@ Permission56001=See tickets Permission56002=Modify tickets Permission56003=Delete tickets Permission56004=Manage tickets -Permission56005=See tickets of all thirdparties (not effective for external users, always be limited to the thirdparty they depend on) +Permission56005=See tickets of all third parties (not effective for external users, always be limited to the thirdparty they depend on) TicketsupDictType=Tickets type TicketsupDictCategory=Tickets categories From 8899b511fdce6bdea16b73fdf495f2ab0729af61 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 11:28:55 +0100 Subject: [PATCH 13/50] 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 5db718448f4ad77bb07a28834c99cbdfc35b78ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 11:29:06 +0100 Subject: [PATCH 14/50] Delete at end --- htdocs/projet/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 90f0fc56755..22887c5e42d 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -435,8 +435,8 @@ $arrayofmassactions = array( // 'builddoc'=>$langs->trans("PDFMerge"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); -if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); if ($user->rights->projet->creer) $arrayofmassactions['close']=$langs->trans("Close"); +if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); From 0013e9d83bdb437b4c63e8c7eb3ea2e50d9fba6f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 11:28:55 +0100 Subject: [PATCH 15/50] 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 f8ca4b1b5cd9cfd1a1079a373421b8904235981a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 11:34:48 +0100 Subject: [PATCH 16/50] NEW Add option BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD --- htdocs/core/class/commonobject.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0e3719d2427..64e1d05657b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4338,8 +4338,10 @@ abstract class CommonObject if ($useonlinesignature) $setsharekey=true; if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; } - if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; - if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; + if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; + if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; + if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; + if ($setsharekey) { if (empty($ecmfile->share)) // Because object not found or share not set yet From f46df6d8e5003e1dc55880b79d52ecc029cf1db4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 11:49:05 +0100 Subject: [PATCH 17/50] Can resize and crop images in the ticketsup module --- htdocs/commande/document.php | 1 + htdocs/core/class/html.formfile.class.php | 4 ++-- htdocs/core/photos_resize.php | 23 ++++++++++++++++++++++- htdocs/langs/en_US/main.lang | 1 + htdocs/ticketsup/document.php | 23 +++++++++++------------ 5 files changed, 37 insertions(+), 15 deletions(-) diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index ee688bed307..5a3f0c1973f 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -69,6 +69,7 @@ $object = new Commande($db); /* * Actions */ + if ($object->fetch($id)) { $object->fetch_thirdparty(); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 5eef895bb0c..251a03399d7 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1226,14 +1226,14 @@ class FormFile if (in_array($modulepart, array('product','produit','service'))) $newmodulepart='produit|service'; $disablecrop=1; - if (in_array($modulepart, array('societe','product','produit','service','expensereport','holiday','project','user'))) $disablecrop=0; + if (in_array($modulepart, array('societe','product','produit','service','expensereport','holiday','project','ticketsup','user'))) $disablecrop=0; if (! $disablecrop && image_format_supported($file['name']) > 0) { if ($permtoeditline) { // Link to resize - print ''.img_picto($langs->trans("Resize"),'resize','class="paddingrightonly"').''; + print ''.img_picto($langs->trans("ResizeOrCrop"),'resize','class="paddingrightonly"').''; } } diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 9a11523f39b..c40a9b26c66 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -77,6 +77,12 @@ elseif ($modulepart == 'societe') if (! $user->rights->societe->lire) accessforbidden(); $accessallowed=1; } +elseif ($modulepart == 'ticketsup') +{ + $result=restrictedArea($user,'ticketsup',$id,'ticketsup'); + if (! $user->rights->ticketsup->read) accessforbidden(); + $accessallowed=1; +} // Security: // Limit access if permissions are wrong @@ -154,6 +160,20 @@ elseif ($modulepart == 'expensereport') $dir=$conf->expensereport->dir_output; // By default } } +elseif ($modulepart == 'ticketsup') +{ + require_once DOL_DOCUMENT_ROOT.'/ticketsup/class/ticketsup.class.php'; + $object = new Ticketsup($db); + if ($id > 0) + { + $result = $object->fetch($id); + if ($result <= 0) dol_print_error($db,'Failed to load object'); + $dir=$conf->ticketsup->dir_output; // By default + } +} +else { + print 'Action crop for module part '.$modulepart.' is not supported yet.'; +} if (empty($backtourl)) { @@ -161,8 +181,9 @@ if (empty($backtourl)) else if (in_array($modulepart, array('expensereport'))) $backtourl=DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($_POST["file"]); else if (in_array($modulepart, array('holiday'))) $backtourl=DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]); else if (in_array($modulepart, array('project'))) $backtourl=DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - else if (in_array($modulepart, array('user'))) $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); else if (in_array($modulepart, array('societe'))) $backtourl=DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]); + else if (in_array($modulepart, array('ticketsup'))) $backtourl=DOL_URL_ROOT."/ticketsup/document.php?id=".$id.'&file='.urldecode($_POST["file"]); + else if (in_array($modulepart, array('user'))) $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); } diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 52dd0aba17e..2066dfa4760 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -185,6 +185,7 @@ ToLink=Link Select=Select Choose=Choose Resize=Resize +ResizeOrCrop=Resize or Crop Recenter=Recenter Author=Author User=User diff --git a/htdocs/ticketsup/document.php b/htdocs/ticketsup/document.php index a19a972c143..94348e1054c 100644 --- a/htdocs/ticketsup/document.php +++ b/htdocs/ticketsup/document.php @@ -33,12 +33,10 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT . "/core/lib/company.lib.php"; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; -$langs->load("companies"); -$langs->load('other'); -$langs->load("ticketsup"); +$langs->loadLangs(array("companies","other","ticketsup")); -$action = GETPOST('action'); -$confirm = GETPOST('confirm'); +$action = GETPOST('action','alpha'); +$confirm = GETPOST('confirm','alpha'); $id = GETPOST('id', 'int'); $track_id = GETPOST('track_id', 'alpha'); $ref = GETPOST('ref', 'alpha'); @@ -61,7 +59,6 @@ $pagenext = $page + 1; if (!$sortorder) { $sortorder = "ASC"; } - if (!$sortfield) { $sortfield = "name"; } @@ -75,22 +72,22 @@ $object->ref = $object->track_id; if ($result < 0) { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } else { $upload_dir = $conf->ticketsup->dir_output . "/" . dol_sanitizeFileName($object->track_id); } + /* * Actions */ -// Included file moved into Dolibarr 4, keep it for compatibility -$res=@include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; -if (! $res) { - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; -} + +include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; $object->ref = $old_ref; + + /* * View */ @@ -155,10 +152,12 @@ if ($object->id) { foreach ($filearray as $key => $file) { $totalsize += $file['size']; } + // For compatibility we use track ID for directory $object->ref = $object->track_id; $modulepart = 'ticketsup'; $permission = $user->rights->ticketsup->write; + $permtoedit = $user->rights->ticketsup->write; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; From e91ffa00eb9add3b7d2c3ea8a5fd0ffb205cc22e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 11:56:04 +0100 Subject: [PATCH 18/50] NEW Can crop image files attached in "document" tabs of a member --- htdocs/core/class/html.formfile.class.php | 2 +- htdocs/core/photos_resize.php | 34 +++++++++++++++++------ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 251a03399d7..df6f389180f 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1226,7 +1226,7 @@ class FormFile if (in_array($modulepart, array('product','produit','service'))) $newmodulepart='produit|service'; $disablecrop=1; - if (in_array($modulepart, array('societe','product','produit','service','expensereport','holiday','project','ticketsup','user'))) $disablecrop=0; + if (in_array($modulepart, array('societe','product','produit','service','expensereport','holiday','member','project','ticketsup','user'))) $disablecrop=0; if (! $disablecrop && image_format_supported($file['name']) > 0) { diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index c40a9b26c66..e51e7ee660b 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -53,16 +53,22 @@ elseif ($modulepart == 'project') if (! $user->rights->projet->lire) accessforbidden(); $accessallowed=1; } +elseif ($modulepart == 'expensereport') +{ + $result=restrictedArea($user,'expensereport',$id,'expensereport'); + if (! $user->rights->expensereport->lire) accessforbidden(); + $accessallowed=1; +} elseif ($modulepart == 'holiday') { $result=restrictedArea($user,'holiday',$id,'holiday'); if (! $user->rights->holiday->read) accessforbidden(); $accessallowed=1; } -elseif ($modulepart == 'expensereport') +elseif ($modulepart == 'member') { - $result=restrictedArea($user,'expensereport',$id,'expensereport'); - if (! $user->rights->expensereport->lire) accessforbidden(); + $result=restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid'); + if (! $user->rights->adherent->lire) accessforbidden(); $accessallowed=1; } elseif ($modulepart == 'user') @@ -127,6 +133,17 @@ elseif ($modulepart == 'holiday') $dir=$conf->holiday->dir_output; // By default } } +elseif ($modulepart == 'member') +{ + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $object = new Adherent($db); + if ($id > 0) + { + $result = $object->fetch($id); + if ($result <= 0) dol_print_error($db,'Failed to load object'); + $dir=$conf->adherent->dir_output; // By default + } +} elseif ($modulepart == 'societe') { require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -179,11 +196,12 @@ if (empty($backtourl)) { if (in_array($modulepart, array('product','produit','service','produit|service'))) $backtourl=DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"]); else if (in_array($modulepart, array('expensereport'))) $backtourl=DOL_URL_ROOT."/expensereport/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - else if (in_array($modulepart, array('holiday'))) $backtourl=DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - else if (in_array($modulepart, array('project'))) $backtourl=DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - else if (in_array($modulepart, array('societe'))) $backtourl=DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - else if (in_array($modulepart, array('ticketsup'))) $backtourl=DOL_URL_ROOT."/ticketsup/document.php?id=".$id.'&file='.urldecode($_POST["file"]); - else if (in_array($modulepart, array('user'))) $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); + else if (in_array($modulepart, array('holiday'))) $backtourl=DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]); + else if (in_array($modulepart, array('member'))) $backtourl=DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]); + else if (in_array($modulepart, array('project'))) $backtourl=DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]); + else if (in_array($modulepart, array('societe'))) $backtourl=DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]); + else if (in_array($modulepart, array('ticketsup'))) $backtourl=DOL_URL_ROOT."/ticketsup/document.php?id=".$id.'&file='.urldecode($_POST["file"]); + else if (in_array($modulepart, array('user'))) $backtourl=DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); } From ce3975377d1a1df2a32fa9d80f6dc2a8eff24366 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 12:02:49 +0100 Subject: [PATCH 19/50] Link to unlink is unlink and not remove --- htdocs/core/tpl/contacts.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 493a6c88ec7..0ecf01f9dd1 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -229,7 +229,7 @@ if ($permission) { From 5a98958280cce71f618803c60a3abd4bc236f33b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 12:07:08 +0100 Subject: [PATCH 20/50] Update adherent.class.php --- htdocs/adherents/class/adherent.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index d9bca123000..cf120f3871f 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1614,7 +1614,7 @@ class Adherent extends CommonObject // Generate PDF (whatever is option MAIN_DISABLE_PDF_AUTOUPDATE) so we can include it into email //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - $invoice->generateDocument($invoice->modelpdf, $outputlangs, 0, 0, 0); + $invoice->generateDocument($invoice->modelpdf, $outputlangs); } } From 6f7098d22e66100d1ede011c6fcb6663567d07f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 12:09:38 +0100 Subject: [PATCH 21/50] Update objectline_view.tpl.php --- htdocs/core/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 1d9e81fe1ee..ff0cec92649 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -286,7 +286,7 @@ if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0; accounting->enabled)) + if (! empty($conf->accounting->enabled) && $line->fk_accounting_account > 0) { $accountingaccount=new AccountingAccount($this->db); $accountingaccount->fetch($line->fk_accounting_account); From 890d0b6685b424fb1a8d0a864cda9a3679467c2e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 19 Mar 2018 12:11:59 +0100 Subject: [PATCH 22/50] 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 c3cd2ff3db4480f0f8cc6ca8542e143bbe078699 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 12:13:18 +0100 Subject: [PATCH 23/50] Update objectline_view.tpl.php --- htdocs/core/tpl/objectline_view.tpl.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index ff0cec92649..82fe0dde873 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -143,6 +143,14 @@ if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0; echo get_date_range($line->date_start,$line->date_end, $format); } } + + if (! empty($conf->accounting->enabled) && $line->fk_accounting_account > 0) + { + $accountingaccount=new AccountingAccount($this->db); + $accountingaccount->fetch($line->fk_accounting_account); + echo '
' . $langs->trans('AccountingAffectation') . ': ' . $accountingaccount->getNomUrl(0,1,1); + } + ?> -accounting->enabled) && $line->fk_accounting_account > 0) - { - $accountingaccount=new AccountingAccount($this->db); - $accountingaccount->fetch($line->fk_accounting_account); - echo '
'; - } -?> - showOptionals($extrafieldsline,'view',array('style'=>$bcdd[$var],'colspan'=>$coldisplay)); } ?> - + + From 2ae1bb26c510c85221f6350af1fb6aff3dfbc18b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 12:14:43 +0100 Subject: [PATCH 24/50] Update compta.lang --- htdocs/langs/en_US/compta.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 7b2c99fe8fc..871b911a971 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -237,4 +237,4 @@ ErrorBankAccountNotFound=Error: Bank account not found FiscalPeriod=Accounting period ListSocialContributionAssociatedProject=List of social contributions associated with the project DeleteFromCat=Remove from accounting group -AccountingAffectation=Accounting affectation +AccountingAffectation=Accounting assignement From 1837d6a5f30183a02f86182da55ecff24b786664 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 12:30:48 +0100 Subject: [PATCH 25/50] Better look of lines --- htdocs/core/tpl/objectline_view.tpl.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 16deed0bcfd..d24a094b9f0 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -154,14 +154,14 @@ if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0; print (! empty($line->description) && $line->description!=$line->product_label)?'
'.dol_htmlentitiesbr($line->description):''; } } - + if (! empty($conf->accounting->enabled) && $line->fk_accounting_account > 0) { $accountingaccount=new AccountingAccount($this->db); $accountingaccount->fetch($line->fk_accounting_account); - echo '
' . $langs->trans('AccountingAffectation') . ': ' . $accountingaccount->getNomUrl(0,1,1); + echo '

' . $langs->trans('AccountingAffectation') . ' : ' . $accountingaccount->getNomUrl(0,1,1); } - + ?> showOptionals($extrafieldsline,'view',array('style'=>$bcdd[$var],'colspan'=>$coldisplay)); } ?> - + From eb7886ecff7ed8ca0bb09a89ed79d7fc1c7f048c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 12:37:53 +0100 Subject: [PATCH 26/50] 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 ae17ce6f9abf08452929f62432865d2a12c33fc3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 12:52:09 +0100 Subject: [PATCH 27/50] NEW Add a tab to specify accountant/auditor of the company --- htdocs/admin/accountant.php | 27 ++++++++------------------- htdocs/core/lib/admin.lib.php | 2 +- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/htdocs/admin/accountant.php b/htdocs/admin/accountant.php index 155534c5f3d..22f42ff0214 100644 --- a/htdocs/admin/accountant.php +++ b/htdocs/admin/accountant.php @@ -52,25 +52,13 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) || ($action == 'updateedit') ) { - $tmparray=getCountry(GETPOST('country_id','int'),'all',$db,$langs,0); - if (! empty($tmparray['id'])) - { - $mysoc->country_id =$tmparray['id']; - $mysoc->country_code =$tmparray['code']; - $mysoc->country_label=$tmparray['label']; - - $s=$mysoc->country_id.':'.$mysoc->country_code.':'.$mysoc->country_label; - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_COUNTRY", $s,'chaine',0,'',$conf->entity); - - activateModulesRequiredByCountry($mysoc->country_code); - } - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom",'nohtml'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address",'nohtml'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_TOWN", GETPOST("town",'nohtml'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ZIP", GETPOST("zipcode",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_STATE", GETPOST("state_id",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_REGION", GETPOST("region_code",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_COUNTRY", GETPOST('country_id','int'), 'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_PHONE", GETPOST("tel",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_FAX", GETPOST("fax",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_MAIL", GETPOST("mail",'alpha'),'chaine',0,'',$conf->entity); @@ -144,12 +132,12 @@ if ($action == 'edit' || $action == 'updateedit') // Country print '
'."\n"; print ''."\n"; print ''; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 7cf10b486b7..4bd9b097b3d 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1154,7 +1154,7 @@ function complete_dictionary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql } /** - * Activate external modules mandatroy when country is country_code + * Activate external modules mandatory when country is country_code * * @param string $country_code CountryCode * @return int 1 From 7272ee806ec664924a1537848cfe4298a596a41a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 12:55:13 +0100 Subject: [PATCH 28/50] Fix field not mandatory --- htdocs/admin/accountant.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/admin/accountant.php b/htdocs/admin/accountant.php index 22f42ff0214..e7733e64941 100644 --- a/htdocs/admin/accountant.php +++ b/htdocs/admin/accountant.php @@ -211,7 +211,6 @@ else print $img?$img.' ':''; print getCountry($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY,1); } - else print img_warning().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Country")).''; print ''; From 8889e7f4b2111b4fde4a861ce4a2fa4c9858b17c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 13:55:26 +0100 Subject: [PATCH 29/50] 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 30/50] 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 31/50] 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('AccountingAffectation') . ': ' . $accountingaccount->getNomUrl(0,1,1) . '
'; //if (empty($country_selected)) $country_selected=substr($langs->defaultlang,-2); // By default, country of localization - print $form->select_country($mysoc->country_id, 'country_id'); + print $form->select_country($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY, 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '
'; - $formcompany->select_departement($conf->global->MAIN_INFO_ACCOUNTANT_STATE, $mysoc->country_code, 'state_id'); + $formcompany->select_departement($conf->global->MAIN_INFO_ACCOUNTANT_STATE, $conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY, 'state_id'); print '
'; @@ -216,13 +204,14 @@ else print '
'.$langs->trans("CompanyCountry").''; - if ($mysoc->country_code) + if (! empty($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY)) { - $img=picto_from_langcode($mysoc->country_code); + $code = getCountry($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY, 2); + $img=picto_from_langcode($code); print $img?$img.' ':''; - print getCountry($mysoc->country_code,1); + print getCountry($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY,1); } - else print img_warning().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; + else print img_warning().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Country")).''; 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 32/50] 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 33/50] 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 34/50] 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 35/50] 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) { From 0dc8d3cb003fefa60d85836ea583958d541119c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 18:53:33 +0100 Subject: [PATCH 36/50] Fix trad --- htdocs/langs/en_US/admin.lang | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 29673edf51c..ed2c27fc004 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -833,11 +833,11 @@ Permission1251=Run mass imports of external data into database (data load) Permission1321=Export customer invoices, attributes and payments Permission1322=Reopen a paid bill Permission1421=Export customer orders and attributes -Permission20001=Read leave requests (yours and your subordinates) -Permission20002=Create/modify your leave requests +Permission20001=Read leave requests (your leaves and the one of your subordinates) +Permission20002=Create/modify your leave requests (yours leaves and the one of your subordinates) Permission20003=Delete leave requests -Permission20004=Read all leave requests (even user not subordinates) -Permission20005=Create/modify leave requests for everybody +Permission20004=Read all leave requests (even of user not subordinates) +Permission20005=Create/modify leave requests for everybody (even of user not subordinates) Permission20006=Admin leave requests (setup and update balance) Permission23001=Read Scheduled job Permission23002=Create/update Scheduled job From 7948359bf7f7a6f4673fa681198b981a4d427a22 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 19:08:35 +0100 Subject: [PATCH 37/50] Unlink picto differs from delete picto --- htdocs/user/group/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 52de09d566d..83daf039aa2 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -460,7 +460,7 @@ else if (! empty($user->admin)) { print ''; - print img_delete($langs->trans("RemoveFromGroup")); + print img_picto($langs->trans("RemoveFromGroup"), 'unlink'); print ''; } else From a325bbf8650567e2fcce5ff9879d1efa57c46ea9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Mar 2018 20:46:43 +0100 Subject: [PATCH 38/50] FIX Input of holiday for subordinates was ko --- htdocs/core/class/html.form.class.php | 2 +- htdocs/holiday/card.php | 51 ++++++++++++++------------- htdocs/holiday/list.php | 25 +++++++------ htdocs/langs/en_US/holiday.lang | 1 + 4 files changed, 44 insertions(+), 35 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 2424523ec0a..4daf78ad52e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1441,7 +1441,7 @@ class Form /** * Return select list of users * - * @param string $selected User id or user object of user preselected. If -1, we use id of current user. + * @param string $selected User id or user object of user preselected. If 0 or < -2, we use id of current user. If -1, keep unselected (if empty is allowed) * @param string $htmlname Field name in form * @param int $show_empty 0=list with no empty value, 1=add also an empty value into list * @param array $exclude Array list of users id to exclude diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 799b0907a92..e788abca30f 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -50,6 +50,18 @@ $now=dol_now(); $langs->load("holiday"); +$childids = $user->getAllChildIds(1); + +$cancreate = 0; +if (! empty($user->rights->holiday->write_all)) $cancreate=1; +if (! empty($user->rights->holiday->write) && in_array($fuserid, $childids)) $cancreate=1; + +$candelete = 0; +if (! empty($user->rights->holiday->delete)) $candelete=1; + +$morefilter = 'AND employee = 1'; +if (! empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = ''; + /* * Actions @@ -61,8 +73,7 @@ if ($action == 'create') $object = new Holiday($db); // If no right to create a request - $fuserid = GETPOST('fuserid','int'); - if (($fuserid == $user->id && empty($user->rights->holiday->write)) || ($fuserid != $user->id && empty($user->rights->holiday->write_all))) + if (! $cancreate) { $error++; setEventMessages($langs->trans('CantCreateCP'), null, 'errors'); @@ -201,13 +212,11 @@ if ($action == 'update') $object = new Holiday($db); $object->fetch($id); - $canedit=(($user->id == $object->fk_user && $user->rights->holiday->write) || ($user->id != $object->fk_user && $user->rights->holiday->write_all)); - // If under validation if ($object->statut == 1) { // If this is the requestor or has read/write rights - if ($canedit) + if ($cancreate) { $valideur = $_POST['valideur']; $description = trim($_POST['description']); @@ -280,13 +289,11 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights- $object = new Holiday($db); $object->fetch($id); - $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, approved, canceled or refused if ($object->statut == 1 || $object->statut == 4 || $object->statut == 5) { // Si l'utilisateur à le droit de lire cette demande, il peut la supprimer - if ($canedit) + if ($candelete) { $result=$object->delete($user); } @@ -314,10 +321,8 @@ if ($action == 'confirm_send') $object = new Holiday($db); $object->fetch($id); - $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($object->statut == 1 && $canedit) + if($object->statut == 1 && $cancreate) { $object->statut = 2; @@ -615,7 +620,7 @@ if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') $object->fetch($id); // Si statut en attente de validation et valideur = valideur ou utilisateur, ou droits de faire pour les autres - if (($object->statut == 2 || $object->statut == 3) && ($user->id == $object->fk_validator || $user->id == $object->fk_user || ! empty($user->rights->holiday->write_all))) + if (($object->statut == 2 || $object->statut == 3) && ($user->id == $object->fk_validator || in_array($object->fk_user, $childids) || ! empty($user->rights->holiday->write_all))) { $db->begin(); @@ -849,10 +854,10 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print ''; if (empty($user->rights->holiday->write_all)) { - print $form->select_dolusers($fuserid, 'useridbis', 0, '', 1, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - print ''; + print $form->select_dolusers(($fuserid?$fuserid:$user->id), 'fuserid', 0, '', 0, 'hierarchyme', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth300'); + //print ''; } - else print $form->select_dolusers(GETPOST('fuserid','int')?GETPOST('fuserid','int'):$user->id, 'fuserid', 0, '', 0, '', '', 0, 0, 0, 'AND employee = 1'); + else print $form->select_dolusers(GETPOST('fuserid','int')?GETPOST('fuserid','int'):$user->id, 'fuserid', 0, '', 0, '', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth300'); print ''; print ''; @@ -957,8 +962,6 @@ else { $object->fetch($id); - $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($object->fk_validator); @@ -1005,7 +1008,7 @@ else } // On vérifie si l'utilisateur à le droit de lire cette demande - if ($canedit) + if ($cancreate) { if ($action == 'delete') { @@ -1242,7 +1245,7 @@ else if ($action == 'edit' && $object->statut == 1) { print '
'; - if ($canedit && $object->statut == 1) + if ($cancreate && $object->statut == 1) { print ''; } @@ -1257,11 +1260,11 @@ else print '
'; // Boutons d'actions - if ($canedit && $object->statut == 1) + if ($cancreate && $object->statut == 1) { print ''.$langs->trans("EditCP").''; } - if ($canedit && $object->statut == 1) + if ($cancreate && $object->statut == 1) // If draft { print ''.$langs->trans("Validate").''; } @@ -1270,7 +1273,7 @@ else print ''.$langs->trans("DeleteCP").''; } - if ($object->statut == 2) + if ($object->statut == 2) // If validated { if ($user->id == $object->fk_validator) { @@ -1284,13 +1287,13 @@ else } } - if (($user->id == $object->fk_validator || $user->id == $object->fk_user || ! empty($user->rights->holiday->write_all)) && ($object->statut == 2 || $object->statut == 3)) // Status validated or approved + if (($user->id == $object->fk_validator || in_array($object->fk_user, $childids) || ! empty($user->rights->holiday->write_all)) && ($object->statut == 2 || $object->statut == 3)) // Status validated or approved { if (($object->date_debut > dol_now()) || $user->admin) print ''.$langs->trans("ActionCancelCP").''; else print ''.$langs->trans("ActionCancelCP").''; } - if ($canedit && $object->statut == 4) + if ($cancreate && $object->statut == 4) { print ''.$langs->trans("SetToDraft").''; } diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index e0894ecb355..8769046b03a 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -96,6 +96,7 @@ $fieldstosearchall = array( 'uu.firstname'=>'EmployeeFirstname' ); +$childids = $user->getAllChildIds(1); /* @@ -160,9 +161,6 @@ $holiday = new Holiday($db); $holidaystatic=new Holiday($db); $fuser = new User($db); -$childids = $user->getAllChildIds(); -$childids[]=$user->id; - // Update sold $result = $holiday->updateBalance(); @@ -302,7 +300,7 @@ if ($search_year_create) $param.='&search_year_create='.urlencode($searc 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_day_end) $param.='&search_day_end='.urlencode($search_day_end); if ($search_month_end) $param.='&search_month_end='.urlencode($search_month_end); if ($search_year_end) $param.='&search_year_end='.urlencode($search_year_end); if ($search_employee > 0) $param.='&search_employee='.urlencode($search_employee); @@ -401,18 +399,25 @@ print ''; - print $form->select_dolusers($search_employee,"search_employee",1,"",0,'','',0,0,0,'',0,'','maxwidth200'); + $defaultuserid = -1; + if (GETPOSTISSET('search_employee')) $defaultuserid=GETPOST('search_employee','int'); + print ''; + print $form->select_dolusers($defaultuserid, "search_employee", 1, "", 0, '', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); print ''; } else { - //print ' '; + $defaultuserid = $user->id; + if (GETPOSTISSET('search_employee')) $defaultuserid=GETPOST('search_employee','int'); print ''; - print $form->select_dolusers($user->id,"search_employee",1,"",1,'','',0,0,0,'',0,'','maxwidth200'); + print $form->select_dolusers($defaultuserid, "search_employee", 1, "", 0, 'hierarchyme', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); print ''; } @@ -426,7 +431,7 @@ if($user->rights->holiday->write_all) $valideurobjects = $validator->listUsersForGroup($excludefilter); $valideurarray = array(); foreach($valideurobjects as $val) $valideurarray[$val->id]=$val->id; - print $form->select_dolusers($search_valideur,"search_valideur",1,"",0,$valideurarray,'', 0, 0, 0, '', 0, '', 'maxwidth200'); + print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); print ''; } else diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 621cc02c758..bb0d1e6ab41 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -59,6 +59,7 @@ DateRefusCP=Date of refusal DateCancelCP=Date of cancellation DefineEventUserCP=Assign an exceptional leave for a user addEventToUserCP=Assign leave +NotTheAssignedApprover=You are not the assigned approver MotifCP=Reason UserCP=User ErrorAddEventToUserCP=An error occurred while adding the exceptional leave. From 8cf2d4eb45205f704b3357d4d48feb623c3980ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Mar 2018 10:10:21 +0100 Subject: [PATCH 39/50] Fix filter on holiday statut Fix tr/td balance for extrafields on lines --- htdocs/contrat/card.php | 9 +-- htdocs/core/class/commonobject.class.php | 44 +++++++------- htdocs/core/menus/init_menu_auguria.sql | 2 +- htdocs/core/menus/standard/eldy.lib.php | 10 ++-- htdocs/core/tpl/objectline_create.tpl.php | 70 ++++++++++++----------- htdocs/core/tpl/objectline_edit.tpl.php | 16 +++--- htdocs/core/tpl/objectline_view.tpl.php | 5 +- htdocs/holiday/class/holiday.class.php | 2 +- 8 files changed, 82 insertions(+), 76 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 93f1b4fd157..9d504aae6e4 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1680,11 +1680,9 @@ else // Display lines extrafields if (is_array($extralabelslines) && count($extralabelslines)>0) { - print ''; $line = new ContratLigne($db); $line->fetch_optionals($objp->rowid,$extralabelslines); - print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bcnd[$var], 'colspan'=>$colspan)); - print ''; + print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bcnd[$var], 'colspan'=>$colspan), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } } // Ligne en mode update @@ -1752,13 +1750,12 @@ else print '   '.$langs->trans("DateEndPlanned").' '; $form->select_date($db->jdate($objp->date_fin),"date_end_update",$usehm,$usehm,($db->jdate($objp->date_fin)>0?0:1),"update"); print ''; + print ''; if (is_array($extralabelslines) && count($extralabelslines)>0) { - print ''; $line = new ContratLigne($db); $line->fetch_optionals($objp->rowid,$extralabelslines); - print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$colspan)); - print ''; + print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$colspan), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } print ''; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 388dfe9799b..63788a32569 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5371,7 +5371,7 @@ abstract class CommonObject $label = $val['label']; $type = $val['type']; $size = $val['css']; - + // Convert var to be able to share same code than showOutputField of extrafields if (preg_match('/varchar\((\d+)\)/', $type, $reg)) { @@ -5708,15 +5708,15 @@ abstract class CommonObject /** * Function to show lines of extrafields with output datas * - * @param Extrafields $extrafields Extrafield Object - * @param string $mode Show output (view) or input (edit) for extrafield - * @param array $params Optional parameters - * @param string $keysuffix Suffix string to add after name and id of field (can be used to avoid duplicate names) - * @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names) - * - * @return string + * @param Extrafields $extrafields Extrafield Object + * @param string $mode Show output (view) or input (edit) for extrafield + * @param array $params Optional parameters + * @param string $keysuffix Suffix string to add after name and id of field (can be used to avoid duplicate names) + * @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names) + * @param string $onetrtd All fields in same tr td + * @return string */ - function showOptionals($extrafields, $mode='view', $params=null, $keysuffix='', $keyprefix='') + function showOptionals($extrafields, $mode='view', $params=null, $keysuffix='', $keyprefix='', $onetrtd=0) { global $_POST, $conf, $langs, $action; @@ -5780,15 +5780,13 @@ abstract class CommonObject $csstyle=$params['style']; } } - if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) + + $out .= ''; + if (empty($onetrtd)) { - $out .= ''; - $colspan='0'; - } - else - { - $out .= ''; + if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan='0'; } } + // Convert date into timestamp format (value in memory must be a timestamp) if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) { @@ -5806,10 +5804,17 @@ abstract class CommonObject { $labeltoshow = ''.$labeltoshow.''; } - $out .= ''.$labeltoshow.''; + + if (empty($onetrtd)) $out .= ''; + else $out .= ''; + + $out .= $labeltoshow; + + if (empty($onetrtd)) $out .= ''; + else $out.=' '; $html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : ''; - $out .=''; + $out .=''; switch($mode) { case "view": @@ -5821,9 +5826,8 @@ abstract class CommonObject } $out .= ''; + $out .= ''; - if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= ''; - else $out .= ''; $e++; } } diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 28eb9fa044a..c2dde1c8493 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -350,7 +350,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5000__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/holiday/list.php?&leftmenu=hrm', 'CPTitreMenu', 0, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5001__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/card.php?&action=request', 'MenuAddCP', 1, 'holiday', '$user->rights->holiday->write', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5002__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/list.php?&leftmenu=hrm', 'List', 1, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5003__+MAX_llx_menu__, 'hrm', '', 5002__+MAX_llx_menu__, '/holiday/list.php?select_statut=2&leftmenu=hrm', 'ListToApprove', 2, 'trips', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5003__+MAX_llx_menu__, 'hrm', '', 5002__+MAX_llx_menu__, '/holiday/list.php?search_statut=2&leftmenu=hrm', 'ListToApprove', 2, 'trips', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5004__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/define_holiday.php?&action=request', 'MenuConfCP', 1, 'holiday', '$user->rights->holiday->define_holiday', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5005__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/view_log.php?&action=request', 'MenuLogCP', 1, 'holiday', '$user->rights->holiday->define_holiday', '', 0, 3, __ENTITY__); -- HRM - Trips and expenses (old module) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 15a262654f4..fd3668aeaac 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1364,11 +1364,11 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/holiday/list.php?leftmenu=hrm", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'hrm'); $newmenu->add("/holiday/card.php?action=request", $langs->trans("New"), 1,$user->rights->holiday->write); $newmenu->add("/holiday/list.php?leftmenu=hrm", $langs->trans("List"), 1,$user->rights->holiday->read); - if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=1&leftmenu=hrm", $langs->trans("DraftCP"), 2, $user->rights->holiday->read); - if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=2&leftmenu=hrm", $langs->trans("ToReviewCP"), 2, $user->rights->holiday->read); - if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=3&leftmenu=hrm", $langs->trans("ApprovedCP"), 2, $user->rights->holiday->read); - if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=4&leftmenu=hrm", $langs->trans("CancelCP"), 2, $user->rights->holiday->read); - if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=5&leftmenu=hrm", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=1&leftmenu=hrm", $langs->trans("DraftCP"), 2, $user->rights->holiday->read); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=2&leftmenu=hrm", $langs->trans("ToReviewCP"), 2, $user->rights->holiday->read); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=3&leftmenu=hrm", $langs->trans("ApprovedCP"), 2, $user->rights->holiday->read); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=4&leftmenu=hrm", $langs->trans("CancelCP"), 2, $user->rights->holiday->read); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=5&leftmenu=hrm", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read); $newmenu->add("/holiday/define_holiday.php?action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->read); $newmenu->add("/holiday/view_log.php?action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday); } diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 0bccdd61e79..6dec803b975 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -58,6 +58,37 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; $colspan = 3; // Col total ht + col edit + col delete if (in_array($object->element,array('propal','commande','order','facture','facturerec','invoice','supplier_proposal','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button //print $object->element; + +// Lines for extrafield +$objectline = null; +if (!empty($extrafieldsline)) +{ + if ($this->table_element_line=='commandedet') { + $objectline = new OrderLine($this->db); + } + elseif ($this->table_element_line=='propaldet') { + $objectline = new PropaleLigne($this->db); + } + elseif ($this->table_element_line=='supplier_proposaldet') { + $objectline = new SupplierProposalLine($this->db); + } + elseif ($this->table_element_line=='facturedet') { + $objectline = new FactureLigne($this->db); + } + elseif ($this->table_element_line=='contratdet') { + $objectline = new ContratLigne($this->db); + } + elseif ($this->table_element_line=='commande_fournisseurdet') { + $objectline = new CommandeFournisseurLigne($this->db); + } + elseif ($this->table_element_line=='facture_fourn_det') { + $objectline = new SupplierInvoiceLine($this->db); + } + elseif ($this->table_element_line=='facturedet_rec') { + $objectline = new FactureLigneRec($this->db); + } +} + ?> @@ -363,41 +394,14 @@ else { - table_element_line=='commandedet') { - $newline = new OrderLine($this->db); - } - elseif ($this->table_element_line=='propaldet') { - $newline = new PropaleLigne($this->db); - } - elseif ($this->table_element_line=='supplier_proposaldet') { - $newline = new SupplierProposalLine($this->db); - } - elseif ($this->table_element_line=='facturedet') { - $newline = new FactureLigne($this->db); - } - elseif ($this->table_element_line=='contratdet') { - $newline = new ContratLigne($this->db); - } - elseif ($this->table_element_line=='commande_fournisseurdet') { - $newline = new CommandeFournisseurLigne($this->db); - } - elseif ($this->table_element_line=='facture_fourn_det') { - $newline = new SupplierInvoiceLine($this->db); - } - elseif ($this->table_element_line=='facturedet_rec') { - $newline = new FactureLigneRec($this->db); - } - if (is_object($newline)) { - print $newline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8)); - } - } - ?> +showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); +} +?> + service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required { diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 67adba3a2ae..41d419694e8 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -225,16 +225,16 @@ $coldisplay=-1; // We remove first td ">
"> - - showOptionals($extrafieldsline,'edit',array('style'=>$bc[$var],'colspan'=>$coldisplay)); - } - ?> +showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var],'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); +} +?> + service->enabled) && $line->product_type == 1 && $dateSelector) { ?> > trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?> diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 8d5b13ece7c..f1c691bf2a2 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -285,13 +285,14 @@ if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0; + + showOptionals($extrafieldsline,'view',array('style'=>$bcdd[$var],'colspan'=>$coldisplay)); + print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bcdd[$var],'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } ?> - diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 6e230fac7b2..c3c541bb8ce 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -958,7 +958,7 @@ class Holiday extends CommonObject * Affiche un select HTML des statuts de congés payés * * @param int $selected Id of preselected status - * @param string $select_statut Name of HTML select field + * @param string $htmlname Name of HTML select field * @return string Show select of status */ function selectStatutCP($selected='', $htmlname='select_statut') { From 29775f735bb5dbb01363a36446fed366db4cc634 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Mar 2018 11:26:41 +0100 Subject: [PATCH 40/50] Option MAIN_EXTRAFIELDS_IN_ONE_TD is now 1 --- htdocs/core/class/conf.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 0705d2fd60d..ac866d1213c 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -589,6 +589,8 @@ class Conf $conf->global->AGENDA_DEFAULT_FILTER_TYPE='0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on. } + if (! isset($this->global->MAIN_EXTRAFIELDS_IN_ONE_TD)) $this->global->MAIN_EXTRAFIELDS_IN_ONE_TD = 1; + $conf->global->MAIN_MODULE_DOLISTORE_API_SRV='https://www.dolistore.com'; $conf->global->MAIN_MODULE_DOLISTORE_API_KEY='dolistorecatalogpublickey1234567'; From 896a1cbc2475abb160f96cb43bfc5cb557099c43 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Mar 2018 11:27:47 +0100 Subject: [PATCH 41/50] Fix bad var init --- htdocs/core/class/conf.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index a1d051440c3..9b2646a12b5 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -422,7 +422,7 @@ class Conf if (empty($this->global->MAIN_MONNAIE)) $this->global->MAIN_MONNAIE='EUR'; $this->currency=$this->global->MAIN_MONNAIE; - if (empty($conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure + if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure // conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...) if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE='RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES' @@ -581,13 +581,13 @@ class Conf if (! isset($this->global->THEME_HIDE_BORDER_ON_INPUT)) $this->global->THEME_HIDE_BORDER_ON_INPUT=0; // Save inconsistent option - if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && (! isset($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $conf->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO')) + if (empty($this->global->AGENDA_USE_EVENT_TYPE) && (! isset($this->global->AGENDA_DEFAULT_FILTER_TYPE) || $this->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO')) { - $conf->global->AGENDA_DEFAULT_FILTER_TYPE='0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on. + $this->global->AGENDA_DEFAULT_FILTER_TYPE='0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on. } - $conf->global->MAIN_MODULE_DOLISTORE_API_SRV='https://www.dolistore.com'; - $conf->global->MAIN_MODULE_DOLISTORE_API_KEY='dolistorecatalogpublickey1234567'; + $this->global->MAIN_MODULE_DOLISTORE_API_SRV='https://www.dolistore.com'; + $this->global->MAIN_MODULE_DOLISTORE_API_KEY='dolistorecatalogpublickey1234567'; // For backward compatibility if (isset($this->product)) $this->produit=$this->product; From 1fdad9182ff8d5945c4140bf0a7f666932e2df3a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Mar 2018 11:45:57 +0100 Subject: [PATCH 42/50] Fix missing security restiction test --- htdocs/holiday/list.php | 9 +++++++++ htdocs/modulebuilder/template/myobject_list.php | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index e0894ecb355..057879c52eb 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -48,6 +48,15 @@ $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectl $backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print') +// Security check +$socid=0; +if ($user->societe_id > 0) // Protection if external user +{ + //$socid = $user->societe_id; + accessforbidden(); +} +$result = restrictedArea($user, 'holiday', $id, ''); + // Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index c5f15db7158..c1867fb87f7 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -98,14 +98,14 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. if (! $sortorder) $sortorder="ASC"; -// Protection if external user +// Security check $socid=0; -if ($user->societe_id > 0) +if ($user->societe_id > 0) // Protection if external user { //$socid = $user->societe_id; accessforbidden(); } -//$result = restrictedArea($user, 'mymodule', $id,''); +//$result = restrictedArea($user, 'mymodule', $id, ''); // Initialize array of search criterias $search_all=trim(GETPOST("search_all",'alpha')); From 67483eeb648d5e827d6435788bd0d37b5067893a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Mar 2018 13:42:29 +0100 Subject: [PATCH 43/50] NEW Report a list of leave requests for a month --- htdocs/core/menus/standard/eldy.lib.php | 1 + htdocs/holiday/card.php | 2 ++ htdocs/holiday/class/holiday.class.php | 2 +- htdocs/holiday/list.php | 4 ++-- htdocs/langs/en_US/holiday.lang | 4 ++++ htdocs/langs/fr_FR/holiday.lang | 4 ++++ 6 files changed, 14 insertions(+), 3 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index b8381382ff4..dafa202557f 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1377,6 +1377,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=4&leftmenu=hrm", $langs->trans("CancelCP"), 2, $user->rights->holiday->read); if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=5&leftmenu=hrm", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read); $newmenu->add("/holiday/define_holiday.php?action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->read); + $newmenu->add("/holiday/month_report.php", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->read); $newmenu->add("/holiday/view_log.php?action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday); } diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 799b0907a92..2c05350fd43 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1071,6 +1071,7 @@ else print ''; print ''; + // User print ''; print ''; print ''; print ''; } + // Nb of days print ''; print ''; print ''; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 6e230fac7b2..c3c894d5088 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -50,7 +50,7 @@ class Holiday extends CommonObject var $date_fin=''; // Date end in PHP server TZ var $date_debut_gmt=''; // Date start in GMT var $date_fin_gmt=''; // Date end in GMT - var $halfday=''; + var $halfday=''; // 0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning var $statut=''; // 1=draft, 2=validated, 3=approved var $fk_validator; var $date_valid=''; diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 057879c52eb..32a8632d2b9 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -490,7 +490,7 @@ print_liste_field_titre("DateCreateCP",$_SERVER["PHP_SELF"],"cp.date_create","", print_liste_field_titre("Employee",$_SERVER["PHP_SELF"],"cp.fk_user","",$param,'',$sortfield,$sortorder); print_liste_field_titre("ValidatorCP",$_SERVER["PHP_SELF"],"cp.fk_validator","",$param,'',$sortfield,$sortorder); print_liste_field_titre("Type",$_SERVER["PHP_SELF"],'','',$param,'',$sortfield,$sortorder); -print_liste_field_titre("Duration",$_SERVER["PHP_SELF"],'','',$pram,'align="right"',$sortfield,$sortorder); +print_liste_field_titre("NbUseDaysCPShort",$_SERVER["PHP_SELF"],'','',$pram,'align="right"',$sortfield,$sortorder); 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); @@ -536,7 +536,7 @@ if (! empty($holiday->holiday)) print ''; print ''; print ''; print ''; diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 3c834cc57cd..55ba6a1d91d 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -39,6 +39,10 @@ TypeOfLeaveId=Type of leave ID TypeOfLeaveCode=Type of leave code TypeOfLeaveLabel=Type of leave label NbUseDaysCP=Number of days of vacation consumed +NbUseDaysCPShort=Days consumed +NbUseDaysCPShortInMonth=Days consumed in month +DateStartInMonth=Start date in month +DateEndInMonth=End date in month EditCP=Edit DeleteCP=Delete ActionRefuseCP=Refuse diff --git a/htdocs/langs/fr_FR/holiday.lang b/htdocs/langs/fr_FR/holiday.lang index a44463d0d1b..e1a3b46bcf1 100644 --- a/htdocs/langs/fr_FR/holiday.lang +++ b/htdocs/langs/fr_FR/holiday.lang @@ -31,6 +31,10 @@ InfosWorkflowCP=Informations du workflow RequestByCP=Demandée par TitreRequestCP=Demande de congés NbUseDaysCP=Nombre de jours de congés consommés +NbUseDaysCPShort=Jours consommés +NbUseDaysCPShortInMonth=Jours consommés dans le mois +DateStartInMonth=Start date in month +DateEndInMonth=End date in month EditCP=Modifier DeleteCP=Supprimer ActionRefuseCP=Refuser From 2fd212a5604e06acd17aca37d479b36f27f576e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Mar 2018 13:42:59 +0100 Subject: [PATCH 44/50] NEW Report a list of leave requests for a month --- htdocs/holiday/month_report.php | 195 ++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 htdocs/holiday/month_report.php diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php new file mode 100644 index 00000000000..9400de3623b --- /dev/null +++ b/htdocs/holiday/month_report.php @@ -0,0 +1,195 @@ + + * Copyright (C) 2011 François Legastelois + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file month_report.php + * \ingroup holiday + * \brief Monthly report of leave requests. + */ + +require('../main.inc.php'); +require_once(DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'); +require_once(DOL_DOCUMENT_ROOT.'/user/class/user.class.php'); +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + +$langs->loadLangs(array("holiday")); + +// Security check +$socid=0; +if ($user->societe_id > 0) // Protection if external user +{ + //$socid = $user->societe_id; + accessforbidden(); +} +$result = restrictedArea($user, 'holiday', $id, ''); + + + +/* + * View + */ + +$holidaystatic = new Holiday($db); + +$listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon")); + + +llxHeader('', $langs->trans('CPTitreMenu')); + +print_fiche_titre($langs->trans('MenuReportMonth')); + +$html = new Form($db); +$formother = new FormOther($db); + + +// Selection filter +print '
'; + +print '' . "\n"; + +$search_month = GETPOST("remonth",'int')?GETPOST("remonth",'int'):date("m", time()); +$search_year = GETPOST("reyear",'int')?GETPOST("reyear",'int'):date("Y", time()); + +$month_year = sprintf("%02d",$search_month).'-'.sprintf("%04d",$search_year); +$year_month = sprintf("%04d",$search_year).'-'.sprintf("%02d",$search_month); + +print $formother->select_month($search_month,'remonth'); + +print $formother->select_year($search_year,'reyear'); + +print ''; + +print ''; + + +$sql = "SELECT cp.rowid, cp.fk_user, cp.date_debut, cp.date_fin, ct.label, cp.description, cp.halfday"; +$sql .= " FROM ".MAIN_DB_PREFIX."holiday cp"; +$sql .= " LEFT JOIN llx_user u ON cp.fk_user = u.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_holiday_types ct ON cp.fk_type = ct.rowid"; +$sql .= " WHERE cp.rowid > 0"; +$sql .= " AND cp.statut = 3"; // Approved +$sql .= " AND (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')"; +$sql .= " ORDER BY u.lastname, cp.date_debut"; + +$resql = $db->query($sql); +if (empty($resql)) +{ + dol_print_error($db); + exit; +} + +$num = $db->num_rows($resql); + +print '
'; + + +print '
'.$langs->trans("User").''; @@ -1133,6 +1134,7 @@ else print '
'.$langs->trans('NbUseDaysCP').''.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).'
'; - print $holidaystatic->getNomUrl(1); + print $holidaystatic->getNomUrl(1, 1); print ''.dol_print_date($date,'day').''.$userstatic->getNomUrl(-1, 'leave').'
'; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +if ($num == 0) +{ + print ''; +} +else +{ + while ($obj = $db->fetch_object($resql)) + { + $user = new User($db); + $user->fetch($obj->fk_user); + + $date_start = $db->jdate($obj->date_debut, true); + $date_end = $db->jdate($obj->date_fin, true); + + $tmpstart = dol_getdate($date_start); + $tmpend = dol_getdate($date_end); + + $starthalfday=($obj->halfday == -1 || $obj->halfday == 2)?'afternoon':'morning'; + $endhalfday=($obj->halfday == 1 || $obj->halfday == 2)?'morning':'afternoon'; + + $halfdayinmonth = $obj->halfday; + $starthalfdayinmonth = $starthalfday; + $endhalfdayinmonth = $endhalfday; + + //0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning + + // Set date_start_gmt and date_end_gmt that are date to show for the selected month + $date_start_inmonth = $db->jdate($obj->date_debut, true); + $date_end_inmonth = $db->jdate($obj->date_fin, true); + if ($tmpstart['year'] < $search_year || $tmpstart['mon'] < $search_month) + { + $date_start_inmonth = dol_get_first_day($search_year, $search_month, true); + $starthalfdayinmonth = 'morning'; + if ($halfdayinmonth == 2) $halfdayinmonth=1; + if ($halfdayinmonth == -1) $halfdayinmonth=0; + } + if ($tmpend['year'] > $search_year || $tmpend['mon'] > $search_month) + { + $date_end_inmonth = dol_get_last_day($search_year, $search_month, true) - ((24 * 3600) - 1); + $endhalfdayinmonth = 'afternoon'; + if ($halfdayinmonth == 2) $halfdayinmonth=-1; + if ($halfdayinmonth == 1) $halfdayinmonth=0; + } + + // Leave request + $holidaystatic->id=$obj->rowid; + $holidaystatic->ref=$obj->rowid; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + +} +print '
' . $langs->trans('Ref') . '' . $langs->trans('Employee') . '' . $langs->trans('Type') . '' . $langs->trans('DateDebCP') . '' . $langs->trans('DateFinCP') . '' . $langs->trans('NbUseDaysCPShort') . '' . $langs->trans('DateStartInMonth') . '' . $langs->trans('DateEndInMonth') . '' . $langs->trans('NbUseDaysCPShortInMonth') . '' . $langs->trans('DescCP') . '
'.$langs->trans('None').'
'; + print $holidaystatic->getNomUrl(1, 1); + print '' . $user->getFullName($langs) . '' . $obj->label . '' . dol_print_date($obj->date_debut, 'day'); + print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; + print '' . dol_print_date($obj->date_fin, 'day'); + print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; + print '' . num_open_day($date_start, $date_end, 0, 1, $obj->halfday) . '' . dol_print_date($date_start_inmonth, 'day'); + print ' ('.$langs->trans($listhalfday[$starthalfdayinmonth]).')'; + print '' . dol_print_date($date_end_inmonth, 'day'); + print ' ('.$langs->trans($listhalfday[$endhalfdayinmonth]).')'; + print '' . num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth) . '' . dol_escape_htmltag(dolGetFirstLineOfText($obj->description)) . '
'; +print '
'; + +// Fin de page +$db->close(); +llxFooter(); From 76cceb59a90277cc9d72c846458b1d6f292a9b99 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Mar 2018 13:54:52 +0100 Subject: [PATCH 45/50] Nead perm to read all for monthly report of leave requests --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index dafa202557f..039150409a9 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1377,7 +1377,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=4&leftmenu=hrm", $langs->trans("CancelCP"), 2, $user->rights->holiday->read); if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=5&leftmenu=hrm", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read); $newmenu->add("/holiday/define_holiday.php?action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->read); - $newmenu->add("/holiday/month_report.php", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->read); + $newmenu->add("/holiday/month_report.php", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->read_all); $newmenu->add("/holiday/view_log.php?action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday); } From ca7122fe281ccaefc712136986ac646ebf23719a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Mar 2018 14:30:02 +0100 Subject: [PATCH 46/50] Fix responsive --- htdocs/holiday/month_report.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 9400de3623b..4215bade305 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -96,9 +96,12 @@ if (empty($resql)) $num = $db->num_rows($resql); +print '
'; + + print '
'; - +print '
'; print ''; print ''; From a12f884a7f1816d1c88cf5c1ff51ea6b92aba077 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Mar 2018 14:31:33 +0100 Subject: [PATCH 47/50] FIX Permission in list of holiday --- htdocs/holiday/list.php | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 32a8632d2b9..bf5a7906f7a 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -48,6 +48,8 @@ $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectl $backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print') +$childis = $user->getAllChildIds(1); + // Security check $socid=0; if ($user->societe_id > 0) // Protection if external user @@ -56,6 +58,7 @@ if ($user->societe_id > 0) // Protection if external user accessforbidden(); } $result = restrictedArea($user, 'holiday', $id, ''); +$id = GETPOST('id','int'); // Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; @@ -80,7 +83,6 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search if (! $sortfield) $sortfield="cp.rowid"; 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','alpha'); @@ -411,22 +413,29 @@ $formother->select_year($search_year_create,'search_year_create',1, $min_year, 0 print ''; // User -if ($user->rights->holiday->write_all) +$disabled=0; +// If into the tab holiday of a user ($id is set in such a case) +if ($id && ! GETPOSTISSET('search_employee')) +{ + $search_employee=$id; + $disabled=1; +} +if (! empty($user->rights->holiday->read_all)) // Can see all { print ''; } else { //print ''; print ''; } // Approve -if($user->rights->holiday->write_all) +if ($user->rights->holiday->read_all) { print '\n"; $listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon")); + +// If we ask a dedicated card and not allow to see it, we forc on user. +if ($id && empty($user->rights->holiday->read_all) && ! in_array($id, $childis)) +{ + print ''; + $result = 0; +} // Lines -if (! empty($holiday->holiday)) +elseif (! empty($holiday->holiday)) { $userstatic = new User($db); $approbatorstatic = new User($db); From 8214e7bb42e042d06f55eb77b2c19ec2e8df17c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Mar 2018 11:45:57 +0100 Subject: [PATCH 48/50] Fix missing security restiction test --- htdocs/holiday/list.php | 9 +++++++++ htdocs/modulebuilder/template/myobject_list.php | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 8769046b03a..35c386387a8 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -48,6 +48,15 @@ $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectl $backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print') +// Security check +$socid=0; +if ($user->societe_id > 0) // Protection if external user +{ + //$socid = $user->societe_id; + accessforbidden(); +} +$result = restrictedArea($user, 'holiday', $id, ''); + // Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index ed8e58e1c12..79d35dddcad 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -95,14 +95,14 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search if (! $sortfield) $sortfield="t.".key($object->fields); // Set here default search field. By default 1st field in definition. if (! $sortorder) $sortorder="ASC"; -// Protection if external user +// Security check $socid=0; -if ($user->societe_id > 0) +if ($user->societe_id > 0) // Protection if external user { //$socid = $user->societe_id; accessforbidden(); } -//$result = restrictedArea($user, 'mymodule', $id,''); +//$result = restrictedArea($user, 'mymodule', $id, ''); // Initialize array of search criterias $search_all=trim(GETPOST("search_all",'alpha')); From 78b4492f1e2afb2226c94a81d4d3065ec7d09475 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Mar 2018 14:31:33 +0100 Subject: [PATCH 49/50] FIX Permission in list of holiday Conflicts: htdocs/holiday/list.php --- htdocs/holiday/list.php | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 35c386387a8..63d9527c132 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -48,6 +48,8 @@ $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectl $backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print') +$childis = $user->getAllChildIds(1); + // Security check $socid=0; if ($user->societe_id > 0) // Protection if external user @@ -56,6 +58,7 @@ if ($user->societe_id > 0) // Protection if external user accessforbidden(); } $result = restrictedArea($user, 'holiday', $id, ''); +$id = GETPOST('id','int'); // Load variable for pagination $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; @@ -80,7 +83,6 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search if (! $sortfield) $sortfield="cp.rowid"; 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','alpha'); @@ -413,25 +415,30 @@ $morefilter = 'AND employee = 1'; if (! empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = ''; // User -if (! empty($user->rights->holiday->write_all)) +$disabled=0; +// If into the tab holiday of a user ($id is set in such a case) +if ($id && ! GETPOSTISSET('search_employee')) { - $defaultuserid = -1; - if (GETPOSTISSET('search_employee')) $defaultuserid=GETPOST('search_employee','int'); + $search_employee=$id; + $disabled=1; +} +if (! empty($user->rights->holiday->read_all)) // Can see all +{ + if (GETPOSTISSET('search_employee')) $search_employee=GETPOST('search_employee','int'); print ''; } else { - $defaultuserid = $user->id; - if (GETPOSTISSET('search_employee')) $defaultuserid=GETPOST('search_employee','int'); + if (GETPOSTISSET('search_employee')) $search_employee=GETPOST('search_employee','int'); print ''; } // Approve -if($user->rights->holiday->write_all) +if ($user->rights->holiday->read_all) { print '\n"; $listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->trans("Afternoon")); + +// If we ask a dedicated card and not allow to see it, we forc on user. +if ($id && empty($user->rights->holiday->read_all) && ! in_array($id, $childids)) +{ + $langs->load("errors"); + print ''; + $result = 0; +} // Lines -if (! empty($holiday->holiday)) +elseif (! empty($holiday->holiday)) { $userstatic = new User($db); $approbatorstatic = new User($db); From d647bf23d6c718d7c10497d40ba39dca5f3059ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Mar 2018 15:05:36 +0100 Subject: [PATCH 50/50] Css --- htdocs/holiday/month_report.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 4215bade305..cc094046316 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -114,7 +114,7 @@ print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; if ($num == 0) @@ -185,7 +185,7 @@ else print ' ('.$langs->trans($listhalfday[$endhalfdayinmonth]).')'; print ''; print ''; - print ''; + print ''; print ''; }
'; - print $form->select_dolusers($search_employee,"search_employee",1,"",0,'','',0,0,0,'',0,'','maxwidth200'); + print $form->select_dolusers($search_employee,"search_employee",1,"",$disabled,'','',0,0,0,'',0,'','maxwidth200'); print ' '; - print $form->select_dolusers($user->id,"search_employee",1,"",1,'','',0,0,0,'',0,'','maxwidth200'); + print $form->select_dolusers($search_employee,"search_employee",1,"",$disabled,'hierarchyme','',0,0,0,'',0,'','maxwidth200'); print ''; @@ -499,8 +508,15 @@ print "
'.$langs->trans("NotEnoughPermission").'
'; - print $form->select_dolusers($defaultuserid, "search_employee", 1, "", 0, '', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); + print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, '', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); print ''; - print $form->select_dolusers($defaultuserid, "search_employee", 1, "", 0, 'hierarchyme', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); + print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, 'hierarchyme', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); print ''; @@ -504,8 +511,16 @@ print "
'.$langs->trans("NotEnoughPermissions").'
' . $langs->trans('NbUseDaysCPShort') . '' . $langs->trans('DateStartInMonth') . '' . $langs->trans('DateEndInMonth') . '' . $langs->trans('NbUseDaysCPShortInMonth') . '' . $langs->trans('DescCP') . '' . $langs->trans('DescCP') . '
' . num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth) . '' . dol_escape_htmltag(dolGetFirstLineOfText($obj->description)) . '' . dol_escape_htmltag(dolGetFirstLineOfText($obj->description)) . '