Fix: pgsql compatibility
This commit is contained in:
parent
0ffc86fe02
commit
4e1d689bf8
@ -20,10 +20,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/tva/clients.php
|
||||
* \file htdocs/compta/tva/clients.php
|
||||
* \ingroup tax
|
||||
* \brief Page des societes
|
||||
* \version $Id$
|
||||
* \brief Page des societes
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require('../../main.inc.php');
|
||||
@ -41,31 +41,31 @@ $langs->load("products");
|
||||
$year=$_REQUEST["year"];
|
||||
if (empty($year))
|
||||
{
|
||||
$year_current = strftime("%Y",dol_now());
|
||||
$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(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); }
|
||||
$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
|
||||
// TODO We define q
|
||||
|
||||
}
|
||||
|
||||
@ -89,11 +89,16 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
|
||||
*/
|
||||
|
||||
$html=new Form($db);
|
||||
|
||||
llxHeader();
|
||||
|
||||
$company_static=new Societe($db);
|
||||
|
||||
$morequerystring='';
|
||||
$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday');
|
||||
foreach($listofparams as $param)
|
||||
{
|
||||
if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param);
|
||||
}
|
||||
|
||||
llxHeader('','','','',0,0,'','',$morequerystring);
|
||||
|
||||
$fsearch.='<br>';
|
||||
$fsearch.=' <input type="hidden" name="year" value="'.$year.'">';
|
||||
@ -102,7 +107,7 @@ $fsearch.=' '.$langs->trans("SalesTurnover").' '.$langs->trans("Minimum").': ';
|
||||
$fsearch.=' <input type="text" name="min" value="'.$min.'">';
|
||||
|
||||
// Affiche en-tete du rapport
|
||||
if ($modetax==1) // Calculate on invoice for goods and services
|
||||
if ($modetax==1) // Calculate on invoice for goods and services
|
||||
{
|
||||
$nom=$langs->trans("VATReportByCustomersInDueDebtMode");
|
||||
//$nom.='<br>('.$langs->trans("SeeVATReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modetax=0">','</a>').')';
|
||||
@ -110,21 +115,21 @@ if ($modetax==1) // Calculate on invoice for goods and services
|
||||
//$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modetax=".$modetax."'>".img_next()."</a>":"");
|
||||
$description=$langs->trans("RulesVATDue");
|
||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
$description.=$fsearch;
|
||||
$description.=$fsearch;
|
||||
$description.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
$builddate=time();
|
||||
$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").')';
|
||||
$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
|
||||
if ($modetax==0) // Invoice for goods, payment for services
|
||||
{
|
||||
$nom=$langs->trans("VATReportByCustomersInInputOutputMode");
|
||||
//$nom.='<br>('.$langs->trans("SeeVATReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modetax=1">','</a>').')';
|
||||
@ -132,19 +137,19 @@ if ($modetax==0) // Invoice for goods, payment for services
|
||||
//$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start-1)."&modetax=".$modetax."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+1)."&modetax=".$modetax."'>".img_next()."</a>":"");
|
||||
$description=$langs->trans("RulesVATIn");
|
||||
//if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='<br>'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite');
|
||||
$description.=$fsearch;
|
||||
$description.=$fsearch;
|
||||
$description.='<br>('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
|
||||
$builddate=time();
|
||||
$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").')';
|
||||
$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);
|
||||
|
||||
@ -169,54 +174,54 @@ print "</tr>\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 "<tr $bc[$var]>";
|
||||
print "<td nowrap>".$i."</td>";
|
||||
$company_static->id=$coll[5];
|
||||
$company_static->nom=$coll[0];
|
||||
print '<td nowrap>'.$company_static->getNomUrl(1).'</td>';
|
||||
$find = array(' ','.');
|
||||
$replace = array('','');
|
||||
print "<td nowrap>".$intra."</td>";
|
||||
print "<td nowrap align=\"right\">".price($coll[2])."</td>";
|
||||
print "<td nowrap align=\"right\">".price($coll[3])."</td>";
|
||||
$total = $total + $coll[3];
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$var=true;
|
||||
$total = 0; $subtotal = 0;
|
||||
$i = 1;
|
||||
foreach($coll_list as $coll)
|
||||
{
|
||||
if($min == 0 or ($min > 0 && $coll->amount > $min))
|
||||
{
|
||||
$var=!$var;
|
||||
$intra = str_replace($find,$replace,$coll->tva_intra);
|
||||
if(empty($intra))
|
||||
{
|
||||
if($coll->assuj == '1')
|
||||
{
|
||||
$intra = $langs->trans('Unknown');
|
||||
}
|
||||
else
|
||||
{
|
||||
$intra = $langs->trans('NotRegistered');
|
||||
}
|
||||
}
|
||||
print "<tr $bc[$var]>";
|
||||
print "<td nowrap>".$i."</td>";
|
||||
$company_static->id=$coll->socid;
|
||||
$company_static->nom=$coll->nom;
|
||||
print '<td nowrap>'.$company_static->getNomUrl(1).'</td>';
|
||||
$find = array(' ','.');
|
||||
$replace = array('','');
|
||||
print "<td nowrap>".$intra."</td>";
|
||||
print "<td nowrap align=\"right\">".price($coll->amount)."</td>";
|
||||
print "<td nowrap align=\"right\">".price($coll->tva)."</td>";
|
||||
$total = $total + $coll->tva;
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
print '<tr class="liste_total"><td align="right" colspan="4">'.$langs->trans("Total").':</td><td nowrap align="right"><b>'.price($total).'</b></td>';
|
||||
print '</tr>';
|
||||
print '<tr class="liste_total"><td align="right" colspan="4">'.$langs->trans("Total").':</td><td nowrap align="right"><b>'.price($total).'</b></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
if ($coll_list == -1)
|
||||
print '<tr><td colspan="5">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
|
||||
else if ($coll_list == -2)
|
||||
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
|
||||
else
|
||||
print '<tr><td colspan="5">'.$langs->trans("Error").'</td></tr>';
|
||||
$langs->load("errors");
|
||||
if ($coll_list == -1)
|
||||
print '<tr><td colspan="5">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
|
||||
else if ($coll_list == -2)
|
||||
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
|
||||
else
|
||||
print '<tr><td colspan="5">'.$langs->trans("Error").'</td></tr>';
|
||||
}
|
||||
|
||||
//print '</table>';
|
||||
@ -241,54 +246,54 @@ $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 "<tr $bc[$var]>";
|
||||
print "<td nowrap>".$i."</td>";
|
||||
$company_static->id=$coll[5];
|
||||
$company_static->nom=$coll[0];
|
||||
print '<td nowrap>'.$company_static->getNomUrl(1).'</td>';
|
||||
$find = array(' ','.');
|
||||
$replace = array('','');
|
||||
print "<td nowrap>".$intra."</td>";
|
||||
print "<td nowrap align=\"right\">".price($coll[2])."</td>";
|
||||
print "<td nowrap align=\"right\">".price($coll[3])."</td>";
|
||||
$total = $total + $coll[3];
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$var=true;
|
||||
$total = 0; $subtotal = 0;
|
||||
$i = 1;
|
||||
foreach($coll_list as $coll)
|
||||
{
|
||||
if($min == 0 or ($min > 0 && $coll->amount > $min))
|
||||
{
|
||||
$var=!$var;
|
||||
$intra = str_replace($find,$replace,$coll->tva_intra);
|
||||
if(empty($intra))
|
||||
{
|
||||
if($coll->assuj == '1')
|
||||
{
|
||||
$intra = $langs->trans('Unknown');
|
||||
}
|
||||
else
|
||||
{
|
||||
$intra = $langs->trans('NotRegistered');
|
||||
}
|
||||
}
|
||||
print "<tr $bc[$var]>";
|
||||
print "<td nowrap>".$i."</td>";
|
||||
$company_static->id=$coll->socid;
|
||||
$company_static->nom=$coll->nom;
|
||||
print '<td nowrap>'.$company_static->getNomUrl(1).'</td>';
|
||||
$find = array(' ','.');
|
||||
$replace = array('','');
|
||||
print "<td nowrap>".$intra."</td>";
|
||||
print "<td nowrap align=\"right\">".price($coll->amount)."</td>";
|
||||
print "<td nowrap align=\"right\">".price($coll->tva)."</td>";
|
||||
$total = $total + $coll->tva;
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
print '<tr class="liste_total"><td align="right" colspan="4">'.$langs->trans("Total").':</td><td nowrap align="right"><b>'.price($total).'</b></td>';
|
||||
print '</tr>';
|
||||
print '<tr class="liste_total"><td align="right" colspan="4">'.$langs->trans("Total").':</td><td nowrap align="right"><b>'.price($total).'</b></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
if ($coll_list == -1)
|
||||
print '<tr><td colspan="5">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
|
||||
else if ($coll_list == -2)
|
||||
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
|
||||
else
|
||||
print '<tr><td colspan="5">'.$langs->trans("Error").'</td></tr>';
|
||||
$langs->load("errors");
|
||||
if ($coll_list == -1)
|
||||
print '<tr><td colspan="5">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
|
||||
else if ($coll_list == -2)
|
||||
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
|
||||
else
|
||||
print '<tr><td colspan="5">'.$langs->trans("Error").'</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
@ -148,7 +148,7 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
while($assoc = $db->fetch_array($resql))
|
||||
while($assoc = $db->fetch_object($resql))
|
||||
{
|
||||
$list[] = $assoc;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user