41 global $db, $langs,
$conf, $user;
46 $head[$h][0] = 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] = 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')) {
69 $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.$param;
70 $head[$h][1] = $titletoconciliatemanual;
71 $head[$h][2] =
'reconcile';
77 if ($allowautomaticconciliation) {
79 if ($user->hasRight(
'banque',
'consolidate')) {
81 $newparam = preg_replace(
'/search_conciliated=\d+/i',
'', $newparam);
83 $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;
84 $head[$h][1] = $titletoconciliateauto;
85 $head[$h][2] =
'reconcileauto';
99 $sql =
"SELECT COUNT(DISTINCT(b.num_releve)) as nb";
100 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b";
101 $sql .=
" WHERE b.fk_account = ".((int)
$object->id);
103 $resql = $db->query($sql);
105 $obj = $db->fetch_object($resql);
107 $nbReceipts = $obj->nb;
112 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/releve.php?account=".((int)
$object->id);
113 $head[$h][1] = $langs->trans(
"AccountStatements");
114 if (($nbReceipts) > 0) {
115 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbReceipts).
'</span>';
117 $head[$h][2] =
'statement';
122 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
123 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
125 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
127 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/document.php?account=".
$object->id;
128 $head[$h][1] = $langs->trans(
"Documents");
129 if (($nbFiles + $nbLinks) > 0) {
130 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
132 $head[$h][2] =
'document';
135 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/annuel.php?account=".
$object->id;
136 $head[$h][1] = $langs->trans(
"IOMonthlyReporting");
137 $head[$h][2] =
'annual';
140 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/graph.php?account=".
$object->id;
141 $head[$h][1] = $langs->trans(
"Graph");
142 $head[$h][2] =
'graph';
145 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/treso.php?account=".
$object->id;
146 $head[$h][1] = $langs->trans(
"PlannedTransactions");
147 $head[$h][2] =
'cash';
173 global $langs,
$conf, $db;
175 $langs->loadLangs(array(
"compta"));
178 $extrafields->fetch_name_optionals_label(
'bank_account');
179 $extrafields->fetch_name_optionals_label(
'bank');
184 $head[$h][0] = DOL_URL_ROOT.
'/admin/bank.php';
185 $head[$h][1] = $langs->trans(
"Miscellaneous");
186 $head[$h][2] =
'general';
189 $head[$h][0] = DOL_URL_ROOT.
'/admin/chequereceipts.php';
190 $head[$h][1] = $langs->trans(
"CheckReceiptShort");
191 $head[$h][2] =
'checkreceipts';
201 $head[$h][0] = DOL_URL_ROOT.
'/admin/bank_extrafields.php';
202 $head[$h][1] = $langs->trans(
"ExtraFields").
' ('.$langs->trans(
"BankAccounts").
')';
203 $nbExtrafields = $extrafields->attributes[
'bank_account'][
'count'];
204 if ($nbExtrafields > 0) {
205 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
207 $head[$h][2] =
'attributes';
210 $head[$h][0] = DOL_URL_ROOT.
'/admin/bankline_extrafields.php';
211 $head[$h][1] = $langs->trans(
"ExtraFields").
' ('.$langs->trans(
"BankTransactions").
')';
212 $nbExtrafields = $extrafields->attributes[
'bank'][
'count'];
213 if ($nbExtrafields > 0) {
214 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
216 $head[$h][2] =
'bankline_extrafields';
235 global $langs,
$conf, $db;
239 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/releve.php?account='.
$object->id.
'&num='.$num;
240 $head[$h][1] = $langs->trans(
"AccountStatement");
241 $head[$h][2] =
'statement';
245 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
246 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
248 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
251 $head[$h][0] = DOL_URL_ROOT.
"/compta/bank/account_statement_document.php?account=".
$object->id.
"&num=".$num;
252 $head[$h][1] = $langs->trans(
"Documents");
253 if (($nbFiles + $nbLinks) > 0) {
254 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
256 $head[$h][2] =
'document';
275 global $db, $langs,
$conf;
280 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/various_payment/card.php?id='.
$object->id;
281 $head[$h][1] = $langs->trans(
"VariousPayment");
282 $head[$h][2] =
'card';
291 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
292 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
294 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
296 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/various_payment/document.php?id='.
$object->id;
297 $head[$h][1] = $langs->trans(
'Documents');
298 if (($nbFiles + $nbLinks) > 0) {
299 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
301 $head[$h][2] =
'documents';
304 $head[$h][0] = DOL_URL_ROOT.
'/compta/bank/various_payment/info.php?id='.
$object->id;
305 $head[$h][1] = $langs->trans(
"Info");
306 $head[$h][2] =
'info';
323 if ($account ==
null && $swift ==
null) {
325 } elseif ($swift ==
null) {
326 $swift = $account->bic;
328 if (preg_match(
"/^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$/", $swift)) {
344 if ($account ==
null && $ibantocheck ==
null) {
346 } elseif ($ibantocheck ==
null) {
347 $ibantocheck = ($account->iban ? $account->iban : $account->iban_prefix);
349 require_once DOL_DOCUMENT_ROOT.
'/includes/php-iban/oophp-iban.php';
351 $iban =
new PHP_IBAN\IBAN($ibantocheck);
352 $check = $iban->Verify();
369 if ($account->getCountryCode() ==
'FR') {
370 require_once DOL_DOCUMENT_ROOT.
'/includes/php-iban/oophp-iban.php';
371 $ibantoprint = preg_replace(
'/[^a-zA-Z0-9]/',
'', empty($account->iban) ?
'' : $account->iban);
372 $iban =
new PHP_IBAN\IBAN($ibantoprint);
373 return $iban->HumanFormat();
376 return $account->iban;
387 $country_code = $account->getCountryCode();
392 if (empty($account->number)) {
393 $account->number = $account->num_compte;
395 if (empty($account->cle)) {
396 $account->cle = $account->cle_rib;
399 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);
401 if ($country_code ==
'FR') {
402 $coef = array(62, 34, 3);
404 $rib = strtolower(trim($account->code_banque).trim($account->code_guichet).trim($account->number).trim($account->cle));
407 $rib = strtr($rib,
"abcdefghijklmnopqrstuvwxyz",
"12345678912345678923456789");
411 for ($i = 0, $s = 0; $i < 3; $i++) {
412 $code = substr($rib, 7 * $i, 7);
413 $s += ((int) $code) * $coef[$i];
416 $cle_rib = 97 - ($s % 97);
417 if ($cle_rib == $account->cle) {
428 if ($country_code ==
'ES') {
429 $CCC = strtolower(trim($account->number));
430 $rib = strtolower(trim($account->code_banque).trim($account->code_guichet));
431 $cle_rib = strtolower(
checkES($rib, $CCC));
432 if ($cle_rib == strtolower($account->cle)) {
437 if ($country_code ==
'AU') {
438 if (strlen($account->code_banque) > 7) {
440 } elseif (strlen($account->code_banque) < 6) {
450 if (empty($account->number)) {
468 if (empty($IentOfi) || empty($InumCta) || strlen($IentOfi) != 8 || strlen($InumCta) != 10) {
473 $ccc = $IentOfi.$InumCta;
474 $numbers =
"1234567890";
478 while ($i <= strlen($ccc) - 1) {
479 if (strpos($numbers, substr($ccc, $i, 1)) ===
false) {
486 $values = array(1, 2, 4, 8, 5, 10, 9, 7, 3, 6);
489 for ($i = 2; $i < 10; $i++) {
490 $sum += $values[$i] * (int) substr($IentOfi, $i - 2, 1);
493 $key = 11 - $sum % 11;
506 for ($i = 0; $i < 11; $i++) {
507 $sum += $values[$i] * (int) substr($InumCta, $i, 1);
510 $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.
getDolGlobalBool($key, $default=false)
Return a Dolibarr global constant boolean value.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...