diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 105bfcb2bf6..618ba11a37e 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -83,7 +83,7 @@ function pt ($db, $sql, $date) while ($i < $num) { $obj = $db->fetch_object($result); - + print ''; print ''.$obj->dm."\n"; $total = $total + $obj->mm; @@ -147,14 +147,14 @@ 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); - + $action = "tva"; $object = array(&$coll_listsell, &$coll_listbuy); $parameters["mode"] = $modetax; $parameters["year"] = $y; $parameters["month"] = $m; $parameters["type"] = 'vat'; - + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('externalbalance')); $reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -171,7 +171,7 @@ for ($m = 1 ; $m < 13 ; $m++ ) break; } - + print ''; print ''.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").''; @@ -220,22 +220,67 @@ print ''; print '
'; + print load_fiche_titre($langs->trans("VATPaid"), '', ''); /* * Payed */ -$sql = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm"; +$sql = "SELECT SUM(amount) as mm, date_format(f.datep,'%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.= " AND f.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'"; +$sql.= " AND f.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'"; $sql.= " GROUP BY dm ORDER BY dm ASC"; pt($db, $sql,$langs->trans("Year")." $y"); +print '
'; + + + +if (! empty($conf->global->MAIN_FEATURES_LEVEL)) +{ + /* + * Recap + */ + + print load_fiche_titre($langs->trans("VATRecap"), '', ''); // need to add translation + + $sql1 = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y') as dm"; + $sql1 .= " FROM " . MAIN_DB_PREFIX . "tva as f"; + $sql1 .= " WHERE f.entity = " . $conf->entity; + $sql1 .= " AND f.datev >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; + $sql1 .= " AND f.datev <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + $sql1 .= " GROUP BY dm ORDER BY dm ASC"; + + $result = $db->query($sql1); + if ($result) { + $obj = $db->fetch_object($result); + print ''; + + print ""; + print ''; // need to add translation + print ''; + print "\n"; + + print ""; + print ''; + print '\n"; + print "\n"; + + $restopay = $total - $obj->mm; + print ""; + print ''; // need to add translation + print ''; + print "\n"; + + print '
' . $langs->trans("VATDue") . '' . price(price2num($total, 1)) . '
' . $langs->trans("VATPaid") . '' . price(price2num($obj->mm, 1)) . "
' . $langs->trans("VATRestopay") . '' . price(price2num($restopay, 1)) . '
'; + } +} + print '
'; llxFooter();