From ba6dadb6fa97af3b1fe927c97b7c35c2b6fb38ad Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 27 Feb 2016 16:21:40 +0100 Subject: [PATCH 1/2] Fix: Use getNomUrl to show account_parent instead of rowid of the account --- htdocs/accountancy/admin/account.php | 35 ++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 8ebaa93d96c..3f251e0090b 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2015 Alexandre Spangaro +/* Copyright (C) 2013-2016 Olivier Geffroy + * Copyright (C) 2013-2016 Alexandre Spangaro * * 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 @@ -17,9 +17,9 @@ */ /** - * \file htdocs/accountancy/admin/account.php - * \ingroup Accounting Expert - * \brief List accounting account + * \file htdocs/accountancy/admin/account.php + * \ingroup Advanced accountancy + * \brief List accounting account */ require '../../main.inc.php'; @@ -104,10 +104,12 @@ llxHeader('', $langs->trans("ListAccounts")); $pcgver = $conf->global->CHARTOFACCOUNTS; -$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active "; -$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa, " . MAIN_DB_PREFIX . "accounting_system as asy"; -$sql .= " WHERE aa.fk_pcg_version = asy.pcg_version"; -$sql .= " AND asy.rowid = " . $pcgver; +$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active, "; +$sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; +$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON aa.account_parent = a2.rowid"; +$sql .= " WHERE asy.rowid = " . $pcgver; if (strlen(trim($search_account))) { $sql .= " AND aa.account_number like '%" . $search_account . "%'"; @@ -175,6 +177,7 @@ if ($result) { $var = false; $accountstatic = new AccountingAccount($db); + $accountparent = new AccountingAccount($db); while ( $i < min($num, $limit) ) { $obj = $db->fetch_object($resql); @@ -186,7 +189,19 @@ if ($result) { print ''; print '' . $accountstatic->getNomUrl(1) . ''; print '' . $obj->label . ''; - print '' . $obj->account_parent . ''; + + if ($obj->account_parent) + { + $accountparent->id = $obj->rowid2; + $accountparent->label = $obj->label2; + $accountparent->account_number = $obj->account_number2; + + print '' . $accountparent->getNomUrl(1) . ''; + } + else + { + print ' '; + } print '' . $obj->pcg_type . ''; print '' . $obj->pcg_subtype . ''; print ''; From 0136a1742efbe9662e0bc024476fe95be483633b Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 27 Feb 2016 16:21:59 +0100 Subject: [PATCH 2/2] Spaces !!! --- htdocs/accountancy/journal/bankjournal.php | 110 ++++++++++----------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 8eaf497fbf0..90d63ef05f8 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -23,9 +23,9 @@ */ /** - * \file htdocs/accountancy/journal/bankjournal.php - * \ingroup Accounting Expert - * \brief Page with bank journal + * \file htdocs/accountancy/journal/bankjournal.php + * \ingroup Advanced accountancy + * \brief Page with bank journal */ require '../../main.inc.php'; @@ -72,7 +72,7 @@ $now = dol_now(); if ($user->societe_id > 0 && empty($id_bank_account)) accessforbidden(); - /* +/* * View */ $year_current = strftime("%Y", dol_now()); @@ -127,7 +127,7 @@ $journal = $bank_code_journal->accountancy_journal; dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG); $result = $db->query($sql); if ($result) { - + $num = $db->num_rows($result); // Variables $cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef")); @@ -135,22 +135,22 @@ if ($result) { $accountancy_account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : $langs->trans("CodeNotDef")); $accountancy_account_pay_vat = (! empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : $langs->trans("CodeNotDef")); $accountancy_account_pay_donation = (! empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : $langs->trans("CodeNotDef")); - + $tabpay = array (); $tabbq = array (); $tabtp = array (); $tabtype = array (); - + $i = 0; while ( $i < $num ) { $obj = $db->fetch_object($result); - + $tabcompany[$obj->rowid] = array ( 'id' => $obj->socid, 'name' => $obj->name, 'code_client' => $obj->code_compta ); - + // Controls $compta_bank = $obj->account_number; if ($obj->label == '(SupplierInvoicePayment)') @@ -159,8 +159,8 @@ if ($result) { $compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $cptcli); if ($obj->typeop == '(BankTransfert)') $compta_soc = $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH; - - // Variable bookkeeping + + // Variable bookkeeping $tabpay[$obj->rowid]["date"] = $obj->do; $tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; $tabpay[$obj->rowid]["ref"] = $obj->label; @@ -171,12 +171,12 @@ if ($result) { $tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60); } $links = $object->get_url($obj->rowid); - + // get_url may return -1 which is not traversable if (is_array($links)) { foreach ( $links as $key => $val ) { $tabtype[$obj->rowid] = $links[$key]['type']; - + if ($links[$key]['type'] == 'payment') { $paymentstatic->id = $links[$key]['url_id']; $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2); @@ -197,7 +197,7 @@ if ($result) { } else if ($links[$key]['type'] == 'sc') { $chargestatic->id = $links[$key]['url_id']; $chargestatic->ref = $links[$key]['url_id']; - + $tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2); if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { if ($reg[1] == 'socialcontribution') @@ -208,14 +208,14 @@ if ($result) { } $chargestatic->ref = $chargestatic->lib; $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); - + $sqlmid = 'SELECT cchgsoc.accountancy_code'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; $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) { @@ -247,9 +247,9 @@ if ($result) { }*/ } } - + $tabbq[$obj->rowid][$compta_bank] += $obj->amount; - + // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount; $i ++; @@ -265,7 +265,7 @@ if ($result) { // Write bookkeeping if ($action == 'writebookkeeping') { $now = dol_now(); - + $error = 0; foreach ( $tabpay as $key => $val ) { // Bank @@ -286,9 +286,9 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->fk_user_author = $user->id; $bookkeeping->date_create = $now; - + if ($tabtype[$key] == 'payment') { - + $sqlmid = 'SELECT fac.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; @@ -301,7 +301,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_ref = $objmid->facnumber; } } else if ($tabtype[$key] == 'payment_supplier') { - + $sqlmid = 'SELECT facf.ref_supplier,facf.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; @@ -315,7 +315,7 @@ if ($action == 'writebookkeeping') { ; } } - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; @@ -338,12 +338,12 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_journal = $journal; $bookkeeping->fk_user_author = $user->id; $bookkeeping->date_create = $now; - + if ($tabtype[$key] == 'sc') { $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; } else if ($tabtype[$key] == 'payment') { - + $sqlmid = 'SELECT fac.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; @@ -358,7 +358,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_tiers = $k; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; } else if ($tabtype[$key] == 'payment_supplier') { - + $sqlmid = 'SELECT facf.ref_supplier,facf.ref'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; @@ -373,7 +373,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->code_tiers = $k; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; } else if ($tabtype[$key] == 'company') { - + $sqlmid = 'SELECT fac.facnumber'; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; @@ -392,7 +392,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->doc_ref = $k; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; } - + $result = $bookkeeping->create($user); if ($result < 0) { $error ++; @@ -400,7 +400,7 @@ if ($action == 'writebookkeeping') { } } } - + if (empty($error)) { setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); } @@ -408,25 +408,25 @@ if ($action == 'writebookkeeping') { // Export if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; - + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - + $companystatic = new Client($db); - + // Model Cegid Expert Export if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { $sep = ";"; - + 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']; $companystatic->client = $tabcompany[$key]['code_client']; - + $date = dol_print_date($db->jdate($val["date"]), '%d%m%Y'); - + // Bank foreach ( $tabbq[$key] as $k => $mt ) { print $date . $sep; @@ -439,7 +439,7 @@ if ($action == 'export_csv') { print $val["ref"] . $sep; print "\n"; } - + // Third party if (is_array($tabtp[$key])) { foreach ( $tabtp[$key] as $k => $mt ) { @@ -477,10 +477,10 @@ if ($action == 'export_csv') { // Model Classic Export foreach ( $tabpay as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), 'day'); - + $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - + // Bank foreach ( $tabbq[$key] as $k => $mt ) { print '"' . $date . '"' . $sep; @@ -491,7 +491,7 @@ if ($action == 'export_csv') { print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; print "\n"; } - + // Third party if (is_array($tabtp[$key])) { foreach ( $tabtp[$key] as $k => $mt ) { @@ -520,23 +520,23 @@ if ($action == 'export_csv') { } } else { $form = new Form($db); - + llxHeader('', $langs->trans("FinanceJournal")); - + $nom = $langs->trans("FinanceJournal") . ' - ' . $journal; $builddate = time(); $description = $langs->trans("DescFinanceJournal") . '
'; $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); - + $varlink = 'id_account=' . $id_bank_account; report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array ( 'action' => '' ), '', $varlink); - + print ''; - + print ''; - + print ' '; - + /* * Show result array */ print '

'; - + $i = 0; print ""; print ""; @@ -566,10 +566,10 @@ if ($action == 'export_csv') { print ""; print ""; print "\n"; - + $var = true; $r = ''; - + foreach ( $tabpay as $key => $val ) { $date = dol_print_date($db->jdate($val["date"]), 'day'); @@ -579,8 +579,8 @@ if ($action == 'export_csv') { if ($val["lib"] == '(CustomerInvoicePayment)') { $reflabel = $langs->trans('CustomerInvoicePayment'); } - - // Bank + + // Bank foreach ( $tabbq[$key] as $k => $mt ) { print ""; print ""; @@ -592,7 +592,7 @@ if ($action == 'export_csv') { print ""; print ""; } - + // Third party if (is_array($tabtp[$key])) { foreach ( $tabtp[$key] as $k => $mt ) { @@ -623,9 +623,9 @@ if ($action == 'export_csv') { } $var = ! $var; } - + print "
" . $langs->trans("PaymentMode") . "" . $langs->trans("Debit") . "" . $langs->trans("Credit") . "
" . $date . "" . ($mt < 0 ? price(- $mt) : '') . "
"; - + llxFooter(); } $db->close();