26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
29 if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
32 $langs->loadLangs(array(
"compta",
"salaries",
"bills",
"hrm"));
34 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
35 $massaction =
GETPOST(
'massaction',
'alpha');
36 $show_files =
GETPOST(
'show_files',
'int');
37 $confirm =
GETPOST(
'confirm',
'alpha');
38 $cancel =
GETPOST(
'cancel',
'alpha');
39 $toselect =
GETPOST(
'toselect',
'array');
40 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'bomlist';
41 $backtopage =
GETPOST(
'backtopage',
'alpha');
42 $optioncss =
GETPOST(
'optioncss',
'aZ');
45 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
46 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
47 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
49 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) { $page = 0; }
50 $offset = $limit * $page;
51 $pageprev = $page - 1;
52 $pagenext = $page + 1;
53 if (!$sortfield) $sortfield =
"s.datep,s.rowid";
54 if (!$sortorder) $sortorder =
"DESC,DESC";
59 $diroutputmassaction = $conf->user->dir_output.
'/temp/massgeneration/'.$user->id;
60 $hookmanager->initHooks(array(
'salarieslist'));
63 $extrafields->fetch_name_optionals_label($object->table_element);
65 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
67 if (!$sortfield) $sortfield =
"s.datep,s.rowid";
68 if (!$sortorder) $sortorder =
"DESC,DESC";
70 $search_ref =
GETPOST(
'search_ref',
'int');
71 $search_user =
GETPOST(
'search_user',
'alpha');
72 $search_label =
GETPOST(
'search_label',
'alpha');
73 $search_date_start =
dol_mktime(0, 0, 0,
GETPOST(
'search_date_startmonth',
'int'),
GETPOST(
'search_date_startday',
'int'),
GETPOST(
'search_date_startyear',
'int'));
74 $search_date_end =
dol_mktime(23, 59, 59,
GETPOST(
'search_date_endmonth',
'int'),
GETPOST(
'search_date_endday',
'int'),
GETPOST(
'search_date_endyear',
'int'));
75 $search_amount =
GETPOST(
'search_amount',
'alpha');
76 $search_account =
GETPOST(
'search_account',
'int');
78 $filtre =
GETPOST(
"filtre",
'restricthtml');
80 if (!
GETPOST(
'search_type_id',
'int'))
82 $newfiltre = str_replace(
'filtre=',
'', $filtre);
83 $filterarray = explode(
'-', $newfiltre);
84 foreach ($filterarray as $val)
86 $part = explode(
':', $val);
87 if ($part[0] ==
's.fk_typepayment') $search_type_id = $part[1];
90 $search_type_id =
GETPOST(
'search_type_id',
'int');
93 $childids = $user->getAllChildIds(1);
96 $socid =
GETPOST(
"socid",
"int");
97 if ($user->socid) $socid = $user->socid;
101 $search_all =
GETPOST(
"search_all",
'alpha');
103 foreach ($object->fields as $key => $val)
105 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
109 $fieldstosearchall = array();
110 foreach ($object->fields as $key => $val)
112 if ($val[
'searchall']) $fieldstosearchall[
't.'.$key] = $val[
'label'];
115 $permissiontoread = $user->rights->salaries->read;
116 $permissiontoadd = $user->rights->salaries->write;
117 $permissiontodelete = $user->rights->salaries->delete;
124 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
125 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') { $massaction =
''; }
127 $parameters = array();
128 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
129 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
134 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
137 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
142 $search_date_start =
'';
143 $search_date_end =
'';
145 $search_account =
'';
146 $search_type_id =
"";
148 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
149 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha'))
155 $objectclass =
'PaymentSalary';
156 $objectlabel =
'SalariesPayments';
157 $uploaddir = $conf->salaries->dir_output;
158 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
161 if (!$error && $massaction ==
'buildsepa' && $permissiontoadd)
163 $objecttmp =
new $objectclass($db);
173 $form =
new Form($db);
175 $userstatic =
new User($db);
176 $accountstatic =
new Account($db);
182 $title = $langs->trans(
'SalariesPayments');
184 $sql =
"SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary as current_salary, u.fk_soc as fk_soc, u.statut as status,";
185 $sql .=
" s.rowid, s.fk_user, s.amount, s.salary, s.label, s.datep as datep, s.datev as datev, s.fk_typepayment as type, s.num_payment, s.fk_bank,";
186 $sql .=
" ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel,";
187 $sql .=
" pst.code as payment_code";
188 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as s";
189 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as pst ON s.fk_typepayment = pst.id";
190 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON s.fk_bank = b.rowid";
191 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_account as ba ON b.fk_account = ba.rowid,";
192 $sql .=
" ".MAIN_DB_PREFIX.
"user as u";
193 $sql .=
" WHERE u.rowid = s.fk_user";
194 $sql .=
" AND s.entity IN (".getEntity(
'payment_salaries').
")";
195 if (empty($user->rights->salaries->readall)) $sql .=
" AND s.fk_user IN (".join(
',', $childids).
")";
198 if ($search_ref) $sql .=
" AND s.rowid=".((int) $search_ref);
199 if ($search_user) $sql .=
natural_search(array(
'u.login',
'u.lastname',
'u.firstname',
'u.email'), $search_user);
200 if ($search_label) $sql .=
natural_search(array(
's.label'), $search_label);
201 if ($search_date_start) $sql .=
" AND s.datep >= '".$db->idate($search_date_start).
"'";
202 if ($search_date_end) $sql .=
" AND s.datep <= '".$db->idate($search_date_end).
"'";
203 if ($search_amount) $sql .=
natural_search(
"s.amount", $search_amount, 1);
204 if ($search_account > 0) $sql .=
" AND b.fk_account=".((int) $search_account);
206 $filtre = str_replace(
":",
"=", $filtre);
207 $sql .=
" AND ".$filtre;
209 if ($search_type_id) {
210 $sql .=
" AND s.fk_typepayment=".$search_type_id;
212 $sql .= $db->order($sortfield, $sortorder);
215 $nbtotalofrecords =
'';
216 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
218 $resql = $db->query($sql);
219 $nbtotalofrecords = $db->num_rows(
$resql);
220 if (($page * $limit) > $nbtotalofrecords)
227 if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
229 $num = $nbtotalofrecords;
231 if ($limit) $sql .= $db->plimit($limit + 1, $offset);
233 $resql = $db->query($sql);
240 $num = $db->num_rows(
$resql);
248 $arrayofselected = is_array($toselect) ? $toselect : array();
251 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
252 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
253 if ($search_type_id) $param .=
'&search_type_id='.urlencode($search_type_id);
254 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
255 if ($search_ref) $param .=
'&search_ref='.urlencode($search_ref);
256 if ($search_user > 0) $param .=
'&search_user='.urlencode($search_user);
257 if ($search_label) $param .=
'&search_label='.urlencode($search_label);
258 if ($search_account) $param .=
'&search_account='.urlencode($search_account);
259 if ($search_date_start) $param .=
'&search_date_startday='.urlencode(
GETPOST(
'search_date_startday',
'int')).
'&search_date_startmonth='.urlencode(
GETPOST(
'search_date_startmonth',
'int')).
'&search_date_startyear='.urlencode(
GETPOST(
'search_date_startyear',
'int'));
260 if ($search_date_end) $param .=
'&search_date_endday='.urlencode(
GETPOST(
'search_date_endday',
'int')).
'&search_date_endmonth='.urlencode(
GETPOST(
'search_date_endmonth',
'int')).
'&search_date_endyear='.urlencode(
GETPOST(
'search_date_endyear',
'int'));
262 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
265 $arrayofmassactions = array(
270 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) $arrayofmassactions = array();
271 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
273 print '<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
274 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
275 print '<input type="hidden" name="token" value="'.newToken().
'">';
276 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
277 print '<input type="hidden" name="action" value="list">';
278 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
279 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
280 print '<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
282 $url = DOL_URL_ROOT.
'/salaries/card.php?action=create';
283 if (!empty($socid)) $url .=
'&socid='.$socid;
284 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewSalaryPayment'),
'',
'fa fa-plus-circle', $url,
'', $user->rights->salaries->write);
286 print_barre_liste($title, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines,
'object_payment', 0, $newcardbutton,
'', $limit, 0, 0, 1);
288 $varpage = empty($contextpage) ?
$_SERVER[
"PHP_SELF"] : $contextpage;
290 $selectedfields =
'';
291 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
293 print '<div class="div-table-responsive">';
294 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
298 print '<tr class="liste_titre_filter">';
300 print
'<td class="liste_titre left">';
301 print
'<input class="flat" type="text" size="3" name="search_ref" value="'.$db->escape($search_ref).
'">';
304 print
'<td class="liste_titre">';
305 print
'<input class="flat" type="text" size="6" name="search_user" value="'.$db->escape($search_user).
'">';
308 print
'<td class="liste_titre"><input type="text" class="flat width150" name="search_label" value="'.$db->escape($search_label).
'"></td>';
310 print
'<td class="liste_titre center">';
311 print
'<div class="nowrap">';
312 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
314 print
'<div class="nowrap">';
315 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
319 print
'<td class="liste_titre center">';
322 print
'<td class="liste_titre left">';
323 $form->select_types_paiements($search_type_id,
'search_type_id',
'', 0, 1, 1, 16);
326 if (!empty($conf->banque->enabled))
328 print
'<td class="liste_titre">';
329 $form->select_comptes($search_account,
'search_account', 0,
'', 1);
333 print
'<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$db->escape($search_amount).
'"></td>';
336 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
339 $parameters = array(
'arrayfields'=>$arrayfields);
340 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object);
341 print $hookmanager->resPrint;
343 print
'<td class="liste_titre maxwidthsearch">';
344 $searchpicto = $form->showFilterButtons();
352 print
'<tr class="liste_titre">';
362 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
364 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
365 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
366 print $hookmanager->resPrint;
368 print
getTitleFieldOfList($selectedfields, 0,
$_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
373 $needToFetchEachLine = 0;
374 if (is_array($extrafields->attributes[$object->table_element][
'computed']) && count($extrafields->attributes[$object->table_element][
'computed']) > 0)
376 foreach ($extrafields->attributes[$object->table_element][
'computed'] as $key => $val)
378 if (preg_match(
'/\$object/', $val)) $needToFetchEachLine++;
386 $totalarray = array();
387 while ($i < ($limit ? min($num, $limit) : $num))
389 $obj = $db->fetch_object(
$resql);
390 if (empty($obj))
break;
393 $object->setVarsFromFetchObj($obj);
396 print
'<tr class="oddeven">';
398 $userstatic->id = $obj->uid;
399 $userstatic->lastname = $obj->lastname;
400 $userstatic->firstname = $obj->firstname;
401 $userstatic->admin = $obj->admin;
402 $userstatic->login = $obj->login;
403 $userstatic->email = $obj->email;
404 $userstatic->socid = $obj->fk_soc;
405 $userstatic->statut = $obj->status;
407 $salstatic->id = $obj->rowid;
408 $salstatic->ref = $obj->rowid;
411 print
"<td>".$salstatic->getNomUrl(1).
"</td>\n";
412 if (!$i) $totalarray[
'nbfield']++;
415 print
"<td>".$userstatic->getNomUrl(1).
"</td>\n";
416 if (!$i) $totalarray[
'nbfield']++;
419 print
"<td>".dol_trunc($obj->label, 40).
"</td>\n";
420 if (!$i) $totalarray[
'nbfield']++;
423 print
'<td class="center">'.dol_print_date($db->jdate($obj->datep),
'day').
"</td>\n";
424 if (!$i) $totalarray[
'nbfield']++;
427 print
'<td class="center">'.dol_print_date($db->jdate($obj->datev),
'day').
"</td>\n";
428 if (!$i) $totalarray[
'nbfield']++;
431 print
'<td>'.$langs->trans(
"PaymentTypeShort".$obj->payment_code).
' '.$obj->num_payment.
'</td>';
432 if (!$i) $totalarray[
'nbfield']++;
435 if (!empty($conf->banque->enabled))
438 if ($obj->fk_bank > 0)
441 $accountstatic->id = $obj->bid;
442 $accountstatic->ref = $obj->bref;
443 $accountstatic->number = $obj->bnumber;
445 if (!empty($conf->accounting->enabled))
447 $accountstatic->account_number = $obj->account_number;
450 $accountingjournal->fetch($obj->fk_accountancy_journal);
452 $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
454 $accountstatic->label = $obj->blabel;
455 print $accountstatic->getNomUrl(1);
456 }
else print
' ';
458 if (!$i) $totalarray[
'nbfield']++;
462 print
'<td class="nowrap right">'.price($obj->amount).
'</td>';
463 if (!$i) $totalarray[
'nbfield']++;
464 if (!$i) $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalttcfield';
465 $totalarray[
'val'][
'totalttcfield'] += $obj->amount;
468 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
470 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
471 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object);
472 print $hookmanager->resPrint;
474 print
'<td class="nowrap center">';
475 if ($massactionbutton || $massaction)
478 if (in_array($object->id, $arrayofselected)) $selected = 1;
479 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
482 if (!$i) $totalarray[
'nbfield']++;
490 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
497 foreach ($arrayfields as $key => $val) {
if (!empty($val[
'checked'])) $colspan++; }
498 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
504 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
505 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
506 print $hookmanager->resPrint;
508 print
'</table>'.
"\n";
511 print
'</form>'.
"\n";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Class to manage salary payments.
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_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
Class to manage bank accounts.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
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.
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...
print $_SERVER["PHP_SELF"]
Edit parameters.
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...
Class to manage accounting accounts.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.