@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) |
59 | 59 | if (GETPOST('search_actioncode', 'array')) { |
60 | 60 | $actioncode = GETPOST('search_actioncode', 'array', 3); |
61 | - if (!count($actioncode)) |
|
62 | - $actioncode = '0'; |
|
63 | -} |
|
64 | -else { |
|
61 | + if (!count($actioncode)) { |
|
62 | + $actioncode = '0'; |
|
63 | + } |
|
64 | + } else { |
|
65 | 65 | $actioncode = GETPOST("search_actioncode", "alpha", 3) ? GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); |
66 | 66 | } |
67 | 67 | if ($actioncode == '' && empty($actioncodearray)) { |
@@ -108,30 +108,36 @@ discard block |
||
108 | 108 | $offset = $limit * $page; |
109 | 109 | if (!$sortorder) { |
110 | 110 | $sortorder = "DESC"; |
111 | - if ($status == 'todo') |
|
112 | - $sortorder = "DESC"; |
|
111 | + if ($status == 'todo') { |
|
112 | + $sortorder = "DESC"; |
|
113 | + } |
|
113 | 114 | //if ($status == 'done') $sortorder="DESC"; |
114 | 115 | } |
115 | 116 | if (!$sortfield) { |
116 | 117 | $sortfield = "a.datep"; |
117 | - if ($status == 'todo') |
|
118 | - $sortfield = "a.datep"; |
|
118 | + if ($status == 'todo') { |
|
119 | + $sortfield = "a.datep"; |
|
120 | + } |
|
119 | 121 | //if ($status == 'done') $sortfield="a.datep2"; |
120 | 122 | } |
121 | 123 | |
122 | 124 | // Security check |
123 | 125 | $socid = GETPOST("search_socid", 'int') ? GETPOST("search_socid", 'int') : GETPOST("socid", 'int'); |
124 | -if ($user->societe_id) |
|
125 | - $socid = $user->societe_id; |
|
126 | +if ($user->societe_id) { |
|
127 | + $socid = $user->societe_id; |
|
128 | +} |
|
126 | 129 | $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); |
127 | -if ($socid < 0) |
|
128 | - $socid = ''; |
|
130 | +if ($socid < 0) { |
|
131 | + $socid = ''; |
|
132 | +} |
|
129 | 133 | |
130 | 134 | $canedit = 1; |
131 | -if (!$user->rights->agenda->myactions->read) |
|
132 | - accessforbidden(); |
|
133 | -if (!$user->rights->agenda->allactions->read) |
|
134 | - $canedit = 0; |
|
135 | +if (!$user->rights->agenda->myactions->read) { |
|
136 | + accessforbidden(); |
|
137 | +} |
|
138 | +if (!$user->rights->agenda->allactions->read) { |
|
139 | + $canedit = 0; |
|
140 | +} |
|
135 | 141 | if (!$user->rights->agenda->allactions->read || $filter == 'mine') { // If no permission to see all, we show only affected to me |
136 | 142 | $filtert = $user->id; |
137 | 143 | } |
@@ -153,8 +159,9 @@ discard block |
||
153 | 159 | // Extra fields |
154 | 160 | if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { |
155 | 161 | foreach ($extrafields->attribute_label as $key => $val) { |
156 | - if (!empty($extrafields->attribute_list[$key])) |
|
157 | - $arrayfields["ef." . $key] = array('label' => $extrafields->attribute_label[$key], 'checked' => $extrafields->attribute_list[$key], 'position' => $extrafields->attribute_pos[$key], 'enabled' => $extrafields->attribute_perms[$key]); |
|
162 | + if (!empty($extrafields->attribute_list[$key])) { |
|
163 | + $arrayfields["ef." . $key] = array('label' => $extrafields->attribute_label[$key], 'checked' => $extrafields->attribute_list[$key], 'position' => $extrafields->attribute_pos[$key], 'enabled' => $extrafields->attribute_perms[$key]); |
|
164 | + } |
|
158 | 165 | } |
159 | 166 | } |
160 | 167 | |
@@ -177,8 +184,9 @@ discard block |
||
177 | 184 | |
178 | 185 | $parameters = array('id' => $socid); |
179 | 186 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
180 | -if ($reshook < 0) |
|
181 | - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
187 | +if ($reshook < 0) { |
|
188 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
189 | +} |
|
182 | 190 | |
183 | 191 | // Selection of new fields |
184 | 192 | include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; |
@@ -215,59 +223,82 @@ discard block |
||
215 | 223 | $listofextcals = array(); |
216 | 224 | |
217 | 225 | $param = ''; |
218 | -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) |
|
219 | - $param .= '&contextpage=' . urlencode($contextpage); |
|
220 | -if ($limit > 0 && $limit != $conf->liste_limit) |
|
221 | - $param .= '&limit=' . urlencode($limit); |
|
226 | +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { |
|
227 | + $param .= '&contextpage=' . urlencode($contextpage); |
|
228 | +} |
|
229 | +if ($limit > 0 && $limit != $conf->liste_limit) { |
|
230 | + $param .= '&limit=' . urlencode($limit); |
|
231 | +} |
|
222 | 232 | if ($actioncode != '') { |
223 | 233 | if (is_array($actioncode)) { |
224 | - foreach ($actioncode as $str_action) |
|
225 | - $param .= "&search_actioncode[]=" . urlencode($str_action); |
|
226 | - } else |
|
227 | - $param .= "&search_actioncode=" . urlencode($actioncode); |
|
228 | -} |
|
229 | -if ($resourceid > 0) |
|
230 | - $param .= "&search_resourceid=" . urlencode($resourceid); |
|
231 | -if ($status != '' && $status > -1) |
|
232 | - $param .= "&search_status=" . urlencode($status); |
|
233 | -if ($filter) |
|
234 | - $param .= "&search_filter=" . urlencode($filter); |
|
235 | -if ($filtert) |
|
236 | - $param .= "&search_filtert=" . urlencode($filtert); |
|
237 | -if ($socid) |
|
238 | - $param .= "&search_socid=" . urlencode($socid); |
|
239 | -if ($showbirthday) |
|
240 | - $param .= "&search_showbirthday=1"; |
|
241 | -if ($pid) |
|
242 | - $param .= "&search_projectid=" . urlencode($pid); |
|
243 | -if ($type) |
|
244 | - $param .= "&search_type=" . urlencode($type); |
|
245 | -if ($usergroup) |
|
246 | - $param .= "&search_usergroup=" . urlencode($usergroup); |
|
247 | -if ($search_id != '') |
|
248 | - $param .= '&search_title=' . urlencode($search_id); |
|
249 | -if ($search_title != '') |
|
250 | - $param .= '&search_title=' . urlencode($search_title); |
|
251 | -if (GETPOST('datestartday', 'int')) |
|
252 | - $param .= '&datestartday=' . GETPOST('datestartday', 'int'); |
|
253 | -if (GETPOST('datestartmonth', 'int')) |
|
254 | - $param .= '&datestartmonth=' . GETPOST('datestartmonth', 'int'); |
|
255 | -if (GETPOST('datestartyear', 'int')) |
|
256 | - $param .= '&datestartyear=' . GETPOST('datestartyear', 'int'); |
|
257 | -if (GETPOST('dateendday', 'int')) |
|
258 | - $param .= '&dateendday=' . GETPOST('dateendday', 'int'); |
|
259 | -if (GETPOST('dateendmonth', 'int')) |
|
260 | - $param .= '&dateendmonth=' . GETPOST('dateendmonth', 'int'); |
|
261 | -if (GETPOST('dateendyear', 'int')) |
|
262 | - $param .= '&dateendyear=' . GETPOST('dateendyear', 'int'); |
|
263 | -if ($optioncss != '') |
|
264 | - $param .= '&optioncss=' . urlencode($optioncss); |
|
234 | + foreach ($actioncode as $str_action) { |
|
235 | + $param .= "&search_actioncode[]=" . urlencode($str_action); |
|
236 | + } |
|
237 | + } else { |
|
238 | + $param .= "&search_actioncode=" . urlencode($actioncode); |
|
239 | + } |
|
240 | + } |
|
241 | +if ($resourceid > 0) { |
|
242 | + $param .= "&search_resourceid=" . urlencode($resourceid); |
|
243 | +} |
|
244 | +if ($status != '' && $status > -1) { |
|
245 | + $param .= "&search_status=" . urlencode($status); |
|
246 | +} |
|
247 | +if ($filter) { |
|
248 | + $param .= "&search_filter=" . urlencode($filter); |
|
249 | +} |
|
250 | +if ($filtert) { |
|
251 | + $param .= "&search_filtert=" . urlencode($filtert); |
|
252 | +} |
|
253 | +if ($socid) { |
|
254 | + $param .= "&search_socid=" . urlencode($socid); |
|
255 | +} |
|
256 | +if ($showbirthday) { |
|
257 | + $param .= "&search_showbirthday=1"; |
|
258 | +} |
|
259 | +if ($pid) { |
|
260 | + $param .= "&search_projectid=" . urlencode($pid); |
|
261 | +} |
|
262 | +if ($type) { |
|
263 | + $param .= "&search_type=" . urlencode($type); |
|
264 | +} |
|
265 | +if ($usergroup) { |
|
266 | + $param .= "&search_usergroup=" . urlencode($usergroup); |
|
267 | +} |
|
268 | +if ($search_id != '') { |
|
269 | + $param .= '&search_title=' . urlencode($search_id); |
|
270 | +} |
|
271 | +if ($search_title != '') { |
|
272 | + $param .= '&search_title=' . urlencode($search_title); |
|
273 | +} |
|
274 | +if (GETPOST('datestartday', 'int')) { |
|
275 | + $param .= '&datestartday=' . GETPOST('datestartday', 'int'); |
|
276 | +} |
|
277 | +if (GETPOST('datestartmonth', 'int')) { |
|
278 | + $param .= '&datestartmonth=' . GETPOST('datestartmonth', 'int'); |
|
279 | +} |
|
280 | +if (GETPOST('datestartyear', 'int')) { |
|
281 | + $param .= '&datestartyear=' . GETPOST('datestartyear', 'int'); |
|
282 | +} |
|
283 | +if (GETPOST('dateendday', 'int')) { |
|
284 | + $param .= '&dateendday=' . GETPOST('dateendday', 'int'); |
|
285 | +} |
|
286 | +if (GETPOST('dateendmonth', 'int')) { |
|
287 | + $param .= '&dateendmonth=' . GETPOST('dateendmonth', 'int'); |
|
288 | +} |
|
289 | +if (GETPOST('dateendyear', 'int')) { |
|
290 | + $param .= '&dateendyear=' . GETPOST('dateendyear', 'int'); |
|
291 | +} |
|
292 | +if ($optioncss != '') { |
|
293 | + $param .= '&optioncss=' . urlencode($optioncss); |
|
294 | +} |
|
265 | 295 | // Add $param from extra fields |
266 | 296 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php'; |
267 | 297 | |
268 | 298 | $sql = "SELECT"; |
269 | -if ($usergroup > 0) |
|
270 | - $sql .= " DISTINCT"; |
|
299 | +if ($usergroup > 0) { |
|
300 | + $sql .= " DISTINCT"; |
|
301 | +} |
|
271 | 302 | $sql .= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,"; |
272 | 303 | $sql .= " a.id, a.label, a.datep as dp, a.datep2 as dp2,"; |
273 | 304 | $sql .= ' a.fk_user_author,a.fk_user_action,'; |
@@ -276,45 +307,51 @@ discard block |
||
276 | 307 | $sql .= " c.code as type_code, c.libelle as type_label,"; |
277 | 308 | $sql .= " sp.lastname, sp.firstname, sp.email, sp.phone, sp.address, sp.phone as phone_pro, sp.phone_mobile, sp.phone_perso, sp.fk_pays as country_id"; |
278 | 309 | // Add fields from extrafields |
279 | -foreach ($extrafields->attribute_label as $key => $val) |
|
280 | - $sql .= ($extrafields->attribute_type[$key] != 'separate' ? ",ef." . $key . ' as options_' . $key : ''); |
|
310 | +foreach ($extrafields->attribute_label as $key => $val) { |
|
311 | + $sql .= ($extrafields->attribute_type[$key] != 'separate' ? ",ef." . $key . ' as options_' . $key : ''); |
|
312 | +} |
|
281 | 313 | $sql .= " FROM " . MAIN_DB_PREFIX . "actioncomm as a"; |
282 | 314 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "actioncomm_extrafields as ef ON (a.id = ef.fk_object) "; |
283 | -if (!$user->rights->societe->client->voir && !$socid) |
|
284 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
315 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
316 | + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
317 | +} |
|
285 | 318 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON a.fk_soc = s.rowid"; |
286 | 319 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "socpeople as sp ON a.fk_contact = sp.rowid"; |
287 | 320 | $sql .= " ," . MAIN_DB_PREFIX . "c_actioncomm as c"; |
288 | 321 | // We must filter on resource table |
289 | -if ($resourceid > 0) |
|
290 | - $sql .= ", " . MAIN_DB_PREFIX . "element_resources as r"; |
|
322 | +if ($resourceid > 0) { |
|
323 | + $sql .= ", " . MAIN_DB_PREFIX . "element_resources as r"; |
|
324 | +} |
|
291 | 325 | // We must filter on assignement table |
292 | -if ($filtert > 0 || $usergroup > 0) |
|
293 | - $sql .= ", " . MAIN_DB_PREFIX . "actioncomm_resources as ar"; |
|
294 | -if ($usergroup > 0) |
|
295 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
326 | +if ($filtert > 0 || $usergroup > 0) { |
|
327 | + $sql .= ", " . MAIN_DB_PREFIX . "actioncomm_resources as ar"; |
|
328 | +} |
|
329 | +if ($usergroup > 0) { |
|
330 | + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
331 | +} |
|
296 | 332 | $sql .= " WHERE c.id = a.fk_action"; |
297 | 333 | $sql .= ' AND a.entity IN (' . getEntity('agenda') . ')'; |
298 | 334 | // Condition on actioncode |
299 | 335 | if (!empty($actioncode)) { |
300 | 336 | if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { |
301 | - if ($actioncode == 'AC_NON_AUTO') |
|
302 | - $sql .= " AND c.type != 'systemauto'"; |
|
303 | - elseif ($actioncode == 'AC_ALL_AUTO') |
|
304 | - $sql .= " AND c.type = 'systemauto'"; |
|
305 | - else { |
|
306 | - if ($actioncode == 'AC_OTH') |
|
307 | - $sql .= " AND c.type != 'systemauto'"; |
|
308 | - if ($actioncode == 'AC_OTH_AUTO') |
|
309 | - $sql .= " AND c.type = 'systemauto'"; |
|
337 | + if ($actioncode == 'AC_NON_AUTO') { |
|
338 | + $sql .= " AND c.type != 'systemauto'"; |
|
339 | + } elseif ($actioncode == 'AC_ALL_AUTO') { |
|
340 | + $sql .= " AND c.type = 'systemauto'"; |
|
341 | + } else { |
|
342 | + if ($actioncode == 'AC_OTH') { |
|
343 | + $sql .= " AND c.type != 'systemauto'"; |
|
344 | + } |
|
345 | + if ($actioncode == 'AC_OTH_AUTO') { |
|
346 | + $sql .= " AND c.type = 'systemauto'"; |
|
347 | + } |
|
310 | 348 | } |
311 | - } |
|
312 | - else { |
|
313 | - if ($actioncode == 'AC_NON_AUTO') |
|
314 | - $sql .= " AND c.type != 'systemauto'"; |
|
315 | - elseif ($actioncode == 'AC_ALL_AUTO') |
|
316 | - $sql .= " AND c.type = 'systemauto'"; |
|
317 | - else { |
|
349 | + } else { |
|
350 | + if ($actioncode == 'AC_NON_AUTO') { |
|
351 | + $sql .= " AND c.type != 'systemauto'"; |
|
352 | + } elseif ($actioncode == 'AC_ALL_AUTO') { |
|
353 | + $sql .= " AND c.type = 'systemauto'"; |
|
354 | + } else { |
|
318 | 355 | if (is_array($actioncode)) { |
319 | 356 | $sql .= " AND c.code IN ('" . implode("','", $actioncode) . "')"; |
320 | 357 | } else { |
@@ -323,19 +360,25 @@ discard block |
||
323 | 360 | } |
324 | 361 | } |
325 | 362 | } |
326 | -if ($resourceid > 0) |
|
327 | - $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = " . $db->escape($resourceid); |
|
328 | -if ($pid) |
|
329 | - $sql .= " AND a.fk_project=" . $db->escape($pid); |
|
330 | -if (!$user->rights->societe->client->voir && !$socid) |
|
331 | - $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = " . $user->id . ")"; |
|
332 | -if ($socid > 0) |
|
333 | - $sql .= " AND s.rowid = " . $socid; |
|
363 | +if ($resourceid > 0) { |
|
364 | + $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = " . $db->escape($resourceid); |
|
365 | +} |
|
366 | +if ($pid) { |
|
367 | + $sql .= " AND a.fk_project=" . $db->escape($pid); |
|
368 | +} |
|
369 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
370 | + $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = " . $user->id . ")"; |
|
371 | +} |
|
372 | +if ($socid > 0) { |
|
373 | + $sql .= " AND s.rowid = " . $socid; |
|
374 | +} |
|
334 | 375 | // We must filter on assignement table |
335 | -if ($filtert > 0 || $usergroup > 0) |
|
336 | - $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
337 | -if ($type) |
|
338 | - $sql .= " AND c.id = " . $type; |
|
376 | +if ($filtert > 0 || $usergroup > 0) { |
|
377 | + $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
378 | +} |
|
379 | +if ($type) { |
|
380 | + $sql .= " AND c.id = " . $type; |
|
381 | +} |
|
339 | 382 | if ($status == '0') { |
340 | 383 | $sql .= " AND a.percent = 0"; |
341 | 384 | } |
@@ -354,27 +397,35 @@ discard block |
||
354 | 397 | if ($status == 'todo') { |
355 | 398 | $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; |
356 | 399 | } |
357 | -if ($search_id) |
|
358 | - $sql .= natural_search("a.id", $search_id, 1); |
|
359 | -if ($search_title) |
|
360 | - $sql .= natural_search("a.label", $search_title); |
|
400 | +if ($search_id) { |
|
401 | + $sql .= natural_search("a.id", $search_id, 1); |
|
402 | +} |
|
403 | +if ($search_title) { |
|
404 | + $sql .= natural_search("a.label", $search_title); |
|
405 | +} |
|
361 | 406 | // We must filter on assignement table |
362 | 407 | if ($filtert > 0 || $usergroup > 0) { |
363 | 408 | $sql .= " AND ("; |
364 | - if ($filtert > 0) |
|
365 | - $sql .= "(ar.fk_element = " . $filtert . " OR (ar.fk_element IS NULL AND a.fk_user_action=" . $filtert . "))"; // The OR is for backward compatibility |
|
366 | - if ($usergroup > 0) |
|
367 | - $sql .= ($filtert > 0 ? " OR " : "") . " ugu.fk_usergroup = " . $usergroup; |
|
409 | + if ($filtert > 0) { |
|
410 | + $sql .= "(ar.fk_element = " . $filtert . " OR (ar.fk_element IS NULL AND a.fk_user_action=" . $filtert . "))"; |
|
411 | + } |
|
412 | + // The OR is for backward compatibility |
|
413 | + if ($usergroup > 0) { |
|
414 | + $sql .= ($filtert > 0 ? " OR " : "") . " ugu.fk_usergroup = " . $usergroup; |
|
415 | + } |
|
368 | 416 | $sql .= ")"; |
369 | 417 | } |
370 | 418 | |
371 | 419 | // The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case) |
372 | -if ($dateselect > 0) |
|
373 | - $sql .= " AND ((a.datep2 >= '" . $db->idate($dateselect) . "' AND a.datep <= '" . $db->idate($dateselect + 3600 * 24 - 1) . "') OR (a.datep2 IS NULL AND a.datep > '" . $db->idate($dateselect - 3600) . "' AND a.datep <= '" . $db->idate($dateselect + 3600 * 24 - 1) . "'))"; |
|
374 | -if ($datestart > 0) |
|
375 | - $sql .= " AND a.datep BETWEEN '" . $db->idate($datestart) . "' AND '" . $db->idate($datestart + 3600 * 24 - 1) . "'"; |
|
376 | -if ($dateend > 0) |
|
377 | - $sql .= " AND a.datep2 BETWEEN '" . $db->idate($dateend) . "' AND '" . $db->idate($dateend + 3600 * 24 - 1) . "'"; |
|
420 | +if ($dateselect > 0) { |
|
421 | + $sql .= " AND ((a.datep2 >= '" . $db->idate($dateselect) . "' AND a.datep <= '" . $db->idate($dateselect + 3600 * 24 - 1) . "') OR (a.datep2 IS NULL AND a.datep > '" . $db->idate($dateselect - 3600) . "' AND a.datep <= '" . $db->idate($dateselect + 3600 * 24 - 1) . "'))"; |
|
422 | +} |
|
423 | +if ($datestart > 0) { |
|
424 | + $sql .= " AND a.datep BETWEEN '" . $db->idate($datestart) . "' AND '" . $db->idate($datestart + 3600 * 24 - 1) . "'"; |
|
425 | +} |
|
426 | +if ($dateend > 0) { |
|
427 | + $sql .= " AND a.datep2 BETWEEN '" . $db->idate($dateend) . "' AND '" . $db->idate($dateend + 3600 * 24 - 1) . "'"; |
|
428 | +} |
|
378 | 429 | // Add where from extra fields |
379 | 430 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php'; |
380 | 431 | |
@@ -411,8 +462,9 @@ discard block |
||
411 | 462 | |
412 | 463 | print '<form method="POST" id="searchFormList" class="listactionsfilter" action="' . $_SERVER["PHP_SELF"] . '">' . "\n"; |
413 | 464 | |
414 | - if ($optioncss != '') |
|
415 | - print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; |
|
465 | + if ($optioncss != '') { |
|
466 | + print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; |
|
467 | + } |
|
416 | 468 | print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; |
417 | 469 | print '<input type="hidden" name="action" value="list">'; |
418 | 470 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
@@ -424,12 +476,14 @@ discard block |
||
424 | 476 | |
425 | 477 | //if ($actioncode) $nav.='<input type="hidden" name="actioncode" value="'.$actioncode.'">'; |
426 | 478 | //if ($resourceid) $nav.='<input type="hidden" name="resourceid" value="'.$resourceid.'">'; |
427 | - if ($filter) |
|
428 | - $nav .= '<input type="hidden" name="search_filter" value="' . $filter . '">'; |
|
479 | + if ($filter) { |
|
480 | + $nav .= '<input type="hidden" name="search_filter" value="' . $filter . '">'; |
|
481 | + } |
|
429 | 482 | //if ($filtert) $nav.='<input type="hidden" name="filtert" value="'.$filtert.'">'; |
430 | 483 | //if ($socid) $nav.='<input type="hidden" name="socid" value="'.$socid.'">'; |
431 | - if ($showbirthday) |
|
432 | - $nav .= '<input type="hidden" name="search_showbirthday" value="1">'; |
|
484 | + if ($showbirthday) { |
|
485 | + $nav .= '<input type="hidden" name="search_showbirthday" value="1">'; |
|
486 | + } |
|
433 | 487 | //if ($pid) $nav.='<input type="hidden" name="projectid" value="'.$pid.'">'; |
434 | 488 | //if ($usergroup) $nav.='<input type="hidden" name="usergroup" value="'.$usergroup.'">'; |
435 | 489 | print $nav; |
@@ -486,21 +540,26 @@ discard block |
||
486 | 540 | |
487 | 541 | $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; |
488 | 542 | $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
489 | - if ($massactionbutton) |
|
490 | - $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); |
|
543 | + if ($massactionbutton) { |
|
544 | + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); |
|
545 | + } |
|
491 | 546 | $i = 0; |
492 | 547 | print '<div class="div-table-responsive">'; |
493 | 548 | print '<table class="tagtable liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n"; |
494 | 549 | |
495 | 550 | print '<tr class="liste_titre_filter">'; |
496 | - if (!empty($arrayfields['a.id']['checked'])) |
|
497 | - print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="' . $search_id . '"></td>'; |
|
498 | - if (!empty($arrayfields['owner']['checked'])) |
|
499 | - print '<td class="liste_titre"></td>'; |
|
500 | - if (!empty($arrayfields['c.libelle']['checked'])) |
|
501 | - print '<td class="liste_titre"></td>'; |
|
502 | - if (!empty($arrayfields['a.label']['checked'])) |
|
503 | - print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="' . $search_title . '"></td>'; |
|
551 | + if (!empty($arrayfields['a.id']['checked'])) { |
|
552 | + print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="' . $search_id . '"></td>'; |
|
553 | + } |
|
554 | + if (!empty($arrayfields['owner']['checked'])) { |
|
555 | + print '<td class="liste_titre"></td>'; |
|
556 | + } |
|
557 | + if (!empty($arrayfields['c.libelle']['checked'])) { |
|
558 | + print '<td class="liste_titre"></td>'; |
|
559 | + } |
|
560 | + if (!empty($arrayfields['a.label']['checked'])) { |
|
561 | + print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="' . $search_title . '"></td>'; |
|
562 | + } |
|
504 | 563 | if (!empty($arrayfields['a.datep']['checked'])) { |
505 | 564 | print '<td class="liste_titre nowraponall" align="center">'; |
506 | 565 | print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0); |
@@ -514,10 +573,12 @@ discard block |
||
514 | 573 | if (!empty($arrayfields['s.nom']['checked'])) { |
515 | 574 | print '<td class="liste_titre"></td>'; |
516 | 575 | } |
517 | - if (!empty($arrayfields['a.fk_contact']['checked'])) |
|
518 | - print '<td class="liste_titre"></td>'; |
|
519 | - if (!empty($arrayfields['a.fk_element']['checked'])) |
|
520 | - print '<td class="liste_titre"></td>'; |
|
576 | + if (!empty($arrayfields['a.fk_contact']['checked'])) { |
|
577 | + print '<td class="liste_titre"></td>'; |
|
578 | + } |
|
579 | + if (!empty($arrayfields['a.fk_element']['checked'])) { |
|
580 | + print '<td class="liste_titre"></td>'; |
|
581 | + } |
|
521 | 582 | |
522 | 583 | // Extra fields |
523 | 584 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php'; |
@@ -527,10 +588,12 @@ discard block |
||
527 | 588 | $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook |
528 | 589 | print $hookmanager->resPrint; |
529 | 590 | |
530 | - if (!empty($arrayfields['a.datec']['checked'])) |
|
531 | - print '<td class="liste_titre"></td>'; |
|
532 | - if (!empty($arrayfields['a.tms']['checked'])) |
|
533 | - print '<td class="liste_titre"></td>'; |
|
591 | + if (!empty($arrayfields['a.datec']['checked'])) { |
|
592 | + print '<td class="liste_titre"></td>'; |
|
593 | + } |
|
594 | + if (!empty($arrayfields['a.tms']['checked'])) { |
|
595 | + print '<td class="liste_titre"></td>'; |
|
596 | + } |
|
534 | 597 | if (!empty($arrayfields['a.percent']['checked'])) { |
535 | 598 | print '<td class="liste_titre center">'; |
536 | 599 | print $formactions->form_select_status_action('formaction', $status, 1, 'status', 1, 2); |
@@ -545,25 +608,34 @@ discard block |
||
545 | 608 | print "</tr>\n"; |
546 | 609 | |
547 | 610 | print '<tr class="liste_titre">'; |
548 | - if (!empty($arrayfields['a.id']['checked'])) |
|
549 | - print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder); |
|
550 | - if (!empty($arrayfields['owner']['checked'])) |
|
551 | - print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); |
|
552 | - if (!empty($arrayfields['c.libelle']['checked'])) |
|
553 | - print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder); |
|
554 | - if (!empty($arrayfields['a.label']['checked'])) |
|
555 | - print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder); |
|
611 | + if (!empty($arrayfields['a.id']['checked'])) { |
|
612 | + print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder); |
|
613 | + } |
|
614 | + if (!empty($arrayfields['owner']['checked'])) { |
|
615 | + print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); |
|
616 | + } |
|
617 | + if (!empty($arrayfields['c.libelle']['checked'])) { |
|
618 | + print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder); |
|
619 | + } |
|
620 | + if (!empty($arrayfields['a.label']['checked'])) { |
|
621 | + print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder); |
|
622 | + } |
|
556 | 623 | //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
557 | - if (!empty($arrayfields['a.datep']['checked'])) |
|
558 | - print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep", $param, '', 'align="center"', $sortfield, $sortorder); |
|
559 | - if (!empty($arrayfields['a.datep2']['checked'])) |
|
560 | - print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); |
|
561 | - if (!empty($arrayfields['s.nom']['checked'])) |
|
562 | - print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); |
|
563 | - if (!empty($arrayfields['a.fk_contact']['checked'])) |
|
564 | - print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "a.fk_contact", $param, "", "", $sortfield, $sortorder); |
|
565 | - if (!empty($arrayfields['a.fk_element']['checked'])) |
|
566 | - print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "a.fk_element", $param, "", "", $sortfield, $sortorder); |
|
624 | + if (!empty($arrayfields['a.datep']['checked'])) { |
|
625 | + print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep", $param, '', 'align="center"', $sortfield, $sortorder); |
|
626 | + } |
|
627 | + if (!empty($arrayfields['a.datep2']['checked'])) { |
|
628 | + print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); |
|
629 | + } |
|
630 | + if (!empty($arrayfields['s.nom']['checked'])) { |
|
631 | + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); |
|
632 | + } |
|
633 | + if (!empty($arrayfields['a.fk_contact']['checked'])) { |
|
634 | + print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "a.fk_contact", $param, "", "", $sortfield, $sortorder); |
|
635 | + } |
|
636 | + if (!empty($arrayfields['a.fk_element']['checked'])) { |
|
637 | + print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "a.fk_element", $param, "", "", $sortfield, $sortorder); |
|
638 | + } |
|
567 | 639 | |
568 | 640 | // Extra fields |
569 | 641 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php'; |
@@ -573,13 +645,16 @@ discard block |
||
573 | 645 | $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook |
574 | 646 | print $hookmanager->resPrint; |
575 | 647 | |
576 | - if (!empty($arrayfields['a.datec']['checked'])) |
|
577 | - print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder); |
|
578 | - if (!empty($arrayfields['a.tms']['checked'])) |
|
579 | - print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder); |
|
648 | + if (!empty($arrayfields['a.datec']['checked'])) { |
|
649 | + print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder); |
|
650 | + } |
|
651 | + if (!empty($arrayfields['a.tms']['checked'])) { |
|
652 | + print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder); |
|
653 | + } |
|
580 | 654 | |
581 | - if (!empty($arrayfields['a.percent']['checked'])) |
|
582 | - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder); |
|
655 | + if (!empty($arrayfields['a.percent']['checked'])) { |
|
656 | + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder); |
|
657 | + } |
|
583 | 658 | print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); |
584 | 659 | print "</tr>\n"; |
585 | 660 | |
@@ -622,8 +697,9 @@ discard block |
||
622 | 697 | if ($obj->fk_user_action > 0) { |
623 | 698 | $userstatic->fetch($obj->fk_user_action); |
624 | 699 | print $userstatic->getNomUrl(-1); |
625 | - } else |
|
626 | - print ' '; |
|
700 | + } else { |
|
701 | + print ' '; |
|
702 | + } |
|
627 | 703 | print '</td>'; |
628 | 704 | } |
629 | 705 | |
@@ -631,28 +707,31 @@ discard block |
||
631 | 707 | if (!empty($arrayfields['c.libelle']['checked'])) { |
632 | 708 | print '<td>'; |
633 | 709 | if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { |
634 | - if ($actionstatic->type_picto) |
|
635 | - print img_picto('', $actionstatic->type_picto); |
|
636 | - else { |
|
637 | - if ($actionstatic->type_code == 'AC_RDV') |
|
638 | - print img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright') . ' '; |
|
639 | - elseif ($actionstatic->type_code == 'AC_TEL') |
|
640 | - print img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright') . ' '; |
|
641 | - elseif ($actionstatic->type_code == 'AC_FAX') |
|
642 | - print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright') . ' '; |
|
643 | - elseif ($actionstatic->type_code == 'AC_EMAIL') |
|
644 | - print img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright') . ' '; |
|
645 | - elseif ($actionstatic->type_code == 'AC_INT') |
|
646 | - print img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright') . ' '; |
|
647 | - elseif (!preg_match('/_AUTO/', $actionstatic->type_code)) |
|
648 | - print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright') . ' '; |
|
710 | + if ($actionstatic->type_picto) { |
|
711 | + print img_picto('', $actionstatic->type_picto); |
|
712 | + } else { |
|
713 | + if ($actionstatic->type_code == 'AC_RDV') { |
|
714 | + print img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright') . ' '; |
|
715 | + } elseif ($actionstatic->type_code == 'AC_TEL') { |
|
716 | + print img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright') . ' '; |
|
717 | + } elseif ($actionstatic->type_code == 'AC_FAX') { |
|
718 | + print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright') . ' '; |
|
719 | + } elseif ($actionstatic->type_code == 'AC_EMAIL') { |
|
720 | + print img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright') . ' '; |
|
721 | + } elseif ($actionstatic->type_code == 'AC_INT') { |
|
722 | + print img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright') . ' '; |
|
723 | + } elseif (!preg_match('/_AUTO/', $actionstatic->type_code)) { |
|
724 | + print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright') . ' '; |
|
725 | + } |
|
649 | 726 | } |
650 | 727 | } |
651 | 728 | $labeltype = $obj->type_code; |
652 | - if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) |
|
653 | - $labeltype = 'AC_OTH'; |
|
654 | - if (!empty($arraylist[$labeltype])) |
|
655 | - $labeltype = $arraylist[$labeltype]; |
|
729 | + if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) { |
|
730 | + $labeltype = 'AC_OTH'; |
|
731 | + } |
|
732 | + if (!empty($arraylist[$labeltype])) { |
|
733 | + $labeltype = $arraylist[$labeltype]; |
|
734 | + } |
|
656 | 735 | print dol_trunc($labeltype, 28); |
657 | 736 | print '</td>'; |
658 | 737 | } |
@@ -669,16 +748,21 @@ discard block |
||
669 | 748 | print '<td align="center">'; |
670 | 749 | print dol_print_date($db->jdate($obj->dp), "dayhour"); |
671 | 750 | $late = 0; |
672 | - if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) |
|
673 | - $late = 1; |
|
674 | - if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) |
|
675 | - $late = 1; |
|
676 | - if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) |
|
677 | - $late = 1; |
|
678 | - if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) |
|
679 | - $late = 1; |
|
680 | - if ($late) |
|
681 | - print img_warning($langs->trans("Late")) . ' '; |
|
751 | + if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) { |
|
752 | + $late = 1; |
|
753 | + } |
|
754 | + if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) { |
|
755 | + $late = 1; |
|
756 | + } |
|
757 | + if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) { |
|
758 | + $late = 1; |
|
759 | + } |
|
760 | + if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) { |
|
761 | + $late = 1; |
|
762 | + } |
|
763 | + if ($late) { |
|
764 | + print img_warning($langs->trans("Late")) . ' '; |
|
765 | + } |
|
682 | 766 | print '</td>'; |
683 | 767 | } |
684 | 768 | |
@@ -699,8 +783,9 @@ discard block |
||
699 | 783 | $societestatic->email = $obj->socemail; |
700 | 784 | |
701 | 785 | print $societestatic->getNomUrl(1, '', 28); |
702 | - } else |
|
703 | - print ' '; |
|
786 | + } else { |
|
787 | + print ' '; |
|
788 | + } |
|
704 | 789 | print '</td>'; |
705 | 790 | } |
706 | 791 |
@@ -43,11 +43,13 @@ discard block |
||
43 | 43 | require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; |
44 | 44 | } |
45 | 45 | |
46 | -if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) |
|
47 | - $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; |
|
46 | +if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) { |
|
47 | + $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; |
|
48 | +} |
|
48 | 49 | |
49 | -if (empty($conf->global->AGENDA_EXT_NB)) |
|
50 | - $conf->global->AGENDA_EXT_NB = 5; |
|
50 | +if (empty($conf->global->AGENDA_EXT_NB)) { |
|
51 | + $conf->global->AGENDA_EXT_NB = 5; |
|
52 | +} |
|
51 | 53 | $MAXAGENDA = $conf->global->AGENDA_EXT_NB; |
52 | 54 | |
53 | 55 | $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); |
@@ -68,24 +70,30 @@ discard block |
||
68 | 70 | } // If $page is not defined, or '' or -1 |
69 | 71 | $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; |
70 | 72 | $offset = $limit * $page; |
71 | -if (!$sortorder) |
|
72 | - $sortorder = "ASC"; |
|
73 | -if (!$sortfield) |
|
74 | - $sortfield = "a.datec"; |
|
73 | +if (!$sortorder) { |
|
74 | + $sortorder = "ASC"; |
|
75 | +} |
|
76 | +if (!$sortfield) { |
|
77 | + $sortfield = "a.datec"; |
|
78 | +} |
|
75 | 79 | |
76 | 80 | // Security check |
77 | 81 | $socid = GETPOST("search_socid", "int") ? GETPOST("search_socid", "int") : GETPOST("socid", "int"); |
78 | -if ($user->societe_id) |
|
79 | - $socid = $user->societe_id; |
|
82 | +if ($user->societe_id) { |
|
83 | + $socid = $user->societe_id; |
|
84 | +} |
|
80 | 85 | $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); |
81 | -if ($socid < 0) |
|
82 | - $socid = ''; |
|
86 | +if ($socid < 0) { |
|
87 | + $socid = ''; |
|
88 | +} |
|
83 | 89 | |
84 | 90 | $canedit = 1; |
85 | -if (!$user->rights->agenda->myactions->read) |
|
86 | - accessforbidden(); |
|
87 | -if (!$user->rights->agenda->allactions->read) |
|
88 | - $canedit = 0; |
|
91 | +if (!$user->rights->agenda->myactions->read) { |
|
92 | + accessforbidden(); |
|
93 | +} |
|
94 | +if (!$user->rights->agenda->allactions->read) { |
|
95 | + $canedit = 0; |
|
96 | +} |
|
89 | 97 | if (!$user->rights->agenda->allactions->read || $filter == 'mine') { // If no permission to see all, we show only affected to me |
90 | 98 | $filtert = $user->id; |
91 | 99 | } |
@@ -103,22 +111,25 @@ discard block |
||
103 | 111 | // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) |
104 | 112 | if (GETPOST('search_actioncode', 'array')) { |
105 | 113 | $actioncode = GETPOST('search_actioncode', 'array', 3); |
106 | - if (!count($actioncode)) |
|
107 | - $actioncode = '0'; |
|
108 | -} |
|
109 | -else { |
|
114 | + if (!count($actioncode)) { |
|
115 | + $actioncode = '0'; |
|
116 | + } |
|
117 | + } else { |
|
110 | 118 | $actioncode = GETPOST("search_actioncode", "alpha", 3) ? GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); |
111 | 119 | } |
112 | -if ($actioncode == '' && empty($actioncodearray)) |
|
113 | - $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); |
|
120 | +if ($actioncode == '' && empty($actioncodearray)) { |
|
121 | + $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); |
|
122 | +} |
|
114 | 123 | |
115 | -if ($status == '' && !GETPOSTISSET('search_status')) |
|
116 | - $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); |
|
124 | +if ($status == '' && !GETPOSTISSET('search_status')) { |
|
125 | + $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); |
|
126 | +} |
|
117 | 127 | |
118 | 128 | $defaultview = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); |
119 | 129 | $defaultview = (empty($user->conf->AGENDA_DEFAULT_VIEW) ? $defaultview : $user->conf->AGENDA_DEFAULT_VIEW); |
120 | -if (empty($action) && !GETPOSTISSET('action')) |
|
121 | - $action = $defaultview; |
|
130 | +if (empty($action) && !GETPOSTISSET('action')) { |
|
131 | + $action = $defaultview; |
|
132 | +} |
|
122 | 133 | if ($action == 'default') { // When action is default, we want a calendar view and not the list |
123 | 134 | $action = (($defaultview != 'show_list') ? $defaultview : 'show_month'); |
124 | 135 | } |
@@ -150,8 +161,9 @@ discard block |
||
150 | 161 | $param = ''; |
151 | 162 | if (is_array($_POST)) { |
152 | 163 | foreach ($_POST as $key => $val) { |
153 | - if ($key == 'token') |
|
154 | - continue; |
|
164 | + if ($key == 'token') { |
|
165 | + continue; |
|
166 | + } |
|
155 | 167 | $param .= '&' . $key . '=' . urlencode($val); |
156 | 168 | } |
157 | 169 | } |
@@ -164,8 +176,9 @@ discard block |
||
164 | 176 | $param = ''; |
165 | 177 | if (is_array($_POST)) { |
166 | 178 | foreach ($_POST as $key => $val) { |
167 | - if ($key == 'token') |
|
168 | - continue; |
|
179 | + if ($key == 'token') { |
|
180 | + continue; |
|
181 | + } |
|
169 | 182 | $param .= '&' . $key . '=' . urlencode($val); |
170 | 183 | } |
171 | 184 | } |
@@ -247,15 +260,18 @@ discard block |
||
247 | 260 | // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday) |
248 | 261 | $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2; // date('w') is 0 fo sunday |
249 | 262 | $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1); |
250 | - if ($tmpday >= 1) |
|
251 | - $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week. |
|
263 | + if ($tmpday >= 1) { |
|
264 | + $tmpday -= 7; |
|
265 | + } |
|
266 | + // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week. |
|
252 | 267 | |
253 | 268 | |
254 | 269 | // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) |
255 | 270 | $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year); |
256 | 271 | $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7; |
257 | - if ($next_day < 6) |
|
258 | - $next_day += 7; |
|
272 | + if ($next_day < 6) { |
|
273 | + $next_day += 7; |
|
274 | + } |
|
259 | 275 | $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year); |
260 | 276 | } |
261 | 277 | if ($action == 'show_week') { |
@@ -303,39 +319,53 @@ discard block |
||
303 | 319 | //print dol_print_date($lastdaytoshow,'day'); |
304 | 320 | |
305 | 321 | $title = $langs->trans("DoneAndToDoActions"); |
306 | -if ($status == 'done') |
|
307 | - $title = $langs->trans("DoneActions"); |
|
308 | -if ($status == 'todo') |
|
309 | - $title = $langs->trans("ToDoActions"); |
|
322 | +if ($status == 'done') { |
|
323 | + $title = $langs->trans("DoneActions"); |
|
324 | +} |
|
325 | +if ($status == 'todo') { |
|
326 | + $title = $langs->trans("ToDoActions"); |
|
327 | +} |
|
310 | 328 | |
311 | 329 | $param = ''; |
312 | 330 | if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) { |
313 | 331 | if (is_array($actioncode)) { |
314 | - foreach ($actioncode as $str_action) |
|
315 | - $param .= "&search_actioncode[]=" . urlencode($str_action); |
|
316 | - } else |
|
317 | - $param .= "&search_actioncode=" . urlencode($actioncode); |
|
318 | -} |
|
319 | -if ($resourceid > 0) |
|
320 | - $param .= "&search_resourceid=" . urlencode($resourceid); |
|
321 | -if ($status || isset($_GET['status']) || isset($_POST['status'])) |
|
322 | - $param .= "&search_status=" . urlencode($status); |
|
323 | -if ($filter) |
|
324 | - $param .= "&search_filter=" . urlencode($filter); |
|
325 | -if ($filtert) |
|
326 | - $param .= "&search_filtert=" . urlencode($filtert); |
|
327 | -if ($usergroup) |
|
328 | - $param .= "&search_usergroup=" . urlencode($usergroup); |
|
329 | -if ($socid) |
|
330 | - $param .= "&search_socid=" . urlencode($socid); |
|
331 | -if ($showbirthday) |
|
332 | - $param .= "&search_showbirthday=1"; |
|
333 | -if ($pid) |
|
334 | - $param .= "&search_projectid=" . urlencode($pid); |
|
335 | -if ($type) |
|
336 | - $param .= "&search_type=" . urlencode($type); |
|
337 | -if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month') |
|
338 | - $param .= '&action=' . urlencode($action); |
|
332 | + foreach ($actioncode as $str_action) { |
|
333 | + $param .= "&search_actioncode[]=" . urlencode($str_action); |
|
334 | + } |
|
335 | + } else { |
|
336 | + $param .= "&search_actioncode=" . urlencode($actioncode); |
|
337 | + } |
|
338 | + } |
|
339 | +if ($resourceid > 0) { |
|
340 | + $param .= "&search_resourceid=" . urlencode($resourceid); |
|
341 | +} |
|
342 | +if ($status || isset($_GET['status']) || isset($_POST['status'])) { |
|
343 | + $param .= "&search_status=" . urlencode($status); |
|
344 | +} |
|
345 | +if ($filter) { |
|
346 | + $param .= "&search_filter=" . urlencode($filter); |
|
347 | +} |
|
348 | +if ($filtert) { |
|
349 | + $param .= "&search_filtert=" . urlencode($filtert); |
|
350 | +} |
|
351 | +if ($usergroup) { |
|
352 | + $param .= "&search_usergroup=" . urlencode($usergroup); |
|
353 | +} |
|
354 | +if ($socid) { |
|
355 | + $param .= "&search_socid=" . urlencode($socid); |
|
356 | +} |
|
357 | +if ($showbirthday) { |
|
358 | + $param .= "&search_showbirthday=1"; |
|
359 | +} |
|
360 | +if ($pid) { |
|
361 | + $param .= "&search_projectid=" . urlencode($pid); |
|
362 | +} |
|
363 | +if ($type) { |
|
364 | + $param .= "&search_type=" . urlencode($type); |
|
365 | +} |
|
366 | +if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month') { |
|
367 | + $param .= '&action=' . urlencode($action); |
|
368 | +} |
|
339 | 369 | $param .= "&maxprint=" . urlencode($maxprint); |
340 | 370 | |
341 | 371 | // Show navigation bar |
@@ -372,22 +402,27 @@ discard block |
||
372 | 402 | |
373 | 403 | |
374 | 404 | $tabactive = ''; |
375 | -if ($action == 'show_month') |
|
376 | - $tabactive = 'cardmonth'; |
|
377 | -if ($action == 'show_week') |
|
378 | - $tabactive = 'cardweek'; |
|
379 | -if ($action == 'show_day') |
|
380 | - $tabactive = 'cardday'; |
|
381 | -if ($action == 'show_list') |
|
382 | - $tabactive = 'cardlist'; |
|
405 | +if ($action == 'show_month') { |
|
406 | + $tabactive = 'cardmonth'; |
|
407 | +} |
|
408 | +if ($action == 'show_week') { |
|
409 | + $tabactive = 'cardweek'; |
|
410 | +} |
|
411 | +if ($action == 'show_day') { |
|
412 | + $tabactive = 'cardday'; |
|
413 | +} |
|
414 | +if ($action == 'show_list') { |
|
415 | + $tabactive = 'cardlist'; |
|
416 | +} |
|
383 | 417 | |
384 | 418 | $paramnoaction = preg_replace('/action=[a-z_]+/', '', $param); |
385 | 419 | |
386 | 420 | $head = calendars_prepare_head($paramnoaction); |
387 | 421 | |
388 | 422 | print '<form method="POST" id="searchFormList" class="listactionsfilter" action="' . $_SERVER["PHP_SELF"] . '">' . "\n"; |
389 | -if ($optioncss != '') |
|
390 | - print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; |
|
423 | +if ($optioncss != '') { |
|
424 | + print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; |
|
425 | +} |
|
391 | 426 | print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; |
392 | 427 | |
393 | 428 | dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); |
@@ -459,15 +494,17 @@ discard block |
||
459 | 494 | } else { // If javascript off |
460 | 495 | $newparam = $param; // newparam is for birthday links |
461 | 496 | $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday=' . (empty($showbirthday) ? 1 : 0), $newparam); |
462 | - if (!preg_match('/showbirthday=/i', $newparam)) |
|
463 | - $newparam .= '&showbirthday=1'; |
|
497 | + if (!preg_match('/showbirthday=/i', $newparam)) { |
|
498 | + $newparam .= '&showbirthday=1'; |
|
499 | + } |
|
464 | 500 | $link = '<a href="' . dol_escape_htmltag($_SERVER['PHP_SELF']); |
465 | 501 | $link .= '?' . dol_escape_htmltag($newparam); |
466 | 502 | $link .= '">'; |
467 | - if (empty($showbirthday)) |
|
468 | - $link .= $langs->trans("AgendaShowBirthdayEvents"); |
|
469 | - else |
|
470 | - $link .= $langs->trans("AgendaHideBirthdayEvents"); |
|
503 | + if (empty($showbirthday)) { |
|
504 | + $link .= $langs->trans("AgendaShowBirthdayEvents"); |
|
505 | + } else { |
|
506 | + $link .= $langs->trans("AgendaHideBirthdayEvents"); |
|
507 | + } |
|
471 | 508 | $link .= '</a>'; |
472 | 509 | } |
473 | 510 | |
@@ -478,8 +515,9 @@ discard block |
||
478 | 515 | $eventarray = array(); |
479 | 516 | |
480 | 517 | $sql = 'SELECT '; |
481 | -if ($usergroup > 0) |
|
482 | - $sql .= " DISTINCT"; |
|
518 | +if ($usergroup > 0) { |
|
519 | + $sql .= " DISTINCT"; |
|
520 | +} |
|
483 | 521 | $sql .= ' a.id, a.label,'; |
484 | 522 | $sql .= ' a.datep,'; |
485 | 523 | $sql .= ' a.datep2,'; |
@@ -490,38 +528,43 @@ discard block |
||
490 | 528 | $sql .= ' a.fk_element, a.elementtype,'; |
491 | 529 | $sql .= ' ca.code as type_code, ca.libelle as type_label, ca.color as type_color'; |
492 | 530 | $sql .= ' FROM ' . MAIN_DB_PREFIX . 'c_actioncomm as ca, ' . MAIN_DB_PREFIX . "actioncomm as a"; |
493 | -if (!$user->rights->societe->client->voir && !$socid) |
|
494 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
531 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
532 | + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
533 | +} |
|
495 | 534 | // We must filter on resource table |
496 | -if ($resourceid > 0) |
|
497 | - $sql .= ", " . MAIN_DB_PREFIX . "element_resources as r"; |
|
535 | +if ($resourceid > 0) { |
|
536 | + $sql .= ", " . MAIN_DB_PREFIX . "element_resources as r"; |
|
537 | +} |
|
498 | 538 | // We must filter on assignement table |
499 | -if ($filtert > 0 || $usergroup > 0) |
|
500 | - $sql .= ", " . MAIN_DB_PREFIX . "actioncomm_resources as ar"; |
|
501 | -if ($usergroup > 0) |
|
502 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
539 | +if ($filtert > 0 || $usergroup > 0) { |
|
540 | + $sql .= ", " . MAIN_DB_PREFIX . "actioncomm_resources as ar"; |
|
541 | +} |
|
542 | +if ($usergroup > 0) { |
|
543 | + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
544 | +} |
|
503 | 545 | $sql .= ' WHERE a.fk_action = ca.id'; |
504 | 546 | $sql .= ' AND a.entity IN (' . getEntity('agenda') . ')'; |
505 | 547 | // Condition on actioncode |
506 | 548 | if (!empty($actioncode)) { |
507 | 549 | if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { |
508 | - if ($actioncode == 'AC_NON_AUTO') |
|
509 | - $sql .= " AND ca.type != 'systemauto'"; |
|
510 | - elseif ($actioncode == 'AC_ALL_AUTO') |
|
511 | - $sql .= " AND ca.type = 'systemauto'"; |
|
512 | - else { |
|
513 | - if ($actioncode == 'AC_OTH') |
|
514 | - $sql .= " AND ca.type != 'systemauto'"; |
|
515 | - if ($actioncode == 'AC_OTH_AUTO') |
|
516 | - $sql .= " AND ca.type = 'systemauto'"; |
|
550 | + if ($actioncode == 'AC_NON_AUTO') { |
|
551 | + $sql .= " AND ca.type != 'systemauto'"; |
|
552 | + } elseif ($actioncode == 'AC_ALL_AUTO') { |
|
553 | + $sql .= " AND ca.type = 'systemauto'"; |
|
554 | + } else { |
|
555 | + if ($actioncode == 'AC_OTH') { |
|
556 | + $sql .= " AND ca.type != 'systemauto'"; |
|
557 | + } |
|
558 | + if ($actioncode == 'AC_OTH_AUTO') { |
|
559 | + $sql .= " AND ca.type = 'systemauto'"; |
|
560 | + } |
|
517 | 561 | } |
518 | - } |
|
519 | - else { |
|
520 | - if ($actioncode == 'AC_NON_AUTO') |
|
521 | - $sql .= " AND ca.type != 'systemauto'"; |
|
522 | - elseif ($actioncode == 'AC_ALL_AUTO') |
|
523 | - $sql .= " AND ca.type = 'systemauto'"; |
|
524 | - else { |
|
562 | + } else { |
|
563 | + if ($actioncode == 'AC_NON_AUTO') { |
|
564 | + $sql .= " AND ca.type != 'systemauto'"; |
|
565 | + } elseif ($actioncode == 'AC_ALL_AUTO') { |
|
566 | + $sql .= " AND ca.type = 'systemauto'"; |
|
567 | + } else { |
|
525 | 568 | if (is_array($actioncode)) { |
526 | 569 | $sql .= " AND ca.code IN ('" . implode("','", $actioncode) . "')"; |
527 | 570 | } else { |
@@ -530,17 +573,22 @@ discard block |
||
530 | 573 | } |
531 | 574 | } |
532 | 575 | } |
533 | -if ($resourceid > 0) |
|
534 | - $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = " . $db->escape($resourceid); |
|
535 | -if ($pid) |
|
536 | - $sql .= " AND a.fk_project=" . $db->escape($pid); |
|
537 | -if (!$user->rights->societe->client->voir && !$socid) |
|
538 | - $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = " . $user->id . ")"; |
|
539 | -if ($socid > 0) |
|
540 | - $sql .= ' AND a.fk_soc = ' . $socid; |
|
576 | +if ($resourceid > 0) { |
|
577 | + $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = " . $db->escape($resourceid); |
|
578 | +} |
|
579 | +if ($pid) { |
|
580 | + $sql .= " AND a.fk_project=" . $db->escape($pid); |
|
581 | +} |
|
582 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
583 | + $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = " . $user->id . ")"; |
|
584 | +} |
|
585 | +if ($socid > 0) { |
|
586 | + $sql .= ' AND a.fk_soc = ' . $socid; |
|
587 | +} |
|
541 | 588 | // We must filter on assignement table |
542 | -if ($filtert > 0 || $usergroup > 0) |
|
543 | - $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
589 | +if ($filtert > 0 || $usergroup > 0) { |
|
590 | + $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
591 | +} |
|
544 | 592 | if ($action == 'show_day') { |
545 | 593 | $sql .= " AND ("; |
546 | 594 | $sql .= " (a.datep BETWEEN '" . $db->idate(dol_mktime(0, 0, 0, $month, $day, $year)) . "'"; |
@@ -565,8 +613,9 @@ discard block |
||
565 | 613 | $sql .= " AND a.datep2 > '" . $db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)) . "')"; |
566 | 614 | $sql .= ')'; |
567 | 615 | } |
568 | -if ($type) |
|
569 | - $sql .= " AND ca.id = " . $type; |
|
616 | +if ($type) { |
|
617 | + $sql .= " AND ca.id = " . $type; |
|
618 | +} |
|
570 | 619 | if ($status == '0') { |
571 | 620 | $sql .= " AND a.percent = 0"; |
572 | 621 | } |
@@ -585,10 +634,12 @@ discard block |
||
585 | 634 | // We must filter on assignement table |
586 | 635 | if ($filtert > 0 || $usergroup > 0) { |
587 | 636 | $sql .= " AND ("; |
588 | - if ($filtert > 0) |
|
589 | - $sql .= "ar.fk_element = " . $filtert; |
|
590 | - if ($usergroup > 0) |
|
591 | - $sql .= ($filtert > 0 ? " OR " : "") . " ugu.fk_usergroup = " . $usergroup; |
|
637 | + if ($filtert > 0) { |
|
638 | + $sql .= "ar.fk_element = " . $filtert; |
|
639 | + } |
|
640 | + if ($usergroup > 0) { |
|
641 | + $sql .= ($filtert > 0 ? " OR " : "") . " ugu.fk_usergroup = " . $usergroup; |
|
642 | + } |
|
592 | 643 | $sql .= ")"; |
593 | 644 | } |
594 | 645 | // Sort on date |
@@ -647,17 +698,18 @@ discard block |
||
647 | 698 | // They are date start and end of action but modified to not be outside calendar view. |
648 | 699 | if ($event->percentage <= 0) { |
649 | 700 | $event->date_start_in_calendar = $event->datep; |
650 | - if ($event->datef != '' && $event->datef >= $event->datep) |
|
651 | - $event->date_end_in_calendar = $event->datef; |
|
652 | - else |
|
653 | - $event->date_end_in_calendar = $event->datep; |
|
654 | - } |
|
655 | - else { |
|
701 | + if ($event->datef != '' && $event->datef >= $event->datep) { |
|
702 | + $event->date_end_in_calendar = $event->datef; |
|
703 | + } else { |
|
704 | + $event->date_end_in_calendar = $event->datep; |
|
705 | + } |
|
706 | + } else { |
|
656 | 707 | $event->date_start_in_calendar = $event->datep; |
657 | - if ($event->datef != '' && $event->datef >= $event->datep) |
|
658 | - $event->date_end_in_calendar = $event->datef; |
|
659 | - else |
|
660 | - $event->date_end_in_calendar = $event->datep; |
|
708 | + if ($event->datef != '' && $event->datef >= $event->datep) { |
|
709 | + $event->date_end_in_calendar = $event->datef; |
|
710 | + } else { |
|
711 | + $event->date_end_in_calendar = $event->datep; |
|
712 | + } |
|
661 | 713 | } |
662 | 714 | // Define ponctual property |
663 | 715 | if ($event->date_start_in_calendar == $event->date_end_in_calendar) { |
@@ -669,10 +721,12 @@ discard block |
||
669 | 721 | $event->date_start_in_calendar >= $lastdaytoshow) { |
670 | 722 | // This record is out of visible range |
671 | 723 | } else { |
672 | - if ($event->date_start_in_calendar < $firstdaytoshow) |
|
673 | - $event->date_start_in_calendar = $firstdaytoshow; |
|
674 | - if ($event->date_end_in_calendar >= $lastdaytoshow) |
|
675 | - $event->date_end_in_calendar = ($lastdaytoshow - 1); |
|
724 | + if ($event->date_start_in_calendar < $firstdaytoshow) { |
|
725 | + $event->date_start_in_calendar = $firstdaytoshow; |
|
726 | + } |
|
727 | + if ($event->date_end_in_calendar >= $lastdaytoshow) { |
|
728 | + $event->date_end_in_calendar = ($lastdaytoshow - 1); |
|
729 | + } |
|
676 | 730 | |
677 | 731 | // Add an entry in actionarray for each day |
678 | 732 | $daycursor = $event->date_start_in_calendar; |
@@ -691,8 +745,9 @@ discard block |
||
691 | 745 | $j++; |
692 | 746 | |
693 | 747 | $daykey += 60 * 60 * 24; |
694 | - if ($daykey > $event->date_end_in_calendar) |
|
695 | - $loop = false; |
|
748 | + if ($daykey > $event->date_end_in_calendar) { |
|
749 | + $loop = false; |
|
750 | + } |
|
696 | 751 | } |
697 | 752 | while ($loop); |
698 | 753 | |
@@ -701,8 +756,7 @@ discard block |
||
701 | 756 | } |
702 | 757 | $i++; |
703 | 758 | } |
704 | -} |
|
705 | -else { |
|
759 | +} else { |
|
706 | 760 | dol_print_error($db); |
707 | 761 | } |
708 | 762 | |
@@ -755,14 +809,14 @@ discard block |
||
755 | 809 | do { |
756 | 810 | $eventarray[$daykey][] = $event; |
757 | 811 | $daykey += 60 * 60 * 24; |
758 | - if ($daykey > $event->date_end_in_calendar) |
|
759 | - $loop = false; |
|
812 | + if ($daykey > $event->date_end_in_calendar) { |
|
813 | + $loop = false; |
|
814 | + } |
|
760 | 815 | } |
761 | 816 | while ($loop); |
762 | 817 | $i++; |
763 | 818 | } |
764 | - } |
|
765 | - else { |
|
819 | + } else { |
|
766 | 820 | dol_print_error($db); |
767 | 821 | } |
768 | 822 | } |
@@ -783,10 +837,14 @@ discard block |
||
783 | 837 | // After this $ical->cal['VEVENT'] contains array of events, $ical->cal['DAYLIGHT'] contains daylight info, $ical->cal['STANDARD'] contains non daylight info, ... |
784 | 838 | //var_dump($ical->cal); exit; |
785 | 839 | $icalevents = array(); |
786 | - if (is_array($ical->get_event_list())) |
|
787 | - $icalevents = array_merge($icalevents, $ical->get_event_list()); // Add $ical->cal['VEVENT'] |
|
788 | - if (is_array($ical->get_freebusy_list())) |
|
789 | - $icalevents = array_merge($icalevents, $ical->get_freebusy_list()); // Add $ical->cal['VFREEBUSY'] |
|
840 | + if (is_array($ical->get_event_list())) { |
|
841 | + $icalevents = array_merge($icalevents, $ical->get_event_list()); |
|
842 | + } |
|
843 | + // Add $ical->cal['VEVENT'] |
|
844 | + if (is_array($ical->get_freebusy_list())) { |
|
845 | + $icalevents = array_merge($icalevents, $ical->get_freebusy_list()); |
|
846 | + } |
|
847 | + // Add $ical->cal['VFREEBUSY'] |
|
790 | 848 | |
791 | 849 | if (count($icalevents) > 0) { |
792 | 850 | // Duplicate all repeatable events into new entries |
@@ -809,19 +867,20 @@ discard block |
||
809 | 867 | $tmpdaylightend = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['STANDARD']['DTSTART']; |
810 | 868 | //var_dump($tmpcurstart);var_dump($tmpcurend); var_dump($ical->cal['DAYLIGHT']['DTSTART']);var_dump($ical->cal['STANDARD']['DTSTART']); |
811 | 869 | // Edit datecurstart and datecurend |
812 | - if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) |
|
813 | - $datecurstart -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; |
|
814 | - else |
|
815 | - $datecurstart -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; |
|
816 | - if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) |
|
817 | - $datecurend -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; |
|
818 | - else |
|
819 | - $datecurend -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; |
|
870 | + if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) { |
|
871 | + $datecurstart -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; |
|
872 | + } else { |
|
873 | + $datecurstart -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; |
|
874 | + } |
|
875 | + if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) { |
|
876 | + $datecurend -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36; |
|
877 | + } else { |
|
878 | + $datecurend -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36; |
|
879 | + } |
|
820 | 880 | } |
821 | 881 | // datecurstart and datecurend are now GMT date |
822 | 882 | //var_dump($datecurstart); var_dump($datecurend); exit; |
823 | - } |
|
824 | - else { |
|
883 | + } else { |
|
825 | 884 | // Not a recongized record |
826 | 885 | dol_syslog("Found a not recognized repeatable record with unknown date start", LOG_ERR); |
827 | 886 | continue; |
@@ -831,10 +890,14 @@ discard block |
||
831 | 890 | $interval = (empty($icalevent['RRULE']['INTERVAL']) ? 1 : $icalevent['RRULE']['INTERVAL']); |
832 | 891 | $until = empty($icalevent['RRULE']['UNTIL']) ? 0 : dol_stringtotime($icalevent['RRULE']['UNTIL'], 1); |
833 | 892 | $maxrepeat = empty($icalevent['RRULE']['COUNT']) ? 0 : $icalevent['RRULE']['COUNT']; |
834 | - if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) |
|
835 | - continue; // We discard repeatable event that end before start date to show |
|
836 | - if ($datecurstart >= $lastdaytoshow) |
|
837 | - continue; // We discard repeatable event that start after end date to show |
|
893 | + if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) { |
|
894 | + continue; |
|
895 | + } |
|
896 | + // We discard repeatable event that end before start date to show |
|
897 | + if ($datecurstart >= $lastdaytoshow) { |
|
898 | + continue; |
|
899 | + } |
|
900 | + // We discard repeatable event that start after end date to show |
|
838 | 901 | |
839 | 902 | $numofevent = 0; |
840 | 903 | while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) { |
@@ -882,8 +945,10 @@ discard block |
||
882 | 945 | foreach ($icalevents as $icalevent) { |
883 | 946 | //var_dump($icalevent); |
884 | 947 | //print $icalevent['SUMMARY'].'->'.var_dump($icalevent).'<br>';exit; |
885 | - if (!empty($icalevent['RRULE'])) |
|
886 | - continue; // We found a repeatable event. It was already split into unitary events, so we discard general rule. |
|
948 | + if (!empty($icalevent['RRULE'])) { |
|
949 | + continue; |
|
950 | + } |
|
951 | + // We found a repeatable event. It was already split into unitary events, so we discard general rule. |
|
887 | 952 | |
888 | 953 | |
889 | 954 | |
@@ -943,19 +1008,21 @@ discard block |
||
943 | 1008 | $event->datef = $dateend + $usertime; |
944 | 1009 | $event->type_code = "ICALEVENT"; |
945 | 1010 | |
946 | - if ($icalevent['SUMMARY']) |
|
947 | - $event->libelle = $icalevent['SUMMARY']; |
|
948 | - elseif ($icalevent['DESCRIPTION']) |
|
949 | - $event->libelle = dol_nl2br($icalevent['DESCRIPTION'], 1); |
|
950 | - else |
|
951 | - $event->libelle = $langs->trans("ExtSiteNoLabel"); |
|
1011 | + if ($icalevent['SUMMARY']) { |
|
1012 | + $event->libelle = $icalevent['SUMMARY']; |
|
1013 | + } elseif ($icalevent['DESCRIPTION']) { |
|
1014 | + $event->libelle = dol_nl2br($icalevent['DESCRIPTION'], 1); |
|
1015 | + } else { |
|
1016 | + $event->libelle = $langs->trans("ExtSiteNoLabel"); |
|
1017 | + } |
|
952 | 1018 | |
953 | 1019 | $event->date_start_in_calendar = $event->datep; |
954 | 1020 | |
955 | - if ($event->datef != '' && $event->datef >= $event->datep) |
|
956 | - $event->date_end_in_calendar = $event->datef; |
|
957 | - else |
|
958 | - $event->date_end_in_calendar = $event->datep; |
|
1021 | + if ($event->datef != '' && $event->datef >= $event->datep) { |
|
1022 | + $event->date_end_in_calendar = $event->datef; |
|
1023 | + } else { |
|
1024 | + $event->date_end_in_calendar = $event->datep; |
|
1025 | + } |
|
959 | 1026 | |
960 | 1027 | // Define ponctual property |
961 | 1028 | if ($event->date_start_in_calendar == $event->date_end_in_calendar) { |
@@ -970,10 +1037,12 @@ discard block |
||
970 | 1037 | //print 'x'.$datestart.'-'.$dateend;exit; |
971 | 1038 | // This record is out of visible range |
972 | 1039 | } else { |
973 | - if ($event->date_start_in_calendar < $firstdaytoshow) |
|
974 | - $event->date_start_in_calendar = $firstdaytoshow; |
|
975 | - if ($event->date_end_in_calendar >= $lastdaytoshow) |
|
976 | - $event->date_end_in_calendar = ($lastdaytoshow - 1); |
|
1040 | + if ($event->date_start_in_calendar < $firstdaytoshow) { |
|
1041 | + $event->date_start_in_calendar = $firstdaytoshow; |
|
1042 | + } |
|
1043 | + if ($event->date_end_in_calendar >= $lastdaytoshow) { |
|
1044 | + $event->date_end_in_calendar = ($lastdaytoshow - 1); |
|
1045 | + } |
|
977 | 1046 | |
978 | 1047 | // Add an entry in actionarray for each day |
979 | 1048 | $daycursor = $event->date_start_in_calendar; |
@@ -992,8 +1061,9 @@ discard block |
||
992 | 1061 | $eventarray[$daykey][] = $event; |
993 | 1062 | $daykey += 60 * 60 * 24; |
994 | 1063 | $daykeygmt += 60 * 60 * 24; // Add one day |
995 | - if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) |
|
996 | - $loop = false; |
|
1064 | + if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) { |
|
1065 | + $loop = false; |
|
1066 | + } |
|
997 | 1067 | } |
998 | 1068 | while ($loop); |
999 | 1069 | } |
@@ -1030,8 +1100,9 @@ discard block |
||
1030 | 1100 | if (is_readable($color_file)) { |
1031 | 1101 | include_once $color_file; |
1032 | 1102 | } |
1033 | -if (!is_array($theme_datacolor)) |
|
1034 | - $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); |
|
1103 | +if (!is_array($theme_datacolor)) { |
|
1104 | + $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); |
|
1105 | +} |
|
1035 | 1106 | |
1036 | 1107 | |
1037 | 1108 | if (empty($action) || $action == 'show_month') { // View by month |
@@ -1057,8 +1128,9 @@ discard block |
||
1057 | 1128 | if (!empty($conf->dol_optimize_smallscreen)) { |
1058 | 1129 | $labelshort = array(0 => 'SundayMin', 1 => 'MondayMin', 2 => 'TuesdayMin', 3 => 'WednesdayMin', 4 => 'ThursdayMin', 5 => 'FridayMin', 6 => 'SaturdayMin'); |
1059 | 1130 | print $langs->trans($labelshort[$numdayinweek]); |
1060 | - } else |
|
1061 | - print $langs->trans("Day" . $numdayinweek); |
|
1131 | + } else { |
|
1132 | + print $langs->trans("Day" . $numdayinweek); |
|
1133 | + } |
|
1062 | 1134 | print ' </td>' . "\n"; |
1063 | 1135 | $i++; |
1064 | 1136 | } |
@@ -1075,8 +1147,9 @@ discard block |
||
1075 | 1147 | /* Show days before the beginning of the current month (previous month) */ |
1076 | 1148 | if ($tmpday <= 0) { |
1077 | 1149 | $style = 'cal_other_month cal_past'; |
1078 | - if ($iter_day == 6) |
|
1079 | - $style .= ' cal_other_month_right'; |
|
1150 | + if ($iter_day == 6) { |
|
1151 | + $style .= ' cal_other_month_right'; |
|
1152 | + } |
|
1080 | 1153 | echo ' <td class="' . $style . ' nowrap" width="14%" valign="top">'; |
1081 | 1154 | show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); |
1082 | 1155 | echo " </td>\n"; |
@@ -1085,15 +1158,19 @@ discard block |
||
1085 | 1158 | elseif ($tmpday <= $max_day_in_month) { |
1086 | 1159 | $curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year); |
1087 | 1160 | $style = 'cal_current_month'; |
1088 | - if ($iter_day == 6) |
|
1089 | - $style .= ' cal_current_month_right'; |
|
1161 | + if ($iter_day == 6) { |
|
1162 | + $style .= ' cal_current_month_right'; |
|
1163 | + } |
|
1090 | 1164 | $today = 0; |
1091 | - if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $month && $todayarray['year'] == $year) |
|
1092 | - $today = 1; |
|
1093 | - if ($today) |
|
1094 | - $style = 'cal_today'; |
|
1095 | - if ($curtime < $todaytms) |
|
1096 | - $style .= ' cal_past'; |
|
1165 | + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $month && $todayarray['year'] == $year) { |
|
1166 | + $today = 1; |
|
1167 | + } |
|
1168 | + if ($today) { |
|
1169 | + $style = 'cal_today'; |
|
1170 | + } |
|
1171 | + if ($curtime < $todaytms) { |
|
1172 | + $style .= ' cal_past'; |
|
1173 | + } |
|
1097 | 1174 | //var_dump($todayarray['mday']."==".$tmpday." && ".$todayarray['mon']."==".$month." && ".$todayarray['year']."==".$year.' -> '.$style); |
1098 | 1175 | echo ' <td class="' . $style . ' nowrap" width="14%" valign="top">'; |
1099 | 1176 | show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); |
@@ -1102,8 +1179,9 @@ discard block |
||
1102 | 1179 | /* Show days after the current month (next month) */ |
1103 | 1180 | else { |
1104 | 1181 | $style = 'cal_other_month'; |
1105 | - if ($iter_day == 6) |
|
1106 | - $style .= ' cal_other_month_right'; |
|
1182 | + if ($iter_day == 6) { |
|
1183 | + $style .= ' cal_other_month_right'; |
|
1184 | + } |
|
1107 | 1185 | echo ' <td class="' . $style . ' nowrap" width="14%" valign="top">'; |
1108 | 1186 | show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); |
1109 | 1187 | echo "</td>\n"; |
@@ -1118,8 +1196,7 @@ discard block |
||
1118 | 1196 | print '<input type="hidden" name="actionmove" value="mupdate">'; |
1119 | 1197 | print '<input type="hidden" name="backtopage" value="' . dol_escape_htmltag($_SERVER['PHP_SELF']) . '?' . dol_escape_htmltag($_SERVER['QUERY_STRING']) . '">'; |
1120 | 1198 | print '<input type="hidden" name="newdate" id="newdate">'; |
1121 | -} |
|
1122 | -elseif ($action == 'show_week') { // View by week |
|
1199 | +} elseif ($action == 'show_week') { // View by week |
|
1123 | 1200 | $newparam = $param; // newparam is for birthday links |
1124 | 1201 | $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done |
1125 | 1202 | $newparam = preg_replace('/action=show_month&?/i', '', $newparam); |
@@ -1152,14 +1229,17 @@ discard block |
||
1152 | 1229 | $tmpyear = $tmparray['year']; |
1153 | 1230 | |
1154 | 1231 | $style = 'cal_current_month'; |
1155 | - if ($iter_day == 6) |
|
1156 | - $style .= ' cal_other_month_right'; |
|
1232 | + if ($iter_day == 6) { |
|
1233 | + $style .= ' cal_other_month_right'; |
|
1234 | + } |
|
1157 | 1235 | $today = 0; |
1158 | 1236 | $todayarray = dol_getdate($now, 'fast'); |
1159 | - if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) |
|
1160 | - $today = 1; |
|
1161 | - if ($today) |
|
1162 | - $style = 'cal_today'; |
|
1237 | + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) { |
|
1238 | + $today = 1; |
|
1239 | + } |
|
1240 | + if ($today) { |
|
1241 | + $style = 'cal_today'; |
|
1242 | + } |
|
1163 | 1243 | |
1164 | 1244 | echo ' <td class="' . $style . '" width="14%" valign="top">'; |
1165 | 1245 | show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300); |
@@ -1173,8 +1253,7 @@ discard block |
||
1173 | 1253 | echo '<input type="hidden" name="actionmove" value="mupdate">'; |
1174 | 1254 | echo '<input type="hidden" name="backtopage" value="' . dol_escape_htmltag($_SERVER['PHP_SELF']) . '?' . dol_escape_htmltag($_SERVER['QUERY_STRING']) . '">'; |
1175 | 1255 | echo '<input type="hidden" name="newdate" id="newdate">'; |
1176 | -} |
|
1177 | -else { // View by day |
|
1256 | +} else { // View by day |
|
1178 | 1257 | $newparam = $param; // newparam is for birthday links |
1179 | 1258 | $newparam = preg_replace('/action=show_month&?/i', '', $newparam); |
1180 | 1259 | $newparam = preg_replace('/action=show_week&?/i', '', $newparam); |
@@ -1184,8 +1263,9 @@ discard block |
||
1184 | 1263 | $style = 'cal_current_month cal_current_month_oneday'; |
1185 | 1264 | $today = 0; |
1186 | 1265 | $todayarray = dol_getdate($now, 'fast'); |
1187 | - if ($todayarray['mday'] == $day && $todayarray['mon'] == $month && $todayarray['year'] == $year) |
|
1188 | - $today = 1; |
|
1266 | + if ($todayarray['mday'] == $day && $todayarray['mon'] == $month && $todayarray['year'] == $year) { |
|
1267 | + $today = 1; |
|
1268 | + } |
|
1189 | 1269 | //if ($today) $style='cal_today'; |
1190 | 1270 | |
1191 | 1271 | $timestamp = dol_mktime(12, 0, 0, $month, $day, $year); |
@@ -1225,10 +1305,12 @@ discard block |
||
1225 | 1305 | $tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS); |
1226 | 1306 | $minhour = round($tmp[0], 0); |
1227 | 1307 | $maxhour = round($tmp[1], 0); |
1228 | - if ($minhour > 23) |
|
1229 | - $minhour = 23; |
|
1230 | - if ($maxhour < 1) |
|
1231 | - $maxhour = 1; |
|
1308 | + if ($minhour > 23) { |
|
1309 | + $minhour = 23; |
|
1310 | + } |
|
1311 | + if ($maxhour < 1) { |
|
1312 | + $maxhour = 1; |
|
1313 | + } |
|
1232 | 1314 | if ($maxhour <= $minhour) { |
1233 | 1315 | $maxhour = $minhour + 1; |
1234 | 1316 | } |
@@ -1304,10 +1386,11 @@ discard block |
||
1304 | 1386 | print 'action=show_day&day=' . str_pad($day, 2, "0", STR_PAD_LEFT) . '&month=' . str_pad($month, 2, "0", STR_PAD_LEFT) . '&year=' . $year; |
1305 | 1387 | print $newparam; |
1306 | 1388 | print '">'; |
1307 | - if ($showinfo) |
|
1308 | - print dol_print_date($curtime, 'daytextshort'); |
|
1309 | - else |
|
1310 | - print dol_print_date($curtime, '%d'); |
|
1389 | + if ($showinfo) { |
|
1390 | + print dol_print_date($curtime, 'daytextshort'); |
|
1391 | + } else { |
|
1392 | + print dol_print_date($curtime, '%d'); |
|
1393 | + } |
|
1311 | 1394 | print '</a>'; |
1312 | 1395 | print '</div><div class="floatright nowrap">'; |
1313 | 1396 | if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { |
@@ -1367,10 +1450,10 @@ discard block |
||
1367 | 1450 | } |
1368 | 1451 | //var_dump($cacheusers[$event->userownerid]->color); |
1369 | 1452 | // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) |
1370 | - if (!empty($cacheusers[$event->userownerid]->color)) |
|
1371 | - $color = $cacheusers[$event->userownerid]->color; |
|
1372 | - } |
|
1373 | - else if ($event->type_code == 'ICALEVENT') { // Event come from external ical file |
|
1453 | + if (!empty($cacheusers[$event->userownerid]->color)) { |
|
1454 | + $color = $cacheusers[$event->userownerid]->color; |
|
1455 | + } |
|
1456 | + } else if ($event->type_code == 'ICALEVENT') { // Event come from external ical file |
|
1374 | 1457 | $numical++; |
1375 | 1458 | if (!empty($event->icalname)) { |
1376 | 1459 | if (!isset($numicals[dol_string_nospecial($event->icalname)])) { |
@@ -1398,8 +1481,9 @@ discard block |
||
1398 | 1481 | } |
1399 | 1482 | //var_dump($cacheusers[$event->userownerid]->color); |
1400 | 1483 | // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) |
1401 | - if (!empty($cacheusers[$event->userownerid]->color)) |
|
1402 | - $color = $cacheusers[$event->userownerid]->color; |
|
1484 | + if (!empty($cacheusers[$event->userownerid]->color)) { |
|
1485 | + $color = $cacheusers[$event->userownerid]->color; |
|
1486 | + } |
|
1403 | 1487 | } |
1404 | 1488 | |
1405 | 1489 | if ($color < 0) { // Color was not set on user card. Set color according to color index. |
@@ -1410,8 +1494,10 @@ discard block |
||
1410 | 1494 | } else { |
1411 | 1495 | $colorindex = $nextindextouse; |
1412 | 1496 | $colorindexused[$idusertouse] = $colorindex; |
1413 | - if (!empty($theme_datacolor[$nextindextouse + 1])) |
|
1414 | - $nextindextouse++; // Prepare to use next color |
|
1497 | + if (!empty($theme_datacolor[$nextindextouse + 1])) { |
|
1498 | + $nextindextouse++; |
|
1499 | + } |
|
1500 | + // Prepare to use next color |
|
1415 | 1501 | } |
1416 | 1502 | //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'<br>'; |
1417 | 1503 | // Define color |
@@ -1501,8 +1587,9 @@ discard block |
||
1501 | 1587 | if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) { |
1502 | 1588 | $daterange .= dol_print_date($event->date_start_in_calendar, '%H:%M'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user |
1503 | 1589 | if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { |
1504 | - if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) |
|
1505 | - $daterange .= '-'; |
|
1590 | + if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) { |
|
1591 | + $daterange .= '-'; |
|
1592 | + } |
|
1506 | 1593 | //else |
1507 | 1594 | //print '...'; |
1508 | 1595 | } |
@@ -1514,11 +1601,12 @@ discard block |
||
1514 | 1601 | } |
1515 | 1602 | // Hour end |
1516 | 1603 | if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) { |
1517 | - if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) |
|
1518 | - $daterange .= dol_print_date($event->date_end_in_calendar, '%H:%M'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user |
|
1604 | + if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) { |
|
1605 | + $daterange .= dol_print_date($event->date_end_in_calendar, '%H:%M'); |
|
1606 | + } |
|
1607 | + // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user |
|
1519 | 1608 | } |
1520 | - } |
|
1521 | - else { |
|
1609 | + } else { |
|
1522 | 1610 | if ($showinfo) { |
1523 | 1611 | print $langs->trans("EventOnFullDay") . "<br>\n"; |
1524 | 1612 | } |
@@ -1528,9 +1616,9 @@ discard block |
||
1528 | 1616 | $titletoshow = $daterange; |
1529 | 1617 | $titletoshow .= ($titletoshow ? ' ' : '') . $event->libelle; |
1530 | 1618 | |
1531 | - if ($event->type_code == 'ICALEVENT') |
|
1532 | - print $titletoshow; |
|
1533 | - else { |
|
1619 | + if ($event->type_code == 'ICALEVENT') { |
|
1620 | + print $titletoshow; |
|
1621 | + } else { |
|
1534 | 1622 | $savlabel = $event->label ? $event->label : $event->libelle; |
1535 | 1623 | $event->label = $titletoshow; |
1536 | 1624 | $event->libelle = $titletoshow; |
@@ -1543,8 +1631,9 @@ discard block |
||
1543 | 1631 | $listofusertoshow = ''; |
1544 | 1632 | $posuserassigned = 0; |
1545 | 1633 | foreach ($event->userassigned as $tmpid => $tmpdata) { |
1546 | - if (!$posuserassigned && $titletoshow) |
|
1547 | - $listofusertoshow .= '<br>'; |
|
1634 | + if (!$posuserassigned && $titletoshow) { |
|
1635 | + $listofusertoshow .= '<br>'; |
|
1636 | + } |
|
1548 | 1637 | $posuserassigned++; |
1549 | 1638 | if (empty($cacheusers[$tmpid])) { |
1550 | 1639 | $newuser = new User($db); |
@@ -1556,8 +1645,9 @@ discard block |
||
1556 | 1645 | } |
1557 | 1646 | print $listofusertoshow; |
1558 | 1647 | |
1559 | - if ($event->type_code == 'ICALEVENT') |
|
1560 | - print '<br>(' . dol_trunc($event->icalname, $maxnbofchar) . ')'; |
|
1648 | + if ($event->type_code == 'ICALEVENT') { |
|
1649 | + print '<br>(' . dol_trunc($event->icalname, $maxnbofchar) . ')'; |
|
1650 | + } |
|
1561 | 1651 | |
1562 | 1652 | // If action related to company / contact |
1563 | 1653 | $linerelatedto = ''; |
@@ -1566,31 +1656,38 @@ discard block |
||
1566 | 1656 | $thirdparty = new Societe($db); |
1567 | 1657 | $thirdparty->fetch($event->societe->id); |
1568 | 1658 | $cachethirdparties[$event->societe->id] = $thirdparty; |
1569 | - } else |
|
1570 | - $thirdparty = $cachethirdparties[$event->societe->id]; |
|
1571 | - if (!empty($thirdparty->id)) |
|
1572 | - $linerelatedto .= $thirdparty->getNomUrl(1, '', 0); |
|
1659 | + } else { |
|
1660 | + $thirdparty = $cachethirdparties[$event->societe->id]; |
|
1661 | + } |
|
1662 | + if (!empty($thirdparty->id)) { |
|
1663 | + $linerelatedto .= $thirdparty->getNomUrl(1, '', 0); |
|
1664 | + } |
|
1573 | 1665 | } |
1574 | 1666 | if (!empty($event->contact->id) && $event->contact->id > 0) { |
1575 | 1667 | if (!is_object($cachecontacts[$event->contact->id])) { |
1576 | 1668 | $contact = new Contact($db); |
1577 | 1669 | $contact->fetch($event->contact->id); |
1578 | 1670 | $cachecontacts[$event->contact->id] = $contact; |
1579 | - } else |
|
1580 | - $contact = $cachecontacts[$event->contact->id]; |
|
1581 | - if ($linerelatedto) |
|
1582 | - $linerelatedto .= ' '; |
|
1583 | - if (!empty($contact->id)) |
|
1584 | - $linerelatedto .= $contact->getNomUrl(1, '', 0); |
|
1671 | + } else { |
|
1672 | + $contact = $cachecontacts[$event->contact->id]; |
|
1673 | + } |
|
1674 | + if ($linerelatedto) { |
|
1675 | + $linerelatedto .= ' '; |
|
1676 | + } |
|
1677 | + if (!empty($contact->id)) { |
|
1678 | + $linerelatedto .= $contact->getNomUrl(1, '', 0); |
|
1679 | + } |
|
1585 | 1680 | } |
1586 | 1681 | if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && !empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) { |
1587 | 1682 | include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; |
1588 | - if ($linerelatedto) |
|
1589 | - $linerelatedto .= '<br>'; |
|
1683 | + if ($linerelatedto) { |
|
1684 | + $linerelatedto .= '<br>'; |
|
1685 | + } |
|
1590 | 1686 | $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1); |
1591 | 1687 | } |
1592 | - if ($linerelatedto) |
|
1593 | - print '<br>' . $linerelatedto; |
|
1688 | + if ($linerelatedto) { |
|
1689 | + print '<br>' . $linerelatedto; |
|
1690 | + } |
|
1594 | 1691 | } |
1595 | 1692 | |
1596 | 1693 | // Show location |
@@ -1606,19 +1703,20 @@ discard block |
||
1606 | 1703 | $withstatus = 0; |
1607 | 1704 | if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') { |
1608 | 1705 | $withstatus = 1; |
1609 | - if ($event->percentage >= 0) |
|
1610 | - $withstatus = 2; |
|
1706 | + if ($event->percentage >= 0) { |
|
1707 | + $withstatus = 2; |
|
1708 | + } |
|
1611 | 1709 | } |
1612 | 1710 | print '<td class="nobottom right nowrap cal_event_right' . ($withstatus >= 2 ? ' cal_event_right_status' : '') . '">'; |
1613 | - if ($withstatus) |
|
1614 | - print $event->getLibStatut(3, 1); |
|
1615 | - else |
|
1616 | - print ' '; |
|
1711 | + if ($withstatus) { |
|
1712 | + print $event->getLibStatut(3, 1); |
|
1713 | + } else { |
|
1714 | + print ' '; |
|
1715 | + } |
|
1617 | 1716 | print '</td></tr></table>'; |
1618 | 1717 | print '</div><!-- end event ' . $i . ' -->' . "\n"; |
1619 | 1718 | $i++; |
1620 | - } |
|
1621 | - else { |
|
1719 | + } else { |
|
1622 | 1720 | print '<a href="' . DOL_URL_ROOT . '/comm/action/index.php?action=' . $action . '&maxprint=0&month=' . $monthshown . '&year=' . $year; |
1623 | 1721 | print ($status ? '&status=' . $status : '') . ($filter ? '&filter=' . $filter : ''); |
1624 | 1722 | print ($filtert ? '&filtert=' . $filtert : ''); |
@@ -1635,8 +1733,9 @@ discard block |
||
1635 | 1733 | break; |
1636 | 1734 | } |
1637 | 1735 | } |
1638 | - if (!$i) |
|
1639 | - print ' '; |
|
1736 | + if (!$i) { |
|
1737 | + print ' '; |
|
1738 | + } |
|
1640 | 1739 | |
1641 | 1740 | if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $i > $maxprint && $maxprint) { |
1642 | 1741 | print '<div id="more_' . $ymd . '">' . img_picto("all", "1downarrow_selected.png") . ' +' . $langs->trans("More") . '...</div>'; |
@@ -568,8 +568,9 @@ discard block |
||
568 | 568 | 'fichinter' => $langs->trans('InterventionCard'), |
569 | 569 | 'contrat' => $langs->trans('Contract') |
570 | 570 | ); |
571 | - if (!empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) |
|
572 | - $elementList["societe"] = $langs->trans('ThirdParty'); |
|
571 | + if (!empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) { |
|
572 | + $elementList["societe"] = $langs->trans('ThirdParty'); |
|
573 | + } |
|
573 | 574 | |
574 | 575 | complete_elementList_with_modules($elementList); |
575 | 576 | |
@@ -615,20 +616,30 @@ discard block |
||
615 | 616 | // Check that all fields are filled |
616 | 617 | $ok = 1; |
617 | 618 | foreach ($listfield as $f => $value) { |
618 | - if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryVAT', 'DictionaryRegion', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp', 'DictionaryAccountancysystem', 'DictionaryAccountancyCategory'))) |
|
619 | - continue; // For some pages, country is not mandatory |
|
620 | - if ($value == 'country' && in_array($tablib[$id], array('DictionaryCanton', 'DictionaryCompanyType', 'DictionaryRevenueStamp'))) |
|
621 | - continue; // For some pages, country is not mandatory |
|
622 | - if ($value == 'localtax1' && empty($_POST['localtax1_type'])) |
|
623 | - continue; |
|
624 | - if ($value == 'localtax2' && empty($_POST['localtax2_type'])) |
|
625 | - continue; |
|
626 | - if ($value == 'color' && empty($_POST['color'])) |
|
627 | - continue; |
|
628 | - if ($value == 'formula' && empty($_POST['formula'])) |
|
629 | - continue; |
|
630 | - if ($value == 'sortorder') |
|
631 | - continue; // For a column name 'sortorder', we use the field name 'position' |
|
619 | + if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryVAT', 'DictionaryRegion', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp', 'DictionaryAccountancysystem', 'DictionaryAccountancyCategory'))) { |
|
620 | + continue; |
|
621 | + } |
|
622 | + // For some pages, country is not mandatory |
|
623 | + if ($value == 'country' && in_array($tablib[$id], array('DictionaryCanton', 'DictionaryCompanyType', 'DictionaryRevenueStamp'))) { |
|
624 | + continue; |
|
625 | + } |
|
626 | + // For some pages, country is not mandatory |
|
627 | + if ($value == 'localtax1' && empty($_POST['localtax1_type'])) { |
|
628 | + continue; |
|
629 | + } |
|
630 | + if ($value == 'localtax2' && empty($_POST['localtax2_type'])) { |
|
631 | + continue; |
|
632 | + } |
|
633 | + if ($value == 'color' && empty($_POST['color'])) { |
|
634 | + continue; |
|
635 | + } |
|
636 | + if ($value == 'formula' && empty($_POST['formula'])) { |
|
637 | + continue; |
|
638 | + } |
|
639 | + if ($value == 'sortorder') { |
|
640 | + continue; |
|
641 | + } |
|
642 | + // For a column name 'sortorder', we use the field name 'position' |
|
632 | 643 | if ((!isset($_POST[$value]) || $_POST[$value] == '') && (!in_array($listfield[$f], array('decalage', 'module', 'accountancy_code', 'accountancy_code_sell', 'accountancy_code_buy', 'tracking')) // Fields that are not mandatory |
633 | 644 | && (!($id == 10 && $listfield[$f] == 'code')) // Code is mandatory fir table 10 |
634 | 645 | ) |
@@ -636,36 +647,51 @@ discard block |
||
636 | 647 | $ok = 0; |
637 | 648 | $fieldnamekey = $listfield[$f]; |
638 | 649 | // We take translate key of field |
639 | - if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) |
|
640 | - $fieldnamekey = 'Label'; |
|
641 | - if ($fieldnamekey == 'libelle_facture') |
|
642 | - $fieldnamekey = 'LabelOnDocuments'; |
|
643 | - if ($fieldnamekey == 'nbjour') |
|
644 | - $fieldnamekey = 'NbOfDays'; |
|
645 | - if ($fieldnamekey == 'decalage') |
|
646 | - $fieldnamekey = 'Offset'; |
|
647 | - if ($fieldnamekey == 'module') |
|
648 | - $fieldnamekey = 'Module'; |
|
649 | - if ($fieldnamekey == 'code') |
|
650 | - $fieldnamekey = 'Code'; |
|
651 | - if ($fieldnamekey == 'note') |
|
652 | - $fieldnamekey = 'Note'; |
|
653 | - if ($fieldnamekey == 'taux') |
|
654 | - $fieldnamekey = 'Rate'; |
|
655 | - if ($fieldnamekey == 'type') |
|
656 | - $fieldnamekey = 'Type'; |
|
657 | - if ($fieldnamekey == 'position') |
|
658 | - $fieldnamekey = 'Position'; |
|
659 | - if ($fieldnamekey == 'unicode') |
|
660 | - $fieldnamekey = 'Unicode'; |
|
661 | - if ($fieldnamekey == 'deductible') |
|
662 | - $fieldnamekey = 'Deductible'; |
|
663 | - if ($fieldnamekey == 'sortorder') |
|
664 | - $fieldnamekey = 'SortOrder'; |
|
665 | - if ($fieldnamekey == 'category_type') |
|
666 | - $fieldnamekey = 'Calculated'; |
|
667 | - if ($fieldnamekey == 'revenuestamp_type') |
|
668 | - $fieldnamekey = 'TypeOfRevenueStamp'; |
|
650 | + if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) { |
|
651 | + $fieldnamekey = 'Label'; |
|
652 | + } |
|
653 | + if ($fieldnamekey == 'libelle_facture') { |
|
654 | + $fieldnamekey = 'LabelOnDocuments'; |
|
655 | + } |
|
656 | + if ($fieldnamekey == 'nbjour') { |
|
657 | + $fieldnamekey = 'NbOfDays'; |
|
658 | + } |
|
659 | + if ($fieldnamekey == 'decalage') { |
|
660 | + $fieldnamekey = 'Offset'; |
|
661 | + } |
|
662 | + if ($fieldnamekey == 'module') { |
|
663 | + $fieldnamekey = 'Module'; |
|
664 | + } |
|
665 | + if ($fieldnamekey == 'code') { |
|
666 | + $fieldnamekey = 'Code'; |
|
667 | + } |
|
668 | + if ($fieldnamekey == 'note') { |
|
669 | + $fieldnamekey = 'Note'; |
|
670 | + } |
|
671 | + if ($fieldnamekey == 'taux') { |
|
672 | + $fieldnamekey = 'Rate'; |
|
673 | + } |
|
674 | + if ($fieldnamekey == 'type') { |
|
675 | + $fieldnamekey = 'Type'; |
|
676 | + } |
|
677 | + if ($fieldnamekey == 'position') { |
|
678 | + $fieldnamekey = 'Position'; |
|
679 | + } |
|
680 | + if ($fieldnamekey == 'unicode') { |
|
681 | + $fieldnamekey = 'Unicode'; |
|
682 | + } |
|
683 | + if ($fieldnamekey == 'deductible') { |
|
684 | + $fieldnamekey = 'Deductible'; |
|
685 | + } |
|
686 | + if ($fieldnamekey == 'sortorder') { |
|
687 | + $fieldnamekey = 'SortOrder'; |
|
688 | + } |
|
689 | + if ($fieldnamekey == 'category_type') { |
|
690 | + $fieldnamekey = 'Calculated'; |
|
691 | + } |
|
692 | + if ($fieldnamekey == 'revenuestamp_type') { |
|
693 | + $fieldnamekey = 'TypeOfRevenueStamp'; |
|
694 | + } |
|
669 | 695 | |
670 | 696 | setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); |
671 | 697 | } |
@@ -700,16 +726,26 @@ discard block |
||
700 | 726 | } |
701 | 727 | |
702 | 728 | // Clean some parameters |
703 | - if ((!empty($_POST["localtax1_type"]) || ($_POST['localtax1_type'] == '0')) && empty($_POST["localtax1"])) |
|
704 | - $_POST["localtax1"] = '0'; // If empty, we force to 0 |
|
705 | - if ((!empty($_POST["localtax2_type"]) || ($_POST['localtax2_type'] == '0')) && empty($_POST["localtax2"])) |
|
706 | - $_POST["localtax2"] = '0'; // If empty, we force to 0 |
|
707 | - if ($_POST["accountancy_code"] <= 0) |
|
708 | - $_POST["accountancy_code"] = ''; // If empty, we force to null |
|
709 | - if ($_POST["accountancy_code_sell"] <= 0) |
|
710 | - $_POST["accountancy_code_sell"] = ''; // If empty, we force to null |
|
711 | - if ($_POST["accountancy_code_buy"] <= 0) |
|
712 | - $_POST["accountancy_code_buy"] = ''; // If empty, we force to null |
|
729 | + if ((!empty($_POST["localtax1_type"]) || ($_POST['localtax1_type'] == '0')) && empty($_POST["localtax1"])) { |
|
730 | + $_POST["localtax1"] = '0'; |
|
731 | + } |
|
732 | + // If empty, we force to 0 |
|
733 | + if ((!empty($_POST["localtax2_type"]) || ($_POST['localtax2_type'] == '0')) && empty($_POST["localtax2"])) { |
|
734 | + $_POST["localtax2"] = '0'; |
|
735 | + } |
|
736 | + // If empty, we force to 0 |
|
737 | + if ($_POST["accountancy_code"] <= 0) { |
|
738 | + $_POST["accountancy_code"] = ''; |
|
739 | + } |
|
740 | + // If empty, we force to null |
|
741 | + if ($_POST["accountancy_code_sell"] <= 0) { |
|
742 | + $_POST["accountancy_code_sell"] = ''; |
|
743 | + } |
|
744 | + // If empty, we force to null |
|
745 | + if ($_POST["accountancy_code_buy"] <= 0) { |
|
746 | + $_POST["accountancy_code_buy"] = ''; |
|
747 | + } |
|
748 | + // If empty, we force to null |
|
713 | 749 | if ($id == 10 && isset($_POST["code"])) { // Spaces are not allowed into code |
714 | 750 | $_POST["code"] = preg_replace('/\s/', '', $_POST["code"]); |
715 | 751 | } |
@@ -732,15 +768,17 @@ discard block |
||
732 | 768 | // Add new entry |
733 | 769 | $sql = "INSERT INTO " . $tabname[$id] . " ("; |
734 | 770 | // List of fields |
735 | - if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) |
|
736 | - $sql .= $tabrowid[$id] . ","; |
|
771 | + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) { |
|
772 | + $sql .= $tabrowid[$id] . ","; |
|
773 | + } |
|
737 | 774 | $sql .= $tabfieldinsert[$id]; |
738 | 775 | $sql .= ",active)"; |
739 | 776 | $sql .= " VALUES("; |
740 | 777 | |
741 | 778 | // List of values |
742 | - if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) |
|
743 | - $sql .= $newid . ","; |
|
779 | + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) { |
|
780 | + $sql .= $newid . ","; |
|
781 | + } |
|
744 | 782 | $i = 0; |
745 | 783 | foreach ($listfieldinsert as $f => $value) { |
746 | 784 | if ($value == 'price' || preg_match('/^amount/i', $value) || $value == 'taux') { |
@@ -748,14 +786,18 @@ discard block |
||
748 | 786 | } else if ($value == 'entity') { |
749 | 787 | $_POST[$listfieldvalue[$i]] = getEntity($tabname[$id]); |
750 | 788 | } |
751 | - if ($i) |
|
752 | - $sql .= ","; |
|
789 | + if ($i) { |
|
790 | + $sql .= ","; |
|
791 | + } |
|
753 | 792 | if ($listfieldvalue[$i] == 'sortorder') { // For column name 'sortorder', we use the field name 'position' |
754 | 793 | $sql .= "'" . (int) $db->escape($_POST['position']) . "'"; |
755 | - } elseif ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) |
|
756 | - $sql .= "null"; // For vat, we want/accept code = '' |
|
757 | - else |
|
758 | - $sql .= "'" . $db->escape($_POST[$listfieldvalue[$i]]) . "'"; |
|
794 | + } elseif ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) { |
|
795 | + $sql .= "null"; |
|
796 | + } |
|
797 | + // For vat, we want/accept code = '' |
|
798 | + else { |
|
799 | + $sql .= "'" . $db->escape($_POST[$listfieldvalue[$i]]) . "'"; |
|
800 | + } |
|
759 | 801 | $i++; |
760 | 802 | } |
761 | 803 | $sql .= ",1)"; |
@@ -796,20 +838,25 @@ discard block |
||
796 | 838 | } else if ($field == 'entity') { |
797 | 839 | $_POST[$listfieldvalue[$i]] = getEntity($tabname[$id]); |
798 | 840 | } |
799 | - if ($i) |
|
800 | - $sql .= ","; |
|
841 | + if ($i) { |
|
842 | + $sql .= ","; |
|
843 | + } |
|
801 | 844 | $sql .= $field . "="; |
802 | 845 | if ($listfieldvalue[$i] == 'sortorder') { // For column name 'sortorder', we use the field name 'position' |
803 | 846 | $sql .= "'" . (int) $db->escape($_POST['position']) . "'"; |
804 | - } elseif ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) |
|
805 | - $sql .= "null"; // For vat, we want/accept code = '' |
|
806 | - else |
|
807 | - $sql .= "'" . $db->escape($_POST[$listfieldvalue[$i]]) . "'"; |
|
847 | + } elseif ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) { |
|
848 | + $sql .= "null"; |
|
849 | + } |
|
850 | + // For vat, we want/accept code = '' |
|
851 | + else { |
|
852 | + $sql .= "'" . $db->escape($_POST[$listfieldvalue[$i]]) . "'"; |
|
853 | + } |
|
808 | 854 | $i++; |
809 | 855 | } |
810 | 856 | $sql .= " WHERE " . $rowidcol . " = '" . $rowid . "'"; |
811 | - if (in_array('entity', $listfieldmodify)) |
|
812 | - $sql .= " AND entity = '" . getEntity($tabname[$id]) . "'"; |
|
857 | + if (in_array('entity', $listfieldmodify)) { |
|
858 | + $sql .= " AND entity = '" . getEntity($tabname[$id]) . "'"; |
|
859 | + } |
|
813 | 860 | |
814 | 861 | dol_syslog("actionmodify", LOG_DEBUG); |
815 | 862 | //print $sql; |
@@ -962,19 +1009,25 @@ discard block |
||
962 | 1009 | |
963 | 1010 | |
964 | 1011 | $param = '&id=' . urlencode($id); |
965 | -if ($search_country_id > 0) |
|
1012 | +if ($search_country_id > 0) { |
|
966 | 1013 | $param .= '&search_country_id=' . urlencode($search_country_id); |
967 | -if ($search_code != '') |
|
1014 | +} |
|
1015 | +if ($search_code != '') { |
|
968 | 1016 | $param .= '&search_code=' . urlencode($search_country_id); |
969 | -if ($entity != '') |
|
1017 | +} |
|
1018 | +if ($entity != '') { |
|
970 | 1019 | $param .= '&entity=' . (int) $entity; |
1020 | +} |
|
971 | 1021 | $paramwithsearch = $param; |
972 | -if ($sortorder) |
|
1022 | +if ($sortorder) { |
|
973 | 1023 | $paramwithsearch .= '&sortorder=' . urlencode($sortorder); |
974 | -if ($sortfield) |
|
1024 | +} |
|
1025 | +if ($sortfield) { |
|
975 | 1026 | $paramwithsearch .= '&sortfield=' . urlencode($sortfield); |
976 | -if (GETPOST('from')) |
|
1027 | +} |
|
1028 | +if (GETPOST('from')) { |
|
977 | 1029 | $paramwithsearch .= '&from=' . urlencode(GETPOST('from', 'alpha')); |
1030 | +} |
|
978 | 1031 | |
979 | 1032 | |
980 | 1033 | // Confirmation de la suppression de la ligne |
@@ -990,19 +1043,24 @@ discard block |
||
990 | 1043 | // Complete requete recherche valeurs avec critere de tri |
991 | 1044 | $sql = $tabsql[$id]; |
992 | 1045 | |
993 | - if (!preg_match('/ WHERE /', $sql)) |
|
994 | - $sql .= " WHERE 1 = 1"; |
|
995 | - if ($search_country_id > 0) |
|
996 | - $sql .= " AND c.rowid = " . $search_country_id; |
|
997 | - if ($search_code != '' && $id != 9) |
|
998 | - $sql .= natural_search("code", $search_code); |
|
999 | - if ($search_code != '' && $id == 9) |
|
1000 | - $sql .= natural_search("code_iso", $search_code); |
|
1046 | + if (!preg_match('/ WHERE /', $sql)) { |
|
1047 | + $sql .= " WHERE 1 = 1"; |
|
1048 | + } |
|
1049 | + if ($search_country_id > 0) { |
|
1050 | + $sql .= " AND c.rowid = " . $search_country_id; |
|
1051 | + } |
|
1052 | + if ($search_code != '' && $id != 9) { |
|
1053 | + $sql .= natural_search("code", $search_code); |
|
1054 | + } |
|
1055 | + if ($search_code != '' && $id == 9) { |
|
1056 | + $sql .= natural_search("code_iso", $search_code); |
|
1057 | + } |
|
1001 | 1058 | |
1002 | 1059 | if ($sortfield) { |
1003 | 1060 | // If sort order is "country", we use country_code instead |
1004 | - if ($sortfield == 'country') |
|
1005 | - $sortfield = 'country_code'; |
|
1061 | + if ($sortfield == 'country') { |
|
1062 | + $sortfield = 'country_code'; |
|
1063 | + } |
|
1006 | 1064 | $sql .= " ORDER BY " . $db->escape($sortfield); |
1007 | 1065 | if ($sortorder) { |
1008 | 1066 | $sql .= " " . strtoupper($db->escape($sortorder)); |
@@ -1065,10 +1123,11 @@ discard block |
||
1065 | 1123 | $valuetoshow = $langs->trans("PriceUHT"); |
1066 | 1124 | } |
1067 | 1125 | if ($fieldlist[$field] == 'taux') { |
1068 | - if ($tabname[$id] != MAIN_DB_PREFIX . "c_revenuestamp") |
|
1069 | - $valuetoshow = $langs->trans("Rate"); |
|
1070 | - else |
|
1071 | - $valuetoshow = $langs->trans("Amount"); |
|
1126 | + if ($tabname[$id] != MAIN_DB_PREFIX . "c_revenuestamp") { |
|
1127 | + $valuetoshow = $langs->trans("Rate"); |
|
1128 | + } else { |
|
1129 | + $valuetoshow = $langs->trans("Amount"); |
|
1130 | + } |
|
1072 | 1131 | $class = 'center'; |
1073 | 1132 | } |
1074 | 1133 | if ($fieldlist[$field] == 'localtax1_type') { |
@@ -1096,10 +1155,11 @@ discard block |
||
1096 | 1155 | $valuetoshow = $langs->trans("Language"); |
1097 | 1156 | } |
1098 | 1157 | if ($fieldlist[$field] == 'type') { |
1099 | - if ($tabname[$id] == MAIN_DB_PREFIX . "c_paiement") |
|
1100 | - $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); |
|
1101 | - else |
|
1102 | - $valuetoshow = $langs->trans("Type"); |
|
1158 | + if ($tabname[$id] == MAIN_DB_PREFIX . "c_paiement") { |
|
1159 | + $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); |
|
1160 | + } else { |
|
1161 | + $valuetoshow = $langs->trans("Type"); |
|
1162 | + } |
|
1103 | 1163 | } |
1104 | 1164 | if ($fieldlist[$field] == 'code') { |
1105 | 1165 | $valuetoshow = $langs->trans("Code"); |
@@ -1248,24 +1308,28 @@ discard block |
||
1248 | 1308 | |
1249 | 1309 | if ($valuetoshow != '') { |
1250 | 1310 | print '<td' . ($class ? ' class="' . $class . '"' : '') . '>'; |
1251 | - if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) |
|
1252 | - print '<a href="' . $tabhelp[$id][$value] . '" target="_blank">' . $valuetoshow . ' ' . img_help(1, $valuetoshow) . '</a>'; |
|
1253 | - else if (!empty($tabhelp[$id][$value])) |
|
1254 | - print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); |
|
1255 | - else |
|
1256 | - print $valuetoshow; |
|
1311 | + if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { |
|
1312 | + print '<a href="' . $tabhelp[$id][$value] . '" target="_blank">' . $valuetoshow . ' ' . img_help(1, $valuetoshow) . '</a>'; |
|
1313 | + } else if (!empty($tabhelp[$id][$value])) { |
|
1314 | + print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); |
|
1315 | + } else { |
|
1316 | + print $valuetoshow; |
|
1317 | + } |
|
1257 | 1318 | print '</td>'; |
1258 | 1319 | } |
1259 | - if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') |
|
1260 | - $alabelisused = 1; |
|
1320 | + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { |
|
1321 | + $alabelisused = 1; |
|
1322 | + } |
|
1261 | 1323 | } |
1262 | 1324 | |
1263 | - if ($id == 4) |
|
1264 | - print '<td></td>'; |
|
1325 | + if ($id == 4) { |
|
1326 | + print '<td></td>'; |
|
1327 | + } |
|
1265 | 1328 | print '<td>'; |
1266 | 1329 | print '<input type="hidden" name="id" value="' . $id . '">'; |
1267 | - if (!is_null($withentity)) |
|
1268 | - print '<input type="hidden" name="entity" value="' . $withentity . '">'; |
|
1330 | + if (!is_null($withentity)) { |
|
1331 | + print '<input type="hidden" name="entity" value="' . $withentity . '">'; |
|
1332 | + } |
|
1269 | 1333 | print '</td>'; |
1270 | 1334 | print '<td style="min-width: 26px;"></td>'; |
1271 | 1335 | print '<td style="min-width: 26px;"></td>'; |
@@ -1278,8 +1342,9 @@ discard block |
||
1278 | 1342 | // If data was already input, we define them in obj to populate input fields. |
1279 | 1343 | if (GETPOST('actionadd')) { |
1280 | 1344 | foreach ($fieldlist as $key => $val) { |
1281 | - if (GETPOST($val) != '') |
|
1282 | - $obj->$val = GETPOST($val); |
|
1345 | + if (GETPOST($val) != '') { |
|
1346 | + $obj->$val = GETPOST($val); |
|
1347 | + } |
|
1283 | 1348 | } |
1284 | 1349 | } |
1285 | 1350 | |
@@ -1289,15 +1354,18 @@ discard block |
||
1289 | 1354 | $error = $hookmanager->error; |
1290 | 1355 | $errors = $hookmanager->errors; |
1291 | 1356 | |
1292 | - if ($id == 3) |
|
1293 | - unset($fieldlist[2]); // Remove field ??? if dictionary Regions |
|
1357 | + if ($id == 3) { |
|
1358 | + unset($fieldlist[2]); |
|
1359 | + } |
|
1360 | + // Remove field ??? if dictionary Regions |
|
1294 | 1361 | |
1295 | 1362 | if (empty($reshook)) { |
1296 | 1363 | fieldList($fieldlist, $obj, $tabname[$id], 'add'); |
1297 | 1364 | } |
1298 | 1365 | |
1299 | - if ($id == 4) |
|
1300 | - print '<td></td>'; |
|
1366 | + if ($id == 4) { |
|
1367 | + print '<td></td>'; |
|
1368 | + } |
|
1301 | 1369 | print '<td colspan="3" align="center">'; |
1302 | 1370 | if ($action != 'edit') { |
1303 | 1371 | print '<input type="submit" class="button" name="actionadd" value="' . $langs->trans("Add") . '">'; |
@@ -1306,8 +1374,9 @@ discard block |
||
1306 | 1374 | print "</tr>"; |
1307 | 1375 | |
1308 | 1376 | $colspan = count($fieldlist) + 3; |
1309 | - if ($id == 4) |
|
1310 | - $colspan++; |
|
1377 | + if ($id == 4) { |
|
1378 | + $colspan++; |
|
1379 | + } |
|
1311 | 1380 | |
1312 | 1381 | print '</table>'; |
1313 | 1382 | print '</div>'; |
@@ -1342,8 +1411,9 @@ discard block |
||
1342 | 1411 | print '<tr class="liste_titre_filter">'; |
1343 | 1412 | $filterfound = 0; |
1344 | 1413 | foreach ($fieldlist as $field => $value) { |
1345 | - if ($fieldlist[$field] == 'entity') |
|
1346 | - continue; |
|
1414 | + if ($fieldlist[$field] == 'entity') { |
|
1415 | + continue; |
|
1416 | + } |
|
1347 | 1417 | |
1348 | 1418 | $showfield = 1; // By default |
1349 | 1419 | |
@@ -1368,8 +1438,9 @@ discard block |
||
1368 | 1438 | } |
1369 | 1439 | } |
1370 | 1440 | } |
1371 | - if ($id == 4) |
|
1372 | - print '<td></td>'; |
|
1441 | + if ($id == 4) { |
|
1442 | + print '<td></td>'; |
|
1443 | + } |
|
1373 | 1444 | print '<td class="liste_titre"></td>'; |
1374 | 1445 | print '<td class="liste_titre" colspan="2" align="right">'; |
1375 | 1446 | if ($filterfound) { |
@@ -1382,8 +1453,9 @@ discard block |
||
1382 | 1453 | // Title of lines |
1383 | 1454 | print '<tr class="liste_titre">'; |
1384 | 1455 | foreach ($fieldlist as $field => $value) { |
1385 | - if ($fieldlist[$field] == 'entity') |
|
1386 | - continue; |
|
1456 | + if ($fieldlist[$field] == 'entity') { |
|
1457 | + continue; |
|
1458 | + } |
|
1387 | 1459 | |
1388 | 1460 | // Determine le nom du champ par rapport aux noms possibles |
1389 | 1461 | // dans les dictionnaires de donnees |
@@ -1407,10 +1479,11 @@ discard block |
||
1407 | 1479 | $valuetoshow = $langs->trans("PriceUHT"); |
1408 | 1480 | } |
1409 | 1481 | if ($fieldlist[$field] == 'taux') { |
1410 | - if ($tabname[$id] != MAIN_DB_PREFIX . "c_revenuestamp") |
|
1411 | - $valuetoshow = $langs->trans("Rate"); |
|
1412 | - else |
|
1413 | - $valuetoshow = $langs->trans("Amount"); |
|
1482 | + if ($tabname[$id] != MAIN_DB_PREFIX . "c_revenuestamp") { |
|
1483 | + $valuetoshow = $langs->trans("Rate"); |
|
1484 | + } else { |
|
1485 | + $valuetoshow = $langs->trans("Amount"); |
|
1486 | + } |
|
1414 | 1487 | $align = 'center'; |
1415 | 1488 | } |
1416 | 1489 | if ($fieldlist[$field] == 'localtax1_type') { |
@@ -1583,8 +1656,9 @@ discard block |
||
1583 | 1656 | } |
1584 | 1657 | } |
1585 | 1658 | // Favorite - Only activated on country dictionary |
1586 | - if ($id == 4) |
|
1587 | - print getTitleFieldOfList($langs->trans("Favorite"), 0, $_SERVER["PHP_SELF"], "favorite", ($page ? 'page=' . $page . '&' : ''), $param, 'align="center"', $sortfield, $sortorder); |
|
1659 | + if ($id == 4) { |
|
1660 | + print getTitleFieldOfList($langs->trans("Favorite"), 0, $_SERVER["PHP_SELF"], "favorite", ($page ? 'page=' . $page . '&' : ''), $param, 'align="center"', $sortfield, $sortorder); |
|
1661 | + } |
|
1588 | 1662 | |
1589 | 1663 | print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page=' . $page . '&' : ''), $param, 'align="center"', $sortfield, $sortorder); |
1590 | 1664 | print getTitleFieldOfList(''); |
@@ -1613,13 +1687,13 @@ discard block |
||
1613 | 1687 | print '<div name="' . (!empty($obj->rowid) ? $obj->rowid : $obj->code) . '"></div>'; |
1614 | 1688 | print '<input type="hidden" name="page" value="' . $page . '">'; |
1615 | 1689 | print '<input type="hidden" name="rowid" value="' . $rowid . '">'; |
1616 | - if (!is_null($withentity)) |
|
1617 | - print '<input type="hidden" name="entity" value="' . $withentity . '">'; |
|
1690 | + if (!is_null($withentity)) { |
|
1691 | + print '<input type="hidden" name="entity" value="' . $withentity . '">'; |
|
1692 | + } |
|
1618 | 1693 | print '<input type="submit" class="button" name="actionmodify" value="' . $langs->trans("Modify") . '">'; |
1619 | 1694 | print '<input type="submit" class="button" name="actioncancel" value="' . $langs->trans("Cancel") . '">'; |
1620 | 1695 | print '</td>'; |
1621 | - } |
|
1622 | - else { |
|
1696 | + } else { |
|
1623 | 1697 | $tmpaction = 'view'; |
1624 | 1698 | $parameters = array('fieldlist' => $fieldlist, 'tabname' => $tabname[$id]); |
1625 | 1699 | $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks |
@@ -1658,15 +1732,15 @@ discard block |
||
1658 | 1732 | $valuetoshow = yn($valuetoshow); |
1659 | 1733 | $align = "center"; |
1660 | 1734 | } else if ($fieldlist[$field] == 'type_cdr') { |
1661 | - if (empty($valuetoshow)) |
|
1662 | - $valuetoshow = $langs->trans('None'); |
|
1663 | - elseif ($valuetoshow == 1) |
|
1664 | - $valuetoshow = $langs->trans('AtEndOfMonth'); |
|
1665 | - elseif ($valuetoshow == 2) |
|
1666 | - $valuetoshow = $langs->trans('CurrentNext'); |
|
1735 | + if (empty($valuetoshow)) { |
|
1736 | + $valuetoshow = $langs->trans('None'); |
|
1737 | + } elseif ($valuetoshow == 1) { |
|
1738 | + $valuetoshow = $langs->trans('AtEndOfMonth'); |
|
1739 | + } elseif ($valuetoshow == 2) { |
|
1740 | + $valuetoshow = $langs->trans('CurrentNext'); |
|
1741 | + } |
|
1667 | 1742 | $align = "center"; |
1668 | - } |
|
1669 | - else if ($fieldlist[$field] == 'price' || preg_match('/^amount/i', $fieldlist[$field])) { |
|
1743 | + } else if ($fieldlist[$field] == 'price' || preg_match('/^amount/i', $fieldlist[$field])) { |
|
1670 | 1744 | $valuetoshow = price($valuetoshow); |
1671 | 1745 | } |
1672 | 1746 | if ($value == 'private') { |
@@ -1744,20 +1818,20 @@ discard block |
||
1744 | 1818 | } else if ($fieldlist[$field] == 'localtax1' || $fieldlist[$field] == 'localtax2') { |
1745 | 1819 | $align = "center"; |
1746 | 1820 | } else if ($fieldlist[$field] == 'localtax1_type') { |
1747 | - if ($obj->localtax1 != 0) |
|
1748 | - $valuetoshow = $localtax_typeList[$valuetoshow]; |
|
1749 | - else |
|
1750 | - $valuetoshow = ''; |
|
1821 | + if ($obj->localtax1 != 0) { |
|
1822 | + $valuetoshow = $localtax_typeList[$valuetoshow]; |
|
1823 | + } else { |
|
1824 | + $valuetoshow = ''; |
|
1825 | + } |
|
1751 | 1826 | $align = "center"; |
1752 | - } |
|
1753 | - else if ($fieldlist[$field] == 'localtax2_type') { |
|
1754 | - if ($obj->localtax2 != 0) |
|
1755 | - $valuetoshow = $localtax_typeList[$valuetoshow]; |
|
1756 | - else |
|
1757 | - $valuetoshow = ''; |
|
1827 | + } else if ($fieldlist[$field] == 'localtax2_type') { |
|
1828 | + if ($obj->localtax2 != 0) { |
|
1829 | + $valuetoshow = $localtax_typeList[$valuetoshow]; |
|
1830 | + } else { |
|
1831 | + $valuetoshow = ''; |
|
1832 | + } |
|
1758 | 1833 | $align = "center"; |
1759 | - } |
|
1760 | - else if ($fieldlist[$field] == 'taux') { |
|
1834 | + } else if ($fieldlist[$field] == 'taux') { |
|
1761 | 1835 | $valuetoshow = price($valuetoshow, 0, $langs, 0, 0); |
1762 | 1836 | $align = "center"; |
1763 | 1837 | } else if (in_array($fieldlist[$field], array('recuperableonly'))) { |
@@ -1779,21 +1853,28 @@ discard block |
||
1779 | 1853 | } |
1780 | 1854 | |
1781 | 1855 | $class = 'tddict'; |
1782 | - if ($fieldlist[$field] == 'note' && $id == 10) |
|
1783 | - $class .= ' tdoverflowmax200'; |
|
1784 | - if ($fieldlist[$field] == 'tracking') |
|
1785 | - $class .= ' tdoverflowauto'; |
|
1786 | - if ($fieldlist[$field] == 'code') |
|
1787 | - $class .= ' width100'; |
|
1788 | - if ($fieldlist[$field] == 'position') |
|
1789 | - $class .= ' right'; |
|
1790 | - if ($fieldlist[$field] == 'localtax1_type') |
|
1791 | - $class .= ' nowrap'; |
|
1792 | - if ($fieldlist[$field] == 'localtax2_type') |
|
1793 | - $class .= ' nowrap'; |
|
1856 | + if ($fieldlist[$field] == 'note' && $id == 10) { |
|
1857 | + $class .= ' tdoverflowmax200'; |
|
1858 | + } |
|
1859 | + if ($fieldlist[$field] == 'tracking') { |
|
1860 | + $class .= ' tdoverflowauto'; |
|
1861 | + } |
|
1862 | + if ($fieldlist[$field] == 'code') { |
|
1863 | + $class .= ' width100'; |
|
1864 | + } |
|
1865 | + if ($fieldlist[$field] == 'position') { |
|
1866 | + $class .= ' right'; |
|
1867 | + } |
|
1868 | + if ($fieldlist[$field] == 'localtax1_type') { |
|
1869 | + $class .= ' nowrap'; |
|
1870 | + } |
|
1871 | + if ($fieldlist[$field] == 'localtax2_type') { |
|
1872 | + $class .= ' nowrap'; |
|
1873 | + } |
|
1794 | 1874 | // Show value for field |
1795 | - if ($showfield) |
|
1796 | - print '<!-- ' . $fieldlist[$field] . ' --><td align="' . $align . '" class="' . $class . '">' . $valuetoshow . '</td>'; |
|
1875 | + if ($showfield) { |
|
1876 | + print '<!-- ' . $fieldlist[$field] . ' --><td align="' . $align . '" class="' . $class . '">' . $valuetoshow . '</td>'; |
|
1877 | + } |
|
1797 | 1878 | } |
1798 | 1879 | } |
1799 | 1880 | |
@@ -1822,66 +1903,76 @@ discard block |
||
1822 | 1903 | $canbedisabled = 0; |
1823 | 1904 | } |
1824 | 1905 | $canbemodified = $iserasable; |
1825 | - if ($obj->code == 'RECEP') |
|
1826 | - $canbemodified = 1; |
|
1827 | - if ($tabname[$id] == MAIN_DB_PREFIX . "c_actioncomm") |
|
1828 | - $canbemodified = 1; |
|
1906 | + if ($obj->code == 'RECEP') { |
|
1907 | + $canbemodified = 1; |
|
1908 | + } |
|
1909 | + if ($tabname[$id] == MAIN_DB_PREFIX . "c_actioncomm") { |
|
1910 | + $canbemodified = 1; |
|
1911 | + } |
|
1829 | 1912 | |
1830 | 1913 | // Url |
1831 | 1914 | $rowidcol = $tabrowid[$id]; |
1832 | 1915 | // If rowidcol not defined |
1833 | - if (empty($rowidcol) || in_array($id, array(6, 7, 8, 13, 17, 19, 27))) |
|
1834 | - $rowidcol = 'rowid'; |
|
1916 | + if (empty($rowidcol) || in_array($id, array(6, 7, 8, 13, 17, 19, 27))) { |
|
1917 | + $rowidcol = 'rowid'; |
|
1918 | + } |
|
1835 | 1919 | //$url = $_SERVER["PHP_SELF"] . '?' . ($page ? 'page=' . $page . '&' : '') . 'sortfield=' . $sortfield . '&sortorder=' . $sortorder . '&rowid=' . ((!empty($obj->{$rowidcol}) || $obj->{$rowidcol} == '0') ? $obj->{$rowidcol} : (!empty($obj->code) ? urlencode($obj->code) : '')) . '&code=' . (!empty($obj->code) ? urlencode($obj->code) : ''); |
1836 | 1920 | $url = BASE_URI . '?controller=admin&method=dict&' . ($page ? 'page=' . $page . '&' : '') . 'sortfield=' . $sortfield . '&sortorder=' . $sortorder . '&rowid=' . ((!empty($obj->{$rowidcol}) || $obj->{$rowidcol} == '0') ? $obj->{$rowidcol} : (!empty($obj->code) ? urlencode($obj->code) : '')) . '&code=' . (!empty($obj->code) ? urlencode($obj->code) : ''); |
1837 | - if (!empty($param)) |
|
1838 | - $url .= '&' . $param; |
|
1839 | - if (!is_null($withentity)) |
|
1840 | - $url .= '&entity=' . $withentity; |
|
1921 | + if (!empty($param)) { |
|
1922 | + $url .= '&' . $param; |
|
1923 | + } |
|
1924 | + if (!is_null($withentity)) { |
|
1925 | + $url .= '&entity=' . $withentity; |
|
1926 | + } |
|
1841 | 1927 | $url .= '&'; |
1842 | 1928 | |
1843 | 1929 | // Favorite |
1844 | 1930 | // Only activated on country dictionary |
1845 | 1931 | if ($id == 4) { |
1846 | 1932 | print '<td align="center" class="nowrap">'; |
1847 | - if ($iserasable) |
|
1848 | - print '<a href="' . $url . 'action=' . $acts[$obj->favorite] . '_favorite">' . $actl[$obj->favorite] . '</a>'; |
|
1849 | - else |
|
1850 | - print $langs->trans("AlwaysActive"); |
|
1933 | + if ($iserasable) { |
|
1934 | + print '<a href="' . $url . 'action=' . $acts[$obj->favorite] . '_favorite">' . $actl[$obj->favorite] . '</a>'; |
|
1935 | + } else { |
|
1936 | + print $langs->trans("AlwaysActive"); |
|
1937 | + } |
|
1851 | 1938 | print '</td>'; |
1852 | 1939 | } |
1853 | 1940 | |
1854 | 1941 | // Active |
1855 | 1942 | print '<td align="center" class="nowrap">'; |
1856 | - if ($canbedisabled) |
|
1857 | - print '<a href="' . $url . 'action=' . $acts[$obj->active] . '">' . $actl[$obj->active] . '</a>'; |
|
1858 | - else { |
|
1859 | - if (in_array($obj->code, array('AC_OTH', 'AC_OTH_AUTO'))) |
|
1860 | - print $langs->trans("AlwaysActive"); |
|
1861 | - else if (isset($obj->type) && in_array($obj->type, array('systemauto')) && empty($obj->active)) |
|
1862 | - print $langs->trans("Deprecated"); |
|
1863 | - else if (isset($obj->type) && in_array($obj->type, array('system')) && !empty($obj->active) && $obj->code != 'AC_OTH') |
|
1864 | - print $langs->trans("UsedOnlyWithTypeOption"); |
|
1865 | - else |
|
1866 | - print $langs->trans("AlwaysActive"); |
|
1943 | + if ($canbedisabled) { |
|
1944 | + print '<a href="' . $url . 'action=' . $acts[$obj->active] . '">' . $actl[$obj->active] . '</a>'; |
|
1945 | + } else { |
|
1946 | + if (in_array($obj->code, array('AC_OTH', 'AC_OTH_AUTO'))) { |
|
1947 | + print $langs->trans("AlwaysActive"); |
|
1948 | + } else if (isset($obj->type) && in_array($obj->type, array('systemauto')) && empty($obj->active)) { |
|
1949 | + print $langs->trans("Deprecated"); |
|
1950 | + } else if (isset($obj->type) && in_array($obj->type, array('system')) && !empty($obj->active) && $obj->code != 'AC_OTH') { |
|
1951 | + print $langs->trans("UsedOnlyWithTypeOption"); |
|
1952 | + } else { |
|
1953 | + print $langs->trans("AlwaysActive"); |
|
1954 | + } |
|
1867 | 1955 | } |
1868 | 1956 | print "</td>"; |
1869 | 1957 | |
1870 | 1958 | // Modify link |
1871 | - if ($canbemodified) |
|
1872 | - print '<td align="center"><a class="reposition" href="' . $url . 'action=edit">' . img_edit() . '</a></td>'; |
|
1873 | - else |
|
1874 | - print '<td> </td>'; |
|
1959 | + if ($canbemodified) { |
|
1960 | + print '<td align="center"><a class="reposition" href="' . $url . 'action=edit">' . img_edit() . '</a></td>'; |
|
1961 | + } else { |
|
1962 | + print '<td> </td>'; |
|
1963 | + } |
|
1875 | 1964 | |
1876 | 1965 | // Delete link |
1877 | 1966 | if ($iserasable) { |
1878 | 1967 | print '<td align="center">'; |
1879 | - if ($user->admin) |
|
1880 | - print '<a href="' . $url . 'action=delete">' . img_delete() . '</a>'; |
|
1968 | + if ($user->admin) { |
|
1969 | + print '<a href="' . $url . 'action=delete">' . img_delete() . '</a>'; |
|
1970 | + } |
|
1881 | 1971 | //else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin |
1882 | 1972 | print '</td>'; |
1883 | - } else |
|
1884 | - print '<td> </td>'; |
|
1973 | + } else { |
|
1974 | + print '<td> </td>'; |
|
1975 | + } |
|
1885 | 1976 | |
1886 | 1977 | print "</tr>\n"; |
1887 | 1978 | } |
@@ -1891,8 +1982,7 @@ discard block |
||
1891 | 1982 | |
1892 | 1983 | print '</table>'; |
1893 | 1984 | print '</div>'; |
1894 | - } |
|
1895 | - else { |
|
1985 | + } else { |
|
1896 | 1986 | dol_print_error($db); |
1897 | 1987 | } |
1898 | 1988 | |
@@ -1915,8 +2005,9 @@ discard block |
||
1915 | 2005 | |
1916 | 2006 | $showemptyline = ''; |
1917 | 2007 | foreach ($taborder as $i) { |
1918 | - if (isset($tabname[$i]) && empty($tabcond[$i])) |
|
1919 | - continue; |
|
2008 | + if (isset($tabname[$i]) && empty($tabcond[$i])) { |
|
2009 | + continue; |
|
2010 | + } |
|
1920 | 2011 | |
1921 | 2012 | if ($i) { |
1922 | 2013 | if ($showemptyline) { |
@@ -1979,8 +2070,9 @@ discard block |
||
1979 | 2070 | |
1980 | 2071 | $formadmin = new FormAdmin($db); |
1981 | 2072 | $formcompany = new FormCompany($db); |
1982 | - if (!empty($conf->accounting->enabled)) |
|
1983 | - $formaccounting = new FormAccounting($db); |
|
2073 | + if (!empty($conf->accounting->enabled)) { |
|
2074 | + $formaccounting = new FormAccounting($db); |
|
2075 | + } |
|
1984 | 2076 | |
1985 | 2077 | $withentity = ''; |
1986 | 2078 | |
@@ -2049,10 +2141,11 @@ discard block |
||
2049 | 2141 | print $type . '<input type="hidden" name="type" value="' . $type . '">'; |
2050 | 2142 | print '</td>'; |
2051 | 2143 | } elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'type_cdr' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') { |
2052 | - if ($fieldlist[$field] == 'type_cdr') |
|
2053 | - print '<td align="center">'; |
|
2054 | - else |
|
2055 | - print '<td>'; |
|
2144 | + if ($fieldlist[$field] == 'type_cdr') { |
|
2145 | + print '<td align="center">'; |
|
2146 | + } else { |
|
2147 | + print '<td>'; |
|
2148 | + } |
|
2056 | 2149 | if ($fieldlist[$field] == 'type_cdr') { |
2057 | 2150 | print $form->selectarray($fieldlist[$field], array(0 => $langs->trans('None'), 1 => $langs->trans('AtEndOfMonth'), 2 => $langs->trans('CurrentNext')), (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : '')); |
2058 | 2151 | } else { |
@@ -2061,13 +2154,14 @@ discard block |
||
2061 | 2154 | print '</td>'; |
2062 | 2155 | } elseif (in_array($fieldlist[$field], array('nbjour', 'decalage', 'taux', 'localtax1', 'localtax2'))) { |
2063 | 2156 | $align = "left"; |
2064 | - if (in_array($fieldlist[$field], array('taux', 'localtax1', 'localtax2'))) |
|
2065 | - $align = "center"; // Fields aligned on right |
|
2157 | + if (in_array($fieldlist[$field], array('taux', 'localtax1', 'localtax2'))) { |
|
2158 | + $align = "center"; |
|
2159 | + } |
|
2160 | + // Fields aligned on right |
|
2066 | 2161 | print '<td align="' . $align . '">'; |
2067 | 2162 | print '<input type="text" class="flat" value="' . (isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : '') . '" size="3" name="' . $fieldlist[$field] . '">'; |
2068 | 2163 | print '</td>'; |
2069 | - } |
|
2070 | - elseif (in_array($fieldlist[$field], array('libelle_facture'))) { |
|
2164 | + } elseif (in_array($fieldlist[$field], array('libelle_facture'))) { |
|
2071 | 2165 | print '<td>'; |
2072 | 2166 | $transfound = 0; |
2073 | 2167 | // Special case for labels |
@@ -2127,25 +2221,33 @@ discard block |
||
2127 | 2221 | print $form->selectExpenseRanges($obj->fk_range); |
2128 | 2222 | print '</td>'; |
2129 | 2223 | } else { |
2130 | - if ($fieldlist[$field] == 'sortorder') |
|
2131 | - $fieldlist[$field] = 'position'; |
|
2224 | + if ($fieldlist[$field] == 'sortorder') { |
|
2225 | + $fieldlist[$field] = 'position'; |
|
2226 | + } |
|
2132 | 2227 | |
2133 | 2228 | $classtd = ''; |
2134 | 2229 | $class = ''; |
2135 | - if ($fieldlist[$field] == 'code') |
|
2136 | - $classtd = 'width100'; |
|
2137 | - if ($fieldlist[$field] == 'affect') |
|
2138 | - $class = 'maxwidth50'; |
|
2139 | - if ($fieldlist[$field] == 'delay') |
|
2140 | - $class = 'maxwidth50'; |
|
2141 | - if ($fieldlist[$field] == 'position') |
|
2142 | - $class = 'maxwidth50'; |
|
2143 | - if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') |
|
2144 | - $class = 'quatrevingtpercent'; |
|
2145 | - if ($fieldlist[$field] == 'tracking') |
|
2146 | - $class = 'quatrevingtpercent'; |
|
2147 | - if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') |
|
2148 | - $class = 'maxwidth50'; |
|
2230 | + if ($fieldlist[$field] == 'code') { |
|
2231 | + $classtd = 'width100'; |
|
2232 | + } |
|
2233 | + if ($fieldlist[$field] == 'affect') { |
|
2234 | + $class = 'maxwidth50'; |
|
2235 | + } |
|
2236 | + if ($fieldlist[$field] == 'delay') { |
|
2237 | + $class = 'maxwidth50'; |
|
2238 | + } |
|
2239 | + if ($fieldlist[$field] == 'position') { |
|
2240 | + $class = 'maxwidth50'; |
|
2241 | + } |
|
2242 | + if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { |
|
2243 | + $class = 'quatrevingtpercent'; |
|
2244 | + } |
|
2245 | + if ($fieldlist[$field] == 'tracking') { |
|
2246 | + $class = 'quatrevingtpercent'; |
|
2247 | + } |
|
2248 | + if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') { |
|
2249 | + $class = 'maxwidth50'; |
|
2250 | + } |
|
2149 | 2251 | print '<td class="' . $classtd . '">'; |
2150 | 2252 | $transfound = 0; |
2151 | 2253 | if (in_array($fieldlist[$field], array('label', 'libelle'))) { |
@@ -46,8 +46,7 @@ |
||
46 | 46 | // include_once DOL_DOCUMENT_ROOT.'/includes/parsedown/Parsedown.php'; |
47 | 47 | $Parsedown = new Parsedown(); |
48 | 48 | $content = $Parsedown->text($content); |
49 | - } |
|
50 | - else |
|
49 | + } else |
|
51 | 50 | { |
52 | 51 | $content = nl2br($content); |
53 | 52 | } |
@@ -79,15 +79,17 @@ discard block |
||
79 | 79 | case self::LETTERS_ONLY:// 'aZ'=check it's a-z only |
80 | 80 | if (!is_array($result)) { |
81 | 81 | $out = trim($result); |
82 | - if (preg_match('/[^a-z]+/i', $result)) |
|
83 | - $result = ''; |
|
82 | + if (preg_match('/[^a-z]+/i', $result)) { |
|
83 | + $result = ''; |
|
84 | + } |
|
84 | 85 | } |
85 | 86 | break; |
86 | 87 | case self::LETTERS_AND_NUMBERS:// 'aZ09'=check it's simple alpha string (recommended for keys) |
87 | 88 | if (!is_array($result)) { |
88 | 89 | $result = trim($result); |
89 | - if (preg_match('/[^a-z0-9_\-\.]+/i', $result)) |
|
90 | - $result = ''; |
|
90 | + if (preg_match('/[^a-z0-9_\-\.]+/i', $result)) { |
|
91 | + $result = ''; |
|
92 | + } |
|
91 | 93 | } |
92 | 94 | break; |
93 | 95 | case self::AN_ARRAY :// 'array'=check it's array |
@@ -174,32 +176,35 @@ discard block |
||
174 | 176 | |
175 | 177 | Debug::addMessage('Deprecated', 'Using GETPOST of functions.lib.php instead of Request library'); |
176 | 178 | |
177 | - if (empty($paramname)) |
|
178 | - return 'BadFirstParameterForGETPOST'; |
|
179 | + if (empty($paramname)) { |
|
180 | + return 'BadFirstParameterForGETPOST'; |
|
181 | + } |
|
179 | 182 | if (empty($check)) { |
180 | 183 | dol_syslog("Deprecated use of GETPOST, called with 1st param = " . $paramname . " and 2nd param is '', when calling page " . $_SERVER["PHP_SELF"], LOG_WARNING); |
181 | 184 | // Enable this line to know who call the GETPOST with '' $check parameter. |
182 | 185 | //var_dump(debug_backtrace()[0]); |
183 | 186 | } |
184 | 187 | |
185 | - if (empty($method)) |
|
186 | - $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] : ''); |
|
187 | - elseif ($method == 1) |
|
188 | - $out = isset($_GET[$paramname]) ? $_GET[$paramname] : ''; |
|
189 | - elseif ($method == 2) |
|
190 | - $out = isset($_POST[$paramname]) ? $_POST[$paramname] : ''; |
|
191 | - elseif ($method == 3) |
|
192 | - $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : ''); |
|
193 | - elseif ($method == 4) |
|
194 | - $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_COOKIE[$paramname]) ? $_COOKIE[$paramname] : '')); |
|
195 | - else |
|
196 | - return 'BadThirdParameterForGETPOST'; |
|
188 | + if (empty($method)) { |
|
189 | + $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] : ''); |
|
190 | + } elseif ($method == 1) { |
|
191 | + $out = isset($_GET[$paramname]) ? $_GET[$paramname] : ''; |
|
192 | + } elseif ($method == 2) { |
|
193 | + $out = isset($_POST[$paramname]) ? $_POST[$paramname] : ''; |
|
194 | + } elseif ($method == 3) { |
|
195 | + $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : ''); |
|
196 | + } elseif ($method == 4) { |
|
197 | + $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_COOKIE[$paramname]) ? $_COOKIE[$paramname] : '')); |
|
198 | + } else { |
|
199 | + return 'BadThirdParameterForGETPOST'; |
|
200 | + } |
|
197 | 201 | |
198 | 202 | if (empty($method) || $method == 3 || $method == 4) { |
199 | 203 | $relativepathstring = $_SERVER["PHP_SELF"]; |
200 | 204 | // Clean $relativepathstring |
201 | - if (constant('DOL_URL_ROOT')) |
|
202 | - $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring); |
|
205 | + if (constant('DOL_URL_ROOT')) { |
|
206 | + $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring); |
|
207 | + } |
|
203 | 208 | $relativepathstring = preg_replace('/^\//', '', $relativepathstring); |
204 | 209 | $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); |
205 | 210 | //var_dump($relativepathstring); |
@@ -248,14 +253,17 @@ discard block |
||
248 | 253 | $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); |
249 | 254 | $foundintru = 0; |
250 | 255 | foreach ($tmpqueryarraytohave as $tmpquerytohave) { |
251 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
252 | - $foundintru = 1; |
|
256 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
257 | + $foundintru = 1; |
|
258 | + } |
|
259 | + } |
|
260 | + if (!$foundintru) { |
|
261 | + $qualified = 1; |
|
253 | 262 | } |
254 | - if (!$foundintru) |
|
255 | - $qualified = 1; |
|
256 | -//var_dump($defkey.'-'.$qualified); |
|
257 | - } else |
|
258 | - $qualified = 1; |
|
263 | + //var_dump($defkey.'-'.$qualified); |
|
264 | + } else { |
|
265 | + $qualified = 1; |
|
266 | + } |
|
259 | 267 | |
260 | 268 | if ($qualified) { |
261 | 269 | //var_dump($user->default_values[$relativepathstring][$defkey]['createform']); |
@@ -282,20 +290,24 @@ discard block |
||
282 | 290 | $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); |
283 | 291 | $foundintru = 0; |
284 | 292 | foreach ($tmpqueryarraytohave as $tmpquerytohave) { |
285 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
286 | - $foundintru = 1; |
|
293 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
294 | + $foundintru = 1; |
|
295 | + } |
|
287 | 296 | } |
288 | - if (!$foundintru) |
|
289 | - $qualified = 1; |
|
290 | -//var_dump($defkey.'-'.$qualified); |
|
291 | - } else |
|
292 | - $qualified = 1; |
|
297 | + if (!$foundintru) { |
|
298 | + $qualified = 1; |
|
299 | + } |
|
300 | + //var_dump($defkey.'-'.$qualified); |
|
301 | + } else { |
|
302 | + $qualified = 1; |
|
303 | + } |
|
293 | 304 | |
294 | 305 | if ($qualified) { |
295 | 306 | $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and , |
296 | 307 | foreach ($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) { |
297 | - if ($out) |
|
298 | - $out .= ', '; |
|
308 | + if ($out) { |
|
309 | + $out .= ', '; |
|
310 | + } |
|
299 | 311 | if ($paramname == 'sortfield') { |
300 | 312 | $out .= dol_string_nospecial($key, '', $forbidden_chars_to_replace); |
301 | 313 | } |
@@ -315,14 +327,17 @@ discard block |
||
315 | 327 | $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); |
316 | 328 | $foundintru = 0; |
317 | 329 | foreach ($tmpqueryarraytohave as $tmpquerytohave) { |
318 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
319 | - $foundintru = 1; |
|
330 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
331 | + $foundintru = 1; |
|
332 | + } |
|
320 | 333 | } |
321 | - if (!$foundintru) |
|
322 | - $qualified = 1; |
|
323 | -//var_dump($defkey.'-'.$qualified); |
|
324 | - } else |
|
325 | - $qualified = 1; |
|
334 | + if (!$foundintru) { |
|
335 | + $qualified = 1; |
|
336 | + } |
|
337 | + //var_dump($defkey.'-'.$qualified); |
|
338 | + } else { |
|
339 | + $qualified = 1; |
|
340 | + } |
|
326 | 341 | |
327 | 342 | if ($qualified) { |
328 | 343 | if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all'])) { |
@@ -394,8 +409,10 @@ discard block |
||
394 | 409 | $newout = $user->fk_user; |
395 | 410 | } elseif ($reg[1] == 'ENTITY_ID' || $reg[1] == 'ENTITYID') { |
396 | 411 | $newout = $conf->entity; |
397 | - } else |
|
398 | - $newout = ''; // Key not found, we replace with empty string |
|
412 | + } else { |
|
413 | + $newout = ''; |
|
414 | + } |
|
415 | + // Key not found, we replace with empty string |
|
399 | 416 | //var_dump('__'.$reg[1].'__ -> '.$newout); |
400 | 417 | $out = preg_replace('/__' . preg_quote($reg[1], '/') . '__/', $newout, $out); |
401 | 418 | } |
@@ -412,18 +429,20 @@ discard block |
||
412 | 429 | } |
413 | 430 | break; |
414 | 431 | case 'intcomma': |
415 | - if (preg_match('/[^0-9,-]+/i', $out)) |
|
416 | - $out = ''; |
|
432 | + if (preg_match('/[^0-9,-]+/i', $out)) { |
|
433 | + $out = ''; |
|
434 | + } |
|
417 | 435 | break; |
418 | 436 | case 'alpha': |
419 | 437 | if (!is_array($out)) { |
420 | 438 | $out = trim($out); |
421 | 439 | // '"' is dangerous because param in url can close the href= or src= and add javascript functions. |
422 | 440 | // '../' is dangerous because it allows dir transversals |
423 | - if (preg_match('/"/', $out)) |
|
424 | - $out = ''; |
|
425 | - else if (preg_match('/\.\.\//', $out)) |
|
426 | - $out = ''; |
|
441 | + if (preg_match('/"/', $out)) { |
|
442 | + $out = ''; |
|
443 | + } else if (preg_match('/\.\.\//', $out)) { |
|
444 | + $out = ''; |
|
445 | + } |
|
427 | 446 | } |
428 | 447 | break; |
429 | 448 | case 'san_alpha': |
@@ -432,27 +451,31 @@ discard block |
||
432 | 451 | case 'aZ': |
433 | 452 | if (!is_array($out)) { |
434 | 453 | $out = trim($out); |
435 | - if (preg_match('/[^a-z]+/i', $out)) |
|
436 | - $out = ''; |
|
454 | + if (preg_match('/[^a-z]+/i', $out)) { |
|
455 | + $out = ''; |
|
456 | + } |
|
437 | 457 | } |
438 | 458 | break; |
439 | 459 | case 'aZ09': |
440 | 460 | if (!is_array($out)) { |
441 | 461 | $out = trim($out); |
442 | - if (preg_match('/[^a-z0-9_\-\.]+/i', $out)) |
|
443 | - $out = ''; |
|
462 | + if (preg_match('/[^a-z0-9_\-\.]+/i', $out)) { |
|
463 | + $out = ''; |
|
464 | + } |
|
444 | 465 | } |
445 | 466 | break; |
446 | 467 | case 'aZ09comma': // great to sanitize sortfield or sortorder params that can be t.abc,t.def_gh |
447 | 468 | if (!is_array($out)) { |
448 | 469 | $out = trim($out); |
449 | - if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) |
|
450 | - $out = ''; |
|
470 | + if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) { |
|
471 | + $out = ''; |
|
472 | + } |
|
451 | 473 | } |
452 | 474 | break; |
453 | 475 | case 'array': |
454 | - if (!is_array($out) || empty($out)) |
|
455 | - $out = array(); |
|
476 | + if (!is_array($out) || empty($out)) { |
|
477 | + $out = array(); |
|
478 | + } |
|
456 | 479 | break; |
457 | 480 | case 'nohtml': // Recommended for most scalar parameters |
458 | 481 | $out = dol_string_nohtmltag($out, 0); |
@@ -462,16 +485,18 @@ discard block |
||
462 | 485 | $out = trim($out); |
463 | 486 | // '"' is dangerous because param in url can close the href= or src= and add javascript functions. |
464 | 487 | // '../' is dangerous because it allows dir transversals |
465 | - if (preg_match('/"/', $out)) |
|
466 | - $out = ''; |
|
467 | - else if (preg_match('/\.\.\//', $out)) |
|
468 | - $out = ''; |
|
488 | + if (preg_match('/"/', $out)) { |
|
489 | + $out = ''; |
|
490 | + } else if (preg_match('/\.\.\//', $out)) { |
|
491 | + $out = ''; |
|
492 | + } |
|
469 | 493 | $out = dol_string_nohtmltag($out); |
470 | 494 | } |
471 | 495 | break; |
472 | 496 | case 'custom': |
473 | - if (empty($filter)) |
|
474 | - return 'BadFourthParameterForGETPOST'; |
|
497 | + if (empty($filter)) { |
|
498 | + return 'BadFourthParameterForGETPOST'; |
|
499 | + } |
|
475 | 500 | $out = filter_var($out, $filter, $options); |
476 | 501 | break; |
477 | 502 | } |