First change to enhance VAT reports

This commit is contained in:
Laurent Destailleur 2010-01-11 23:25:54 +00:00
parent 18cbf7a63b
commit 6d8a09fd74
11 changed files with 237 additions and 165 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 <EFBFBD>ric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Yannick Warnier <ywarnier@beeznest.org> * Copyright (C) 2006 Yannick Warnier <ywarnier@beeznest.org>
* *
@ -20,15 +20,16 @@
*/ */
/** /**
\file htdocs/compta/tva/clients.php * \file htdocs/compta/tva/clients.php
\ingroup tax * \ingroup tax
\brief Page des societes * \brief Page des societes
\version $Id$ * \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/report.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/report.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/tax.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/tax.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
require_once(DOL_DOCUMENT_ROOT."/compta/tva/tva.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/tva/tva.class.php");
$langs->load("bills"); $langs->load("bills");
@ -36,30 +37,43 @@ $langs->load("compta");
$langs->load("companies"); $langs->load("companies");
$langs->load("products"); $langs->load("products");
$year=$_GET["year"]; // Date range
if ($year == 0 or $year!=intval(strval($year))) $year=$_REQUEST["year"];
if (empty($year))
{ {
$year_current = strftime("%Y",time()); $year_current = strftime("%Y",dol_now());
$year_start = $year_current; $year_start = $year_current;
} else { } else {
$year_current = $year; $year_current = $year;
$year_start = $year; $year_start = $year;
}
$date_start=dol_mktime($_REQUEST["date_starthour"],$_REQUEST["date_startmin"],$_REQUEST["date_startsec"],$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]);
$date_end=dol_mktime($_REQUEST["date_endhour"],$_REQUEST["date_endmin"],$_REQUEST["date_endsec"],$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]);
// Quarter
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$q=(! empty($_REQUEST["q"]))?$_REQUEST["q"]:1; // TODO Set current quarter
if ($q==1) { $date_start=dol_get_first_day($year_start,1); $date_end=dol_get_last_day($year_start,3); }
if ($q==2) { $date_start=dol_get_first_day($year_start,4); $date_end=dol_get_last_day($year_start,6); }
if ($q==3) { $date_start=dol_get_first_day($year_start,7); $date_end=dol_get_last_day($year_start,9); }
if ($q==4) { $date_start=dol_get_first_day($year_start,10); $date_end=dol_get_last_day($year_start,12); }
}
else
{
// TODO We define q
} }
$min = $_GET["min"]; $min = $_REQUEST["min"];
if($min == 0 or $min!=floatval(strval($min))){ if (empty($min)) $min = 0;
$min = 0.00;
}else{
//keep min
}
// Define modetax (0 or 1) // Define modetax (0 or 1)
// 0=normal, 1=option vat for services is on debit // 0=normal, 1=option vat for services is on debit
$modetax = $conf->global->TAX_MODE; $modetax = $conf->global->TAX_MODE;
if (isset($_GET["modetax"])) $modetax=$_GET["modetax"]; if (isset($_REQUEST["modetax"])) $modetax=$_REQUEST["modetax"];
// Security check // Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:''; $socid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:'';
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges'); $result = restrictedArea($user, 'tax', '', '', 'charges');
@ -69,26 +83,26 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
* View * View
*/ */
$html=new Form($db);
llxHeader(); llxHeader();
$company_static=new Societe($db); $company_static=new Societe($db);
//print_fiche_titre($langs->trans("VAT"),"");
$fsearch='<form method="get" action="clients.php?year='.$year.'">'; $fsearch.=' <br><input type="hidden" name="year" value="'.$year.'">';
$fsearch.=' <input type="hidden" name="year" value="'.$year.'">'; $fsearch.=' <input type="hidden" name="modetax" value="'.$modetax.'">';
$fsearch.=' '.$langs->trans("SalesTurnover").' '.$langs->trans("Minimum").': '; $fsearch.=' '.$langs->trans("SalesTurnover").' '.$langs->trans("Minimum").': ';
$fsearch.=' <input type="text" name="min" value="'.$min.'">'; $fsearch.=' <input type="text" name="min" value="'.$min.'">';
$fsearch.=' <input type="submit" class="button" name="submit" value="'.$langs->trans("Chercher").'">';
$fsearch.='</form>';
// Affiche en-tete du rapport // Affiche en-tete du rapport
if ($modetax==1) // Calculate on invoice for goods and services if ($modetax==1) // Calculate on invoice for goods and services
{ {
$nom=$langs->trans("VATReportByCustomersInDueDebtMode"); $nom=$langs->trans("VATReportByCustomersInDueDebtMode");
$nom.='<br>('.$langs->trans("SeeVATReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modetax=0">','</a>').')'; $nom.='<br>('.$langs->trans("SeeVATReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modetax=0">','</a>').')';
$period=$year_start; //$period=$year_start;
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modetax=".$modetax."'>".img_next()."</a>":""); $period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1);
//$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modetax=".$modetax."'>".img_next()."</a>":"");
$description=$langs->trans("RulesVATDue"); $description=$langs->trans("RulesVATDue");
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite'); //if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
$description.=$fsearch; $description.=$fsearch;
@ -110,8 +124,9 @@ if ($modetax==0) // Invoice for goods, payment for services
{ {
$nom=$langs->trans("VATReportByCustomersInInputOutputMode"); $nom=$langs->trans("VATReportByCustomersInInputOutputMode");
$nom.='<br>('.$langs->trans("SeeVATReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modetax=1">','</a>').')'; $nom.='<br>('.$langs->trans("SeeVATReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modetax=1">','</a>').')';
$period=$year_start; //$period=$year_start;
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modetax=".$modetax."'>".img_next()."</a>":""); $period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1);
//$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modetax=".$modetax."'>".img_next()."</a>":"");
$description=$langs->trans("RulesVATIn"); $description=$langs->trans("RulesVATIn");
if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite'); if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
$description.=$fsearch; $description.=$fsearch;
@ -146,7 +161,7 @@ print "<td align=\"right\">".$langs->trans("SalesTurnover")." ".$langs->trans("H
print "<td align=\"right\">".$vatcust."</td>"; print "<td align=\"right\">".$vatcust."</td>";
print "</tr>\n"; print "</tr>\n";
$coll_list = vat_by_thirdparty($db,$year_current,$modetax,'sell'); $coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell');
if (is_array($coll_list)) if (is_array($coll_list))
{ {
$var=true; $var=true;
@ -218,7 +233,7 @@ print "</tr>\n";
$company_static=new Societe($db); $company_static=new Societe($db);
$coll_list = vat_by_thirdparty($db,$year_current,$modetax,'buy'); $coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy');
if (is_array($coll_list)) if (is_array($coll_list))
{ {
$var=true; $var=true;

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 <EFBFBD>ric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org> * Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org>
* *
@ -20,16 +20,17 @@
*/ */
/** /**
\file htdocs/compta/tva/quadri_detail.php * \file htdocs/compta/tva/quadri_detail.php
\ingroup tax * \ingroup tax
\brief Trimestrial page - detailed version * \brief Trimestrial page - detailed version
\version $Id$ * \version $Id$
\todo Deal with recurrent invoices as well * \todo Deal with recurrent invoices as well
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/report.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/report.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/tax.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/tax.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php");
require_once(DOL_DOCUMENT_ROOT."/compta/tva/tva.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/tva/tva.class.php");
require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product.class.php");
@ -42,24 +43,44 @@ $langs->load("compta");
$langs->load("companies"); $langs->load("companies");
$langs->load("products"); $langs->load("products");
$year=$_GET["year"]; // Date range
$year=$_REQUEST["year"];
if (empty($year)) if (empty($year))
{ {
$year_current = strftime("%Y",time()); $year_current = strftime("%Y",dol_now());
$year_start = $year_current; $year_start = $year_current;
} else { } else {
$year_current = $year; $year_current = $year;
$year_start = $year; $year_start = $year;
} }
$q=(! empty($_GET["q"]))?$_GET["q"]:1; $date_start=dol_mktime($_REQUEST["date_starthour"],$_REQUEST["date_startmin"],$_REQUEST["date_startsec"],$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]);
$date_end=dol_mktime($_REQUEST["date_endhour"],$_REQUEST["date_endmin"],$_REQUEST["date_endsec"],$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]);
// Quarter
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$q=(! empty($_REQUEST["q"]))?$_REQUEST["q"]:1; // TODO Set current quarter
if ($q==1) { $date_start=dol_get_first_day($year_start,1); $date_end=dol_get_last_day($year_start,3); }
if ($q==2) { $date_start=dol_get_first_day($year_start,4); $date_end=dol_get_last_day($year_start,6); }
if ($q==3) { $date_start=dol_get_first_day($year_start,7); $date_end=dol_get_last_day($year_start,9); }
if ($q==4) { $date_start=dol_get_first_day($year_start,10); $date_end=dol_get_last_day($year_start,12); }
}
else
{
// TODO We define q
}
$min = $_REQUEST["min"];
if (empty($min)) $min = 0;
// Define modetax (0 or 1) // Define modetax (0 or 1)
// 0=normal, 1=option vat for services is on debit // 0=normal, 1=option vat for services is on debit
$modetax = $conf->global->TAX_MODE; $modetax = $conf->global->TAX_MODE;
if (isset($_GET["modetax"])) $modetax=$_GET["modetax"]; if (isset($_REQUEST["modetax"])) $modetax=$_REQUEST["modetax"];
if (empty($modetax)) $modetax=0;
// Security check // Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:''; $socid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:'';
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges'); $result = restrictedArea($user, 'tax', '', '', 'charges');
@ -71,6 +92,8 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
llxHeader(); llxHeader();
$html=new Form($db);
$company_static=new Societe($db); $company_static=new Societe($db);
$invoice_customer=new Facture($db); $invoice_customer=new Facture($db);
$invoice_supplier=new FactureFournisseur($db); $invoice_supplier=new FactureFournisseur($db);
@ -80,19 +103,25 @@ $paymentfourn_static=new PaiementFourn($db);
//print_fiche_titre($langs->trans("VAT"),""); //print_fiche_titre($langs->trans("VAT"),"");
$fsearch.=' <br><input type="hidden" name="year" value="'.$year.'">';
$fsearch.=' <input type="hidden" name="modetax" value="'.$modetax.'">';
//$fsearch.=' '.$langs->trans("SalesTurnover").' '.$langs->trans("Minimum").': ';
//$fsearch.=' <input type="text" name="min" value="'.$min.'">';
// Affiche en-tete du rapport // Affiche en-tete du rapport
if ($modetax==1) // Calculate on invoice for goods and services if ($modetax==1) // Calculate on invoice for goods and services
{ {
$nom=$langs->trans("VATReportByQuartersInDueDebtMode"); $nom=$langs->trans("VATReportByQuartersInDueDebtMode");
$nom.='<br>('.$langs->trans("SeeVATReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&q='.$q.'&modetax=0">','</a>').')'; $nom.='<br>('.$langs->trans("SeeVATReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&q='.$q.'&modetax=0">','</a>').')';
$period=$year_start.' - '.$langs->trans("Quadri")." $q (".dol_print_date(dol_mktime(12,0,0,(($q-1)*3)+1,1,$year_start),"%b %Y").' - '.dol_print_date(dol_mktime(12,0,0,($q*3),1,$year_start),"%b %Y").")"; //$period=$year_start.' - '.$langs->trans("Quadri")." $q (".dol_print_date(dol_mktime(12,0,0,(($q-1)*3)+1,1,$year_start),"%b %Y").' - '.dol_print_date(dol_mktime(12,0,0,($q*3),1,$year_start),"%b %Y").")";
$prevyear=$year_start; $prevquarter=$q; $period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1);
$prevyear=$year_start; $prevquarter=$q;
if ($prevquarter > 1) $prevquarter--; if ($prevquarter > 1) $prevquarter--;
else { $prevquarter=4; $prevyear--; } else { $prevquarter=4; $prevyear--; }
$nextyear=$year_start; $nextquarter=$q; $nextyear=$year_start; $nextquarter=$q;
if ($nextquarter < 4) $nextquarter++; if ($nextquarter < 4) $nextquarter++;
else { $nextquarter=1; $nextyear++; } else { $nextquarter=1; $nextyear++; }
$periodlink=($prevyear?"<a href='".$_SERVER["PHP_SELF"]."?year=".$prevyear."&q=".$prevquarter."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".$nextyear."&q=".$nextquarter."&modetax=".$modetax."'>".img_next()."</a>":""); //$periodlink=($prevyear?"<a href='".$_SERVER["PHP_SELF"]."?year=".$prevyear."&q=".$prevquarter."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".$nextyear."&q=".$nextquarter."&modetax=".$modetax."'>".img_next()."</a>":"");
$description=$langs->trans("RulesVATDue"); $description=$langs->trans("RulesVATDue");
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite'); //if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
$description.=$fsearch; $description.=$fsearch;
@ -114,14 +143,15 @@ if ($modetax==0) // Invoice for goods, payment for services
{ {
$nom=$langs->trans("VATReportByQuartersInInputOutputMode"); $nom=$langs->trans("VATReportByQuartersInInputOutputMode");
$nom.='<br>('.$langs->trans("SeeVATReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&q='.$q.'&modetax=1">','</a>').')'; $nom.='<br>('.$langs->trans("SeeVATReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&q='.$q.'&modetax=1">','</a>').')';
$period=$year_start.' - '.$langs->trans("Quadri")." $q (".dol_print_date(dol_mktime(12,0,0,(($q-1)*3)+1,1,$year_start),"%b %Y").' - '.dol_print_date(dol_mktime(12,0,0,($q*3),1,$year_start),"%b %Y").")"; //$period=$year_start.' - '.$langs->trans("Quadri")." $q (".dol_print_date(dol_mktime(12,0,0,(($q-1)*3)+1,1,$year_start),"%b %Y").' - '.dol_print_date(dol_mktime(12,0,0,($q*3),1,$year_start),"%b %Y").")";
$prevyear=$year_start; $prevquarter=$q; $period=$html->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,0,'',1,0,1);
$prevyear=$year_start; $prevquarter=$q;
if ($prevquarter > 1) $prevquarter--; if ($prevquarter > 1) $prevquarter--;
else { $prevquarter=4; $prevyear--; } else { $prevquarter=4; $prevyear--; }
$nextyear=$year_start; $nextquarter=$q; $nextyear=$year_start; $nextquarter=$q;
if ($nextquarter < 4) $nextquarter++; if ($nextquarter < 4) $nextquarter++;
else { $nextquarter=1; $nextyear++; } else { $nextquarter=1; $nextyear++; }
$periodlink=($prevyear?"<a href='".$_SERVER["PHP_SELF"]."?year=".$prevyear."&q=".$prevquarter."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".$nextyear."&q=".$nextquarter."&modetax=".$modetax."'>".img_next()."</a>":""); //$periodlink=($prevyear?"<a href='".$_SERVER["PHP_SELF"]."?year=".$prevyear."&q=".$prevquarter."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".$nextyear."&q=".$nextquarter."&modetax=".$modetax."'>".img_next()."</a>":"");
$description=$langs->trans("RulesVATIn"); $description=$langs->trans("RulesVATIn");
if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite'); if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
$description.=$fsearch; $description.=$fsearch;
@ -152,8 +182,8 @@ $subtotal = 0;
$i=0; $i=0;
// Load arrays of datas // Load arrays of datas
$x_coll = vat_by_quarter($db, $y, $q, $modetax, 'sell'); $x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell');
$x_paye = vat_by_quarter($db, $y, $q, $modetax, 'buy'); $x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy');
if (! is_array($x_coll) || ! is_array($x_paye)) if (! is_array($x_coll) || ! is_array($x_paye))
{ {
@ -520,17 +550,18 @@ else
print '<tr><td colspan="'.($span+1).'">&nbsp;</td></tr>'; print '<tr><td colspan="'.($span+1).'">&nbsp;</td></tr>';
print '<tr>'; // Total to pay
print '<td colspan="'.($span-1).'"></td><td align="right" colspan="2">'.$langs->trans("TotalToPay").', '.$langs->trans("Quadri").' '.$q.':</td>'; print '<tr class="liste_titre">';
print '<td class="liste_titre" colspan="'.($span-1).'"></td><td class="liste_titre" align="right" colspan="2">'.$langs->trans("TotalToPay").', '.$langs->trans("Quadri").' '.$q.':</td>';
print '</tr>'."\n"; print '</tr>'."\n";
$diff = $x_coll_sum - $x_paye_sum; $diff = $x_coll_sum - $x_paye_sum;
print "<tr>"; print '<tr class="list_total">';
print '<td colspan="'.$span.'"></td>'; print '<td class="liste_total" colspan="'.$span.'"></td>';
print '<td nowrap align="right"><b>'.price(price2num($diff,'MT'))."</b></td>\n"; print '<td class="liste_total" nowrap="nowrap" align="right"><b>'.price(price2num($diff,'MT'))."</b></td>\n";
print "</tr>\n"; print "</tr>\n";
print '<tr><td colspan="'.($span+1).'">&nbsp;</td></tr>'."\n"; //print '<tr><td colspan="'.($span+1).'">&nbsp;</td></tr>'."\n";
$i++; $i++;
} }

View File

@ -2262,11 +2262,14 @@ class Form
* @param form_name Nom du formulaire de provenance. Utilise pour les dates en popup. * @param form_name Nom du formulaire de provenance. Utilise pour les dates en popup.
* @param d 1=Affiche aussi les jours, mois, annees * @param d 1=Affiche aussi les jours, mois, annees
* @param addnowbutton Add a button "Now" * @param addnowbutton Add a button "Now"
* @param nooutput Do not output zone but return it
*/ */
function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowbutton=0) function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowbutton=0, $nooutput=0)
{ {
global $conf,$langs; global $conf,$langs;
$retstring='';
if($prefix=='') $prefix='re'; if($prefix=='') $prefix='re';
if($h == '') $h=0; if($h == '') $h=0;
if($m == '') $m=0; if($m == '') $m=0;
@ -2320,46 +2323,46 @@ class Form
if ("$conf->use_popup_calendar" == "eldy") // Laisser conf->use_popup_calendar entre quote if ("$conf->use_popup_calendar" == "eldy") // Laisser conf->use_popup_calendar entre quote
{ {
// Zone de saisie manuelle de la date // Zone de saisie manuelle de la date
print '<input id="'.$prefix.'" name="'.$prefix.'" type="text" size="9" maxlength="11" value="'.$formated_date.'"'; $retstring ='<input id="'.$prefix.'" name="'.$prefix.'" type="text" size="9" maxlength="11" value="'.$formated_date.'"';
print ' onChange="dpChangeDay(\''.$prefix.'\',\''.$conf->format_date_short_java.'\'); "'; $retstring.=' onChange="dpChangeDay(\''.$prefix.'\',\''.$conf->format_date_short_java.'\'); "';
print '>'; $retstring.='>';
// Icone calendrier // Icone calendrier
print '<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons"'; $retstring.='<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons"';
$base=DOL_URL_ROOT.'/lib/'; $base=DOL_URL_ROOT.'/lib/';
print ' onClick="showDP(\''.$base.'\',\''.$prefix.'\',\''.$conf->format_date_short_java.'\');">'.img_object($langs->trans("SelectDate"),'calendar').'</button>'; $retstring.=' onClick="showDP(\''.$base.'\',\''.$prefix.'\',\''.$conf->format_date_short_java.'\');">'.img_object($langs->trans("SelectDate"),'calendar').'</button>';
print '<input type="hidden" id="'.$prefix.'day" name="'.$prefix.'day" value="'.$sday.'">'."\n"; $retstring.='<input type="hidden" id="'.$prefix.'day" name="'.$prefix.'day" value="'.$sday.'">'."\n";
print '<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n"; $retstring.='<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n";
print '<input type="hidden" id="'.$prefix.'year" name="'.$prefix.'year" value="'.$syear.'">'."\n"; $retstring.='<input type="hidden" id="'.$prefix.'year" name="'.$prefix.'year" value="'.$syear.'">'."\n";
} }
else else
{ {
// Calendrier popup version defaut // Calendrier popup version defaut
if ($langs->defaultlang != "") if ($langs->defaultlang != "")
{ {
print '<script type="text/javascript">'; $retstring.='<script type="text/javascript">';
print 'selectedLanguage = "'.substr($langs->defaultlang,0,2).'"'; $retstring.='selectedLanguage = "'.substr($langs->defaultlang,0,2).'"';
print '</script>'; $retstring.='</script>';
} }
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/lib/lib_calendar.js"></script>'; $retstring.='<script type="text/javascript" src="'.DOL_URL_ROOT.'/lib/lib_calendar.js"></script>';
print '<input id="'.$prefix.'" type="text" name="'.$prefix.'" size="9" value="'.$formated_date.'"'; $retstring.='<input id="'.$prefix.'" type="text" name="'.$prefix.'" size="9" value="'.$formated_date.'"';
print ' onChange="dpChangeDay(\''.$prefix.'\',\''.$conf->format_date_short_java.'\')"'; $retstring.=' onChange="dpChangeDay(\''.$prefix.'\',\''.$conf->format_date_short_java.'\')"';
print '> '; $retstring.='> ';
print '<input type="hidden" id="'.$prefix.'day" name="'.$prefix.'day" value="'.$sday.'">'."\n"; $retstring.='<input type="hidden" id="'.$prefix.'day" name="'.$prefix.'day" value="'.$sday.'">'."\n";
print '<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n"; $retstring.='<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n";
print '<input type="hidden" id="'.$prefix.'year" name="'.$prefix.'year" value="'.$syear.'">'."\n"; $retstring.='<input type="hidden" id="'.$prefix.'year" name="'.$prefix.'year" value="'.$syear.'">'."\n";
if ($form_name =="") if ($form_name =="")
{ {
print '<A HREF="javascript:showCalendar(document.forms[3].'.$prefix.')">'; $retstring.='<a href="javascript:showCalendar(document.forms[3].'.$prefix.')">';
print '<img style="vertical-align:middle" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/calendar.png" border="0" alt="" title="">'; $retstring.='<img style="vertical-align:middle" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/calendar.png" border="0" alt="" title="">';
print '</a>'; $retstring.='</a>';
} }
else else
{ {
print '<A HREF="javascript:showCalendar(document.forms[\''.$form_name.'\'].'.$prefix.')">'; $retstring.='<a href="javascript:showCalendar(document.forms[\''.$form_name.'\'].'.$prefix.')">';
print '<img style="vertical-align:middle" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/calendar.png" border="0" alt="" title="">'; $retstring.='<img style="vertical-align:middle" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/calendar.png" border="0" alt="" title="">';
print '</a>'; $retstring.='</a>';
} }
} }
} }
@ -2370,78 +2373,78 @@ class Form
if (! $conf->use_javascript_ajax || ! $conf->use_popup_calendar) if (! $conf->use_javascript_ajax || ! $conf->use_popup_calendar)
{ {
// Jour // Jour
print '<select class="flat" name="'.$prefix.'day">'; $retstring.='<select class="flat" name="'.$prefix.'day">';
if ($empty || $set_time == -1) if ($empty || $set_time == -1)
{ {
print '<option value="0" selected="true">&nbsp;</option>'; $retstring.='<option value="0" selected="true">&nbsp;</option>';
} }
for ($day = 1 ; $day <= 31; $day++) for ($day = 1 ; $day <= 31; $day++)
{ {
if ($day == $sday) if ($day == $sday)
{ {
print "<option value=\"$day\" selected=\"true\">$day"; $retstring.="<option value=\"$day\" selected=\"true\">$day";
} }
else else
{ {
print "<option value=\"$day\">$day"; $retstring.="<option value=\"$day\">$day";
} }
print "</option>"; $retstring.="</option>";
} }
print "</select>"; $retstring.="</select>";
print '<select class="flat" name="'.$prefix.'month">'; $retstring.='<select class="flat" name="'.$prefix.'month">';
if ($empty || $set_time == -1) if ($empty || $set_time == -1)
{ {
print '<option value="0" selected="true">&nbsp;</option>'; $retstring.='<option value="0" selected="true">&nbsp;</option>';
} }
// Mois // Mois
for ($month = 1 ; $month <= 12 ; $month++) for ($month = 1 ; $month <= 12 ; $month++)
{ {
print '<option value="'.$month.'"'.($month == $smonth?' selected="true"':'').'>'; $retstring.='<option value="'.$month.'"'.($month == $smonth?' selected="true"':'').'>';
print dol_print_date(mktime(1,1,1,$month,1,2000),"%b"); $retstring.=dol_print_date(mktime(1,1,1,$month,1,2000),"%b");
print "</option>"; $retstring.="</option>";
} }
print "</select>"; $retstring.="</select>";
// Ann<6E>e // Ann<6E>e
if ($empty || $set_time == -1) if ($empty || $set_time == -1)
{ {
print '<input class="flat" type="text" size="3" maxlength="4" name="'.$prefix.'year" value="'.$syear.'">'; $retstring.='<input class="flat" type="text" size="3" maxlength="4" name="'.$prefix.'year" value="'.$syear.'">';
} }
else else
{ {
print '<select class="flat" name="'.$prefix.'year">'; $retstring.='<select class="flat" name="'.$prefix.'year">';
for ($year = $syear - 5; $year < $syear + 10 ; $year++) for ($year = $syear - 5; $year < $syear + 10 ; $year++)
{ {
if ($year == $syear) if ($year == $syear)
{ {
print "<option value=\"$year\" selected=\"true\">$year"; $retstring.="<option value=\"$year\" selected=\"true\">".$year;
} }
else else
{ {
print "<option value=\"$year\">$year"; $retstring.="<option value=\"$year\">".$year;
} }
print "</option>"; $retstring.="</option>";
} }
print "</select>\n"; $retstring.="</select>\n";
} }
} }
} }
if ($d && $h) print '&nbsp;'; if ($d && $h) $retstring.='&nbsp;';
if ($h) if ($h)
{ {
/* /*
* Affiche heure en select * Affiche heure en select
*/ */
print '<select class="flat" name="'.$prefix.'hour">'; $retstring.='<select class="flat" name="'.$prefix.'hour">';
if ($empty) print '<option value="-1">&nbsp;</option>'; if ($empty) $retstring.='<option value="-1">&nbsp;</option>';
for ($hour = 0; $hour < 24; $hour++) for ($hour = 0; $hour < 24; $hour++)
{ {
if (strlen($hour) < 2) if (strlen($hour) < 2)
@ -2450,15 +2453,15 @@ class Form
} }
if ($hour == $shour) if ($hour == $shour)
{ {
print "<option value=\"$hour\" selected=\"true\">$hour</option>"; $retstring.="<option value=\"$hour\" selected=\"true\">$hour</option>";
} }
else else
{ {
print "<option value=\"$hour\">$hour</option>"; $retstring.="<option value=\"$hour\">$hour</option>";
} }
} }
print "</select>"; $retstring.="</select>";
print "H\n"; $retstring.="H\n";
} }
if ($m) if ($m)
@ -2466,8 +2469,8 @@ class Form
/* /*
* Affiche min en select * Affiche min en select
*/ */
print '<select class="flat" name="'.$prefix.'min">'; $retstring.='<select class="flat" name="'.$prefix.'min">';
if ($empty) print '<option value="-1">&nbsp;</option>'; if ($empty) $retstring.='<option value="-1">&nbsp;</option>';
for ($min = 0; $min < 60 ; $min++) for ($min = 0; $min < 60 ; $min++)
{ {
if (strlen($min) < 2) if (strlen($min) < 2)
@ -2476,15 +2479,15 @@ class Form
} }
if ($min == $smin) if ($min == $smin)
{ {
print "<option value=\"$min\" selected=\"true\">$min</option>"; $retstring.="<option value=\"$min\" selected=\"true\">$min</option>";
} }
else else
{ {
print "<option value=\"$min\">$min</option>"; $retstring.="<option value=\"$min\">$min</option>";
} }
} }
print "</select>"; $retstring.="</select>";
print "M\n"; $retstring.="M\n";
} }
// Added by Matelli http://matelli.fr/showcases/patchs-dolibarr/update-date-input-in-action-form.html) // Added by Matelli http://matelli.fr/showcases/patchs-dolibarr/update-date-input-in-action-form.html)
@ -2519,13 +2522,17 @@ class Form
// If reset_scripts is not empty, print the button with the reset_scripts in OnClick // If reset_scripts is not empty, print the button with the reset_scripts in OnClick
if ($reset_scripts) if ($reset_scripts)
{ {
print '<button class="dpInvisibleButtons" id="'.$prefix.'ButtonNow" type="button" name="_useless" value="Maintenant" onClick="'.$reset_scripts.'">'; $retstring.='<button class="dpInvisibleButtons" id="'.$prefix.'ButtonNow" type="button" name="_useless" value="Maintenant" onClick="'.$reset_scripts.'">';
print $langs->trans("Now"); $retstring.=$langs->trans("Now");
//print img_refresh($langs->trans("Now")); //print img_refresh($langs->trans("Now"));
print '</button> '; $retstring.='</button> ';
} }
} }
if (! empty($nooutput)) return $retstring;
print $restring;
return;
} }
/** /**

View File

@ -45,7 +45,7 @@ Individual=Private individual
ToCreateContactWithSameName=Will create automatically a physical contact with same informations ToCreateContactWithSameName=Will create automatically a physical contact with same informations
ParentCompany=Parent company ParentCompany=Parent company
ReportByCustomers=Report by customers ReportByCustomers=Report by customers
ReportByQuarter=Report by quarter ReportByQuarter=Report by rate
CivilityCode=Civility code CivilityCode=Civility code
RegisteredOffice=Registered office RegisteredOffice=Registered office
Name=Name Name=Name

View File

@ -101,8 +101,8 @@ RulesCADue=- It includes the clients' due invoices whether they are paid or not.
RulesCAIn=- It includes all the effective payments of invoices received from clients.<br>- It is based on the payment date of these invoices<br> RulesCAIn=- It includes all the effective payments of invoices received from clients.<br>- It is based on the payment date of these invoices<br>
VATReportByCustomersInInputOutputMode=Report by the customer VAT collected and paid (VAT receipt) VATReportByCustomersInInputOutputMode=Report by the customer VAT collected and paid (VAT receipt)
VATReportByCustomersInDueDebtMode=Report by the customer VAT collected and paid (VAT rate) VATReportByCustomersInDueDebtMode=Report by the customer VAT collected and paid (VAT rate)
VATReportByQuartersInInputOutputMode=Quarterly report of the VAT collected and paid (VAT receipt) VATReportByQuartersInInputOutputMode=Report by rate of the VAT collected and paid (VAT receipt)
VATReportByQuartersInDueDebtMode=Quarterly report of the VAT collected and paid (VAT rate) VATReportByQuartersInDueDebtMode=Report by rate of the VAT collected and paid (VAT rate)
SeeVATReportInInputOutputMode=See report <b>%sVAT encasement%s</b> for a standard calculation SeeVATReportInInputOutputMode=See report <b>%sVAT encasement%s</b> for a standard calculation
SeeVATReportInDueDebtMode=See report <b>%sVAT on flow%s</b> for a calculation with an option on the flow SeeVATReportInDueDebtMode=See report <b>%sVAT on flow%s</b> for a calculation with an option on the flow
RulesVATIn=For services, the report includes the VAT regulations actually received or issued on the basis of the date of payment.<br>- For material assets, it includes the VAT invoices on the basis of the validation date of the invoice. RulesVATIn=For services, the report includes the VAT regulations actually received or issued on the basis of the date of payment.<br>- For material assets, it includes the VAT invoices on the basis of the validation date of the invoice.

View File

@ -45,7 +45,7 @@ Company/Fundation=Société/Association
Individual=Individu privé Individual=Individu privé
ToCreateContactWithSameName=Créera automatiquement un contact physique avec info identiques ToCreateContactWithSameName=Créera automatiquement un contact physique avec info identiques
ReportByCustomers=Rapport par client ReportByCustomers=Rapport par client
ReportByQuarter=Rapport par trimestre ReportByQuarter=Rapport par taux
ParentCompany=Maison mère ParentCompany=Maison mère
CivilityCode=Code civilité CivilityCode=Code civilité
RegisteredOffice=Siège sociale RegisteredOffice=Siège sociale

View File

@ -101,8 +101,8 @@ RulesCADue=- Il inclut les factures clients dues, qu'elles soient payées ou non
RulesCAIn=- Il inclut les réglements effectivement reçus des factures clients.<br>- Il se base sur la date de réglement de ces factures<br> RulesCAIn=- Il inclut les réglements effectivement reçus des factures clients.<br>- Il se base sur la date de réglement de ces factures<br>
VATReportByCustomersInInputOutputMode=Rapport par client des TVA collectées et payés (TVA sur encaissement) VATReportByCustomersInInputOutputMode=Rapport par client des TVA collectées et payés (TVA sur encaissement)
VATReportByCustomersInDueDebtMode=Rapport par client des TVA collectées et payés (TVA sur débit) VATReportByCustomersInDueDebtMode=Rapport par client des TVA collectées et payés (TVA sur débit)
VATReportByQuartersInInputOutputMode=Rapport par trimestre des TVA collectées et payés (TVA sur encaissement) VATReportByQuartersInInputOutputMode=Rapport par taux des TVA collectées et payés (TVA sur encaissement)
VATReportByQuartersInDueDebtMode=Rapport par trimestre des TVA collectées et payés (TVA sur débit) VATReportByQuartersInDueDebtMode=Rapport par taux des TVA collectées et payés (TVA sur débit)
SeeVATReportInInputOutputMode=Voir le rapport <b>%sTVA encaissement%s</b> pour mode de calcul standard SeeVATReportInInputOutputMode=Voir le rapport <b>%sTVA encaissement%s</b> pour mode de calcul standard
SeeVATReportInDueDebtMode=Voir le rapport <b>%sTVA sur débit%s</b> pour mode de calcul avec option sur les débits SeeVATReportInDueDebtMode=Voir le rapport <b>%sTVA sur débit%s</b> pour mode de calcul avec option sur les débits
RulesVATIn=- Pour les services, le rapport inclut les TVA des réglements effectivement reçus ou émis en se basant sur la date du réglement.<br>- Pour les biens matériels, il inclut les TVA des factures en se basant sur la date de validation de la facture. RulesVATIn=- Pour les services, le rapport inclut les TVA des réglements effectivement reçus ou émis en se basant sur la date du réglement.<br>- Pour les biens matériels, il inclut les TVA des factures en se basant sur la date de validation de la facture.

View File

@ -109,7 +109,7 @@ function dol_get_prev_month($month, $year)
* \param year Year * \param year Year
* \return array Next year,month * \return array Next year,month
*/ */
function dol_get_next_month ($month, $year) function dol_get_next_month($month, $year)
{ {
if ($month == 12) if ($month == 12)
{ {
@ -128,18 +128,18 @@ function dol_get_next_month ($month, $year)
/** \brief Return GMT time with international string format for first day of a month or year /** \brief Return GMT time with international string format for first day of a month or year
* \param year Year * \param year Year
* \param month Month * \param month Month
* \return Timestamp Date for first day with format YYYY-MM-DD * \return Timestamp Date for first day
*/ */
function dol_get_first_day($year,$month=1) function dol_get_first_day($year,$month=1)
{ {
return dol_date('Y-m-d',dol_mktime(12,0,0,$month,1,$year,1),1); return dol_mktime(0,0,0,$month,1,$year,1);
} }
/** \brief Return GMT time with international string format for last day of a month or year /** \brief Return GMT time with international string format for last day of a month or year
* \param year Year * \param year Year
* \param month Month * \param month Month
* \return Timestamp Date for first day with format YYYY-MM-DD * \return Timestamp Date for first day
*/ */
function dol_get_last_day($year,$month=12) function dol_get_last_day($year,$month=12)
{ {
@ -154,10 +154,10 @@ function dol_get_last_day($year,$month=12)
} }
// On se deplace au debut du mois suivant, et on retire un jour // On se deplace au debut du mois suivant, et on retire un jour
$datelim=dol_mktime(12,0,0,$month,1,$year,1); $datelim=dol_mktime(0,0,0,$month,1,$year,1);
$datelim -= (3600 * 24); $datelim -= (3600 * 24);
return dol_date('Y-m-d',$datelim,1); return $datelim;
} }
@ -284,7 +284,7 @@ function num_between_day($timestampStart, $timestampEnd, $lastday=0)
} }
/** /**
* \brief Fonction retournant le nombre de jour entre deux dates sans les jours f<EFBFBD>ri<EFBFBD>s (jours ouvr<EFBFBD>s) * \brief Fonction retournant le nombre de jour entre deux dates sans les jours feries (jours ouvres)
* \param timestampStart Timestamp de debut * \param timestampStart Timestamp de debut
* \param timestampEnd Timestamp de fin * \param timestampEnd Timestamp de fin
* \param inhour 0: sort le nombre de jour , 1: sort le nombre d'heure (72 max) * \param inhour 0: sort le nombre de jour , 1: sort le nombre d'heure (72 max)

View File

@ -18,21 +18,21 @@
*/ */
/** /**
\file htdocs/lib/report.lib.php * \file htdocs/lib/report.lib.php
\brief Ensemble de fonctions de base de dolibarr pour reporting sous forme d'include * \brief Set of functions for reporting
\version $Id$ * \version $Id$
*/ */
/** /**
* \brief Affiche la cartouche générique d'un rapport * \brief Show header of a VAT report
* \param nom Valeur pour nom du rapport * \param nom Name of report
* \param variante Lien optionnel de variante du rapport * \param variante Link for alternate report
* \param period Periode du reporting * \param period Period of report
* \param periodlink Lien pour changer de période * \param periodlink Link to switch period
* \param description Description * \param description Description
* \param builddate Date génération * \param builddate Date generation
* \param exportlink Lien pour export * \param exportlink Link for export
*/ */
function report_header($nom,$variante='',$period,$periodlink,$description,$builddate,$exportlink) function report_header($nom,$variante='',$period,$periodlink,$description,$builddate,$exportlink)
{ {
@ -45,6 +45,7 @@ function report_header($nom,$variante='',$period,$periodlink,$description,$build
$head[$h][1] = $langs->trans("Report"); $head[$h][1] = $langs->trans("Report");
dol_fiche_head($head, $hselected, $societe->nom); dol_fiche_head($head, $hselected, $societe->nom);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<table width="100%" class="border">'; print '<table width="100%" class="border">';
// Ligne de titre // Ligne de titre
@ -62,7 +63,7 @@ function report_header($nom,$variante='',$period,$periodlink,$description,$build
print '<td>'.$langs->trans("ReportPeriod").'</td>'; print '<td>'.$langs->trans("ReportPeriod").'</td>';
if (! $periodlink) print '<td colspan="3">'; if (! $periodlink) print '<td colspan="3">';
else print '<td>'; else print '<td>';
print $period; if ($period) print $period;
if ($periodlink) print '</td><td colspan="2">'.$periodlink; if ($periodlink) print '</td><td colspan="2">'.$periodlink;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -82,7 +83,14 @@ function report_header($nom,$variante='',$period,$periodlink,$description,$build
if ($exportlink) print '</td><td>'.$langs->trans("Export").'</td><td>'.$exportlink; if ($exportlink) print '</td><td>'.$langs->trans("Export").'</td><td>'.$exportlink;
print '</td></tr>'; print '</td></tr>';
print '<tr>';
print '<td colspan="4" align="center"><input type="submit" class="button" name="submit" value="'.$langs->trans("Refresh").'"></td>';
print '</tr>';
print '</table>'; print '</table>';
print '</form>';
print '</div>'; print '</div>';
print "\n<!-- fin cartouche rapport -->\n\n"; print "\n<!-- fin cartouche rapport -->\n\n";
} }

View File

@ -29,11 +29,13 @@
* \brief Look for collectable VAT clients in the chosen year * \brief Look for collectable VAT clients in the chosen year
* \param db Database handle * \param db Database handle
* \param y Year * \param y Year
* \param modetax 0 or 1 (option vat on debit) * \param date_start Start date
* \param date_end End date
* \param modetax 0 or 1 (option vat on debit)
* \param direction 'sell' or 'buy' * \param direction 'sell' or 'buy'
* \return array List of customers third parties with vat, -1 if no accountancy module, -2 if not yet developped, -3 if error * \return array List of customers third parties with vat, -1 if no accountancy module, -2 if not yet developped, -3 if error
*/ */
function vat_by_thirdparty($db, $y, $modetax, $direction) function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction)
{ {
global $conf; global $conf;
@ -65,7 +67,7 @@ function vat_by_thirdparty($db, $y, $modetax, $direction)
{ {
// \todo a ce jour on se sait pas la compter car le montant tva d'un payment // \todo a ce jour on se sait pas la compter car le montant tva d'un payment
// n'est pas stocke dans la table des payments. // n'est pas stocke dans la table des payments.
// Seul le module compta expert peut r<EFBFBD>soudre ce probl<62>me. // Seul le module compta expert peut resoudre ce probleme.
// (Il faut quand un payment a lieu, stocker en plus du montant du paiement le // (Il faut quand un payment a lieu, stocker en plus du montant du paiement le
// detail part tva et part ht). // detail part tva et part ht).
$sql = 'TODO'; $sql = 'TODO';
@ -78,7 +80,8 @@ function vat_by_thirdparty($db, $y, $modetax, $direction)
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f, ".MAIN_DB_PREFIX.$invoicedettable." as fd, ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f, ".MAIN_DB_PREFIX.$invoicedettable." as fd, ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE "; $sql.= " WHERE ";
$sql.= " f.fk_statut in (1,2)"; // Validated or paid (partially or completely) $sql.= " f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
$sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'"; if ($y) $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " AND s.rowid = f.fk_soc AND f.rowid = fd.".$fk_facture; $sql.= " AND s.rowid = f.fk_soc AND f.rowid = fd.".$fk_facture;
$sql.= " GROUP BY s.rowid"; $sql.= " GROUP BY s.rowid";
} }
@ -89,22 +92,23 @@ function vat_by_thirdparty($db, $y, $modetax, $direction)
{ {
// If vat paid on payments // If vat paid on payments
// \todo a ce jour on se sait pas la compter car le montant tva d'un payment // \todo a ce jour on se sait pas la compter car le montant tva d'un payment
// n'est pas stock<EFBFBD> dans la table des payments. // n'est pas stocke dans la table des payments.
// Seul le module compta expert peut r<EFBFBD>soudre ce probl<62>me. // Seul le module compta expert peut resoudre ce probleme.
// (Il faut quand un payment a lieu, stocker en plus du montant du paiement le // (Il faut quand un payment a lieu, stocker en plus du montant du paiement le
// detail part tva et part ht). // detail part tva et part ht).
$sql = 'TODO'; $sql = 'TODO';
} }
if ($conf->global->MAIN_MODULE_COMPTABILITE) if ($conf->global->MAIN_MODULE_COMPTABILITE)
{ {
// Tva sur factures pay<EFBFBD>s (should be on payment) // Tva sur factures payes (should be on payment)
/* $sql = "SELECT s.nom as nom, s.tva_intra as tva_intra,"; /* $sql = "SELECT s.nom as nom, s.tva_intra as tva_intra,";
$sql.= " sum(fd.total_ht) as amount, sum(".$total_tva.") as tva,"; $sql.= " sum(fd.total_ht) as amount, sum(".$total_tva.") as tva,";
$sql.= " s.tva_assuj as assuj, s.rowid as socid"; $sql.= " s.tva_assuj as assuj, s.rowid as socid";
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f, ".MAIN_DB_PREFIX.$invoicetable." as fd, ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f, ".MAIN_DB_PREFIX.$invoicetable." as fd, ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE "; $sql.= " WHERE ";
$sql.= " f.fk_statut in (2)"; // Paid (partially or completely) $sql.= " f.fk_statut in (2)"; // Paid (partially or completely)
$sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'"; if ($y) $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " AND s.rowid = f.fk_soc AND f.rowid = fd.".$fk_facture; $sql.= " AND s.rowid = f.fk_soc AND f.rowid = fd.".$fk_facture;
$sql.= " GROUP BY s.rowid"; $sql.= " GROUP BY s.rowid";
*/ */
@ -143,13 +147,15 @@ function vat_by_thirdparty($db, $y, $modetax, $direction)
* This function also accounts recurrent invoices * This function also accounts recurrent invoices
* \param db Database handler object * \param db Database handler object
* \param y Year * \param y Year
* \param q Period. If 1-4, it's year quarter. * \param q Quarter
* \param modetax 0 or 1 (option vat on debit) * \param date_start Start date
* \param date_end End date
* \param modetax 0 or 1 (option vat on debit)
* \param direction 'sell' (customer invoice) or 'buy' (supplier invoices) * \param direction 'sell' (customer invoice) or 'buy' (supplier invoices)
* \param m Month * \param m Month
* \return array List of quarters with vat * \return array List of quarters with vat
*/ */
function vat_by_quarter($db, $y, $q=0, $modetax, $direction, $m=0) function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0)
{ {
global $conf; global $conf;
@ -207,9 +213,10 @@ function vat_by_quarter($db, $y, $q=0, $modetax, $direction, $m=0)
$sql.= " WHERE "; $sql.= " WHERE ";
$sql.= " f.fk_statut in (1,2)"; // Validated or paid (partially or completely) $sql.= " f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
$sql.= " AND f.rowid = d.".$fk_facture; $sql.= " AND f.rowid = d.".$fk_facture;
$sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'"; if ($y) $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
if ($m) $sql.= " AND (date_format(f.datef,'%m') > ".($m-1)." AND date_format(f.datef,'%m') <= ".($m).")"; if ($m) $sql.= " AND (date_format(f.datef,'%m') > ".($m-1)." AND date_format(f.datef,'%m') <= ".($m).")";
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " AND (d.product_type = 0"; // Limit to products $sql.= " AND (d.product_type = 0"; // Limit to products
$sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of service $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of service
$sql.= " ORDER BY d.rowid, d.".$fk_facture; $sql.= " ORDER BY d.rowid, d.".$fk_facture;
@ -247,12 +254,14 @@ function vat_by_quarter($db, $y, $q=0, $modetax, $direction, $m=0)
// $sql.= " AND pa.rowid = pf.".$fk_payment; // $sql.= " AND pa.rowid = pf.".$fk_payment;
// $sql.= " AND pa.datep >= '".$y."0101000000' AND pa.datep <= '".$y."1231235959'"; // $sql.= " AND pa.datep >= '".$y."0101000000' AND pa.datep <= '".$y."1231235959'";
// $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; // $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
$sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'"; if ($y) $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
if ($m) $sql.= " AND (date_format(f.datef,'%m') > ".($m-1)." AND date_format(f.datef,'%m') <= ".($m).")"; if ($m) $sql.= " AND (date_format(f.datef,'%m') > ".($m-1)." AND date_format(f.datef,'%m') <= ".($m).")";
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " AND (d.product_type = 0"; // Limit to products $sql.= " AND (d.product_type = 0"; // Limit to products
$sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of service $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of service
$sql.= " ORDER BY d.rowid, d.".$fk_facture; $sql.= " ORDER BY d.rowid, d.".$fk_facture;
//print $sql;
} }
} }
@ -341,9 +350,10 @@ function vat_by_quarter($db, $y, $q=0, $modetax, $direction, $m=0)
$sql.= " WHERE "; $sql.= " WHERE ";
$sql.= " f.fk_statut in (1,2)"; // Validated or paid (partially or completely) $sql.= " f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
$sql.= " AND f.rowid = d.".$fk_facture; $sql.= " AND f.rowid = d.".$fk_facture;
$sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'"; if ($y) $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
if ($m) $sql.= " AND (date_format(f.datef,'%m') > ".($m-1)." AND date_format(f.datef,'%m') <= ".($m).")"; if ($m) $sql.= " AND (date_format(f.datef,'%m') > ".($m-1)." AND date_format(f.datef,'%m') <= ".($m).")";
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " AND (d.product_type = 1"; // Limit to services $sql.= " AND (d.product_type = 1"; // Limit to services
$sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service
$sql.= " ORDER BY d.rowid, d.".$fk_facture; $sql.= " ORDER BY d.rowid, d.".$fk_facture;
@ -379,9 +389,10 @@ function vat_by_quarter($db, $y, $q=0, $modetax, $direction, $m=0)
$sql.= " AND f.rowid = d.".$fk_facture;; $sql.= " AND f.rowid = d.".$fk_facture;;
$sql.= " AND pf.".$fk_facture2." = f.rowid"; $sql.= " AND pf.".$fk_facture2." = f.rowid";
$sql.= " AND pa.rowid = pf.".$fk_payment; $sql.= " AND pa.rowid = pf.".$fk_payment;
$sql.= " AND pa.datep >= '".$y."0101000000' AND pa.datep <= '".$y."1231235959'"; if ($y) $sql.= " AND pa.datep >= '".$y."0101000000' AND pa.datep <= '".$y."1231235959'";
if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
if ($m) $sql.= " AND (date_format(pa.datep,'%m') > ".($m-1)." AND date_format(pa.datep,'%m') <= ".($m).")"; if ($m) $sql.= " AND (date_format(pa.datep,'%m') > ".($m-1)." AND date_format(pa.datep,'%m') <= ".($m).")";
if ($date_start && $date_end) $sql.= " AND pa.datep >= ".$db->idate($date_start)." AND pa.datep <= ".$db->idate($date_end);
$sql.= " AND (d.product_type = 1"; // Limit to services $sql.= " AND (d.product_type = 1"; // Limit to services
$sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service
$sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";

View File

@ -101,13 +101,13 @@ if ($conf->categorie->enabled && !$user->rights->categorie->voir)
if ($month > 0) if ($month > 0)
{ {
if ($year > 0) if ($year > 0)
$sql.= " AND m.datem between '".dol_get_first_day($year,$month)."' AND '".dol_get_last_day($year,$month)."'"; $sql.= " AND m.datem between '".$db->idate(dol_get_first_day($year,$month))."' AND '".$db->idate(dol_get_last_day($year,$month))."'";
else else
$sql.= " AND date_format(m.datem, '%m') = '$month'"; $sql.= " AND date_format(m.datem, '%m') = '$month'";
} }
else if ($year > 0) else if ($year > 0)
{ {
$sql.= " AND m.datem between '".dol_get_first_day($year)."' AND '".dol_get_last_day($year)."'"; $sql.= " AND m.datem between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."'";
} }
if (! empty($search_movment)) if (! empty($search_movment))
{ {