* Copyright (C) 2004 Eric Seigne * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/compta/tva/index.php * \ingroup tax * \brief Index page of VAT reports * \version $Id: index.php,v 1.43 2011/08/03 00:46:24 eldy Exp $ */ require('../../main.inc.php'); require_once(DOL_DOCUMENT_ROOT."/lib/tax.lib.php"); require_once(DOL_DOCUMENT_ROOT."/compta/tva/class/tva.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php"); $langs->load("other"); $year=$_GET["year"]; if ($year == 0 ) { $year_current = strftime("%Y",time()); $year_start = $year_current; } else { $year_current = $year; $year_start = $year; } // Security check $socid = isset($_GET["socid"])?$_GET["socid"]:''; if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); // 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"]; function pt ($db, $sql, $date) { global $conf, $bc,$langs; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; $total = 0; print ""; print ""; print ""; print ""; print "\n"; print "\n"; $var=True; while ($i < $num) { $obj = $db->fetch_object($result); $var=!$var; print ""; print "\n"; $total = $total + $obj->mm; print "\n"; print "\n"; $i++; } print ""; print "
$date".$langs->trans("Amount")." 
$obj->dm".price($obj->mm)." 
".$langs->trans("Total")." :".price($total)." 
"; $db->free($result); } else { dolibar_print_error($db); } } /* * View */ llxHeader(); $tva = new Tva($db); $textprevyear="".img_previous().""; $textnextyear=" ".img_next().""; print_fiche_titre($langs->trans("VAT"),"$textprevyear ".$langs->trans("Year")." $year_start $textnextyear"); print $langs->trans("VATReportBuildWithOptionDefinedInModule").'
'; print '('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')
'; print '
'; echo ''; echo ''; echo '
'; print_titre($langs->trans("VATSummary")); // The report mode is the one defined by defaut in tax module setup //print $modetax; //print '('.$langs->trans("SeeVATReportInInputOutputMode",'','').')'; echo ' '; print_titre($langs->trans("VATPaid")); echo '
'; print ""; print ""; print ""; print ""; print ""; print ""; print "\n"; print "\n"; $y = $year_current ; $var=True; $total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; $i=0; for ($m = 1 ; $m < 13 ; $m++ ) { $coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m); $coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m); if (! is_array($coll_listbuy) && $coll_listbuy == -1) { $langs->load("errors"); print ''; break; } if (! is_array($coll_listbuy) && $coll_listbuy == -2) { print ''; break; } $var=!$var; print ""; print ''; $x_coll = 0; foreach($coll_listsell as $vatrate=>$val) { $x_coll+=$val['vat']; } $subtotalcoll = $subtotalcoll + $x_coll; print ""; $x_paye = 0; foreach($coll_listbuy as $vatrate=>$val) { $x_paye+=$val['vat']; } $subtotalpaye = $subtotalpaye + $x_paye; print ""; $diff = $x_coll - $x_paye; $total = $total + $diff; $subtotal = $subtotal + $diff; print "\n"; print "\n"; print "\n"; $i++; if ($i > 2) { print ''; print ''; print ''; print ''; print ''; print ''; $i = 0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; } } print ''; print "\n"; print ''; /*} else { print ''; print ''; }*/ print '
".$langs->trans("Year")." $y".$langs->trans("VATToPay")."".$langs->trans("VATToCollect")."".$langs->trans("TotalToPay")." 
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("FeatureNotYetAvailable").'
'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'".price($x_coll)."".price($x_paye)."".price($diff)." 
'.$langs->trans("SubTotal").':'.price($subtotalcoll).''.price($subtotalpaye).''.price($subtotal).' 
'.$langs->trans("TotalToPay").':'.price($total).' 
'.$langs->trans("FeatureNotYetAvailable").'
'.$langs->trans("FeatureIsSupportedInInOutModeOnly").'
'; echo '
 '; /* * Payed */ $sql = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as f"; $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.datev >= '".$db->idate(dol_get_first_day($y,1,false))."'"; $sql.= " AND f.datev <= '".$db->idate(dol_get_last_day($y,12,false))."'"; $sql.= " GROUP BY dm ASC"; pt($db, $sql,$langs->trans("Year")." $y"); print "
"; echo ''; echo ''; $db->close(); llxFooter('$Date: 2011/08/03 00:46:24 $ - $Revision: 1.43 $'); ?>