31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
34if (isModEnabled(
'accounting')) {
35 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
39$langs->loadLangs(array(
"compta",
"salaries",
"bills",
"hrm"));
41$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
42$massaction =
GETPOST(
'massaction',
'alpha');
44$confirm =
GETPOST(
'confirm',
'alpha');
45$cancel =
GETPOST(
'cancel',
'alpha');
46$toselect =
GETPOST(
'toselect',
'array');
47$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
48$backtopage =
GETPOST(
'backtopage',
'alpha');
49$optioncss =
GETPOST(
'optioncss',
'aZ');
55$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
56$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
58if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
62$offset = $limit * $page;
66 $sortfield =
"s.datep,s.rowid";
69 $sortorder =
"DESC,DESC";
75$diroutputmassaction = $conf->user->dir_output.
'/temp/massgeneration/'.$user->id;
76$hookmanager->initHooks(array(
'salarieslist'));
79$extrafields->fetch_name_optionals_label(
$object->table_element);
81$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
84 $sortfield =
"s.datep,s.rowid";
87 $sortorder =
"DESC,DESC";
90$search_ref =
GETPOST(
'search_ref',
'alpha');
91$search_user =
GETPOST(
'search_user',
'alpha');
92$search_label =
GETPOST(
'search_label',
'alpha');
97$search_amount =
GETPOST(
'search_amount',
'alpha');
98$search_account =
GETPOST(
'search_account',
'alpha');
99$search_status =
GETPOST(
'search_status',
'intcomma');
100$search_type_id =
GETPOST(
'search_type_id',
'intcomma');
102$childids = $user->getAllChildIds(1);
105$search_all =
GETPOST(
"search_all",
'alpha');
107foreach (
$object->fields as $key => $val) {
108 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
109 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
111 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
118$fieldstosearchall = array();
119foreach (
$object->fields as $key => $val) {
120 if (!empty($val[
'searchall'])) {
121 $fieldstosearchall[
's.'.$key] = $val[
'label'];
126$arrayfields = array();
127foreach (
$object->fields as $key => $val) {
129 if (!empty($val[
'visible'])) {
130 $visible = (int)
dol_eval((
string) $val[
'visible'], 1);
131 $arrayfields[
's.'.$key] = array(
132 'label' => $val[
'label'],
133 'checked' => (($visible < 0) ? 0 : 1),
134 'enabled' => (abs($visible) != 3 && (bool)
dol_eval($val[
'enabled'], 1)),
135 'position' => $val[
'position'],
136 'help' => isset($val[
'help']) ? $val[
'help'] :
''
141include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
146$permissiontoread = $user->hasRight(
'salaries',
'read');
147$permissiontoadd = $user->hasRight(
'salaries',
'write');
148$permissiontodelete = $user->hasRight(
'salaries',
'delete');
155 $socid = $user->socid;
164if (
GETPOST(
'cancel',
'alpha')) {
168if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
173if ($massaction ==
'withdrawrequest') {
174 $langs->load(
"withdrawals");
176 if (!$user->hasRight(
'paymentbybanktransfer',
'create')) {
182 $listofSalries = array();
183 $arrayofselected = is_array($toselect) ? $toselect : array();
184 foreach ($arrayofselected as $toselectid) {
185 $objecttmp =
new Salary($db);
186 $result = $objecttmp->fetch($toselectid);
188 $totalpaid = $objecttmp->getSommePaiement();
189 $objecttmp->resteapayer =
price2num((
float) $objecttmp->amount - $totalpaid,
'MT');
192 $parameters = array(
'remaintopay' => $objecttmp->resteapayer);
193 $reshook = $hookmanager->executeHooks(
'finalizeAmountOfInvoice', $parameters, $objecttmp, $action);
195 if (!empty($remaintopay = $hookmanager->resArray[
'remaintopay'])) {
196 $objecttmp->resteapayer = $remaintopay;
198 } elseif ($reshook < 0) {
200 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"ProcessingError"), $hookmanager->errors,
'errors');
203 if ($objecttmp->status == Salary::STATUS_PAID || $objecttmp->resteapayer == 0) {
205 setEventMessages($langs->trans(
"Salary").
' '.$objecttmp->ref.
' : '.$langs->trans(
"AlreadyPaid"), $objecttmp->errors,
'errors');
206 } elseif ($resteapayer < 0) {
208 setEventMessages($langs->trans(
"Salary").
' '.$objecttmp->ref.
' : '.$langs->trans(
"AmountMustBePositive"), $objecttmp->errors,
'errors');
211 $rsql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
212 $rsql .=
" , pfd.date_traite as date_traite";
213 $rsql .=
" , pfd.amount";
214 $rsql .=
" , u.rowid as user_id, u.lastname, u.firstname, u.login";
215 $rsql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
216 $rsql .=
" , ".MAIN_DB_PREFIX.
"user as u";
217 $rsql .=
" WHERE fk_salary = ".((int) $objecttmp->id);
218 $rsql .=
" AND pfd.fk_user_demande = u.rowid";
219 $rsql .=
" AND pfd.traite = 0";
220 $rsql .=
" ORDER BY pfd.date_demande DESC";
222 $result_sql = $db->query($rsql);
224 $numprlv = $db->num_rows($result_sql);
229 setEventMessages($langs->trans(
"Salary").
' '.$objecttmp->ref.
' : '.$langs->trans(
"RequestAlreadyDone"), $objecttmp->errors,
'warnings');
230 } elseif (!empty($objecttmp->type_payment_code) && $objecttmp->type_payment_code !=
'VIR') {
231 $langs->load(
"errors");
233 setEventMessages($langs->trans(
"Salary").
' '.$objecttmp->ref.
' : '.$langs->trans(
"ErrorThisPaymentModeIsNotCreditTransfer"), $objecttmp->errors,
'errors');
235 $listofSalries[] = $objecttmp;
241 if (!$error && !empty($listofSalries)) {
242 $nbwithdrawrequestok = 0;
243 foreach ($listofSalries as $salary) {
245 $result = $salary->demande_prelevement($user, (
float) $salary->resteapayer,
'salaire');
248 $nbwithdrawrequestok++;
254 if ($nbwithdrawrequestok > 0) {
255 setEventMessages($langs->trans(
"WithdrawRequestsDone", $nbwithdrawrequestok),
null,
'mesgs');
261$parameters = array();
262$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
267if (empty($reshook)) {
269 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
272 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
276 $search_date_start_from =
'';
277 $search_date_start_to =
'';
278 $search_date_end_from =
'';
279 $search_date_end_to =
'';
280 $search_date_end =
'';
282 $search_account =
'';
284 $search_type_id =
"";
286 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
287 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
292 $objectclass =
'Salary';
293 $objectlabel =
'Salaries';
294 $uploaddir = $conf->salaries->dir_output;
295 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
298 if (!$error && $massaction ==
'buildsepa' && $permissiontoadd) {
299 $objecttmp =
new $objectclass($db);
309$form =
new Form($db);
310$salstatic =
new Salary($db);
311$userstatic =
new User($db);
312$accountstatic =
new Account($db);
316$title = $langs->trans(
'Salaries');
324$sql =
"SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.photo, u.salary as current_salary, u.fk_soc as fk_soc, u.statut as status,";
325$sql .=
" s.rowid, s.fk_account, s.paye, s.fk_user, s.amount, s.salary, s.label, s.datesp, s.dateep, s.fk_typepayment as paymenttype, ";
326$sql .=
" ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel, ba.iban_prefix as iban, ba.bic, ba.currency_code, ba.clos,";
327$sql .=
" pst.code as payment_code,";
328$sql .=
" SUM(ps.amount) as alreadypayed";
330if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
331 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
332 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
336$parameters = array();
337$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
338$sql .= $hookmanager->resPrint;
339$sql = preg_replace(
'/,\s*$/',
'', $sql);
344$sql .=
" FROM ".MAIN_DB_PREFIX.
"salary as s";
345if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
346 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (s.rowid = ef.fk_object)";
348$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"payment_salary as ps ON (ps.fk_salary = s.rowid) ";
349$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as pst ON (s.fk_typepayment = pst.id) ";
350$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_account ba ON (ba.rowid = s.fk_account), ";
352$sql .=
" ".MAIN_DB_PREFIX.
"user as u";
353$sql .=
" WHERE u.rowid = s.fk_user";
354$sql .=
" AND s.entity IN (".getEntity(
'salaries').
")";
355if (!$user->hasRight(
'salaries',
'readall')) {
356 $sql .=
" AND s.fk_user IN (".$db->sanitize(implode(
',', $childids)).
")";
362 $sql .=
" AND s.rowid=".((int) $search_ref);
365 $sql .=
natural_search(array(
'u.login',
'u.lastname',
'u.firstname',
'u.email'), $search_user);
370if (!empty($search_date_start_from)) {
371 $sql .=
" AND s.datesp >= '".$db->idate($search_date_start_from).
"'";
373if (!empty($search_date_end_from)) {
374 $sql .=
" AND s.dateep >= '".$db->idate($search_date_end_from).
"'";
376if (!empty($search_date_start_to)) {
377 $sql .=
" AND s.datesp <= '".$db->idate($search_date_start_to).
"'";
379if (!empty($search_date_end_to)) {
380 $sql .=
" AND s.dateep <= '".$db->idate($search_date_end_to).
"'";
386if ($search_account > 0) {
387 $sql .=
" AND s.fk_account=".((int) $search_account);
389if ($search_status !=
'' && $search_status >= 0) {
390 $sql .=
" AND s.paye = ".((int) $search_status);
392if ($search_type_id) {
393 $sql .=
" AND s.fk_typepayment=".((int) $search_type_id);
396include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
397$sql .=
" GROUP BY u.rowid, u.lastname, u.firstname, u.login, u.email, u.admin, u.photo, u.salary, u.fk_soc, u.statut,";
398$sql .=
" s.rowid, s.fk_account, s.paye, s.fk_user, s.amount, s.salary, s.label, s.datesp, s.dateep, s.fk_typepayment, s.fk_bank,";
399$sql .=
" ba.rowid, ba.ref, ba.number, ba.account_number, ba.fk_accountancy_journal, ba.label, ba.iban_prefix, ba.bic, ba.currency_code, ba.clos,";
403$nbtotalofrecords =
'';
406 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
407 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
408 $resql = $db->query($sqlforcount);
410 $objforcount = $db->fetch_object($resql);
411 $nbtotalofrecords = $objforcount->nbtotalofrecords;
416 if (($page * $limit) > $nbtotalofrecords) {
424$sql .= $db->order($sortfield, $sortorder);
426 $sql .= $db->plimit($limit + 1, $offset);
429$resql = $db->query($sql);
435$num = $db->num_rows($resql);
439if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
440 $obj = $db->fetch_object($resql);
442 header(
"Location: ".DOL_URL_ROOT.
'/salaries/card.php?id='.
$id);
450llxHeader(
'', $title, $help_url,
'', 0, 0, $morejs, $morecss,
'',
'bodyforlist');
452$arrayofselected = is_array($toselect) ? $toselect : array();
456 $param .=
'&mode='.urlencode($mode);
458if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
459 $param .=
'&contextpage='.urlencode($contextpage);
461if ($limit > 0 && $limit != $conf->liste_limit) {
462 $param .=
'&limit='.((int) $limit);
464if ($search_type_id) {
465 $param .=
'&search_type_id='.urlencode($search_type_id);
467if ($optioncss !=
'') {
468 $param .=
'&optioncss='.urlencode($optioncss);
470if ($search_ref !=
'') {
471 $param .=
'&search_ref='.urlencode($search_ref);
473if ($search_user !=
'') {
474 $param .=
'&search_user='.urlencode($search_user);
477 $param .=
'&search_label='.urlencode($search_label);
479if ($search_account) {
480 $param .=
'&search_account='.urlencode((
string) ($search_account));
482if ($search_status !=
'' && $search_status !=
'-1') {
483 $param .=
'&search_status='.urlencode($search_status);
485if (!empty($search_date_start_from)) {
486 $param .=
'&search_date_start_fromday='.urlencode(
GETPOST(
'search_date_start_fromday')).
'&search_date_start_frommonth='.urlencode(
GETPOST(
'search_date_start_frommonth')).
'&search_date_start_fromyear='.urlencode(
GETPOST(
'search_date_start_fromyear'));
488if (!empty($search_date_start_to)) {
489 $param .=
"&search_date_start_today=".urlencode(
GETPOST(
'search_date_start_today')).
"&search_date_start_tomonth=".urlencode(
GETPOST(
'search_date_start_tomonth')).
"&search_date_start_toyear=".urlencode(
GETPOST(
'search_date_start_toyear'));
491if (!empty($search_date_end_from)) {
492 $param .=
'&search_date_end_fromday='.urlencode(
GETPOST(
'search_date_end_fromday')).
'&search_date_end_frommonth='.urlencode(
GETPOST(
'search_date_end_frommonth')).
'&search_date_end_fromyear='.urlencode(
GETPOST(
'search_date_end_fromyear'));
494if (!empty($search_date_end_to)) {
495 $param .=
"&search_date_end_today=".urlencode(
GETPOST(
'search_date_end_today')).
"&search_date_end_tomonth=".urlencode(
GETPOST(
'search_date_end_tomonth')).
"&search_date_end_toyear=".urlencode(
GETPOST(
'search_date_end_toyear'));
499include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
501$parameters = array(
'param' => &$param);
502$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
503$param .= $hookmanager->resPrint;
506$arrayofmassactions = array(
510if (!empty($permissiontodelete)) {
511 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
513if (isModEnabled(
'paymentbybanktransfer') && $user->hasRight(
'paymentbybanktransfer',
'create')) {
514 $langs->load(
"withdrawals");
515 $arrayofmassactions[
'withdrawrequest'] =
img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakeBankTransferOrder");
517if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
518 $arrayofmassactions = array();
520$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
522print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
523if ($optioncss !=
'') {
524 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
526print
'<input type="hidden" name="token" value="'.newToken().
'">';
527print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
528print
'<input type="hidden" name="action" value="list">';
529print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
530print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
531print
'<input type="hidden" name="page" value="'.$page.
'">';
532print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
533print
'<input type="hidden" name="page_y" value="">';
534print
'<input type="hidden" name="mode" value="'.$mode.
'">';
537$url = DOL_URL_ROOT.
'/salaries/card.php?action=create';
539 $url .=
'&socid='.$socid;
543$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ((empty($mode) || $mode ==
'common') ? 2 : 1), array(
'morecss' =>
'reposition'));
544$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss' =>
'reposition'));
546$newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewSalary'),
'',
'fa fa-plus-circle', $url,
'', $permissiontoadd);
548print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
$object->picto, 0, $newcardbutton,
'', $limit, 0, 0, 1);
551$topicmail =
"SendSalaryRef";
552$modelmail =
"salary";
553$objecttmp =
new Salary($db);
554$trackid =
'sal'.$object->id;
555include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
559$parameters = array();
560$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
561if (empty($reshook)) {
562 $moreforfilter .= $hookmanager->resPrint;
564 $moreforfilter = $hookmanager->resPrint;
567if (!empty($moreforfilter)) {
568 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
569 print $moreforfilter;
573$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
574$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
575$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
576$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
578print
'<div class="div-table-responsive">';
579print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
583print
'<tr class="liste_titre_filter">';
586 print
'<td class="liste_titre center maxwidthsearch">';
587 $searchpicto = $form->showFilterButtons(
'left');
592if (!empty($arrayfields[
's.ref'][
'checked'])) {
593 print
'<td class="liste_titre left">';
594 print
'<input class="flat width50" type="text" name="search_ref" value="'.$db->escape($search_ref).
'">';
599if (!empty($arrayfields[
's.label'][
'checked'])) {
600 print
'<td class="liste_titre"><input type="text" class="flat width100" name="search_label" value="'.$db->escape($search_label).
'"></td>';
604if (!empty($arrayfields[
's.datesp'][
'checked'])) {
605 print
'<td class="liste_titre center">';
606 print
'<div class="nowrapfordate">';
607 print $form->selectDate($search_date_start_from ? $search_date_start_from : -1,
'search_date_start_from', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
609 print
'<div class="nowrapfordate">';
610 print $form->selectDate($search_date_start_to ? $search_date_start_to : -1,
'search_date_start_to', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
616if (!empty($arrayfields[
's.dateep'][
'checked'])) {
617 print
'<td class="liste_titre center">';
618 print
'<div class="nowrapfordate">';
619 print $form->selectDate($search_date_end_from ? $search_date_end_from : -1,
'search_date_end_from', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
621 print
'<div class="nowrapfordate">';
622 print $form->selectDate($search_date_end_to ? $search_date_end_to : -1,
'search_date_end_to', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
628if (!empty($arrayfields[
's.fk_user'][
'checked'])) {
629 print
'<td class="liste_titre">';
630 print
'<input class="flat" type="text" size="6" name="search_user" value="'.$db->escape($search_user).
'">';
635if (!empty($arrayfields[
's.fk_typepayment'][
'checked'])) {
636 print
'<td class="liste_titre left">';
637 print $form->select_types_paiements($search_type_id,
'search_type_id',
'', 0, 1, 1, 16, 1,
'maxwidth125', 1);
642if (isModEnabled(
"bank")) {
643 if (!empty($arrayfields[
's.fk_account'][
'checked'])) {
644 print
'<td class="liste_titre">';
645 print $form->select_comptes($search_account,
'search_account', 0,
'', 1,
'', 0,
'maxwidth125', 1);
651include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
654if (!empty($arrayfields[
's.amount'][
'checked'])) {
655 print
'<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$db->escape($search_amount).
'"></td>';
659if (!empty($arrayfields[
's.paye'][
'checked'])) {
660 print
'<td class="liste_titre center parentonrightofpage">';
661 $liststatus = array(
'0' => $langs->trans(
"Unpaid"),
'1' => $langs->trans(
"Paid"));
663 print $form->selectarray(
'search_status', $liststatus, $search_status, 1, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage');
668$parameters = array(
'arrayfields' => $arrayfields);
669$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
670print $hookmanager->resPrint;
673 print
'<td class="liste_titre center maxwidthsearch">';
674 $searchpicto = $form->showFilterButtons();
680$totalarray = array();
681$totalarray[
'nbfield'] = 0;
685print
'<tr class="liste_titre">';
688 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
689 $totalarray[
'nbfield']++;
692if (!empty($arrayfields[
's.ref'][
'checked'])) {
694 $totalarray[
'nbfield']++;
697if (!empty($arrayfields[
's.label'][
'checked'])) {
699 $totalarray[
'nbfield']++;
702if (!empty($arrayfields[
's.datesp'][
'checked'])) {
703 print_liste_field_titre(
"DateStart", $_SERVER[
"PHP_SELF"],
"s.datesp,s.rowid",
"", $param,
'', $sortfield, $sortorder,
'center ');
704 $totalarray[
'nbfield']++;
707if (!empty($arrayfields[
's.dateep'][
'checked'])) {
708 print_liste_field_titre(
"DateEnd", $_SERVER[
"PHP_SELF"],
"s.dateep,s.rowid",
"", $param,
'', $sortfield, $sortorder,
'center ');
709 $totalarray[
'nbfield']++;
712if (!empty($arrayfields[
's.fk_user'][
'checked'])) {
713 print_liste_field_titre(
"Employee", $_SERVER[
"PHP_SELF"],
"u.lastname",
"", $param,
"", $sortfield, $sortorder);
714 $totalarray[
'nbfield']++;
717if (!empty($arrayfields[
's.fk_typepayment'][
'checked'])) {
718 print_liste_field_titre(
"DefaultPaymentMode", $_SERVER[
"PHP_SELF"],
"type",
"", $param,
'', $sortfield, $sortorder);
719 $totalarray[
'nbfield']++;
722if (isModEnabled(
"bank")) {
723 if (!empty($arrayfields[
's.fk_account'][
'checked'])) {
724 print_liste_field_titre(
"DefaultBankAccount", $_SERVER[
"PHP_SELF"],
"ba.label",
"", $param,
"", $sortfield, $sortorder);
725 $totalarray[
'nbfield']++;
730include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
732if (!empty($arrayfields[
's.amount'][
'checked'])) {
733 print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"s.amount",
"", $param,
'', $sortfield, $sortorder,
'right ');
734 $totalarray[
'nbfield']++;
737if (!empty($arrayfields[
's.paye'][
'checked'])) {
738 print_liste_field_titre(
'Status', $_SERVER[
"PHP_SELF"],
"s.paye",
'', $param,
'', $sortfield, $sortorder,
'center ');
739 $totalarray[
'nbfield']++;
743$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
744$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
745print $hookmanager->resPrint;
748 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
749 $totalarray[
'nbfield']++;
755$needToFetchEachLine = 0;
756if (isset($extrafields->attributes[
$object->table_element][
'computed']) && is_array($extrafields->attributes[
$object->table_element][
'computed']) && count($extrafields->attributes[
$object->table_element][
'computed']) > 0) {
757 foreach ($extrafields->attributes[
$object->table_element][
'computed'] as $key => $val) {
758 if (!is_null($val) && preg_match(
'/\$object/', $val)) {
759 $needToFetchEachLine++;
767$savnbfield = $totalarray[
'nbfield'];
768$totalarray = array();
769$totalarray[
'nbfield'] = 0;
770$totalarray[
'val'] = array();
771$totalarray[
'val'][
'totalttcfield'] = 0;
772$imaxinloop = ($limit ? min($num, $limit) : $num);
773while ($i < $imaxinloop) {
774 $obj = $db->fetch_object($resql);
780 $object->setVarsFromFetchObj($obj);
782 $userstatic->id = $obj->uid;
783 $userstatic->lastname = $obj->lastname;
784 $userstatic->firstname = $obj->firstname;
785 $userstatic->admin = $obj->admin;
786 $userstatic->login = $obj->login;
787 $userstatic->email = $obj->email;
788 $userstatic->socid = $obj->fk_soc;
789 $userstatic->statut = $obj->status;
790 $userstatic->status = $obj->status;
791 $userstatic->photo = $obj->photo;
793 $salstatic->id = $obj->rowid;
794 $salstatic->ref = $obj->rowid;
795 $salstatic->label = $obj->label;
796 $salstatic->paye = $obj->paye;
797 $salstatic->status = $obj->paye;
798 $salstatic->alreadypaid = $obj->alreadypayed;
799 $salstatic->totalpaid = $obj->alreadypayed;
800 $salstatic->datesp = $obj->datesp;
801 $salstatic->dateep = $obj->dateep;
802 $salstatic->amount = $obj->amount;
803 $salstatic->type_payment = $obj->payment_code;
805 if ($mode ==
'kanban') {
807 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
808 print
'<div class="box-flex-container kanban">';
811 if ($massactionbutton || $massaction) {
813 if (in_array(
$object->id, $arrayofselected)) {
817 print $salstatic->getKanbanView(
'', array(
'user' => $userstatic,
'selected' => $selected));
818 if ($i == ($imaxinloop - 1)) {
825 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
828 print
'<td class="nowrap center">';
829 if ($massactionbutton || $massaction) {
831 if (in_array(
$object->id, $arrayofselected)) {
834 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
838 $totalarray[
'nbfield']++;
843 if (!empty($arrayfields[
's.ref'][
'checked'])) {
844 print
"<td>".$salstatic->getNomUrl(1).
"</td>\n";
846 $totalarray[
'nbfield']++;
851 if (!empty($arrayfields[
's.label'][
'checked'])) {
852 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->label).
'">'.
dol_escape_htmltag($obj->label).
"</td>\n";
854 $totalarray[
'nbfield']++;
859 if (!empty($arrayfields[
's.datesp'][
'checked'])) {
860 print
'<td class="center">'.dol_print_date($db->jdate($obj->datesp),
'day').
"</td>\n";
862 $totalarray[
'nbfield']++;
867 if (!empty($arrayfields[
's.dateep'][
'checked'])) {
868 print
'<td class="center">'.dol_print_date($db->jdate($obj->dateep),
'day').
"</td>\n";
870 $totalarray[
'nbfield']++;
875 if (!empty($arrayfields[
's.fk_user'][
'checked'])) {
876 print
'<td class="tdoverflowmax150">'.$userstatic->getNomUrl(-1).
"</td>\n";
878 $totalarray[
'nbfield']++;
883 if (!empty($arrayfields[
's.fk_typepayment'][
'checked'])) {
884 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($langs->trans(
"PaymentTypeShort".$obj->payment_code)).
'">';
885 if (!empty($obj->payment_code)) {
886 print $langs->trans(
"PaymentTypeShort".$obj->payment_code);
890 $totalarray[
'nbfield']++;
895 if (isModEnabled(
"bank")) {
896 if (!empty($arrayfields[
's.fk_account'][
'checked'])) {
898 if ($obj->fk_account > 0) {
900 $accountstatic->id = $obj->bid;
901 $accountstatic->ref = $obj->bref;
902 $accountstatic->label = $obj->blabel;
903 $accountstatic->number = $obj->bnumber;
904 $accountstatic->iban = $obj->iban;
905 $accountstatic->bic = $obj->bic;
906 $accountstatic->currency_code = $langs->trans(
"Currency".$obj->currency_code);
907 $accountstatic->account_number = $obj->account_number;
908 $accountstatic->clos = $obj->clos;
909 $accountstatic->status = $obj->clos;
911 if (isModEnabled(
'accounting')) {
912 $accountstatic->account_number = $obj->account_number;
915 $accountingjournal->fetch($obj->fk_accountancy_journal);
917 $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
920 print $accountstatic->getNomUrl(1);
926 $totalarray[
'nbfield']++;
932 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
935 if (!empty($arrayfields[
's.amount'][
'checked'])) {
936 print
'<td class="nowraponall right"><span class="amount">'.price($obj->amount).
'</span></td>';
938 $totalarray[
'nbfield']++;
941 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalttcfield';
943 $totalarray[
'val'][
'totalttcfield'] += $obj->amount;
947 if (!empty($arrayfields[
's.paye'][
'checked'])) {
948 print
'<td class="nowraponall center">'.$salstatic->getLibStatut(5, $obj->alreadypayed).
'</td>';
950 $totalarray[
'nbfield']++;
955 $parameters = array(
'arrayfields' => $arrayfields,
'object' => $object,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
956 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
957 print $hookmanager->resPrint;
961 print
'<td class="nowrap center">';
962 if ($massactionbutton || $massaction) {
964 if (in_array(
$object->id, $arrayofselected)) {
967 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
971 $totalarray[
'nbfield']++;
981include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
993 if (isModEnabled(
"bank")) {
996 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1002$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
1003$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1004print $hookmanager->resPrint;
1006print
'</table>'.
"\n";
1009print
'</form>'.
"\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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 to manage accounting journals.
Class to manage salary payments.
Class to manage Dolibarr users.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
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...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.