39 global $db, $langs, $conf;
43 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/card.php?id='.$object->id;
44 $head[$h][1] = $langs->trans(
"BankAccount");
45 $head[$h][2] =
'bankname';
48 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/bankentries_list.php?id=".$object->id;
49 $head[$h][1] = $langs->trans(
"BankTransactions");
50 $head[$h][2] =
'journal';
55 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/treso.php?account=".$object->id;
56 $head[$h][1] = $langs->trans(
"PlannedTransactions");
57 $head[$h][2] =
'cash';
61 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/annuel.php?account=".$object->id;
62 $head[$h][1] = $langs->trans(
"IOMonthlyReporting");
63 $head[$h][2] =
'annual';
66 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/graph.php?account=".$object->id;
67 $head[$h][1] = $langs->trans(
"Graph");
68 $head[$h][2] =
'graph';
75 $sql =
"SELECT COUNT(DISTINCT(b.num_releve)) as nb";
76 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b";
77 $sql .=
" WHERE b.fk_account = ".((int) $object->id);
79 $resql = $db->query($sql);
81 $obj = $db->fetch_object($resql);
83 $nbReceipts = $obj->nb;
88 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/releve.php?account=".((int) $object->id);
89 $head[$h][1] = $langs->trans(
"AccountStatements");
90 if (($nbReceipts) > 0) {
91 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbReceipts).
'</span>';
93 $head[$h][2] =
'statement';
98 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
99 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
101 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
102 $nbLinks =
Link::count($db, $object->element, $object->id);
103 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/document.php?account=".$object->id;
104 $head[$h][1] = $langs->trans(
"Documents");
105 if (($nbFiles + $nbLinks) > 0) {
106 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
108 $head[$h][2] =
'document';
134 global $langs, $conf, $db;
136 $langs->loadLangs(array(
"compta"));
139 $extrafields->fetch_name_optionals_label(
'bank_account');
140 $extrafields->fetch_name_optionals_label(
'bank');
145 $head[$h][0] = DOL_URL_ROOT.
'/admin/bank.php';
146 $head[$h][1] = $langs->trans(
"Miscellaneous");
147 $head[$h][2] =
'general';
150 $head[$h][0] = DOL_URL_ROOT.
'/admin/chequereceipts.php';
151 $head[$h][1] = $langs->trans(
"CheckReceiptShort");
152 $head[$h][2] =
'checkreceipts';
162 $head[$h][0] = DOL_URL_ROOT.
'/admin/bank_extrafields.php';
163 $head[$h][1] = $langs->trans(
"ExtraFields").
' ('.$langs->trans(
"BankAccounts").
')';
164 $nbExtrafields = $extrafields->attributes[
'bank_account'][
'count'];
165 if ($nbExtrafields > 0) {
166 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
168 $head[$h][2] =
'attributes';
171 $head[$h][0] = DOL_URL_ROOT.
'/admin/bankline_extrafields.php';
172 $head[$h][1] = $langs->trans(
"ExtraFields").
' ('.$langs->trans(
"BankTransactions").
')';
173 $nbExtrafields = $extrafields->attributes[
'bank'][
'count'];
174 if ($nbExtrafields > 0) {
175 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
177 $head[$h][2] =
'bankline_extrafields';
196 global $langs, $conf, $db;
200 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/releve.php?account='.$object->id.
'&num='.$num;
201 $head[$h][1] = $langs->trans(
"AccountStatement");
202 $head[$h][2] =
'statement';
206 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
207 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
209 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
210 $nbLinks =
Link::count($db, $object->element, $object->id);
212 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/account_statement_document.php?account=".$object->id.
"&num=".$num;
213 $head[$h][1] = $langs->trans(
"Documents");
214 if (($nbFiles + $nbLinks) > 0) {
215 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
217 $head[$h][2] =
'document';
236 global $db, $langs, $conf;
241 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/various_payment/card.php?id='.$object->id;
242 $head[$h][1] = $langs->trans(
"VariousPayment");
243 $head[$h][2] =
'card';
252 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
253 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
255 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
256 $nbLinks =
Link::count($db, $object->element, $object->id);
257 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/various_payment/document.php?id='.$object->id;
258 $head[$h][1] = $langs->trans(
'Documents');
259 if (($nbFiles + $nbLinks) > 0) {
260 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
262 $head[$h][2] =
'documents';
265 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/various_payment/info.php?id='.$object->id;
266 $head[$h][1] = $langs->trans(
"Info");
267 $head[$h][2] =
'info';
284 if ($account ==
null && $swift ==
null) {
286 } elseif ($swift ==
null) {
287 $swift = $account->bic;
289 if (preg_match(
"/^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$/", $swift)) {
305 if ($account ==
null && $ibantocheck ==
null) {
307 } elseif ($ibantocheck ==
null) {
308 $ibantocheck = ($account->iban ? $account->iban : $account->iban_prefix);
310 require_once DOL_DOCUMENT_ROOT.
'/includes/php-iban/oophp-iban.php';
312 $iban =
new PHP_IBAN\IBAN($ibantocheck);
313 $check = $iban->Verify();
330 if ($account->getCountryCode() ==
'FR') {
331 require_once DOL_DOCUMENT_ROOT.
'/includes/php-iban/oophp-iban.php';
332 $ibantoprint = preg_replace(
'/[^a-zA-Z0-9]/',
'', empty($account->iban) ?
'' : $account->iban);
333 $iban =
new PHP_IBAN\IBAN($ibantoprint);
334 return $iban->HumanFormat();
337 return $account->iban;
348 $country_code = $account->getCountryCode();
353 if (empty($account->number)) {
354 $account->number = $account->num_compte;
356 if (empty($account->cle)) {
357 $account->cle = $account->cle_rib;
360 dol_syslog(
"bank.lib::checkBanForAccount account->code_banque=".$account->code_banque.
" account->code_guichet=".$account->code_guichet.
" account->number=".$account->number.
" account->cle=".$account->cle.
" account->iban=".$account->iban.
" country_code=".$country_code, LOG_DEBUG);
362 if ($country_code ==
'FR') {
363 $coef = array(62, 34, 3);
365 $rib = strtolower(trim($account->code_banque).trim($account->code_guichet).trim($account->number).trim($account->cle));
368 $rib = strtr($rib,
"abcdefghijklmnopqrstuvwxyz",
"12345678912345678923456789");
372 for ($i = 0, $s = 0; $i < 3; $i++) {
373 $code = substr($rib, 7 * $i, 7);
374 $s += ((int) $code) * $coef[$i];
377 $cle_rib = 97 - ($s % 97);
378 if ($cle_rib == $account->cle) {
384 if ($country_code ==
'BE') {
387 if ($country_code ==
'ES') {
388 $CCC = strtolower(trim($account->number));
389 $rib = strtolower(trim($account->code_banque).trim($account->code_guichet));
390 $cle_rib = strtolower(
checkES($rib, $CCC));
391 if ($cle_rib == strtolower($account->cle)) {
396 if ($country_code ==
'AU') {
397 if (strlen($account->code_banque) > 7) {
399 } elseif (strlen($account->code_banque) < 6) {
409 if (empty($account->number)) {
427 if (empty($IentOfi) || empty($InumCta) || strlen($IentOfi) != 8 || strlen($InumCta) != 10) {
432 $ccc = $IentOfi.$InumCta;
433 $numbers =
"1234567890";
437 while ($i <= strlen($ccc) - 1) {
438 if (strpos($numbers, substr($ccc, $i, 1)) ===
false) {
445 $values = array(1, 2, 4, 8, 5, 10, 9, 7, 3, 6);
448 for ($i = 2; $i < 10; $i++) {
449 $sum += $values[$i] * substr($IentOfi, $i - 2, 1);
452 $key = 11 - $sum % 11;
465 for ($i = 0; $i < 11; $i++) {
466 $sum += $values[$i] * (int) substr($InumCta, $i, 1);
469 $key = 11 - $sum % 11;
checkES($IentOfi, $InumCta)
Returns the key for Spanish Banks Accounts.
checkSwiftForAccount(Account $account=null, $swift=null)
Check SWIFT informations for a bank account.
checkIbanForAccount(Account $account=null, $ibantocheck=null)
Check IBAN number informations for a bank account.
account_statement_prepare_head($object, $num)
Prepare array with list of tabs.
checkBanForAccount($account)
Check account number informations for a bank account.
getIbanHumanReadable(Account $account)
Returns the iban human readable.
bank_prepare_head(Account $object)
Prepare array with list of tabs.
various_payment_prepare_head($object)
Prepare array with list of tabs.
bank_admin_prepare_head($object)
Prepare array with list of tabs.
Class to manage bank accounts.
const TYPE_CASH
Cash account.
static count($dbs, $objecttype, $objectid)
Return nb of links.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.