diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 3e4b69d6624..5038c93fc82 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -1,7 +1,7 @@ - * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2015 Alexandre Spangaro +/* Copyright (C) 2016 Olivier Geffroy + * Copyright (C) 2016 Florian Henry + * Copyright (C) 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 @@ -19,9 +19,9 @@ */ /** - * \file htdocs/accountancy/bookkeeping/balance.php - * \ingroup Accounting Expert - * \brief Balance of book keeping + * \file htdocs/accountancy/bookkeeping/balance.php + * \ingroup Advanced accountancy + * \brief Balance of book keeping */ require '../../main.inc.php'; @@ -137,7 +137,6 @@ else { /* * List */ - $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); @@ -150,13 +149,12 @@ else { if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - - print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords); - + + print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result); + print '
'; print '
' . "\n"; print '
'; - print '
'; print '
'; @@ -169,6 +167,7 @@ else { print ''; print ''; print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder); @@ -176,11 +175,11 @@ else { print "\n"; print ''; - print ''; @@ -203,23 +202,28 @@ else { foreach ( $object->lines as $line ) { $var = ! $var; - + $link = ''; $total_debit += $line->debit; $total_credit += $line->credit; - + $description = $object->get_compte_desc($line->numero_compte); // Search description of the account + if(empty($description)){ + $link = '' . img_edit_add() .''; + } print ""; print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print "\n"; } print ''; print ''; + print ''; print ''; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 4a0ebbe8988..ebf2b1d8f20 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015-2016 Florian Henry + * Copyright (C) 2015-2016 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * * This program is free software; you can redistribute it and/or modify @@ -1207,6 +1207,48 @@ class BookKeeping extends CommonObject return - 1; } } + + /** + * Description of accounting account + * + * @param string $account Accounting account + * @return string + */ + function get_compte_desc($account = null) + { + global $conf; + $pcgver = $conf->global->CHARTOFACCOUNTS; + + $sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category"; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa "; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; + $sql .= " AND aa.account_number = '" . $account . "'"; + $sql .= " AND asy.rowid = " . $pcgver; + $sql .= " AND aa.active = 1"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid"; + + dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $obj = ''; + if ($this->db->num_rows($resql)) { + $obj = $this->db->fetch_object($resql); + } + + if(empty($obj->category)){ + return $obj->label; + }else{ + return $obj->label.' ('.$obj->category.')'; + + } + } else { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR); + + return -1; + } + } + } /** diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index 502e83010f7..9c750719102 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -18,9 +18,9 @@ */ /** - * \file htdocs/core/lib/account.lib.php - * \ingroup Accounting Expert - * \brief Library of accountancy functions + * \file htdocs/core/lib/accounting.lib.php + * \ingroup Advanced accountancy + * \brief Library of accountancy functions */ /** @@ -120,7 +120,7 @@ function length_accountg($account) // Clean parameters $i = strlen($account); - if ($i >= 2) { + if ($i >= 1) { while ( $i < $g ) { $account .= '0'; @@ -152,7 +152,7 @@ function length_accounta($accounta) // Clean parameters $i = strlen($accounta); - if ($i >= 2) { + if ($i >= 1) { while ( $i < $a ) { $accounta .= '0';
'; + print ''; print $langs->trans('From'); print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, ''); print '
'; - print $langs->trans('To'); + print $langs->trans('to'); print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, ''); print '
' . length_accountg($line->numero_compte) . '' . price($line->debit) . '' . price($line->credit) . '' . price($line->credit - $line->debit) . ''; + print '' . $description . '' . number_format($line->debit, 2, ',', ' ') . '' . number_format($line->credit, 2, ',', ' ') . '' . number_format($line->credit - $line->debit, 2, ',', ' ') . '' . $link; print '
'; print price($total_debit); print '