* Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013 Peter Fontaine * Copyright (C) 2015-2016 Marcos GarcĂ­a * Copyright (C) 2015 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 * 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/user/bank.php * \ingroup HRM * \brief BAN tab for users */ require '../main.inc.php'; 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.'/user/class/userbankaccount.class.php'; $langs->load("companies"); $langs->load("commercial"); $langs->load("banks"); $langs->load("bills"); $id = GETPOST('id','int'); $action = GETPOST("action"); // Security check $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; $feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); if ($user->id == $id) $feature2=''; // A user can always read its own card $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); $object = new User($db); if ($id > 0 || ! empty($ref)) { $result = $object->fetch($id, $ref); } /* * Actions */ if ($action == 'update' && ! $_POST["cancel"]) { // Modification $account = new UserBankAccount($db); $account->fetch($id); $account->userid = $object->id; $account->bank = $_POST["bank"]; $account->label = $_POST["label"]; $account->courant = $_POST["courant"]; $account->clos = $_POST["clos"]; $account->code_banque = $_POST["code_banque"]; $account->code_guichet = $_POST["code_guichet"]; $account->number = $_POST["number"]; $account->cle_rib = $_POST["cle_rib"]; $account->bic = $_POST["bic"]; $account->iban = $_POST["iban"]; $account->domiciliation = $_POST["domiciliation"]; $account->proprio = $_POST["proprio"]; $account->owner_address = $_POST["owner_address"]; $result = $account->update($user); if (! $result) { setEventMessages($account->error, $account->errors, 'errors'); $_GET["action"]='edit'; // Force chargement page edition } else { $url=DOL_URL_ROOT.'/user/bank.php?id='.$object->id; header('Location: '.$url); exit; } } /* * View */ $form = new Form($db); llxHeader(); $head = user_prepare_head($object); $account = new UserBankAccount($db); if (! $id) $account->fetch(0,$object->id); else $account->fetch($id); if (empty($account->userid)) $account->userid=$object->id; if ($id && $action == 'edit' && $user->rights->user->user->creer) { print '
'; print ''; print ''; print ''; } if ($id && $action == 'create' && $user->rights->user->user->creer) { print ''; print ''; print ''; } // View if ($id && $action != 'edit') { $title = $langs->trans("User"); dol_fiche_head($head, 'bank', $title, 0, 'user'); $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); print '
'; print '
'; print ''; print ''; print ''; print ''; print ''; // Show fields of bank account foreach ($account->getFieldsToShow() as $val) { if ($val == 'BankCode') { $content = $account->code_banque; } elseif ($val == 'DeskCode') { $content = $account->code_guichet; } elseif ($val == 'BankAccountNumber') { $content = $account->number; } elseif ($val == 'BankAccountNumberKey') { $content = $account->cle_rib; } print ''; print ''; print ''; } print ''; print ''; print ''; print ''; print '\n"; print '\n"; print '\n"; print '
'.$langs->trans("LabelRIB").''.$account->label.'
'.$langs->trans("BankName").''.$account->bank.'
'.$langs->trans($val).''.$content.'
'.$langs->trans("IBAN").''.$account->iban . ' '; if (! empty($account->iban)) { if (! checkIbanForAccount($account)) { print img_picto($langs->trans("IbanNotValid"),'warning'); } else { print img_picto($langs->trans("IbanValid"),'info'); } } print '
'.$langs->trans("BIC").''.$account->bic.' '; if (! empty($account->bic)) { if (! checkSwiftForAccount($account)) { print img_picto($langs->trans("SwiftNotValid"),'warning'); } else { print img_picto($langs->trans("SwiftValid"),'info'); } } print '
'.$langs->trans("BankAccountDomiciliation").''; print $account->domiciliation; print "
'.$langs->trans("BankAccountOwner").''; print $account->proprio; print "
'.$langs->trans("BankAccountOwnerAddress").''; print $account->owner_address; print "
'; // Check BBAN if ($account->label && ! checkBanForAccount($account)) { print '
'.$langs->trans("RIBControlError").'
'; } print "
"; dol_fiche_end(); /* * Barre d'actions */ print '
'; if ($user->rights->user->user->creer) { print ''.$langs->trans("Edit").''; } print '
'; } // Edit if ($id && $action == 'edit' && $user->rights->user->user->creer) { $title = $langs->trans("User"); dol_fiche_head($head, 'bank', $title, 0, 'user'); $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); print '
'; print '
'; print ''; print ''; print ''; print ''; print ''; // Show fields of bank account foreach ($account->getFieldsToShow() as $val) { if ($val == 'BankCode') { $name = 'code_banque'; $size = 8; $content = $account->code_banque; } elseif ($val == 'DeskCode') { $name = 'code_guichet'; $size = 8; $content = $account->code_guichet; } elseif ($val == 'BankAccountNumber') { $name = 'number'; $size = 18; $content = $account->number; } elseif ($val == 'BankAccountNumberKey') { $name = 'cle_rib'; $size = 3; $content = $account->cle_rib; } print ''; print ''; print ''; } // IBAN print ''; print ''; print ''; print ''; print '"; print ''; print ''; print "\n"; print '"; print '
'.$langs->trans("LabelRIB").'
'.$langs->trans("BankName").'
'.$langs->trans($val).'
'.$langs->trans("IBAN").'
'.$langs->trans("BIC").'
'.$langs->trans("BankAccountDomiciliation").''; print '
'.$langs->trans("BankAccountOwner").'
'.$langs->trans("BankAccountOwnerAddress").''; print "
'; print '
'; dol_fiche_end(); print '
'; print ''; print '     '; print ''; print '
'; } llxFooter(); $db->close();