30 require
'../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/paymentsocialcontribution.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formsocialcontrib.class.php';
43 $hookmanager->initHooks(array(
'specialexpensesindex'));
46 $langs->loadLangs(array(
'compta',
'bills'));
49 if ($user->socid) $socid = $user->socid;
50 $result =
restrictedArea($user,
'tax|salaries',
'',
'',
'charges|');
53 $search_sc_type =
GETPOST(
'search_sc_type',
'int');
55 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
56 $sortfield =
GETPOST(
"sortfield",
'alpha');
57 $sortorder =
GETPOST(
"sortorder",
'alpha');
59 if (empty($page) || $page == -1) { $page = 0; }
60 $offset = $limit * $page;
61 $pageprev = $page - 1;
62 $pagenext = $page + 1;
63 if (!$sortfield) $sortfield =
"cs.date_ech";
64 if (!$sortorder) $sortorder =
"DESC";
66 if (empty($conf->tax->enabled) || empty($user->rights->tax->charges->lire))
77 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
89 $tva_static =
new Tva($db);
93 $accountstatic =
new Account($db);
96 $title = $langs->trans(
"SocialContributionsPayments");
102 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
103 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
104 if ($sortfield) $param .=
'&sortfield='.urlencode($sortfield);
105 if ($sortorder) $param .=
'&sortorder='.urlencode($sortorder);
106 if ($year) $param .=
'&year='.urlencode($year);
107 if ($search_sc_type) $param .=
'&search_sc_type='.urlencode($search_sc_type);
110 print '<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
111 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
112 print '<input type="hidden" name="token" value="'.newToken().
'">';
113 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
114 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
115 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
116 print '<input type="hidden" name="page" value="'.$page.
'">';
118 $sql =
"SELECT c.id, c.libelle as label,";
119 $sql .=
" cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,";
120 $sql .=
" pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,";
121 $sql .=
" pct.code as payment_code,";
122 $sql .=
" ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
123 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_chargesociales as c,";
124 $sql .=
" ".MAIN_DB_PREFIX.
"chargesociales as cs";
125 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiementcharge as pc ON pc.fk_charge = cs.rowid";
126 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as pct ON pc.fk_typepaiement = pct.id";
127 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON pc.fk_bank = b.rowid";
128 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_account as ba ON b.fk_account = ba.rowid";
129 $sql .=
" WHERE cs.fk_type = c.id";
130 $sql .=
" AND cs.entity IN (".getEntity(
"tax").
")";
131 if ($search_sc_type > 0) {
132 $sql .=
" AND cs.fk_type = ".((int) $search_sc_type);
142 if (preg_match(
'/^cs\./', $sortfield) || preg_match(
'/^c\./', $sortfield) || preg_match(
'/^pc\./', $sortfield) || preg_match(
'/^pct\./', $sortfield)) {
143 $sql .= $db->order($sortfield, $sortorder);
147 $nbtotalofrecords =
'';
148 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
149 $resql = $db->query($sql);
150 $nbtotalofrecords = $db->num_rows(
$resql);
151 if (($page * $limit) > $nbtotalofrecords) {
157 if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
158 $num = $nbtotalofrecords;
160 if ($limit) $sql .= $db->plimit($limit + 1, $offset);
162 $resql = $db->query($sql);
168 $num = $db->num_rows(
$resql);
174 print_barre_liste($title, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'object_payment', 0, $nav,
'', $limit, 0);
176 print '<table class="noborder centpercent">';
178 print '<tr class="liste_titre">';
179 print '<td class="liste_titre"></td>';
180 print '<td class="liste_titre"></td>';
181 print '<td class="liste_titre">';
182 $formsocialcontrib->select_type_socialcontrib(
GETPOSTISSET(
"search_sc_type") ? $search_sc_type :
'',
'search_sc_type', 1, 0, 0,
'minwidth200 maxwidth300');
184 print '<td class="liste_titre"></td>';
185 print '<td class="liste_titre"></td>';
186 print '<td class="liste_titre"></td>';
187 print '<td class="liste_titre"></td>';
188 if (!empty($conf->banque->enabled))
print '<td class="liste_titre"></td>';
189 print '<td class="liste_titre"></td>';
190 print '<td class="liste_titre center">';
191 $searchpicto = $form->showFilterButtons();
196 print '<tr class="liste_titre">';
220 while ($i < min($num, $limit)) {
221 $obj = $db->fetch_object(
$resql);
222 print '<tr class="oddeven">';
224 $date = $obj->periode;
225 if (empty($date)) $date = $obj->date_ech;
226 print '<td>'.dol_print_date($date,
'day').
'</td>';
229 $socialcontrib->id = $obj->rowid;
230 $socialcontrib->ref = $obj->label;
231 $socialcontrib->label = $obj->label;
232 print $socialcontrib->getNomUrl(1,
'20');
235 print '<td title="'.dol_escape_htmltag($obj->label).
'" class="tdmaxoverflow300">'.$obj->label.
'</td>';
237 print '<td class="right">'.price($obj->total).
'</td>';
239 $payment_sc_static->id = $obj->pid;
240 $payment_sc_static->ref = $obj->pid;
241 print '<td>'.$payment_sc_static->getNomUrl(1).
"</td>\n";
243 print '<td class="center">'.dol_print_date($db->jdate($obj->datep),
'day').
'</td>';
246 if ($obj->payment_code)
print $langs->trans(
"PaymentTypeShort".$obj->payment_code).
' ';
247 print $obj->num_payment.
'</td>';
249 if (!empty($conf->banque->enabled))
252 if ($obj->fk_bank > 0)
255 $accountstatic->id = $obj->bid;
256 $accountstatic->ref = $obj->bref;
257 $accountstatic->number = $obj->bnumber;
258 $accountstatic->accountancy_number = $obj->account_number;
259 $accountstatic->accountancy_journal = $obj->accountancy_journal;
260 $accountstatic->label = $obj->blabel;
261 print $accountstatic->getNomUrl(1);
262 }
else print ' ';
266 print '<td class="right">';
267 if ($obj->totalpaye)
print price($obj->totalpaye);
274 $total = $total + $obj->total;
275 $totalnb = $totalnb + $obj->nb;
276 $totalpaye = $totalpaye + $obj->totalpaye;
281 print '<tr class="liste_total"><td colspan="3" class="liste_total">'.$langs->trans(
"Total").
'</td>';
282 print '<td class="liste_total right"></td>';
283 print '<td align="center" class="liste_total"> </td>';
284 print '<td align="center" class="liste_total"> </td>';
285 print '<td align="center" class="liste_total"> </td>';
286 if (!empty($conf->banque->enabled))
print '<td></td>';
287 print '<td class="liste_total right">'.price($totalpaye).
"</td>";
296 $parameters = array(
'user' => $user);
297 $reshook = $hookmanager->executeHooks(
'dashboardSpecialBills', $parameters, $object);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage salary payments.
Class to manage payments of social contributions.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Class to manage bank accounts.
Put here description of your class.
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_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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=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 Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...