From ec764595f8614e10c891b582297fecb7797bc545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 29 Aug 2022 16:59:23 +0200 Subject: [PATCH 1/3] enhance bank display for user --- htdocs/langs/en_US/holiday.lang | 5 +- htdocs/langs/fr_FR/holiday.lang | 1 + htdocs/user/bank.php | 90 ++++++++++++++++++++- htdocs/user/class/userbankaccount.class.php | 30 +++++-- 4 files changed, 115 insertions(+), 11 deletions(-) diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 0ab79985ea7..04f47c8428d 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -1,6 +1,7 @@ # Dolibarr language file - Source file is en_US - holiday HRM=HRM -Holidays=Leave +Holidays=Leaves +Holiday=Leave CPTitreMenu=Leave MenuReportMonth=Monthly statement MenuAddCP=New leave request @@ -147,4 +148,4 @@ XIsAUsualNonWorkingDay=%s is usualy a NON working day BlockHolidayIfNegative=Block if balance negative LeaveRequestCreationBlockedBecauseBalanceIsNegative=The creation of this leave request is blocked because your balance is negative ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted=Leave request %s must be draft, canceled or refused to be deleted -HolidayQtyNotModified=Balance of remaining days for %s has not been changed \ No newline at end of file +HolidayQtyNotModified=Balance of remaining days for %s has not been changed diff --git a/htdocs/langs/fr_FR/holiday.lang b/htdocs/langs/fr_FR/holiday.lang index c6671f9f6a3..22720779eaf 100644 --- a/htdocs/langs/fr_FR/holiday.lang +++ b/htdocs/langs/fr_FR/holiday.lang @@ -1,6 +1,7 @@ # Dolibarr language file - Source file is en_US - holiday HRM=GRH Holidays=Congés +Holiday=Congé CPTitreMenu=Demande de congés MenuReportMonth=État mensuel MenuAddCP=Créer demande de congés diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 1b7ca92bbbb..81bf184d391 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -33,6 +33,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; if (!empty($conf->holiday->enabled)) { require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; } @@ -122,6 +124,10 @@ if ($action == 'add' && !$cancel && $permissiontoaddbankaccount) { $account->proprio = GETPOST('proprio', 'alpha'); $account->owner_address = GETPOST('owner_address', 'alpha'); + $account->currency_code = trim(GETPOST("account_currency_code")); + $account->state_id = GETPOST("account_state_id", 'int'); + $account->country_id = GETPOST("account_country_id", 'int'); + $result = $account->create($user); if (!$result) { @@ -192,6 +198,10 @@ if ($action == 'update' && !$cancel && $permissiontoaddbankaccount) { $account->proprio = GETPOST('proprio', 'alpha'); $account->owner_address = GETPOST('owner_address', 'alpha'); + $account->currency_code = trim(GETPOST("account_currency_code")); + $account->state_id = GETPOST("account_state_id", 'int'); + $account->country_id = GETPOST("account_country_id", 'int'); + $result = $account->update($user); if (!$result) { @@ -274,6 +284,7 @@ if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { */ $form = new Form($db); +$formcompany = new FormCompany($db); $childids = $user->getAllChildIds(1); @@ -285,14 +296,42 @@ llxHeader('', $title, $help_url); $head = user_prepare_head($object); if ($id && $bankid && $action == 'edit' && ($user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write)) { - print '
'; + if ($conf->use_javascript_ajax) { + print "\n\n"; + } + print ''; print ''; print ''; print ''; print ''; } if ($id && $action == 'create' && $user->rights->user->user->creer) { - print ''; + if ($conf->use_javascript_ajax) { + print "\n\n"; + } + print ''; print ''; print ''; print ''; @@ -772,6 +811,7 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac print_liste_field_titre("RIB"); print_liste_field_titre("IBAN"); print_liste_field_titre("BIC"); + print_liste_field_titre("Currency"); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', '', '', 'maxwidthsearch '); print "\n"; @@ -806,7 +846,7 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac print $string; print ''; // IBAN - print ''.$account->iban; + print ''.getIbanHumanReadable($account); if (!empty($account->iban)) { if (!checkIbanForAccount($account)) { print ' '.img_picto($langs->trans("IbanNotValid"), 'warning'); @@ -822,6 +862,9 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac } print ''; + // Currency + print ''.$account->currency_code.''; + // Edit/Delete print ''; if ($permissiontoaddbankaccount) { @@ -864,6 +907,47 @@ if ($id && ($action == 'edit' || $action == 'create') && $user->rights->user->us print ''.$langs->trans("BankName").''; print ''; + // Currency + print ''.$langs->trans("Currency"); + print ''; + print ''; + print ''; + $selectedcode = $account->currency_code; + if (!$selectedcode) { + $selectedcode = $conf->currency; + } + print img_picto('', 'multicurrency', 'class="pictofixedwidth"'); + print $form->selectCurrency((GETPOSTISSET("account_currency_code") ? GETPOST("account_currency_code") : $selectedcode), 'account_currency_code'); + print ''; + + // Country + $account->country_id = $account->country_id ? $account->country_id : $mysoc->country_id; + $selectedcode = $account->country_code; + if (GETPOSTISSET("account_country_id")) { + $selectedcode = GETPOST("account_country_id"); + } elseif (empty($selectedcode)) { + $selectedcode = $mysoc->country_code; + } + $account->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules + + print ''.$langs->trans("Country").''; + print ''; + print img_picto('', 'country', 'class="pictofixedwidth"').$form->select_country($selectedcode, 'account_country_id'); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } + print ''; + + // State + print ''.$langs->trans('State').''; + if ($selectedcode) { + print img_picto('', 'state', 'class="pictofixedwidth"'); + print $formcompany->select_state(GETPOSTISSET("account_state_id") ? GETPOST("account_state_id") : $account->state_id, $selectedcode, 'account_state_id'); + } else { + print $countrynotdefined; + } + print ''; + // Show fields of bank account foreach ($account->getFieldsToShow() as $val) { if ($val == 'BankCode') { diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php index 42164ce8b2c..d18f5feae16 100644 --- a/htdocs/user/class/userbankaccount.class.php +++ b/htdocs/user/class/userbankaccount.class.php @@ -134,6 +134,9 @@ class UserBankAccount extends Account $sql .= ",domiciliation='".$this->db->escape($this->domiciliation)."'"; $sql .= ",proprio = '".$this->db->escape($this->proprio)."'"; $sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'"; + $sql .= ",currency_code = '".$this->db->escape($this->currency_code)."'"; + $sql .= ",state_id = ".($this->state_id > 0 ? ((int) $this->state_id) : "null"); + $sql .= ",fk_country = ".($this->country_id > 0 ? ((int) $this->country_id) : "null"); if (trim($this->label) != '') { $sql .= ",label = '".$this->db->escape($this->label)."'"; @@ -165,17 +168,23 @@ class UserBankAccount extends Account return -1; } - $sql = "SELECT rowid, fk_user, entity, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,"; - $sql .= " owner_address, label, datec, tms as datem"; - $sql .= " FROM ".$this->db->prefix()."user_rib"; + $sql = "SELECT ur.rowid, ur.fk_user, ur.entity, ur.bank, ur.number, ur.code_banque, ur.code_guichet, ur.cle_rib, ur.bic, ur.iban_prefix as iban, ur.domiciliation, ur.proprio"; + $sql .= ", ur.owner_address, ur.label, ur.datec, ur.tms as datem"; + $sql .= ', ur.currency_code, ur.state_id, ur.fk_country as country_id'; + $sql .= ', c.code as country_code, c.label as country'; + $sql .= ', d.code_departement as state_code, d.nom as state'; + $sql .= " FROM ".$this->db->prefix()."user_rib as ur"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON ur.fk_country=c.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON ur.state_id=d.rowid'; + if ($id) { - $sql .= " WHERE rowid = ".((int) $id); + $sql .= " WHERE ur.rowid = ".((int) $id); } if ($ref) { - $sql .= " WHERE label = '".$this->db->escape($ref)."'"; + $sql .= " WHERE ur.label = '".$this->db->escape($ref)."'"; } if ($userid) { - $sql .= " WHERE fk_user = ".((int) $userid); + $sql .= " WHERE ur.fk_user = ".((int) $userid); } $resql = $this->db->query($sql); @@ -198,6 +207,15 @@ class UserBankAccount extends Account $this->label = $obj->label; $this->datec = $this->db->jdate($obj->datec); $this->datem = $this->db->jdate($obj->datem); + $this->currency_code = $obj->currency_code; + + $this->state_id = $obj->state_id; + $this->state_code = $obj->state_code; + $this->state = $obj->state; + + $this->country_id = $obj->country_id; + $this->country_code = $obj->country_code; + $this->country = $obj->country; } $this->db->free($resql); From e450d464aa0eef77e41b865c77fb058dc9750144 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Fri, 2 Sep 2022 10:26:30 +0200 Subject: [PATCH 2/3] Update bom_agenda.php --- htdocs/bom/bom_agenda.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index d2c64eea0b6..2e4424bde47 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -17,9 +17,9 @@ */ /** - * \file htdocs/modulebuilder/template/myobject_agenda.php - * \ingroup bom - * \brief Page of MyObject events + * \file htdocs/bom/bom_agenda.php + * \ingroup bom + * \brief Page of BOM events */ // Load Dolibarr environment From a28eb9296fdcb8d245df9e72d26ef18f2680b174 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 2 Sep 2022 11:51:28 +0200 Subject: [PATCH 3/3] Update userbankaccount.class.php --- htdocs/user/class/userbankaccount.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php index d18f5feae16..271609139b1 100644 --- a/htdocs/user/class/userbankaccount.class.php +++ b/htdocs/user/class/userbankaccount.class.php @@ -174,8 +174,8 @@ class UserBankAccount extends Account $sql .= ', c.code as country_code, c.label as country'; $sql .= ', d.code_departement as state_code, d.nom as state'; $sql .= " FROM ".$this->db->prefix()."user_rib as ur"; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON ur.fk_country=c.rowid'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON ur.state_id=d.rowid'; + $sql .= ' LEFT JOIN '.$this->db->prefix().'c_country as c ON ur.fk_country=c.rowid'; + $sql .= ' LEFT JOIN '.$this->db->prefix().'c_departements as d ON ur.state_id=d.rowid'; if ($id) { $sql .= " WHERE ur.rowid = ".((int) $id);