39 global $db, $langs, $conf, $user;
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';
71 if ($object->courant !=
Account::TYPE_CASH || !empty($conf->global->BANK_CAN_RECONCILIATE_CASHACCOUNT)) {
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, $user, $db;
137 $extrafields->fetch_name_optionals_label(
'bank_account');
138 $extrafields->fetch_name_optionals_label(
'bank');
143 $head[$h][0] = DOL_URL_ROOT.
'/admin/bank.php';
144 $head[$h][1] = $langs->trans(
"Miscellaneous");
145 $head[$h][2] =
'general';
148 $head[$h][0] = DOL_URL_ROOT.
'/admin/chequereceipts.php';
149 $head[$h][1] = $langs->trans(
"CheckReceiptShort");
150 $head[$h][2] =
'checkreceipts';
160 $head[$h][0] = DOL_URL_ROOT.
'/admin/bank_extrafields.php';
161 $head[$h][1] = $langs->trans(
"ExtraFields").
' ('.$langs->trans(
"BankAccounts").
')';
162 $nbExtrafields = $extrafields->attributes[
'bank_account'][
'count'];
163 if ($nbExtrafields > 0) {
164 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
166 $head[$h][2] =
'attributes';
169 $head[$h][0] = DOL_URL_ROOT.
'/admin/bankline_extrafields.php';
170 $head[$h][1] = $langs->trans(
"ExtraFields").
' ('.$langs->trans(
"BankTransactions").
')';
171 $nbExtrafields = $extrafields->attributes[
'bank'][
'count'];
172 if ($nbExtrafields > 0) {
173 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
175 $head[$h][2] =
'bankline_extrafields';
194 global $langs, $conf, $user, $db;
198 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/releve.php?account='.$object->id.
'&num='.$num;
199 $head[$h][1] = $langs->trans(
"AccountStatement");
200 $head[$h][2] =
'statement';
204 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
205 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
207 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
208 $nbLinks =
Link::count($db, $object->element, $object->id);
210 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/account_statement_document.php?account=".$object->id.
"&num=".$num;
211 $head[$h][1] = $langs->trans(
"Documents");
212 if (($nbFiles + $nbLinks) > 0) {
213 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
215 $head[$h][2] =
'document';
234 global $db, $langs, $conf;
239 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/various_payment/card.php?id='.$object->id;
240 $head[$h][1] = $langs->trans(
"VariousPayment");
241 $head[$h][2] =
'card';
250 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
251 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
253 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
254 $nbLinks =
Link::count($db, $object->element, $object->id);
255 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/various_payment/document.php?id='.$object->id;
256 $head[$h][1] = $langs->trans(
'Documents');
257 if (($nbFiles + $nbLinks) > 0) {
258 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
260 $head[$h][2] =
'documents';
263 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/various_payment/info.php?id='.$object->id;
264 $head[$h][1] = $langs->trans(
"Info");
265 $head[$h][2] =
'info';
281 $swift = $account->bic;
282 if (preg_match(
"/^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$/", $swift)) {
297 require_once DOL_DOCUMENT_ROOT.
'/includes/php-iban/oophp-iban.php';
299 $ibantocheck = ($account->iban ? $account->iban : $account->iban_prefix);
301 $iban =
new PHP_IBAN\IBAN($ibantocheck);
302 $check = $iban->Verify();
319 if ($account->getCountryCode() ==
'FR') {
320 require_once DOL_DOCUMENT_ROOT.
'/includes/php-iban/oophp-iban.php';
321 $ibantoprint = preg_replace(
'/[^a-zA-Z0-9]/',
'', empty($account->iban)?
'':$account->iban);
322 $iban =
new PHP_IBAN\IBAN($ibantoprint);
323 return $iban->HumanFormat();
326 return $account->iban;
337 $country_code = $account->getCountryCode();
342 if (empty($account->number)) {
343 $account->number = $account->num_compte;
345 if (empty($account->cle)) {
346 $account->cle = $account->cle_rib;
349 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);
351 if ($country_code ==
'FR') {
352 $coef = array(62, 34, 3);
354 $rib = strtolower(trim($account->code_banque).trim($account->code_guichet).trim($account->number).trim($account->cle));
357 $rib = strtr($rib,
"abcdefghijklmnopqrstuvwxyz",
"12345678912345678923456789");
361 for ($i = 0, $s = 0; $i < 3; $i++) {
362 $code = substr($rib, 7 * $i, 7);
363 $s += ((int) $code) * $coef[$i];
366 $cle_rib = 97 - ($s % 97);
367 if ($cle_rib == $account->cle) {
373 if ($country_code ==
'BE') {
376 if ($country_code ==
'ES') {
377 $CCC = strtolower(trim($account->number));
378 $rib = strtolower(trim($account->code_banque).trim($account->code_guichet));
379 $cle_rib = strtolower(
checkES($rib, $CCC));
380 if ($cle_rib == strtolower($account->cle)) {
385 if ($country_code ==
'AU') {
386 if (strlen($account->code_banque) > 7) {
388 } elseif (strlen($account->code_banque) < 6) {
398 if (empty($account->number)) {
416 if (empty($IentOfi) || empty($InumCta) || strlen($IentOfi) != 8 || strlen($InumCta) != 10) {
421 $ccc = $IentOfi.$InumCta;
422 $numbers =
"1234567890";
426 while ($i <= strlen($ccc) - 1) {
427 if (strpos($numbers, substr($ccc, $i, 1)) ===
false) {
434 $values = array(1, 2, 4, 8, 5, 10, 9, 7, 3, 6);
437 for ($i = 2; $i < 10; $i++) {
438 $sum += $values[$i] * substr($IentOfi, $i - 2, 1);
441 $key = 11 - $sum % 11;
454 for ($i = 0; $i < 11; $i++) {
455 $sum += $values[$i] * (int) substr($InumCta, $i, 1);
458 $key = 11 - $sum % 11;
checkES($IentOfi, $InumCta)
Returns the key for Spanish Banks Accounts.
account_statement_prepare_head($object, $num)
Prepare array with list of tabs.
checkIbanForAccount(Account $account)
Check IBAN number informations for a bank account.
checkBanForAccount($account)
Check account number informations for a bank account.
getIbanHumanReadable(Account $account)
Returns the iban human readable.
checkSwiftForAccount($account)
Check SWIFT informations for a bank account.
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).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.