@@ -40,7 +40,7 @@ |
||
40 | 40 | $confirm = GETPOST('confirm', 'alpha'); |
41 | 41 | $cancel = GETPOST('cancel', 'aZ09'); |
42 | 42 | $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)) . basename(__FILE__, '.php')); // To manage different context of search |
43 | -$backtopage = GETPOST('backtopage', 'alpha'); // if not set, a default page will be used |
|
43 | +$backtopage = GETPOST('backtopage', 'alpha'); // if not set, a default page will be used |
|
44 | 44 | $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); // if not set, $backtopage will be used |
45 | 45 | $backtopagejsfields = GETPOST('backtopagejsfields', 'alpha'); |
46 | 46 | $dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09'); |
@@ -61,7 +61,7 @@ |
||
61 | 61 | $search_date_endday = GETPOSTINT('search_date_endday'); |
62 | 62 | $search_date_endmonth = GETPOSTINT('search_date_endmonth'); |
63 | 63 | $search_date_endyear = GETPOSTINT('search_date_endyear'); |
64 | -$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver |
|
64 | +$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver |
|
65 | 65 | $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); |
66 | 66 | $search_country = GETPOST('search_country', 'aZ09'); |
67 | 67 | $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | // Search Getpost |
60 | 60 | $search_societe = GETPOST('search_societe', 'alpha'); |
61 | -$search_lineid = GETPOST('search_lineid', 'alpha'); // Can be '> 100' |
|
61 | +$search_lineid = GETPOST('search_lineid', 'alpha'); // Can be '> 100' |
|
62 | 62 | $search_ref = GETPOST('search_ref', 'alpha'); |
63 | 63 | $search_invoice = GETPOST('search_invoice', 'alpha'); |
64 | 64 | $search_label = GETPOST('search_label', 'alpha'); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $search_date_endday = GETPOSTINT('search_date_endday'); |
73 | 73 | $search_date_endmonth = GETPOSTINT('search_date_endmonth'); |
74 | 74 | $search_date_endyear = GETPOSTINT('search_date_endyear'); |
75 | -$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver |
|
75 | +$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver |
|
76 | 76 | $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); |
77 | 77 | $search_country = GETPOST('search_country', 'aZ09'); |
78 | 78 | $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); |
@@ -568,14 +568,14 @@ discard block |
||
568 | 568 | $thirdpartystatic->client = $objp->client; |
569 | 569 | $thirdpartystatic->fournisseur = $objp->fournisseur; |
570 | 570 | $thirdpartystatic->code_client = $objp->code_client; |
571 | - $thirdpartystatic->code_compta = $objp->code_compta_client; // For backward compatibility |
|
571 | + $thirdpartystatic->code_compta = $objp->code_compta_client; // For backward compatibility |
|
572 | 572 | $thirdpartystatic->code_compta_client = $objp->code_compta_client; |
573 | 573 | $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; |
574 | 574 | $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; |
575 | 575 | $thirdpartystatic->email = $objp->email; |
576 | 576 | $thirdpartystatic->country_code = $objp->country_code; |
577 | 577 | $thirdpartystatic->tva_intra = $objp->tva_intra; |
578 | - $thirdpartystatic->code_compta_product = $objp->company_code_sell; // The accounting account for product stored on thirdparty object (for level3 suggestion) |
|
578 | + $thirdpartystatic->code_compta_product = $objp->company_code_sell; // The accounting account for product stored on thirdparty object (for level3 suggestion) |
|
579 | 579 | |
580 | 580 | $product_static->ref = $objp->product_ref; |
581 | 581 | $product_static->id = $objp->product_id; |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | $sql .= " co.code as country_code, co.label as country_label,"; |
143 | 143 | $sql .= " s.tva_intra,"; |
144 | 144 | if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { |
145 | - $sql .= " spe.accountancy_code_sell as company_code_sell"; // accounting code for product but stored on thirdparty |
|
145 | + $sql .= " spe.accountancy_code_sell as company_code_sell"; // accounting code for product but stored on thirdparty |
|
146 | 146 | } else { |
147 | - $sql .= " s.accountancy_code_sell as company_code_sell"; // accounting code for product but stored on thirdparty |
|
147 | + $sql .= " s.accountancy_code_sell as company_code_sell"; // accounting code for product but stored on thirdparty |
|
148 | 148 | } |
149 | 149 | $sql .= " FROM " . $db->prefix() . "facture as f"; |
150 | 150 | $sql .= " INNER JOIN " . $db->prefix() . "societe as s ON s.rowid = f.fk_soc"; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $sql .= " LEFT JOIN " . $db->prefix() . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); |
153 | 153 | } |
154 | 154 | $sql .= " LEFT JOIN " . $db->prefix() . "c_country as co ON co.rowid = s.fk_pays "; |
155 | - $sql .= " INNER JOIN " . $db->prefix() . "facturedet as l ON f.rowid = l.fk_facture"; // the main table |
|
155 | + $sql .= " INNER JOIN " . $db->prefix() . "facturedet as l ON f.rowid = l.fk_facture"; // the main table |
|
156 | 156 | $sql .= " LEFT JOIN " . $db->prefix() . "product as p ON p.rowid = l.fk_product"; |
157 | 157 | if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { |
158 | 158 | $sql .= " LEFT JOIN " . $db->prefix() . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | $thirdpartystatic->email = !empty($objp->email) ? $objp->email : ""; |
207 | 207 | $thirdpartystatic->country_code = !empty($objp->country_code) ? $objp->country_code : ""; |
208 | 208 | $thirdpartystatic->tva_intra = !empty($objp->tva_intra) ? $objp->tva_intra : ""; |
209 | - $thirdpartystatic->code_compta_product = !empty($objp->company_code_sell) ? $objp->company_code_sell : ""; // The accounting account for product stored on thirdparty object (for level3 suggestion) |
|
209 | + $thirdpartystatic->code_compta_product = !empty($objp->company_code_sell) ? $objp->company_code_sell : ""; // The accounting account for product stored on thirdparty object (for level3 suggestion) |
|
210 | 210 | |
211 | 211 | $product_static->ref = $objp->product_ref; |
212 | 212 | $product_static->id = $objp->product_id; |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | "MONTH(f.datef) = " . ((int) $j), |
669 | 669 | " (" . $db->ifsql( |
670 | 670 | "fd.total_ht < 0", |
671 | - " (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))))", // TODO This is bugged, we must use the percent for the invoice and fd.situation_percent is cumulated percent ! |
|
671 | + " (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))))", // TODO This is bugged, we must use the percent for the invoice and fd.situation_percent is cumulated percent ! |
|
672 | 672 | " (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))" |
673 | 673 | ) . ")", |
674 | 674 | 0 |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | } |
677 | 677 | $sql .= " SUM(" . $db->ifsql( |
678 | 678 | "fd.total_ht < 0", |
679 | - " (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))))", // TODO This is bugged, we must use the percent for the invoice and fd.situation_percent is cumulated percent ! |
|
679 | + " (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))))", // TODO This is bugged, we must use the percent for the invoice and fd.situation_percent is cumulated percent ! |
|
680 | 680 | " (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))" |
681 | 681 | ) . ") as total"; |
682 | 682 | } else { |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $cpttva = getDolGlobalString('ACCOUNTING_VAT_BUY_ACCOUNT', 'NotDefined'); |
204 | 204 | $rcctva = getDolGlobalString('ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT', 'NotDefined'); |
205 | 205 | $rcdtva = getDolGlobalString('ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT', 'NotDefined'); |
206 | - $country_code_in_EEC = getCountriesInEEC(); // This make a database call but there is a cache done into $conf->cache['country_code_in_EEC'] |
|
206 | + $country_code_in_EEC = getCountriesInEEC(); // This make a database call but there is a cache done into $conf->cache['country_code_in_EEC'] |
|
207 | 207 | |
208 | 208 | $i = 0; |
209 | 209 | while ($i < $num) { |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | $totalcredit = 0; |
412 | 412 | $totaldebit = 0; |
413 | 413 | |
414 | - $db->begin(); // We accept transaction into loop so if we hang, we can continue transfer from last error |
|
414 | + $db->begin(); // We accept transaction into loop so if we hang, we can continue transfer from last error |
|
415 | 415 | |
416 | 416 | $companystatic->id = $tabcompany[$key]['id']; |
417 | 417 | $companystatic->name = $tabcompany[$key]['name']; |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | |
618 | 618 | foreach ($arrayofvat[$key] as $k => $mt) { |
619 | 619 | if ($mt) { |
620 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache for label |
|
620 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache for label |
|
621 | 621 | $label_account = $accountingaccount->label; |
622 | 622 | |
623 | 623 | $bookkeeping = new BookKeeping($db); |
@@ -975,7 +975,7 @@ discard block |
||
975 | 975 | } |
976 | 976 | |
977 | 977 | // Button to write into Ledger |
978 | - $acctSupplierNotConfigured = in_array(getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), ['','-1']); |
|
978 | + $acctSupplierNotConfigured = in_array(getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), ['', '-1']); |
|
979 | 979 | if ($acctSupplierNotConfigured) { |
980 | 980 | print '<br><div class="warning">' . img_warning() . ' ' . $langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); |
981 | 981 | $desc = ' : ' . $langs->trans("AccountancyAreaDescMisc", 4, '{link}'); |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | |
301 | 301 | // Move a part of the retained warrenty into the account of warranty |
302 | 302 | if (getDolGlobalString('INVOICE_USE_RETAINED_WARRANTY') && $obj->retained_warranty > 0) { |
303 | - $retained_warranty = (float) price2num($total_ttc * $obj->retained_warranty / 100, 'MT'); // Calculate the amount of warrenty for this line (using the percent value) |
|
303 | + $retained_warranty = (float) price2num($total_ttc * $obj->retained_warranty / 100, 'MT'); // Calculate the amount of warrenty for this line (using the percent value) |
|
304 | 304 | $tabwarranty[$obj->rowid][$compta_soc] += $retained_warranty; |
305 | 305 | $total_ttc -= $retained_warranty; |
306 | 306 | } |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | $totalcredit = 0; |
440 | 440 | $totaldebit = 0; |
441 | 441 | |
442 | - $db->begin(); // We accept transaction into loop so if we hang, we can continue transfer from last error |
|
442 | + $db->begin(); // We accept transaction into loop so if we hang, we can continue transfer from last error |
|
443 | 443 | |
444 | 444 | $companystatic->id = $tabcompany[$key]['id']; |
445 | 445 | $companystatic->name = $tabcompany[$key]['name']; |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | |
672 | 672 | foreach ($arrayofvat[$key] as $k => $mt) { |
673 | 673 | if ($mt) { |
674 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache for label |
|
674 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache for label |
|
675 | 675 | $label_account = $accountingaccount->label; |
676 | 676 | |
677 | 677 | $bookkeeping = new BookKeeping($db); |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) { |
733 | 733 | foreach ($tabrevenuestamp[$key] as $k => $mt) { |
734 | 734 | if ($mt) { |
735 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache for label |
|
735 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache for label |
|
736 | 736 | $label_account = $accountingaccount->label; |
737 | 737 | |
738 | 738 | $bookkeeping = new BookKeeping($db); |
@@ -853,7 +853,7 @@ discard block |
||
853 | 853 | foreach ($tabfac as $key => $val) { |
854 | 854 | $companystatic->id = $tabcompany[$key]['id']; |
855 | 855 | $companystatic->name = $tabcompany[$key]['name']; |
856 | - $companystatic->code_compta = $tabcompany[$key]['code_compta']; // deprecated |
|
856 | + $companystatic->code_compta = $tabcompany[$key]['code_compta']; // deprecated |
|
857 | 857 | $companystatic->code_compta_client = $tabcompany[$key]['code_compta']; |
858 | 858 | $companystatic->code_client = $tabcompany[$key]['code_client']; |
859 | 859 | $companystatic->client = 3; |
@@ -1041,7 +1041,7 @@ discard block |
||
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | // Button to write into Ledger |
1044 | - $acctCustomerNotConfigured = in_array(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), ['','-1']); |
|
1044 | + $acctCustomerNotConfigured = in_array(getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), ['', '-1']); |
|
1045 | 1045 | if ($acctCustomerNotConfigured) { |
1046 | 1046 | print '<br><div class="warning">' . img_warning() . ' ' . $langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); |
1047 | 1047 | $desc = ' : ' . $langs->trans("AccountancyAreaDescMisc", 4, '{link}'); |
@@ -384,12 +384,12 @@ discard block |
||
384 | 384 | if ($links[$key]['type'] == 'payment') { |
385 | 385 | $paymentstatic->id = $links[$key]['url_id']; |
386 | 386 | $paymentstatic->ref = $links[$key]['url_id']; |
387 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this |
|
387 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this |
|
388 | 388 | $tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id; |
389 | 389 | } elseif ($links[$key]['type'] == 'payment_supplier') { |
390 | 390 | $paymentsupplierstatic->id = $links[$key]['url_id']; |
391 | 391 | $paymentsupplierstatic->ref = $links[$key]['url_id']; |
392 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsupplierstatic->getNomUrl(2); |
|
392 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2); |
|
393 | 393 | $tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id; |
394 | 394 | } elseif ($links[$key]['type'] == 'company') { |
395 | 395 | $societestatic->id = $links[$key]['url_id']; |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | $chargestatic->id = $links[$key]['url_id']; |
424 | 424 | $chargestatic->ref = $links[$key]['url_id']; |
425 | 425 | |
426 | - $tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2); |
|
426 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2); |
|
427 | 427 | $reg = array(); |
428 | 428 | if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { |
429 | 429 | if ($reg[1] == 'socialcontribution') { |
@@ -440,13 +440,13 @@ discard block |
||
440 | 440 | // Retrieve the accounting code of the social contribution of the payment from link of payment. |
441 | 441 | // Note: We have the social contribution id, it can be faster to get accounting code from social contribution id. |
442 | 442 | $sqlmid = "SELECT cchgsoc.accountancy_code"; |
443 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc"; |
|
444 | - $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type = cchgsoc.id"; |
|
445 | - $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge = chgsoc.rowid"; |
|
446 | - $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid AND bkurl.type = 'payment_sc'"; |
|
447 | - $sqlmid .= " WHERE bkurl.fk_bank = ".((int) $obj->rowid); |
|
443 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc"; |
|
444 | + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type = cchgsoc.id"; |
|
445 | + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge = chgsoc.rowid"; |
|
446 | + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid AND bkurl.type = 'payment_sc'"; |
|
447 | + $sqlmid .= " WHERE bkurl.fk_bank = " . ((int) $obj->rowid); |
|
448 | 448 | |
449 | - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); |
|
449 | + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); |
|
450 | 450 | $resultmid = $db->query($sqlmid); |
451 | 451 | if ($resultmid) { |
452 | 452 | $objmid = $db->fetch_object($resultmid); |
@@ -456,14 +456,14 @@ discard block |
||
456 | 456 | $paymentdonstatic->id = $links[$key]['url_id']; |
457 | 457 | $paymentdonstatic->ref = $links[$key]['url_id']; |
458 | 458 | $paymentdonstatic->fk_donation = $links[$key]['url_id']; |
459 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2); |
|
459 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentdonstatic->getNomUrl(2); |
|
460 | 460 | $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id; |
461 | 461 | $tabtp[$obj->rowid][$account_pay_donation] = isset($tabtp[$obj->rowid][$account_pay_donation]) ? $tabtp[$obj->rowid][$account_pay_donation] + $amounttouse : $amounttouse; |
462 | 462 | } elseif ($links[$key]['type'] == 'member') { |
463 | 463 | $paymentsubscriptionstatic->id = $links[$key]['url_id']; |
464 | 464 | $paymentsubscriptionstatic->ref = $links[$key]['url_id']; |
465 | 465 | $paymentsubscriptionstatic->label = $links[$key]['label']; |
466 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2); |
|
466 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsubscriptionstatic->getNomUrl(2); |
|
467 | 467 | $tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id; |
468 | 468 | $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id); |
469 | 469 | $tabtp[$obj->rowid][$account_pay_subscription] = isset($tabtp[$obj->rowid][$account_pay_subscription]) ? $tabtp[$obj->rowid][$account_pay_subscription] + $amounttouse : $amounttouse; |
@@ -471,14 +471,14 @@ discard block |
||
471 | 471 | $paymentvatstatic->id = $links[$key]['url_id']; |
472 | 472 | $paymentvatstatic->ref = $links[$key]['url_id']; |
473 | 473 | $paymentvatstatic->label = $links[$key]['label']; |
474 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2); |
|
474 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); |
|
475 | 475 | $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id; |
476 | 476 | $tabtp[$obj->rowid][$account_pay_vat] = isset($tabtp[$obj->rowid][$account_pay_vat]) ? $tabtp[$obj->rowid][$account_pay_vat] + $amounttouse : $amounttouse; |
477 | 477 | } elseif ($links[$key]['type'] == 'payment_salary') { |
478 | 478 | $paymentsalstatic->id = $links[$key]['url_id']; |
479 | 479 | $paymentsalstatic->ref = $links[$key]['url_id']; |
480 | 480 | $paymentsalstatic->label = $links[$key]['label']; |
481 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsalstatic->getNomUrl(2); |
|
481 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2); |
|
482 | 482 | $tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id; |
483 | 483 | |
484 | 484 | // This part of code is no more required. it is here to solve case where a link were missing (with v14.0.0) and keep writing in accountancy complete. |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | $paymentvariousstatic->id = $links[$key]['url_id']; |
527 | 527 | $paymentvariousstatic->ref = $links[$key]['url_id']; |
528 | 528 | $paymentvariousstatic->label = $links[$key]['label']; |
529 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvariousstatic->getNomUrl(2); |
|
529 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvariousstatic->getNomUrl(2); |
|
530 | 530 | $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; |
531 | 531 | $paymentvariousstatic->fetch($paymentvariousstatic->id); |
532 | 532 | $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word |
@@ -537,14 +537,14 @@ discard block |
||
537 | 537 | $paymentloanstatic->id = $links[$key]['url_id']; |
538 | 538 | $paymentloanstatic->ref = $links[$key]['url_id']; |
539 | 539 | $paymentloanstatic->fk_loan = $links[$key]['url_id']; |
540 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2); |
|
540 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentloanstatic->getNomUrl(2); |
|
541 | 541 | $tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id; |
542 | 542 | //$tabtp[$obj->rowid][$account_pay_loan] += $amounttouse; |
543 | 543 | $sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest'; |
544 | - $sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l'; |
|
545 | - $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid); |
|
544 | + $sqlmid .= ' FROM ' . MAIN_DB_PREFIX . 'payment_loan as pl, ' . MAIN_DB_PREFIX . 'loan as l'; |
|
545 | + $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = ' . ((int) $obj->rowid); |
|
546 | 546 | |
547 | - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); |
|
547 | + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); |
|
548 | 548 | $resultmid = $db->query($sqlmid); |
549 | 549 | if ($resultmid) { |
550 | 550 | $objmid = $db->fetch_object($resultmid); |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | } |
555 | 555 | } elseif ($links[$key]['type'] == 'banktransfert') { |
556 | 556 | $accountLinestatic->fetch($links[$key]['url_id']); |
557 | - $tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- '.$accountLinestatic ->getNomUrl(1); |
|
557 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("BankTransfer") . '- ' . $accountLinestatic ->getNomUrl(1); |
|
558 | 558 | $tabtp[$obj->rowid][$account_transfer] = isset($tabtp[$obj->rowid][$account_transfer]) ? $tabtp[$obj->rowid][$account_transfer] + $amounttouse : $amounttouse; |
559 | 559 | $bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']); |
560 | 560 | $tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2); |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | if ($mt) { |
673 | 673 | if (empty($conf->cache['accountingaccountincurrententity'][$k])) { |
674 | 674 | $accountingaccount = new AccountingAccount($db); |
675 | - $accountingaccount->fetch(0, $k, true); // $k is accounting account of the bank. |
|
675 | + $accountingaccount->fetch(0, $k, true); // $k is accounting account of the bank. |
|
676 | 676 | $conf->cache['accountingaccountincurrententity'][$k] = $accountingaccount; |
677 | 677 | } else { |
678 | 678 | $accountingaccount = $conf->cache['accountingaccountincurrententity'][$k]; |
@@ -682,11 +682,11 @@ discard block |
||
682 | 682 | |
683 | 683 | $reflabel = ''; |
684 | 684 | if (!empty($val['lib'])) { |
685 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
685 | + $reflabel .= dol_string_nohtmltag($val['lib']) . " - "; |
|
686 | 686 | } |
687 | - $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); |
|
687 | + $reflabel .= $langs->trans("Bank") . ' ' . dol_string_nohtmltag($val['bank_account_ref']); |
|
688 | 688 | if (!empty($val['soclib'])) { |
689 | - $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); |
|
689 | + $reflabel .= " - " . dol_string_nohtmltag($val['soclib']); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | $bookkeeping = new BookKeeping($db); |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
723 | 723 | $error++; |
724 | 724 | $errorforline++; |
725 | - setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
725 | + setEventMessages('Transaction for (' . $bookkeeping->doc_type . ', ' . $bookkeeping->fk_doc . ', ' . $bookkeeping->fk_docdet . ') were already recorded', null, 'warnings'); |
|
726 | 726 | } else { |
727 | 727 | $error++; |
728 | 728 | $errorforline++; |
@@ -743,10 +743,10 @@ discard block |
||
743 | 743 | |
744 | 744 | $reflabel = ''; |
745 | 745 | if (!empty($val['lib'])) { |
746 | - $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); |
|
746 | + $reflabel .= dol_string_nohtmltag($val['lib']) . ($val['soclib'] ? " - " : ""); |
|
747 | 747 | } |
748 | 748 | if ($tabtype[$key] == 'banktransfert') { |
749 | - $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); |
|
749 | + $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount') . ' ' . $account_transfer); |
|
750 | 750 | } else { |
751 | 751 | $reflabel .= dol_string_nohtmltag($val['soclib']); |
752 | 752 | } |
@@ -793,43 +793,43 @@ discard block |
||
793 | 793 | } elseif (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution |
794 | 794 | $bookkeeping->subledger_account = ''; |
795 | 795 | $bookkeeping->subledger_label = ''; |
796 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
796 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
797 | 797 | $bookkeeping->numero_compte = $k; |
798 | 798 | $bookkeeping->label_compte = $accountingaccount->label; |
799 | 799 | } elseif ($tabtype[$key] == 'payment_vat') { |
800 | 800 | $bookkeeping->subledger_account = ''; |
801 | 801 | $bookkeeping->subledger_label = ''; |
802 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
802 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
803 | 803 | $bookkeeping->numero_compte = $k; |
804 | 804 | $bookkeeping->label_compte = $accountingaccount->label; |
805 | 805 | } elseif ($tabtype[$key] == 'payment_donation') { |
806 | 806 | $bookkeeping->subledger_account = ''; |
807 | 807 | $bookkeeping->subledger_label = ''; |
808 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
808 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
809 | 809 | $bookkeeping->numero_compte = $k; |
810 | 810 | $bookkeeping->label_compte = $accountingaccount->label; |
811 | 811 | } elseif ($tabtype[$key] == 'member') { |
812 | 812 | $bookkeeping->subledger_account = ''; |
813 | 813 | $bookkeeping->subledger_label = ''; |
814 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
814 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
815 | 815 | $bookkeeping->numero_compte = $k; |
816 | 816 | $bookkeeping->label_compte = $accountingaccount->label; |
817 | 817 | } elseif ($tabtype[$key] == 'payment_loan') { |
818 | 818 | $bookkeeping->subledger_account = ''; |
819 | 819 | $bookkeeping->subledger_label = ''; |
820 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
820 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
821 | 821 | $bookkeeping->numero_compte = $k; |
822 | 822 | $bookkeeping->label_compte = $accountingaccount->label; |
823 | 823 | } elseif ($tabtype[$key] == 'payment_various') { |
824 | 824 | $bookkeeping->subledger_account = $k; |
825 | 825 | $bookkeeping->subledger_label = $tabcompany[$key]['name']; |
826 | - $accountingaccount->fetch(null, $tabpay[$key]["account_various"], true); // TODO Use a cache |
|
826 | + $accountingaccount->fetch(null, $tabpay[$key]["account_various"], true); // TODO Use a cache |
|
827 | 827 | $bookkeeping->numero_compte = $tabpay[$key]["account_various"]; |
828 | 828 | $bookkeeping->label_compte = $accountingaccount->label; |
829 | 829 | } elseif ($tabtype[$key] == 'banktransfert') { |
830 | 830 | $bookkeeping->subledger_account = ''; |
831 | 831 | $bookkeeping->subledger_label = ''; |
832 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
832 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
833 | 833 | $bookkeeping->numero_compte = $k; |
834 | 834 | $bookkeeping->label_compte = $accountingaccount->label; |
835 | 835 | } else { |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
853 | 853 | $error++; |
854 | 854 | $errorforline++; |
855 | - setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
855 | + setEventMessages('Transaction for (' . $bookkeeping->doc_type . ', ' . $bookkeeping->fk_doc . ', ' . $bookkeeping->fk_docdet . ') were already recorded', null, 'warnings'); |
|
856 | 856 | } else { |
857 | 857 | $error++; |
858 | 858 | $errorforline++; |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | if ($mt) { |
873 | 873 | $reflabel = ''; |
874 | 874 | if (!empty($val['lib'])) { |
875 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
875 | + $reflabel .= dol_string_nohtmltag($val['lib']) . " - "; |
|
876 | 876 | } |
877 | 877 | $reflabel .= dol_string_nohtmltag('WaitingAccount'); |
878 | 878 | |
@@ -903,7 +903,7 @@ discard block |
||
903 | 903 | if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
904 | 904 | $error++; |
905 | 905 | $errorforline++; |
906 | - setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
906 | + setEventMessages('Transaction for (' . $bookkeeping->doc_type . ', ' . $bookkeeping->fk_doc . ', ' . $bookkeeping->fk_docdet . ') were already recorded', null, 'warnings'); |
|
907 | 907 | } else { |
908 | 908 | $error++; |
909 | 909 | $errorforline++; |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')) { |
919 | 919 | $error++; |
920 | 920 | $errorforline++; |
921 | - setEventMessages('We tried to insert a non balanced transaction in book for '.$ref.'. Canceled. Surely a bug.', null, 'errors'); |
|
921 | + setEventMessages('We tried to insert a non balanced transaction in book for ' . $ref . '. Canceled. Surely a bug.', null, 'errors'); |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | if (!$errorforline) { |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | |
930 | 930 | $MAXNBERRORS = 5; |
931 | 931 | if ($error >= $MAXNBERRORS) { |
932 | - setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors'); |
|
932 | + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped") . ' (>' . $MAXNBERRORS . ')', null, 'errors'); |
|
933 | 933 | break; // Break in the foreach |
934 | 934 | } |
935 | 935 | } |
@@ -947,15 +947,15 @@ discard block |
||
947 | 947 | |
948 | 948 | // Must reload data, so we make a redirect |
949 | 949 | if (count($tabpay) != $error) { |
950 | - $param = 'id_journal='.$id_journal; |
|
951 | - $param .= '&date_startday='.$date_startday; |
|
952 | - $param .= '&date_startmonth='.$date_startmonth; |
|
953 | - $param .= '&date_startyear='.$date_startyear; |
|
954 | - $param .= '&date_endday='.$date_endday; |
|
955 | - $param .= '&date_endmonth='.$date_endmonth; |
|
956 | - $param .= '&date_endyear='.$date_endyear; |
|
957 | - $param .= '&in_bookkeeping='.$in_bookkeeping; |
|
958 | - header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : '')); |
|
950 | + $param = 'id_journal=' . $id_journal; |
|
951 | + $param .= '&date_startday=' . $date_startday; |
|
952 | + $param .= '&date_startmonth=' . $date_startmonth; |
|
953 | + $param .= '&date_startyear=' . $date_startyear; |
|
954 | + $param .= '&date_endday=' . $date_endday; |
|
955 | + $param .= '&date_endmonth=' . $date_endmonth; |
|
956 | + $param .= '&date_endyear=' . $date_endyear; |
|
957 | + $param .= '&in_bookkeeping=' . $in_bookkeeping; |
|
958 | + header("Location: " . $_SERVER['PHP_SELF'] . ($param ? '?' . $param : '')); |
|
959 | 959 | exit; |
960 | 960 | } |
961 | 961 | } |
@@ -968,20 +968,20 @@ discard block |
||
968 | 968 | |
969 | 969 | $filename = 'journal'; |
970 | 970 | $type_export = 'journal'; |
971 | - include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; |
|
971 | + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; |
|
972 | 972 | |
973 | 973 | // CSV header line |
974 | - print '"'.$langs->transnoentitiesnoconv("BankId").'"'.$sep; |
|
975 | - print '"'.$langs->transnoentitiesnoconv("Date").'"'.$sep; |
|
976 | - print '"'.$langs->transnoentitiesnoconv("PaymentMode").'"'.$sep; |
|
977 | - print '"'.$langs->transnoentitiesnoconv("AccountAccounting").'"'.$sep; |
|
978 | - print '"'.$langs->transnoentitiesnoconv("LedgerAccount").'"'.$sep; |
|
979 | - print '"'.$langs->transnoentitiesnoconv("SubledgerAccount").'"'.$sep; |
|
980 | - print '"'.$langs->transnoentitiesnoconv("Label").'"'.$sep; |
|
981 | - print '"'.$langs->transnoentitiesnoconv("AccountingDebit").'"'.$sep; |
|
982 | - print '"'.$langs->transnoentitiesnoconv("AccountingCredit").'"'.$sep; |
|
983 | - print '"'.$langs->transnoentitiesnoconv("Journal").'"'.$sep; |
|
984 | - print '"'.$langs->transnoentitiesnoconv("Note").'"'.$sep; |
|
974 | + print '"' . $langs->transnoentitiesnoconv("BankId") . '"' . $sep; |
|
975 | + print '"' . $langs->transnoentitiesnoconv("Date") . '"' . $sep; |
|
976 | + print '"' . $langs->transnoentitiesnoconv("PaymentMode") . '"' . $sep; |
|
977 | + print '"' . $langs->transnoentitiesnoconv("AccountAccounting") . '"' . $sep; |
|
978 | + print '"' . $langs->transnoentitiesnoconv("LedgerAccount") . '"' . $sep; |
|
979 | + print '"' . $langs->transnoentitiesnoconv("SubledgerAccount") . '"' . $sep; |
|
980 | + print '"' . $langs->transnoentitiesnoconv("Label") . '"' . $sep; |
|
981 | + print '"' . $langs->transnoentitiesnoconv("AccountingDebit") . '"' . $sep; |
|
982 | + print '"' . $langs->transnoentitiesnoconv("AccountingCredit") . '"' . $sep; |
|
983 | + print '"' . $langs->transnoentitiesnoconv("Journal") . '"' . $sep; |
|
984 | + print '"' . $langs->transnoentitiesnoconv("Note") . '"' . $sep; |
|
985 | 985 | print "\n"; |
986 | 986 | |
987 | 987 | foreach ($tabpay as $key => $val) { |
@@ -994,24 +994,24 @@ discard block |
||
994 | 994 | if ($mt) { |
995 | 995 | $reflabel = ''; |
996 | 996 | if (!empty($val['lib'])) { |
997 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
997 | + $reflabel .= dol_string_nohtmltag($val['lib']) . " - "; |
|
998 | 998 | } |
999 | - $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); |
|
999 | + $reflabel .= $langs->trans("Bank") . ' ' . dol_string_nohtmltag($val['bank_account_ref']); |
|
1000 | 1000 | if (!empty($val['soclib'])) { |
1001 | - $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); |
|
1001 | + $reflabel .= " - " . dol_string_nohtmltag($val['soclib']); |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | - print '"'.$key.'"'.$sep; |
|
1005 | - print '"'.$date.'"'.$sep; |
|
1006 | - print '"'.$val["type_payment"].'"'.$sep; |
|
1007 | - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
1008 | - print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
1009 | - print " ".$sep; |
|
1010 | - print '"'.$reflabel.'"'.$sep; |
|
1011 | - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
1012 | - print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
1013 | - print '"'.$journal.'"'.$sep; |
|
1014 | - print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
1004 | + print '"' . $key . '"' . $sep; |
|
1005 | + print '"' . $date . '"' . $sep; |
|
1006 | + print '"' . $val["type_payment"] . '"' . $sep; |
|
1007 | + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; |
|
1008 | + print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; |
|
1009 | + print " " . $sep; |
|
1010 | + print '"' . $reflabel . '"' . $sep; |
|
1011 | + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; |
|
1012 | + print '"' . ($mt < 0 ? price(-$mt) : '') . '"' . $sep; |
|
1013 | + print '"' . $journal . '"' . $sep; |
|
1014 | + print '"' . dol_string_nohtmltag($ref) . '"' . $sep; |
|
1015 | 1015 | print "\n"; |
1016 | 1016 | } |
1017 | 1017 | } |
@@ -1022,35 +1022,35 @@ discard block |
||
1022 | 1022 | if ($mt) { |
1023 | 1023 | $reflabel = ''; |
1024 | 1024 | if (!empty($val['lib'])) { |
1025 | - $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); |
|
1025 | + $reflabel .= dol_string_nohtmltag($val['lib']) . ($val['soclib'] ? " - " : ""); |
|
1026 | 1026 | } |
1027 | 1027 | if ($tabtype[$key] == 'banktransfert') { |
1028 | - $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); |
|
1028 | + $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount') . ' ' . $account_transfer); |
|
1029 | 1029 | } else { |
1030 | 1030 | $reflabel .= dol_string_nohtmltag($val['soclib']); |
1031 | 1031 | } |
1032 | 1032 | |
1033 | - print '"'.$key.'"'.$sep; |
|
1034 | - print '"'.$date.'"'.$sep; |
|
1035 | - print '"'.$val["type_payment"].'"'.$sep; |
|
1036 | - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
1033 | + print '"' . $key . '"' . $sep; |
|
1034 | + print '"' . $date . '"' . $sep; |
|
1035 | + print '"' . $val["type_payment"] . '"' . $sep; |
|
1036 | + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; |
|
1037 | 1037 | if ($tabtype[$key] == 'payment_supplier') { |
1038 | - print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER').'"'.$sep; |
|
1038 | + print '"' . getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') . '"' . $sep; |
|
1039 | 1039 | } elseif ($tabtype[$key] == 'payment') { |
1040 | - print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER').'"'.$sep; |
|
1040 | + print '"' . getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') . '"' . $sep; |
|
1041 | 1041 | } elseif ($tabtype[$key] == 'payment_expensereport') { |
1042 | - print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT').'"'.$sep; |
|
1042 | + print '"' . getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') . '"' . $sep; |
|
1043 | 1043 | } elseif ($tabtype[$key] == 'payment_salary') { |
1044 | - print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep; |
|
1044 | + print '"' . getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') . '"' . $sep; |
|
1045 | 1045 | } else { |
1046 | - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
1046 | + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; |
|
1047 | 1047 | } |
1048 | - print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
1049 | - print '"'.$reflabel.'"'.$sep; |
|
1050 | - print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
1051 | - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
1052 | - print '"'.$journal.'"'.$sep; |
|
1053 | - print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
1048 | + print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; |
|
1049 | + print '"' . $reflabel . '"' . $sep; |
|
1050 | + print '"' . ($mt < 0 ? price(-$mt) : '') . '"' . $sep; |
|
1051 | + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; |
|
1052 | + print '"' . $journal . '"' . $sep; |
|
1053 | + print '"' . dol_string_nohtmltag($ref) . '"' . $sep; |
|
1054 | 1054 | print "\n"; |
1055 | 1055 | } |
1056 | 1056 | } |
@@ -1059,21 +1059,21 @@ discard block |
||
1059 | 1059 | if ($mt) { |
1060 | 1060 | $reflabel = ''; |
1061 | 1061 | if (!empty($val['lib'])) { |
1062 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
1062 | + $reflabel .= dol_string_nohtmltag($val['lib']) . " - "; |
|
1063 | 1063 | } |
1064 | 1064 | $reflabel .= dol_string_nohtmltag('WaitingAccount'); |
1065 | 1065 | |
1066 | - print '"'.$key.'"'.$sep; |
|
1067 | - print '"'.$date.'"'.$sep; |
|
1068 | - print '"'.$val["type_payment"].'"'.$sep; |
|
1069 | - print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep; |
|
1070 | - print '"'.length_accounta(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep; |
|
1066 | + print '"' . $key . '"' . $sep; |
|
1067 | + print '"' . $date . '"' . $sep; |
|
1068 | + print '"' . $val["type_payment"] . '"' . $sep; |
|
1069 | + print '"' . length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')) . '"' . $sep; |
|
1070 | + print '"' . length_accounta(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')) . '"' . $sep; |
|
1071 | 1071 | print $sep; |
1072 | - print '"'.$reflabel.'"'.$sep; |
|
1073 | - print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
1074 | - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
1075 | - print '"'.$journal.'"'.$sep; |
|
1076 | - print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
1072 | + print '"' . $reflabel . '"' . $sep; |
|
1073 | + print '"' . ($mt < 0 ? price(-$mt) : '') . '"' . $sep; |
|
1074 | + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; |
|
1075 | + print '"' . $journal . '"' . $sep; |
|
1076 | + print '"' . dol_string_nohtmltag($ref) . '"' . $sep; |
|
1077 | 1077 | print "\n"; |
1078 | 1078 | } |
1079 | 1079 | } |
@@ -1098,23 +1098,23 @@ discard block |
||
1098 | 1098 | $salarystatic = new Salary($db); |
1099 | 1099 | $variousstatic = new PaymentVarious($db); |
1100 | 1100 | |
1101 | - $title = $langs->trans("GenerationOfAccountingEntries").' - '.$accountingjournalstatic->getNomUrl(0, 2, 1, '', 1); |
|
1102 | - $help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité'; |
|
1101 | + $title = $langs->trans("GenerationOfAccountingEntries") . ' - ' . $accountingjournalstatic->getNomUrl(0, 2, 1, '', 1); |
|
1102 | + $help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité'; |
|
1103 | 1103 | llxHeader('', dol_string_nohtmltag($title), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-generation page-bankjournal'); |
1104 | 1104 | |
1105 | 1105 | $nom = $title; |
1106 | 1106 | $builddate = dol_now(); |
1107 | 1107 | //$description = $langs->trans("DescFinanceJournal") . '<br>'; |
1108 | - $description = $langs->trans("DescJournalOnlyBindedVisible").'<br>'; |
|
1108 | + $description = $langs->trans("DescJournalOnlyBindedVisible") . '<br>'; |
|
1109 | 1109 | |
1110 | 1110 | $listofchoices = array( |
1111 | 1111 | 'notyet' => $langs->trans("NotYetInGeneralLedger"), |
1112 | 1112 | 'already' => $langs->trans("AlreadyInGeneralLedger") |
1113 | 1113 | ); |
1114 | - $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); |
|
1115 | - $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
1114 | + $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0) . ' - ' . $form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); |
|
1115 | + $period .= ' - ' . $langs->trans("JournalizationInLedgerStatus") . ' ' . $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
1116 | 1116 | |
1117 | - $varlink = 'id_journal='.$id_journal; |
|
1117 | + $varlink = 'id_journal=' . $id_journal; |
|
1118 | 1118 | $periodlink = ''; |
1119 | 1119 | $exportlink = ''; |
1120 | 1120 | |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | 1 => $langs->trans("TransfertAllBankLines"), |
1123 | 1123 | 2 => $langs->trans("TransfertOnlyConciliatedBankLine") |
1124 | 1124 | ); |
1125 | - $moreoptions = [ "BankLineConciliated" => $form->selectarray('only_rappro', $listofchoices, $only_rappro)]; |
|
1125 | + $moreoptions = ["BankLineConciliated" => $form->selectarray('only_rappro', $listofchoices, $only_rappro)]; |
|
1126 | 1126 | |
1127 | 1127 | journalHead($nom, '', $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink, $moreoptions); |
1128 | 1128 | |
@@ -1131,14 +1131,14 @@ discard block |
||
1131 | 1131 | if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') { |
1132 | 1132 | // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) |
1133 | 1133 | // Fiscal period test |
1134 | - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); |
|
1134 | + $sql = "SELECT COUNT(rowid) as nb FROM " . MAIN_DB_PREFIX . "accounting_fiscalyear WHERE entity = " . ((int) $conf->entity); |
|
1135 | 1135 | $resql = $db->query($sql); |
1136 | 1136 | if ($resql) { |
1137 | 1137 | $obj = $db->fetch_object($resql); |
1138 | 1138 | if ($obj->nb == 0) { |
1139 | - print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); |
|
1140 | - $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); |
|
1141 | - $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'</strong>', $desc); |
|
1139 | + print '<br><div class="warning">' . img_warning() . ' ' . $langs->trans("TheFiscalPeriodIsNotDefined"); |
|
1140 | + $desc = ' : ' . $langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); |
|
1141 | + $desc = str_replace('{link}', '<strong>' . $langs->transnoentitiesnoconv("MenuAccountancy") . '-' . $langs->transnoentitiesnoconv("Setup") . "-" . $langs->transnoentitiesnoconv("FiscalPeriod") . '</strong>', $desc); |
|
1142 | 1142 | print $desc; |
1143 | 1143 | print '</div>'; |
1144 | 1144 | } |
@@ -1148,14 +1148,14 @@ discard block |
||
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | // Bank test |
1151 | - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."bank_account WHERE entity = ".((int) $conf->entity)." AND fk_accountancy_journal IS NULL AND clos=0"; |
|
1151 | + $sql = "SELECT COUNT(rowid) as nb FROM " . MAIN_DB_PREFIX . "bank_account WHERE entity = " . ((int) $conf->entity) . " AND fk_accountancy_journal IS NULL AND clos=0"; |
|
1152 | 1152 | $resql = $db->query($sql); |
1153 | 1153 | if ($resql) { |
1154 | 1154 | $obj = $db->fetch_object($resql); |
1155 | 1155 | if ($obj->nb > 0) { |
1156 | - print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); |
|
1157 | - $desc = ' : '.$langs->trans("AccountancyAreaDescBank", 6, '{link}'); |
|
1158 | - $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("BankAccounts").'</strong>', $desc); |
|
1156 | + print '<br><div class="warning">' . img_warning() . ' ' . $langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); |
|
1157 | + $desc = ' : ' . $langs->trans("AccountancyAreaDescBank", 6, '{link}'); |
|
1158 | + $desc = str_replace('{link}', '<strong>' . $langs->transnoentitiesnoconv("MenuAccountancy") . '-' . $langs->transnoentitiesnoconv("Setup") . "-" . $langs->transnoentitiesnoconv("BankAccounts") . '</strong>', $desc); |
|
1159 | 1159 | print $desc; |
1160 | 1160 | print '</div>'; |
1161 | 1161 | } |
@@ -1171,9 +1171,9 @@ discard block |
||
1171 | 1171 | || (isModEnabled("expensereport") && (getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == '-1'))) { |
1172 | 1172 | |
1173 | 1173 | |
1174 | - print($desc ? '' : '<br>').'<div class="warning">'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); |
|
1175 | - $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); |
|
1176 | - $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>', $desc); |
|
1174 | + print($desc ? '' : '<br>') . '<div class="warning">' . img_warning() . ' ' . $langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); |
|
1175 | + $desc = ' : ' . $langs->trans("AccountancyAreaDescMisc", 4, '{link}'); |
|
1176 | + $desc = str_replace('{link}', '<strong>' . $langs->transnoentitiesnoconv("MenuAccountancy") . '-' . $langs->transnoentitiesnoconv("Setup") . "-" . $langs->transnoentitiesnoconv("MenuDefaultAccounts") . '</strong>', $desc); |
|
1177 | 1177 | print $desc; |
1178 | 1178 | print '</div>'; |
1179 | 1179 | } |
@@ -1182,17 +1182,17 @@ discard block |
||
1182 | 1182 | print '<br><div class="tabsAction tabsActionNoBottom centerimp">'; |
1183 | 1183 | |
1184 | 1184 | if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping == 'notyet') { |
1185 | - print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; |
|
1185 | + print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />'; |
|
1186 | 1186 | } |
1187 | 1187 | |
1188 | 1188 | if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1' |
1189 | 1189 | || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1') { |
1190 | - print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; |
|
1190 | + print '<input type="button" class="butActionRefused classfortooltip" title="' . dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")) . '" value="' . $langs->trans("WriteBookKeeping") . '" />'; |
|
1191 | 1191 | } else { |
1192 | 1192 | if ($in_bookkeeping == 'notyet') { |
1193 | - print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; |
|
1193 | + print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; |
|
1194 | 1194 | } else { |
1195 | - print '<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; |
|
1195 | + print '<a class="butActionRefused classfortooltip" name="writebookkeeping">' . $langs->trans("WriteBookKeeping") . '</a>'; |
|
1196 | 1196 | } |
1197 | 1197 | } |
1198 | 1198 | |
@@ -1224,14 +1224,14 @@ discard block |
||
1224 | 1224 | print '<div class="div-table-responsive">'; |
1225 | 1225 | print '<table class="noborder centpercent">'; |
1226 | 1226 | print '<tr class="liste_titre">'; |
1227 | - print "<td>".$langs->trans("Date")."</td>"; |
|
1228 | - print "<td>".$langs->trans("Piece").' ('.$langs->trans("ObjectsRef").")</td>"; |
|
1229 | - print "<td>".$langs->trans("AccountAccounting")."</td>"; |
|
1230 | - print "<td>".$langs->trans("SubledgerAccount")."</td>"; |
|
1231 | - print "<td>".$langs->trans("LabelOperation")."</td>"; |
|
1232 | - print '<td class="center">'.$langs->trans("PaymentMode")."</td>"; |
|
1233 | - print '<td class="right">'.$langs->trans("AccountingDebit")."</td>"; |
|
1234 | - print '<td class="right">'.$langs->trans("AccountingCredit")."</td>"; |
|
1227 | + print "<td>" . $langs->trans("Date") . "</td>"; |
|
1228 | + print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("ObjectsRef") . ")</td>"; |
|
1229 | + print "<td>" . $langs->trans("AccountAccounting") . "</td>"; |
|
1230 | + print "<td>" . $langs->trans("SubledgerAccount") . "</td>"; |
|
1231 | + print "<td>" . $langs->trans("LabelOperation") . "</td>"; |
|
1232 | + print '<td class="center">' . $langs->trans("PaymentMode") . "</td>"; |
|
1233 | + print '<td class="right">' . $langs->trans("AccountingDebit") . "</td>"; |
|
1234 | + print '<td class="right">' . $langs->trans("AccountingCredit") . "</td>"; |
|
1235 | 1235 | print "</tr>\n"; |
1236 | 1236 | |
1237 | 1237 | $r = ''; |
@@ -1246,29 +1246,29 @@ discard block |
||
1246 | 1246 | if ($mt) { |
1247 | 1247 | $reflabel = ''; |
1248 | 1248 | if (!empty($val['lib'])) { |
1249 | - $reflabel .= $val['lib']." - "; |
|
1249 | + $reflabel .= $val['lib'] . " - "; |
|
1250 | 1250 | } |
1251 | - $reflabel .= $langs->trans("Bank").' '.$val['bank_account_ref']; |
|
1251 | + $reflabel .= $langs->trans("Bank") . ' ' . $val['bank_account_ref']; |
|
1252 | 1252 | if (!empty($val['soclib'])) { |
1253 | - $reflabel .= " - ".$val['soclib']; |
|
1253 | + $reflabel .= " - " . $val['soclib']; |
|
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | //var_dump($tabpay[$key]); |
1257 | - print '<!-- Bank bank.rowid='.$key.' type='.$tabpay[$key]['type'].' ref='.$tabpay[$key]['ref'].'-->'; |
|
1257 | + print '<!-- Bank bank.rowid=' . $key . ' type=' . $tabpay[$key]['type'] . ' ref=' . $tabpay[$key]['ref'] . '-->'; |
|
1258 | 1258 | print '<tr class="oddeven">'; |
1259 | 1259 | |
1260 | 1260 | // Date |
1261 | - print "<td>".$date."</td>"; |
|
1261 | + print "<td>" . $date . "</td>"; |
|
1262 | 1262 | |
1263 | 1263 | // Ref |
1264 | - print "<td>".dol_escape_htmltag($ref)."</td>"; |
|
1264 | + print "<td>" . dol_escape_htmltag($ref) . "</td>"; |
|
1265 | 1265 | |
1266 | 1266 | // Ledger account |
1267 | 1267 | $accounttoshow = length_accountg($k); |
1268 | 1268 | if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { |
1269 | - $accounttoshow = '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>'; |
|
1269 | + $accounttoshow = '<span class="error">' . $langs->trans("BankAccountNotDefined") . '</span>'; |
|
1270 | 1270 | } |
1271 | - print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">'; |
|
1271 | + print '<td class="maxwidth300" title="' . dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)) . '">'; |
|
1272 | 1272 | print $accounttoshow; |
1273 | 1273 | print "</td>"; |
1274 | 1274 | |
@@ -1284,12 +1284,12 @@ discard block |
||
1284 | 1284 | |
1285 | 1285 | // Label operation |
1286 | 1286 | print '<td>'; |
1287 | - print $reflabel; // This is already html escaped content |
|
1287 | + print $reflabel; // This is already html escaped content |
|
1288 | 1288 | print "</td>"; |
1289 | 1289 | |
1290 | - print '<td class="center">'.$val["type_payment"]."</td>"; |
|
1291 | - print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
1292 | - print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
1290 | + print '<td class="center">' . $val["type_payment"] . "</td>"; |
|
1291 | + print '<td class="right nowraponall amount">' . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
1292 | + print '<td class="right nowraponall amount">' . ($mt < 0 ? price(-$mt) : '') . "</td>"; |
|
1293 | 1293 | print "</tr>"; |
1294 | 1294 | |
1295 | 1295 | $i++; |
@@ -1302,22 +1302,22 @@ discard block |
||
1302 | 1302 | if ($mt) { |
1303 | 1303 | $reflabel = ''; |
1304 | 1304 | if (!empty($val['lib'])) { |
1305 | - $reflabel .= $val['lib'].(isset($val['soclib']) ? " - " : ""); |
|
1305 | + $reflabel .= $val['lib'] . (isset($val['soclib']) ? " - " : ""); |
|
1306 | 1306 | } |
1307 | 1307 | if ($tabtype[$key] == 'banktransfert') { |
1308 | - $reflabel .= $langs->trans('TransitionalAccount').' '.$account_transfer; |
|
1308 | + $reflabel .= $langs->trans('TransitionalAccount') . ' ' . $account_transfer; |
|
1309 | 1309 | } else { |
1310 | 1310 | $reflabel .= isset($val['soclib']) ? $val['soclib'] : ""; |
1311 | 1311 | } |
1312 | 1312 | |
1313 | - print '<!-- Thirdparty bank.rowid='.$key.' -->'; |
|
1313 | + print '<!-- Thirdparty bank.rowid=' . $key . ' -->'; |
|
1314 | 1314 | print '<tr class="oddeven">'; |
1315 | 1315 | |
1316 | 1316 | // Date |
1317 | - print "<td>".$date."</td>"; |
|
1317 | + print "<td>" . $date . "</td>"; |
|
1318 | 1318 | |
1319 | 1319 | // Ref |
1320 | - print "<td>".dol_escape_htmltag($ref)."</td>"; |
|
1320 | + print "<td>" . dol_escape_htmltag($ref) . "</td>"; |
|
1321 | 1321 | |
1322 | 1322 | // Ledger account |
1323 | 1323 | $account_ledger = $k; |
@@ -1348,9 +1348,9 @@ discard block |
||
1348 | 1348 | if ($tabtype[$key] == 'unknown') { |
1349 | 1349 | // We will accept writing, but into a waiting account |
1350 | 1350 | if (!getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') || getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') == '-1') { |
1351 | - $accounttoshow = '<span class="error small">'.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').'</span>'; |
|
1351 | + $accounttoshow = '<span class="error small">' . $langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking') . '</span>'; |
|
1352 | 1352 | } else { |
1353 | - $accounttoshow = '<span class="warning small">'.$langs->trans('UnknownAccountForThirdparty', length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'))).'</span>'; // We will use a waiting account |
|
1353 | + $accounttoshow = '<span class="warning small">' . $langs->trans('UnknownAccountForThirdparty', length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'))) . '</span>'; // We will use a waiting account |
|
1354 | 1354 | } |
1355 | 1355 | } else { |
1356 | 1356 | // We will refuse writing |
@@ -1373,11 +1373,11 @@ discard block |
||
1373 | 1373 | if ($tabtype[$key] == 'member') { |
1374 | 1374 | $errorstring = 'MainAccountForSubscriptionPaymentNotDefined'; |
1375 | 1375 | } |
1376 | - $accounttoshow = '<span class="error small">'.$langs->trans($errorstring).'</span>'; |
|
1376 | + $accounttoshow = '<span class="error small">' . $langs->trans($errorstring) . '</span>'; |
|
1377 | 1377 | } |
1378 | 1378 | } |
1379 | - print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">'; |
|
1380 | - print $accounttoshow; // This is a HTML string |
|
1379 | + print '<td class="maxwidth300" title="' . dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)) . '">'; |
|
1380 | + print $accounttoshow; // This is a HTML string |
|
1381 | 1381 | print "</td>"; |
1382 | 1382 | |
1383 | 1383 | // Subledger account |
@@ -1393,12 +1393,12 @@ discard block |
||
1393 | 1393 | if (!empty($tabcompany[$key]['code_compta'])) { |
1394 | 1394 | if (in_array($tabtype[$key], array('payment_various', 'payment_salary'))) { |
1395 | 1395 | // For such case, if subledger is not defined, we won't use subledger accounts. |
1396 | - $accounttoshowsubledger = '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").'</span>'; |
|
1396 | + $accounttoshowsubledger = '<span class="warning small">' . $langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored") . '</span>'; |
|
1397 | 1397 | } else { |
1398 | - $accounttoshowsubledger = '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>'; |
|
1398 | + $accounttoshowsubledger = '<span class="warning small">' . $langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']) . '</span>'; |
|
1399 | 1399 | } |
1400 | 1400 | } else { |
1401 | - $accounttoshowsubledger = '<span class="error small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").'</span>'; |
|
1401 | + $accounttoshowsubledger = '<span class="error small">' . $langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking") . '</span>'; |
|
1402 | 1402 | } |
1403 | 1403 | } |
1404 | 1404 | } else { |
@@ -1406,16 +1406,16 @@ discard block |
||
1406 | 1406 | } |
1407 | 1407 | } |
1408 | 1408 | print '<td class="maxwidth300">'; |
1409 | - print $accounttoshowsubledger; // This is a html string |
|
1409 | + print $accounttoshowsubledger; // This is a html string |
|
1410 | 1410 | print "</td>"; |
1411 | 1411 | |
1412 | - print "<td>".$reflabel."</td>"; |
|
1412 | + print "<td>" . $reflabel . "</td>"; |
|
1413 | 1413 | |
1414 | - print '<td class="center">'.$val["type_payment"]."</td>"; |
|
1414 | + print '<td class="center">' . $val["type_payment"] . "</td>"; |
|
1415 | 1415 | |
1416 | - print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
1416 | + print '<td class="right nowraponall amount">' . ($mt < 0 ? price(-$mt) : '') . "</td>"; |
|
1417 | 1417 | |
1418 | - print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
1418 | + print '<td class="right nowraponall amount">' . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
1419 | 1419 | |
1420 | 1420 | print "</tr>"; |
1421 | 1421 | |
@@ -1427,14 +1427,14 @@ discard block |
||
1427 | 1427 | if ($mt) { |
1428 | 1428 | $reflabel = ''; |
1429 | 1429 | if (!empty($val['lib'])) { |
1430 | - $reflabel .= $val['lib']." - "; |
|
1430 | + $reflabel .= $val['lib'] . " - "; |
|
1431 | 1431 | } |
1432 | 1432 | $reflabel .= 'WaitingAccount'; |
1433 | 1433 | |
1434 | - print '<!-- Wait bank.rowid='.$key.' -->'; |
|
1434 | + print '<!-- Wait bank.rowid=' . $key . ' -->'; |
|
1435 | 1435 | print '<tr class="oddeven">'; |
1436 | - print "<td>".$date."</td>"; |
|
1437 | - print "<td>".$ref."</td>"; |
|
1436 | + print "<td>" . $date . "</td>"; |
|
1437 | + print "<td>" . $ref . "</td>"; |
|
1438 | 1438 | // Ledger account |
1439 | 1439 | print "<td>"; |
1440 | 1440 | /*if (empty($accounttoshow) || $accounttoshow == 'NotDefined') |
@@ -1447,10 +1447,10 @@ discard block |
||
1447 | 1447 | // Subledger account |
1448 | 1448 | print "<td>"; |
1449 | 1449 | print "</td>"; |
1450 | - print "<td>".dol_escape_htmltag($reflabel)."</td>"; |
|
1451 | - print '<td class="center">'.$val["type_payment"]."</td>"; |
|
1452 | - print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
1453 | - print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
1450 | + print "<td>" . dol_escape_htmltag($reflabel) . "</td>"; |
|
1451 | + print '<td class="center">' . $val["type_payment"] . "</td>"; |
|
1452 | + print '<td class="right nowraponall amount">' . ($mt < 0 ? price(-$mt) : '') . "</td>"; |
|
1453 | + print '<td class="right nowraponall amount">' . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
1454 | 1454 | print "</tr>"; |
1455 | 1455 | |
1456 | 1456 | $i++; |
@@ -1461,7 +1461,7 @@ discard block |
||
1461 | 1461 | |
1462 | 1462 | if (!$i) { |
1463 | 1463 | $colspan = 8; |
1464 | - print '<tr class="oddeven"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>'; |
|
1464 | + print '<tr class="oddeven"><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs->trans("NoRecordFound") . '</span></td></tr>'; |
|
1465 | 1465 | } |
1466 | 1466 | |
1467 | 1467 | print "</table>"; |
@@ -1516,77 +1516,77 @@ discard block |
||
1516 | 1516 | $sqlmid = ''; |
1517 | 1517 | if ($typerecord == 'payment') { |
1518 | 1518 | if (getDolGlobalInt('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) { |
1519 | - $sqlmid = "SELECT payfac.fk_facture as id, ".$db->ifsql('f1.rowid IS NULL', 'f.ref', 'f1.ref')." as ref"; |
|
1520 | - $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac"; |
|
1521 | - $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture"; |
|
1522 | - $sqlmid .= " LEFT JOIN ".$db->prefix()."societe_remise_except as sre ON sre.fk_facture_source = payfac.fk_facture"; |
|
1523 | - $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f1 ON f1.rowid = sre.fk_facture"; |
|
1524 | - $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']); |
|
1519 | + $sqlmid = "SELECT payfac.fk_facture as id, " . $db->ifsql('f1.rowid IS NULL', 'f.ref', 'f1.ref') . " as ref"; |
|
1520 | + $sqlmid .= " FROM " . $db->prefix() . "paiement_facture as payfac"; |
|
1521 | + $sqlmid .= " LEFT JOIN " . $db->prefix() . "facture as f ON f.rowid = payfac.fk_facture"; |
|
1522 | + $sqlmid .= " LEFT JOIN " . $db->prefix() . "societe_remise_except as sre ON sre.fk_facture_source = payfac.fk_facture"; |
|
1523 | + $sqlmid .= " LEFT JOIN " . $db->prefix() . "facture as f1 ON f1.rowid = sre.fk_facture"; |
|
1524 | + $sqlmid .= " WHERE payfac.fk_paiement=" . ((int) $val['paymentid']); |
|
1525 | 1525 | } else { |
1526 | 1526 | $sqlmid = "SELECT payfac.fk_facture as id, f.ref as ref"; |
1527 | - $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac"; |
|
1528 | - $sqlmid .= " INNER JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture"; |
|
1529 | - $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']); |
|
1527 | + $sqlmid .= " FROM " . $db->prefix() . "paiement_facture as payfac"; |
|
1528 | + $sqlmid .= " INNER JOIN " . $db->prefix() . "facture as f ON f.rowid = payfac.fk_facture"; |
|
1529 | + $sqlmid .= " WHERE payfac.fk_paiement=" . ((int) $val['paymentid']); |
|
1530 | 1530 | } |
1531 | 1531 | $ref = $langs->transnoentitiesnoconv("Invoice"); |
1532 | 1532 | } elseif ($typerecord == 'payment_supplier') { |
1533 | 1533 | $sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref'; |
1534 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
1535 | - $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".((int) $val["paymentsupplierid"]); |
|
1534 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfac, " . MAIN_DB_PREFIX . "facture_fourn as f"; |
|
1535 | + $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=" . ((int) $val["paymentsupplierid"]); |
|
1536 | 1536 | $ref = $langs->transnoentitiesnoconv("SupplierInvoice"); |
1537 | 1537 | } elseif ($typerecord == 'payment_expensereport') { |
1538 | 1538 | $sqlmid = 'SELECT e.rowid as id, e.ref'; |
1539 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as pe, ".MAIN_DB_PREFIX."expensereport as e"; |
|
1540 | - $sqlmid .= " WHERE pe.rowid=".((int) $val["paymentexpensereport"])." AND pe.fk_expensereport = e.rowid"; |
|
1539 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_expensereport as pe, " . MAIN_DB_PREFIX . "expensereport as e"; |
|
1540 | + $sqlmid .= " WHERE pe.rowid=" . ((int) $val["paymentexpensereport"]) . " AND pe.fk_expensereport = e.rowid"; |
|
1541 | 1541 | $ref = $langs->transnoentitiesnoconv("ExpenseReport"); |
1542 | 1542 | } elseif ($typerecord == 'payment_salary') { |
1543 | 1543 | $sqlmid = 'SELECT s.rowid as ref'; |
1544 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; |
|
1545 | - $sqlmid .= " WHERE s.rowid=".((int) $val["paymentsalid"]); |
|
1544 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_salary as s"; |
|
1545 | + $sqlmid .= " WHERE s.rowid=" . ((int) $val["paymentsalid"]); |
|
1546 | 1546 | $ref = $langs->transnoentitiesnoconv("SalaryPayment"); |
1547 | 1547 | } elseif ($typerecord == 'sc') { |
1548 | 1548 | $sqlmid = 'SELECT sc.rowid as ref'; |
1549 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementcharge as sc"; |
|
1550 | - $sqlmid .= " WHERE sc.rowid=".((int) $val["paymentscid"]); |
|
1549 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementcharge as sc"; |
|
1550 | + $sqlmid .= " WHERE sc.rowid=" . ((int) $val["paymentscid"]); |
|
1551 | 1551 | $ref = $langs->transnoentitiesnoconv("SocialContribution"); |
1552 | 1552 | } elseif ($typerecord == 'payment_vat') { |
1553 | 1553 | $sqlmid = 'SELECT v.rowid as ref'; |
1554 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v"; |
|
1555 | - $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvatid"]); |
|
1554 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "tva as v"; |
|
1555 | + $sqlmid .= " WHERE v.rowid=" . ((int) $val["paymentvatid"]); |
|
1556 | 1556 | $ref = $langs->transnoentitiesnoconv("PaymentVat"); |
1557 | 1557 | } elseif ($typerecord == 'payment_donation') { |
1558 | 1558 | $sqlmid = 'SELECT payd.fk_donation as ref'; |
1559 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_donation as payd"; |
|
1560 | - $sqlmid .= " WHERE payd.fk_donation=".((int) $val["paymentdonationid"]); |
|
1559 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_donation as payd"; |
|
1560 | + $sqlmid .= " WHERE payd.fk_donation=" . ((int) $val["paymentdonationid"]); |
|
1561 | 1561 | $ref = $langs->transnoentitiesnoconv("Donation"); |
1562 | 1562 | } elseif ($typerecord == 'payment_loan') { |
1563 | 1563 | $sqlmid = 'SELECT l.rowid as ref'; |
1564 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_loan as l"; |
|
1565 | - $sqlmid .= " WHERE l.rowid=".((int) $val["paymentloanid"]); |
|
1564 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_loan as l"; |
|
1565 | + $sqlmid .= " WHERE l.rowid=" . ((int) $val["paymentloanid"]); |
|
1566 | 1566 | $ref = $langs->transnoentitiesnoconv("LoanPayment"); |
1567 | 1567 | } elseif ($typerecord == 'payment_various') { |
1568 | 1568 | $sqlmid = 'SELECT v.rowid as ref'; |
1569 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; |
|
1570 | - $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvariousid"]); |
|
1569 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_various as v"; |
|
1570 | + $sqlmid .= " WHERE v.rowid=" . ((int) $val["paymentvariousid"]); |
|
1571 | 1571 | $ref = $langs->transnoentitiesnoconv("VariousPayment"); |
1572 | 1572 | } |
1573 | 1573 | // Add warning |
1574 | 1574 | if (empty($sqlmid)) { |
1575 | - dol_syslog("Found a typerecord=".$typerecord." not supported", LOG_WARNING); |
|
1575 | + dol_syslog("Found a typerecord=" . $typerecord . " not supported", LOG_WARNING); |
|
1576 | 1576 | } |
1577 | 1577 | |
1578 | 1578 | if ($sqlmid) { |
1579 | - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG); |
|
1579 | + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); |
|
1580 | 1580 | $resultmid = $db->query($sqlmid); |
1581 | 1581 | if ($resultmid) { |
1582 | 1582 | while ($objmid = $db->fetch_object($resultmid)) { |
1583 | - $ref .= ' '.$objmid->ref; |
|
1583 | + $ref .= ' ' . $objmid->ref; |
|
1584 | 1584 | } |
1585 | 1585 | } else { |
1586 | 1586 | dol_print_error($db); |
1587 | 1587 | } |
1588 | 1588 | } |
1589 | 1589 | |
1590 | - $ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300 |
|
1590 | + $ref = dol_trunc($langs->transnoentitiesnoconv("BankId") . ' ' . $val['fk_bank'] . ' - ' . $ref, 295); // 295 + 3 dots (...) is < than max size of 300 |
|
1591 | 1591 | return $ref; |
1592 | 1592 | } |
@@ -369,235 +369,235 @@ discard block |
||
369 | 369 | // We save tabtype for a future use, to remember what kind of payment it is |
370 | 370 | $tabpay[$obj->rowid]['type'] = $links[$key]['type']; |
371 | 371 | $tabtype[$obj->rowid] = $links[$key]['type']; |
372 | - /* phpcs:disable -- Code does nothing at this moment -> commented |
|
372 | + /* phpcs:disable -- Code does nothing at this moment -> commented |
|
373 | 373 | } elseif (in_array($links[$key]['type'], array('company', 'user'))) { |
374 | 374 | if ($tabpay[$obj->rowid]['type'] == 'unknown') { |
375 | 375 | // We can guess here it is a bank record for a thirdparty company or a user. |
376 | 376 | // But we won't be able to record somewhere else than into a waiting account, because there is no other journal to record the contreparty. |
377 | 377 | } |
378 | 378 | */ // phpcs::enable |
379 | - } |
|
380 | - |
|
381 | - // Special case to ask later to add more request to get information for old links without company link. |
|
382 | - if ($links[$key]['type'] == 'withdraw') { |
|
383 | - $tabmoreinfo[$obj->rowid]['withdraw'] = 1; |
|
384 | - } |
|
379 | + } |
|
385 | 380 | |
386 | - if ($links[$key]['type'] == 'payment') { |
|
387 | - $paymentstatic->id = $links[$key]['url_id']; |
|
388 | - $paymentstatic->ref = $links[$key]['url_id']; |
|
389 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this |
|
390 | - $tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id; |
|
391 | - } elseif ($links[$key]['type'] == 'payment_supplier') { |
|
392 | - $paymentsupplierstatic->id = $links[$key]['url_id']; |
|
393 | - $paymentsupplierstatic->ref = $links[$key]['url_id']; |
|
394 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsupplierstatic->getNomUrl(2); |
|
395 | - $tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id; |
|
396 | - } elseif ($links[$key]['type'] == 'company') { |
|
397 | - $societestatic->id = $links[$key]['url_id']; |
|
398 | - $societestatic->name = $links[$key]['label']; |
|
399 | - $societestatic->email = $tabcompany[$obj->rowid]['email']; |
|
400 | - $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); |
|
401 | - if ($compta_soc) { |
|
402 | - if (empty($tabtp[$obj->rowid][$compta_soc])) { |
|
403 | - $tabtp[$obj->rowid][$compta_soc] = $amounttouse; |
|
404 | - } else { |
|
405 | - $tabtp[$obj->rowid][$compta_soc] += $amounttouse; |
|
406 | - } |
|
407 | - } |
|
408 | - } elseif ($links[$key]['type'] == 'user') { |
|
409 | - $userstatic->id = $links[$key]['url_id']; |
|
410 | - $userstatic->name = $links[$key]['label']; |
|
411 | - $userstatic->email = $tabuser[$obj->rowid]['email']; |
|
412 | - $userstatic->firstname = $tabuser[$obj->rowid]['firstname']; |
|
413 | - $userstatic->lastname = $tabuser[$obj->rowid]['lastname']; |
|
414 | - $userstatic->status = $tabuser[$obj->rowid]['status']; |
|
415 | - $userstatic->accountancy_code = $tabuser[$obj->rowid]['accountancy_code']; |
|
416 | - if ($userstatic->id > 0) { |
|
417 | - $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0); |
|
418 | - } else { |
|
419 | - $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. |
|
420 | - } |
|
421 | - if ($compta_user) { |
|
422 | - $tabtp[$obj->rowid][$compta_user] += $amounttouse; |
|
423 | - } |
|
424 | - } elseif ($links[$key]['type'] == 'sc') { |
|
425 | - $chargestatic->id = $links[$key]['url_id']; |
|
426 | - $chargestatic->ref = $links[$key]['url_id']; |
|
427 | - |
|
428 | - $tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2); |
|
429 | - $reg = array(); |
|
430 | - if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { |
|
431 | - if ($reg[1] == 'socialcontribution') { |
|
432 | - $reg[1] = 'SocialContribution'; |
|
433 | - } |
|
434 | - $chargestatic->label = $langs->trans($reg[1]); |
|
435 | - } else { |
|
436 | - $chargestatic->label = $links[$key]['label']; |
|
437 | - } |
|
438 | - $chargestatic->ref = $chargestatic->label; |
|
439 | - $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); |
|
440 | - $tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id; |
|
441 | - |
|
442 | - // Retrieve the accounting code of the social contribution of the payment from link of payment. |
|
443 | - // Note: We have the social contribution id, it can be faster to get accounting code from social contribution id. |
|
444 | - $sqlmid = "SELECT cchgsoc.accountancy_code"; |
|
445 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc"; |
|
446 | - $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type = cchgsoc.id"; |
|
447 | - $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge = chgsoc.rowid"; |
|
448 | - $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid AND bkurl.type = 'payment_sc'"; |
|
449 | - $sqlmid .= " WHERE bkurl.fk_bank = ".((int) $obj->rowid); |
|
450 | - |
|
451 | - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); |
|
452 | - $resultmid = $db->query($sqlmid); |
|
453 | - if ($resultmid) { |
|
454 | - $objmid = $db->fetch_object($resultmid); |
|
455 | - $tabtp[$obj->rowid][$objmid->accountancy_code] = isset($tabtp[$obj->rowid][$objmid->accountancy_code]) ? $tabtp[$obj->rowid][$objmid->accountancy_code] + $amounttouse : $amounttouse; |
|
456 | - } |
|
457 | - } elseif ($links[$key]['type'] == 'payment_donation') { |
|
458 | - $paymentdonstatic->id = $links[$key]['url_id']; |
|
459 | - $paymentdonstatic->ref = $links[$key]['url_id']; |
|
460 | - $paymentdonstatic->fk_donation = $links[$key]['url_id']; |
|
461 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2); |
|
462 | - $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id; |
|
463 | - $tabtp[$obj->rowid][$account_pay_donation] = isset($tabtp[$obj->rowid][$account_pay_donation]) ? $tabtp[$obj->rowid][$account_pay_donation] + $amounttouse : $amounttouse; |
|
464 | - } elseif ($links[$key]['type'] == 'member') { |
|
465 | - $paymentsubscriptionstatic->id = $links[$key]['url_id']; |
|
466 | - $paymentsubscriptionstatic->ref = $links[$key]['url_id']; |
|
467 | - $paymentsubscriptionstatic->label = $links[$key]['label']; |
|
468 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2); |
|
469 | - $tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id; |
|
470 | - $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id); |
|
471 | - $tabtp[$obj->rowid][$account_pay_subscription] = isset($tabtp[$obj->rowid][$account_pay_subscription]) ? $tabtp[$obj->rowid][$account_pay_subscription] + $amounttouse : $amounttouse; |
|
472 | - } elseif ($links[$key]['type'] == 'payment_vat') { // Payment VAT |
|
473 | - $paymentvatstatic->id = $links[$key]['url_id']; |
|
474 | - $paymentvatstatic->ref = $links[$key]['url_id']; |
|
475 | - $paymentvatstatic->label = $links[$key]['label']; |
|
476 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2); |
|
477 | - $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id; |
|
478 | - $tabtp[$obj->rowid][$account_pay_vat] = isset($tabtp[$obj->rowid][$account_pay_vat]) ? $tabtp[$obj->rowid][$account_pay_vat] + $amounttouse : $amounttouse; |
|
479 | - } elseif ($links[$key]['type'] == 'payment_salary') { |
|
480 | - $paymentsalstatic->id = $links[$key]['url_id']; |
|
481 | - $paymentsalstatic->ref = $links[$key]['url_id']; |
|
482 | - $paymentsalstatic->label = $links[$key]['label']; |
|
483 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsalstatic->getNomUrl(2); |
|
484 | - $tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id; |
|
485 | - |
|
486 | - // This part of code is no more required. it is here to solve case where a link were missing (with v14.0.0) and keep writing in accountancy complete. |
|
487 | - // Note: A better way to fix this is to delete payment of salary and recreate it, or to fix the bookkeeping table manually after. |
|
488 | - if (getDolGlobalString('ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USER_ON_SALARY_BANK_PAYMENT')) { |
|
489 | - $tmpsalary = new Salary($db); |
|
490 | - $tmpsalary->fetch($paymentsalstatic->id); |
|
491 | - $tmpsalary->fetch_user($tmpsalary->fk_user); |
|
492 | - |
|
493 | - $userstatic->id = $tmpsalary->user->id; |
|
494 | - $userstatic->name = $tmpsalary->user->name; |
|
495 | - $userstatic->email = $tmpsalary->user->email; |
|
496 | - $userstatic->firstname = $tmpsalary->user->firstname; |
|
497 | - $userstatic->lastname = $tmpsalary->user->lastname; |
|
498 | - $userstatic->status = $tmpsalary->user->status; |
|
499 | - $userstatic->accountancy_code = $tmpsalary->user->accountancy_code; |
|
500 | - |
|
501 | - if ($userstatic->id > 0) { |
|
502 | - $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0); |
|
503 | - } else { |
|
504 | - $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen |
|
505 | - } |
|
381 | + // Special case to ask later to add more request to get information for old links without company link. |
|
382 | + if ($links[$key]['type'] == 'withdraw') { |
|
383 | + $tabmoreinfo[$obj->rowid]['withdraw'] = 1; |
|
384 | + } |
|
506 | 385 | |
507 | - if (empty($obj->typeop_user)) { // Add test to avoid to add amount twice if a link already exists also on user. |
|
508 | - $compta_user = $userstatic->accountancy_code; |
|
509 | - if ($compta_user) { |
|
510 | - $tabtp[$obj->rowid][$compta_user] += $amounttouse; |
|
511 | - $tabuser[$obj->rowid] = array( |
|
512 | - 'id' => $userstatic->id, |
|
513 | - 'name' => dolGetFirstLastname($userstatic->firstname, $userstatic->lastname), |
|
514 | - 'lastname' => $userstatic->lastname, |
|
515 | - 'firstname' => $userstatic->firstname, |
|
516 | - 'email' => $userstatic->email, |
|
517 | - 'accountancy_code' => $compta_user, |
|
518 | - 'status' => $userstatic->status |
|
519 | - ); |
|
520 | - } |
|
521 | - } |
|
522 | - } |
|
523 | - } elseif ($links[$key]['type'] == 'payment_expensereport') { |
|
524 | - $paymentexpensereportstatic->id = $links[$key]['url_id']; |
|
525 | - $tabpay[$obj->rowid]["lib"] .= $paymentexpensereportstatic->getNomUrl(2); |
|
526 | - $tabpay[$obj->rowid]["paymentexpensereport"] = $paymentexpensereportstatic->id; |
|
527 | - } elseif ($links[$key]['type'] == 'payment_various') { |
|
528 | - $paymentvariousstatic->id = $links[$key]['url_id']; |
|
529 | - $paymentvariousstatic->ref = $links[$key]['url_id']; |
|
530 | - $paymentvariousstatic->label = $links[$key]['label']; |
|
531 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvariousstatic->getNomUrl(2); |
|
532 | - $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; |
|
533 | - $paymentvariousstatic->fetch($paymentvariousstatic->id); |
|
534 | - $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word |
|
535 | - $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word |
|
536 | - $tabpay[$obj->rowid]["account_various"] = $account_various; |
|
537 | - $tabtp[$obj->rowid][$account_subledger] = isset($tabtp[$obj->rowid][$account_subledger]) ? $tabtp[$obj->rowid][$account_subledger] + $amounttouse : $amounttouse; |
|
538 | - } elseif ($links[$key]['type'] == 'payment_loan') { |
|
539 | - $paymentloanstatic->id = $links[$key]['url_id']; |
|
540 | - $paymentloanstatic->ref = $links[$key]['url_id']; |
|
541 | - $paymentloanstatic->fk_loan = $links[$key]['url_id']; |
|
542 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2); |
|
543 | - $tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id; |
|
544 | - //$tabtp[$obj->rowid][$account_pay_loan] += $amounttouse; |
|
545 | - $sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest'; |
|
546 | - $sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l'; |
|
547 | - $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid); |
|
548 | - |
|
549 | - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); |
|
550 | - $resultmid = $db->query($sqlmid); |
|
551 | - if ($resultmid) { |
|
552 | - $objmid = $db->fetch_object($resultmid); |
|
553 | - $tabtp[$obj->rowid][$objmid->accountancy_account_capital] = isset($tabtp[$obj->rowid][$objmid->accountancy_account_capital]) ? $tabtp[$obj->rowid][$objmid->accountancy_account_capital] - $objmid->amount_capital : $amounttouse; |
|
554 | - $tabtp[$obj->rowid][$objmid->accountancy_account_insurance] = isset($tabtp[$obj->rowid][$objmid->accountancy_account_insurance]) ? $tabtp[$obj->rowid][$objmid->accountancy_account_insurance] - $objmid->amount_insurance : $amounttouse; |
|
555 | - $tabtp[$obj->rowid][$objmid->accountancy_account_interest] = isset($tabtp[$obj->rowid][$objmid->accountancy_account_interest]) ? $tabtp[$obj->rowid][$objmid->accountancy_account_interest] - $objmid->amount_interes : $amounttouse; |
|
556 | - } |
|
557 | - } elseif ($links[$key]['type'] == 'banktransfert') { |
|
558 | - $accountLinestatic->fetch($links[$key]['url_id']); |
|
559 | - $tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- '.$accountLinestatic ->getNomUrl(1); |
|
560 | - $tabtp[$obj->rowid][$account_transfer] = isset($tabtp[$obj->rowid][$account_transfer]) ? $tabtp[$obj->rowid][$account_transfer] + $amounttouse : $amounttouse; |
|
561 | - $bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']); |
|
562 | - $tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2); |
|
563 | - } |
|
564 | - } |
|
565 | - } |
|
386 | + if ($links[$key]['type'] == 'payment') { |
|
387 | + $paymentstatic->id = $links[$key]['url_id']; |
|
388 | + $paymentstatic->ref = $links[$key]['url_id']; |
|
389 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this |
|
390 | + $tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id; |
|
391 | + } elseif ($links[$key]['type'] == 'payment_supplier') { |
|
392 | + $paymentsupplierstatic->id = $links[$key]['url_id']; |
|
393 | + $paymentsupplierstatic->ref = $links[$key]['url_id']; |
|
394 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsupplierstatic->getNomUrl(2); |
|
395 | + $tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id; |
|
396 | + } elseif ($links[$key]['type'] == 'company') { |
|
397 | + $societestatic->id = $links[$key]['url_id']; |
|
398 | + $societestatic->name = $links[$key]['label']; |
|
399 | + $societestatic->email = $tabcompany[$obj->rowid]['email']; |
|
400 | + $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); |
|
401 | + if ($compta_soc) { |
|
402 | + if (empty($tabtp[$obj->rowid][$compta_soc])) { |
|
403 | + $tabtp[$obj->rowid][$compta_soc] = $amounttouse; |
|
404 | + } else { |
|
405 | + $tabtp[$obj->rowid][$compta_soc] += $amounttouse; |
|
406 | + } |
|
407 | + } |
|
408 | + } elseif ($links[$key]['type'] == 'user') { |
|
409 | + $userstatic->id = $links[$key]['url_id']; |
|
410 | + $userstatic->name = $links[$key]['label']; |
|
411 | + $userstatic->email = $tabuser[$obj->rowid]['email']; |
|
412 | + $userstatic->firstname = $tabuser[$obj->rowid]['firstname']; |
|
413 | + $userstatic->lastname = $tabuser[$obj->rowid]['lastname']; |
|
414 | + $userstatic->status = $tabuser[$obj->rowid]['status']; |
|
415 | + $userstatic->accountancy_code = $tabuser[$obj->rowid]['accountancy_code']; |
|
416 | + if ($userstatic->id > 0) { |
|
417 | + $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0); |
|
418 | + } else { |
|
419 | + $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. |
|
420 | + } |
|
421 | + if ($compta_user) { |
|
422 | + $tabtp[$obj->rowid][$compta_user] += $amounttouse; |
|
423 | + } |
|
424 | + } elseif ($links[$key]['type'] == 'sc') { |
|
425 | + $chargestatic->id = $links[$key]['url_id']; |
|
426 | + $chargestatic->ref = $links[$key]['url_id']; |
|
427 | + |
|
428 | + $tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2); |
|
429 | + $reg = array(); |
|
430 | + if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { |
|
431 | + if ($reg[1] == 'socialcontribution') { |
|
432 | + $reg[1] = 'SocialContribution'; |
|
433 | + } |
|
434 | + $chargestatic->label = $langs->trans($reg[1]); |
|
435 | + } else { |
|
436 | + $chargestatic->label = $links[$key]['label']; |
|
437 | + } |
|
438 | + $chargestatic->ref = $chargestatic->label; |
|
439 | + $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); |
|
440 | + $tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id; |
|
441 | + |
|
442 | + // Retrieve the accounting code of the social contribution of the payment from link of payment. |
|
443 | + // Note: We have the social contribution id, it can be faster to get accounting code from social contribution id. |
|
444 | + $sqlmid = "SELECT cchgsoc.accountancy_code"; |
|
445 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc"; |
|
446 | + $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type = cchgsoc.id"; |
|
447 | + $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge = chgsoc.rowid"; |
|
448 | + $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid AND bkurl.type = 'payment_sc'"; |
|
449 | + $sqlmid .= " WHERE bkurl.fk_bank = ".((int) $obj->rowid); |
|
450 | + |
|
451 | + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); |
|
452 | + $resultmid = $db->query($sqlmid); |
|
453 | + if ($resultmid) { |
|
454 | + $objmid = $db->fetch_object($resultmid); |
|
455 | + $tabtp[$obj->rowid][$objmid->accountancy_code] = isset($tabtp[$obj->rowid][$objmid->accountancy_code]) ? $tabtp[$obj->rowid][$objmid->accountancy_code] + $amounttouse : $amounttouse; |
|
456 | + } |
|
457 | + } elseif ($links[$key]['type'] == 'payment_donation') { |
|
458 | + $paymentdonstatic->id = $links[$key]['url_id']; |
|
459 | + $paymentdonstatic->ref = $links[$key]['url_id']; |
|
460 | + $paymentdonstatic->fk_donation = $links[$key]['url_id']; |
|
461 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2); |
|
462 | + $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id; |
|
463 | + $tabtp[$obj->rowid][$account_pay_donation] = isset($tabtp[$obj->rowid][$account_pay_donation]) ? $tabtp[$obj->rowid][$account_pay_donation] + $amounttouse : $amounttouse; |
|
464 | + } elseif ($links[$key]['type'] == 'member') { |
|
465 | + $paymentsubscriptionstatic->id = $links[$key]['url_id']; |
|
466 | + $paymentsubscriptionstatic->ref = $links[$key]['url_id']; |
|
467 | + $paymentsubscriptionstatic->label = $links[$key]['label']; |
|
468 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2); |
|
469 | + $tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id; |
|
470 | + $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id); |
|
471 | + $tabtp[$obj->rowid][$account_pay_subscription] = isset($tabtp[$obj->rowid][$account_pay_subscription]) ? $tabtp[$obj->rowid][$account_pay_subscription] + $amounttouse : $amounttouse; |
|
472 | + } elseif ($links[$key]['type'] == 'payment_vat') { // Payment VAT |
|
473 | + $paymentvatstatic->id = $links[$key]['url_id']; |
|
474 | + $paymentvatstatic->ref = $links[$key]['url_id']; |
|
475 | + $paymentvatstatic->label = $links[$key]['label']; |
|
476 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2); |
|
477 | + $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id; |
|
478 | + $tabtp[$obj->rowid][$account_pay_vat] = isset($tabtp[$obj->rowid][$account_pay_vat]) ? $tabtp[$obj->rowid][$account_pay_vat] + $amounttouse : $amounttouse; |
|
479 | + } elseif ($links[$key]['type'] == 'payment_salary') { |
|
480 | + $paymentsalstatic->id = $links[$key]['url_id']; |
|
481 | + $paymentsalstatic->ref = $links[$key]['url_id']; |
|
482 | + $paymentsalstatic->label = $links[$key]['label']; |
|
483 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsalstatic->getNomUrl(2); |
|
484 | + $tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id; |
|
485 | + |
|
486 | + // This part of code is no more required. it is here to solve case where a link were missing (with v14.0.0) and keep writing in accountancy complete. |
|
487 | + // Note: A better way to fix this is to delete payment of salary and recreate it, or to fix the bookkeeping table manually after. |
|
488 | + if (getDolGlobalString('ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USER_ON_SALARY_BANK_PAYMENT')) { |
|
489 | + $tmpsalary = new Salary($db); |
|
490 | + $tmpsalary->fetch($paymentsalstatic->id); |
|
491 | + $tmpsalary->fetch_user($tmpsalary->fk_user); |
|
492 | + |
|
493 | + $userstatic->id = $tmpsalary->user->id; |
|
494 | + $userstatic->name = $tmpsalary->user->name; |
|
495 | + $userstatic->email = $tmpsalary->user->email; |
|
496 | + $userstatic->firstname = $tmpsalary->user->firstname; |
|
497 | + $userstatic->lastname = $tmpsalary->user->lastname; |
|
498 | + $userstatic->status = $tmpsalary->user->status; |
|
499 | + $userstatic->accountancy_code = $tmpsalary->user->accountancy_code; |
|
500 | + |
|
501 | + if ($userstatic->id > 0) { |
|
502 | + $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0); |
|
503 | + } else { |
|
504 | + $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen |
|
505 | + } |
|
506 | + |
|
507 | + if (empty($obj->typeop_user)) { // Add test to avoid to add amount twice if a link already exists also on user. |
|
508 | + $compta_user = $userstatic->accountancy_code; |
|
509 | + if ($compta_user) { |
|
510 | + $tabtp[$obj->rowid][$compta_user] += $amounttouse; |
|
511 | + $tabuser[$obj->rowid] = array( |
|
512 | + 'id' => $userstatic->id, |
|
513 | + 'name' => dolGetFirstLastname($userstatic->firstname, $userstatic->lastname), |
|
514 | + 'lastname' => $userstatic->lastname, |
|
515 | + 'firstname' => $userstatic->firstname, |
|
516 | + 'email' => $userstatic->email, |
|
517 | + 'accountancy_code' => $compta_user, |
|
518 | + 'status' => $userstatic->status |
|
519 | + ); |
|
520 | + } |
|
521 | + } |
|
522 | + } |
|
523 | + } elseif ($links[$key]['type'] == 'payment_expensereport') { |
|
524 | + $paymentexpensereportstatic->id = $links[$key]['url_id']; |
|
525 | + $tabpay[$obj->rowid]["lib"] .= $paymentexpensereportstatic->getNomUrl(2); |
|
526 | + $tabpay[$obj->rowid]["paymentexpensereport"] = $paymentexpensereportstatic->id; |
|
527 | + } elseif ($links[$key]['type'] == 'payment_various') { |
|
528 | + $paymentvariousstatic->id = $links[$key]['url_id']; |
|
529 | + $paymentvariousstatic->ref = $links[$key]['url_id']; |
|
530 | + $paymentvariousstatic->label = $links[$key]['label']; |
|
531 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvariousstatic->getNomUrl(2); |
|
532 | + $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; |
|
533 | + $paymentvariousstatic->fetch($paymentvariousstatic->id); |
|
534 | + $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word |
|
535 | + $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word |
|
536 | + $tabpay[$obj->rowid]["account_various"] = $account_various; |
|
537 | + $tabtp[$obj->rowid][$account_subledger] = isset($tabtp[$obj->rowid][$account_subledger]) ? $tabtp[$obj->rowid][$account_subledger] + $amounttouse : $amounttouse; |
|
538 | + } elseif ($links[$key]['type'] == 'payment_loan') { |
|
539 | + $paymentloanstatic->id = $links[$key]['url_id']; |
|
540 | + $paymentloanstatic->ref = $links[$key]['url_id']; |
|
541 | + $paymentloanstatic->fk_loan = $links[$key]['url_id']; |
|
542 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2); |
|
543 | + $tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id; |
|
544 | + //$tabtp[$obj->rowid][$account_pay_loan] += $amounttouse; |
|
545 | + $sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest'; |
|
546 | + $sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l'; |
|
547 | + $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid); |
|
548 | + |
|
549 | + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); |
|
550 | + $resultmid = $db->query($sqlmid); |
|
551 | + if ($resultmid) { |
|
552 | + $objmid = $db->fetch_object($resultmid); |
|
553 | + $tabtp[$obj->rowid][$objmid->accountancy_account_capital] = isset($tabtp[$obj->rowid][$objmid->accountancy_account_capital]) ? $tabtp[$obj->rowid][$objmid->accountancy_account_capital] - $objmid->amount_capital : $amounttouse; |
|
554 | + $tabtp[$obj->rowid][$objmid->accountancy_account_insurance] = isset($tabtp[$obj->rowid][$objmid->accountancy_account_insurance]) ? $tabtp[$obj->rowid][$objmid->accountancy_account_insurance] - $objmid->amount_insurance : $amounttouse; |
|
555 | + $tabtp[$obj->rowid][$objmid->accountancy_account_interest] = isset($tabtp[$obj->rowid][$objmid->accountancy_account_interest]) ? $tabtp[$obj->rowid][$objmid->accountancy_account_interest] - $objmid->amount_interes : $amounttouse; |
|
556 | + } |
|
557 | + } elseif ($links[$key]['type'] == 'banktransfert') { |
|
558 | + $accountLinestatic->fetch($links[$key]['url_id']); |
|
559 | + $tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- '.$accountLinestatic ->getNomUrl(1); |
|
560 | + $tabtp[$obj->rowid][$account_transfer] = isset($tabtp[$obj->rowid][$account_transfer]) ? $tabtp[$obj->rowid][$account_transfer] + $amounttouse : $amounttouse; |
|
561 | + $bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']); |
|
562 | + $tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2); |
|
563 | + } |
|
564 | + } |
|
565 | + } |
|
566 | 566 | |
567 | - if (empty($tabbq[$obj->rowid][$compta_bank])) { |
|
568 | - $tabbq[$obj->rowid][$compta_bank] = $amounttouse; |
|
569 | - } else { |
|
570 | - $tabbq[$obj->rowid][$compta_bank] += $amounttouse; |
|
571 | - } |
|
567 | + if (empty($tabbq[$obj->rowid][$compta_bank])) { |
|
568 | + $tabbq[$obj->rowid][$compta_bank] = $amounttouse; |
|
569 | + } else { |
|
570 | + $tabbq[$obj->rowid][$compta_bank] += $amounttouse; |
|
571 | + } |
|
572 | 572 | |
573 | - // If no links were found to know the amount on thirdparty, we try to guess it. |
|
574 | - // This may happens on bank entries without the links lines to 'company'. |
|
575 | - if (empty($tabtp[$obj->rowid]) && !empty($tabmoreinfo[$obj->rowid]['withdraw'])) { // If we don't find 'company' link because it is an old 'withdraw' record |
|
576 | - foreach ($links as $key => $val) { |
|
577 | - if ($links[$key]['type'] == 'payment') { |
|
578 | - // Get thirdparty |
|
579 | - $tmppayment->fetch($links[$key]['url_id']); |
|
580 | - $arrayofamounts = $tmppayment->getAmountsArray(); |
|
581 | - if (is_array($arrayofamounts)) { |
|
582 | - foreach ($arrayofamounts as $invoiceid => $amount) { |
|
583 | - $tmpinvoice->fetch($invoiceid); |
|
584 | - $tmpinvoice->fetch_thirdparty(); |
|
585 | - if ($tmpinvoice->thirdparty->code_compta_client) { |
|
586 | - $tabtp[$obj->rowid][$tmpinvoice->thirdparty->code_compta_client] += $amount; |
|
587 | - } |
|
588 | - } |
|
589 | - } |
|
590 | - } |
|
591 | - } |
|
592 | - } |
|
573 | + // If no links were found to know the amount on thirdparty, we try to guess it. |
|
574 | + // This may happens on bank entries without the links lines to 'company'. |
|
575 | + if (empty($tabtp[$obj->rowid]) && !empty($tabmoreinfo[$obj->rowid]['withdraw'])) { // If we don't find 'company' link because it is an old 'withdraw' record |
|
576 | + foreach ($links as $key => $val) { |
|
577 | + if ($links[$key]['type'] == 'payment') { |
|
578 | + // Get thirdparty |
|
579 | + $tmppayment->fetch($links[$key]['url_id']); |
|
580 | + $arrayofamounts = $tmppayment->getAmountsArray(); |
|
581 | + if (is_array($arrayofamounts)) { |
|
582 | + foreach ($arrayofamounts as $invoiceid => $amount) { |
|
583 | + $tmpinvoice->fetch($invoiceid); |
|
584 | + $tmpinvoice->fetch_thirdparty(); |
|
585 | + if ($tmpinvoice->thirdparty->code_compta_client) { |
|
586 | + $tabtp[$obj->rowid][$tmpinvoice->thirdparty->code_compta_client] += $amount; |
|
587 | + } |
|
588 | + } |
|
589 | + } |
|
590 | + } |
|
591 | + } |
|
592 | + } |
|
593 | 593 | |
594 | - // If no links were found to know the amount on thirdparty/user, we init it to account 'NotDefined'. |
|
595 | - if (empty($tabtp[$obj->rowid])) { |
|
596 | - $tabtp[$obj->rowid]['NotDefined'] = $tabbq[$obj->rowid][$compta_bank]; |
|
597 | - } |
|
594 | + // If no links were found to know the amount on thirdparty/user, we init it to account 'NotDefined'. |
|
595 | + if (empty($tabtp[$obj->rowid])) { |
|
596 | + $tabtp[$obj->rowid]['NotDefined'] = $tabbq[$obj->rowid][$compta_bank]; |
|
597 | + } |
|
598 | 598 | |
599 | - // Check account number is ok |
|
600 | - /*if ($action == 'writebookkeeping') // Make test now in such a case |
|
599 | + // Check account number is ok |
|
600 | + /*if ($action == 'writebookkeeping') // Make test now in such a case |
|
601 | 601 | { |
602 | 602 | reset($tabbq[$obj->rowid]); |
603 | 603 | $first_key_tabbq = key($tabbq[$obj->rowid]); |
@@ -615,12 +615,12 @@ discard block |
||
615 | 615 | } |
616 | 616 | }*/ |
617 | 617 | |
618 | - // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $amounttouse; |
|
618 | + // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $amounttouse; |
|
619 | 619 | |
620 | - $i++; |
|
621 | - } |
|
620 | + $i++; |
|
621 | + } |
|
622 | 622 | } else { |
623 | - dol_print_error($db); |
|
623 | + dol_print_error($db); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | |
@@ -632,454 +632,454 @@ discard block |
||
632 | 632 | |
633 | 633 | // Write bookkeeping |
634 | 634 | if (!$error && $action == 'writebookkeeping') { |
635 | - $now = dol_now(); |
|
636 | - |
|
637 | - $accountingaccountcustomer = new AccountingAccount($db); |
|
638 | - $accountingaccountcustomer->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true); |
|
639 | - |
|
640 | - $accountingaccountsupplier = new AccountingAccount($db); |
|
641 | - $accountingaccountsupplier->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), true); |
|
642 | - |
|
643 | - $accountingaccountpayment = new AccountingAccount($db); |
|
644 | - $accountingaccountpayment->fetch(null, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true); |
|
645 | - |
|
646 | - $accountingaccountexpensereport = new AccountingAccount($db); |
|
647 | - $accountingaccountexpensereport->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_EXPENSEREPORT, true); |
|
648 | - |
|
649 | - $accountingaccountsuspense = new AccountingAccount($db); |
|
650 | - $accountingaccountsuspense->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'), true); |
|
651 | - |
|
652 | - $error = 0; |
|
653 | - foreach ($tabpay as $key => $val) { // $key is rowid into llx_bank |
|
654 | - $date = dol_print_date($val["date"], 'day'); |
|
655 | - |
|
656 | - $ref = getSourceDocRef($val, $tabtype[$key]); |
|
657 | - |
|
658 | - $errorforline = 0; |
|
659 | - |
|
660 | - $totalcredit = 0; |
|
661 | - $totaldebit = 0; |
|
662 | - |
|
663 | - $db->begin(); |
|
664 | - |
|
665 | - // Introduce a protection. Total of tabtp must be total of tabbq |
|
666 | - //var_dump($tabpay); |
|
667 | - //var_dump($tabtp); |
|
668 | - //var_dump($tabbq);exit; |
|
669 | - |
|
670 | - // Bank |
|
671 | - if (!$errorforline && is_array($tabbq[$key])) { |
|
672 | - // Line into bank account |
|
673 | - foreach ($tabbq[$key] as $k => $mt) { |
|
674 | - if ($mt) { |
|
675 | - if (empty($conf->cache['accountingaccountincurrententity'][$k])) { |
|
676 | - $accountingaccount = new AccountingAccount($db); |
|
677 | - $accountingaccount->fetch(0, $k, true); // $k is accounting account of the bank. |
|
678 | - $conf->cache['accountingaccountincurrententity'][$k] = $accountingaccount; |
|
679 | - } else { |
|
680 | - $accountingaccount = $conf->cache['accountingaccountincurrententity'][$k]; |
|
681 | - } |
|
682 | - |
|
683 | - $account_label = $accountingaccount->label; |
|
684 | - |
|
685 | - $reflabel = ''; |
|
686 | - if (!empty($val['lib'])) { |
|
687 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
688 | - } |
|
689 | - $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); |
|
690 | - if (!empty($val['soclib'])) { |
|
691 | - $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); |
|
692 | - } |
|
693 | - |
|
694 | - $bookkeeping = new BookKeeping($db); |
|
695 | - $bookkeeping->doc_date = $val["date"]; |
|
696 | - $bookkeeping->doc_ref = $ref; |
|
697 | - $bookkeeping->doc_type = 'bank'; |
|
698 | - $bookkeeping->fk_doc = $key; |
|
699 | - $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
700 | - |
|
701 | - $bookkeeping->numero_compte = $k; |
|
702 | - $bookkeeping->label_compte = $account_label; |
|
703 | - |
|
704 | - $bookkeeping->label_operation = $reflabel; |
|
705 | - $bookkeeping->montant = $mt; |
|
706 | - $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; |
|
707 | - $bookkeeping->debit = ($mt >= 0 ? $mt : 0); |
|
708 | - $bookkeeping->credit = ($mt < 0 ? -$mt : 0); |
|
709 | - $bookkeeping->code_journal = $journal; |
|
710 | - $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
711 | - $bookkeeping->fk_user_author = $user->id; |
|
712 | - $bookkeeping->date_creation = $now; |
|
713 | - |
|
714 | - // No subledger_account value for the bank line but add a specific label_operation |
|
715 | - $bookkeeping->subledger_account = ''; |
|
716 | - $bookkeeping->label_operation = $reflabel; |
|
717 | - $bookkeeping->entity = $conf->entity; |
|
718 | - |
|
719 | - $totaldebit += $bookkeeping->debit; |
|
720 | - $totalcredit += $bookkeeping->credit; |
|
721 | - |
|
722 | - $result = $bookkeeping->create($user); |
|
723 | - if ($result < 0) { |
|
724 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
725 | - $error++; |
|
726 | - $errorforline++; |
|
727 | - setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
728 | - } else { |
|
729 | - $error++; |
|
730 | - $errorforline++; |
|
731 | - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
732 | - } |
|
733 | - } |
|
734 | - } |
|
735 | - } |
|
736 | - } |
|
737 | - |
|
738 | - // Third party |
|
739 | - if (!$errorforline) { |
|
740 | - if (is_array($tabtp[$key])) { |
|
741 | - // Line into thirdparty account |
|
742 | - foreach ($tabtp[$key] as $k => $mt) { |
|
743 | - if ($mt) { |
|
744 | - $lettering = false; |
|
745 | - |
|
746 | - $reflabel = ''; |
|
747 | - if (!empty($val['lib'])) { |
|
748 | - $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); |
|
749 | - } |
|
750 | - if ($tabtype[$key] == 'banktransfert') { |
|
751 | - $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); |
|
752 | - } else { |
|
753 | - $reflabel .= dol_string_nohtmltag($val['soclib']); |
|
754 | - } |
|
635 | + $now = dol_now(); |
|
636 | + |
|
637 | + $accountingaccountcustomer = new AccountingAccount($db); |
|
638 | + $accountingaccountcustomer->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true); |
|
639 | + |
|
640 | + $accountingaccountsupplier = new AccountingAccount($db); |
|
641 | + $accountingaccountsupplier->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), true); |
|
642 | + |
|
643 | + $accountingaccountpayment = new AccountingAccount($db); |
|
644 | + $accountingaccountpayment->fetch(null, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true); |
|
645 | + |
|
646 | + $accountingaccountexpensereport = new AccountingAccount($db); |
|
647 | + $accountingaccountexpensereport->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_EXPENSEREPORT, true); |
|
648 | + |
|
649 | + $accountingaccountsuspense = new AccountingAccount($db); |
|
650 | + $accountingaccountsuspense->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'), true); |
|
651 | + |
|
652 | + $error = 0; |
|
653 | + foreach ($tabpay as $key => $val) { // $key is rowid into llx_bank |
|
654 | + $date = dol_print_date($val["date"], 'day'); |
|
655 | + |
|
656 | + $ref = getSourceDocRef($val, $tabtype[$key]); |
|
657 | + |
|
658 | + $errorforline = 0; |
|
659 | + |
|
660 | + $totalcredit = 0; |
|
661 | + $totaldebit = 0; |
|
662 | + |
|
663 | + $db->begin(); |
|
664 | + |
|
665 | + // Introduce a protection. Total of tabtp must be total of tabbq |
|
666 | + //var_dump($tabpay); |
|
667 | + //var_dump($tabtp); |
|
668 | + //var_dump($tabbq);exit; |
|
669 | + |
|
670 | + // Bank |
|
671 | + if (!$errorforline && is_array($tabbq[$key])) { |
|
672 | + // Line into bank account |
|
673 | + foreach ($tabbq[$key] as $k => $mt) { |
|
674 | + if ($mt) { |
|
675 | + if (empty($conf->cache['accountingaccountincurrententity'][$k])) { |
|
676 | + $accountingaccount = new AccountingAccount($db); |
|
677 | + $accountingaccount->fetch(0, $k, true); // $k is accounting account of the bank. |
|
678 | + $conf->cache['accountingaccountincurrententity'][$k] = $accountingaccount; |
|
679 | + } else { |
|
680 | + $accountingaccount = $conf->cache['accountingaccountincurrententity'][$k]; |
|
681 | + } |
|
682 | + |
|
683 | + $account_label = $accountingaccount->label; |
|
684 | + |
|
685 | + $reflabel = ''; |
|
686 | + if (!empty($val['lib'])) { |
|
687 | + $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
688 | + } |
|
689 | + $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); |
|
690 | + if (!empty($val['soclib'])) { |
|
691 | + $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); |
|
692 | + } |
|
693 | + |
|
694 | + $bookkeeping = new BookKeeping($db); |
|
695 | + $bookkeeping->doc_date = $val["date"]; |
|
696 | + $bookkeeping->doc_ref = $ref; |
|
697 | + $bookkeeping->doc_type = 'bank'; |
|
698 | + $bookkeeping->fk_doc = $key; |
|
699 | + $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
700 | + |
|
701 | + $bookkeeping->numero_compte = $k; |
|
702 | + $bookkeeping->label_compte = $account_label; |
|
703 | + |
|
704 | + $bookkeeping->label_operation = $reflabel; |
|
705 | + $bookkeeping->montant = $mt; |
|
706 | + $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; |
|
707 | + $bookkeeping->debit = ($mt >= 0 ? $mt : 0); |
|
708 | + $bookkeeping->credit = ($mt < 0 ? -$mt : 0); |
|
709 | + $bookkeeping->code_journal = $journal; |
|
710 | + $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
711 | + $bookkeeping->fk_user_author = $user->id; |
|
712 | + $bookkeeping->date_creation = $now; |
|
713 | + |
|
714 | + // No subledger_account value for the bank line but add a specific label_operation |
|
715 | + $bookkeeping->subledger_account = ''; |
|
716 | + $bookkeeping->label_operation = $reflabel; |
|
717 | + $bookkeeping->entity = $conf->entity; |
|
718 | + |
|
719 | + $totaldebit += $bookkeeping->debit; |
|
720 | + $totalcredit += $bookkeeping->credit; |
|
721 | + |
|
722 | + $result = $bookkeeping->create($user); |
|
723 | + if ($result < 0) { |
|
724 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
725 | + $error++; |
|
726 | + $errorforline++; |
|
727 | + setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
728 | + } else { |
|
729 | + $error++; |
|
730 | + $errorforline++; |
|
731 | + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
732 | + } |
|
733 | + } |
|
734 | + } |
|
735 | + } |
|
736 | + } |
|
755 | 737 | |
756 | - $bookkeeping = new BookKeeping($db); |
|
757 | - $bookkeeping->doc_date = $val["date"]; |
|
758 | - $bookkeeping->doc_ref = $ref; |
|
759 | - $bookkeeping->doc_type = 'bank'; |
|
760 | - $bookkeeping->fk_doc = $key; |
|
761 | - $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
762 | - |
|
763 | - $bookkeeping->label_operation = $reflabel; |
|
764 | - $bookkeeping->montant = $mt; |
|
765 | - $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; |
|
766 | - $bookkeeping->debit = ($mt < 0 ? -$mt : 0); |
|
767 | - $bookkeeping->credit = ($mt >= 0) ? $mt : 0; |
|
768 | - $bookkeeping->code_journal = $journal; |
|
769 | - $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
770 | - $bookkeeping->fk_user_author = $user->id; |
|
771 | - $bookkeeping->date_creation = $now; |
|
772 | - |
|
773 | - if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice |
|
774 | - $lettering = true; |
|
775 | - $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp |
|
776 | - $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction |
|
777 | - $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'); |
|
778 | - $bookkeeping->label_compte = $accountingaccountcustomer->label; |
|
779 | - } elseif ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice |
|
780 | - $lettering = true; |
|
781 | - $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp |
|
782 | - $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction |
|
783 | - $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); |
|
784 | - $bookkeeping->label_compte = $accountingaccountsupplier->label; |
|
785 | - } elseif ($tabtype[$key] == 'payment_expensereport') { |
|
786 | - $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; |
|
787 | - $bookkeeping->subledger_label = $tabuser[$key]['name']; |
|
788 | - $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'); |
|
789 | - $bookkeeping->label_compte = $accountingaccountexpensereport->label; |
|
790 | - } elseif ($tabtype[$key] == 'payment_salary') { |
|
791 | - $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; |
|
792 | - $bookkeeping->subledger_label = $tabuser[$key]['name']; |
|
793 | - $bookkeeping->numero_compte = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); |
|
794 | - $bookkeeping->label_compte = $accountingaccountpayment->label; |
|
795 | - } elseif (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution |
|
796 | - $bookkeeping->subledger_account = ''; |
|
797 | - $bookkeeping->subledger_label = ''; |
|
798 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
799 | - $bookkeeping->numero_compte = $k; |
|
800 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
801 | - } elseif ($tabtype[$key] == 'payment_vat') { |
|
802 | - $bookkeeping->subledger_account = ''; |
|
803 | - $bookkeeping->subledger_label = ''; |
|
804 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
805 | - $bookkeeping->numero_compte = $k; |
|
806 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
807 | - } elseif ($tabtype[$key] == 'payment_donation') { |
|
808 | - $bookkeeping->subledger_account = ''; |
|
809 | - $bookkeeping->subledger_label = ''; |
|
810 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
811 | - $bookkeeping->numero_compte = $k; |
|
812 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
813 | - } elseif ($tabtype[$key] == 'member') { |
|
814 | - $bookkeeping->subledger_account = ''; |
|
815 | - $bookkeeping->subledger_label = ''; |
|
816 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
817 | - $bookkeeping->numero_compte = $k; |
|
818 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
819 | - } elseif ($tabtype[$key] == 'payment_loan') { |
|
820 | - $bookkeeping->subledger_account = ''; |
|
821 | - $bookkeeping->subledger_label = ''; |
|
822 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
823 | - $bookkeeping->numero_compte = $k; |
|
824 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
825 | - } elseif ($tabtype[$key] == 'payment_various') { |
|
826 | - $bookkeeping->subledger_account = $k; |
|
827 | - $bookkeeping->subledger_label = $tabcompany[$key]['name']; |
|
828 | - $accountingaccount->fetch(null, $tabpay[$key]["account_various"], true); // TODO Use a cache |
|
829 | - $bookkeeping->numero_compte = $tabpay[$key]["account_various"]; |
|
830 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
831 | - } elseif ($tabtype[$key] == 'banktransfert') { |
|
832 | - $bookkeeping->subledger_account = ''; |
|
833 | - $bookkeeping->subledger_label = ''; |
|
834 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
835 | - $bookkeeping->numero_compte = $k; |
|
836 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
837 | - } else { |
|
838 | - if ($tabtype[$key] == 'unknown') { // Unknown transaction, we will use a waiting account for thirdparty. |
|
839 | - // Temporary account |
|
840 | - $bookkeeping->subledger_account = ''; |
|
841 | - $bookkeeping->subledger_label = ''; |
|
842 | - $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'); |
|
843 | - $bookkeeping->label_compte = $accountingaccountsuspense->label; |
|
844 | - } |
|
845 | - } |
|
846 | - $bookkeeping->label_operation = $reflabel; |
|
847 | - $bookkeeping->entity = $conf->entity; |
|
848 | - |
|
849 | - $totaldebit += $bookkeeping->debit; |
|
850 | - $totalcredit += $bookkeeping->credit; |
|
851 | - |
|
852 | - $result = $bookkeeping->create($user); |
|
853 | - if ($result < 0) { |
|
854 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
855 | - $error++; |
|
856 | - $errorforline++; |
|
857 | - setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
858 | - } else { |
|
859 | - $error++; |
|
860 | - $errorforline++; |
|
861 | - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
862 | - } |
|
863 | - } else { |
|
864 | - if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { |
|
865 | - $lettering_static = new Lettering($db); |
|
866 | - $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id)); |
|
867 | - } |
|
868 | - } |
|
869 | - } |
|
870 | - } |
|
871 | - } else { // If thirdparty unknown, output the waiting account |
|
872 | - foreach ($tabbq[$key] as $k => $mt) { |
|
873 | - if ($mt) { |
|
874 | - $reflabel = ''; |
|
875 | - if (!empty($val['lib'])) { |
|
876 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
877 | - } |
|
878 | - $reflabel .= dol_string_nohtmltag('WaitingAccount'); |
|
879 | - |
|
880 | - $bookkeeping = new BookKeeping($db); |
|
881 | - $bookkeeping->doc_date = $val["date"]; |
|
882 | - $bookkeeping->doc_ref = $ref; |
|
883 | - $bookkeeping->doc_type = 'bank'; |
|
884 | - $bookkeeping->fk_doc = $key; |
|
885 | - $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
886 | - $bookkeeping->montant = $mt; |
|
887 | - $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; |
|
888 | - $bookkeeping->debit = ($mt < 0 ? -$mt : 0); |
|
889 | - $bookkeeping->credit = ($mt >= 0) ? $mt : 0; |
|
890 | - $bookkeeping->code_journal = $journal; |
|
891 | - $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
892 | - $bookkeeping->fk_user_author = $user->id; |
|
893 | - $bookkeeping->date_creation = $now; |
|
894 | - $bookkeeping->label_compte = ''; |
|
895 | - $bookkeeping->label_operation = $reflabel; |
|
896 | - $bookkeeping->entity = $conf->entity; |
|
897 | - |
|
898 | - $totaldebit += $bookkeeping->debit; |
|
899 | - $totalcredit += $bookkeeping->credit; |
|
900 | - |
|
901 | - $result = $bookkeeping->create($user); |
|
902 | - |
|
903 | - if ($result < 0) { |
|
904 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
905 | - $error++; |
|
906 | - $errorforline++; |
|
907 | - setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
908 | - } else { |
|
909 | - $error++; |
|
910 | - $errorforline++; |
|
911 | - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
912 | - } |
|
913 | - } |
|
914 | - } |
|
915 | - } |
|
916 | - } |
|
917 | - } |
|
738 | + // Third party |
|
739 | + if (!$errorforline) { |
|
740 | + if (is_array($tabtp[$key])) { |
|
741 | + // Line into thirdparty account |
|
742 | + foreach ($tabtp[$key] as $k => $mt) { |
|
743 | + if ($mt) { |
|
744 | + $lettering = false; |
|
745 | + |
|
746 | + $reflabel = ''; |
|
747 | + if (!empty($val['lib'])) { |
|
748 | + $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); |
|
749 | + } |
|
750 | + if ($tabtype[$key] == 'banktransfert') { |
|
751 | + $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); |
|
752 | + } else { |
|
753 | + $reflabel .= dol_string_nohtmltag($val['soclib']); |
|
754 | + } |
|
755 | + |
|
756 | + $bookkeeping = new BookKeeping($db); |
|
757 | + $bookkeeping->doc_date = $val["date"]; |
|
758 | + $bookkeeping->doc_ref = $ref; |
|
759 | + $bookkeeping->doc_type = 'bank'; |
|
760 | + $bookkeeping->fk_doc = $key; |
|
761 | + $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
762 | + |
|
763 | + $bookkeeping->label_operation = $reflabel; |
|
764 | + $bookkeeping->montant = $mt; |
|
765 | + $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; |
|
766 | + $bookkeeping->debit = ($mt < 0 ? -$mt : 0); |
|
767 | + $bookkeeping->credit = ($mt >= 0) ? $mt : 0; |
|
768 | + $bookkeeping->code_journal = $journal; |
|
769 | + $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
770 | + $bookkeeping->fk_user_author = $user->id; |
|
771 | + $bookkeeping->date_creation = $now; |
|
772 | + |
|
773 | + if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice |
|
774 | + $lettering = true; |
|
775 | + $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp |
|
776 | + $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction |
|
777 | + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'); |
|
778 | + $bookkeeping->label_compte = $accountingaccountcustomer->label; |
|
779 | + } elseif ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice |
|
780 | + $lettering = true; |
|
781 | + $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp |
|
782 | + $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction |
|
783 | + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); |
|
784 | + $bookkeeping->label_compte = $accountingaccountsupplier->label; |
|
785 | + } elseif ($tabtype[$key] == 'payment_expensereport') { |
|
786 | + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; |
|
787 | + $bookkeeping->subledger_label = $tabuser[$key]['name']; |
|
788 | + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'); |
|
789 | + $bookkeeping->label_compte = $accountingaccountexpensereport->label; |
|
790 | + } elseif ($tabtype[$key] == 'payment_salary') { |
|
791 | + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; |
|
792 | + $bookkeeping->subledger_label = $tabuser[$key]['name']; |
|
793 | + $bookkeeping->numero_compte = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); |
|
794 | + $bookkeeping->label_compte = $accountingaccountpayment->label; |
|
795 | + } elseif (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution |
|
796 | + $bookkeeping->subledger_account = ''; |
|
797 | + $bookkeeping->subledger_label = ''; |
|
798 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
799 | + $bookkeeping->numero_compte = $k; |
|
800 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
801 | + } elseif ($tabtype[$key] == 'payment_vat') { |
|
802 | + $bookkeeping->subledger_account = ''; |
|
803 | + $bookkeeping->subledger_label = ''; |
|
804 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
805 | + $bookkeeping->numero_compte = $k; |
|
806 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
807 | + } elseif ($tabtype[$key] == 'payment_donation') { |
|
808 | + $bookkeeping->subledger_account = ''; |
|
809 | + $bookkeeping->subledger_label = ''; |
|
810 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
811 | + $bookkeeping->numero_compte = $k; |
|
812 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
813 | + } elseif ($tabtype[$key] == 'member') { |
|
814 | + $bookkeeping->subledger_account = ''; |
|
815 | + $bookkeeping->subledger_label = ''; |
|
816 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
817 | + $bookkeeping->numero_compte = $k; |
|
818 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
819 | + } elseif ($tabtype[$key] == 'payment_loan') { |
|
820 | + $bookkeeping->subledger_account = ''; |
|
821 | + $bookkeeping->subledger_label = ''; |
|
822 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
823 | + $bookkeeping->numero_compte = $k; |
|
824 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
825 | + } elseif ($tabtype[$key] == 'payment_various') { |
|
826 | + $bookkeeping->subledger_account = $k; |
|
827 | + $bookkeeping->subledger_label = $tabcompany[$key]['name']; |
|
828 | + $accountingaccount->fetch(null, $tabpay[$key]["account_various"], true); // TODO Use a cache |
|
829 | + $bookkeeping->numero_compte = $tabpay[$key]["account_various"]; |
|
830 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
831 | + } elseif ($tabtype[$key] == 'banktransfert') { |
|
832 | + $bookkeeping->subledger_account = ''; |
|
833 | + $bookkeeping->subledger_label = ''; |
|
834 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
835 | + $bookkeeping->numero_compte = $k; |
|
836 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
837 | + } else { |
|
838 | + if ($tabtype[$key] == 'unknown') { // Unknown transaction, we will use a waiting account for thirdparty. |
|
839 | + // Temporary account |
|
840 | + $bookkeeping->subledger_account = ''; |
|
841 | + $bookkeeping->subledger_label = ''; |
|
842 | + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'); |
|
843 | + $bookkeeping->label_compte = $accountingaccountsuspense->label; |
|
844 | + } |
|
845 | + } |
|
846 | + $bookkeeping->label_operation = $reflabel; |
|
847 | + $bookkeeping->entity = $conf->entity; |
|
848 | + |
|
849 | + $totaldebit += $bookkeeping->debit; |
|
850 | + $totalcredit += $bookkeeping->credit; |
|
851 | + |
|
852 | + $result = $bookkeeping->create($user); |
|
853 | + if ($result < 0) { |
|
854 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
855 | + $error++; |
|
856 | + $errorforline++; |
|
857 | + setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
858 | + } else { |
|
859 | + $error++; |
|
860 | + $errorforline++; |
|
861 | + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
862 | + } |
|
863 | + } else { |
|
864 | + if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { |
|
865 | + $lettering_static = new Lettering($db); |
|
866 | + $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id)); |
|
867 | + } |
|
868 | + } |
|
869 | + } |
|
870 | + } |
|
871 | + } else { // If thirdparty unknown, output the waiting account |
|
872 | + foreach ($tabbq[$key] as $k => $mt) { |
|
873 | + if ($mt) { |
|
874 | + $reflabel = ''; |
|
875 | + if (!empty($val['lib'])) { |
|
876 | + $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
877 | + } |
|
878 | + $reflabel .= dol_string_nohtmltag('WaitingAccount'); |
|
879 | + |
|
880 | + $bookkeeping = new BookKeeping($db); |
|
881 | + $bookkeeping->doc_date = $val["date"]; |
|
882 | + $bookkeeping->doc_ref = $ref; |
|
883 | + $bookkeeping->doc_type = 'bank'; |
|
884 | + $bookkeeping->fk_doc = $key; |
|
885 | + $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
886 | + $bookkeeping->montant = $mt; |
|
887 | + $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; |
|
888 | + $bookkeeping->debit = ($mt < 0 ? -$mt : 0); |
|
889 | + $bookkeeping->credit = ($mt >= 0) ? $mt : 0; |
|
890 | + $bookkeeping->code_journal = $journal; |
|
891 | + $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
892 | + $bookkeeping->fk_user_author = $user->id; |
|
893 | + $bookkeeping->date_creation = $now; |
|
894 | + $bookkeeping->label_compte = ''; |
|
895 | + $bookkeeping->label_operation = $reflabel; |
|
896 | + $bookkeeping->entity = $conf->entity; |
|
897 | + |
|
898 | + $totaldebit += $bookkeeping->debit; |
|
899 | + $totalcredit += $bookkeeping->credit; |
|
900 | + |
|
901 | + $result = $bookkeeping->create($user); |
|
902 | + |
|
903 | + if ($result < 0) { |
|
904 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
905 | + $error++; |
|
906 | + $errorforline++; |
|
907 | + setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
908 | + } else { |
|
909 | + $error++; |
|
910 | + $errorforline++; |
|
911 | + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
912 | + } |
|
913 | + } |
|
914 | + } |
|
915 | + } |
|
916 | + } |
|
917 | + } |
|
918 | 918 | |
919 | - if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')) { |
|
920 | - $error++; |
|
921 | - $errorforline++; |
|
922 | - setEventMessages('We tried to insert a non balanced transaction in book for '.$ref.'. Canceled. Surely a bug.', null, 'errors'); |
|
923 | - } |
|
919 | + if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')) { |
|
920 | + $error++; |
|
921 | + $errorforline++; |
|
922 | + setEventMessages('We tried to insert a non balanced transaction in book for '.$ref.'. Canceled. Surely a bug.', null, 'errors'); |
|
923 | + } |
|
924 | 924 | |
925 | - if (!$errorforline) { |
|
926 | - $db->commit(); |
|
927 | - } else { |
|
928 | - //print 'KO for line '.$key.' '.$error.'<br>'; |
|
929 | - $db->rollback(); |
|
925 | + if (!$errorforline) { |
|
926 | + $db->commit(); |
|
927 | + } else { |
|
928 | + //print 'KO for line '.$key.' '.$error.'<br>'; |
|
929 | + $db->rollback(); |
|
930 | 930 | |
931 | - $MAXNBERRORS = 5; |
|
932 | - if ($error >= $MAXNBERRORS) { |
|
933 | - setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors'); |
|
934 | - break; // Break in the foreach |
|
935 | - } |
|
936 | - } |
|
937 | - } |
|
938 | - |
|
939 | - if (empty($error) && count($tabpay) > 0) { |
|
940 | - setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); |
|
941 | - } elseif (count($tabpay) == $error) { |
|
942 | - setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); |
|
943 | - } else { |
|
944 | - setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); |
|
945 | - } |
|
946 | - |
|
947 | - $action = ''; |
|
948 | - |
|
949 | - // Must reload data, so we make a redirect |
|
950 | - if (count($tabpay) != $error) { |
|
951 | - $param = 'id_journal='.$id_journal; |
|
952 | - $param .= '&date_startday='.$date_startday; |
|
953 | - $param .= '&date_startmonth='.$date_startmonth; |
|
954 | - $param .= '&date_startyear='.$date_startyear; |
|
955 | - $param .= '&date_endday='.$date_endday; |
|
956 | - $param .= '&date_endmonth='.$date_endmonth; |
|
957 | - $param .= '&date_endyear='.$date_endyear; |
|
958 | - $param .= '&in_bookkeeping='.$in_bookkeeping; |
|
959 | - header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : '')); |
|
960 | - exit; |
|
961 | - } |
|
931 | + $MAXNBERRORS = 5; |
|
932 | + if ($error >= $MAXNBERRORS) { |
|
933 | + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors'); |
|
934 | + break; // Break in the foreach |
|
935 | + } |
|
936 | + } |
|
937 | + } |
|
938 | + |
|
939 | + if (empty($error) && count($tabpay) > 0) { |
|
940 | + setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); |
|
941 | + } elseif (count($tabpay) == $error) { |
|
942 | + setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); |
|
943 | + } else { |
|
944 | + setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); |
|
945 | + } |
|
946 | + |
|
947 | + $action = ''; |
|
948 | + |
|
949 | + // Must reload data, so we make a redirect |
|
950 | + if (count($tabpay) != $error) { |
|
951 | + $param = 'id_journal='.$id_journal; |
|
952 | + $param .= '&date_startday='.$date_startday; |
|
953 | + $param .= '&date_startmonth='.$date_startmonth; |
|
954 | + $param .= '&date_startyear='.$date_startyear; |
|
955 | + $param .= '&date_endday='.$date_endday; |
|
956 | + $param .= '&date_endmonth='.$date_endmonth; |
|
957 | + $param .= '&date_endyear='.$date_endyear; |
|
958 | + $param .= '&in_bookkeeping='.$in_bookkeeping; |
|
959 | + header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : '')); |
|
960 | + exit; |
|
961 | + } |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | |
965 | 965 | |
966 | 966 | // Export |
967 | 967 | if ($action == 'exportcsv') { // ISO and not UTF8 ! |
968 | - $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV'); |
|
969 | - |
|
970 | - $filename = 'journal'; |
|
971 | - $type_export = 'journal'; |
|
972 | - include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; |
|
973 | - |
|
974 | - // CSV header line |
|
975 | - print '"'.$langs->transnoentitiesnoconv("BankId").'"'.$sep; |
|
976 | - print '"'.$langs->transnoentitiesnoconv("Date").'"'.$sep; |
|
977 | - print '"'.$langs->transnoentitiesnoconv("PaymentMode").'"'.$sep; |
|
978 | - print '"'.$langs->transnoentitiesnoconv("AccountAccounting").'"'.$sep; |
|
979 | - print '"'.$langs->transnoentitiesnoconv("LedgerAccount").'"'.$sep; |
|
980 | - print '"'.$langs->transnoentitiesnoconv("SubledgerAccount").'"'.$sep; |
|
981 | - print '"'.$langs->transnoentitiesnoconv("Label").'"'.$sep; |
|
982 | - print '"'.$langs->transnoentitiesnoconv("AccountingDebit").'"'.$sep; |
|
983 | - print '"'.$langs->transnoentitiesnoconv("AccountingCredit").'"'.$sep; |
|
984 | - print '"'.$langs->transnoentitiesnoconv("Journal").'"'.$sep; |
|
985 | - print '"'.$langs->transnoentitiesnoconv("Note").'"'.$sep; |
|
986 | - print "\n"; |
|
987 | - |
|
988 | - foreach ($tabpay as $key => $val) { |
|
989 | - $date = dol_print_date($val["date"], 'day'); |
|
990 | - |
|
991 | - $ref = getSourceDocRef($val, $tabtype[$key]); |
|
992 | - |
|
993 | - // Bank |
|
994 | - foreach ($tabbq[$key] as $k => $mt) { |
|
995 | - if ($mt) { |
|
996 | - $reflabel = ''; |
|
997 | - if (!empty($val['lib'])) { |
|
998 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
999 | - } |
|
1000 | - $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); |
|
1001 | - if (!empty($val['soclib'])) { |
|
1002 | - $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); |
|
1003 | - } |
|
1004 | - |
|
1005 | - print '"'.$key.'"'.$sep; |
|
1006 | - print '"'.$date.'"'.$sep; |
|
1007 | - print '"'.$val["type_payment"].'"'.$sep; |
|
1008 | - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
1009 | - print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
1010 | - print " ".$sep; |
|
1011 | - print '"'.$reflabel.'"'.$sep; |
|
1012 | - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
1013 | - print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
1014 | - print '"'.$journal.'"'.$sep; |
|
1015 | - print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
1016 | - print "\n"; |
|
1017 | - } |
|
1018 | - } |
|
968 | + $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV'); |
|
969 | + |
|
970 | + $filename = 'journal'; |
|
971 | + $type_export = 'journal'; |
|
972 | + include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; |
|
973 | + |
|
974 | + // CSV header line |
|
975 | + print '"'.$langs->transnoentitiesnoconv("BankId").'"'.$sep; |
|
976 | + print '"'.$langs->transnoentitiesnoconv("Date").'"'.$sep; |
|
977 | + print '"'.$langs->transnoentitiesnoconv("PaymentMode").'"'.$sep; |
|
978 | + print '"'.$langs->transnoentitiesnoconv("AccountAccounting").'"'.$sep; |
|
979 | + print '"'.$langs->transnoentitiesnoconv("LedgerAccount").'"'.$sep; |
|
980 | + print '"'.$langs->transnoentitiesnoconv("SubledgerAccount").'"'.$sep; |
|
981 | + print '"'.$langs->transnoentitiesnoconv("Label").'"'.$sep; |
|
982 | + print '"'.$langs->transnoentitiesnoconv("AccountingDebit").'"'.$sep; |
|
983 | + print '"'.$langs->transnoentitiesnoconv("AccountingCredit").'"'.$sep; |
|
984 | + print '"'.$langs->transnoentitiesnoconv("Journal").'"'.$sep; |
|
985 | + print '"'.$langs->transnoentitiesnoconv("Note").'"'.$sep; |
|
986 | + print "\n"; |
|
987 | + |
|
988 | + foreach ($tabpay as $key => $val) { |
|
989 | + $date = dol_print_date($val["date"], 'day'); |
|
990 | + |
|
991 | + $ref = getSourceDocRef($val, $tabtype[$key]); |
|
992 | + |
|
993 | + // Bank |
|
994 | + foreach ($tabbq[$key] as $k => $mt) { |
|
995 | + if ($mt) { |
|
996 | + $reflabel = ''; |
|
997 | + if (!empty($val['lib'])) { |
|
998 | + $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
999 | + } |
|
1000 | + $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); |
|
1001 | + if (!empty($val['soclib'])) { |
|
1002 | + $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); |
|
1003 | + } |
|
1019 | 1004 | |
1020 | - // Third party |
|
1021 | - if (is_array($tabtp[$key])) { |
|
1022 | - foreach ($tabtp[$key] as $k => $mt) { |
|
1023 | - if ($mt) { |
|
1024 | - $reflabel = ''; |
|
1025 | - if (!empty($val['lib'])) { |
|
1026 | - $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); |
|
1027 | - } |
|
1028 | - if ($tabtype[$key] == 'banktransfert') { |
|
1029 | - $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); |
|
1030 | - } else { |
|
1031 | - $reflabel .= dol_string_nohtmltag($val['soclib']); |
|
1032 | - } |
|
1005 | + print '"'.$key.'"'.$sep; |
|
1006 | + print '"'.$date.'"'.$sep; |
|
1007 | + print '"'.$val["type_payment"].'"'.$sep; |
|
1008 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
1009 | + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
1010 | + print " ".$sep; |
|
1011 | + print '"'.$reflabel.'"'.$sep; |
|
1012 | + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
1013 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
1014 | + print '"'.$journal.'"'.$sep; |
|
1015 | + print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
1016 | + print "\n"; |
|
1017 | + } |
|
1018 | + } |
|
1033 | 1019 | |
1034 | - print '"'.$key.'"'.$sep; |
|
1035 | - print '"'.$date.'"'.$sep; |
|
1036 | - print '"'.$val["type_payment"].'"'.$sep; |
|
1037 | - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
1038 | - if ($tabtype[$key] == 'payment_supplier') { |
|
1039 | - print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER').'"'.$sep; |
|
1040 | - } elseif ($tabtype[$key] == 'payment') { |
|
1041 | - print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER').'"'.$sep; |
|
1042 | - } elseif ($tabtype[$key] == 'payment_expensereport') { |
|
1043 | - print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT').'"'.$sep; |
|
1044 | - } elseif ($tabtype[$key] == 'payment_salary') { |
|
1045 | - print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep; |
|
1046 | - } else { |
|
1047 | - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
1048 | - } |
|
1049 | - print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
1050 | - print '"'.$reflabel.'"'.$sep; |
|
1051 | - print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
1052 | - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
1053 | - print '"'.$journal.'"'.$sep; |
|
1054 | - print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
1055 | - print "\n"; |
|
1056 | - } |
|
1057 | - } |
|
1058 | - } else { // If thirdparty unknown, output the waiting account |
|
1059 | - foreach ($tabbq[$key] as $k => $mt) { |
|
1060 | - if ($mt) { |
|
1061 | - $reflabel = ''; |
|
1062 | - if (!empty($val['lib'])) { |
|
1063 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
1064 | - } |
|
1065 | - $reflabel .= dol_string_nohtmltag('WaitingAccount'); |
|
1066 | - |
|
1067 | - print '"'.$key.'"'.$sep; |
|
1068 | - print '"'.$date.'"'.$sep; |
|
1069 | - print '"'.$val["type_payment"].'"'.$sep; |
|
1070 | - print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep; |
|
1071 | - print '"'.length_accounta(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep; |
|
1072 | - print $sep; |
|
1073 | - print '"'.$reflabel.'"'.$sep; |
|
1074 | - print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
1075 | - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
1076 | - print '"'.$journal.'"'.$sep; |
|
1077 | - print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
1078 | - print "\n"; |
|
1079 | - } |
|
1080 | - } |
|
1081 | - } |
|
1082 | - } |
|
1020 | + // Third party |
|
1021 | + if (is_array($tabtp[$key])) { |
|
1022 | + foreach ($tabtp[$key] as $k => $mt) { |
|
1023 | + if ($mt) { |
|
1024 | + $reflabel = ''; |
|
1025 | + if (!empty($val['lib'])) { |
|
1026 | + $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); |
|
1027 | + } |
|
1028 | + if ($tabtype[$key] == 'banktransfert') { |
|
1029 | + $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); |
|
1030 | + } else { |
|
1031 | + $reflabel .= dol_string_nohtmltag($val['soclib']); |
|
1032 | + } |
|
1033 | + |
|
1034 | + print '"'.$key.'"'.$sep; |
|
1035 | + print '"'.$date.'"'.$sep; |
|
1036 | + print '"'.$val["type_payment"].'"'.$sep; |
|
1037 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
1038 | + if ($tabtype[$key] == 'payment_supplier') { |
|
1039 | + print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER').'"'.$sep; |
|
1040 | + } elseif ($tabtype[$key] == 'payment') { |
|
1041 | + print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER').'"'.$sep; |
|
1042 | + } elseif ($tabtype[$key] == 'payment_expensereport') { |
|
1043 | + print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT').'"'.$sep; |
|
1044 | + } elseif ($tabtype[$key] == 'payment_salary') { |
|
1045 | + print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep; |
|
1046 | + } else { |
|
1047 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
1048 | + } |
|
1049 | + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
1050 | + print '"'.$reflabel.'"'.$sep; |
|
1051 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
1052 | + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
1053 | + print '"'.$journal.'"'.$sep; |
|
1054 | + print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
1055 | + print "\n"; |
|
1056 | + } |
|
1057 | + } |
|
1058 | + } else { // If thirdparty unknown, output the waiting account |
|
1059 | + foreach ($tabbq[$key] as $k => $mt) { |
|
1060 | + if ($mt) { |
|
1061 | + $reflabel = ''; |
|
1062 | + if (!empty($val['lib'])) { |
|
1063 | + $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
1064 | + } |
|
1065 | + $reflabel .= dol_string_nohtmltag('WaitingAccount'); |
|
1066 | + |
|
1067 | + print '"'.$key.'"'.$sep; |
|
1068 | + print '"'.$date.'"'.$sep; |
|
1069 | + print '"'.$val["type_payment"].'"'.$sep; |
|
1070 | + print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep; |
|
1071 | + print '"'.length_accounta(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep; |
|
1072 | + print $sep; |
|
1073 | + print '"'.$reflabel.'"'.$sep; |
|
1074 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
1075 | + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
1076 | + print '"'.$journal.'"'.$sep; |
|
1077 | + print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
1078 | + print "\n"; |
|
1079 | + } |
|
1080 | + } |
|
1081 | + } |
|
1082 | + } |
|
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | |
@@ -1090,117 +1090,117 @@ discard block |
||
1090 | 1090 | $form = new Form($db); |
1091 | 1091 | |
1092 | 1092 | if (empty($action) || $action == 'view') { |
1093 | - $invoicestatic = new Facture($db); |
|
1094 | - $invoicesupplierstatic = new FactureFournisseur($db); |
|
1095 | - $expensereportstatic = new ExpenseReport($db); |
|
1096 | - $vatstatic = new Tva($db); |
|
1097 | - $donationstatic = new Don($db); |
|
1098 | - $loanstatic = new Loan($db); |
|
1099 | - $salarystatic = new Salary($db); |
|
1100 | - $variousstatic = new PaymentVarious($db); |
|
1101 | - |
|
1102 | - $title = $langs->trans("GenerationOfAccountingEntries").' - '.$accountingjournalstatic->getNomUrl(0, 2, 1, '', 1); |
|
1103 | - $help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité'; |
|
1104 | - llxHeader('', dol_string_nohtmltag($title), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-generation page-bankjournal'); |
|
1105 | - |
|
1106 | - $nom = $title; |
|
1107 | - $builddate = dol_now(); |
|
1108 | - //$description = $langs->trans("DescFinanceJournal") . '<br>'; |
|
1109 | - $description = $langs->trans("DescJournalOnlyBindedVisible").'<br>'; |
|
1110 | - |
|
1111 | - $listofchoices = array( |
|
1112 | - 'notyet' => $langs->trans("NotYetInGeneralLedger"), |
|
1113 | - 'already' => $langs->trans("AlreadyInGeneralLedger") |
|
1114 | - ); |
|
1115 | - $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); |
|
1116 | - $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
1117 | - |
|
1118 | - $varlink = 'id_journal='.$id_journal; |
|
1119 | - $periodlink = ''; |
|
1120 | - $exportlink = ''; |
|
1121 | - |
|
1122 | - $listofchoices = array( |
|
1123 | - 1 => $langs->trans("TransfertAllBankLines"), |
|
1124 | - 2 => $langs->trans("TransfertOnlyConciliatedBankLine") |
|
1125 | - ); |
|
1126 | - $moreoptions = [ "BankLineConciliated" => $form->selectarray('only_rappro', $listofchoices, $only_rappro)]; |
|
1127 | - |
|
1128 | - journalHead($nom, '', $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink, $moreoptions); |
|
1129 | - |
|
1130 | - $desc = ''; |
|
1131 | - |
|
1132 | - if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') { |
|
1133 | - // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) |
|
1134 | - // Fiscal period test |
|
1135 | - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); |
|
1136 | - $resql = $db->query($sql); |
|
1137 | - if ($resql) { |
|
1138 | - $obj = $db->fetch_object($resql); |
|
1139 | - if ($obj->nb == 0) { |
|
1140 | - print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); |
|
1141 | - $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); |
|
1142 | - $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'</strong>', $desc); |
|
1143 | - print $desc; |
|
1144 | - print '</div>'; |
|
1145 | - } |
|
1146 | - } else { |
|
1147 | - dol_print_error($db); |
|
1148 | - } |
|
1149 | - } |
|
1150 | - |
|
1151 | - // Bank test |
|
1152 | - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."bank_account WHERE entity = ".((int) $conf->entity)." AND fk_accountancy_journal IS NULL AND clos=0"; |
|
1153 | - $resql = $db->query($sql); |
|
1154 | - if ($resql) { |
|
1155 | - $obj = $db->fetch_object($resql); |
|
1156 | - if ($obj->nb > 0) { |
|
1157 | - print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); |
|
1158 | - $desc = ' : '.$langs->trans("AccountancyAreaDescBank", 6, '{link}'); |
|
1159 | - $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("BankAccounts").'</strong>', $desc); |
|
1160 | - print $desc; |
|
1161 | - print '</div>'; |
|
1162 | - } |
|
1163 | - } else { |
|
1164 | - dol_print_error($db); |
|
1165 | - } |
|
1093 | + $invoicestatic = new Facture($db); |
|
1094 | + $invoicesupplierstatic = new FactureFournisseur($db); |
|
1095 | + $expensereportstatic = new ExpenseReport($db); |
|
1096 | + $vatstatic = new Tva($db); |
|
1097 | + $donationstatic = new Don($db); |
|
1098 | + $loanstatic = new Loan($db); |
|
1099 | + $salarystatic = new Salary($db); |
|
1100 | + $variousstatic = new PaymentVarious($db); |
|
1101 | + |
|
1102 | + $title = $langs->trans("GenerationOfAccountingEntries").' - '.$accountingjournalstatic->getNomUrl(0, 2, 1, '', 1); |
|
1103 | + $help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité'; |
|
1104 | + llxHeader('', dol_string_nohtmltag($title), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-generation page-bankjournal'); |
|
1105 | + |
|
1106 | + $nom = $title; |
|
1107 | + $builddate = dol_now(); |
|
1108 | + //$description = $langs->trans("DescFinanceJournal") . '<br>'; |
|
1109 | + $description = $langs->trans("DescJournalOnlyBindedVisible").'<br>'; |
|
1110 | + |
|
1111 | + $listofchoices = array( |
|
1112 | + 'notyet' => $langs->trans("NotYetInGeneralLedger"), |
|
1113 | + 'already' => $langs->trans("AlreadyInGeneralLedger") |
|
1114 | + ); |
|
1115 | + $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); |
|
1116 | + $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
1117 | + |
|
1118 | + $varlink = 'id_journal='.$id_journal; |
|
1119 | + $periodlink = ''; |
|
1120 | + $exportlink = ''; |
|
1121 | + |
|
1122 | + $listofchoices = array( |
|
1123 | + 1 => $langs->trans("TransfertAllBankLines"), |
|
1124 | + 2 => $langs->trans("TransfertOnlyConciliatedBankLine") |
|
1125 | + ); |
|
1126 | + $moreoptions = [ "BankLineConciliated" => $form->selectarray('only_rappro', $listofchoices, $only_rappro)]; |
|
1127 | + |
|
1128 | + journalHead($nom, '', $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink, $moreoptions); |
|
1129 | + |
|
1130 | + $desc = ''; |
|
1131 | + |
|
1132 | + if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') { |
|
1133 | + // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) |
|
1134 | + // Fiscal period test |
|
1135 | + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); |
|
1136 | + $resql = $db->query($sql); |
|
1137 | + if ($resql) { |
|
1138 | + $obj = $db->fetch_object($resql); |
|
1139 | + if ($obj->nb == 0) { |
|
1140 | + print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); |
|
1141 | + $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); |
|
1142 | + $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'</strong>', $desc); |
|
1143 | + print $desc; |
|
1144 | + print '</div>'; |
|
1145 | + } |
|
1146 | + } else { |
|
1147 | + dol_print_error($db); |
|
1148 | + } |
|
1149 | + } |
|
1150 | + |
|
1151 | + // Bank test |
|
1152 | + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."bank_account WHERE entity = ".((int) $conf->entity)." AND fk_accountancy_journal IS NULL AND clos=0"; |
|
1153 | + $resql = $db->query($sql); |
|
1154 | + if ($resql) { |
|
1155 | + $obj = $db->fetch_object($resql); |
|
1156 | + if ($obj->nb > 0) { |
|
1157 | + print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); |
|
1158 | + $desc = ' : '.$langs->trans("AccountancyAreaDescBank", 6, '{link}'); |
|
1159 | + $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("BankAccounts").'</strong>', $desc); |
|
1160 | + print $desc; |
|
1161 | + print '</div>'; |
|
1162 | + } |
|
1163 | + } else { |
|
1164 | + dol_print_error($db); |
|
1165 | + } |
|
1166 | 1166 | |
1167 | 1167 | |
1168 | - // Button to write into Ledger |
|
1169 | - if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1' |
|
1170 | - || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1' |
|
1171 | - || (isModEnabled("salaries") && (getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == "" || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1')) |
|
1172 | - || (isModEnabled("expensereport") && (getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == '-1'))) { |
|
1168 | + // Button to write into Ledger |
|
1169 | + if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1' |
|
1170 | + || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1' |
|
1171 | + || (isModEnabled("salaries") && (getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == "" || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1')) |
|
1172 | + || (isModEnabled("expensereport") && (getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == '-1'))) { |
|
1173 | 1173 | |
1174 | 1174 | |
1175 | - print($desc ? '' : '<br>').'<div class="warning">'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); |
|
1176 | - $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); |
|
1177 | - $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>', $desc); |
|
1178 | - print $desc; |
|
1179 | - print '</div>'; |
|
1180 | - } |
|
1175 | + print($desc ? '' : '<br>').'<div class="warning">'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); |
|
1176 | + $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); |
|
1177 | + $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>', $desc); |
|
1178 | + print $desc; |
|
1179 | + print '</div>'; |
|
1180 | + } |
|
1181 | 1181 | |
1182 | 1182 | |
1183 | - print '<br><div class="tabsAction tabsActionNoBottom centerimp">'; |
|
1183 | + print '<br><div class="tabsAction tabsActionNoBottom centerimp">'; |
|
1184 | 1184 | |
1185 | - if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping == 'notyet') { |
|
1186 | - print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; |
|
1187 | - } |
|
1185 | + if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping == 'notyet') { |
|
1186 | + print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; |
|
1187 | + } |
|
1188 | 1188 | |
1189 | - if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1' |
|
1190 | - || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1') { |
|
1191 | - print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; |
|
1192 | - } else { |
|
1193 | - if ($in_bookkeeping == 'notyet') { |
|
1194 | - print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; |
|
1195 | - } else { |
|
1196 | - print '<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; |
|
1197 | - } |
|
1198 | - } |
|
1189 | + if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1' |
|
1190 | + || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1') { |
|
1191 | + print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; |
|
1192 | + } else { |
|
1193 | + if ($in_bookkeeping == 'notyet') { |
|
1194 | + print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; |
|
1195 | + } else { |
|
1196 | + print '<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; |
|
1197 | + } |
|
1198 | + } |
|
1199 | 1199 | |
1200 | - print '</div>'; |
|
1200 | + print '</div>'; |
|
1201 | 1201 | |
1202 | - // TODO Avoid using js. We can use a direct link with $param |
|
1203 | - print ' |
|
1202 | + // TODO Avoid using js. We can use a direct link with $param |
|
1203 | + print ' |
|
1204 | 1204 | <script type="text/javascript"> |
1205 | 1205 | function launch_export() { |
1206 | 1206 | console.log("Set value into form and submit"); |
@@ -1216,259 +1216,259 @@ discard block |
||
1216 | 1216 | } |
1217 | 1217 | </script>'; |
1218 | 1218 | |
1219 | - /* |
|
1219 | + /* |
|
1220 | 1220 | * Show result array |
1221 | 1221 | */ |
1222 | - print '<br>'; |
|
1223 | - |
|
1224 | - $i = 0; |
|
1225 | - print '<div class="div-table-responsive">'; |
|
1226 | - print '<table class="noborder centpercent">'; |
|
1227 | - print '<tr class="liste_titre">'; |
|
1228 | - print "<td>".$langs->trans("Date")."</td>"; |
|
1229 | - print "<td>".$langs->trans("Piece").' ('.$langs->trans("ObjectsRef").")</td>"; |
|
1230 | - print "<td>".$langs->trans("AccountAccounting")."</td>"; |
|
1231 | - print "<td>".$langs->trans("SubledgerAccount")."</td>"; |
|
1232 | - print "<td>".$langs->trans("LabelOperation")."</td>"; |
|
1233 | - print '<td class="center">'.$langs->trans("PaymentMode")."</td>"; |
|
1234 | - print '<td class="right">'.$langs->trans("AccountingDebit")."</td>"; |
|
1235 | - print '<td class="right">'.$langs->trans("AccountingCredit")."</td>"; |
|
1236 | - print "</tr>\n"; |
|
1237 | - |
|
1238 | - $r = ''; |
|
1239 | - |
|
1240 | - foreach ($tabpay as $key => $val) { // $key is rowid in llx_bank |
|
1241 | - $date = dol_print_date($val["date"], 'day'); |
|
1242 | - |
|
1243 | - $ref = getSourceDocRef($val, $tabtype[$key]); |
|
1244 | - |
|
1245 | - // Bank |
|
1246 | - foreach ($tabbq[$key] as $k => $mt) { |
|
1247 | - if ($mt) { |
|
1248 | - $reflabel = ''; |
|
1249 | - if (!empty($val['lib'])) { |
|
1250 | - $reflabel .= $val['lib']." - "; |
|
1251 | - } |
|
1252 | - $reflabel .= $langs->trans("Bank").' '.$val['bank_account_ref']; |
|
1253 | - if (!empty($val['soclib'])) { |
|
1254 | - $reflabel .= " - ".$val['soclib']; |
|
1255 | - } |
|
1222 | + print '<br>'; |
|
1256 | 1223 | |
1257 | - //var_dump($tabpay[$key]); |
|
1258 | - print '<!-- Bank bank.rowid='.$key.' type='.$tabpay[$key]['type'].' ref='.$tabpay[$key]['ref'].'-->'; |
|
1259 | - print '<tr class="oddeven">'; |
|
1224 | + $i = 0; |
|
1225 | + print '<div class="div-table-responsive">'; |
|
1226 | + print '<table class="noborder centpercent">'; |
|
1227 | + print '<tr class="liste_titre">'; |
|
1228 | + print "<td>".$langs->trans("Date")."</td>"; |
|
1229 | + print "<td>".$langs->trans("Piece").' ('.$langs->trans("ObjectsRef").")</td>"; |
|
1230 | + print "<td>".$langs->trans("AccountAccounting")."</td>"; |
|
1231 | + print "<td>".$langs->trans("SubledgerAccount")."</td>"; |
|
1232 | + print "<td>".$langs->trans("LabelOperation")."</td>"; |
|
1233 | + print '<td class="center">'.$langs->trans("PaymentMode")."</td>"; |
|
1234 | + print '<td class="right">'.$langs->trans("AccountingDebit")."</td>"; |
|
1235 | + print '<td class="right">'.$langs->trans("AccountingCredit")."</td>"; |
|
1236 | + print "</tr>\n"; |
|
1237 | + |
|
1238 | + $r = ''; |
|
1239 | + |
|
1240 | + foreach ($tabpay as $key => $val) { // $key is rowid in llx_bank |
|
1241 | + $date = dol_print_date($val["date"], 'day'); |
|
1242 | + |
|
1243 | + $ref = getSourceDocRef($val, $tabtype[$key]); |
|
1244 | + |
|
1245 | + // Bank |
|
1246 | + foreach ($tabbq[$key] as $k => $mt) { |
|
1247 | + if ($mt) { |
|
1248 | + $reflabel = ''; |
|
1249 | + if (!empty($val['lib'])) { |
|
1250 | + $reflabel .= $val['lib']." - "; |
|
1251 | + } |
|
1252 | + $reflabel .= $langs->trans("Bank").' '.$val['bank_account_ref']; |
|
1253 | + if (!empty($val['soclib'])) { |
|
1254 | + $reflabel .= " - ".$val['soclib']; |
|
1255 | + } |
|
1260 | 1256 | |
1261 | - // Date |
|
1262 | - print "<td>".$date."</td>"; |
|
1257 | + //var_dump($tabpay[$key]); |
|
1258 | + print '<!-- Bank bank.rowid='.$key.' type='.$tabpay[$key]['type'].' ref='.$tabpay[$key]['ref'].'-->'; |
|
1259 | + print '<tr class="oddeven">'; |
|
1263 | 1260 | |
1264 | - // Ref |
|
1265 | - print "<td>".dol_escape_htmltag($ref)."</td>"; |
|
1261 | + // Date |
|
1262 | + print "<td>".$date."</td>"; |
|
1266 | 1263 | |
1267 | - // Ledger account |
|
1268 | - $accounttoshow = length_accountg($k); |
|
1269 | - if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { |
|
1270 | - $accounttoshow = '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>'; |
|
1271 | - } |
|
1272 | - print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">'; |
|
1273 | - print $accounttoshow; |
|
1274 | - print "</td>"; |
|
1264 | + // Ref |
|
1265 | + print "<td>".dol_escape_htmltag($ref)."</td>"; |
|
1275 | 1266 | |
1276 | - // Subledger account |
|
1277 | - print '<td class="maxwidth300">'; |
|
1278 | - /*$accounttoshow = length_accountg($k); |
|
1267 | + // Ledger account |
|
1268 | + $accounttoshow = length_accountg($k); |
|
1269 | + if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { |
|
1270 | + $accounttoshow = '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>'; |
|
1271 | + } |
|
1272 | + print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">'; |
|
1273 | + print $accounttoshow; |
|
1274 | + print "</td>"; |
|
1275 | + |
|
1276 | + // Subledger account |
|
1277 | + print '<td class="maxwidth300">'; |
|
1278 | + /*$accounttoshow = length_accountg($k); |
|
1279 | 1279 | if (empty($accounttoshow) || $accounttoshow == 'NotDefined') |
1280 | 1280 | { |
1281 | 1281 | print '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>'; |
1282 | 1282 | } |
1283 | 1283 | else print $accounttoshow;*/ |
1284 | - print "</td>"; |
|
1285 | - |
|
1286 | - // Label operation |
|
1287 | - print '<td>'; |
|
1288 | - print $reflabel; // This is already html escaped content |
|
1289 | - print "</td>"; |
|
1290 | - |
|
1291 | - print '<td class="center">'.$val["type_payment"]."</td>"; |
|
1292 | - print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
1293 | - print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
1294 | - print "</tr>"; |
|
1295 | - |
|
1296 | - $i++; |
|
1297 | - } |
|
1298 | - } |
|
1299 | - |
|
1300 | - // Third party |
|
1301 | - if (is_array($tabtp[$key])) { |
|
1302 | - foreach ($tabtp[$key] as $k => $mt) { |
|
1303 | - if ($mt) { |
|
1304 | - $reflabel = ''; |
|
1305 | - if (!empty($val['lib'])) { |
|
1306 | - $reflabel .= $val['lib'].(isset($val['soclib']) ? " - " : ""); |
|
1307 | - } |
|
1308 | - if ($tabtype[$key] == 'banktransfert') { |
|
1309 | - $reflabel .= $langs->trans('TransitionalAccount').' '.$account_transfer; |
|
1310 | - } else { |
|
1311 | - $reflabel .= isset($val['soclib']) ? $val['soclib'] : ""; |
|
1312 | - } |
|
1313 | - |
|
1314 | - print '<!-- Thirdparty bank.rowid='.$key.' -->'; |
|
1315 | - print '<tr class="oddeven">'; |
|
1316 | - |
|
1317 | - // Date |
|
1318 | - print "<td>".$date."</td>"; |
|
1319 | - |
|
1320 | - // Ref |
|
1321 | - print "<td>".dol_escape_htmltag($ref)."</td>"; |
|
1322 | - |
|
1323 | - // Ledger account |
|
1324 | - $account_ledger = $k; |
|
1325 | - // Try to force general ledger account depending on type |
|
1326 | - if ($tabtype[$key] == 'payment') { |
|
1327 | - $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'); |
|
1328 | - } |
|
1329 | - if ($tabtype[$key] == 'payment_supplier') { |
|
1330 | - $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); |
|
1331 | - } |
|
1332 | - if ($tabtype[$key] == 'payment_expensereport') { |
|
1333 | - $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'); |
|
1334 | - } |
|
1335 | - if ($tabtype[$key] == 'payment_salary') { |
|
1336 | - $account_ledger = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); |
|
1337 | - } |
|
1338 | - if ($tabtype[$key] == 'payment_vat') { |
|
1339 | - $account_ledger = getDolGlobalString('ACCOUNTING_VAT_PAY_ACCOUNT'); |
|
1340 | - } |
|
1341 | - if ($tabtype[$key] == 'member') { |
|
1342 | - $account_ledger = getDolGlobalString('ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT'); |
|
1343 | - } |
|
1344 | - if ($tabtype[$key] == 'payment_various') { |
|
1345 | - $account_ledger = $tabpay[$key]["account_various"]; |
|
1346 | - } |
|
1347 | - $accounttoshow = length_accountg($account_ledger); |
|
1348 | - if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { |
|
1349 | - if ($tabtype[$key] == 'unknown') { |
|
1350 | - // We will accept writing, but into a waiting account |
|
1351 | - if (!getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') || getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') == '-1') { |
|
1352 | - $accounttoshow = '<span class="error small">'.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').'</span>'; |
|
1353 | - } else { |
|
1354 | - $accounttoshow = '<span class="warning small">'.$langs->trans('UnknownAccountForThirdparty', length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'))).'</span>'; // We will use a waiting account |
|
1355 | - } |
|
1356 | - } else { |
|
1357 | - // We will refuse writing |
|
1358 | - $errorstring = 'UnknownAccountForThirdpartyBlocking'; |
|
1359 | - if ($tabtype[$key] == 'payment') { |
|
1360 | - $errorstring = 'MainAccountForCustomersNotDefined'; |
|
1361 | - } |
|
1362 | - if ($tabtype[$key] == 'payment_supplier') { |
|
1363 | - $errorstring = 'MainAccountForSuppliersNotDefined'; |
|
1364 | - } |
|
1365 | - if ($tabtype[$key] == 'payment_expensereport') { |
|
1366 | - $errorstring = 'MainAccountForUsersNotDefined'; |
|
1367 | - } |
|
1368 | - if ($tabtype[$key] == 'payment_salary') { |
|
1369 | - $errorstring = 'MainAccountForUsersNotDefined'; |
|
1370 | - } |
|
1371 | - if ($tabtype[$key] == 'payment_vat') { |
|
1372 | - $errorstring = 'MainAccountForVatPaymentNotDefined'; |
|
1373 | - } |
|
1374 | - if ($tabtype[$key] == 'member') { |
|
1375 | - $errorstring = 'MainAccountForSubscriptionPaymentNotDefined'; |
|
1376 | - } |
|
1377 | - $accounttoshow = '<span class="error small">'.$langs->trans($errorstring).'</span>'; |
|
1378 | - } |
|
1379 | - } |
|
1380 | - print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">'; |
|
1381 | - print $accounttoshow; // This is a HTML string |
|
1382 | - print "</td>"; |
|
1383 | - |
|
1384 | - // Subledger account |
|
1385 | - $accounttoshowsubledger = ''; |
|
1386 | - if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) { // Type of payments that uses a subledger |
|
1387 | - $accounttoshowsubledger = length_accounta($k); |
|
1388 | - if ($accounttoshow != $accounttoshowsubledger) { |
|
1389 | - if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') { |
|
1390 | - //var_dump($tabpay[$key]); |
|
1391 | - //var_dump($tabtype[$key]); |
|
1392 | - //var_dump($tabbq[$key]); |
|
1393 | - //print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>'; |
|
1394 | - if (!empty($tabcompany[$key]['code_compta'])) { |
|
1395 | - if (in_array($tabtype[$key], array('payment_various', 'payment_salary'))) { |
|
1396 | - // For such case, if subledger is not defined, we won't use subledger accounts. |
|
1397 | - $accounttoshowsubledger = '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").'</span>'; |
|
1398 | - } else { |
|
1399 | - $accounttoshowsubledger = '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>'; |
|
1400 | - } |
|
1401 | - } else { |
|
1402 | - $accounttoshowsubledger = '<span class="error small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").'</span>'; |
|
1403 | - } |
|
1404 | - } |
|
1405 | - } else { |
|
1406 | - $accounttoshowsubledger = ''; |
|
1407 | - } |
|
1408 | - } |
|
1409 | - print '<td class="maxwidth300">'; |
|
1410 | - print $accounttoshowsubledger; // This is a html string |
|
1411 | - print "</td>"; |
|
1412 | - |
|
1413 | - print "<td>".$reflabel."</td>"; |
|
1414 | - |
|
1415 | - print '<td class="center">'.$val["type_payment"]."</td>"; |
|
1284 | + print "</td>"; |
|
1416 | 1285 | |
1417 | - print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
1286 | + // Label operation |
|
1287 | + print '<td>'; |
|
1288 | + print $reflabel; // This is already html escaped content |
|
1289 | + print "</td>"; |
|
1418 | 1290 | |
1419 | - print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
1291 | + print '<td class="center">'.$val["type_payment"]."</td>"; |
|
1292 | + print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
1293 | + print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
1294 | + print "</tr>"; |
|
1420 | 1295 | |
1421 | - print "</tr>"; |
|
1296 | + $i++; |
|
1297 | + } |
|
1298 | + } |
|
1422 | 1299 | |
1423 | - $i++; |
|
1424 | - } |
|
1425 | - } |
|
1426 | - } else { // Waiting account |
|
1427 | - foreach ($tabbq[$key] as $k => $mt) { |
|
1428 | - if ($mt) { |
|
1429 | - $reflabel = ''; |
|
1430 | - if (!empty($val['lib'])) { |
|
1431 | - $reflabel .= $val['lib']." - "; |
|
1432 | - } |
|
1433 | - $reflabel .= 'WaitingAccount'; |
|
1434 | - |
|
1435 | - print '<!-- Wait bank.rowid='.$key.' -->'; |
|
1436 | - print '<tr class="oddeven">'; |
|
1437 | - print "<td>".$date."</td>"; |
|
1438 | - print "<td>".$ref."</td>"; |
|
1439 | - // Ledger account |
|
1440 | - print "<td>"; |
|
1441 | - /*if (empty($accounttoshow) || $accounttoshow == 'NotDefined') |
|
1300 | + // Third party |
|
1301 | + if (is_array($tabtp[$key])) { |
|
1302 | + foreach ($tabtp[$key] as $k => $mt) { |
|
1303 | + if ($mt) { |
|
1304 | + $reflabel = ''; |
|
1305 | + if (!empty($val['lib'])) { |
|
1306 | + $reflabel .= $val['lib'].(isset($val['soclib']) ? " - " : ""); |
|
1307 | + } |
|
1308 | + if ($tabtype[$key] == 'banktransfert') { |
|
1309 | + $reflabel .= $langs->trans('TransitionalAccount').' '.$account_transfer; |
|
1310 | + } else { |
|
1311 | + $reflabel .= isset($val['soclib']) ? $val['soclib'] : ""; |
|
1312 | + } |
|
1313 | + |
|
1314 | + print '<!-- Thirdparty bank.rowid='.$key.' -->'; |
|
1315 | + print '<tr class="oddeven">'; |
|
1316 | + |
|
1317 | + // Date |
|
1318 | + print "<td>".$date."</td>"; |
|
1319 | + |
|
1320 | + // Ref |
|
1321 | + print "<td>".dol_escape_htmltag($ref)."</td>"; |
|
1322 | + |
|
1323 | + // Ledger account |
|
1324 | + $account_ledger = $k; |
|
1325 | + // Try to force general ledger account depending on type |
|
1326 | + if ($tabtype[$key] == 'payment') { |
|
1327 | + $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'); |
|
1328 | + } |
|
1329 | + if ($tabtype[$key] == 'payment_supplier') { |
|
1330 | + $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); |
|
1331 | + } |
|
1332 | + if ($tabtype[$key] == 'payment_expensereport') { |
|
1333 | + $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'); |
|
1334 | + } |
|
1335 | + if ($tabtype[$key] == 'payment_salary') { |
|
1336 | + $account_ledger = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); |
|
1337 | + } |
|
1338 | + if ($tabtype[$key] == 'payment_vat') { |
|
1339 | + $account_ledger = getDolGlobalString('ACCOUNTING_VAT_PAY_ACCOUNT'); |
|
1340 | + } |
|
1341 | + if ($tabtype[$key] == 'member') { |
|
1342 | + $account_ledger = getDolGlobalString('ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT'); |
|
1343 | + } |
|
1344 | + if ($tabtype[$key] == 'payment_various') { |
|
1345 | + $account_ledger = $tabpay[$key]["account_various"]; |
|
1346 | + } |
|
1347 | + $accounttoshow = length_accountg($account_ledger); |
|
1348 | + if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { |
|
1349 | + if ($tabtype[$key] == 'unknown') { |
|
1350 | + // We will accept writing, but into a waiting account |
|
1351 | + if (!getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') || getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') == '-1') { |
|
1352 | + $accounttoshow = '<span class="error small">'.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').'</span>'; |
|
1353 | + } else { |
|
1354 | + $accounttoshow = '<span class="warning small">'.$langs->trans('UnknownAccountForThirdparty', length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'))).'</span>'; // We will use a waiting account |
|
1355 | + } |
|
1356 | + } else { |
|
1357 | + // We will refuse writing |
|
1358 | + $errorstring = 'UnknownAccountForThirdpartyBlocking'; |
|
1359 | + if ($tabtype[$key] == 'payment') { |
|
1360 | + $errorstring = 'MainAccountForCustomersNotDefined'; |
|
1361 | + } |
|
1362 | + if ($tabtype[$key] == 'payment_supplier') { |
|
1363 | + $errorstring = 'MainAccountForSuppliersNotDefined'; |
|
1364 | + } |
|
1365 | + if ($tabtype[$key] == 'payment_expensereport') { |
|
1366 | + $errorstring = 'MainAccountForUsersNotDefined'; |
|
1367 | + } |
|
1368 | + if ($tabtype[$key] == 'payment_salary') { |
|
1369 | + $errorstring = 'MainAccountForUsersNotDefined'; |
|
1370 | + } |
|
1371 | + if ($tabtype[$key] == 'payment_vat') { |
|
1372 | + $errorstring = 'MainAccountForVatPaymentNotDefined'; |
|
1373 | + } |
|
1374 | + if ($tabtype[$key] == 'member') { |
|
1375 | + $errorstring = 'MainAccountForSubscriptionPaymentNotDefined'; |
|
1376 | + } |
|
1377 | + $accounttoshow = '<span class="error small">'.$langs->trans($errorstring).'</span>'; |
|
1378 | + } |
|
1379 | + } |
|
1380 | + print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">'; |
|
1381 | + print $accounttoshow; // This is a HTML string |
|
1382 | + print "</td>"; |
|
1383 | + |
|
1384 | + // Subledger account |
|
1385 | + $accounttoshowsubledger = ''; |
|
1386 | + if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) { // Type of payments that uses a subledger |
|
1387 | + $accounttoshowsubledger = length_accounta($k); |
|
1388 | + if ($accounttoshow != $accounttoshowsubledger) { |
|
1389 | + if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') { |
|
1390 | + //var_dump($tabpay[$key]); |
|
1391 | + //var_dump($tabtype[$key]); |
|
1392 | + //var_dump($tabbq[$key]); |
|
1393 | + //print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>'; |
|
1394 | + if (!empty($tabcompany[$key]['code_compta'])) { |
|
1395 | + if (in_array($tabtype[$key], array('payment_various', 'payment_salary'))) { |
|
1396 | + // For such case, if subledger is not defined, we won't use subledger accounts. |
|
1397 | + $accounttoshowsubledger = '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").'</span>'; |
|
1398 | + } else { |
|
1399 | + $accounttoshowsubledger = '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>'; |
|
1400 | + } |
|
1401 | + } else { |
|
1402 | + $accounttoshowsubledger = '<span class="error small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").'</span>'; |
|
1403 | + } |
|
1404 | + } |
|
1405 | + } else { |
|
1406 | + $accounttoshowsubledger = ''; |
|
1407 | + } |
|
1408 | + } |
|
1409 | + print '<td class="maxwidth300">'; |
|
1410 | + print $accounttoshowsubledger; // This is a html string |
|
1411 | + print "</td>"; |
|
1412 | + |
|
1413 | + print "<td>".$reflabel."</td>"; |
|
1414 | + |
|
1415 | + print '<td class="center">'.$val["type_payment"]."</td>"; |
|
1416 | + |
|
1417 | + print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
1418 | + |
|
1419 | + print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
1420 | + |
|
1421 | + print "</tr>"; |
|
1422 | + |
|
1423 | + $i++; |
|
1424 | + } |
|
1425 | + } |
|
1426 | + } else { // Waiting account |
|
1427 | + foreach ($tabbq[$key] as $k => $mt) { |
|
1428 | + if ($mt) { |
|
1429 | + $reflabel = ''; |
|
1430 | + if (!empty($val['lib'])) { |
|
1431 | + $reflabel .= $val['lib']." - "; |
|
1432 | + } |
|
1433 | + $reflabel .= 'WaitingAccount'; |
|
1434 | + |
|
1435 | + print '<!-- Wait bank.rowid='.$key.' -->'; |
|
1436 | + print '<tr class="oddeven">'; |
|
1437 | + print "<td>".$date."</td>"; |
|
1438 | + print "<td>".$ref."</td>"; |
|
1439 | + // Ledger account |
|
1440 | + print "<td>"; |
|
1441 | + /*if (empty($accounttoshow) || $accounttoshow == 'NotDefined') |
|
1442 | 1442 | { |
1443 | 1443 | print '<span class="error">'.$langs->trans("WaitAccountNotDefined").'</span>'; |
1444 | 1444 | } |
1445 | 1445 | else */ |
1446 | - print length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')); |
|
1447 | - print "</td>"; |
|
1448 | - // Subledger account |
|
1449 | - print "<td>"; |
|
1450 | - print "</td>"; |
|
1451 | - print "<td>".dol_escape_htmltag($reflabel)."</td>"; |
|
1452 | - print '<td class="center">'.$val["type_payment"]."</td>"; |
|
1453 | - print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
1454 | - print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
1455 | - print "</tr>"; |
|
1456 | - |
|
1457 | - $i++; |
|
1458 | - } |
|
1459 | - } |
|
1460 | - } |
|
1461 | - } |
|
1446 | + print length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')); |
|
1447 | + print "</td>"; |
|
1448 | + // Subledger account |
|
1449 | + print "<td>"; |
|
1450 | + print "</td>"; |
|
1451 | + print "<td>".dol_escape_htmltag($reflabel)."</td>"; |
|
1452 | + print '<td class="center">'.$val["type_payment"]."</td>"; |
|
1453 | + print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
1454 | + print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
1455 | + print "</tr>"; |
|
1456 | + |
|
1457 | + $i++; |
|
1458 | + } |
|
1459 | + } |
|
1460 | + } |
|
1461 | + } |
|
1462 | 1462 | |
1463 | - if (!$i) { |
|
1464 | - $colspan = 8; |
|
1465 | - print '<tr class="oddeven"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>'; |
|
1466 | - } |
|
1463 | + if (!$i) { |
|
1464 | + $colspan = 8; |
|
1465 | + print '<tr class="oddeven"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>'; |
|
1466 | + } |
|
1467 | 1467 | |
1468 | - print "</table>"; |
|
1469 | - print '</div>'; |
|
1468 | + print "</table>"; |
|
1469 | + print '</div>'; |
|
1470 | 1470 | |
1471 | - llxFooter(); |
|
1471 | + llxFooter(); |
|
1472 | 1472 | } |
1473 | 1473 | |
1474 | 1474 | $db->close(); |
@@ -1484,110 +1484,110 @@ discard block |
||
1484 | 1484 | */ |
1485 | 1485 | function getSourceDocRef($val, $typerecord) |
1486 | 1486 | { |
1487 | - global $db, $langs; |
|
1488 | - |
|
1489 | - // Defined the docref into $ref (We start with $val['ref'] by default and we complete according to other data) |
|
1490 | - // WE MUST HAVE SAME REF FOR ALL LINES WE WILL RECORD INTO THE BOOKKEEPING |
|
1491 | - $ref = $val['ref']; |
|
1492 | - if ($ref == '(SupplierInvoicePayment)' || $ref == '(SupplierInvoicePaymentBack)') { |
|
1493 | - $ref = $langs->transnoentitiesnoconv('Supplier'); |
|
1494 | - } |
|
1495 | - if ($ref == '(CustomerInvoicePayment)' || $ref == '(CustomerInvoicePaymentBack)') { |
|
1496 | - $ref = $langs->transnoentitiesnoconv('Customer'); |
|
1497 | - } |
|
1498 | - if ($ref == '(SocialContributionPayment)') { |
|
1499 | - $ref = $langs->transnoentitiesnoconv('SocialContribution'); |
|
1500 | - } |
|
1501 | - if ($ref == '(DonationPayment)') { |
|
1502 | - $ref = $langs->transnoentitiesnoconv('Donation'); |
|
1503 | - } |
|
1504 | - if ($ref == '(SubscriptionPayment)') { |
|
1505 | - $ref = $langs->transnoentitiesnoconv('Subscription'); |
|
1506 | - } |
|
1507 | - if ($ref == '(ExpenseReportPayment)') { |
|
1508 | - $ref = $langs->transnoentitiesnoconv('Employee'); |
|
1509 | - } |
|
1510 | - if ($ref == '(LoanPayment)') { |
|
1511 | - $ref = $langs->transnoentitiesnoconv('Loan'); |
|
1512 | - } |
|
1513 | - if ($ref == '(payment_salary)') { |
|
1514 | - $ref = $langs->transnoentitiesnoconv('Employee'); |
|
1515 | - } |
|
1516 | - |
|
1517 | - $sqlmid = ''; |
|
1518 | - if ($typerecord == 'payment') { |
|
1519 | - if (getDolGlobalInt('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) { |
|
1520 | - $sqlmid = "SELECT payfac.fk_facture as id, ".$db->ifsql('f1.rowid IS NULL', 'f.ref', 'f1.ref')." as ref"; |
|
1521 | - $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac"; |
|
1522 | - $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture"; |
|
1523 | - $sqlmid .= " LEFT JOIN ".$db->prefix()."societe_remise_except as sre ON sre.fk_facture_source = payfac.fk_facture"; |
|
1524 | - $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f1 ON f1.rowid = sre.fk_facture"; |
|
1525 | - $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']); |
|
1526 | - } else { |
|
1527 | - $sqlmid = "SELECT payfac.fk_facture as id, f.ref as ref"; |
|
1528 | - $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac"; |
|
1529 | - $sqlmid .= " INNER JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture"; |
|
1530 | - $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']); |
|
1531 | - } |
|
1532 | - $ref = $langs->transnoentitiesnoconv("Invoice"); |
|
1533 | - } elseif ($typerecord == 'payment_supplier') { |
|
1534 | - $sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref'; |
|
1535 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
1536 | - $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".((int) $val["paymentsupplierid"]); |
|
1537 | - $ref = $langs->transnoentitiesnoconv("SupplierInvoice"); |
|
1538 | - } elseif ($typerecord == 'payment_expensereport') { |
|
1539 | - $sqlmid = 'SELECT e.rowid as id, e.ref'; |
|
1540 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as pe, ".MAIN_DB_PREFIX."expensereport as e"; |
|
1541 | - $sqlmid .= " WHERE pe.rowid=".((int) $val["paymentexpensereport"])." AND pe.fk_expensereport = e.rowid"; |
|
1542 | - $ref = $langs->transnoentitiesnoconv("ExpenseReport"); |
|
1543 | - } elseif ($typerecord == 'payment_salary') { |
|
1544 | - $sqlmid = 'SELECT s.rowid as ref'; |
|
1545 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; |
|
1546 | - $sqlmid .= " WHERE s.rowid=".((int) $val["paymentsalid"]); |
|
1547 | - $ref = $langs->transnoentitiesnoconv("SalaryPayment"); |
|
1548 | - } elseif ($typerecord == 'sc') { |
|
1549 | - $sqlmid = 'SELECT sc.rowid as ref'; |
|
1550 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementcharge as sc"; |
|
1551 | - $sqlmid .= " WHERE sc.rowid=".((int) $val["paymentscid"]); |
|
1552 | - $ref = $langs->transnoentitiesnoconv("SocialContribution"); |
|
1553 | - } elseif ($typerecord == 'payment_vat') { |
|
1554 | - $sqlmid = 'SELECT v.rowid as ref'; |
|
1555 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v"; |
|
1556 | - $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvatid"]); |
|
1557 | - $ref = $langs->transnoentitiesnoconv("PaymentVat"); |
|
1558 | - } elseif ($typerecord == 'payment_donation') { |
|
1559 | - $sqlmid = 'SELECT payd.fk_donation as ref'; |
|
1560 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_donation as payd"; |
|
1561 | - $sqlmid .= " WHERE payd.fk_donation=".((int) $val["paymentdonationid"]); |
|
1562 | - $ref = $langs->transnoentitiesnoconv("Donation"); |
|
1563 | - } elseif ($typerecord == 'payment_loan') { |
|
1564 | - $sqlmid = 'SELECT l.rowid as ref'; |
|
1565 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_loan as l"; |
|
1566 | - $sqlmid .= " WHERE l.rowid=".((int) $val["paymentloanid"]); |
|
1567 | - $ref = $langs->transnoentitiesnoconv("LoanPayment"); |
|
1568 | - } elseif ($typerecord == 'payment_various') { |
|
1569 | - $sqlmid = 'SELECT v.rowid as ref'; |
|
1570 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; |
|
1571 | - $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvariousid"]); |
|
1572 | - $ref = $langs->transnoentitiesnoconv("VariousPayment"); |
|
1573 | - } |
|
1574 | - // Add warning |
|
1575 | - if (empty($sqlmid)) { |
|
1576 | - dol_syslog("Found a typerecord=".$typerecord." not supported", LOG_WARNING); |
|
1577 | - } |
|
1578 | - |
|
1579 | - if ($sqlmid) { |
|
1580 | - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG); |
|
1581 | - $resultmid = $db->query($sqlmid); |
|
1582 | - if ($resultmid) { |
|
1583 | - while ($objmid = $db->fetch_object($resultmid)) { |
|
1584 | - $ref .= ' '.$objmid->ref; |
|
1585 | - } |
|
1586 | - } else { |
|
1587 | - dol_print_error($db); |
|
1588 | - } |
|
1589 | - } |
|
1487 | + global $db, $langs; |
|
1488 | + |
|
1489 | + // Defined the docref into $ref (We start with $val['ref'] by default and we complete according to other data) |
|
1490 | + // WE MUST HAVE SAME REF FOR ALL LINES WE WILL RECORD INTO THE BOOKKEEPING |
|
1491 | + $ref = $val['ref']; |
|
1492 | + if ($ref == '(SupplierInvoicePayment)' || $ref == '(SupplierInvoicePaymentBack)') { |
|
1493 | + $ref = $langs->transnoentitiesnoconv('Supplier'); |
|
1494 | + } |
|
1495 | + if ($ref == '(CustomerInvoicePayment)' || $ref == '(CustomerInvoicePaymentBack)') { |
|
1496 | + $ref = $langs->transnoentitiesnoconv('Customer'); |
|
1497 | + } |
|
1498 | + if ($ref == '(SocialContributionPayment)') { |
|
1499 | + $ref = $langs->transnoentitiesnoconv('SocialContribution'); |
|
1500 | + } |
|
1501 | + if ($ref == '(DonationPayment)') { |
|
1502 | + $ref = $langs->transnoentitiesnoconv('Donation'); |
|
1503 | + } |
|
1504 | + if ($ref == '(SubscriptionPayment)') { |
|
1505 | + $ref = $langs->transnoentitiesnoconv('Subscription'); |
|
1506 | + } |
|
1507 | + if ($ref == '(ExpenseReportPayment)') { |
|
1508 | + $ref = $langs->transnoentitiesnoconv('Employee'); |
|
1509 | + } |
|
1510 | + if ($ref == '(LoanPayment)') { |
|
1511 | + $ref = $langs->transnoentitiesnoconv('Loan'); |
|
1512 | + } |
|
1513 | + if ($ref == '(payment_salary)') { |
|
1514 | + $ref = $langs->transnoentitiesnoconv('Employee'); |
|
1515 | + } |
|
1516 | + |
|
1517 | + $sqlmid = ''; |
|
1518 | + if ($typerecord == 'payment') { |
|
1519 | + if (getDolGlobalInt('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) { |
|
1520 | + $sqlmid = "SELECT payfac.fk_facture as id, ".$db->ifsql('f1.rowid IS NULL', 'f.ref', 'f1.ref')." as ref"; |
|
1521 | + $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac"; |
|
1522 | + $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture"; |
|
1523 | + $sqlmid .= " LEFT JOIN ".$db->prefix()."societe_remise_except as sre ON sre.fk_facture_source = payfac.fk_facture"; |
|
1524 | + $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f1 ON f1.rowid = sre.fk_facture"; |
|
1525 | + $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']); |
|
1526 | + } else { |
|
1527 | + $sqlmid = "SELECT payfac.fk_facture as id, f.ref as ref"; |
|
1528 | + $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac"; |
|
1529 | + $sqlmid .= " INNER JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture"; |
|
1530 | + $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']); |
|
1531 | + } |
|
1532 | + $ref = $langs->transnoentitiesnoconv("Invoice"); |
|
1533 | + } elseif ($typerecord == 'payment_supplier') { |
|
1534 | + $sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref'; |
|
1535 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
1536 | + $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".((int) $val["paymentsupplierid"]); |
|
1537 | + $ref = $langs->transnoentitiesnoconv("SupplierInvoice"); |
|
1538 | + } elseif ($typerecord == 'payment_expensereport') { |
|
1539 | + $sqlmid = 'SELECT e.rowid as id, e.ref'; |
|
1540 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as pe, ".MAIN_DB_PREFIX."expensereport as e"; |
|
1541 | + $sqlmid .= " WHERE pe.rowid=".((int) $val["paymentexpensereport"])." AND pe.fk_expensereport = e.rowid"; |
|
1542 | + $ref = $langs->transnoentitiesnoconv("ExpenseReport"); |
|
1543 | + } elseif ($typerecord == 'payment_salary') { |
|
1544 | + $sqlmid = 'SELECT s.rowid as ref'; |
|
1545 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; |
|
1546 | + $sqlmid .= " WHERE s.rowid=".((int) $val["paymentsalid"]); |
|
1547 | + $ref = $langs->transnoentitiesnoconv("SalaryPayment"); |
|
1548 | + } elseif ($typerecord == 'sc') { |
|
1549 | + $sqlmid = 'SELECT sc.rowid as ref'; |
|
1550 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementcharge as sc"; |
|
1551 | + $sqlmid .= " WHERE sc.rowid=".((int) $val["paymentscid"]); |
|
1552 | + $ref = $langs->transnoentitiesnoconv("SocialContribution"); |
|
1553 | + } elseif ($typerecord == 'payment_vat') { |
|
1554 | + $sqlmid = 'SELECT v.rowid as ref'; |
|
1555 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v"; |
|
1556 | + $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvatid"]); |
|
1557 | + $ref = $langs->transnoentitiesnoconv("PaymentVat"); |
|
1558 | + } elseif ($typerecord == 'payment_donation') { |
|
1559 | + $sqlmid = 'SELECT payd.fk_donation as ref'; |
|
1560 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_donation as payd"; |
|
1561 | + $sqlmid .= " WHERE payd.fk_donation=".((int) $val["paymentdonationid"]); |
|
1562 | + $ref = $langs->transnoentitiesnoconv("Donation"); |
|
1563 | + } elseif ($typerecord == 'payment_loan') { |
|
1564 | + $sqlmid = 'SELECT l.rowid as ref'; |
|
1565 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_loan as l"; |
|
1566 | + $sqlmid .= " WHERE l.rowid=".((int) $val["paymentloanid"]); |
|
1567 | + $ref = $langs->transnoentitiesnoconv("LoanPayment"); |
|
1568 | + } elseif ($typerecord == 'payment_various') { |
|
1569 | + $sqlmid = 'SELECT v.rowid as ref'; |
|
1570 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; |
|
1571 | + $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvariousid"]); |
|
1572 | + $ref = $langs->transnoentitiesnoconv("VariousPayment"); |
|
1573 | + } |
|
1574 | + // Add warning |
|
1575 | + if (empty($sqlmid)) { |
|
1576 | + dol_syslog("Found a typerecord=".$typerecord." not supported", LOG_WARNING); |
|
1577 | + } |
|
1578 | + |
|
1579 | + if ($sqlmid) { |
|
1580 | + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG); |
|
1581 | + $resultmid = $db->query($sqlmid); |
|
1582 | + if ($resultmid) { |
|
1583 | + while ($objmid = $db->fetch_object($resultmid)) { |
|
1584 | + $ref .= ' '.$objmid->ref; |
|
1585 | + } |
|
1586 | + } else { |
|
1587 | + dol_print_error($db); |
|
1588 | + } |
|
1589 | + } |
|
1590 | 1590 | |
1591 | - $ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300 |
|
1592 | - return $ref; |
|
1591 | + $ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300 |
|
1592 | + return $ref; |
|
1593 | 1593 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
86 | 86 | $object = new BookKeeping($db); |
87 | -$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array |
|
87 | +$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array |
|
88 | 88 | |
89 | 89 | $formaccounting = new FormAccounting($db); |
90 | 90 | $formother = new FormOther($db); |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | if (getDolGlobalString('ACCOUNTANCY_SHOW_OPENING_BALANCE')) { |
469 | 469 | $sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance"; |
470 | 470 | $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t"; |
471 | - $sql .= " WHERE t.entity = " . $conf->entity; // Never do sharing into accounting features |
|
471 | + $sql .= " WHERE t.entity = " . $conf->entity; // Never do sharing into accounting features |
|
472 | 472 | $sql .= " AND t.doc_date < '" . $db->idate($search_date_start) . "'"; |
473 | 473 | $sql .= " GROUP BY t.numero_compte"; |
474 | 474 |
@@ -617,7 +617,7 @@ |
||
617 | 617 | |
618 | 618 | print '<br>'; |
619 | 619 | |
620 | - $result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt |
|
620 | + $result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt |
|
621 | 621 | |
622 | 622 | if ($result < 0) { |
623 | 623 | setEventMessages($object->error, $object->errors, 'errors'); |