mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
First change to enhance VAT reports
This commit is contained in:
parent
18cbf7a63b
commit
6d8a09fd74
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/* 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) 2006 Yannick Warnier <ywarnier@beeznest.org>
|
||||
*
|
||||
|
|
@ -20,15 +20,16 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/compta/tva/clients.php
|
||||
\ingroup tax
|
||||
\brief Page des societes
|
||||
\version $Id$
|
||||
*/
|
||||
* \file htdocs/compta/tva/clients.php
|
||||
* \ingroup tax
|
||||
* \brief Page des societes
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require("./pre.inc.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/date.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/compta/tva/tva.class.php");
|
||||
|
||||
$langs->load("bills");
|
||||
|
|
@ -36,30 +37,43 @@ $langs->load("compta");
|
|||
$langs->load("companies");
|
||||
$langs->load("products");
|
||||
|
||||
$year=$_GET["year"];
|
||||
if ($year == 0 or $year!=intval(strval($year)))
|
||||
// Date range
|
||||
$year=$_REQUEST["year"];
|
||||
if (empty($year))
|
||||
{
|
||||
$year_current = strftime("%Y",time());
|
||||
$year_start = $year_current;
|
||||
$year_current = strftime("%Y",dol_now());
|
||||
$year_start = $year_current;
|
||||
} else {
|
||||
$year_current = $year;
|
||||
$year_start = $year;
|
||||
$year_current = $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"];
|
||||
if($min == 0 or $min!=floatval(strval($min))){
|
||||
$min = 0.00;
|
||||
}else{
|
||||
//keep min
|
||||
}
|
||||
$min = $_REQUEST["min"];
|
||||
if (empty($min)) $min = 0;
|
||||
|
||||
// Define modetax (0 or 1)
|
||||
// 0=normal, 1=option vat for services is on debit
|
||||
$modetax = $conf->global->TAX_MODE;
|
||||
if (isset($_GET["modetax"])) $modetax=$_GET["modetax"];
|
||||
if (isset($_REQUEST["modetax"])) $modetax=$_REQUEST["modetax"];
|
||||
|
||||
// Security check
|
||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||
$socid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:'';
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
||||
|
||||
|
|
@ -69,26 +83,26 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
|
|||
* View
|
||||
*/
|
||||
|
||||
$html=new Form($db);
|
||||
|
||||
llxHeader();
|
||||
|
||||
$company_static=new Societe($db);
|
||||
|
||||
//print_fiche_titre($langs->trans("VAT"),"");
|
||||
|
||||
$fsearch='<form method="get" action="clients.php?year='.$year.'">';
|
||||
$fsearch.=' <input type="hidden" name="year" value="'.$year.'">';
|
||||
$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.'">';
|
||||
$fsearch.=' <input type="submit" class="button" name="submit" value="'.$langs->trans("Chercher").'">';
|
||||
$fsearch.='</form>';
|
||||
|
||||
// Affiche en-tete du rapport
|
||||
if ($modetax==1) // Calculate on invoice for goods and services
|
||||
{
|
||||
$nom=$langs->trans("VATReportByCustomersInDueDebtMode");
|
||||
$nom.='<br>('.$langs->trans("SeeVATReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modetax=0">','</a>').')';
|
||||
$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=$year_start;
|
||||
$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");
|
||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
$description.=$fsearch;
|
||||
|
|
@ -110,8 +124,9 @@ if ($modetax==0) // Invoice for goods, payment for services
|
|||
{
|
||||
$nom=$langs->trans("VATReportByCustomersInInputOutputMode");
|
||||
$nom.='<br>('.$langs->trans("SeeVATReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modetax=1">','</a>').')';
|
||||
$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=$year_start;
|
||||
$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");
|
||||
if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
$description.=$fsearch;
|
||||
|
|
@ -146,7 +161,7 @@ print "<td align=\"right\">".$langs->trans("SalesTurnover")." ".$langs->trans("H
|
|||
print "<td align=\"right\">".$vatcust."</td>";
|
||||
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))
|
||||
{
|
||||
$var=true;
|
||||
|
|
@ -218,7 +233,7 @@ print "</tr>\n";
|
|||
|
||||
$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))
|
||||
{
|
||||
$var=true;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/* 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) 2006-2007 Yannick Warnier <ywarnier@beeznest.org>
|
||||
*
|
||||
|
|
@ -20,16 +20,17 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/compta/tva/quadri_detail.php
|
||||
\ingroup tax
|
||||
\brief Trimestrial page - detailed version
|
||||
\version $Id$
|
||||
\todo Deal with recurrent invoices as well
|
||||
*/
|
||||
* \file htdocs/compta/tva/quadri_detail.php
|
||||
* \ingroup tax
|
||||
* \brief Trimestrial page - detailed version
|
||||
* \version $Id$
|
||||
* \todo Deal with recurrent invoices as well
|
||||
*/
|
||||
|
||||
require("./pre.inc.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/date.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/compta/tva/tva.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
||||
|
|
@ -42,24 +43,44 @@ $langs->load("compta");
|
|||
$langs->load("companies");
|
||||
$langs->load("products");
|
||||
|
||||
$year=$_GET["year"];
|
||||
// Date range
|
||||
$year=$_REQUEST["year"];
|
||||
if (empty($year))
|
||||
{
|
||||
$year_current = strftime("%Y",time());
|
||||
$year_current = strftime("%Y",dol_now());
|
||||
$year_start = $year_current;
|
||||
} else {
|
||||
$year_current = $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)
|
||||
// 0=normal, 1=option vat for services is on debit
|
||||
$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
|
||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||
$socid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:'';
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
||||
|
||||
|
|
@ -71,6 +92,8 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
|
|||
|
||||
llxHeader();
|
||||
|
||||
$html=new Form($db);
|
||||
|
||||
$company_static=new Societe($db);
|
||||
$invoice_customer=new Facture($db);
|
||||
$invoice_supplier=new FactureFournisseur($db);
|
||||
|
|
@ -80,19 +103,25 @@ $paymentfourn_static=new PaiementFourn($db);
|
|||
|
||||
//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
|
||||
if ($modetax==1) // Calculate on invoice for goods and services
|
||||
{
|
||||
$nom=$langs->trans("VATReportByQuartersInDueDebtMode");
|
||||
$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").")";
|
||||
$prevyear=$year_start; $prevquarter=$q;
|
||||
//$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=$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--;
|
||||
else { $prevquarter=4; $prevyear--; }
|
||||
$nextyear=$year_start; $nextquarter=$q;
|
||||
if ($nextquarter < 4) $nextquarter++;
|
||||
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");
|
||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
$description.=$fsearch;
|
||||
|
|
@ -114,14 +143,15 @@ if ($modetax==0) // Invoice for goods, payment for services
|
|||
{
|
||||
$nom=$langs->trans("VATReportByQuartersInInputOutputMode");
|
||||
$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").")";
|
||||
$prevyear=$year_start; $prevquarter=$q;
|
||||
//$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=$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--;
|
||||
else { $prevquarter=4; $prevyear--; }
|
||||
$nextyear=$year_start; $nextquarter=$q;
|
||||
if ($nextquarter < 4) $nextquarter++;
|
||||
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");
|
||||
if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
$description.=$fsearch;
|
||||
|
|
@ -152,8 +182,8 @@ $subtotal = 0;
|
|||
$i=0;
|
||||
|
||||
// Load arrays of datas
|
||||
$x_coll = vat_by_quarter($db, $y, $q, $modetax, 'sell');
|
||||
$x_paye = vat_by_quarter($db, $y, $q, $modetax, 'buy');
|
||||
$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell');
|
||||
$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy');
|
||||
|
||||
if (! is_array($x_coll) || ! is_array($x_paye))
|
||||
{
|
||||
|
|
@ -520,17 +550,18 @@ else
|
|||
|
||||
print '<tr><td colspan="'.($span+1).'"> </td></tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td colspan="'.($span-1).'"></td><td align="right" colspan="2">'.$langs->trans("TotalToPay").', '.$langs->trans("Quadri").' '.$q.':</td>';
|
||||
// Total to pay
|
||||
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";
|
||||
|
||||
$diff = $x_coll_sum - $x_paye_sum;
|
||||
print "<tr>";
|
||||
print '<td colspan="'.$span.'"></td>';
|
||||
print '<td nowrap align="right"><b>'.price(price2num($diff,'MT'))."</b></td>\n";
|
||||
print '<tr class="list_total">';
|
||||
print '<td class="liste_total" colspan="'.$span.'"></td>';
|
||||
print '<td class="liste_total" nowrap="nowrap" align="right"><b>'.price(price2num($diff,'MT'))."</b></td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr><td colspan="'.($span+1).'"> </td></tr>'."\n";
|
||||
//print '<tr><td colspan="'.($span+1).'"> </td></tr>'."\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2262,11 +2262,14 @@ class Form
|
|||
* @param form_name Nom du formulaire de provenance. Utilise pour les dates en popup.
|
||||
* @param d 1=Affiche aussi les jours, mois, annees
|
||||
* @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;
|
||||
|
||||
$retstring='';
|
||||
|
||||
if($prefix=='') $prefix='re';
|
||||
if($h == '') $h=0;
|
||||
if($m == '') $m=0;
|
||||
|
|
@ -2320,46 +2323,46 @@ class Form
|
|||
if ("$conf->use_popup_calendar" == "eldy") // Laisser conf->use_popup_calendar entre quote
|
||||
{
|
||||
// Zone de saisie manuelle de la date
|
||||
print '<input id="'.$prefix.'" name="'.$prefix.'" type="text" size="9" maxlength="11" value="'.$formated_date.'"';
|
||||
print ' onChange="dpChangeDay(\''.$prefix.'\',\''.$conf->format_date_short_java.'\'); "';
|
||||
print '>';
|
||||
$retstring ='<input id="'.$prefix.'" name="'.$prefix.'" type="text" size="9" maxlength="11" value="'.$formated_date.'"';
|
||||
$retstring.=' onChange="dpChangeDay(\''.$prefix.'\',\''.$conf->format_date_short_java.'\'); "';
|
||||
$retstring.='>';
|
||||
|
||||
// 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/';
|
||||
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";
|
||||
print '<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.'day" name="'.$prefix.'day" value="'.$sday.'">'."\n";
|
||||
$retstring.='<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n";
|
||||
$retstring.='<input type="hidden" id="'.$prefix.'year" name="'.$prefix.'year" value="'.$syear.'">'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Calendrier popup version defaut
|
||||
if ($langs->defaultlang != "")
|
||||
{
|
||||
print '<script type="text/javascript">';
|
||||
print 'selectedLanguage = "'.substr($langs->defaultlang,0,2).'"';
|
||||
print '</script>';
|
||||
$retstring.='<script type="text/javascript">';
|
||||
$retstring.='selectedLanguage = "'.substr($langs->defaultlang,0,2).'"';
|
||||
$retstring.='</script>';
|
||||
}
|
||||
print '<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.'"';
|
||||
print ' onChange="dpChangeDay(\''.$prefix.'\',\''.$conf->format_date_short_java.'\')"';
|
||||
print '> ';
|
||||
print '<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";
|
||||
print '<input type="hidden" id="'.$prefix.'year" name="'.$prefix.'year" value="'.$syear.'">'."\n";
|
||||
$retstring.='<script type="text/javascript" src="'.DOL_URL_ROOT.'/lib/lib_calendar.js"></script>';
|
||||
$retstring.='<input id="'.$prefix.'" type="text" name="'.$prefix.'" size="9" value="'.$formated_date.'"';
|
||||
$retstring.=' onChange="dpChangeDay(\''.$prefix.'\',\''.$conf->format_date_short_java.'\')"';
|
||||
$retstring.='> ';
|
||||
$retstring.='<input type="hidden" id="'.$prefix.'day" name="'.$prefix.'day" value="'.$sday.'">'."\n";
|
||||
$retstring.='<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n";
|
||||
$retstring.='<input type="hidden" id="'.$prefix.'year" name="'.$prefix.'year" value="'.$syear.'">'."\n";
|
||||
if ($form_name =="")
|
||||
{
|
||||
print '<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="">';
|
||||
print '</a>';
|
||||
$retstring.='<a href="javascript:showCalendar(document.forms[3].'.$prefix.')">';
|
||||
$retstring.='<img style="vertical-align:middle" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/calendar.png" border="0" alt="" title="">';
|
||||
$retstring.='</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<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="">';
|
||||
print '</a>';
|
||||
$retstring.='<a href="javascript:showCalendar(document.forms[\''.$form_name.'\'].'.$prefix.')">';
|
||||
$retstring.='<img style="vertical-align:middle" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/calendar.png" border="0" alt="" title="">';
|
||||
$retstring.='</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2370,78 +2373,78 @@ class Form
|
|||
if (! $conf->use_javascript_ajax || ! $conf->use_popup_calendar)
|
||||
{
|
||||
// Jour
|
||||
print '<select class="flat" name="'.$prefix.'day">';
|
||||
$retstring.='<select class="flat" name="'.$prefix.'day">';
|
||||
|
||||
if ($empty || $set_time == -1)
|
||||
{
|
||||
print '<option value="0" selected="true"> </option>';
|
||||
$retstring.='<option value="0" selected="true"> </option>';
|
||||
}
|
||||
|
||||
for ($day = 1 ; $day <= 31; $day++)
|
||||
{
|
||||
if ($day == $sday)
|
||||
{
|
||||
print "<option value=\"$day\" selected=\"true\">$day";
|
||||
$retstring.="<option value=\"$day\" selected=\"true\">$day";
|
||||
}
|
||||
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)
|
||||
{
|
||||
print '<option value="0" selected="true"> </option>';
|
||||
$retstring.='<option value="0" selected="true"> </option>';
|
||||
}
|
||||
|
||||
// Mois
|
||||
for ($month = 1 ; $month <= 12 ; $month++)
|
||||
{
|
||||
print '<option value="'.$month.'"'.($month == $smonth?' selected="true"':'').'>';
|
||||
print dol_print_date(mktime(1,1,1,$month,1,2000),"%b");
|
||||
print "</option>";
|
||||
$retstring.='<option value="'.$month.'"'.($month == $smonth?' selected="true"':'').'>';
|
||||
$retstring.=dol_print_date(mktime(1,1,1,$month,1,2000),"%b");
|
||||
$retstring.="</option>";
|
||||
}
|
||||
print "</select>";
|
||||
$retstring.="</select>";
|
||||
|
||||
// Ann<6E>e
|
||||
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
|
||||
{
|
||||
print '<select class="flat" name="'.$prefix.'year">';
|
||||
$retstring.='<select class="flat" name="'.$prefix.'year">';
|
||||
|
||||
for ($year = $syear - 5; $year < $syear + 10 ; $year++)
|
||||
{
|
||||
if ($year == $syear)
|
||||
{
|
||||
print "<option value=\"$year\" selected=\"true\">$year";
|
||||
$retstring.="<option value=\"$year\" selected=\"true\">".$year;
|
||||
}
|
||||
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 ' ';
|
||||
if ($d && $h) $retstring.=' ';
|
||||
|
||||
if ($h)
|
||||
{
|
||||
/*
|
||||
* Affiche heure en select
|
||||
*/
|
||||
print '<select class="flat" name="'.$prefix.'hour">';
|
||||
if ($empty) print '<option value="-1"> </option>';
|
||||
$retstring.='<select class="flat" name="'.$prefix.'hour">';
|
||||
if ($empty) $retstring.='<option value="-1"> </option>';
|
||||
for ($hour = 0; $hour < 24; $hour++)
|
||||
{
|
||||
if (strlen($hour) < 2)
|
||||
|
|
@ -2450,15 +2453,15 @@ class Form
|
|||
}
|
||||
if ($hour == $shour)
|
||||
{
|
||||
print "<option value=\"$hour\" selected=\"true\">$hour</option>";
|
||||
$retstring.="<option value=\"$hour\" selected=\"true\">$hour</option>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<option value=\"$hour\">$hour</option>";
|
||||
$retstring.="<option value=\"$hour\">$hour</option>";
|
||||
}
|
||||
}
|
||||
print "</select>";
|
||||
print "H\n";
|
||||
$retstring.="</select>";
|
||||
$retstring.="H\n";
|
||||
}
|
||||
|
||||
if ($m)
|
||||
|
|
@ -2466,8 +2469,8 @@ class Form
|
|||
/*
|
||||
* Affiche min en select
|
||||
*/
|
||||
print '<select class="flat" name="'.$prefix.'min">';
|
||||
if ($empty) print '<option value="-1"> </option>';
|
||||
$retstring.='<select class="flat" name="'.$prefix.'min">';
|
||||
if ($empty) $retstring.='<option value="-1"> </option>';
|
||||
for ($min = 0; $min < 60 ; $min++)
|
||||
{
|
||||
if (strlen($min) < 2)
|
||||
|
|
@ -2476,15 +2479,15 @@ class Form
|
|||
}
|
||||
if ($min == $smin)
|
||||
{
|
||||
print "<option value=\"$min\" selected=\"true\">$min</option>";
|
||||
$retstring.="<option value=\"$min\" selected=\"true\">$min</option>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<option value=\"$min\">$min</option>";
|
||||
$retstring.="<option value=\"$min\">$min</option>";
|
||||
}
|
||||
}
|
||||
print "</select>";
|
||||
print "M\n";
|
||||
$retstring.="</select>";
|
||||
$retstring.="M\n";
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
print '<button class="dpInvisibleButtons" id="'.$prefix.'ButtonNow" type="button" name="_useless" value="Maintenant" onClick="'.$reset_scripts.'">';
|
||||
print $langs->trans("Now");
|
||||
$retstring.='<button class="dpInvisibleButtons" id="'.$prefix.'ButtonNow" type="button" name="_useless" value="Maintenant" onClick="'.$reset_scripts.'">';
|
||||
$retstring.=$langs->trans("Now");
|
||||
//print img_refresh($langs->trans("Now"));
|
||||
print '</button> ';
|
||||
$retstring.='</button> ';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($nooutput)) return $retstring;
|
||||
|
||||
print $restring;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ Individual=Private individual
|
|||
ToCreateContactWithSameName=Will create automatically a physical contact with same informations
|
||||
ParentCompany=Parent company
|
||||
ReportByCustomers=Report by customers
|
||||
ReportByQuarter=Report by quarter
|
||||
ReportByQuarter=Report by rate
|
||||
CivilityCode=Civility code
|
||||
RegisteredOffice=Registered office
|
||||
Name=Name
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
VATReportByCustomersInInputOutputMode=Report by the customer VAT collected and paid (VAT receipt)
|
||||
VATReportByCustomersInDueDebtMode=Report by the customer VAT collected and paid (VAT rate)
|
||||
VATReportByQuartersInInputOutputMode=Quarterly report of the VAT collected and paid (VAT receipt)
|
||||
VATReportByQuartersInDueDebtMode=Quarterly report of the VAT collected and paid (VAT rate)
|
||||
VATReportByQuartersInInputOutputMode=Report by rate of the VAT collected and paid (VAT receipt)
|
||||
VATReportByQuartersInDueDebtMode=Report by rate of the VAT collected and paid (VAT rate)
|
||||
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
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ Company/Fundation=Société/Association
|
|||
Individual=Individu privé
|
||||
ToCreateContactWithSameName=Créera automatiquement un contact physique avec info identiques
|
||||
ReportByCustomers=Rapport par client
|
||||
ReportByQuarter=Rapport par trimestre
|
||||
ReportByQuarter=Rapport par taux
|
||||
ParentCompany=Maison mère
|
||||
CivilityCode=Code civilité
|
||||
RegisteredOffice=Siège sociale
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
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)
|
||||
VATReportByQuartersInInputOutputMode=Rapport par trimestre 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)
|
||||
VATReportByQuartersInInputOutputMode=Rapport par taux des TVA collectées et payés (TVA sur encaissement)
|
||||
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
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ function dol_get_prev_month($month, $year)
|
|||
* \param year Year
|
||||
* \return array Next year,month
|
||||
*/
|
||||
function dol_get_next_month ($month, $year)
|
||||
function dol_get_next_month($month, $year)
|
||||
{
|
||||
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
|
||||
* \param year Year
|
||||
* \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)
|
||||
{
|
||||
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
|
||||
* \param year Year
|
||||
* \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)
|
||||
{
|
||||
|
|
@ -152,12 +152,12 @@ function dol_get_last_day($year,$month=12)
|
|||
{
|
||||
$month += 1;
|
||||
}
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
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 timestampEnd Timestamp de fin
|
||||
* \param inhour 0: sort le nombre de jour , 1: sort le nombre d'heure (72 max)
|
||||
|
|
|
|||
|
|
@ -18,33 +18,34 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/lib/report.lib.php
|
||||
\brief Ensemble de fonctions de base de dolibarr pour reporting sous forme d'include
|
||||
\version $Id$
|
||||
*/
|
||||
* \file htdocs/lib/report.lib.php
|
||||
* \brief Set of functions for reporting
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \brief Affiche la cartouche générique d'un rapport
|
||||
* \param nom Valeur pour nom du rapport
|
||||
* \param variante Lien optionnel de variante du rapport
|
||||
* \param period Periode du reporting
|
||||
* \param periodlink Lien pour changer de période
|
||||
* \brief Show header of a VAT report
|
||||
* \param nom Name of report
|
||||
* \param variante Link for alternate report
|
||||
* \param period Period of report
|
||||
* \param periodlink Link to switch period
|
||||
* \param description Description
|
||||
* \param builddate Date génération
|
||||
* \param exportlink Lien pour export
|
||||
* \param builddate Date generation
|
||||
* \param exportlink Link for export
|
||||
*/
|
||||
function report_header($nom,$variante='',$period,$periodlink,$description,$builddate,$exportlink)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
|
||||
print "\n\n<!-- debut cartouche rapport -->\n";
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = $_SERVER["PHP_SELF"];
|
||||
$head[$h][1] = $langs->trans("Report");
|
||||
dol_fiche_head($head, $hselected, $societe->nom);
|
||||
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<table width="100%" class="border">';
|
||||
|
||||
// Ligne de titre
|
||||
|
|
@ -56,13 +57,13 @@ function report_header($nom,$variante='',$period,$periodlink,$description,$build
|
|||
if ($variante) print '</td><td colspan="2">'.$variante;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
// Ligne de la periode d'analyse du rapport
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("ReportPeriod").'</td>';
|
||||
if (! $periodlink) print '<td colspan="3">';
|
||||
else print '<td>';
|
||||
print $period;
|
||||
if ($period) print $period;
|
||||
if ($periodlink) print '</td><td colspan="2">'.$periodlink;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
|
@ -81,8 +82,15 @@ function report_header($nom,$variante='',$period,$periodlink,$description,$build
|
|||
print dol_print_date($builddate);
|
||||
if ($exportlink) print '</td><td>'.$langs->trans("Export").'</td><td>'.$exportlink;
|
||||
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 '</form>';
|
||||
|
||||
print '</div>';
|
||||
print "\n<!-- fin cartouche rapport -->\n\n";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,11 +29,13 @@
|
|||
* \brief Look for collectable VAT clients in the chosen year
|
||||
* \param db Database handle
|
||||
* \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'
|
||||
* \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;
|
||||
|
||||
|
|
@ -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
|
||||
// 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
|
||||
// detail part tva et part ht).
|
||||
$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.= " WHERE ";
|
||||
$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.= " GROUP BY s.rowid";
|
||||
}
|
||||
|
|
@ -89,22 +92,23 @@ function vat_by_thirdparty($db, $y, $modetax, $direction)
|
|||
{
|
||||
// If vat paid on payments
|
||||
// \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.
|
||||
// Seul le module compta expert peut r<EFBFBD>soudre ce probl<62>me.
|
||||
// n'est pas stocke dans la table des payments.
|
||||
// Seul le module compta expert peut resoudre ce probleme.
|
||||
// (Il faut quand un payment a lieu, stocker en plus du montant du paiement le
|
||||
// detail part tva et part ht).
|
||||
$sql = 'TODO';
|
||||
}
|
||||
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.= " sum(fd.total_ht) as amount, sum(".$total_tva.") as tva,";
|
||||
$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.= " WHERE ";
|
||||
$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.= " GROUP BY s.rowid";
|
||||
*/
|
||||
|
|
@ -143,13 +147,15 @@ function vat_by_thirdparty($db, $y, $modetax, $direction)
|
|||
* This function also accounts recurrent invoices
|
||||
* \param db Database handler object
|
||||
* \param y Year
|
||||
* \param q Period. If 1-4, it's year quarter.
|
||||
* \param modetax 0 or 1 (option vat on debit)
|
||||
* \param q Quarter
|
||||
* \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 m Month
|
||||
* \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;
|
||||
|
||||
|
|
@ -207,9 +213,10 @@ function vat_by_quarter($db, $y, $q=0, $modetax, $direction, $m=0)
|
|||
$sql.= " WHERE ";
|
||||
$sql.= " f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
|
||||
$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 ($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.date_start is null AND d.date_end IS NULL)"; // enhance detection of service
|
||||
$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.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 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 ($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.date_start is null AND d.date_end IS NULL)"; // enhance detection of service
|
||||
$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.= " f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
|
||||
$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 ($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.= " 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;
|
||||
|
|
@ -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 pf.".$fk_facture2." = f.rowid";
|
||||
$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 ($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.= " 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";
|
||||
|
|
|
|||
|
|
@ -101,13 +101,13 @@ if ($conf->categorie->enabled && !$user->rights->categorie->voir)
|
|||
if ($month > 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
|
||||
$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))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user