From 4ba095cb5c3a0929ea3e8523e8815c3e72620cfc Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 22 Feb 2015 15:04:18 +0100 Subject: [PATCH] FIXED: Bankjournal is generated from id_account now --- htdocs/accountancy/journal/bankjournal.php | 178 ++++++++++++++++----- 1 file changed, 139 insertions(+), 39 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index b9d3b9209f9..8125f6ef14d 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -103,9 +103,7 @@ $sql .= " FROM " . MAIN_DB_PREFIX . "bank as b"; $sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid"; -// To isolate the cash of the other accounts -$sql .= " WHERE ba.courant <> 2"; -$sql .= " AND ba.rowid=".$id_accountancy_journal; +$sql .= " WHERE ba.rowid=".$id_accountancy_journal; if (! empty($conf->multicompany->enabled)) { $sql .= " AND ba.entity = " . $conf->entity; } @@ -218,6 +216,7 @@ if ($result) { $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; $sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid; + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); $resultmid = $db->query($sqlmid); if ($resultmid) @@ -237,6 +236,7 @@ if ($result) { { $paymentsalstatic->id = $links[$key]['url_id']; $paymentsalstatic->ref = $links[$key]['url_id']; + $paymentsalstatic->label = $links[$key]['label']; $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2); $tabtp[$obj->rowid][$accountancy_account_salary] += $obj->amount; } @@ -421,6 +421,7 @@ if ($action == 'export_csv') foreach ( $tabpay as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); + $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; @@ -438,21 +439,44 @@ if ($action == 'export_csv') } // Third party - foreach ( $tabtp[$key] as $k => $mt ) { - if ($mt) { - print $date . $sep; - print $bank_journal . $sep; - if ($val["lib"] == '(SupplierInvoicePayment)') { - print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep; - } else { - print length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) . $sep; + if (is_array ( $tabtp[$key])) + { + foreach ( $tabtp[$key] as $k => $mt ) + { + if ($mt) + { + print $date . $sep; + print $bank_journal . $sep; + if ($val["lib"] == '(SupplierInvoicePayment)') { + print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) . $sep; + } else { + print length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) . $sep; + } + print length_accounta(html_entity_decode($k)) . $sep; + print ($mt < 0 ? 'D' : 'C') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print $val["type_payment"] . $sep; + print $val["ref"] . $sep; + print "\n"; + } + } + } + else + { + foreach ( $tabbq[$key] as $k => $mt ) + { + if (1) + { + print $date . $sep; + print $bank_journal . $sep; + print $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE . $sep; + print $sep; + print ($mt < 0 ? 'D' : 'C') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print $val["type_payment"] . $sep; + print $val["ref"] . $sep; + print "\n"; } - print length_accounta(html_entity_decode($k)) . $sep; - print ($mt < 0 ? 'D' : 'C') . $sep; - print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print $val["type_payment"] . $sep; - print $val["ref"] . $sep; - print "\n"; } } } @@ -476,15 +500,35 @@ if ($action == 'export_csv') } // Third party - foreach ( $tabtp[$key] as $k => $mt ) { - if ($mt) { - print '"' . $date . '"' . $sep; - print '"' . $val["type_payment"] . '"' . $sep; - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . $companystatic->name . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"'; - print "\n"; + if (is_array ( $tabtp[$key])) + { + foreach ( $tabtp[$key] as $k => $mt ) + { + if ($mt) { + print '"' . $date . '"' . $sep; + print '"' . $val["type_payment"] . '"' . $sep; + print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; + print '"' . $companystatic->name . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"'; + print "\n"; + } + } + } + else + { + foreach ( $tabbq[$key] as $k => $mt ) + { + if (1) + { + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE . '"' . $sep; + print '"' . $langs->trans("Bank") . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"'; + print "\n"; + } } } } @@ -498,14 +542,54 @@ else llxHeader('', $langs->trans("BankJournal")); $namereport = $langs->trans("BankJournal"); - $namelink = ''; - $periodlink = ''; - $exportlink = ''; - $builddate = time(); - $description = $langs->trans("DescBankJournal") . '
'; + $description = $langs->trans("DescBankJournal"); $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); - report_header($namereport, $namelink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); + // Report + $h=0; + $head[$h][0] = $_SERVER["PHP_SELF"].'?id_account='.$id_accountancy_journal; + $head[$h][1] = $langs->trans("Report"); + $head[$h][2] = 'report'; + + dol_fiche_head($head, $hselected); + + print '
'; + print ''; + + // Title + print ''; + print ''; + print ''; + print ''; + print ''; + + // Period report + print ''; + print ''; + if (! $periodlink) print ''; + print ''; + + // Description + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + + print '
'.$langs->trans("ReportName").''.$namereport.'
'.$langs->trans("ReportPeriod").''; + else print ''; + if ($period) print $period; + if ($periodlink) print ''.$periodlink; + print '
'.$langs->trans("ReportDescription").''.$description.'
'; + + print '
'; + + print ''; + // End report + print ''; print ''; @@ -565,20 +649,36 @@ else } // Third party - foreach ( $tabtp[$key] as $k => $mt ) { - if ($k != 'type') { + if (is_array ( $tabtp[$key])) + { + foreach ( $tabtp[$key] as $k => $mt ) { + if ($k != 'type') { + print ""; + print "" . $date . ""; + print "" . $val["soclib"] . ""; + print "" . length_accounta($k) . ""; + print "" . $langs->trans('ThirdParty') . " (" . $val['soclib'] . ")"; + print "" . $val["type_payment"] . ""; + print "" . ($mt < 0 ? price(- $mt) : '') . ""; + print "" . ($mt >= 0 ? price($mt) : '') . ""; + print ""; + } + } + } + else + { + foreach ( $tabbq[$key] as $k => $mt ) + { print ""; print "" . $date . ""; - print "" . $val["soclib"] . ""; - print "" . length_accounta($k) . ""; - print "" . $langs->trans('ThirdParty') . " (" . $val['soclib'] . ")"; - print "" . $val["type_payment"] . ""; + print "" . $reflabel . ""; + print "" . $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE . ""; + print "" . $langs->trans('ThirdParty') . ""; print "" . ($mt < 0 ? price(- $mt) : '') . ""; print "" . ($mt >= 0 ? price($mt) : '') . ""; print ""; } } - $var = ! $var; }