* Copyright (C) 2004 Eric Seigne * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2006 Yannick Warnier * * 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, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * \file htdocs/compta/tva/clients.php * \ingroup tax * \brief Page des societes * \version $Id$ */ require('../../main.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/class/tva.class.php"); $langs->load("bills"); $langs->load("compta"); $langs->load("companies"); $langs->load("products"); // Date range $year=$_REQUEST["year"]; if (empty($year)) { $year_current = strftime("%Y",dol_now()); $year_start = $year_current; } else { $year_current = $year; $year_start = $year; } $date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); $date_end=dol_mktime(23,59,59,$_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"]:0; if ($q==0) { if (isset($_REQUEST["month"])) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"],false); $date_end=dol_get_last_day($year_start,$_REQUEST["month"],false); } else $q=1; } if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } } 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($_REQUEST["modetax"])) $modetax=$_REQUEST["modetax"]; // Security check $socid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:''; if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); /* * View */ $html=new Form($db); llxHeader(); $company_static=new Societe($db); $fsearch.='
'; $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("VATReportByCustomersInDueDebtMode"); //$nom.='
('.$langs->trans("SeeVATReportInInputOutputMode",'','').')'; $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; $description.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; $builddate=time(); $exportlink=$langs->trans("NotYetAvailable"); $elementcust=$langs->trans("CustomersInvoices"); $productcust=$langs->trans("Description"); $amountcust=$langs->trans("AmountHT"); if ($mysoc->tva_assuj) $vatcust.=' ('.$langs->trans("ToPay").')'; $elementsup=$langs->trans("SuppliersInvoices"); $productsup=$langs->trans("Description"); $amountsup=$langs->trans("AmountHT"); if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')'; } if ($modetax==0) // Invoice for goods, payment for services { $nom=$langs->trans("VATReportByCustomersInInputOutputMode"); //$nom.='
('.$langs->trans("SeeVATReportInDueDebtMode",'','').')'; $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; $description.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; $builddate=time(); $exportlink=$langs->trans("NotYetAvailable"); $elementcust=$langs->trans("CustomersInvoices"); $productcust=$langs->trans("Description"); $amountcust=$langs->trans("AmountHT"); if ($mysoc->tva_assuj) $vatcust.=' ('.$langs->trans("ToPay").')'; $elementsup=$langs->trans("SuppliersInvoices"); $productsup=$langs->trans("Description"); $amountsup=$langs->trans("AmountHT"); if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')'; } report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportlink); $vatcust=$langs->trans("VATReceived"); $vatsup=$langs->trans("VATPaid"); // VAT Received //print "
"; //print_titre($vatcust); print ""; print ""; print '"; print '"; print ""; print ""; print ""; print "\n"; $coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell'); if (is_array($coll_list)) { $var=true; $total = 0; $subtotal = 0; $i = 1; foreach($coll_list as $coll) { if($min == 0 or ($min>0 and $coll[2]>$min)) { $var=!$var; $intra = str_replace($find,$replace,$coll[1]); if(empty($intra)) { if($coll[4] == '1') { $intra = $langs->trans('Unknown'); } else { $intra = $langs->trans('NotRegistered'); } } print ""; print ""; $company_static->id=$coll[5]; $company_static->nom=$coll[0]; print ''; $find = array(' ','.'); $replace = array('',''); print ""; print ""; print ""; $total = $total + $coll[3]; print "\n"; $i++; } } print ''; print ''; } else { $langs->load("errors"); if ($coll_list == -1) print ''; else if ($coll_list == -2) print ''; else print ''; } //print '
'.$langs->trans("Num")."'.$langs->trans("Customer")."".$langs->trans("VATIntra")."".$langs->trans("SalesTurnover")." ".$langs->trans("HT")."".$vatcust."
".$i."'.$company_static->getNomUrl(1).'".$intra."".price($coll[2])."".price($coll[3])."
'.$langs->trans("Total").':'.price($total).'
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("FeatureNotYetAvailable").'
'.$langs->trans("Error").'
'; // VAT Paid //print "
"; //print_titre($vatsup); //print ""; print ""; print '"; print '"; print ""; print ""; print ""; print "\n"; $company_static=new Societe($db); $coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy'); if (is_array($coll_list)) { $var=true; $total = 0; $subtotal = 0; $i = 1; foreach($coll_list as $coll) { if($min == 0 or ($min>0 and $coll[2]>$min)) { $var=!$var; $intra = str_replace($find,$replace,$coll[1]); if(empty($intra)) { if($coll[4] == '1') { $intra = $langs->trans('Unknown'); } else { $intra = $langs->trans('NotRegistered'); } } print ""; print ""; $company_static->id=$coll[5]; $company_static->nom=$coll[0]; print ''; $find = array(' ','.'); $replace = array('',''); print ""; print ""; print ""; $total = $total + $coll[3]; print "\n"; $i++; } } print ''; print ''; } else { $langs->load("errors"); if ($coll_list == -1) print ''; else if ($coll_list == -2) print ''; else print ''; } print '
'.$langs->trans("Num")."'.$langs->trans("Supplier")."".$langs->trans("VATIntra")."".$langs->trans("Outcome")." ".$langs->trans("HT")."".$vatsup."
".$i."'.$company_static->getNomUrl(1).'".$intra."".price($coll[2])."".price($coll[3])."
'.$langs->trans("Total").':'.price($total).'
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("FeatureNotYetAvailable").'
'.$langs->trans("Error").'
'; $db->close(); llxFooter('$Date$ - $Revision$'); ?>