2
0
forked from Wavyzz/dolibarr
This commit is contained in:
Laurent Destailleur
2017-07-07 19:32:03 +02:00
parent c459d3aa7a
commit a026e1d701

View File

@@ -83,7 +83,7 @@ function pt ($db, $sql, $date)
while ($i < $num)
{
$obj = $db->fetch_object($result);
print '<tr class="oddeven">';
print '<td class="nowrap">'.$obj->dm."</td>\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 '<tr class="oddeven">';
print '<td class="nowrap"><a href="quadri_detail.php?leftmenu=tax_vat&month='.$m.'&year='.$y.'">'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'</a></td>';
@@ -220,22 +220,67 @@ print '</table>';
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
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 '<br>';
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 '<table class="noborder" width="100%">';
print "<tr>";
print '<td align="right">' . $langs->trans("VATDue") . '</td>'; // need to add translation
print '<td class="nowrap" align="right">' . price(price2num($total, 1)) . '</td>';
print "</tr>\n";
print "<tr>";
print '<td align="right">' . $langs->trans("VATPaid") . '</td>';
print '<td class="nowrap" align="right">' . price(price2num($obj->mm, 1)) . "</td>\n";
print "</tr>\n";
$restopay = $total - $obj->mm;
print "<tr>";
print '<td align="right">' . $langs->trans("VATRestopay") . '</td>'; // need to add translation
print '<td class="nowrap" align="right">' . price(price2num($restopay, 1)) . '</td>';
print "</tr>\n";
print '</table>';
}
}
print '</div></div>';
llxFooter();