diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index 161b9c15e64..98e9e70b0bd 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004 �ric Seigne + * Copyright (C) 2004 Eric Seigne * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2006 Yannick Warnier * @@ -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='
'; -$fsearch.=' '; +$fsearch.='
'; +$fsearch.=' '; $fsearch.=' '.$langs->trans("SalesTurnover").' '.$langs->trans("Minimum").': '; $fsearch.=' '; -$fsearch.=' '; -$fsearch.='
'; // Affiche en-tete du rapport if ($modetax==1) // Calculate on invoice for goods and services { $nom=$langs->trans("VATReportByCustomersInDueDebtMode"); $nom.='
('.$langs->trans("SeeVATReportInInputOutputMode",'','').')'; - $period=$year_start; - $periodlink=($year_start?"".img_previous()." ".img_next()."":""); + //$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?"".img_previous()." ".img_next()."":""); $description=$langs->trans("RulesVATDue"); //if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='
'.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.='
('.$langs->trans("SeeVATReportInDueDebtMode",'','').')'; - $period=$year_start; - $periodlink=($year_start?"".img_previous()." ".img_next()."":""); + //$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?"".img_previous()." ".img_next()."":""); $description=$langs->trans("RulesVATIn"); if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='
'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite'); $description.=$fsearch; @@ -146,7 +161,7 @@ print "".$langs->trans("SalesTurnover")." ".$langs->trans("H print "".$vatcust.""; print "\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 "\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; diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 71f46679a21..6a77d26e1de 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004 �ric Seigne + * Copyright (C) 2004 Eric Seigne * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2006-2007 Yannick Warnier * @@ -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.='
'; +$fsearch.=' '; +//$fsearch.=' '.$langs->trans("SalesTurnover").' '.$langs->trans("Minimum").': '; +//$fsearch.=' '; + // Affiche en-tete du rapport if ($modetax==1) // Calculate on invoice for goods and services { $nom=$langs->trans("VATReportByQuartersInDueDebtMode"); $nom.='
('.$langs->trans("SeeVATReportInInputOutputMode",'','').')'; - $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?"".img_previous()." ".img_next()."":""); + //$periodlink=($prevyear?"".img_previous()." ".img_next()."":""); $description=$langs->trans("RulesVATDue"); //if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='
'.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.='
('.$langs->trans("SeeVATReportInDueDebtMode",'','').')'; - $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?"".img_previous()." ".img_next()."":""); + //$periodlink=($prevyear?"".img_previous()." ".img_next()."":""); $description=$langs->trans("RulesVATIn"); if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='
'.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 ' '; - print ''; - print ''.$langs->trans("TotalToPay").', '.$langs->trans("Quadri").' '.$q.':'; + // Total to pay + print ''; + print ''.$langs->trans("TotalToPay").', '.$langs->trans("Quadri").' '.$q.':'; print ''."\n"; $diff = $x_coll_sum - $x_paye_sum; - print ""; - print ''; - print ''.price(price2num($diff,'MT'))."\n"; + print ''; + print ''; + print ''.price(price2num($diff,'MT'))."\n"; print "\n"; - print ' '."\n"; + //print ' '."\n"; $i++; } diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 3229cad0b7d..931d66f85d3 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -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 ''; + $retstring ='format_date_short_java.'\'); "'; + $retstring.='>'; // Icone calendrier - print ''; + $retstring.=' onClick="showDP(\''.$base.'\',\''.$prefix.'\',\''.$conf->format_date_short_java.'\');">'.img_object($langs->trans("SelectDate"),'calendar').''; - print ''."\n"; - print ''."\n"; - print ''."\n"; + $retstring.=''."\n"; + $retstring.=''."\n"; + $retstring.=''."\n"; } else { // Calendrier popup version defaut if ($langs->defaultlang != "") { - print ''; + $retstring.=''; } - print ''; - print ' '; - print ''."\n"; - print ''."\n"; - print ''."\n"; + $retstring.=''; + $retstring.='format_date_short_java.'\')"'; + $retstring.='> '; + $retstring.=''."\n"; + $retstring.=''."\n"; + $retstring.=''."\n"; if ($form_name =="") { - print ''; - print ''; - print ''; + $retstring.=''; + $retstring.=''; + $retstring.=''; } else { - print ''; - print ''; - print ''; + $retstring.=''; + $retstring.=''; + $retstring.=''; } } } @@ -2370,78 +2373,78 @@ class Form if (! $conf->use_javascript_ajax || ! $conf->use_popup_calendar) { // Jour - print ''; if ($empty || $set_time == -1) { - print ''; + $retstring.=''; } for ($day = 1 ; $day <= 31; $day++) { if ($day == $sday) { - print ""; + $retstring.=""; } - print ""; + $retstring.=""; - print ''; if ($empty || $set_time == -1) { - print ''; + $retstring.=''; } // Mois for ($month = 1 ; $month <= 12 ; $month++) { - print '"; + $retstring.='"; } - print ""; + $retstring.=""; // Ann�e if ($empty || $set_time == -1) { - print ''; + $retstring.=''; } else { - print ''; for ($year = $syear - 5; $year < $syear + 10 ; $year++) { if ($year == $syear) { - print ""; + $retstring.=""; } - print "\n"; + $retstring.="\n"; } } } - if ($d && $h) print ' '; + if ($d && $h) $retstring.=' '; if ($h) { /* * Affiche heure en select */ - print ''; + if ($empty) $retstring.=''; for ($hour = 0; $hour < 24; $hour++) { if (strlen($hour) < 2) @@ -2450,15 +2453,15 @@ class Form } if ($hour == $shour) { - print ""; + $retstring.=""; } else { - print ""; + $retstring.=""; } } - print ""; - print "H\n"; + $retstring.=""; + $retstring.="H\n"; } if ($m) @@ -2466,8 +2469,8 @@ class Form /* * Affiche min en select */ - print ''; + if ($empty) $retstring.=''; for ($min = 0; $min < 60 ; $min++) { if (strlen($min) < 2) @@ -2476,15 +2479,15 @@ class Form } if ($min == $smin) { - print ""; + $retstring.=""; } else { - print ""; + $retstring.=""; } } - print ""; - print "M\n"; + $retstring.=""; + $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 ' '; + $retstring.=' '; } } + if (! empty($nooutput)) return $retstring; + + print $restring; + return; } /** diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index aade072071a..a7eb053b0a9 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -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 diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 5cbf75179d6..c55a7dd32e3 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -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.
- It is based on the payment date of these invoices
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 %sVAT encasement%s for a standard calculation SeeVATReportInDueDebtMode=See report %sVAT on flow%s 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.
- For material assets, it includes the VAT invoices on the basis of the validation date of the invoice. diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 3c93b2e5e68..84c3da7156b 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -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 diff --git a/htdocs/langs/fr_FR/compta.lang b/htdocs/langs/fr_FR/compta.lang index e2471a48fc7..2f5a93d0b31 100644 --- a/htdocs/langs/fr_FR/compta.lang +++ b/htdocs/langs/fr_FR/compta.lang @@ -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.
- Il se base sur la date de réglement de ces factures
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 %sTVA encaissement%s pour mode de calcul standard SeeVATReportInDueDebtMode=Voir le rapport %sTVA sur débit%s 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.
- Pour les biens matériels, il inclut les TVA des factures en se basant sur la date de validation de la facture. diff --git a/htdocs/lib/date.lib.php b/htdocs/lib/date.lib.php index c767154ed78..cb69287b5a7 100644 --- a/htdocs/lib/date.lib.php +++ b/htdocs/lib/date.lib.php @@ -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�ri�s (jours ouvr�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) diff --git a/htdocs/lib/report.lib.php b/htdocs/lib/report.lib.php index 3cd6684eee0..c9b19f99414 100644 --- a/htdocs/lib/report.lib.php +++ b/htdocs/lib/report.lib.php @@ -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\n"; $h=0; $head[$h][0] = $_SERVER["PHP_SELF"]; $head[$h][1] = $langs->trans("Report"); dol_fiche_head($head, $hselected, $societe->nom); - + + print '
'; print ''; // Ligne de titre @@ -56,13 +57,13 @@ function report_header($nom,$variante='',$period,$periodlink,$description,$build if ($variante) print ''; print ''; - + // Ligne de la periode d'analyse du rapport print ''; print ''; if (! $periodlink) print ''; print ''; @@ -81,8 +82,15 @@ function report_header($nom,$variante='',$period,$periodlink,$description,$build print dol_print_date($builddate); if ($exportlink) print ''; - + + print ''; + print ''; + print ''; + print '
'.$variante; print '
'.$langs->trans("ReportPeriod").''; else print ''; - print $period; + if ($period) print $period; if ($periodlink) print ''.$periodlink; print '
'.$langs->trans("Export").''.$exportlink; print '
'; + + print '
'; + print ''; print "\n\n\n"; } diff --git a/htdocs/lib/tax.lib.php b/htdocs/lib/tax.lib.php index 48996d3265f..f496321469f 100644 --- a/htdocs/lib/tax.lib.php +++ b/htdocs/lib/tax.lib.php @@ -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�soudre ce probl�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� dans la table des payments. - // Seul le module compta expert peut r�soudre ce probl�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�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"; diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 0b150e60d09..5a08186bc61 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -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)) {