Merge pull request #7840 from frederic34/bankjournal

align export bankjournal on others
This commit is contained in:
Laurent Destailleur 2017-11-22 11:57:27 +01:00 committed by GitHub
commit 1509a4f125
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2017 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -674,7 +675,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
// Bank // Bank
foreach ( $tabbq[$key] as $k => $mt ) { foreach ( $tabbq[$key] as $k => $mt ) {
print '"' . $journal . '"' . $sep; print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["type_payment"] . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
@ -686,7 +687,8 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($companystatic->name) . '"' . $sep; print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
} }
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . $journal . '"' . $sep;
print "\n"; print "\n";
} }
@ -694,7 +696,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
if (is_array($tabtp[$key])) { if (is_array($tabtp[$key])) {
foreach ( $tabtp[$key] as $k => $mt ) { foreach ( $tabtp[$key] as $k => $mt ) {
if ($mt) { if ($mt) {
print '"' . $journal . '"' . $sep; print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["type_payment"] . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
@ -712,13 +714,14 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($companystatic->name) . '"' . $sep; print '"' . $langs->trans('ThirdParty') . " - " . utf8_decode($companystatic->name) . '"' . $sep;
} }
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . $journal . '"' . $sep;
print "\n"; print "\n";
} }
} }
} else { } else {
foreach ( $tabbq[$key] as $k => $mt ) { foreach ( $tabbq[$key] as $k => $mt ) {
print '"' . $journal . '"' . $sep; print '"' . $key . '"' . $sep;
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["type_payment"] . '"' . $sep; print '"' . $val["type_payment"] . '"' . $sep;
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep; print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
@ -730,7 +733,8 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($companystatic->name) . '"' . $sep; print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
} }
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"'; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . $journal . '"' . $sep;
print "\n"; print "\n";
} }
} }
@ -769,11 +773,11 @@ if (empty($action) || $action == 'view') {
// Test that setup is complete // Test that setup is complete
$sql='SELECT COUNT(rowid) as nb FROM '.MAIN_DB_PREFIX.'bank_account WHERE fk_accountancy_journal IS NULL'; $sql = 'SELECT COUNT(rowid) as nb FROM '.MAIN_DB_PREFIX.'bank_account WHERE fk_accountancy_journal IS NULL';
$resql=$db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$obj=$db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj->nb > 0) if ($obj->nb > 0)
{ {
print '<br>'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); print '<br>'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount");
@ -1004,141 +1008,86 @@ function getSourceDocRef($val, $typerecord)
// Defined the docref into $ref (We start with $val['ref'] by default and we complete according to other data) // Defined the docref into $ref (We start with $val['ref'] by default and we complete according to other data)
// WE MUST HAVE SAME REF FOR ALL LINES WE WILL RECORD INTO THE BOOKKEEPING // WE MUST HAVE SAME REF FOR ALL LINES WE WILL RECORD INTO THE BOOKKEEPING
$reflabel = $val['ref']; $ref = $val['ref'];
if ($reflabel == '(SupplierInvoicePayment)' || $reflabel == '(SupplierInvoicePaymentBack)') { if ($ref == '(SupplierInvoicePayment)' || $ref == '(SupplierInvoicePaymentBack)') {
$reflabel = $langs->trans('Supplier'); $ref = $langs->trans('Supplier');
} }
if ($reflabel == '(CustomerInvoicePayment)' || $reflabel == '(CustomerInvoicePaymentBack)') { if ($ref == '(CustomerInvoicePayment)' || $ref == '(CustomerInvoicePaymentBack)') {
$reflabel = $langs->trans('Customer'); $ref = $langs->trans('Customer');
} }
if ($reflabel == '(SocialContributionPayment)') { if ($ref == '(SocialContributionPayment)') {
$reflabel = $langs->trans('SocialContribution'); $ref = $langs->trans('SocialContribution');
} }
if ($reflabel == '(DonationPayment)') { if ($ref == '(DonationPayment)') {
$reflabel = $langs->trans('Donation'); $ref = $langs->trans('Donation');
} }
if ($reflabel == '(SubscriptionPayment)') { if ($refl == '(SubscriptionPayment)') {
$reflabel = $langs->trans('Subscription'); $ref = $langs->trans('Subscription');
} }
if ($reflabel == '(ExpenseReportPayment)') { if ($ref == '(ExpenseReportPayment)') {
$reflabel = $langs->trans('Employee'); $ref = $langs->trans('Employee');
} }
if ($reflabel == '(payment_salary)') { if ($ref == '(payment_salary)') {
$reflabel = $langs->trans('Employee'); $ref = $langs->trans('Employee');
} }
$ref=$reflabel;
if ($typerecord == 'payment') if ($typerecord == 'payment')
{ {
$sqlmid = 'SELECT payfac.fk_facture as id, f.facnumber as ref'; $sqlmid = 'SELECT payfac.fk_facture as id, f.facnumber as ref';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac, ".MAIN_DB_PREFIX."facture as f"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac, ".MAIN_DB_PREFIX."facture as f";
$sqlmid .= " WHERE payfac.fk_facture = f.rowid AND payfac.fk_paiement=" . $val["paymentid"]; $sqlmid .= " WHERE payfac.fk_facture = f.rowid AND payfac.fk_paiement=" . $val["paymentid"];
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); $ref = $langs->trans("Invoice");
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$ref=$langs->trans("Invoice");
while ($objmid = $db->fetch_object($resultmid))
{
$ref.=' '.$objmid->ref;
}
}
else dol_print_error($db);
} }
elseif ($typerecord == 'payment_supplier') elseif ($typerecord == 'payment_supplier')
{ {
$sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref'; $sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f";
$sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=" . $val["paymentsupplierid"]; $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=" . $val["paymentsupplierid"];
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); $ref = $langs->trans("SupplierInvoice");
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$ref=$langs->trans("SupplierInvoice");
while($objmid = $db->fetch_object($resultmid))
{
$ref.=' '.$objmid->ref;
}
}
else dol_print_error($db);
} }
elseif ($typerecord == 'payment_expensereport') elseif ($typerecord == 'payment_expensereport')
{ {
$sqlmid = 'SELECT e.rowid as id, e.ref'; $sqlmid = 'SELECT e.rowid as id, e.ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_expensereport as pe, " . MAIN_DB_PREFIX . "expensereport as e"; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_expensereport as pe, " . MAIN_DB_PREFIX . "expensereport as e";
$sqlmid .= " WHERE pe.rowid=" . $val["paymentexpensereport"]." AND pe.fk_expensereport = e.rowid"; $sqlmid .= " WHERE pe.rowid=" . $val["paymentexpensereport"]." AND pe.fk_expensereport = e.rowid";
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); $ref = $langs->trans("ExpenseReport");
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$ref=$langs->trans("ExpenseReport");
while($objmid = $db->fetch_object($resultmid))
{
$ref.=' '.$objmid->ref;
}
}
else dol_print_error($db);
} }
elseif ($typerecord == 'payment_salary') elseif ($typerecord == 'payment_salary')
{ {
$sqlmid = 'SELECT s.rowid as ref'; $sqlmid = 'SELECT s.rowid as ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_salary as s"; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_salary as s";
$sqlmid .= " WHERE s.rowid=" . $val["paymentsalid"]; $sqlmid .= " WHERE s.rowid=" . $val["paymentsalid"];
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); $ref = $langs->trans("SalaryPayment");
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$ref=$langs->trans("SalaryPayment");
while ($objmid = $db->fetch_object($resultmid))
{
$ref.=' '.$objmid->ref;
}
}
else dol_print_error($db);
} }
elseif ($typerecord == 'payment_vat') elseif ($typerecord == 'payment_vat')
{ {
$sqlmid = 'SELECT v.rowid as ref'; $sqlmid = 'SELECT v.rowid as ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "tva as v"; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "tva as v";
$sqlmid .= " WHERE v.rowid=" . $val["paymentvatid"]; $sqlmid .= " WHERE v.rowid=" . $val["paymentvatid"];
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); $ref = $langs->trans("PaymentVat");
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$ref=$langs->trans("PaymentVat");
while ($objmid = $db->fetch_object($resultmid))
{
$ref.=' '.$objmid->ref;
}
}
else dol_print_error($db);
} }
elseif ($typerecord == 'payment_donation') elseif ($typerecord == 'payment_donation')
{ {
$sqlmid = 'SELECT payd.fk_donation as ref'; $sqlmid = 'SELECT payd.fk_donation as ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_donation as payd"; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_donation as payd";
$sqlmid .= " WHERE payd.fk_donation=" . $val["paymentdonationid"]; $sqlmid .= " WHERE payd.fk_donation=" . $val["paymentdonationid"];
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); $ref = $langs->trans("Donation").' ';
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$ref=$langs->trans("Donation").' ';
while ($objmid = $db->fetch_object($resultmid))
{
$ref.=' '.$objmid->ref;
}
}
else dol_print_error($db);
} }
elseif ($typerecord == 'payment_various') elseif ($typerecord == 'payment_various')
{ {
$sqlmid = 'SELECT v.rowid as ref'; $sqlmid = 'SELECT v.rowid as ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_various as v"; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_various as v";
$sqlmid .= " WHERE v.rowid=" . $val["paymentvariousid"]; $sqlmid .= " WHERE v.rowid=" . $val["paymentvariousid"];
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); $ref = $langs->trans("VariousPayment");
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$ref=$langs->trans("VariousPayment");
while ($objmid = $db->fetch_object($resultmid))
{
$ref.=' '.$objmid->ref;
}
}
else dol_print_error($db);
} }
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
while ($objmid = $db->fetch_object($resultmid))
{
$ref.=' '.$objmid->ref;
}
}
else dol_print_error($db);
return $ref; return $ref;
} }