Merge pull request #21975 from frederic34/userbankaccount
enhance bank display for user
This commit is contained in:
commit
febe70fad0
@ -1,6 +1,7 @@
|
|||||||
# Dolibarr language file - Source file is en_US - holiday
|
# Dolibarr language file - Source file is en_US - holiday
|
||||||
HRM=HRM
|
HRM=HRM
|
||||||
Holidays=Leave
|
Holidays=Leaves
|
||||||
|
Holiday=Leave
|
||||||
CPTitreMenu=Leave
|
CPTitreMenu=Leave
|
||||||
MenuReportMonth=Monthly statement
|
MenuReportMonth=Monthly statement
|
||||||
MenuAddCP=New leave request
|
MenuAddCP=New leave request
|
||||||
@ -147,4 +148,4 @@ XIsAUsualNonWorkingDay=%s is usualy a NON working day
|
|||||||
BlockHolidayIfNegative=Block if balance negative
|
BlockHolidayIfNegative=Block if balance negative
|
||||||
LeaveRequestCreationBlockedBecauseBalanceIsNegative=The creation of this leave request is blocked because your balance is 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
|
ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted=Leave request %s must be draft, canceled or refused to be deleted
|
||||||
HolidayQtyNotModified=Balance of remaining days for %s has not been changed
|
HolidayQtyNotModified=Balance of remaining days for %s has not been changed
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
# Dolibarr language file - Source file is en_US - holiday
|
# Dolibarr language file - Source file is en_US - holiday
|
||||||
HRM=GRH
|
HRM=GRH
|
||||||
Holidays=Congés
|
Holidays=Congés
|
||||||
|
Holiday=Congé
|
||||||
CPTitreMenu=Demande de congés
|
CPTitreMenu=Demande de congés
|
||||||
MenuReportMonth=État mensuel
|
MenuReportMonth=État mensuel
|
||||||
MenuAddCP=Créer demande de congés
|
MenuAddCP=Créer demande de congés
|
||||||
|
|||||||
@ -33,13 +33,15 @@ 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/bank.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.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.'/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 (isModEnabled('holiday')) {
|
if (isModEnabled('holiday')) {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
|
||||||
}
|
}
|
||||||
if (isModEnabled('expensereport')) {
|
if (isModEnabled('expensereport')) {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
|
||||||
}
|
}
|
||||||
if (!empty($conf->salaries->enabled)) {
|
if (isModEnabled('salaries')) {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
|
||||||
}
|
}
|
||||||
@ -122,6 +124,10 @@ if ($action == 'add' && !$cancel && $permissiontoaddbankaccount) {
|
|||||||
$account->proprio = GETPOST('proprio', 'alpha');
|
$account->proprio = GETPOST('proprio', 'alpha');
|
||||||
$account->owner_address = GETPOST('owner_address', '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);
|
$result = $account->create($user);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
@ -192,6 +198,10 @@ if ($action == 'update' && !$cancel && $permissiontoaddbankaccount) {
|
|||||||
$account->proprio = GETPOST('proprio', 'alpha');
|
$account->proprio = GETPOST('proprio', 'alpha');
|
||||||
$account->owner_address = GETPOST('owner_address', '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);
|
$result = $account->update($user);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
@ -274,6 +284,7 @@ if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
$formcompany = new FormCompany($db);
|
||||||
|
|
||||||
$childids = $user->getAllChildIds(1);
|
$childids = $user->getAllChildIds(1);
|
||||||
|
|
||||||
@ -285,14 +296,42 @@ llxHeader('', $title, $help_url);
|
|||||||
$head = user_prepare_head($object);
|
$head = user_prepare_head($object);
|
||||||
|
|
||||||
if ($id && $bankid && $action == 'edit' && ($user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write)) {
|
if ($id && $bankid && $action == 'edit' && ($user->rights->user->user->creer || $user->rights->hrm->write_personal_information->write)) {
|
||||||
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
|
if ($conf->use_javascript_ajax) {
|
||||||
|
print "\n<script>";
|
||||||
|
print 'jQuery(document).ready(function () {
|
||||||
|
jQuery("#type").change(function() {
|
||||||
|
document.formbank.action.value="edit";
|
||||||
|
document.formbank.submit();
|
||||||
|
});
|
||||||
|
jQuery("#selectaccount_country_id").change(function() {
|
||||||
|
document.formbank.action.value="edit";
|
||||||
|
document.formbank.submit();
|
||||||
|
});
|
||||||
|
})';
|
||||||
|
print "</script>\n";
|
||||||
|
}
|
||||||
|
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" name="formbank" method="post">';
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="action" value="update">';
|
print '<input type="hidden" name="action" value="update">';
|
||||||
print '<input type="hidden" name="id" value="'.GETPOST("id", 'int').'">';
|
print '<input type="hidden" name="id" value="'.GETPOST("id", 'int').'">';
|
||||||
print '<input type="hidden" name="bankid" value="'.$bankid.'">';
|
print '<input type="hidden" name="bankid" value="'.$bankid.'">';
|
||||||
}
|
}
|
||||||
if ($id && $action == 'create' && $user->rights->user->user->creer) {
|
if ($id && $action == 'create' && $user->rights->user->user->creer) {
|
||||||
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
|
if ($conf->use_javascript_ajax) {
|
||||||
|
print "\n<script>";
|
||||||
|
print 'jQuery(document).ready(function () {
|
||||||
|
jQuery("#type").change(function() {
|
||||||
|
document.formbank.action.value="create";
|
||||||
|
document.formbank.submit();
|
||||||
|
});
|
||||||
|
jQuery("#selectaccount_country_id").change(function() {
|
||||||
|
document.formbank.action.value="create";
|
||||||
|
document.formbank.submit();
|
||||||
|
});
|
||||||
|
})';
|
||||||
|
print "</script>\n";
|
||||||
|
}
|
||||||
|
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" name="formbank" method="post">';
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="action" value="add">';
|
print '<input type="hidden" name="action" value="add">';
|
||||||
print '<input type="hidden" name="bankid" value="'.$bankid.'">';
|
print '<input type="hidden" name="bankid" value="'.$bankid.'">';
|
||||||
@ -772,6 +811,7 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac
|
|||||||
print_liste_field_titre("RIB");
|
print_liste_field_titre("RIB");
|
||||||
print_liste_field_titre("IBAN");
|
print_liste_field_titre("IBAN");
|
||||||
print_liste_field_titre("BIC");
|
print_liste_field_titre("BIC");
|
||||||
|
print_liste_field_titre("Currency");
|
||||||
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', '', '', 'maxwidthsearch ');
|
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', '', '', 'maxwidthsearch ');
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
@ -806,7 +846,7 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac
|
|||||||
print $string;
|
print $string;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
// IBAN
|
// IBAN
|
||||||
print '<td>'.$account->iban;
|
print '<td>'.getIbanHumanReadable($account);
|
||||||
if (!empty($account->iban)) {
|
if (!empty($account->iban)) {
|
||||||
if (!checkIbanForAccount($account)) {
|
if (!checkIbanForAccount($account)) {
|
||||||
print ' '.img_picto($langs->trans("IbanNotValid"), 'warning');
|
print ' '.img_picto($langs->trans("IbanNotValid"), 'warning');
|
||||||
@ -822,6 +862,9 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac
|
|||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
|
// Currency
|
||||||
|
print '<td>'.$account->currency_code.'</td>';
|
||||||
|
|
||||||
// Edit/Delete
|
// Edit/Delete
|
||||||
print '<td class="right nowraponall">';
|
print '<td class="right nowraponall">';
|
||||||
if ($permissiontoaddbankaccount) {
|
if ($permissiontoaddbankaccount) {
|
||||||
@ -864,6 +907,47 @@ if ($id && ($action == 'edit' || $action == 'create') && $user->rights->user->us
|
|||||||
print '<tr><td class="fieldrequired">'.$langs->trans("BankName").'</td>';
|
print '<tr><td class="fieldrequired">'.$langs->trans("BankName").'</td>';
|
||||||
print '<td><input size="30" type="text" name="bank" value="'.$account->bank.'"></td></tr>';
|
print '<td><input size="30" type="text" name="bank" value="'.$account->bank.'"></td></tr>';
|
||||||
|
|
||||||
|
// Currency
|
||||||
|
print '<tr><td class="fieldrequired">'.$langs->trans("Currency");
|
||||||
|
print '<input type="hidden" value="'.$account->currency_code.'">';
|
||||||
|
print '</td>';
|
||||||
|
print '<td class="maxwidth200onsmartphone">';
|
||||||
|
$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 '</td></tr>';
|
||||||
|
|
||||||
|
// 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 '<tr><td class="fieldrequired">'.$langs->trans("Country").'</td>';
|
||||||
|
print '<td class="maxwidth200onsmartphone">';
|
||||||
|
print img_picto('', 'country', 'class="pictofixedwidth"').$form->select_country($selectedcode, 'account_country_id');
|
||||||
|
if ($user->admin) {
|
||||||
|
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||||
|
}
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// State
|
||||||
|
print '<tr><td>'.$langs->trans('State').'</td><td class="maxwidth200onsmartphone">';
|
||||||
|
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 '</td></tr>';
|
||||||
|
|
||||||
// Show fields of bank account
|
// Show fields of bank account
|
||||||
foreach ($account->getFieldsToShow() as $val) {
|
foreach ($account->getFieldsToShow() as $val) {
|
||||||
if ($val == 'BankCode') {
|
if ($val == 'BankCode') {
|
||||||
|
|||||||
@ -134,6 +134,9 @@ class UserBankAccount extends Account
|
|||||||
$sql .= ",domiciliation='".$this->db->escape($this->domiciliation)."'";
|
$sql .= ",domiciliation='".$this->db->escape($this->domiciliation)."'";
|
||||||
$sql .= ",proprio = '".$this->db->escape($this->proprio)."'";
|
$sql .= ",proprio = '".$this->db->escape($this->proprio)."'";
|
||||||
$sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'";
|
$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) != '') {
|
if (trim($this->label) != '') {
|
||||||
$sql .= ",label = '".$this->db->escape($this->label)."'";
|
$sql .= ",label = '".$this->db->escape($this->label)."'";
|
||||||
@ -165,17 +168,23 @@ class UserBankAccount extends Account
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT rowid, fk_user, entity, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
|
$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 .= " owner_address, label, datec, tms as datem";
|
$sql .= ", ur.owner_address, ur.label, ur.datec, ur.tms as datem";
|
||||||
$sql .= " FROM ".$this->db->prefix()."user_rib";
|
$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 '.$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) {
|
if ($id) {
|
||||||
$sql .= " WHERE rowid = ".((int) $id);
|
$sql .= " WHERE ur.rowid = ".((int) $id);
|
||||||
}
|
}
|
||||||
if ($ref) {
|
if ($ref) {
|
||||||
$sql .= " WHERE label = '".$this->db->escape($ref)."'";
|
$sql .= " WHERE ur.label = '".$this->db->escape($ref)."'";
|
||||||
}
|
}
|
||||||
if ($userid) {
|
if ($userid) {
|
||||||
$sql .= " WHERE fk_user = ".((int) $userid);
|
$sql .= " WHERE ur.fk_user = ".((int) $userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -198,6 +207,15 @@ class UserBankAccount extends Account
|
|||||||
$this->label = $obj->label;
|
$this->label = $obj->label;
|
||||||
$this->datec = $this->db->jdate($obj->datec);
|
$this->datec = $this->db->jdate($obj->datec);
|
||||||
$this->datem = $this->db->jdate($obj->datem);
|
$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);
|
$this->db->free($resql);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user