41 global $db, $langs, $conf, $user;
46 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/compta/bank/card.php', [
'id' =>
$object->id]);
47 $head[$h][1] = $langs->trans(
"BankAccount");
48 $head[$h][2] =
'bankname';
51 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/compta/bank/bankentries_list.php', [
'id' =>
$object->id]);
52 $head[$h][1] = $langs->trans(
"BankTransactions");
53 $head[$h][2] =
'journal';
56 if (
$object->canBeConciliated() > 0) {
57 $allowautomaticconciliation =
getDolGlobalBool(
'MAIN_ALLOW_AUTOMATIC_CONCILIATION');
58 $titletoconciliatemanual = $langs->trans(
"Conciliate");
59 $titletoconciliateauto = $langs->trans(
"Conciliate");
60 if ($allowautomaticconciliation) {
61 $titletoconciliatemanual .=
' ('.$langs->trans(
"Manual").
')';
62 $titletoconciliateauto .=
' ('.$langs->trans(
"Auto").
')';
68 if ($user->hasRight(
'banque',
'consolidate')) {
71 'action' =>
'reconcile',
72 'sortfield' =>
'b.datev,b.dateo,b.rowid',
73 'sortorder' =>
'asc,asc,asc',
74 'search_conciliated' => 0,
75 'search_account' =>
$object->id,
77 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/compta/bank/bankentries_list.php', $query).$param;
78 $head[$h][1] = $titletoconciliatemanual;
79 $head[$h][2] =
'reconcile';
85 if ($allowautomaticconciliation) {
87 if ($user->hasRight(
'banque',
'consolidate')) {
89 $newparam = preg_replace(
'/search_conciliated=\d+/i',
'', $newparam);
91 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/bankentries_list.php?id=".
$object->id.
'&action=reconcile&sortfield=b.datev,b.dateo,b.rowid&sortorder=asc,asc,asc&search_conciliated=0&search_account='.
$object->id.$newparam;
92 $head[$h][1] = $titletoconciliateauto;
93 $head[$h][2] =
'reconcileauto';
107 $sql =
"SELECT COUNT(DISTINCT(b.num_releve)) as nb";
108 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b";
109 $sql .=
" WHERE b.fk_account = ".((int)
$object->id);
111 $resql = $db->query($sql);
113 $obj = $db->fetch_object($resql);
115 $nbReceipts = $obj->nb;
120 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/compta/bank/releve.php', [
'account' =>
$object->id]);
121 $head[$h][1] = $langs->trans(
"AccountStatements");
122 if (($nbReceipts) > 0) {
123 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbReceipts).
'</span>';
125 $head[$h][2] =
'statement';
130 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
131 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
133 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
135 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/compta/bank/document.php', [
'account' =>
$object->id]);
136 $head[$h][1] = $langs->trans(
"Documents");
137 if (($nbFiles + $nbLinks) > 0) {
138 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
140 $head[$h][2] =
'document';
143 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/compta/bank/annuel.php', [
'account' =>
$object->id]);
144 $head[$h][1] = $langs->trans(
"Reports");
145 $head[$h][2] =
'annual';
148 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/compta/bank/treso.php', [
'account' =>
$object->id]);
149 $head[$h][1] = $langs->trans(
"PlannedTransactions");
150 $head[$h][2] =
'cash';
177 global $db, $langs, $conf, $user;
182 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/compta/bank/annuel.php', [
'account' =>
$object->id]);
183 $head[$h][1] = $langs->trans(
"IOMonthlyReporting");
184 $head[$h][2] =
'annual';
187 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/compta/bank/graph.php', [
'account' =>
$object->id]);
188 $head[$h][1] = $langs->trans(
"Graph");
189 $head[$h][2] =
'graph';
202 global $langs, $conf, $db;
204 $langs->loadLangs(array(
"compta"));
207 $extrafields->fetch_name_optionals_label(
'bank_account');
208 $extrafields->fetch_name_optionals_label(
'bank');
209 $extrafields->fetch_name_optionals_label(
'paiement');
214 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/bank.php');
215 $head[$h][1] = $langs->trans(
"Miscellaneous");
216 $head[$h][2] =
'general';
219 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/chequereceipts.php');
220 $head[$h][1] = $langs->trans(
"CheckReceiptShort");
221 $head[$h][2] =
'checkreceipts';
231 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/bank_extrafields.php');
232 $head[$h][1] = $langs->trans(
"ExtraFields").
' ('.$langs->trans(
"BankAccounts").
')';
233 $nbExtrafields = $extrafields->attributes[
'bank_account'][
'count'];
234 if ($nbExtrafields > 0) {
235 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
237 $head[$h][2] =
'attributes';
240 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/bankline_extrafields.php');
241 $head[$h][1] = $langs->trans(
"ExtraFields").
' ('.$langs->trans(
"BankTransactions").
')';
242 $nbExtrafields = $extrafields->attributes[
'bank'][
'count'];
243 if ($nbExtrafields > 0) {
244 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
246 $head[$h][2] =
'bankline_extrafields';
249 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/bank_payments_extrafields.php');
250 $head[$h][1] = $langs->trans(
"ExtraFields").
' ('.$langs->trans(
"Payments").
')';
251 $nbExtrafields = $extrafields->attributes[
'paiement'][
'count'];
252 if ($nbExtrafields > 0) {
253 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
255 $head[$h][2] =
'bank_payments_extrafields';
273 global $langs, $conf, $db;
277 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/compta/bank/releve.php', [
'account' =>
$object->id,
'num' => $num]);
278 $head[$h][1] = $langs->trans(
"AccountStatement");
279 $head[$h][2] =
'statement';
283 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
284 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
286 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
289 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/compta/bank/account_statement_document.php', [
'account' =>
$object->id,
'num' => $num]);
290 $head[$h][1] = $langs->trans(
"Documents");
291 if (($nbFiles + $nbLinks) > 0) {
292 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
294 $head[$h][2] =
'document';
313 global $db, $langs, $conf;
318 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/various_payment/card.php?id='.
$object->id;
319 $head[$h][1] = $langs->trans(
"VariousPayment");
320 $head[$h][2] =
'card';
329 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
330 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
332 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
334 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/various_payment/document.php?id='.
$object->id;
335 $head[$h][1] = $langs->trans(
'Documents');
336 if (($nbFiles + $nbLinks) > 0) {
337 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
339 $head[$h][2] =
'documents';
342 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/various_payment/info.php?id='.
$object->id;
343 $head[$h][1] = $langs->trans(
"Info");
344 $head[$h][2] =
'info';
361 if ($account ==
null && $swift ==
null) {
363 } elseif ($swift ==
null) {
364 $swift = $account->bic;
366 if (preg_match(
"/^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$/", $swift)) {
382 if ($account ==
null && $ibantocheck ==
null) {
384 } elseif ($ibantocheck ==
null) {
385 $ibantocheck = ($account->iban ? $account->iban : $account->iban_prefix);
387 require_once DOL_DOCUMENT_ROOT.
'/includes/php-iban/oophp-iban.php';
389 $iban =
new PHP_IBAN\IBAN($ibantocheck);
390 $check = $iban->Verify();
407 if ($account->getCountryCode() ==
'FR') {
408 require_once DOL_DOCUMENT_ROOT.
'/includes/php-iban/oophp-iban.php';
409 $ibantoprint = preg_replace(
'/[^a-zA-Z0-9]/',
'', empty($account->iban) ?
'' : $account->iban);
410 $iban =
new PHP_IBAN\IBAN($ibantoprint);
411 return $iban->HumanFormat();
414 return $account->iban;
425 $country_code = $account->getCountryCode();
430 if (empty($account->number)) {
431 $account->number = $account->num_compte;
433 if (empty($account->cle)) {
434 $account->cle = $account->cle_rib;
437 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);
439 if ($country_code ==
'FR') {
440 $coef = array(62, 34, 3);
442 $rib = strtolower(trim($account->code_banque).trim($account->code_guichet).trim($account->number).trim($account->cle));
445 $rib = strtr($rib,
"abcdefghijklmnopqrstuvwxyz",
"12345678912345678923456789");
449 for ($i = 0, $s = 0; $i < 3; $i++) {
450 $code = substr($rib, 7 * $i, 7);
451 $s += ((int) $code) * $coef[$i];
454 $cle_rib = 97 - ($s % 97);
455 if ($cle_rib == $account->cle) {
466 if ($country_code ==
'ES') {
467 $CCC = strtolower(trim($account->number));
468 $rib = strtolower(trim($account->code_banque).trim($account->code_guichet));
469 $cle_rib = strtolower(
checkES($rib, $CCC));
470 if ($cle_rib == strtolower($account->cle)) {
475 if ($country_code ==
'AU') {
476 if (strlen($account->code_banque) > 7) {
478 } elseif (strlen($account->code_banque) < 6) {
488 if (empty($account->number)) {
506 if (empty($IentOfi) || empty($InumCta) || strlen($IentOfi) != 8 || strlen($InumCta) != 10) {
511 $ccc = $IentOfi.$InumCta;
512 $numbers =
"1234567890";
516 while ($i <= strlen($ccc) - 1) {
517 if (strpos($numbers, substr($ccc, $i, 1)) ===
false) {
524 $values = array(1, 2, 4, 8, 5, 10, 9, 7, 3, 6);
527 for ($i = 2; $i < 10; $i++) {
528 $sum += $values[$i] * (int) substr($IentOfi, $i - 2, 1);
531 $key = 11 - $sum % 11;
544 for ($i = 0; $i < 11; $i++) {
545 $sum += $values[$i] * (int) substr($InumCta, $i, 1);
548 $key = 11 - $sum % 11;
if(! $sortfield) if(! $sortorder) $object
checkIbanForAccount($account=null, $ibantocheck=null)
Check IBAN number information for a bank account.
checkES($IentOfi, $InumCta)
Returns the key for Spanish Banks Accounts.
bank_report_prepare_head(Account $object)
Prepare array with list of tabs for bank report.
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.
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalBool($key, $default=false)
Return a Dolibarr global constant boolean value.
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.