27 require
'../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/tax.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/compta/localtax/class/localtax.class.php';
35 $langs->loadLangs(array(
"other",
"compta",
"banks",
"bills",
"companies",
"product",
"trips",
"admin"));
37 $local =
GETPOST(
'localTaxType',
'int');
43 $year_start = $year_current;
45 $year_current = $year;
51 if (empty($date_start) || empty($date_end)) {
58 $date_start =
dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START,
false);
59 if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) {
61 } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) {
63 } elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) {
94 $modetax = $conf->global->TAX_MODE;
96 $modetax =
GETPOST(
"modetax",
'int');
98 if (empty($modetax)) {
103 $socid =
GETPOST(
'socid',
'int');
105 $socid = $user->socid;
121 $company_static =
new Societe($db);
123 $morequerystring =
'';
124 $listofparams = array(
'date_startmonth',
'date_startyear',
'date_startday',
'date_endmonth',
'date_endyear',
'date_endday');
125 foreach ($listofparams as $param) {
127 $morequerystring .= ($morequerystring ?
'&' :
'').$param.
'='.
GETPOST($param);
131 llxHeader(
'',
'',
'',
'', 0, 0,
'',
'', $morequerystring);
134 $name = $langs->transcountry($local == 1 ?
"LT1ReportByCustomers" :
"LT2ReportByCustomers", $mysoc->country_code);
136 $fsearch =
'<!-- hidden fields for form -->';
137 $fsearch .=
'<input type="hidden" name="token" value="'.newToken().
'">';
138 $fsearch .=
'<input type="hidden" name="modetax" value="'.$modetax.
'">';
139 $fsearch .=
'<input type="hidden" name="localTaxType" value="'.$local.
'">';
140 $fsearch .= $langs->trans(
"SalesTurnoverMinimum").
': ';
141 $fsearch .=
'<input type="text" name="min" id="min" value="'.$min.
'" size="6">';
143 $calc = $conf->global->MAIN_INFO_LOCALTAX_CALC.$local;
145 if ($calc == 0 || $calc == 1) {
146 $calcmode = $calc == 0 ? $langs->trans(
"CalcModeLT".$local) : $langs->trans(
"CalcModeLT".$local.
"Rec");
147 $calcmode .=
' <span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.
'/admin/company.php').
')</span>';
148 $period =
$form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0).
' - '.
$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0);
149 if (!empty($conf->global->MAIN_MODULE_COMPTABILITE)) {
150 $description .=
'<br>'.$langs->trans(
"WarningDepositsNotIncluded");
152 $description .= $fsearch;
153 $description .=
' <span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.
'/admin/company.php').
')</span>';
156 $elementcust = $langs->trans(
"CustomersInvoices");
157 $productcust = $langs->trans(
"Description");
158 $amountcust = $langs->trans(
"AmountHT");
159 $elementsup = $langs->trans(
"SuppliersInvoices");
160 $productsup = $langs->trans(
"Description");
161 $amountsup = $langs->trans(
"AmountHT");
164 $calcmode = $langs->trans(
"CalcModeLT2Debt");
165 $calcmode .=
' <span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.
'/admin/company.php').
')</span>';
166 $period =
$form->selectDate($date_start,
'date_start', 0, 0, 0,
'', 1, 0).
' - '.
$form->selectDate($date_end,
'date_end', 0, 0, 0,
'', 1, 0);
167 if (!empty($conf->global->MAIN_MODULE_COMPTABILITE)) {
168 $description .=
'<br>'.$langs->trans(
"WarningDepositsNotIncluded");
170 $description .= $fsearch;
171 $description .=
'<span class="opacitymedium">('.$langs->trans(
"TaxModuleSetupToModifyRulesLT", DOL_URL_ROOT.
'/admin/company.php').
')</span>';
174 $elementcust = $langs->trans(
"CustomersInvoices");
175 $productcust = $langs->trans(
"Description");
176 $amountcust = $langs->trans(
"AmountHT");
177 $elementsup = $langs->trans(
"SuppliersInvoices");
178 $productsup = $langs->trans(
"Description");
179 $amountsup = $langs->trans(
"AmountHT");
181 report_header($name,
'', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode);
184 $vatcust = $langs->transcountry($local == 1 ?
"LT1" :
"LT2", $mysoc->country_code);
185 $vatsup = $langs->transcountry($local == 1 ?
"LT1" :
"LT2", $mysoc->country_code);
187 print
'<div class="div-table-responsive">';
188 print
'<table class="noborder centpercent">';
191 if ($calc == 0 || $calc == 2) {
192 print
'<tr class="liste_titre">';
193 print
'<td class="left">'.$langs->trans(
"Num").
'</td>';
194 print
'<td class="left">'.$langs->trans(
"Customer").
'</td>';
195 print
'<td>'.$langs->transcountry(
"ProfId1", $mysoc->country_code).
'</td>';
196 print
'<td class="right">'.$langs->trans(
"TotalHT").
'</td>';
197 print
'<td class="right">'.$vatcust.
'</td>';
200 $coll_list =
tax_by_thirdparty(
'localtax'.$local, $db, 0, $date_start, $date_end, $modetax,
'sell');
202 $action =
"tvaclient";
203 $object = &$coll_list;
204 $parameters[
"mode"] = $modetax;
205 $parameters[
"start"] = $date_start;
206 $parameters[
"end"] = $date_end;
207 $parameters[
"direction"] =
'sell';
208 $parameters[
"type"] =
'localtax'.$local;
211 $hookmanager->initHooks(array(
'externalbalance'));
212 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
214 if (is_array($coll_list)) {
218 foreach ($coll_list as $coll) {
219 if (($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local == 1 ? $coll->localtax1 : $coll->localtax2) != 0) {
220 $intra = str_replace($find, $replace, $coll->tva_intra);
222 if ($coll->assuj ==
'1') {
223 $intra = $langs->trans(
'Unknown');
228 print
'<tr class="oddeven">';
229 print
'<td class="nowrap">'.$i.
"</td>";
230 $company_static->id = $coll->socid;
231 $company_static->name = $coll->name;
232 print
'<td class="nowrap">'.$company_static->getNomUrl(1).
'</td>';
233 $find = array(
' ',
'.');
234 $replace = array(
'',
'');
235 print
'<td class="nowrap">'.$intra.
'</td>';
236 print
'<td class="nowrap right">'.price($coll->amount).
'</td>';
237 print
'<td class="nowrap right">'.price($local == 1 ? $coll->localtax1 : $coll->localtax2).
'</td>';
238 $totalamount = $totalamount + $coll->amount;
239 $total = $total + ($local == 1 ? $coll->localtax1 : $coll->localtax2);
244 $x_coll_sum = $total;
246 print
'<tr class="liste_total"><td class="right" colspan="3">'.$langs->trans(
"Total").
':</td>';
247 print
'<td class="nowrap right">'.price($totalamount).
'</td>';
248 print
'<td class="nowrap right">'.price($total).
'</td>';
251 $langs->load(
"errors");
252 if ($coll_list == -1) {
253 print
'<tr><td colspan="5">'.$langs->trans(
"ErrorNoAccountancyModuleLoaded").
'</td></tr>';
254 } elseif ($coll_list == -2) {
255 print
'<tr><td colspan="5">'.$langs->trans(
"FeatureNotYetAvailable").
'</td></tr>';
257 print
'<tr><td colspan="5">'.$langs->trans(
"Error").
'</td></tr>';
263 if ($calc == 0 || $calc == 1) {
264 print
'<tr class="liste_titre">';
265 print
'<td class="left">'.$langs->trans(
"Num").
"</td>";
266 print
'<td class="left">'.$langs->trans(
"Supplier").
"</td>";
267 print
'<td>'.$langs->transcountry(
"ProfId1", $mysoc->country_code).
'</td>';
268 print
'<td class="right">'.$langs->trans(
"TotalHT").
'</td>';
269 print
'<td class="right">'.$vatsup.
'</td>';
272 $company_static =
new Societe($db);
274 $coll_list =
tax_by_thirdparty(
'localtax'.$local, $db, 0, $date_start, $date_end, $modetax,
'buy');
275 $parameters[
"direction"] =
'buy';
276 $parameters[
"type"] =
'localtax'.$local;
278 $reshook = $hookmanager->executeHooks(
'addVatLine', $parameters, $object, $action);
279 if (is_array($coll_list)) {
283 foreach ($coll_list as $coll) {
284 if (($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local == 1 ? $coll->localtax1 : $coll->localtax2) != 0) {
285 $intra = str_replace($find, $replace, $coll->tva_intra);
287 if ($coll->assuj ==
'1') {
288 $intra = $langs->trans(
'Unknown');
293 print
'<tr class="oddeven">';
294 print
'<td class="nowrap">'.$i.
"</td>";
295 $company_static->id = $coll->socid;
296 $company_static->name = $coll->name;
297 print
'<td class="nowrap">'.$company_static->getNomUrl(1).
'</td>';
298 $find = array(
' ',
'.');
299 $replace = array(
'',
'');
300 print
'<td class="nowrap">'.$intra.
"</td>";
301 print
'<td class="nowrap right">'.price($coll->amount).
'</td>';
302 print
'<td class="nowrap right">'.price($local == 1 ? $coll->localtax1 : $coll->localtax2).
'</td>';
303 $totalamount = $totalamount + $coll->amount;
304 $total = $total + ($local == 1 ? $coll->localtax1 : $coll->localtax2);
309 $x_paye_sum = $total;
311 print
'<tr class="liste_total"><td class="right" colspan="3">'.$langs->trans(
"Total").
':</td>';
312 print
'<td class="nowrap right">'.price($totalamount).
'</td>';
313 print
'<td class="nowrap right">'.price($total).
'</td>';
316 $langs->load(
"errors");
317 if ($coll_list == -1) {
318 print
'<tr><td colspan="5">'.$langs->trans(
"ErrorNoAccountancyModuleLoaded").
'</td></tr>';
319 } elseif ($coll_list == -2) {
320 print
'<tr><td colspan="5">'.$langs->trans(
"FeatureNotYetAvailable").
'</td></tr>';
322 print
'<tr><td colspan="5">'.$langs->trans(
"Error").
'</td></tr>';
329 print
'<tr><td colspan="5"></td></tr>';
331 $diff = $x_coll_sum - $x_paye_sum;
332 print
'<tr class="liste_total">';
333 print
'<td class="liste_total" colspan="4">'.$langs->trans(
"TotalToPay").($q ?
', '.$langs->trans(
"Quadri").
' '.$q :
'').
'</td>';
334 print
'<td class="liste_total nowrap right"><b>'.price(
price2num($diff,
'MT')).
"</b></td>\n";
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage third parties objects (customers, suppliers, prospects...)
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a report.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $direction, $m=0, $q=0)
Look for collectable VAT clients in the chosen year (and month)