34require
'../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/paymentvat.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/paymentsocialcontribution.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
56$hookmanager->initHooks(array(
'specialexpensesindex'));
59$langs->loadLangs(array(
'compta',
'bills'));
63 $socid = $user->socid;
65$result =
restrictedArea($user,
'tax|salaries',
'',
'',
'charges|');
67$mode =
GETPOST(
"mode",
'alpha');
69$filtre =
GETPOST(
"filtre",
'alpha');
71 $year = date(
"Y", time());
73$optioncss =
GETPOST(
'optioncss',
'aZ');
76$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
77$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
79if (empty($page) || $page == -1) {
82$offset = $limit * $page;
86 $sortfield =
"cs.date_ech";
97$tva_static =
new Tva($db);
101$sal_static =
new Salary($db);
102$accountstatic =
new Account($db);
104llxHeader(
'', $langs->trans(
"SpecialExpensesArea"));
106$title = $langs->trans(
"SpecialExpensesArea");
109if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
110 $param .=
'&contextpage='.$contextpage;
112if ($limit > 0 && $limit !=
$conf->liste_limit) {
113 $param .=
'&limit='.$limit;
116 $param .=
'&sortfield='.$sortfield;
119 $param .=
'&sortorder='.$sortorder;
125print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
126if ($optioncss !=
'') {
127 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
129print
'<input type="hidden" name="token" value="'.newToken().
'">';
130print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
131print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
132print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
133print
'<input type="hidden" name="page" value="'.$page.
'">';
134print
'<input type="hidden" name="mode" value="'.$mode.
'">';
136$nav = ($year ?
'<a href="index.php?year='.($year - 1).$param.
'">'.
img_previous($langs->trans(
"Previous"),
'class="valignbottom"').
"</a> ".$langs->trans(
"Year").
' '.$year.
' <a href="index.php?year='.($year + 1).$param.
'">'.
img_next($langs->trans(
"Next"),
'class="valignbottom"').
"</a>" :
"");
138print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $totalnboflines,
'object_payment', 0, $nav,
'', $limit, 1);
141 $param .=
'&year='.$year;
144print
'<span class="opacitymedium">'.$langs->trans(
"DescTaxAndDividendsArea").
'</span><br>';
147if (isModEnabled(
'tax') && $user->hasRight(
'tax',
'charges',
'lire')) {
148 $sql =
"SELECT c.id, c.libelle as label,";
149 $sql .=
" cs.rowid, cs.libelle, cs.fk_type as type, cs.periode as period, cs.date_ech, cs.amount as total,";
150 $sql .=
" pc.rowid as pid, pc.datep, pc.amount as totalpaid, pc.num_paiement as num_payment, pc.fk_bank,";
151 $sql .=
" pct.code as payment_code,";
152 $sql .=
" ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
153 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_chargesociales as c,";
154 $sql .=
" ".MAIN_DB_PREFIX.
"chargesociales as cs";
155 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiementcharge as pc ON pc.fk_charge = cs.rowid";
156 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as pct ON pc.fk_typepaiement = pct.id";
157 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON pc.fk_bank = b.rowid";
158 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_account as ba ON b.fk_account = ba.rowid";
159 $sql .=
" WHERE cs.fk_type = c.id";
160 $sql .=
" AND cs.entity IN (".getEntity(
"tax").
")";
169 if (preg_match(
'/^(cs?|pct?)\./', (
string) $sortfield)) {
170 $sql .= $db->order($sortfield, $sortorder);
175 dol_syslog(
"compta/charges/index.php: select payment", LOG_DEBUG);
176 $resql = $db->query($sql);
178 $num = $db->num_rows($resql);
182 print
load_fiche_titre($langs->trans(
"SocialContributions").($year ?
' ('.$langs->trans(
"Year").
' '.$year.
')' :
''),
'',
'');
184 print
'<table class="noborder centpercent">';
185 print
'<tr class="liste_titre">';
186 print_liste_field_titre(
"PeriodEndDate", $_SERVER[
"PHP_SELF"],
"cs.date_ech",
"", $param,
'width="120"', $sortfield, $sortorder,
'nowraponall ');
189 print_liste_field_titre(
"ExpectedToPay", $_SERVER[
"PHP_SELF"],
"cs.amount",
"", $param,
'class="right"', $sortfield, $sortorder);
190 print_liste_field_titre(
"RefPayment", $_SERVER[
"PHP_SELF"],
"pc.rowid",
"", $param,
'', $sortfield, $sortorder);
191 print_liste_field_titre(
"DatePayment", $_SERVER[
"PHP_SELF"],
"pc.datep",
"", $param,
'align="center"', $sortfield, $sortorder);
192 print_liste_field_titre(
"PaymentMode", $_SERVER[
"PHP_SELF"],
"pct.code",
"", $param,
'', $sortfield, $sortorder);
193 if (isModEnabled(
"bank")) {
194 print_liste_field_titre(
"BankAccount", $_SERVER[
"PHP_SELF"],
"ba.label",
"", $param,
"", $sortfield, $sortorder);
196 print_liste_field_titre(
"PayedByThisPayment", $_SERVER[
"PHP_SELF"],
"pc.amount",
"", $param,
'class="right"', $sortfield, $sortorder);
206 while ($i < $imaxinloop) {
207 $obj = $db->fetch_object($resql);
209 print
'<tr class="oddeven">';
211 $date = $obj->period;
213 $date = $obj->date_ech;
215 print
'<td>'.dol_print_date($date,
'day').
'</td>';
218 $socialcontrib->id = $obj->rowid;
219 $socialcontrib->ref = $obj->label;
220 $socialcontrib->label = $obj->label;
221 print $socialcontrib->getNomUrl(1,
'20');
224 print
'<td class="tdoverflowmax200"><a href="'.DOL_URL_ROOT.
'/compta/sociales/list.php?filtre=cs.fk_type:'.$obj->type.
'">'.$obj->label.
'</a></td>';
226 print
'<td class="right"><span class="amount">'.price($obj->total).
'</span></td>';
228 $payment_sc_static->id = $obj->pid;
229 $payment_sc_static->ref = $obj->pid;
230 print
'<td>'.$payment_sc_static->getNomUrl(1).
"</td>\n";
232 print
'<td class="center">'.dol_print_date($db->jdate($obj->datep),
'day').
'</td>';
236 if ($obj->payment_code) {
237 $s .= $langs->trans(
"PaymentTypeShort".$obj->payment_code).
' ';
239 $s .= $obj->num_payment;
240 print
'<td class="tdoverflowmax125" title="'.dolPrintHTMLForAttribute($s).
'">';
245 if (isModEnabled(
"bank")) {
247 if ($obj->fk_bank > 0) {
249 $accountstatic->id = $obj->bid;
250 $accountstatic->ref = $obj->bref;
251 $accountstatic->number = $obj->bnumber;
252 $accountstatic->account_number = $obj->account_number;
253 $accountstatic->fk_accountancy_journal = $obj->fk_accountancy_journal;
254 $accountstatic->label = $obj->blabel;
256 print $accountstatic->getNomUrl(1);
263 print
'<td class="right">';
264 if ($obj->totalpaid) {
265 print
price($obj->totalpaid);
270 $total += $obj->total;
271 $totalpaid += $obj->totalpaid;
274 print
'<tr class="liste_total">';
276 print
'<td colspan="3" class="liste_total">'.$langs->trans(
"Total").
'</td>';
280 print
'<td class="liste_total right"></td>';
282 print
'<td class="liste_total center"> </td>';
283 print
'<td class="liste_total center"> </td>';
284 print
'<td class="liste_total center"> </td>';
285 if (isModEnabled(
"bank")) {
286 print
'<td class="liste_total center"></td>';
288 print
'<td class="liste_total right">'.price($totalpaid).
"</td>";
298if (isModEnabled(
'tax') && $user->hasRight(
'tax',
'charges',
'lire')) {
299 $sql =
"SELECT ptva.rowid, pv.rowid as id_tva, pv.amount as amount_tva, ptva.amount, pv.label, pv.datev as dm, ptva.datep as date_payment, ptva.fk_bank, ptva.num_paiement as num_payment,";
300 $sql .=
" pct.code as payment_code,";
301 $sql .=
" ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
302 $sql .=
" FROM ".MAIN_DB_PREFIX.
"tva as pv";
303 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"payment_vat as ptva ON ptva.fk_tva = pv.rowid";
304 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON (ptva.fk_bank = b.rowid)";
305 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_account as ba ON b.fk_account = ba.rowid";
306 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as pct ON ptva.fk_typepaiement = pct.id";
307 $sql .=
" WHERE pv.entity IN (".getEntity(
"tax").
")";
313 if (preg_match(
'/^(pv|ptva)\./', (
string) $sortfield)) {
314 $sql .= $db->order($sortfield, $sortorder);
317 $result = $db->query($sql);
319 $num = $db->num_rows($result);
327 $labeltax = $langs->transcountry(
"VAT", $mysoc->country_code);
329 print
load_fiche_titre($labeltax.($year ?
' ('.$langs->trans(
"Year").
' '.$year.
')' :
''),
'',
'');
331 print
'<table class="noborder centpercent">';
332 print
'<tr class="liste_titre">';
333 print_liste_field_titre(
"PeriodEndDate", $_SERVER[
"PHP_SELF"],
"pv.datev",
"", $param,
'width="120"', $sortfield, $sortorder,
'nowraponall ');
335 print_liste_field_titre(
"ExpectedToPay", $_SERVER[
"PHP_SELF"],
"pv.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
336 print_liste_field_titre(
"RefPayment", $_SERVER[
"PHP_SELF"],
"ptva.rowid",
"", $param,
'', $sortfield, $sortorder);
337 print_liste_field_titre(
"DatePayment", $_SERVER[
"PHP_SELF"],
"ptva.datep",
"", $param,
'', $sortfield, $sortorder,
'center ');
338 print_liste_field_titre(
"PaymentMode", $_SERVER[
"PHP_SELF"],
"pct.code",
"", $param,
'', $sortfield, $sortorder);
339 if (isModEnabled(
"bank")) {
340 print_liste_field_titre(
"BankAccount", $_SERVER[
"PHP_SELF"],
"ba.label",
"", $param,
"", $sortfield, $sortorder);
342 print_liste_field_titre(
"PayedByThisPayment", $_SERVER[
"PHP_SELF"],
"ptva.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
348 while ($i < $imaxinloop) {
349 $obj = $db->fetch_object($result);
351 $totaltopay += $obj->amount_tva;
352 $total += $obj->amount;
354 print
'<tr class="oddeven">';
356 print
'<td class="left">'.dol_print_date($db->jdate($obj->dm),
'day').
'</td>'.
"\n";
358 $tva_static->id = $obj->id_tva;
359 $tva_static->ref = $obj->label;
360 print
"<td>".$tva_static->getNomUrl(1).
"</td>\n";
362 print
'<td class="right"><span class="amount">'.price($obj->amount_tva).
"</span></td>";
365 $ptva_static->id = $obj->rowid;
366 $ptva_static->ref = $obj->rowid;
367 print
'<td>'.$ptva_static->getNomUrl(1).
"</td>\n";
370 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_payment),
'day').
"</td>\n";
374 if ($obj->payment_code) {
375 $s .= $langs->trans(
"PaymentTypeShort".$obj->payment_code).
' ';
377 $s .= $obj->num_payment;
378 print
'<td class="tdoverflowmax125" title="'.dolPrintHTMLForAttribute($s).
'">';
383 if (isModEnabled(
"bank")) {
385 if ($obj->fk_bank > 0) {
387 $accountstatic->id = $obj->bid;
388 $accountstatic->ref = $obj->bref;
389 $accountstatic->number = $obj->bnumber;
390 $accountstatic->account_number = $obj->account_number;
391 $accountstatic->fk_accountancy_journal = $obj->fk_accountancy_journal;
392 $accountstatic->label = $obj->blabel;
394 print $accountstatic->getNomUrl(1);
402 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>";
409 print
'<tr class="liste_total">';
411 print
'<td class="liste_total" colspan="2">'.$langs->trans(
"Total").
'</td>';
415 print
'<td class="liste_total"> </td>';
417 print
'<td class="liste_total"></td>';
418 print
'<td class="liste_total"></td>';
419 print
'<td class="liste_total"></td>';
421 if (isModEnabled(
"bank")) {
422 print
'<td class="liste_total"></td>';
425 print
'<td class="liste_total right">'.price($total).
"</td>";
438if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
441} elseif ($mysoc->localtax1_assuj ==
"1") {
444} elseif ($mysoc->localtax2_assuj ==
"1") {
455 $labeltax = $langs->transcountry(($j == 1 ?
"LT1" :
"LT2"), $mysoc->country_code);
457 print
load_fiche_titre($labeltax.($year ?
' ('.$langs->trans(
"Year").
' '.$year.
')' :
''),
'',
'');
460 $sql =
"SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp";
461 $sql .=
" FROM ".MAIN_DB_PREFIX.
"localtax as pv";
462 $sql .=
" WHERE pv.entity = ".$conf->entity.
" AND localtaxtype = ".((int) $j);
468 if (preg_match(
'/^pv/', (
string) $sortfield)) {
469 $sql .= $db->order($sortfield, $sortorder);
472 $result = $db->query($sql);
474 $num = $db->num_rows($result);
478 print
'<div class="div-table-responsive-no-min">';
479 print
'<table class="noborder centpercent">';
480 print
'<tr class="liste_titre">';
481 print_liste_field_titre(
"PeriodEndDate", $_SERVER[
"PHP_SELF"],
"pv.datev",
"", $param,
'width="120"', $sortfield, $sortorder);
483 print_liste_field_titre(
"ExpectedToPay", $_SERVER[
"PHP_SELF"],
"pv.amount",
"", $param,
'class="right"', $sortfield, $sortorder);
484 print_liste_field_titre(
"RefPayment", $_SERVER[
"PHP_SELF"],
"pv.rowid",
"", $param,
'', $sortfield, $sortorder);
485 print_liste_field_titre(
"DatePayment", $_SERVER[
"PHP_SELF"],
"pv.datep",
"", $param,
'align="center"', $sortfield, $sortorder);
486 print_liste_field_titre(
"PayedByThisPayment", $_SERVER[
"PHP_SELF"],
"pv.amount",
"", $param,
'class="right"', $sortfield, $sortorder);
490 $obj = $db->fetch_object($result);
492 $total += $obj->amount;
494 print
'<tr class="oddeven">';
495 print
'<td class="left">'.dol_print_date($db->jdate($obj->dm),
'day').
'</td>'.
"\n";
497 print
"<td>".$obj->label.
"</td>\n";
499 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>";
502 $ptva_static->id = $obj->rowid;
503 $ptva_static->ref = $obj->rowid;
504 print
'<td class="left">'.$ptva_static->getNomUrl(1).
"</td>\n";
506 print
'<td class="center">'.dol_print_date($db->jdate($obj->dp),
'day').
"</td>\n";
507 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>";
512 print
'<tr class="liste_total"><td colspan="2">'.$langs->trans(
"Total").
'</td>';
513 print
'<td class="right">'.price($total).
"</td>";
514 print
'<td align="center"> </td>';
515 print
'<td align="center"> </td>';
516 print
'<td class="right">'.price($total).
"</td>";
532$parameters = array(
'user' => $user);
533$reshook = $hookmanager->executeHooks(
'dashboardSpecialBills', $parameters, $object);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage bank accounts.
Class for managing the social charges.
Class to manage payments of social contributions.
Class to manage payments of social contributions.
Class to manage salary payments.
Class to manage VAT - Value-added tax (also known in French as TVA - Taxe sur la valeur ajoutée)
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_previous($titlealt='default', $moreatt='')
Show previous logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_next($titlealt='default', $moreatt='')
Show next logo.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.