32require
'../../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/paymentvat.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/paymentsocialcontribution.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
45$hookmanager->initHooks(array(
'specialexpensesindex'));
48$langs->loadLangs(array(
'compta',
'bills'));
52 $socid = $user->socid;
54$result =
restrictedArea($user,
'tax|salaries',
'',
'',
'charges|');
56$mode =
GETPOST(
"mode",
'alpha');
58$filtre =
GETPOST(
"filtre",
'alpha');
60 $year = date(
"Y", time());
62$optioncss =
GETPOST(
'optioncss',
'aZ');
64$search_account =
GETPOST(
'search_account',
'int');
66$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
67$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
68$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
69$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
70if (empty($page) || $page == -1) {
73$offset = $limit * $page;
77 $sortfield =
"cs.date_ech";
88$tva_static =
new Tva($db);
92$sal_static =
new Salary($db);
93$accountstatic =
new Account($db);
95llxHeader(
'', $langs->trans(
"SpecialExpensesArea"));
97$title = $langs->trans(
"SpecialExpensesArea");
100if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
101 $param .=
'&contextpage='.$contextpage;
103if ($limit > 0 && $limit != $conf->liste_limit) {
104 $param .=
'&limit='.$limit;
107 $param .=
'&sortfield='.$sortfield;
110 $param .=
'&sortorder='.$sortorder;
116print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
117if ($optioncss !=
'') {
118 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
120print
'<input type="hidden" name="token" value="'.newToken().
'">';
121print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
122print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
123print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
124print
'<input type="hidden" name="page" value="'.$page.
'">';
125print
'<input type="hidden" name="mode" value="'.$mode.
'">';
127$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')) {
139 print
load_fiche_titre($langs->trans(
"SocialContributions").($year ?
' ('.$langs->trans(
"Year").
' '.$year.
')' :
''),
'',
'');
141 print
'<table class="noborder centpercent">';
142 print
'<tr class="liste_titre">';
143 print_liste_field_titre(
"PeriodEndDate", $_SERVER[
"PHP_SELF"],
"cs.date_ech",
"", $param,
'', $sortfield, $sortorder,
'nowraponall ');
146 print_liste_field_titre(
"ExpectedToPay", $_SERVER[
"PHP_SELF"],
"cs.amount",
"", $param,
'class="right"', $sortfield, $sortorder);
147 print_liste_field_titre(
"RefPayment", $_SERVER[
"PHP_SELF"],
"pc.rowid",
"", $param,
'', $sortfield, $sortorder);
148 print_liste_field_titre(
"DatePayment", $_SERVER[
"PHP_SELF"],
"pc.datep",
"", $param,
'align="center"', $sortfield, $sortorder);
150 if (isModEnabled(
"banque")) {
153 print_liste_field_titre(
"PayedByThisPayment", $_SERVER[
"PHP_SELF"],
"pc.amount",
"", $param,
'class="right"', $sortfield, $sortorder);
156 $sql =
"SELECT c.id, c.libelle as label,";
157 $sql .=
" cs.rowid, cs.libelle, cs.fk_type as type, cs.periode as period, cs.date_ech, cs.amount as total,";
158 $sql .=
" pc.rowid as pid, pc.datep, pc.amount as totalpaid, pc.num_paiement as num_payment, pc.fk_bank,";
159 $sql .=
" pct.code as payment_code,";
160 $sql .=
" ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
161 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_chargesociales as c,";
162 $sql .=
" ".MAIN_DB_PREFIX.
"chargesociales as cs";
163 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiementcharge as pc ON pc.fk_charge = cs.rowid";
164 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as pct ON pc.fk_typepaiement = pct.id";
165 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON pc.fk_bank = b.rowid";
166 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_account as ba ON b.fk_account = ba.rowid";
167 $sql .=
" WHERE cs.fk_type = c.id";
168 $sql .=
" AND cs.entity IN (".getEntity(
"tax").
")";
177 if (preg_match(
'/^cs\./', $sortfield) || preg_match(
'/^c\./', $sortfield) || preg_match(
'/^pc\./', $sortfield) || preg_match(
'/^pct\./', $sortfield)) {
178 $sql .= $db->order($sortfield, $sortorder);
183 dol_syslog(
"compta/charges/index.php: select payment", LOG_DEBUG);
184 $resql = $db->query($sql);
186 $num = $db->num_rows($resql);
192 while ($i < min($num, $limit)) {
193 $obj = $db->fetch_object($resql);
195 print
'<tr class="oddeven">';
197 $date = $obj->period;
199 $date = $obj->date_ech;
201 print
'<td>'.dol_print_date($date,
'day').
'</td>';
204 $socialcontrib->id = $obj->rowid;
205 $socialcontrib->ref = $obj->label;
206 $socialcontrib->label = $obj->label;
207 print $socialcontrib->getNomUrl(1,
'20');
210 print
'<td><a href="'.DOL_URL_ROOT.
'/compta/sociales/list.php?filtre=cs.fk_type:'.$obj->type.
'">'.$obj->label.
'</a></td>';
212 print
'<td class="right"><span class="amount">'.price($obj->total).
'</span></td>';
214 $payment_sc_static->id = $obj->pid;
215 $payment_sc_static->ref = $obj->pid;
216 print
'<td>'.$payment_sc_static->getNomUrl(1).
"</td>\n";
218 print
'<td class="center">'.dol_print_date($db->jdate($obj->datep),
'day').
'</td>';
221 if ($obj->payment_code) {
222 print $langs->trans(
"PaymentTypeShort".$obj->payment_code).
' ';
224 print $obj->num_payment.
'</td>';
226 if (isModEnabled(
"banque")) {
228 if ($obj->fk_bank > 0) {
230 $accountstatic->id = $obj->bid;
231 $accountstatic->ref = $obj->bref;
232 $accountstatic->number = $obj->bnumber;
233 $accountstatic->account_number = $obj->account_number;
234 $accountstatic->fk_accountancy_journal = $obj->fk_accountancy_journal;
235 $accountstatic->label = $obj->blabel;
237 print $accountstatic->getNomUrl(1);
244 print
'<td class="right">';
245 if ($obj->totalpaid) {
246 print
price($obj->totalpaid);
251 $total = $total + $obj->total;
252 $totalpaid = $totalpaid + $obj->totalpaid;
255 print
'<tr class="liste_total">';
257 print
'<td colspan="3" class="liste_total">'.$langs->trans(
"Total").
'</td>';
261 print
'<td class="liste_total right"></td>';
263 print
'<td class="liste_total center"> </td>';
264 print
'<td class="liste_total center"> </td>';
265 print
'<td class="liste_total center"> </td>';
266 if (isModEnabled(
"banque")) {
267 print
'<td class="liste_total center"></td>';
269 print
'<td class="liste_total right">'.price($totalpaid).
"</td>";
279if (isModEnabled(
'tax') && $user->hasRight(
'tax',
'charges',
'lire')) {
284 print
load_fiche_titre($langs->trans(
"VATDeclarations").($year ?
' ('.$langs->trans(
"Year").
' '.$year.
')' :
''),
'',
'');
286 $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,";
287 $sql .=
" pct.code as payment_code,";
288 $sql .=
" ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
289 $sql .=
" FROM ".MAIN_DB_PREFIX.
"tva as pv";
290 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"payment_vat as ptva ON ptva.fk_tva = pv.rowid";
291 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON (ptva.fk_bank = b.rowid)";
292 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_account as ba ON b.fk_account = ba.rowid";
293 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as pct ON ptva.fk_typepaiement = pct.id";
294 $sql .=
" WHERE pv.entity IN (".getEntity(
"tax").
")";
300 if (preg_match(
'/^pv\./', $sortfield) || preg_match(
'/^ptva\./', $sortfield)) {
301 $sql .= $db->order($sortfield, $sortorder);
304 $result = $db->query($sql);
306 $num = $db->num_rows($result);
312 print
'<table class="noborder centpercent">';
313 print
'<tr class="liste_titre">';
314 print_liste_field_titre(
"PeriodEndDate", $_SERVER[
"PHP_SELF"],
"pv.datev",
"", $param,
'', $sortfield, $sortorder,
'nowraponall ');
316 print_liste_field_titre(
"ExpectedToPay", $_SERVER[
"PHP_SELF"],
"pv.amount",
"", $param,
'class="right"', $sortfield, $sortorder);
317 print_liste_field_titre(
"RefPayment", $_SERVER[
"PHP_SELF"],
"ptva.rowid",
"", $param,
'', $sortfield, $sortorder);
318 print_liste_field_titre(
"DatePayment", $_SERVER[
"PHP_SELF"],
"ptva.datep",
"", $param,
'align="center"', $sortfield, $sortorder);
320 if (isModEnabled(
"banque")) {
323 print_liste_field_titre(
"PayedByThisPayment", $_SERVER[
"PHP_SELF"],
"ptva.amount",
"", $param,
'class="right"', $sortfield, $sortorder);
327 $obj = $db->fetch_object($result);
329 $totaltopay = $totaltopay + $obj->amount_tva;
330 $total = $total + $obj->amount;
333 print
'<tr class="oddeven">';
335 print
'<td class="left">'.dol_print_date($db->jdate($obj->dm),
'day').
'</td>'.
"\n";
337 $tva_static->id = $obj->id_tva;
338 $tva_static->ref = $obj->label;
339 print
"<td>".$tva_static->getNomUrl(1).
"</td>\n";
341 print
'<td class="right"><span class="amount">'.price($obj->amount_tva).
"</span></td>";
344 $ptva_static->id = $obj->rowid;
345 $ptva_static->ref = $obj->rowid;
346 print
'<td>'.$ptva_static->getNomUrl(1).
"</td>\n";
349 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_payment),
'day').
"</td>\n";
353 if ($obj->payment_code) {
354 print $langs->trans(
"PaymentTypeShort".$obj->payment_code).
' ';
356 print $obj->num_payment.
'</td>';
359 if (isModEnabled(
"banque")) {
361 if ($obj->fk_bank > 0) {
363 $accountstatic->id = $obj->bid;
364 $accountstatic->ref = $obj->bref;
365 $accountstatic->number = $obj->bnumber;
366 $accountstatic->account_number = $obj->account_number;
367 $accountstatic->fk_accountancy_journal = $obj->fk_accountancy_journal;
368 $accountstatic->label = $obj->blabel;
370 print $accountstatic->getNomUrl(1);
378 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>";
383 print
'<tr class="liste_total">';
385 print
'<td class="liste_total" colspan="2">'.$langs->trans(
"Total").
'</td>';
389 print
'<td class="liste_total"> </td>';
391 print
'<td class="liste_total"></td>';
392 print
'<td class="liste_total"></td>';
393 print
'<td class="liste_total"></td>';
395 if (isModEnabled(
"banque")) {
396 print
'<td class="liste_total"></td>';
399 print
'<td class="liste_total right">'.price($total).
"</td>";
412if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
415} elseif ($mysoc->localtax1_assuj ==
"1") {
418} elseif ($mysoc->localtax2_assuj ==
"1") {
431 print
load_fiche_titre($langs->transcountry(($j == 1 ?
"LT1Payments" :
"LT2Payments"), $mysoc->country_code).($year ?
' ('.$langs->trans(
"Year").
' '.$year.
')' :
''),
'',
'');
434 $sql =
"SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp";
435 $sql .=
" FROM ".MAIN_DB_PREFIX.
"localtax as pv";
436 $sql .=
" WHERE pv.entity = ".$conf->entity.
" AND localtaxtype = ".((int) $j);
442 if (preg_match(
'/^pv/', $sortfield)) {
443 $sql .= $db->order($sortfield, $sortorder);
446 $result = $db->query($sql);
448 $num = $db->num_rows($result);
452 print
'<div class="div-table-responsive-no-min">';
453 print
'<table class="noborder centpercent">';
454 print
'<tr class="liste_titre">';
455 print_liste_field_titre(
"PeriodEndDate", $_SERVER[
"PHP_SELF"],
"pv.datev",
"", $param,
'width="120"', $sortfield, $sortorder);
457 print_liste_field_titre(
"ExpectedToPay", $_SERVER[
"PHP_SELF"],
"pv.amount",
"", $param,
'class="right"', $sortfield, $sortorder);
458 print_liste_field_titre(
"RefPayment", $_SERVER[
"PHP_SELF"],
"pv.rowid",
"", $param,
'', $sortfield, $sortorder);
459 print_liste_field_titre(
"DatePayment", $_SERVER[
"PHP_SELF"],
"pv.datep",
"", $param,
'align="center"', $sortfield, $sortorder);
460 print_liste_field_titre(
"PayedByThisPayment", $_SERVER[
"PHP_SELF"],
"pv.amount",
"", $param,
'class="right"', $sortfield, $sortorder);
464 $obj = $db->fetch_object($result);
466 $total = $total + $obj->amount;
468 print
'<tr class="oddeven">';
469 print
'<td class="left">'.dol_print_date($db->jdate($obj->dm),
'day').
'</td>'.
"\n";
471 print
"<td>".$obj->label.
"</td>\n";
473 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>";
476 $ptva_static->id = $obj->rowid;
477 $ptva_static->ref = $obj->rowid;
478 print
'<td class="left">'.$ptva_static->getNomUrl(1).
"</td>\n";
480 print
'<td class="center">'.dol_print_date($db->jdate($obj->dp),
'day').
"</td>\n";
481 print
'<td class="right"><span class="amount">'.price($obj->amount).
"</span></td>";
486 print
'<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans(
"Total").
'</td>';
487 print
'<td class="right">'.price($total).
"</td>";
488 print
'<td align="center"> </td>';
489 print
'<td align="center"> </td>';
490 print
'<td class="right">'.price($total).
"</td>";
506$parameters = array(
'user' => $user);
507$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()
Empty header.
Class to manage bank accounts.
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...
Class to manage payments of social contributions.
Class to manage payments of social contributions.
Class to manage salary payments.
Put here description of your class.
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($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.