33require
'../../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/paymentvat.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/paymentsocialcontribution.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
46$hookmanager->initHooks(array(
'specialexpensesindex'));
49$langs->loadLangs(array(
'compta',
'bills'));
53 $socid = $user->socid;
55$result =
restrictedArea($user,
'tax|salaries',
'',
'',
'charges|');
57$mode =
GETPOST(
"mode",
'alpha');
59$filtre =
GETPOST(
"filtre",
'alpha');
61 $year = date(
"Y", time());
63$optioncss =
GETPOST(
'optioncss',
'aZ');
66$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
67$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
69if (empty($page) || $page == -1) {
72$offset = $limit * $page;
76 $sortfield =
"cs.date_ech";
87$tva_static =
new Tva($db);
91$sal_static =
new Salary($db);
92$accountstatic =
new Account($db);
94llxHeader(
'', $langs->trans(
"SpecialExpensesArea"));
96$title = $langs->trans(
"SpecialExpensesArea");
99if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
100 $param .=
'&contextpage='.$contextpage;
102if ($limit > 0 && $limit != $conf->liste_limit) {
103 $param .=
'&limit='.$limit;
106 $param .=
'&sortfield='.$sortfield;
109 $param .=
'&sortorder='.$sortorder;
115print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
116if ($optioncss !=
'') {
117 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
119print
'<input type="hidden" name="token" value="'.newToken().
'">';
120print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
121print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
122print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
123print
'<input type="hidden" name="page" value="'.$page.
'">';
124print
'<input type="hidden" name="mode" value="'.$mode.
'">';
126$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>" :
"");
128print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $totalnboflines,
'object_payment', 0, $nav,
'', $limit, 1);
131 $param .=
'&year='.$year;
134print
'<span class="opacitymedium">'.$langs->trans(
"DescTaxAndDividendsArea").
'</span><br>';
137if (isModEnabled(
'tax') && $user->hasRight(
'tax',
'charges',
'lire')) {
138 $sql =
"SELECT c.id, c.libelle as label,";
139 $sql .=
" cs.rowid, cs.libelle, cs.fk_type as type, cs.periode as period, cs.date_ech, cs.amount as total,";
140 $sql .=
" pc.rowid as pid, pc.datep, pc.amount as totalpaid, pc.num_paiement as num_payment, pc.fk_bank,";
141 $sql .=
" pct.code as payment_code,";
142 $sql .=
" ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
143 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_chargesociales as c,";
144 $sql .=
" ".MAIN_DB_PREFIX.
"chargesociales as cs";
145 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiementcharge as pc ON pc.fk_charge = cs.rowid";
146 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as pct ON pc.fk_typepaiement = pct.id";
147 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON pc.fk_bank = b.rowid";
148 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_account as ba ON b.fk_account = ba.rowid";
149 $sql .=
" WHERE cs.fk_type = c.id";
150 $sql .=
" AND cs.entity IN (".getEntity(
"tax").
")";
159 if (preg_match(
'/^cs\./', $sortfield) || preg_match(
'/^c\./', $sortfield) || preg_match(
'/^pc\./', $sortfield) || preg_match(
'/^pct\./', $sortfield)) {
160 $sql .= $db->order($sortfield, $sortorder);
165 dol_syslog(
"compta/charges/index.php: select payment", LOG_DEBUG);
166 $resql = $db->query($sql);
168 $num = $db->num_rows($resql);
172 print
load_fiche_titre($langs->trans(
"SocialContributions").($year ?
' ('.$langs->trans(
"Year").
' '.$year.
')' :
''),
'',
'');
174 print
'<table class="noborder centpercent">';
175 print
'<tr class="liste_titre">';
176 print_liste_field_titre(
"PeriodEndDate", $_SERVER[
"PHP_SELF"],
"cs.date_ech",
"", $param,
'width="120"', $sortfield, $sortorder,
'nowraponall ');
179 print_liste_field_titre(
"ExpectedToPay", $_SERVER[
"PHP_SELF"],
"cs.amount",
"", $param,
'class="right"', $sortfield, $sortorder);
180 print_liste_field_titre(
"RefPayment", $_SERVER[
"PHP_SELF"],
"pc.rowid",
"", $param,
'', $sortfield, $sortorder);
181 print_liste_field_titre(
"DatePayment", $_SERVER[
"PHP_SELF"],
"pc.datep",
"", $param,
'align="center"', $sortfield, $sortorder);
182 print_liste_field_titre(
"PaymentMode", $_SERVER[
"PHP_SELF"],
"pct.code",
"", $param,
'', $sortfield, $sortorder);
183 if (isModEnabled(
"bank")) {
184 print_liste_field_titre(
"BankAccount", $_SERVER[
"PHP_SELF"],
"ba.label",
"", $param,
"", $sortfield, $sortorder);
186 print_liste_field_titre(
"PayedByThisPayment", $_SERVER[
"PHP_SELF"],
"pc.amount",
"", $param,
'class="right"', $sortfield, $sortorder);
196 while ($i < $imaxinloop) {
197 $obj = $db->fetch_object($resql);
199 print
'<tr class="oddeven">';
201 $date = $obj->period;
203 $date = $obj->date_ech;
205 print
'<td>'.dol_print_date($date,
'day').
'</td>';
208 $socialcontrib->id = $obj->rowid;
209 $socialcontrib->ref = $obj->label;
210 $socialcontrib->label = $obj->label;
211 print $socialcontrib->getNomUrl(1,
'20');
214 print
'<td class="tdoverflowmax200"><a href="'.DOL_URL_ROOT.
'/compta/sociales/list.php?filtre=cs.fk_type:'.$obj->type.
'">'.$obj->label.
'</a></td>';
216 print
'<td class="right"><span class="amount">'.price($obj->total).
'</span></td>';
218 $payment_sc_static->id = $obj->pid;
219 $payment_sc_static->ref = $obj->pid;
220 print
'<td>'.$payment_sc_static->getNomUrl(1).
"</td>\n";
222 print
'<td class="center">'.dol_print_date($db->jdate($obj->datep),
'day').
'</td>';
226 if ($obj->payment_code) {
227 $s .= $langs->trans(
"PaymentTypeShort".$obj->payment_code).
' ';
229 $s .= $obj->num_payment;
230 print
'<td class="tdoverflowmax125" title="'.dolPrintHTMLForAttribute($s).
'">';
235 if (isModEnabled(
"bank")) {
237 if ($obj->fk_bank > 0) {
239 $accountstatic->id = $obj->bid;
240 $accountstatic->ref = $obj->bref;
241 $accountstatic->number = $obj->bnumber;
242 $accountstatic->account_number = $obj->account_number;
243 $accountstatic->fk_accountancy_journal = $obj->fk_accountancy_journal;
244 $accountstatic->label = $obj->blabel;
246 print $accountstatic->getNomUrl(1);
253 print
'<td class="right">';
254 if ($obj->totalpaid) {
255 print
price($obj->totalpaid);
260 $total += $obj->total;
261 $totalpaid += $obj->totalpaid;
264 print
'<tr class="liste_total">';
266 print
'<td colspan="3" class="liste_total">'.$langs->trans(
"Total").
'</td>';
270 print
'<td class="liste_total right"></td>';
272 print
'<td class="liste_total center"> </td>';
273 print
'<td class="liste_total center"> </td>';
274 print
'<td class="liste_total center"> </td>';
275 if (isModEnabled(
"bank")) {
276 print
'<td class="liste_total center"></td>';
278 print
'<td class="liste_total right">'.price($totalpaid).
"</td>";
288if (isModEnabled(
'tax') && $user->hasRight(
'tax',
'charges',
'lire')) {
289 $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,";
290 $sql .=
" pct.code as payment_code,";
291 $sql .=
" ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
292 $sql .=
" FROM ".MAIN_DB_PREFIX.
"tva as pv";
293 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"payment_vat as ptva ON ptva.fk_tva = pv.rowid";
294 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON (ptva.fk_bank = b.rowid)";
295 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_account as ba ON b.fk_account = ba.rowid";
296 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as pct ON ptva.fk_typepaiement = pct.id";
297 $sql .=
" WHERE pv.entity IN (".getEntity(
"tax").
")";
303 if (preg_match(
'/^pv\./', $sortfield) || preg_match(
'/^ptva\./', $sortfield)) {
304 $sql .= $db->order($sortfield, $sortorder);
307 $result = $db->query($sql);
309 $num = $db->num_rows($result);
317 $labeltax = $langs->transcountry(
"VAT", $mysoc->country_code);
319 print
load_fiche_titre($labeltax.($year ?
' ('.$langs->trans(
"Year").
' '.$year.
')' :
''),
'',
'');
321 print
'<table class="noborder centpercent">';
322 print
'<tr class="liste_titre">';
323 print_liste_field_titre(
"PeriodEndDate", $_SERVER[
"PHP_SELF"],
"pv.datev",
"", $param,
'width="120"', $sortfield, $sortorder,
'nowraponall ');
325 print_liste_field_titre(
"ExpectedToPay", $_SERVER[
"PHP_SELF"],
"pv.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
326 print_liste_field_titre(
"RefPayment", $_SERVER[
"PHP_SELF"],
"ptva.rowid",
"", $param,
'', $sortfield, $sortorder);
327 print_liste_field_titre(
"DatePayment", $_SERVER[
"PHP_SELF"],
"ptva.datep",
"", $param,
'', $sortfield, $sortorder,
'center ');
328 print_liste_field_titre(
"PaymentMode", $_SERVER[
"PHP_SELF"],
"pct.code",
"", $param,
'', $sortfield, $sortorder);
329 if (isModEnabled(
"bank")) {
330 print_liste_field_titre(
"BankAccount", $_SERVER[
"PHP_SELF"],
"ba.label",
"", $param,
"", $sortfield, $sortorder);
332 print_liste_field_titre(
"PayedByThisPayment", $_SERVER[
"PHP_SELF"],
"ptva.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
338 while ($i < $imaxinloop) {
339 $obj = $db->fetch_object($result);
341 $totaltopay += $obj->amount_tva;
342 $total += $obj->amount;
344 print
'<tr class="oddeven">';
346 print
'<td class="left">'.dol_print_date($db->jdate($obj->dm),
'day').
'</td>'.
"\n";
348 $tva_static->id = $obj->id_tva;
349 $tva_static->ref = $obj->label;
350 print
"<td>".$tva_static->getNomUrl(1).
"</td>\n";
352 print
'<td class="right"><span class="amount">'.price($obj->amount_tva).
"</span></td>";
355 $ptva_static->id = $obj->rowid;
356 $ptva_static->ref = $obj->rowid;
357 print
'<td>'.$ptva_static->getNomUrl(1).
"</td>\n";
360 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_payment),
'day').
"</td>\n";
364 if ($obj->payment_code) {
365 $s .= $langs->trans(
"PaymentTypeShort".$obj->payment_code).
' ';
367 $s .= $obj->num_payment;
368 print
'<td class="tdoverflowmax125" title="'.dolPrintHTMLForAttribute($s).
'">';
373 if (isModEnabled(
"bank")) {
375 if ($obj->fk_bank > 0) {
377 $accountstatic->id = $obj->bid;
378 $accountstatic->ref = $obj->bref;
379 $accountstatic->number = $obj->bnumber;
380 $accountstatic->account_number = $obj->account_number;
381 $accountstatic->fk_accountancy_journal = $obj->fk_accountancy_journal;
382 $accountstatic->label = $obj->blabel;
384 print $accountstatic->getNomUrl(1);
392 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>";
399 print
'<tr class="liste_total">';
401 print
'<td class="liste_total" colspan="2">'.$langs->trans(
"Total").
'</td>';
405 print
'<td class="liste_total"> </td>';
407 print
'<td class="liste_total"></td>';
408 print
'<td class="liste_total"></td>';
409 print
'<td class="liste_total"></td>';
411 if (isModEnabled(
"bank")) {
412 print
'<td class="liste_total"></td>';
415 print
'<td class="liste_total right">'.price($total).
"</td>";
428if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
431} elseif ($mysoc->localtax1_assuj ==
"1") {
434} elseif ($mysoc->localtax2_assuj ==
"1") {
445 $labeltax = $langs->transcountry(($j == 1 ?
"LT1" :
"LT2"), $mysoc->country_code);
447 print
load_fiche_titre($labeltax.($year ?
' ('.$langs->trans(
"Year").
' '.$year.
')' :
''),
'',
'');
450 $sql =
"SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp";
451 $sql .=
" FROM ".MAIN_DB_PREFIX.
"localtax as pv";
452 $sql .=
" WHERE pv.entity = ".$conf->entity.
" AND localtaxtype = ".((int) $j);
458 if (preg_match(
'/^pv/', $sortfield)) {
459 $sql .= $db->order($sortfield, $sortorder);
462 $result = $db->query($sql);
464 $num = $db->num_rows($result);
468 print
'<div class="div-table-responsive-no-min">';
469 print
'<table class="noborder centpercent">';
470 print
'<tr class="liste_titre">';
471 print_liste_field_titre(
"PeriodEndDate", $_SERVER[
"PHP_SELF"],
"pv.datev",
"", $param,
'width="120"', $sortfield, $sortorder);
473 print_liste_field_titre(
"ExpectedToPay", $_SERVER[
"PHP_SELF"],
"pv.amount",
"", $param,
'class="right"', $sortfield, $sortorder);
474 print_liste_field_titre(
"RefPayment", $_SERVER[
"PHP_SELF"],
"pv.rowid",
"", $param,
'', $sortfield, $sortorder);
475 print_liste_field_titre(
"DatePayment", $_SERVER[
"PHP_SELF"],
"pv.datep",
"", $param,
'align="center"', $sortfield, $sortorder);
476 print_liste_field_titre(
"PayedByThisPayment", $_SERVER[
"PHP_SELF"],
"pv.amount",
"", $param,
'class="right"', $sortfield, $sortorder);
480 $obj = $db->fetch_object($result);
482 $total += $obj->amount;
484 print
'<tr class="oddeven">';
485 print
'<td class="left">'.dol_print_date($db->jdate($obj->dm),
'day').
'</td>'.
"\n";
487 print
"<td>".$obj->label.
"</td>\n";
489 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>";
492 $ptva_static->id = $obj->rowid;
493 $ptva_static->ref = $obj->rowid;
494 print
'<td class="left">'.$ptva_static->getNomUrl(1).
"</td>\n";
496 print
'<td class="center">'.dol_print_date($db->jdate($obj->dp),
'day').
"</td>\n";
497 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>";
502 print
'<tr class="liste_total"><td colspan="2">'.$langs->trans(
"Total").
'</td>';
503 print
'<td class="right">'.price($total).
"</td>";
504 print
'<td align="center"> </td>';
505 print
'<td align="center"> </td>';
506 print
'<td class="right">'.price($total).
"</td>";
522$parameters = array(
'user' => $user);
523$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.
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.