27 require
'../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
35 $langs->loadLangs(array(
"holiday"));
46 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
47 $massaction =
GETPOST(
'massaction',
'alpha');
48 $contextpage =
GETPOST(
'contextpage',
'aZ');
49 $optioncss =
GETPOST(
'optioncss',
'aZ');
51 $search_ref =
GETPOST(
'search_ref',
'alphanohtml');
52 $search_employee =
GETPOST(
'search_employee',
'int');
53 $search_type =
GETPOST(
'search_type',
'int');
54 $search_description =
GETPOST(
'search_description',
'alphanohtml');
56 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
57 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
58 $sortorder =
GETPOST(
'sortorder',
'alpha');
60 if (!$sortfield) $sortfield =
"cp.rowid";
61 if (!$sortorder) $sortorder =
"ASC";
63 $hookmanager->initHooks(array(
'leavemovementlist'));
65 $arrayfields = array();
66 $arrayofmassactions = array();
72 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
73 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') { $massaction =
''; }
75 $parameters = array();
76 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
77 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
82 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
85 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
88 $search_employee =
'';
90 $search_description =
'';
92 $search_array_options = array();
95 if (
GETPOST(
'button_removefilter_x',
'alpha')
96 ||
GETPOST(
'button_removefilter.x',
'alpha')
97 ||
GETPOST(
'button_removefilter',
'alpha')
98 ||
GETPOST(
'button_search_x',
'alpha')
99 ||
GETPOST(
'button_search.x',
'alpha')
100 ||
GETPOST(
'button_search',
'alpha'))
106 $arrayfields = array(
107 'cp.ref'=>array(
'label'=>$langs->trans(
'Ref'),
'checked'=>1),
108 'cp.fk_user'=>array(
'label'=>$langs->trans(
'Employee'),
'checked'=>1),
109 'ct.label'=>array(
'label'=>$langs->trans(
'Type'),
'checked'=>1),
110 'cp.date_debut'=>array(
'label'=>$langs->trans(
'DateDebCP'),
'checked'=>1),
111 'cp.date_fin'=>array(
'label'=>$langs->trans(
'DateFinCP'),
'checked'=>1),
112 'used_days'=>array(
'label'=>$langs->trans(
'NbUseDaysCPShort'),
'checked'=>1),
113 'date_start_month'=>array(
'label'=>$langs->trans(
'DateStartInMonth'),
'checked'=>1),
114 'date_end_month'=>array(
'label'=>$langs->trans(
'DateEndInMonth'),
'checked'=>1),
115 'used_days_month'=>array(
'label'=>$langs->trans(
'NbUseDaysCPShortInMonth'),
'checked'=>1),
116 'cp.description'=>array(
'label'=>$langs->trans(
'DescCP'),
'checked'=>1),
124 $form =
new Form($db);
126 $holidaystatic =
new Holiday($db);
128 $listhalfday = array(
'morning'=>$langs->trans(
"Morning"),
"afternoon"=>$langs->trans(
"Afternoon"));
130 llxHeader(
'', $langs->trans(
'CPTitreMenu'));
132 $search_month =
GETPOST(
"remonth",
'int') ?
GETPOST(
"remonth",
'int') : date(
"m", time());
133 $search_year =
GETPOST(
"reyear",
'int') ?
GETPOST(
"reyear",
'int') : date(
"Y", time());
134 $year_month = sprintf(
"%04d", $search_year).
'-'.sprintf(
"%02d", $search_month);
136 $sql =
"SELECT cp.rowid, cp.ref, cp.fk_user, cp.date_debut, cp.date_fin, ct.label, cp.description, cp.halfday";
137 $sql .=
" FROM ".MAIN_DB_PREFIX.
"holiday cp";
138 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user u ON cp.fk_user = u.rowid";
139 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_holiday_types ct ON cp.fk_type = ct.rowid";
140 $sql .=
" WHERE cp.rowid > 0";
141 $sql .=
" AND cp.statut = 3";
142 $sql .=
" AND (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month).
"' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month).
"')";
144 if (!empty($search_ref)) $sql .=
natural_search(
'cp.ref', $search_ref);
145 if (!empty($search_employee)) $sql .=
" AND cp.fk_user = '".$db->escape($search_employee).
"'";
146 if (!empty($search_type)) $sql .=
' AND cp.fk_type IN ('.$db->escape($search_type).
')';
147 if (!empty($search_description)) $sql .=
natural_search(
'cp.description', $search_description);
149 $sql .= $db->order($sortfield, $sortorder);
151 $resql = $db->query($sql);
158 $num = $db->num_rows(
$resql);
161 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
162 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
163 if (!empty($search_ref)) $param .=
'&search_ref='.urlencode($search_ref);
164 if (!empty($search_employee)) $param .=
'&search_employee='.urlencode($search_employee);
165 if (!empty($search_type)) $param .=
'&search_type='.urlencode($search_type);
166 if (!empty($search_description)) $param .=
'&search_description='.urlencode($search_description);
168 print '<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
169 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
170 print '<input type="hidden" name="token" value="'.newToken().
'">';
171 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
172 print '<input type="hidden" name="action" value="list">';
173 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
174 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
175 print '<input type="hidden" name="page" value="'.$page.
'">';
176 print '<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
181 print '<div class="tabBar">';
182 print $formother->select_month($search_month,
'remonth', 0, 0,
'minwidth50 maxwidth75imp valignmiddle',
true);
183 print $formother->selectyear($search_year,
'reyear', 0, 10, 5, 0, 0,
'',
'valignmiddle width75',
true);
184 print
'<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans(
"Search")).
'" />';
190 $varpage = empty($contextpage) ?
$_SERVER[
"PHP_SELF"] : $contextpage;
191 $selectedfields =
'';
192 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
193 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
195 print
'<div class="div-table-responsive">';
196 print
'<table class="noborder centpercent">';
198 print
'<tr class="liste_titre">';
201 if (!empty($arrayfields[
'cp.ref'][
'checked'])) {
202 print
'<td class="liste_titre">';
203 print
'<input class="flat maxwidth100" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
208 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) {
209 print
'<td class="liste_titre">';
210 print $form->select_dolusers($search_employee,
"search_employee", 1, null, 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth200');
215 if (!empty($arrayfields[
'ct.label'][
'checked'])) {
216 $typeleaves = $holidaystatic->getTypes(1, -1);
217 $arraytypeleaves = array();
218 foreach ($typeleaves as $key => $val)
220 $labeltoshow = ($langs->trans($val[
'code']) != $val[
'code'] ? $langs->trans($val[
'code']) : $val[
'label']);
221 $arraytypeleaves[$val[
'rowid']] = $labeltoshow;
224 print
'<td class="liste_titre">';
225 print $form->selectarray(
'search_type', $arraytypeleaves, $search_type, 1, 0, 0,
'', 0, 0, 0,
'',
'', 1);
229 if (!empty($arrayfields[
'cp.date_debut'][
'checked'])) print
'<td class="liste_titre"></td>';
230 if (!empty($arrayfields[
'cp.date_fin'][
'checked'])) print
'<td class="liste_titre"></td>';
231 if (!empty($arrayfields[
'used_days'][
'checked'])) print
'<td class="liste_titre"></td>';
232 if (!empty($arrayfields[
'date_start_month'][
'checked'])) print
'<td class="liste_titre"></td>';
233 if (!empty($arrayfields[
'date_end_month'][
'checked'])) print
'<td class="liste_titre"></td>';
234 if (!empty($arrayfields[
'used_days_month'][
'checked'])) print
'<td class="liste_titre"></td>';
237 if (!empty($arrayfields[
'cp.description'][
'checked'])) {
238 print
'<td class="liste_titre">';
239 print
'<input type="text" class="maxwidth100" name="search_description" value="'.$search_description.
'">';
244 print
'<td class="liste_titre maxwidthsearch">';
245 $searchpicto = $form->showFilterButtons();
250 print
'<tr class="liste_titre">';
251 if (!empty($arrayfields[
'cp.ref'][
'checked']))
print_liste_field_titre($arrayfields[
'cp.ref'][
'label'],
$_SERVER[
"PHP_SELF"],
'cp.ref',
'',
'',
'', $sortfield, $sortorder);
252 if (!empty($arrayfields[
'cp.fk_user'][
'checked']))
print_liste_field_titre($arrayfields[
'cp.fk_user'][
'label'],
$_SERVER[
"PHP_SELF"],
'cp.fk_user',
'',
'',
'', $sortfield, $sortorder);
253 if (!empty($arrayfields[
'ct.label'][
'checked']))
print_liste_field_titre($arrayfields[
'ct.label'][
'label'],
$_SERVER[
"PHP_SELF"],
'ct.label',
'',
'',
'', $sortfield, $sortorder);
254 if (!empty($arrayfields[
'cp.date_debut'][
'checked']))
print_liste_field_titre($arrayfields[
'cp.date_debut'][
'label'],
$_SERVER[
"PHP_SELF"],
'cp.date_debut',
'',
'',
'', $sortfield, $sortorder);
255 if (!empty($arrayfields[
'cp.date_fin'][
'checked']))
print_liste_field_titre($arrayfields[
'cp.date_fin'][
'label'],
$_SERVER[
"PHP_SELF"],
'cp.date_fin',
'',
'',
'', $sortfield, $sortorder);
256 if (!empty($arrayfields[
'used_days'][
'checked']))
print_liste_field_titre($arrayfields[
'used_days'][
'label'],
$_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder);
257 if (!empty($arrayfields[
'date_start_month'][
'checked']))
print_liste_field_titre($arrayfields[
'date_start_month'][
'label'],
$_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder);
258 if (!empty($arrayfields[
'date_end_month'][
'checked']))
print_liste_field_titre($arrayfields[
'date_end_month'][
'label'],
$_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder);
259 if (!empty($arrayfields[
'used_days_month'][
'checked']))
print_liste_field_titre($arrayfields[
'used_days_month'][
'label'],
$_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder);
260 if (!empty($arrayfields[
'cp.description'][
'checked']))
print_liste_field_titre($arrayfields[
'cp.description'][
'label'],
$_SERVER[
"PHP_SELF"],
'cp.description',
'',
'',
'', $sortfield, $sortorder);
261 print
getTitleFieldOfList($selectedfields, 0,
$_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
266 print
'<tr><td colspan="10" class="opacitymedium">'.$langs->trans(
'None').
'</td></tr>';
269 while ($obj = $db->fetch_object(
$resql))
271 $user =
new User($db);
272 $user->fetch($obj->fk_user);
274 $date_start = $db->jdate($obj->date_debut,
true);
275 $date_end = $db->jdate($obj->date_fin,
true);
280 $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ?
'afternoon' :
'morning';
281 $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ?
'morning' :
'afternoon';
283 $halfdayinmonth = $obj->halfday;
284 $starthalfdayinmonth = $starthalfday;
285 $endhalfdayinmonth = $endhalfday;
290 $date_start_inmonth = $db->jdate($obj->date_debut,
true);
291 $date_end_inmonth = $db->jdate($obj->date_fin,
true);
292 if ($tmpstart[
'year'] < $search_year || $tmpstart[
'mon'] < $search_month)
295 $starthalfdayinmonth =
'morning';
296 if ($halfdayinmonth == 2) $halfdayinmonth = 1;
297 if ($halfdayinmonth == -1) $halfdayinmonth = 0;
299 if ($tmpend[
'year'] > $search_year || $tmpend[
'mon'] > $search_month)
301 $date_end_inmonth =
dol_get_last_day($search_year, $search_month,
true) - ((24 * 3600) - 1);
302 $endhalfdayinmonth =
'afternoon';
303 if ($halfdayinmonth == 2) $halfdayinmonth = -1;
304 if ($halfdayinmonth == 1) $halfdayinmonth = 0;
308 $holidaystatic->id = $obj->rowid;
309 $holidaystatic->ref = $obj->ref;
311 print
'<tr class="oddeven">';
313 if (!empty($arrayfields[
'cp.ref'][
'checked'])) print
'<td>'.$holidaystatic->getNomUrl(1, 1).
'</td>';
314 if (!empty($arrayfields[
'cp.fk_user'][
'checked'])) print
'<td>'.$user->getFullName($langs).
'</td>';
315 if (!empty($arrayfields[
'ct.label'][
'checked'])) print
'<td>'.$obj->label.
'</td>';
317 if (!empty($arrayfields[
'cp.date_debut'][
'checked']))
319 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_debut),
'day');
320 print
' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfday]).
')</span>';
324 if (!empty($arrayfields[
'cp.date_fin'][
'checked']))
326 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_fin),
'day');
327 print
' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfday]).
')</span>';
331 if (!empty($arrayfields[
'used_days'][
'checked'])) print
'<td class="right">'.num_open_day($date_start, $date_end, 0, 1, $obj->halfday).
'</td>';
333 if (!empty($arrayfields[
'date_start_month'][
'checked']))
335 print
'<td class="center">'.dol_print_date($date_start_inmonth,
'day');
336 print
' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfdayinmonth]).
')</span>';
340 if (!empty($arrayfields[
'date_end_month'][
'checked']))
342 print
'<td class="center">'.dol_print_date($date_end_inmonth,
'day');
343 print
' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfdayinmonth]).
')</span>';
347 if (!empty($arrayfields[
'used_days_month'][
'checked'])) print
'<td class="right">'.num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth).
'</td>';
348 if (!empty($arrayfields[
'cp.description'][
'checked'])) print
'<td class="maxwidth300">'.dol_escape_htmltag(
dolGetFirstLineOfText($obj->description)).
'</td>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class of the module paid holiday.
Class to manage Dolibarr users.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_getdate($timestamp, $fast=false, $forcetimezone= '')
Return an array with locale date info.
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 ...
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.
dolGetFirstLineOfText($text, $nboflines=1, $charset= 'UTF-8')
Return first line of text.
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...
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.