diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index c777c36dca0..a2ec757b212 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -18,9 +18,9 @@ */ /** - * \file htdocs/accountancy/admin/card.php - * \ingroup Advanced accountancy - * \brief Card of accounting account + * \file htdocs/accountancy/admin/card.php + * \ingroup Advanced accountancy + * \brief Card of accounting account */ require '../../main.inc.php'; diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 443bbfa4961..1c5e036c78b 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2013-2018 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 @@ -16,9 +16,9 @@ */ /** - * \file htdocs/accountancy/admin/fiscalyear.php - * \ingroup Advanced accountancy - * \brief Setup page to configure fiscal year + * \file htdocs/accountancy/admin/fiscalyear.php + * \ingroup Advanced accountancy + * \brief Setup page to configure fiscal year */ require '../../main.inc.php'; @@ -45,8 +45,8 @@ $langs->loadLangs(array("admin","compta")); // Security check if ($user->societe_id > 0) accessforbidden(); -if (! $user->rights->accounting->fiscalyear) // If we can read accounting records, we shoul be able to see fiscal year. - accessforbidden(); +if (! $user->rights->accounting->fiscalyear) // If we can read accounting records, we should be able to see fiscal year. + accessforbidden(); $error = 0; @@ -113,23 +113,26 @@ if ($result) if (! empty($user->rights->accounting->fiscalyear)) { - $addbutton = '' . $langs->trans("NewFiscalYear") . ''; + $addbutton = '' . $langs->trans("NewFiscalYear") .''; } else { - $addbutton = '' . $langs->trans("NewFiscalYear") . ''; + $addbutton = '' . $langs->trans("NewFiscalYear") .''; } $title = $langs->trans('AccountingPeriods'); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $addbutton, '', $limit, 1); // Load attribute_label - print ''; + print '
'; + print '
'; print ''; print ''; print ''; print ''; print ''; + print ''; + print ''; print ''; print ''; @@ -144,6 +147,8 @@ if ($result) print ''; print ''; print ''; + print ''; + print ''; print ''; print ''; $i++; @@ -152,6 +157,7 @@ if ($result) print ''; } print '
' . $langs->trans("Ref") . '' . $langs->trans("Label") . '' . $langs->trans("DateStart") . '' . $langs->trans("DateEnd") . '' . $langs->trans("NumberOfAccountancyEntries") . '' . $langs->trans("NumberOfAccountancyMovements") . '' . $langs->trans("Statut") . '
' . $obj->label . '' . dol_print_date($db->jdate($obj->date_start), 'day') . '' . dol_print_date($db->jdate($obj->date_end), 'day') . '' . $object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end) . '' . $object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end) . '' . $fiscalyearstatic->LibStatut($obj->statut, 5) . '
' . $langs->trans("None") . '
'; + print ''; } else { dol_print_error($db); } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 88f3cae0a21..80a0c6f819b 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -256,7 +256,7 @@ class Account extends CommonObject } /** - * Shows the account number in the appropiate format + * Shows the account number in the appropriate format * * @return string */ @@ -419,7 +419,7 @@ class Account extends CommonObject */ function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='', $accountancycode='', $datev=null) { - // Deprecatîon warning + // Deprecation warning if (is_numeric($oper)) { dol_syslog(__METHOD__ . ": using numeric operations is deprecated", LOG_WARNING); } @@ -430,7 +430,7 @@ class Account extends CommonObject $now=dol_now(); - if (is_numeric($oper)) // Clean oper to have a code instead of a rowid + if (is_numeric($oper)) // Clean operation to have a code instead of a rowid { $sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_paiement"; $sql.= " WHERE id=".$oper; diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index 985d67d5cae..c1c288cbf79 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2018 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 @@ -21,7 +21,7 @@ * \brief File of class to manage fiscal years */ -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; /** * Class to manage fiscal year @@ -60,9 +60,9 @@ class Fiscalyear extends CommonObject public $rowid; /** - * @var string fiscal year label - */ - public $label; + * @var string fiscal year label + */ + public $label; public $date_start; public $date_end; @@ -82,8 +82,10 @@ class Fiscalyear extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + function __construct(DoliDB $db) { + global $langs; + $this->db = $db; $this->statuts_short = array(0 => 'Opened', 1 => 'Closed'); @@ -163,10 +165,10 @@ class Fiscalyear extends CommonObject // Check parameters if (empty($this->date_start) && empty($this->date_end)) - { - $this->error='ErrorBadParameter'; - return -1; - } + { + $this->error='ErrorBadParameter'; + return -1; + } $this->db->begin(); @@ -267,7 +269,7 @@ class Fiscalyear extends CommonObject return $this->LibStatut($this->statut,$mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Give a label from a status * @@ -277,7 +279,7 @@ class Fiscalyear extends CommonObject */ function LibStatut($statut,$mode=0) { - // phpcs:enable + // phpcs:enable global $langs; if ($mode == 0) @@ -354,4 +356,56 @@ class Fiscalyear extends CommonObject dol_print_error($this->db); } } + + /** + * Return the number of entries by fiscal year + * + * @param int $datestart Date start to scan + * @param int $dateend Date end to scan + * @return string Number of entries + */ + function getAccountancyEntriesByFiscalYear($datestart, $dateend) + { + global $conf; + + $sql = "SELECT count(DISTINCT piece_num) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping "; + $sql.= " WHERE doc_date >= '".$datestart."' and doc_date <= '".$dateend."'"; + + $resql=$this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + $nb = $obj->nb; + } + else dol_print_error($this->db); + + return $nb; + } + + /** + * Return the number of movements by fiscal year + * + * @param int $datestart Date start to scan + * @param int $dateend Date end to scan + * @return string Number of movements + */ + function getAccountancyMovementsByFiscalYear($datestart, $dateend) + { + global $conf; + + $sql = "SELECT count(rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping "; + $sql.= " WHERE doc_date >= '".$datestart."' AND doc_date <= '".$dateend."'"; + + $resql=$this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + $nb = $obj->nb; + } + else dol_print_error($this->db); + + return $nb; + } } diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index c14b7bef0ca..6986f549759 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -254,6 +254,8 @@ AccountingJournalType8=Inventory AccountingJournalType9=Has-new ErrorAccountingJournalIsAlreadyUse=This journal is already use AccountingAccountForSalesTaxAreDefinedInto=Note: Accounting account for Sales tax are defined into menu %s - %s +NumberOfAccountancyEntries=Number of entries +NumberOfAccountancyMovements=Number of movements ## Export ExportDraftJournal=Export draft journal