41 global $db, $langs, $conf;
45 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/card.php?id='.
$object->id;
46 $head[$h][1] = $langs->trans(
"BankAccount");
47 $head[$h][2] =
'bankname';
50 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/bankentries_list.php?id=".
$object->id;
51 $head[$h][1] = $langs->trans(
"BankTransactions");
52 $head[$h][2] =
'journal';
57 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/treso.php?account=".
$object->id;
58 $head[$h][1] = $langs->trans(
"PlannedTransactions");
59 $head[$h][2] =
'cash';
63 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/annuel.php?account=".
$object->id;
64 $head[$h][1] = $langs->trans(
"IOMonthlyReporting");
65 $head[$h][2] =
'annual';
68 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/graph.php?account=".
$object->id;
69 $head[$h][1] = $langs->trans(
"Graph");
70 $head[$h][2] =
'graph';
77 $sql =
"SELECT COUNT(DISTINCT(b.num_releve)) as nb";
78 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b";
79 $sql .=
" WHERE b.fk_account = ".((int)
$object->id);
81 $resql = $db->query($sql);
83 $obj = $db->fetch_object($resql);
85 $nbReceipts = $obj->nb;
90 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/releve.php?account=".((int)
$object->id);
91 $head[$h][1] = $langs->trans(
"AccountStatements");
92 if (($nbReceipts) > 0) {
93 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbReceipts).
'</span>';
95 $head[$h][2] =
'statement';
100 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
101 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
103 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
105 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/document.php?account=".
$object->id;
106 $head[$h][1] = $langs->trans(
"Documents");
107 if (($nbFiles + $nbLinks) > 0) {
108 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
110 $head[$h][2] =
'document';
136 global $langs, $conf, $db;
138 $langs->loadLangs(array(
"compta"));
141 $extrafields->fetch_name_optionals_label(
'bank_account');
142 $extrafields->fetch_name_optionals_label(
'bank');
147 $head[$h][0] = DOL_URL_ROOT.
'/admin/bank.php';
148 $head[$h][1] = $langs->trans(
"Miscellaneous");
149 $head[$h][2] =
'general';
152 $head[$h][0] = DOL_URL_ROOT.
'/admin/chequereceipts.php';
153 $head[$h][1] = $langs->trans(
"CheckReceiptShort");
154 $head[$h][2] =
'checkreceipts';
164 $head[$h][0] = DOL_URL_ROOT.
'/admin/bank_extrafields.php';
165 $head[$h][1] = $langs->trans(
"ExtraFields").
' ('.$langs->trans(
"BankAccounts").
')';
166 $nbExtrafields = $extrafields->attributes[
'bank_account'][
'count'];
167 if ($nbExtrafields > 0) {
168 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
170 $head[$h][2] =
'attributes';
173 $head[$h][0] = DOL_URL_ROOT.
'/admin/bankline_extrafields.php';
174 $head[$h][1] = $langs->trans(
"ExtraFields").
' ('.$langs->trans(
"BankTransactions").
')';
175 $nbExtrafields = $extrafields->attributes[
'bank'][
'count'];
176 if ($nbExtrafields > 0) {
177 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
179 $head[$h][2] =
'bankline_extrafields';
198 global $langs, $conf, $db;
202 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/releve.php?account='.
$object->id.
'&num='.$num;
203 $head[$h][1] = $langs->trans(
"AccountStatement");
204 $head[$h][2] =
'statement';
208 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
209 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
211 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
214 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/account_statement_document.php?account=".
$object->id.
"&num=".$num;
215 $head[$h][1] = $langs->trans(
"Documents");
216 if (($nbFiles + $nbLinks) > 0) {
217 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
219 $head[$h][2] =
'document';
238 global $db, $langs, $conf;
243 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/various_payment/card.php?id='.
$object->id;
244 $head[$h][1] = $langs->trans(
"VariousPayment");
245 $head[$h][2] =
'card';
254 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
255 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
257 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
259 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/various_payment/document.php?id='.
$object->id;
260 $head[$h][1] = $langs->trans(
'Documents');
261 if (($nbFiles + $nbLinks) > 0) {
262 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
264 $head[$h][2] =
'documents';
267 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/various_payment/info.php?id='.
$object->id;
268 $head[$h][1] = $langs->trans(
"Info");
269 $head[$h][2] =
'info';
286 if ($account ==
null && $swift ==
null) {
288 } elseif ($swift ==
null) {
289 $swift = $account->bic;
291 if (preg_match(
"/^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$/", $swift)) {
307 if ($account ==
null && $ibantocheck ==
null) {
309 } elseif ($ibantocheck ==
null) {
310 $ibantocheck = ($account->iban ? $account->iban : $account->iban_prefix);
312 require_once DOL_DOCUMENT_ROOT.
'/includes/php-iban/oophp-iban.php';
314 $iban =
new PHP_IBAN\IBAN($ibantocheck);
315 $check = $iban->Verify();
332 if ($account->getCountryCode() ==
'FR') {
333 require_once DOL_DOCUMENT_ROOT.
'/includes/php-iban/oophp-iban.php';
334 $ibantoprint = preg_replace(
'/[^a-zA-Z0-9]/',
'', empty($account->iban) ?
'' : $account->iban);
335 $iban =
new PHP_IBAN\IBAN($ibantoprint);
336 return $iban->HumanFormat();
339 return $account->iban;
350 $country_code = $account->getCountryCode();
355 if (empty($account->number)) {
356 $account->number = $account->num_compte;
358 if (empty($account->cle)) {
359 $account->cle = $account->cle_rib;
362 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);
364 if ($country_code ==
'FR') {
365 $coef = array(62, 34, 3);
367 $rib = strtolower(trim($account->code_banque).trim($account->code_guichet).trim($account->number).trim($account->cle));
370 $rib = strtr($rib,
"abcdefghijklmnopqrstuvwxyz",
"12345678912345678923456789");
374 for ($i = 0, $s = 0; $i < 3; $i++) {
375 $code = substr($rib, 7 * $i, 7);
376 $s += ((int) $code) * $coef[$i];
379 $cle_rib = 97 - ($s % 97);
380 if ($cle_rib == $account->cle) {
386 if ($country_code ==
'BE') {
389 if ($country_code ==
'ES') {
390 $CCC = strtolower(trim($account->number));
391 $rib = strtolower(trim($account->code_banque).trim($account->code_guichet));
392 $cle_rib = strtolower(
checkES($rib, $CCC));
393 if ($cle_rib == strtolower($account->cle)) {
398 if ($country_code ==
'AU') {
399 if (strlen($account->code_banque) > 7) {
401 } elseif (strlen($account->code_banque) < 6) {
411 if (empty($account->number)) {
429 if (empty($IentOfi) || empty($InumCta) || strlen($IentOfi) != 8 || strlen($InumCta) != 10) {
434 $ccc = $IentOfi.$InumCta;
435 $numbers =
"1234567890";
439 while ($i <= strlen($ccc) - 1) {
440 if (strpos($numbers, substr($ccc, $i, 1)) ===
false) {
447 $values = array(1, 2, 4, 8, 5, 10, 9, 7, 3, 6);
450 for ($i = 2; $i < 10; $i++) {
451 $sum += $values[$i] * (int) substr($IentOfi, $i - 2, 1);
454 $key = 11 - $sum % 11;
467 for ($i = 0; $i < 11; $i++) {
468 $sum += $values[$i] * (int) substr($InumCta, $i, 1);
471 $key = 11 - $sum % 11;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
checkIbanForAccount($account=null, $ibantocheck=null)
Check IBAN number information for a bank account.
checkES($IentOfi, $InumCta)
Returns the key for Spanish Banks Accounts.
account_statement_prepare_head($object, $num)
Prepare array with list of tabs.
checkBanForAccount($account)
Check account number information 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.
checkSwiftForAccount($account=null, $swift=null)
Check SWIFT information for a bank account.
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($utf8_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 a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.