NEW: Add stats on entries & movements by fiscal year

This commit is contained in:
Alexandre SPANGARO 2018-12-02 11:01:11 +01:00
parent 2466fa224c
commit 088c002ed1
6 changed files with 90 additions and 22 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com> * Copyright (C) 2013-2018 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* *
* 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
@ -18,9 +18,9 @@
*/ */
/** /**
* \file htdocs/accountancy/admin/card.php * \file htdocs/accountancy/admin/card.php
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief Card of accounting account * \brief Card of accounting account
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
@ -41,6 +41,7 @@ $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$rowid = GETPOST('rowid', 'int'); $rowid = GETPOST('rowid', 'int');
$cancel = GETPOST('cancel','alpha'); $cancel = GETPOST('cancel','alpha');
$accountingaccount = GETPOST('accountingaccount','alpha');
// Security check // Security check
@ -229,7 +230,7 @@ if ($action == 'create') {
// Account number // Account number
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("AccountNumber") . '</span></td>'; print '<tr><td class="titlefieldcreate"><span class="fieldrequired">' . $langs->trans("AccountNumber") . '</span></td>';
print '<td><input name="account_number" size="30" value="' . $object->account_number . '"></td></tr>'; print '<td><input name="account_number" size="30" value="' . $accountingaccount . '"></td></tr>';
// Label // Label
print '<tr><td><span class="fieldrequired">' . $langs->trans("Label") . '</span></td>'; print '<tr><td><span class="fieldrequired">' . $langs->trans("Label") . '</span></td>';

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com> /* Copyright (C) 2013-2018 Alexandre Spangaro <aspangaro@zendsi.com>
* *
* 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
@ -16,9 +16,9 @@
*/ */
/** /**
* \file htdocs/accountancy/admin/fiscalyear.php * \file htdocs/accountancy/admin/fiscalyear.php
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
* \brief Setup page to configure fiscal year * \brief Setup page to configure fiscal year
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
@ -45,8 +45,8 @@ $langs->loadLangs(array("admin","compta"));
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
if (! $user->rights->accounting->fiscalyear) // If we can read accounting records, we shoul be able to see fiscal year. if (! $user->rights->accounting->fiscalyear) // If we can read accounting records, we should be able to see fiscal year.
accessforbidden(); accessforbidden();
$error = 0; $error = 0;
@ -113,23 +113,26 @@ if ($result)
if (! empty($user->rights->accounting->fiscalyear)) if (! empty($user->rights->accounting->fiscalyear))
{ {
$addbutton = '<a class="butAction" href="fiscalyear_card.php?action=create">' . $langs->trans("NewFiscalYear") . '</a>'; $addbutton = '<a class="butActionNew" href="fiscalyear_card.php?action=create"><span class="valignmiddle">' . $langs->trans("NewFiscalYear") .'</span><span class="fa fa-plus-circle valignmiddle"></span></a>';
} }
else else
{ {
$addbutton = '<a class="butActionRefused" href="#">' . $langs->trans("NewFiscalYear") . '</a>'; $addbutton = '<a class="butActionRefused" href="#"><span class="valignmiddle">' . $langs->trans("NewFiscalYear") .'</span><span class="fa fa-plus-circle valignmiddle"></span></a>';
} }
$title = $langs->trans('AccountingPeriods'); $title = $langs->trans('AccountingPeriods');
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $addbutton, '', $limit, 1); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $addbutton, '', $limit, 1);
// Load attribute_label // Load attribute_label
print '<table class="noborder" width="100%">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>' . $langs->trans("Ref") . '</td>'; print '<td>' . $langs->trans("Ref") . '</td>';
print '<td>' . $langs->trans("Label") . '</td>'; print '<td>' . $langs->trans("Label") . '</td>';
print '<td>' . $langs->trans("DateStart") . '</td>'; print '<td>' . $langs->trans("DateStart") . '</td>';
print '<td>' . $langs->trans("DateEnd") . '</td>'; print '<td>' . $langs->trans("DateEnd") . '</td>';
print '<td align="center">' . $langs->trans("NumberOfAccountancyEntries") . '</td>';
print '<td align="center">' . $langs->trans("NumberOfAccountancyMovements") . '</td>';
print '<td align="right">' . $langs->trans("Statut") . '</td>'; print '<td align="right">' . $langs->trans("Statut") . '</td>';
print '</tr>'; print '</tr>';
@ -144,6 +147,8 @@ if ($result)
print '<td align="left">' . $obj->label . '</td>'; print '<td align="left">' . $obj->label . '</td>';
print '<td align="left">' . dol_print_date($db->jdate($obj->date_start), 'day') . '</td>'; print '<td align="left">' . dol_print_date($db->jdate($obj->date_start), 'day') . '</td>';
print '<td align="left">' . dol_print_date($db->jdate($obj->date_end), 'day') . '</td>'; print '<td align="left">' . dol_print_date($db->jdate($obj->date_end), 'day') . '</td>';
print '<td align="center">' . $object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end) . '</td>';
print '<td align="center">' . $object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end) . '</td>';
print '<td align="right">' . $fiscalyearstatic->LibStatut($obj->statut, 5) . '</td>'; print '<td align="right">' . $fiscalyearstatic->LibStatut($obj->statut, 5) . '</td>';
print '</tr>'; print '</tr>';
$i++; $i++;
@ -152,6 +157,7 @@ if ($result)
print '<tr class="oddeven"><td colspan="5" class="opacitymedium">' . $langs->trans("None") . '</td></tr>'; print '<tr class="oddeven"><td colspan="5" class="opacitymedium">' . $langs->trans("None") . '</td></tr>';
} }
print '</table>'; print '</table>';
print '</div>';
} else { } else {
dol_print_error($db); dol_print_error($db);
} }

View File

@ -265,7 +265,7 @@ if ($action != 'export_csv')
$description = $object->get_compte_desc($line->numero_compte); // Search description of the account $description = $object->get_compte_desc($line->numero_compte); // Search description of the account
$root_account_description = $object->get_compte_racine($line->numero_compte); $root_account_description = $object->get_compte_racine($line->numero_compte);
if (empty($description)) { if (empty($description)) {
$link = '<a href="../admin/card.php?action=create&compte=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>'; $link = '<a href="../admin/card.php?action=create&accountingaccount=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>';
} }
print '<tr class="oddeven">'; print '<tr class="oddeven">';

View File

@ -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 * @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) 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)) { if (is_numeric($oper)) {
dol_syslog(__METHOD__ . ": using numeric operations is deprecated", LOG_WARNING); dol_syslog(__METHOD__ . ": using numeric operations is deprecated", LOG_WARNING);
} }
@ -430,7 +430,7 @@ class Account extends CommonObject
$now=dol_now(); $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 = "SELECT code FROM ".MAIN_DB_PREFIX."c_paiement";
$sql.= " WHERE id=".$oper; $sql.= " WHERE id=".$oper;

View File

@ -21,13 +21,18 @@
* \brief File of class to manage fiscal years * \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 * Class to manage fiscal year
*/ */
class Fiscalyear extends CommonObject class Fiscalyear extends CommonObject
{ {
/**
* @var DoliDB Database handler.
*/
public $db;
/** /**
* @var string ID to identify managed object * @var string ID to identify managed object
*/ */
@ -82,8 +87,10 @@ class Fiscalyear extends CommonObject
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) function __construct(DoliDB $db)
{ {
global $langs;
$this->db = $db; $this->db = $db;
$this->statuts_short = array(0 => 'Opened', 1 => 'Closed'); $this->statuts_short = array(0 => 'Opened', 1 => 'Closed');
@ -354,4 +361,56 @@ class Fiscalyear extends CommonObject
dol_print_error($this->db); dol_print_error($this->db);
} }
} }
/**
* Return the number of entries by fiscal year
*
* @param int $year Year to scan
* @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month
* @return array Array of values
*/
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 string $year Year to scan
* @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month
* @return array Array of values
*/
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;
}
} }

View File

@ -254,6 +254,8 @@ AccountingJournalType8=Inventory
AccountingJournalType9=Has-new AccountingJournalType9=Has-new
ErrorAccountingJournalIsAlreadyUse=This journal is already use ErrorAccountingJournalIsAlreadyUse=This journal is already use
AccountingAccountForSalesTaxAreDefinedInto=Note: Accounting account for Sales tax are defined into menu <b>%s</b> - <b>%s</b> AccountingAccountForSalesTaxAreDefinedInto=Note: Accounting account for Sales tax are defined into menu <b>%s</b> - <b>%s</b>
NumberOfAccountancyEntries=Number of entries
NumberOfAccountancyMovements=Number of movements
## Export ## Export
ExportDraftJournal=Export draft journal ExportDraftJournal=Export draft journal