@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | { |
| 731 | 731 | $error = 0; |
| 732 | 732 | |
| 733 | - $shour = dol_print_date($object->datep, "%H", 'tzuserrel'); // We take the date visible by user $newdate is also date visible by user. |
|
| 733 | + $shour = dol_print_date($object->datep, "%H", 'tzuserrel'); // We take the date visible by user $newdate is also date visible by user. |
|
| 734 | 734 | $smin = dol_print_date($object->datep, "%M", 'tzuserrel'); |
| 735 | 735 | |
| 736 | 736 | $newdate = GETPOST('newdate', 'alpha'); |
@@ -1776,7 +1776,7 @@ discard block |
||
| 1776 | 1776 | })'; |
| 1777 | 1777 | print '</script>'."\n"; |
| 1778 | 1778 | |
| 1779 | - print '</div>'; // End of div for reminderparameters |
|
| 1779 | + print '</div>'; // End of div for reminderparameters |
|
| 1780 | 1780 | } |
| 1781 | 1781 | |
| 1782 | 1782 | print dol_get_fiche_end(); |
@@ -27,7 +27,9 @@ discard block |
||
| 27 | 27 | * \brief Page to list actions |
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | -if (!defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); |
|
| 30 | +if (!defined("NOREDIRECTBYMAINTOLOGIN")) { |
|
| 31 | + define('NOREDIRECTBYMAINTOLOGIN', 1); |
|
| 32 | +} |
|
| 31 | 33 | |
| 32 | 34 | require '../../main.inc.php'; |
| 33 | 35 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
@@ -58,11 +60,15 @@ discard block |
||
| 58 | 60 | if (GETPOST('search_actioncode', 'array')) |
| 59 | 61 | { |
| 60 | 62 | $actioncode = GETPOST('search_actioncode', 'array', 3); |
| 61 | - if (!count($actioncode)) $actioncode = '0'; |
|
| 62 | -} else { |
|
| 63 | + if (!count($actioncode)) { |
|
| 64 | + $actioncode = '0'; |
|
| 65 | + } |
|
| 66 | + } else { |
|
| 63 | 67 | $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)); |
| 64 | 68 | } |
| 65 | -if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); |
|
| 69 | +if ($actioncode == '' && empty($actioncodearray)) { |
|
| 70 | + $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); |
|
| 71 | +} |
|
| 66 | 72 | $search_id = GETPOST('search_id', 'alpha'); |
| 67 | 73 | $search_title = GETPOST('search_title', 'alpha'); |
| 68 | 74 | $search_note = GETPOST('search_note', 'alpha'); |
@@ -70,8 +76,12 @@ discard block |
||
| 70 | 76 | $dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'), 'tzuserrel'); |
| 71 | 77 | $datestart = dol_mktime(0, 0, 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int'), 'tzuserrel'); |
| 72 | 78 | $dateend = dol_mktime(0, 0, 0, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int'), 'tzuserrel'); |
| 73 | -if ($search_status == '' && !GETPOSTISSET('search_status')) $search_status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); |
|
| 74 | -if (empty($action) && !GETPOSTISSET('action')) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); |
|
| 79 | +if ($search_status == '' && !GETPOSTISSET('search_status')) { |
|
| 80 | + $search_status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); |
|
| 81 | +} |
|
| 82 | +if (empty($action) && !GETPOSTISSET('action')) { |
|
| 83 | + $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); |
|
| 84 | +} |
|
| 75 | 85 | |
| 76 | 86 | $filter = GETPOST("search_filter", 'alpha', 3) ?GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); |
| 77 | 87 | $filtert = GETPOST("search_filtert", "int", 3) ?GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); |
@@ -103,27 +113,41 @@ discard block |
||
| 103 | 113 | if (!$sortorder) |
| 104 | 114 | { |
| 105 | 115 | $sortorder = "DESC,DESC"; |
| 106 | - if ($search_status == 'todo') $sortorder = "DESC,DESC"; |
|
| 107 | -} |
|
| 116 | + if ($search_status == 'todo') { |
|
| 117 | + $sortorder = "DESC,DESC"; |
|
| 118 | + } |
|
| 119 | + } |
|
| 108 | 120 | if (!$sortfield) |
| 109 | 121 | { |
| 110 | 122 | $sortfield = "a.datep,a.id"; |
| 111 | - if ($search_status == 'todo') $sortfield = "a.datep,a.id"; |
|
| 112 | -} |
|
| 123 | + if ($search_status == 'todo') { |
|
| 124 | + $sortfield = "a.datep,a.id"; |
|
| 125 | + } |
|
| 126 | + } |
|
| 113 | 127 | |
| 114 | 128 | // Security check |
| 115 | 129 | $socid = GETPOST("search_socid", 'int') ?GETPOST("search_socid", 'int') : GETPOST("socid", 'int'); |
| 116 | -if ($user->socid) $socid = $user->socid; |
|
| 130 | +if ($user->socid) { |
|
| 131 | + $socid = $user->socid; |
|
| 132 | +} |
|
| 117 | 133 | $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); |
| 118 | -if ($socid < 0) $socid = ''; |
|
| 134 | +if ($socid < 0) { |
|
| 135 | + $socid = ''; |
|
| 136 | +} |
|
| 119 | 137 | |
| 120 | 138 | $canedit = 1; |
| 121 | -if (!$user->rights->agenda->myactions->read) accessforbidden(); |
|
| 122 | -if (!$user->rights->agenda->allactions->read) $canedit = 0; |
|
| 123 | -if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me |
|
| 139 | +if (!$user->rights->agenda->myactions->read) { |
|
| 140 | + accessforbidden(); |
|
| 141 | +} |
|
| 142 | +if (!$user->rights->agenda->allactions->read) { |
|
| 143 | + $canedit = 0; |
|
| 144 | +} |
|
| 145 | +if (!$user->rights->agenda->allactions->read || $filter == 'mine') { |
|
| 146 | + // If no permission to see all, we show only affected to me |
|
| 124 | 147 | { |
| 125 | 148 | $filtert = $user->id; |
| 126 | 149 | } |
| 150 | +} |
|
| 127 | 151 | |
| 128 | 152 | $arrayfields = array( |
| 129 | 153 | 'a.id'=>array('label'=>"Ref", 'checked'=>1), |
@@ -174,15 +198,19 @@ discard block |
||
| 174 | 198 | |
| 175 | 199 | $parameters = array('id'=>$socid); |
| 176 | 200 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
| 177 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 201 | +if ($reshook < 0) { |
|
| 202 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 203 | +} |
|
| 178 | 204 | |
| 179 | 205 | // Selection of new fields |
| 180 | 206 | include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; |
| 181 | 207 | // Purge search criteria |
| 182 | -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers |
|
| 208 | +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { |
|
| 209 | + // All tests are required to be compatible with all browsers |
|
| 183 | 210 | { |
| 184 | 211 | //$actioncode=''; |
| 185 | 212 | $search_id = ''; |
| 213 | +} |
|
| 186 | 214 | $search_title = ''; |
| 187 | 215 | $search_note = ''; |
| 188 | 216 | $datestart = ''; |
@@ -258,32 +286,78 @@ discard block |
||
| 258 | 286 | $listofextcals = array(); |
| 259 | 287 | |
| 260 | 288 | $param = ''; |
| 261 | -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); |
|
| 262 | -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); |
|
| 289 | +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { |
|
| 290 | + $param .= '&contextpage='.urlencode($contextpage); |
|
| 291 | +} |
|
| 292 | +if ($limit > 0 && $limit != $conf->liste_limit) { |
|
| 293 | + $param .= '&limit='.urlencode($limit); |
|
| 294 | +} |
|
| 263 | 295 | if ($actioncode != '') { |
| 264 | 296 | if (is_array($actioncode)) { |
| 265 | - foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); |
|
| 266 | - } else $param .= "&search_actioncode=".urlencode($actioncode); |
|
| 267 | -} |
|
| 268 | -if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); |
|
| 269 | -if ($search_status != '' && $search_status > -1) $param .= "&search_status=".urlencode($search_status); |
|
| 270 | -if ($filter) $param .= "&search_filter=".urlencode($filter); |
|
| 271 | -if ($filtert) $param .= "&search_filtert=".urlencode($filtert); |
|
| 272 | -if ($usergroup > 0) $param .= "&search_usergroup=".urlencode($usergroup); |
|
| 273 | -if ($socid > 0) $param .= "&search_socid=".urlencode($socid); |
|
| 274 | -if ($showbirthday) $param .= "&search_showbirthday=1"; |
|
| 275 | -if ($pid) $param .= "&search_projectid=".urlencode($pid); |
|
| 276 | -if ($type) $param .= "&search_type=".urlencode($type); |
|
| 277 | -if ($search_id != '') $param .= '&search_title='.urlencode($search_id); |
|
| 278 | -if ($search_title != '') $param .= '&search_title='.urlencode($search_title); |
|
| 279 | -if ($search_note != '') $param .= '&search_note='.$search_note; |
|
| 280 | -if (GETPOST('datestartday', 'int')) $param .= '&datestartday='.GETPOST('datestartday', 'int'); |
|
| 281 | -if (GETPOST('datestartmonth', 'int')) $param .= '&datestartmonth='.GETPOST('datestartmonth', 'int'); |
|
| 282 | -if (GETPOST('datestartyear', 'int')) $param .= '&datestartyear='.GETPOST('datestartyear', 'int'); |
|
| 283 | -if (GETPOST('dateendday', 'int')) $param .= '&dateendday='.GETPOST('dateendday', 'int'); |
|
| 284 | -if (GETPOST('dateendmonth', 'int')) $param .= '&dateendmonth='.GETPOST('dateendmonth', 'int'); |
|
| 285 | -if (GETPOST('dateendyear', 'int')) $param .= '&dateendyear='.GETPOST('dateendyear', 'int'); |
|
| 286 | -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); |
|
| 297 | + foreach ($actioncode as $str_action) { |
|
| 298 | + $param .= "&search_actioncode[]=".urlencode($str_action); |
|
| 299 | + } |
|
| 300 | + } else { |
|
| 301 | + $param .= "&search_actioncode=".urlencode($actioncode); |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | +if ($resourceid > 0) { |
|
| 305 | + $param .= "&search_resourceid=".urlencode($resourceid); |
|
| 306 | +} |
|
| 307 | +if ($search_status != '' && $search_status > -1) { |
|
| 308 | + $param .= "&search_status=".urlencode($search_status); |
|
| 309 | +} |
|
| 310 | +if ($filter) { |
|
| 311 | + $param .= "&search_filter=".urlencode($filter); |
|
| 312 | +} |
|
| 313 | +if ($filtert) { |
|
| 314 | + $param .= "&search_filtert=".urlencode($filtert); |
|
| 315 | +} |
|
| 316 | +if ($usergroup > 0) { |
|
| 317 | + $param .= "&search_usergroup=".urlencode($usergroup); |
|
| 318 | +} |
|
| 319 | +if ($socid > 0) { |
|
| 320 | + $param .= "&search_socid=".urlencode($socid); |
|
| 321 | +} |
|
| 322 | +if ($showbirthday) { |
|
| 323 | + $param .= "&search_showbirthday=1"; |
|
| 324 | +} |
|
| 325 | +if ($pid) { |
|
| 326 | + $param .= "&search_projectid=".urlencode($pid); |
|
| 327 | +} |
|
| 328 | +if ($type) { |
|
| 329 | + $param .= "&search_type=".urlencode($type); |
|
| 330 | +} |
|
| 331 | +if ($search_id != '') { |
|
| 332 | + $param .= '&search_title='.urlencode($search_id); |
|
| 333 | +} |
|
| 334 | +if ($search_title != '') { |
|
| 335 | + $param .= '&search_title='.urlencode($search_title); |
|
| 336 | +} |
|
| 337 | +if ($search_note != '') { |
|
| 338 | + $param .= '&search_note='.$search_note; |
|
| 339 | +} |
|
| 340 | +if (GETPOST('datestartday', 'int')) { |
|
| 341 | + $param .= '&datestartday='.GETPOST('datestartday', 'int'); |
|
| 342 | +} |
|
| 343 | +if (GETPOST('datestartmonth', 'int')) { |
|
| 344 | + $param .= '&datestartmonth='.GETPOST('datestartmonth', 'int'); |
|
| 345 | +} |
|
| 346 | +if (GETPOST('datestartyear', 'int')) { |
|
| 347 | + $param .= '&datestartyear='.GETPOST('datestartyear', 'int'); |
|
| 348 | +} |
|
| 349 | +if (GETPOST('dateendday', 'int')) { |
|
| 350 | + $param .= '&dateendday='.GETPOST('dateendday', 'int'); |
|
| 351 | +} |
|
| 352 | +if (GETPOST('dateendmonth', 'int')) { |
|
| 353 | + $param .= '&dateendmonth='.GETPOST('dateendmonth', 'int'); |
|
| 354 | +} |
|
| 355 | +if (GETPOST('dateendyear', 'int')) { |
|
| 356 | + $param .= '&dateendyear='.GETPOST('dateendyear', 'int'); |
|
| 357 | +} |
|
| 358 | +if ($optioncss != '') { |
|
| 359 | + $param .= '&optioncss='.urlencode($optioncss); |
|
| 360 | +} |
|
| 287 | 361 | // Add $param from extra fields |
| 288 | 362 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; |
| 289 | 363 | |
@@ -299,12 +373,18 @@ discard block |
||
| 299 | 373 | { |
| 300 | 374 | $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); |
| 301 | 375 | } |
| 302 | -if ($user->rights->agenda->myactions->create) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag"); |
|
| 303 | -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array(); |
|
| 376 | +if ($user->rights->agenda->myactions->create) { |
|
| 377 | + $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag"); |
|
| 378 | +} |
|
| 379 | +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) { |
|
| 380 | + $arrayofmassactions = array(); |
|
| 381 | +} |
|
| 304 | 382 | $massactionbutton = $form->selectMassAction('', $arrayofmassactions); |
| 305 | 383 | |
| 306 | 384 | $sql = "SELECT"; |
| 307 | -if ($usergroup > 0) $sql .= " DISTINCT"; |
|
| 385 | +if ($usergroup > 0) { |
|
| 386 | + $sql .= " DISTINCT"; |
|
| 387 | +} |
|
| 308 | 388 | $sql .= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,"; |
| 309 | 389 | $sql .= " a.id, a.code, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,"; |
| 310 | 390 | $sql .= ' a.fk_user_author,a.fk_user_action,'; |
@@ -315,8 +395,10 @@ discard block |
||
| 315 | 395 | |
| 316 | 396 | // Add fields from extrafields |
| 317 | 397 | if (!empty($extrafields->attributes[$object->table_element]['label'])) { |
| 318 | - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); |
|
| 319 | -} |
|
| 398 | + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { |
|
| 399 | + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); |
|
| 400 | + } |
|
| 401 | + } |
|
| 320 | 402 | |
| 321 | 403 | // Add fields from hooks |
| 322 | 404 | $parameters = array(); |
@@ -325,15 +407,23 @@ discard block |
||
| 325 | 407 | |
| 326 | 408 | $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; |
| 327 | 409 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object) "; |
| 328 | -if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
| 410 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
| 411 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
| 412 | +} |
|
| 329 | 413 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; |
| 330 | 414 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; |
| 331 | 415 | $sql .= " ,".MAIN_DB_PREFIX."c_actioncomm as c"; |
| 332 | 416 | // We must filter on resource table |
| 333 | -if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; |
|
| 417 | +if ($resourceid > 0) { |
|
| 418 | + $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; |
|
| 419 | +} |
|
| 334 | 420 | // We must filter on assignement table |
| 335 | -if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; |
|
| 336 | -if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
| 421 | +if ($filtert > 0 || $usergroup > 0) { |
|
| 422 | + $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; |
|
| 423 | +} |
|
| 424 | +if ($usergroup > 0) { |
|
| 425 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
| 426 | +} |
|
| 337 | 427 | $sql .= " WHERE c.id = a.fk_action"; |
| 338 | 428 | $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; |
| 339 | 429 | // Condition on actioncode |
@@ -341,16 +431,24 @@ discard block |
||
| 341 | 431 | { |
| 342 | 432 | if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
| 343 | 433 | { |
| 344 | - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; |
|
| 345 | - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; |
|
| 346 | - else { |
|
| 347 | - if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'"; |
|
| 348 | - if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'"; |
|
| 434 | + if ($actioncode == 'AC_NON_AUTO') { |
|
| 435 | + $sql .= " AND c.type != 'systemauto'"; |
|
| 436 | + } elseif ($actioncode == 'AC_ALL_AUTO') { |
|
| 437 | + $sql .= " AND c.type = 'systemauto'"; |
|
| 438 | + } else { |
|
| 439 | + if ($actioncode == 'AC_OTH') { |
|
| 440 | + $sql .= " AND c.type != 'systemauto'"; |
|
| 441 | + } |
|
| 442 | + if ($actioncode == 'AC_OTH_AUTO') { |
|
| 443 | + $sql .= " AND c.type = 'systemauto'"; |
|
| 444 | + } |
|
| 349 | 445 | } |
| 350 | 446 | } else { |
| 351 | - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'"; |
|
| 352 | - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'"; |
|
| 353 | - else { |
|
| 447 | + if ($actioncode == 'AC_NON_AUTO') { |
|
| 448 | + $sql .= " AND c.type != 'systemauto'"; |
|
| 449 | + } elseif ($actioncode == 'AC_ALL_AUTO') { |
|
| 450 | + $sql .= " AND c.type = 'systemauto'"; |
|
| 451 | + } else { |
|
| 354 | 452 | if (is_array($actioncode)) |
| 355 | 453 | { |
| 356 | 454 | $sql .= " AND c.code IN ('".implode("','", $actioncode)."')"; |
@@ -360,35 +458,64 @@ discard block |
||
| 360 | 458 | } |
| 361 | 459 | } |
| 362 | 460 | } |
| 363 | -if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); |
|
| 364 | -if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); |
|
| 365 | -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; |
|
| 366 | -if ($socid > 0) $sql .= " AND s.rowid = ".$socid; |
|
| 461 | +if ($resourceid > 0) { |
|
| 462 | + $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); |
|
| 463 | +} |
|
| 464 | +if ($pid) { |
|
| 465 | + $sql .= " AND a.fk_project=".$db->escape($pid); |
|
| 466 | +} |
|
| 467 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
| 468 | + $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; |
|
| 469 | +} |
|
| 470 | +if ($socid > 0) { |
|
| 471 | + $sql .= " AND s.rowid = ".$socid; |
|
| 472 | +} |
|
| 367 | 473 | // We must filter on assignement table |
| 368 | -if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
| 369 | -if ($type) $sql .= " AND c.id = ".(int) $type; |
|
| 474 | +if ($filtert > 0 || $usergroup > 0) { |
|
| 475 | + $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
| 476 | +} |
|
| 477 | +if ($type) { |
|
| 478 | + $sql .= " AND c.id = ".(int) $type; |
|
| 479 | +} |
|
| 370 | 480 | if ($search_status == '0') { $sql .= " AND a.percent = 0"; } |
| 371 | 481 | if ($search_status == 'na') { $sql .= " AND a.percent = -1"; } // Not applicable |
| 372 | 482 | if ($search_status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started |
| 373 | 483 | if ($search_status == '100') { $sql .= " AND a.percent = 100"; } |
| 374 | 484 | if ($search_status == 'done') { $sql .= " AND (a.percent = 100)"; } |
| 375 | 485 | if ($search_status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } |
| 376 | -if ($search_id) $sql .= natural_search("a.id", $search_id, 1); |
|
| 377 | -if ($search_title) $sql .= natural_search("a.label", $search_title); |
|
| 378 | -if ($search_note) $sql .= natural_search('a.note', $search_note); |
|
| 486 | +if ($search_id) { |
|
| 487 | + $sql .= natural_search("a.id", $search_id, 1); |
|
| 488 | +} |
|
| 489 | +if ($search_title) { |
|
| 490 | + $sql .= natural_search("a.label", $search_title); |
|
| 491 | +} |
|
| 492 | +if ($search_note) { |
|
| 493 | + $sql .= natural_search('a.note', $search_note); |
|
| 494 | +} |
|
| 379 | 495 | // We must filter on assignement table |
| 380 | 496 | if ($filtert > 0 || $usergroup > 0) |
| 381 | 497 | { |
| 382 | 498 | $sql .= " AND ("; |
| 383 | - if ($filtert > 0) $sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility |
|
| 384 | - if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; |
|
| 499 | + if ($filtert > 0) { |
|
| 500 | + $sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; |
|
| 501 | + } |
|
| 502 | + // The OR is for backward compatibility |
|
| 503 | + if ($usergroup > 0) { |
|
| 504 | + $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; |
|
| 505 | + } |
|
| 385 | 506 | $sql .= ")"; |
| 386 | 507 | } |
| 387 | 508 | |
| 388 | 509 | // The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case) |
| 389 | -if ($dateselect > 0) $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)."'))"; |
|
| 390 | -if ($datestart > 0) $sql .= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart + 3600 * 24 - 1)."'"; |
|
| 391 | -if ($dateend > 0) $sql .= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend + 3600 * 24 - 1)."'"; |
|
| 510 | +if ($dateselect > 0) { |
|
| 511 | + $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)."'))"; |
|
| 512 | +} |
|
| 513 | +if ($datestart > 0) { |
|
| 514 | + $sql .= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart + 3600 * 24 - 1)."'"; |
|
| 515 | +} |
|
| 516 | +if ($dateend > 0) { |
|
| 517 | + $sql .= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend + 3600 * 24 - 1)."'"; |
|
| 518 | +} |
|
| 392 | 519 | |
| 393 | 520 | // Add where from extra fields |
| 394 | 521 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; |
@@ -405,9 +532,11 @@ discard block |
||
| 405 | 532 | { |
| 406 | 533 | $result = $db->query($sql); |
| 407 | 534 | $nbtotalofrecords = $db->num_rows($result); |
| 408 | - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 |
|
| 535 | + if (($page * $limit) > $nbtotalofrecords) { |
|
| 536 | + // if total resultset is smaller then paging size (filtering), goto and load page 0 |
|
| 409 | 537 | { |
| 410 | 538 | $page = 0; |
| 539 | + } |
|
| 411 | 540 | $offset = 0; |
| 412 | 541 | } |
| 413 | 542 | } |
@@ -438,7 +567,9 @@ discard block |
||
| 438 | 567 | |
| 439 | 568 | print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n"; |
| 440 | 569 | |
| 441 | - if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
| 570 | + if ($optioncss != '') { |
|
| 571 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
| 572 | + } |
|
| 442 | 573 | print '<input type="hidden" name="token" value="'.newToken().'">'; |
| 443 | 574 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
| 444 | 575 | print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; |
@@ -446,8 +577,12 @@ discard block |
||
| 446 | 577 | print '<input type="hidden" name="type" value="'.$type.'">'; |
| 447 | 578 | $nav = ''; |
| 448 | 579 | |
| 449 | - if ($filter) $nav .= '<input type="hidden" name="search_filter" value="'.$filter.'">'; |
|
| 450 | - if ($showbirthday) $nav .= '<input type="hidden" name="search_showbirthday" value="1">'; |
|
| 580 | + if ($filter) { |
|
| 581 | + $nav .= '<input type="hidden" name="search_filter" value="'.$filter.'">'; |
|
| 582 | + } |
|
| 583 | + if ($showbirthday) { |
|
| 584 | + $nav .= '<input type="hidden" name="search_showbirthday" value="1">'; |
|
| 585 | + } |
|
| 451 | 586 | print $nav; |
| 452 | 587 | |
| 453 | 588 | //print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action'); |
@@ -550,7 +685,9 @@ discard block |
||
| 550 | 685 | |
| 551 | 686 | $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; |
| 552 | 687 | $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields |
| 553 | - if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); |
|
| 688 | + if ($massactionbutton) { |
|
| 689 | + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); |
|
| 690 | + } |
|
| 554 | 691 | $i = 0; |
| 555 | 692 | |
| 556 | 693 | print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
@@ -561,11 +698,21 @@ discard block |
||
| 561 | 698 | print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; |
| 562 | 699 | |
| 563 | 700 | print '<tr class="liste_titre_filter">'; |
| 564 | - if (!empty($arrayfields['a.id']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>'; |
|
| 565 | - if (!empty($arrayfields['owner']['checked'])) print '<td class="liste_titre"></td>'; |
|
| 566 | - if (!empty($arrayfields['c.libelle']['checked'])) print '<td class="liste_titre"></td>'; |
|
| 567 | - if (!empty($arrayfields['a.label']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>'; |
|
| 568 | - if (!empty($arrayfields['a.note']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.'"></td>'; |
|
| 701 | + if (!empty($arrayfields['a.id']['checked'])) { |
|
| 702 | + print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>'; |
|
| 703 | + } |
|
| 704 | + if (!empty($arrayfields['owner']['checked'])) { |
|
| 705 | + print '<td class="liste_titre"></td>'; |
|
| 706 | + } |
|
| 707 | + if (!empty($arrayfields['c.libelle']['checked'])) { |
|
| 708 | + print '<td class="liste_titre"></td>'; |
|
| 709 | + } |
|
| 710 | + if (!empty($arrayfields['a.label']['checked'])) { |
|
| 711 | + print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>'; |
|
| 712 | + } |
|
| 713 | + if (!empty($arrayfields['a.note']['checked'])) { |
|
| 714 | + print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.'"></td>'; |
|
| 715 | + } |
|
| 569 | 716 | if (!empty($arrayfields['a.datep']['checked'])) { |
| 570 | 717 | print '<td class="liste_titre nowraponall" align="center">'; |
| 571 | 718 | print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel'); |
@@ -579,8 +726,12 @@ discard block |
||
| 579 | 726 | if (!empty($arrayfields['s.nom']['checked'])) { |
| 580 | 727 | print '<td class="liste_titre"></td>'; |
| 581 | 728 | } |
| 582 | - if (!empty($arrayfields['a.fk_contact']['checked'])) print '<td class="liste_titre"></td>'; |
|
| 583 | - if (!empty($arrayfields['a.fk_element']['checked'])) print '<td class="liste_titre"></td>'; |
|
| 729 | + if (!empty($arrayfields['a.fk_contact']['checked'])) { |
|
| 730 | + print '<td class="liste_titre"></td>'; |
|
| 731 | + } |
|
| 732 | + if (!empty($arrayfields['a.fk_element']['checked'])) { |
|
| 733 | + print '<td class="liste_titre"></td>'; |
|
| 734 | + } |
|
| 584 | 735 | |
| 585 | 736 | // Extra fields |
| 586 | 737 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; |
@@ -590,8 +741,12 @@ discard block |
||
| 590 | 741 | $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook |
| 591 | 742 | print $hookmanager->resPrint; |
| 592 | 743 | |
| 593 | - if (!empty($arrayfields['a.datec']['checked'])) print '<td class="liste_titre"></td>'; |
|
| 594 | - if (!empty($arrayfields['a.tms']['checked'])) print '<td class="liste_titre"></td>'; |
|
| 744 | + if (!empty($arrayfields['a.datec']['checked'])) { |
|
| 745 | + print '<td class="liste_titre"></td>'; |
|
| 746 | + } |
|
| 747 | + if (!empty($arrayfields['a.tms']['checked'])) { |
|
| 748 | + print '<td class="liste_titre"></td>'; |
|
| 749 | + } |
|
| 595 | 750 | if (!empty($arrayfields['a.percent']['checked'])) { |
| 596 | 751 | print '<td class="liste_titre center">'; |
| 597 | 752 | $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125'); |
@@ -606,17 +761,37 @@ discard block |
||
| 606 | 761 | print "</tr>\n"; |
| 607 | 762 | |
| 608 | 763 | print '<tr class="liste_titre">'; |
| 609 | - if (!empty($arrayfields['a.id']['checked'])) print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder); |
|
| 610 | - if (!empty($arrayfields['owner']['checked'])) print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); |
|
| 611 | - if (!empty($arrayfields['c.libelle']['checked'])) print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder); |
|
| 612 | - if (!empty($arrayfields['a.label']['checked'])) print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder); |
|
| 613 | - if (!empty($arrayfields['a.note']['checked'])) print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder); |
|
| 764 | + if (!empty($arrayfields['a.id']['checked'])) { |
|
| 765 | + print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder); |
|
| 766 | + } |
|
| 767 | + if (!empty($arrayfields['owner']['checked'])) { |
|
| 768 | + print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); |
|
| 769 | + } |
|
| 770 | + if (!empty($arrayfields['c.libelle']['checked'])) { |
|
| 771 | + print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder); |
|
| 772 | + } |
|
| 773 | + if (!empty($arrayfields['a.label']['checked'])) { |
|
| 774 | + print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder); |
|
| 775 | + } |
|
| 776 | + if (!empty($arrayfields['a.note']['checked'])) { |
|
| 777 | + print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder); |
|
| 778 | + } |
|
| 614 | 779 | //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
| 615 | - if (!empty($arrayfields['a.datep']['checked'])) print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder); |
|
| 616 | - if (!empty($arrayfields['a.datep2']['checked'])) print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); |
|
| 617 | - if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); |
|
| 618 | - if (!empty($arrayfields['a.fk_contact']['checked'])) print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); |
|
| 619 | - if (!empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); |
|
| 780 | + if (!empty($arrayfields['a.datep']['checked'])) { |
|
| 781 | + print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder); |
|
| 782 | + } |
|
| 783 | + if (!empty($arrayfields['a.datep2']['checked'])) { |
|
| 784 | + print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); |
|
| 785 | + } |
|
| 786 | + if (!empty($arrayfields['s.nom']['checked'])) { |
|
| 787 | + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); |
|
| 788 | + } |
|
| 789 | + if (!empty($arrayfields['a.fk_contact']['checked'])) { |
|
| 790 | + print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); |
|
| 791 | + } |
|
| 792 | + if (!empty($arrayfields['a.fk_element']['checked'])) { |
|
| 793 | + print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); |
|
| 794 | + } |
|
| 620 | 795 | |
| 621 | 796 | // Extra fields |
| 622 | 797 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; |
@@ -626,10 +801,16 @@ discard block |
||
| 626 | 801 | $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook |
| 627 | 802 | print $hookmanager->resPrint; |
| 628 | 803 | |
| 629 | - if (!empty($arrayfields['a.datec']['checked'])) print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder); |
|
| 630 | - if (!empty($arrayfields['a.tms']['checked'])) print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder); |
|
| 804 | + if (!empty($arrayfields['a.datec']['checked'])) { |
|
| 805 | + print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder); |
|
| 806 | + } |
|
| 807 | + if (!empty($arrayfields['a.tms']['checked'])) { |
|
| 808 | + print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder); |
|
| 809 | + } |
|
| 631 | 810 | |
| 632 | - if (!empty($arrayfields['a.percent']['checked']))print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder); |
|
| 811 | + if (!empty($arrayfields['a.percent']['checked'])) { |
|
| 812 | + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder); |
|
| 813 | + } |
|
| 633 | 814 | print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); |
| 634 | 815 | print "</tr>\n"; |
| 635 | 816 | |
@@ -683,7 +864,9 @@ discard block |
||
| 683 | 864 | { |
| 684 | 865 | $userstatic->fetch($obj->fk_user_action); |
| 685 | 866 | print $userstatic->getNomUrl(-1); |
| 686 | - } else print ' '; |
|
| 867 | + } else { |
|
| 868 | + print ' '; |
|
| 869 | + } |
|
| 687 | 870 | print '</td>'; |
| 688 | 871 | } |
| 689 | 872 | |
@@ -693,12 +876,19 @@ discard block |
||
| 693 | 876 | print '<td class="nowraponall">'; |
| 694 | 877 | print $actionstatic->getTypePicto(); |
| 695 | 878 | $labeltype = $obj->type_code; |
| 696 | - if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype = 'AC_OTH'; |
|
| 879 | + if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) { |
|
| 880 | + $labeltype = 'AC_OTH'; |
|
| 881 | + } |
|
| 697 | 882 | if ($actionstatic->type_code == 'AC_OTH' && $actionstatic->code == 'TICKET_MSG') { |
| 698 | 883 | $labeltype = $langs->trans("Message"); |
| 699 | 884 | } else { |
| 700 | - if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype]; |
|
| 701 | - if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code |
|
| 885 | + if (!empty($arraylist[$labeltype])) { |
|
| 886 | + $labeltype = $arraylist[$labeltype]; |
|
| 887 | + } |
|
| 888 | + if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) { |
|
| 889 | + $labeltype .= ' - '.$arraylist[$obj->code]; |
|
| 890 | + } |
|
| 891 | + // Use code in priority on type_code |
|
| 702 | 892 | } |
| 703 | 893 | print dol_trunc($labeltype, 28); |
| 704 | 894 | print '</td>'; |
@@ -726,11 +916,21 @@ discard block |
||
| 726 | 916 | print '<td class="center nowraponall">'; |
| 727 | 917 | print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuser'); |
| 728 | 918 | $late = 0; |
| 729 | - if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; |
|
| 730 | - if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; |
|
| 731 | - if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) $late = 1; |
|
| 732 | - if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1; |
|
| 733 | - if ($late) print img_warning($langs->trans("Late")).' '; |
|
| 919 | + if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) { |
|
| 920 | + $late = 1; |
|
| 921 | + } |
|
| 922 | + if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) { |
|
| 923 | + $late = 1; |
|
| 924 | + } |
|
| 925 | + if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) { |
|
| 926 | + $late = 1; |
|
| 927 | + } |
|
| 928 | + if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) { |
|
| 929 | + $late = 1; |
|
| 930 | + } |
|
| 931 | + if ($late) { |
|
| 932 | + print img_warning($langs->trans("Late")).' '; |
|
| 933 | + } |
|
| 734 | 934 | print '</td>'; |
| 735 | 935 | } |
| 736 | 936 | |
@@ -752,7 +952,9 @@ discard block |
||
| 752 | 952 | $societestatic->email = $obj->socemail; |
| 753 | 953 | |
| 754 | 954 | print $societestatic->getNomUrl(1, '', 28); |
| 755 | - } else print ' '; |
|
| 955 | + } else { |
|
| 956 | + print ' '; |
|
| 957 | + } |
|
| 756 | 958 | print '</td>'; |
| 757 | 959 | } |
| 758 | 960 | |
@@ -782,9 +984,11 @@ discard block |
||
| 782 | 984 | if (!empty($contactList)) { |
| 783 | 985 | print implode(', ', $contactList); |
| 784 | 986 | } |
| 785 | - } elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event |
|
| 987 | + } elseif ($obj->fk_contact > 0) { |
|
| 988 | + //keep for retrocompatibility with faraway event |
|
| 786 | 989 | { |
| 787 | 990 | $contactstatic->id = $obj->fk_contact; |
| 991 | + } |
|
| 788 | 992 | $contactstatic->email = $obj->email; |
| 789 | 993 | $contactstatic->lastname = $obj->lastname; |
| 790 | 994 | $contactstatic->firstname = $obj->firstname; |
@@ -835,10 +1039,14 @@ discard block |
||
| 835 | 1039 | } |
| 836 | 1040 | // Action column |
| 837 | 1041 | print '<td class="nowrap center">'; |
| 838 | - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
|
| 1042 | + if ($massactionbutton || $massaction) { |
|
| 1043 | + // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
|
| 839 | 1044 | { |
| 840 | 1045 | $selected = 0; |
| 841 | - if (in_array($obj->id, $arrayofselected)) $selected = 1; |
|
| 1046 | + } |
|
| 1047 | + if (in_array($obj->id, $arrayofselected)) { |
|
| 1048 | + $selected = 1; |
|
| 1049 | + } |
|
| 842 | 1050 | print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>'; |
| 843 | 1051 | } |
| 844 | 1052 | print '</td>'; |
@@ -39,7 +39,9 @@ discard block |
||
| 39 | 39 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 40 | 40 | |
| 41 | 41 | |
| 42 | -if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; |
|
| 42 | +if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) { |
|
| 43 | + $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; |
|
| 44 | +} |
|
| 43 | 45 | |
| 44 | 46 | $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); |
| 45 | 47 | $filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); |
@@ -60,22 +62,36 @@ discard block |
||
| 60 | 62 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
| 61 | 63 | $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; |
| 62 | 64 | $offset = $limit * $page; |
| 63 | -if (!$sortorder) $sortorder = "ASC"; |
|
| 64 | -if (!$sortfield) $sortfield = "a.datec"; |
|
| 65 | +if (!$sortorder) { |
|
| 66 | + $sortorder = "ASC"; |
|
| 67 | +} |
|
| 68 | +if (!$sortfield) { |
|
| 69 | + $sortfield = "a.datec"; |
|
| 70 | +} |
|
| 65 | 71 | |
| 66 | 72 | // Security check |
| 67 | 73 | $socid = GETPOST("search_socid", "int") ?GETPOST("search_socid", "int") : GETPOST("socid", "int"); |
| 68 | -if ($user->socid) $socid = $user->socid; |
|
| 74 | +if ($user->socid) { |
|
| 75 | + $socid = $user->socid; |
|
| 76 | +} |
|
| 69 | 77 | $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); |
| 70 | -if ($socid < 0) $socid = ''; |
|
| 78 | +if ($socid < 0) { |
|
| 79 | + $socid = ''; |
|
| 80 | +} |
|
| 71 | 81 | |
| 72 | 82 | $canedit = 1; |
| 73 | -if (!$user->rights->agenda->myactions->read) accessforbidden(); |
|
| 74 | -if (!$user->rights->agenda->allactions->read) $canedit = 0; |
|
| 75 | -if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me |
|
| 83 | +if (!$user->rights->agenda->myactions->read) { |
|
| 84 | + accessforbidden(); |
|
| 85 | +} |
|
| 86 | +if (!$user->rights->agenda->allactions->read) { |
|
| 87 | + $canedit = 0; |
|
| 88 | +} |
|
| 89 | +if (!$user->rights->agenda->allactions->read || $filter == 'mine') { |
|
| 90 | + // If no permission to see all, we show only affected to me |
|
| 76 | 91 | { |
| 77 | 92 | $filtert = $user->id; |
| 78 | 93 | } |
| 94 | +} |
|
| 79 | 95 | |
| 80 | 96 | //$action=GETPOST('action','alpha'); |
| 81 | 97 | $action = 'show_pertype'; |
@@ -93,11 +109,15 @@ discard block |
||
| 93 | 109 | if (GETPOST('search_actioncode', 'array')) |
| 94 | 110 | { |
| 95 | 111 | $actioncode = GETPOST('search_actioncode', 'array', 3); |
| 96 | - if (!count($actioncode)) $actioncode = '0'; |
|
| 97 | -} else { |
|
| 112 | + if (!count($actioncode)) { |
|
| 113 | + $actioncode = '0'; |
|
| 114 | + } |
|
| 115 | + } else { |
|
| 98 | 116 | $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); |
| 99 | 117 | } |
| 100 | -if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); |
|
| 118 | +if ($actioncode == '' && empty($actioncodearray)) { |
|
| 119 | + $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); |
|
| 120 | +} |
|
| 101 | 121 | |
| 102 | 122 | $dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); |
| 103 | 123 | if ($dateselect > 0) |
@@ -112,9 +132,15 @@ discard block |
||
| 112 | 132 | $tmparray = explode('-', $tmp); |
| 113 | 133 | $begin_h = GETPOST('begin_h', 'int') != '' ?GETPOST('begin_h', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 9); |
| 114 | 134 | $end_h = GETPOST('end_h', 'int') ?GETPOST('end_h', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 18); |
| 115 | -if ($begin_h < 0 || $begin_h > 23) $begin_h = 9; |
|
| 116 | -if ($end_h < 1 || $end_h > 24) $end_h = 18; |
|
| 117 | -if ($end_h <= $begin_h) $end_h = $begin_h + 1; |
|
| 135 | +if ($begin_h < 0 || $begin_h > 23) { |
|
| 136 | + $begin_h = 9; |
|
| 137 | +} |
|
| 138 | +if ($end_h < 1 || $end_h > 24) { |
|
| 139 | + $end_h = 18; |
|
| 140 | +} |
|
| 141 | +if ($end_h <= $begin_h) { |
|
| 142 | + $end_h = $begin_h + 1; |
|
| 143 | +} |
|
| 118 | 144 | |
| 119 | 145 | $tmp = empty($conf->global->MAIN_DEFAULT_WORKING_DAYS) ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS; |
| 120 | 146 | $tmp = str_replace(' ', '', $tmp); // FIX 7533 |
@@ -122,8 +148,12 @@ discard block |
||
| 122 | 148 | $begin_d = 1; |
| 123 | 149 | $end_d = 53; |
| 124 | 150 | |
| 125 | -if ($status == '' && !GETPOSTISSET('status')) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); |
|
| 126 | -if (empty($action) && !GETPOSTISSET('action')) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); |
|
| 151 | +if ($status == '' && !GETPOSTISSET('status')) { |
|
| 152 | + $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); |
|
| 153 | +} |
|
| 154 | +if (empty($action) && !GETPOSTISSET('action')) { |
|
| 155 | + $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); |
|
| 156 | +} |
|
| 127 | 157 | |
| 128 | 158 | if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { |
| 129 | 159 | $action = 'show_month'; $day = ''; |
@@ -185,7 +215,9 @@ discard block |
||
| 185 | 215 | 'usergroup' => $usergroup, |
| 186 | 216 | ); |
| 187 | 217 | $reshook = $hookmanager->executeHooks('beforeAgendaPerType', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
| 188 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 218 | +if ($reshook < 0) { |
|
| 219 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 220 | +} |
|
| 189 | 221 | |
| 190 | 222 | $form = new Form($db); |
| 191 | 223 | $companystatic = new Societe($db); |
@@ -223,29 +255,65 @@ discard block |
||
| 223 | 255 | //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day; |
| 224 | 256 | |
| 225 | 257 | $title = $langs->trans("DoneAndToDoActions"); |
| 226 | -if ($status == 'done') $title = $langs->trans("DoneActions"); |
|
| 227 | -if ($status == 'todo') $title = $langs->trans("ToDoActions"); |
|
| 258 | +if ($status == 'done') { |
|
| 259 | + $title = $langs->trans("DoneActions"); |
|
| 260 | +} |
|
| 261 | +if ($status == 'todo') { |
|
| 262 | + $title = $langs->trans("ToDoActions"); |
|
| 263 | +} |
|
| 228 | 264 | |
| 229 | 265 | $param = ''; |
| 230 | 266 | if ($actioncode || GETPOSTISSET('search_actioncode')) { |
| 231 | 267 | if (is_array($actioncode)) { |
| 232 | - foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); |
|
| 233 | - } else $param .= "&search_actioncode=".urlencode($actioncode); |
|
| 268 | + foreach ($actioncode as $str_action) { |
|
| 269 | + $param .= "&search_actioncode[]=".urlencode($str_action); |
|
| 270 | + } |
|
| 271 | + } else { |
|
| 272 | + $param .= "&search_actioncode=".urlencode($actioncode); |
|
| 273 | + } |
|
| 274 | + } |
|
| 275 | +if ($resourceid > 0) { |
|
| 276 | + $param .= "&search_resourceid=".urlencode($resourceid); |
|
| 277 | +} |
|
| 278 | +if ($status || GETPOSTISSET('status')) { |
|
| 279 | + $param .= "&search_status=".urlencode($status); |
|
| 280 | +} |
|
| 281 | +if ($filter) { |
|
| 282 | + $param .= "&search_filter=".urlencode($filter); |
|
| 283 | +} |
|
| 284 | +if ($filtert) { |
|
| 285 | + $param .= "&search_filtert=".urlencode($filtert); |
|
| 286 | +} |
|
| 287 | +if ($usergroup > 0) { |
|
| 288 | + $param .= "&search_usergroup=".urlencode($usergroup); |
|
| 289 | +} |
|
| 290 | +if ($socid > 0) { |
|
| 291 | + $param .= "&search_socid=".urlencode($socid); |
|
| 292 | +} |
|
| 293 | +if ($showbirthday) { |
|
| 294 | + $param .= "&search_showbirthday=1"; |
|
| 295 | +} |
|
| 296 | +if ($pid) { |
|
| 297 | + $param .= "&search_projectid=".urlencode($pid); |
|
| 298 | +} |
|
| 299 | +if ($type) { |
|
| 300 | + $param .= "&search_type=".urlencode($type); |
|
| 301 | +} |
|
| 302 | +if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser') { |
|
| 303 | + $param .= '&action='.urlencode($action); |
|
| 304 | +} |
|
| 305 | +if ($begin_h != '') { |
|
| 306 | + $param .= '&begin_h='.urlencode($begin_h); |
|
| 307 | +} |
|
| 308 | +if ($end_h != '') { |
|
| 309 | + $param .= '&end_h='.urlencode($end_h); |
|
| 310 | +} |
|
| 311 | +if ($begin_d != '') { |
|
| 312 | + $param .= '&begin_d='.urlencode($begin_d); |
|
| 313 | +} |
|
| 314 | +if ($end_d != '') { |
|
| 315 | + $param .= '&end_d='.urlencode($end_d); |
|
| 234 | 316 | } |
| 235 | -if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); |
|
| 236 | -if ($status || GETPOSTISSET('status')) $param .= "&search_status=".urlencode($status); |
|
| 237 | -if ($filter) $param .= "&search_filter=".urlencode($filter); |
|
| 238 | -if ($filtert) $param .= "&search_filtert=".urlencode($filtert); |
|
| 239 | -if ($usergroup > 0) $param .= "&search_usergroup=".urlencode($usergroup); |
|
| 240 | -if ($socid > 0) $param .= "&search_socid=".urlencode($socid); |
|
| 241 | -if ($showbirthday) $param .= "&search_showbirthday=1"; |
|
| 242 | -if ($pid) $param .= "&search_projectid=".urlencode($pid); |
|
| 243 | -if ($type) $param .= "&search_type=".urlencode($type); |
|
| 244 | -if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser') $param .= '&action='.urlencode($action); |
|
| 245 | -if ($begin_h != '') $param .= '&begin_h='.urlencode($begin_h); |
|
| 246 | -if ($end_h != '') $param .= '&end_h='.urlencode($end_h); |
|
| 247 | -if ($begin_d != '') $param .= '&begin_d='.urlencode($begin_d); |
|
| 248 | -if ($end_d != '') $param .= '&end_d='.urlencode($end_d); |
|
| 249 | 317 | $param .= "&maxprint=".urlencode($maxprint); |
| 250 | 318 | |
| 251 | 319 | $paramnoactionodate = $param; |
@@ -435,7 +503,9 @@ discard block |
||
| 435 | 503 | |
| 436 | 504 | // DEFAULT CALENDAR + AUTOEVENT CALENDAR + CONFERENCEBOOTH CALENDAR |
| 437 | 505 | $sql = 'SELECT'; |
| 438 | -if ($usergroup > 0) $sql .= " DISTINCT"; |
|
| 506 | +if ($usergroup > 0) { |
|
| 507 | + $sql .= " DISTINCT"; |
|
| 508 | +} |
|
| 439 | 509 | $sql .= ' a.id, a.label,'; |
| 440 | 510 | $sql .= ' a.datep,'; |
| 441 | 511 | $sql .= ' a.datep2,'; |
@@ -445,12 +515,20 @@ discard block |
||
| 445 | 515 | $sql .= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,'; |
| 446 | 516 | $sql .= ' ca.code, ca.libelle as type_label, ca.color, ca.type as type_type, ca.picto as type_picto'; |
| 447 | 517 | $sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; |
| 448 | -if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
| 518 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
| 519 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
| 520 | +} |
|
| 449 | 521 | // We must filter on resource table |
| 450 | -if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; |
|
| 522 | +if ($resourceid > 0) { |
|
| 523 | + $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; |
|
| 524 | +} |
|
| 451 | 525 | // We must filter on assignement table |
| 452 | -if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; |
|
| 453 | -if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
| 526 | +if ($filtert > 0 || $usergroup > 0) { |
|
| 527 | + $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; |
|
| 528 | +} |
|
| 529 | +if ($usergroup > 0) { |
|
| 530 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
| 531 | +} |
|
| 454 | 532 | $sql .= ' WHERE a.fk_action = ca.id'; |
| 455 | 533 | $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; |
| 456 | 534 | // Condition on actioncode |
@@ -458,16 +536,24 @@ discard block |
||
| 458 | 536 | { |
| 459 | 537 | if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
| 460 | 538 | { |
| 461 | - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; |
|
| 462 | - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; |
|
| 463 | - else { |
|
| 464 | - if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; |
|
| 465 | - if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; |
|
| 539 | + if ($actioncode == 'AC_NON_AUTO') { |
|
| 540 | + $sql .= " AND ca.type != 'systemauto'"; |
|
| 541 | + } elseif ($actioncode == 'AC_ALL_AUTO') { |
|
| 542 | + $sql .= " AND ca.type = 'systemauto'"; |
|
| 543 | + } else { |
|
| 544 | + if ($actioncode == 'AC_OTH') { |
|
| 545 | + $sql .= " AND ca.type != 'systemauto'"; |
|
| 546 | + } |
|
| 547 | + if ($actioncode == 'AC_OTH_AUTO') { |
|
| 548 | + $sql .= " AND ca.type = 'systemauto'"; |
|
| 549 | + } |
|
| 466 | 550 | } |
| 467 | 551 | } else { |
| 468 | - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; |
|
| 469 | - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; |
|
| 470 | - else { |
|
| 552 | + if ($actioncode == 'AC_NON_AUTO') { |
|
| 553 | + $sql .= " AND ca.type != 'systemauto'"; |
|
| 554 | + } elseif ($actioncode == 'AC_ALL_AUTO') { |
|
| 555 | + $sql .= " AND ca.type = 'systemauto'"; |
|
| 556 | + } else { |
|
| 471 | 557 | if (is_array($actioncode)) |
| 472 | 558 | { |
| 473 | 559 | $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; |
@@ -477,12 +563,22 @@ discard block |
||
| 477 | 563 | } |
| 478 | 564 | } |
| 479 | 565 | } |
| 480 | -if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); |
|
| 481 | -if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); |
|
| 482 | -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; |
|
| 483 | -if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; |
|
| 566 | +if ($resourceid > 0) { |
|
| 567 | + $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); |
|
| 568 | +} |
|
| 569 | +if ($pid) { |
|
| 570 | + $sql .= " AND a.fk_project=".$db->escape($pid); |
|
| 571 | +} |
|
| 572 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
| 573 | + $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; |
|
| 574 | +} |
|
| 575 | +if ($socid > 0) { |
|
| 576 | + $sql .= ' AND a.fk_soc = '.$socid; |
|
| 577 | +} |
|
| 484 | 578 | // We must filter on assignement table |
| 485 | -if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
| 579 | +if ($filtert > 0 || $usergroup > 0) { |
|
| 580 | + $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
| 581 | +} |
|
| 486 | 582 | if ($action == 'show_day') |
| 487 | 583 | { |
| 488 | 584 | $sql .= " AND ("; |
@@ -508,7 +604,9 @@ discard block |
||
| 508 | 604 | $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, 12, 31, $year) + (60 * 60 * 24 * 7))."')"; |
| 509 | 605 | $sql .= ')'; |
| 510 | 606 | } |
| 511 | -if ($type) $sql .= " AND ca.id = ".$type; |
|
| 607 | +if ($type) { |
|
| 608 | + $sql .= " AND ca.id = ".$type; |
|
| 609 | +} |
|
| 512 | 610 | if ($status == '0') { $sql .= " AND a.percent = 0"; } |
| 513 | 611 | if ($status == '-1') { $sql .= " AND a.percent = -1"; } // Not applicable |
| 514 | 612 | if ($status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started |
@@ -518,8 +616,12 @@ discard block |
||
| 518 | 616 | if ($filtert > 0 || $usergroup > 0) |
| 519 | 617 | { |
| 520 | 618 | $sql .= " AND ("; |
| 521 | - if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; |
|
| 522 | - if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; |
|
| 619 | + if ($filtert > 0) { |
|
| 620 | + $sql .= "ar.fk_element = ".$filtert; |
|
| 621 | + } |
|
| 622 | + if ($usergroup > 0) { |
|
| 623 | + $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; |
|
| 624 | + } |
|
| 523 | 625 | $sql .= ")"; |
| 524 | 626 | } |
| 525 | 627 | // Sort on date |
@@ -575,12 +677,18 @@ discard block |
||
| 575 | 677 | if ($event->percentage <= 0) |
| 576 | 678 | { |
| 577 | 679 | $event->date_start_in_calendar = $datep; |
| 578 | - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; |
|
| 579 | - else $event->date_end_in_calendar = $datep; |
|
| 680 | + if ($datep2 != '' && $datep2 >= $datep) { |
|
| 681 | + $event->date_end_in_calendar = $datep2; |
|
| 682 | + } else { |
|
| 683 | + $event->date_end_in_calendar = $datep; |
|
| 684 | + } |
|
| 580 | 685 | } else { |
| 581 | 686 | $event->date_start_in_calendar = $datep; |
| 582 | - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; |
|
| 583 | - else $event->date_end_in_calendar = $datep; |
|
| 687 | + if ($datep2 != '' && $datep2 >= $datep) { |
|
| 688 | + $event->date_end_in_calendar = $datep2; |
|
| 689 | + } else { |
|
| 690 | + $event->date_end_in_calendar = $datep; |
|
| 691 | + } |
|
| 584 | 692 | } |
| 585 | 693 | // Define ponctual property |
| 586 | 694 | if ($event->date_start_in_calendar == $event->date_end_in_calendar) |
@@ -598,8 +706,12 @@ discard block |
||
| 598 | 706 | //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n"; |
| 599 | 707 | $event->fetch_userassigned(); // This load $event->userassigned |
| 600 | 708 | |
| 601 | - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; |
|
| 602 | - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); |
|
| 709 | + if ($event->date_start_in_calendar < $firstdaytoshow) { |
|
| 710 | + $event->date_start_in_calendar = $firstdaytoshow; |
|
| 711 | + } |
|
| 712 | + if ($event->date_end_in_calendar >= $lastdaytoshow) { |
|
| 713 | + $event->date_end_in_calendar = ($lastdaytoshow - 1); |
|
| 714 | + } |
|
| 603 | 715 | |
| 604 | 716 | // Add an entry in actionarray for each day |
| 605 | 717 | $daycursor = $event->date_start_in_calendar; |
@@ -617,7 +729,9 @@ discard block |
||
| 617 | 729 | $j++; |
| 618 | 730 | |
| 619 | 731 | $daykey += 60 * 60 * 24; |
| 620 | - if ($daykey > $event->date_end_in_calendar) $loop = false; |
|
| 732 | + if ($daykey > $event->date_end_in_calendar) { |
|
| 733 | + $loop = false; |
|
| 734 | + } |
|
| 621 | 735 | } while ($loop); |
| 622 | 736 | |
| 623 | 737 | //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); |
@@ -641,7 +755,9 @@ discard block |
||
| 641 | 755 | { |
| 642 | 756 | include_once $color_file; |
| 643 | 757 | } |
| 644 | -if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); |
|
| 758 | +if (!is_array($theme_datacolor)) { |
|
| 759 | + $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); |
|
| 760 | +} |
|
| 645 | 761 | |
| 646 | 762 | |
| 647 | 763 | $newparam = $param; // newparam is for birthday links |
@@ -735,10 +851,16 @@ discard block |
||
| 735 | 851 | $tmpyear = $tmparray['year']; |
| 736 | 852 | |
| 737 | 853 | $style = 'cal_current_month'; |
| 738 | - if ($iter_day == 6) $style .= ' cal_other_month'; |
|
| 854 | + if ($iter_day == 6) { |
|
| 855 | + $style .= ' cal_other_month'; |
|
| 856 | + } |
|
| 739 | 857 | $today = 0; |
| 740 | - if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; |
|
| 741 | - if ($today) $style = 'cal_today_peruser'; |
|
| 858 | + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) { |
|
| 859 | + $today = 1; |
|
| 860 | + } |
|
| 861 | + if ($today) { |
|
| 862 | + $style = 'cal_today_peruser'; |
|
| 863 | + } |
|
| 742 | 864 | |
| 743 | 865 | show_day_events_pertype($typeofevent, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); |
| 744 | 866 | |
@@ -866,7 +988,8 @@ discard block |
||
| 866 | 988 | $mois = dol_print_date($daykey, '%m'); |
| 867 | 989 | $jour = dol_print_date($daykey, '%d'); |
| 868 | 990 | |
| 869 | - if ($day == $jour && $month == $mois && $year == $annee) // Is it the day we are looking for when calling function ? |
|
| 991 | + if ($day == $jour && $month == $mois && $year == $annee) { |
|
| 992 | + // Is it the day we are looking for when calling function ? |
|
| 870 | 993 | { |
| 871 | 994 | // Scan all event for this date |
| 872 | 995 | foreach ($eventarray[$daykey] as $index => $event) |
@@ -875,12 +998,18 @@ discard block |
||
| 875 | 998 | //var_dump($event); |
| 876 | 999 | |
| 877 | 1000 | $keysofuserassigned = array_keys($event->userassigned); |
| 878 | - if (!in_array($username->id, $keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show |
|
| 1001 | + } |
|
| 1002 | + if (!in_array($username->id, $keysofuserassigned)) { |
|
| 1003 | + continue; |
|
| 1004 | + } |
|
| 1005 | + // We discard record if event is from another user than user we want to show |
|
| 879 | 1006 | //if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show |
| 880 | 1007 | |
| 881 | 1008 | $parameters = array(); |
| 882 | 1009 | $reshook = $hookmanager->executeHooks('formatEvent', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks |
| 883 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 1010 | + if ($reshook < 0) { |
|
| 1011 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 1012 | + } |
|
| 884 | 1013 | |
| 885 | 1014 | $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar); |
| 886 | 1015 | |
@@ -889,7 +1018,9 @@ discard block |
||
| 889 | 1018 | if (in_array($user->id, $keysofuserassigned)) |
| 890 | 1019 | { |
| 891 | 1020 | $nummytasks++; $cssclass = 'family_mytasks'; |
| 892 | - if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color = $event->type_color; |
|
| 1021 | + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { |
|
| 1022 | + $color = $event->type_color; |
|
| 1023 | + } |
|
| 893 | 1024 | } elseif ($event->type_code == 'ICALEVENT') |
| 894 | 1025 | { |
| 895 | 1026 | $numical++; |
@@ -908,20 +1039,27 @@ discard block |
||
| 908 | 1039 | $numbirthday++; $colorindex = 2; $cssclass = 'family_birthday unsortable'; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); |
| 909 | 1040 | } else { |
| 910 | 1041 | $numother++; $cssclass = 'family_other'; |
| 911 | - if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $color = $event->type_color; |
|
| 1042 | + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { |
|
| 1043 | + $color = $event->type_color; |
|
| 1044 | + } |
|
| 912 | 1045 | } |
| 913 | 1046 | |
| 914 | - if ($color < 0) // Color was not set on user card. Set color according to color index. |
|
| 1047 | + if ($color < 0) { |
|
| 1048 | + // Color was not set on user card. Set color according to color index. |
|
| 915 | 1049 | { |
| 916 | 1050 | // Define color index if not yet defined |
| 917 | 1051 | $idusertouse = ($event->userownerid ? $event->userownerid : 0); |
| 1052 | + } |
|
| 918 | 1053 | if (isset($colorindexused[$idusertouse])) |
| 919 | 1054 | { |
| 920 | 1055 | $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user |
| 921 | 1056 | } else { |
| 922 | 1057 | $colorindex = $nextindextouse; |
| 923 | 1058 | $colorindexused[$idusertouse] = $colorindex; |
| 924 | - if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color |
|
| 1059 | + if (!empty($theme_datacolor[$nextindextouse + 1])) { |
|
| 1060 | + $nextindextouse++; |
|
| 1061 | + } |
|
| 1062 | + // Prepare to use next color |
|
| 925 | 1063 | } |
| 926 | 1064 | // Define color |
| 927 | 1065 | $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); |
@@ -940,7 +1078,9 @@ discard block |
||
| 940 | 1078 | $c = dol_mktime((int) $h + 1, 0, 0, $month, $day, $year, 'tzuserrel', 0); |
| 941 | 1079 | |
| 942 | 1080 | $dateendtouse = $event->date_end_in_calendar; |
| 943 | - if ($dateendtouse == $event->date_start_in_calendar) $dateendtouse++; |
|
| 1081 | + if ($dateendtouse == $event->date_start_in_calendar) { |
|
| 1082 | + $dateendtouse++; |
|
| 1083 | + } |
|
| 944 | 1084 | |
| 945 | 1085 | //print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'<br>'; |
| 946 | 1086 | |
@@ -953,10 +1093,15 @@ discard block |
||
| 953 | 1093 | { |
| 954 | 1094 | $tmpa = dol_getdate($event->date_start_in_calendar, true); |
| 955 | 1095 | $tmpb = dol_getdate($event->date_end_in_calendar, true); |
| 956 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel'); |
|
| 957 | - else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel'); |
|
| 1096 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { |
|
| 1097 | + $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel'); |
|
| 1098 | + } else { |
|
| 1099 | + $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel'); |
|
| 1100 | + } |
|
| 1101 | + } |
|
| 1102 | + if ($event->label) { |
|
| 1103 | + $cases1[$h][$event->id]['string'] .= ' - '.$event->label; |
|
| 958 | 1104 | } |
| 959 | - if ($event->label) $cases1[$h][$event->id]['string'] .= ' - '.$event->label; |
|
| 960 | 1105 | $cases1[$h][$event->id]['typecode'] = $event->type_code; |
| 961 | 1106 | $cases1[$h][$event->id]['color'] = $color; |
| 962 | 1107 | if ($event->fk_project > 0) |
@@ -999,10 +1144,15 @@ discard block |
||
| 999 | 1144 | { |
| 1000 | 1145 | $tmpa = dol_getdate($event->date_start_in_calendar, true); |
| 1001 | 1146 | $tmpb = dol_getdate($event->date_end_in_calendar, true); |
| 1002 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel'); |
|
| 1003 | - else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel'); |
|
| 1147 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { |
|
| 1148 | + $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel'); |
|
| 1149 | + } else { |
|
| 1150 | + $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel'); |
|
| 1151 | + } |
|
| 1152 | + } |
|
| 1153 | + if ($event->label) { |
|
| 1154 | + $cases2[$h][$event->id]['string'] .= ' - '.$event->label; |
|
| 1004 | 1155 | } |
| 1005 | - if ($event->label) $cases2[$h][$event->id]['string'] .= ' - '.$event->label; |
|
| 1006 | 1156 | $cases2[$h][$event->id]['typecode'] = $event->type_code; |
| 1007 | 1157 | $cases2[$h][$event->id]['color'] = $color; |
| 1008 | 1158 | if ($event->fk_project > 0) |
@@ -1065,52 +1215,85 @@ discard block |
||
| 1065 | 1215 | if (isset($cases1[$h]) && $cases1[$h] != '') |
| 1066 | 1216 | { |
| 1067 | 1217 | //$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
| 1068 | - if (count($cases1[$h]) > 1) $title1 .= count($cases1[$h]).' '.(count($cases1[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events")); |
|
| 1218 | + if (count($cases1[$h]) > 1) { |
|
| 1219 | + $title1 .= count($cases1[$h]).' '.(count($cases1[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events")); |
|
| 1220 | + } |
|
| 1069 | 1221 | $string1 = ' '; |
| 1070 | - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1 = 'peruser_notbusy'; |
|
| 1071 | - else $style1 = 'peruser_busy'; |
|
| 1222 | + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) { |
|
| 1223 | + $style1 = 'peruser_notbusy'; |
|
| 1224 | + } else { |
|
| 1225 | + $style1 = 'peruser_busy'; |
|
| 1226 | + } |
|
| 1072 | 1227 | foreach ($cases1[$h] as $id => $ev) |
| 1073 | 1228 | { |
| 1074 | - if ($ev['busy']) $style1 = 'peruser_busy'; |
|
| 1229 | + if ($ev['busy']) { |
|
| 1230 | + $style1 = 'peruser_busy'; |
|
| 1231 | + } |
|
| 1075 | 1232 | } |
| 1076 | 1233 | } |
| 1077 | 1234 | if (isset($cases2[$h]) && $cases2[$h] != '') |
| 1078 | 1235 | { |
| 1079 | 1236 | //$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
| 1080 | - if (count($cases2[$h]) > 1) $title2 .= count($cases2[$h]).' '.(count($cases2[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events")); |
|
| 1237 | + if (count($cases2[$h]) > 1) { |
|
| 1238 | + $title2 .= count($cases2[$h]).' '.(count($cases2[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events")); |
|
| 1239 | + } |
|
| 1081 | 1240 | $string2 = ' '; |
| 1082 | - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2 = 'peruser_notbusy'; |
|
| 1083 | - else $style2 = 'peruser_busy'; |
|
| 1241 | + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) { |
|
| 1242 | + $style2 = 'peruser_notbusy'; |
|
| 1243 | + } else { |
|
| 1244 | + $style2 = 'peruser_busy'; |
|
| 1245 | + } |
|
| 1084 | 1246 | foreach ($cases2[$h] as $id => $ev) |
| 1085 | 1247 | { |
| 1086 | - if ($ev['busy']) $style2 = 'peruser_busy'; |
|
| 1248 | + if ($ev['busy']) { |
|
| 1249 | + $style2 = 'peruser_busy'; |
|
| 1250 | + } |
|
| 1087 | 1251 | } |
| 1088 | 1252 | } |
| 1089 | 1253 | |
| 1090 | 1254 | $ids1 = ''; $ids2 = ''; |
| 1091 | - if (count($cases1[$h]) && array_keys($cases1[$h])) $ids1 = join(',', array_keys($cases1[$h])); |
|
| 1092 | - if (count($cases2[$h]) && array_keys($cases2[$h])) $ids2 = join(',', array_keys($cases2[$h])); |
|
| 1255 | + if (count($cases1[$h]) && array_keys($cases1[$h])) { |
|
| 1256 | + $ids1 = join(',', array_keys($cases1[$h])); |
|
| 1257 | + } |
|
| 1258 | + if (count($cases2[$h]) && array_keys($cases2[$h])) { |
|
| 1259 | + $ids2 = join(',', array_keys($cases2[$h])); |
|
| 1260 | + } |
|
| 1093 | 1261 | |
| 1094 | - if ($h == $begin_h) echo '<td class="'.$style.'_peruserleft cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">'; |
|
| 1095 | - else echo '<td class="'.$style.' cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">'; |
|
| 1096 | - if (count($cases1[$h]) == 1) // only 1 event |
|
| 1262 | + if ($h == $begin_h) { |
|
| 1263 | + echo '<td class="'.$style.'_peruserleft cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">'; |
|
| 1264 | + } else { |
|
| 1265 | + echo '<td class="'.$style.' cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">'; |
|
| 1266 | + } |
|
| 1267 | + if (count($cases1[$h]) == 1) { |
|
| 1268 | + // only 1 event |
|
| 1097 | 1269 | { |
| 1098 | 1270 | $output = array_slice($cases1[$h], 0, 1); |
| 1271 | + } |
|
| 1099 | 1272 | $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); |
| 1100 | - if ($output[0]['string']) $title1 .= ($title1 ? ' - ' : '').$output[0]['string']; |
|
| 1101 | - if ($output[0]['color']) $color1 = $output[0]['color']; |
|
| 1273 | + if ($output[0]['string']) { |
|
| 1274 | + $title1 .= ($title1 ? ' - ' : '').$output[0]['string']; |
|
| 1275 | + } |
|
| 1276 | + if ($output[0]['color']) { |
|
| 1277 | + $color1 = $output[0]['color']; |
|
| 1278 | + } |
|
| 1102 | 1279 | } elseif (count($cases1[$h]) > 1) |
| 1103 | 1280 | { |
| 1104 | 1281 | $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); |
| 1105 | 1282 | $color1 = '222222'; |
| 1106 | 1283 | } |
| 1107 | 1284 | |
| 1108 | - if (count($cases2[$h]) == 1) // only 1 event |
|
| 1285 | + if (count($cases2[$h]) == 1) { |
|
| 1286 | + // only 1 event |
|
| 1109 | 1287 | { |
| 1110 | 1288 | $output = array_slice($cases2[$h], 0, 1); |
| 1289 | + } |
|
| 1111 | 1290 | $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); |
| 1112 | - if ($output[0]['string']) $title2 .= ($title2 ? ' - ' : '').$output[0]['string']; |
|
| 1113 | - if ($output[0]['color']) $color2 = $output[0]['color']; |
|
| 1291 | + if ($output[0]['string']) { |
|
| 1292 | + $title2 .= ($title2 ? ' - ' : '').$output[0]['string']; |
|
| 1293 | + } |
|
| 1294 | + if ($output[0]['color']) { |
|
| 1295 | + $color2 = $output[0]['color']; |
|
| 1296 | + } |
|
| 1114 | 1297 | } elseif (count($cases2[$h]) > 1) |
| 1115 | 1298 | { |
| 1116 | 1299 | $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); |
@@ -390,9 +390,11 @@ discard block |
||
| 390 | 390 | $now = dol_now(); |
| 391 | 391 | |
| 392 | 392 | // Check parameters |
| 393 | - if (!isset($this->userownerid) || $this->userownerid === '') // $this->userownerid may be 0 (anonymous event) of > 0 |
|
| 393 | + if (!isset($this->userownerid) || $this->userownerid === '') { |
|
| 394 | + // $this->userownerid may be 0 (anonymous event) of > 0 |
|
| 394 | 395 | { |
| 395 | 396 | dol_syslog("You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING); |
| 397 | + } |
|
| 396 | 398 | $this->errors[] = 'ErrorPropertyUserowneridNotDefined'; |
| 397 | 399 | return -1; |
| 398 | 400 | } |
@@ -401,25 +403,50 @@ discard block |
||
| 401 | 403 | $this->label = dol_trunc(trim($this->label), 128); |
| 402 | 404 | $this->location = dol_trunc(trim($this->location), 128); |
| 403 | 405 | $this->note_private = dol_htmlcleanlastbr(trim(empty($this->note_private) ? $this->note : $this->note_private)); |
| 404 | - if (empty($this->percentage)) $this->percentage = 0; |
|
| 405 | - if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; |
|
| 406 | - if (empty($this->fulldayevent)) $this->fulldayevent = 0; |
|
| 407 | - if (empty($this->transparency)) $this->transparency = 0; |
|
| 408 | - if ($this->percentage > 100) $this->percentage = 100; |
|
| 406 | + if (empty($this->percentage)) { |
|
| 407 | + $this->percentage = 0; |
|
| 408 | + } |
|
| 409 | + if (empty($this->priority) || !is_numeric($this->priority)) { |
|
| 410 | + $this->priority = 0; |
|
| 411 | + } |
|
| 412 | + if (empty($this->fulldayevent)) { |
|
| 413 | + $this->fulldayevent = 0; |
|
| 414 | + } |
|
| 415 | + if (empty($this->transparency)) { |
|
| 416 | + $this->transparency = 0; |
|
| 417 | + } |
|
| 418 | + if ($this->percentage > 100) { |
|
| 419 | + $this->percentage = 100; |
|
| 420 | + } |
|
| 409 | 421 | //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; |
| 410 | - if (!empty($this->datep) && !empty($this->datef)) $this->durationp = ($this->datef - $this->datep); // deprecated |
|
| 422 | + if (!empty($this->datep) && !empty($this->datef)) { |
|
| 423 | + $this->durationp = ($this->datef - $this->datep); |
|
| 424 | + } |
|
| 425 | + // deprecated |
|
| 411 | 426 | //if (! empty($this->date) && ! empty($this->dateend)) $this->durationa=($this->dateend - $this->date); |
| 412 | - if (!empty($this->datep) && !empty($this->datef) && $this->datep > $this->datef) $this->datef = $this->datep; |
|
| 427 | + if (!empty($this->datep) && !empty($this->datef) && $this->datep > $this->datef) { |
|
| 428 | + $this->datef = $this->datep; |
|
| 429 | + } |
|
| 413 | 430 | //if (! empty($this->date) && ! empty($this->dateend) && $this->date > $this->dateend) $this->dateend=$this->date; |
| 414 | - if (!isset($this->fk_project) || $this->fk_project < 0) $this->fk_project = 0; |
|
| 431 | + if (!isset($this->fk_project) || $this->fk_project < 0) { |
|
| 432 | + $this->fk_project = 0; |
|
| 433 | + } |
|
| 415 | 434 | // For backward compatibility |
| 416 | - if ($this->elementtype == 'facture') $this->elementtype = 'invoice'; |
|
| 417 | - if ($this->elementtype == 'commande') $this->elementtype = 'order'; |
|
| 418 | - if ($this->elementtype == 'contrat') $this->elementtype = 'contract'; |
|
| 435 | + if ($this->elementtype == 'facture') { |
|
| 436 | + $this->elementtype = 'invoice'; |
|
| 437 | + } |
|
| 438 | + if ($this->elementtype == 'commande') { |
|
| 439 | + $this->elementtype = 'order'; |
|
| 440 | + } |
|
| 441 | + if ($this->elementtype == 'contrat') { |
|
| 442 | + $this->elementtype = 'contract'; |
|
| 443 | + } |
|
| 419 | 444 | |
| 420 | - if (!is_array($this->userassigned) && !empty($this->userassigned)) // For backward compatibility when userassigned was an int instead fo array |
|
| 445 | + if (!is_array($this->userassigned) && !empty($this->userassigned)) { |
|
| 446 | + // For backward compatibility when userassigned was an int instead fo array |
|
| 421 | 447 | { |
| 422 | 448 | $tmpid = $this->userassigned; |
| 449 | + } |
|
| 423 | 450 | $this->userassigned = array(); |
| 424 | 451 | $this->userassigned[$tmpid] = array('id'=>$tmpid, 'transparency'=>$this->transparency); |
| 425 | 452 | } |
@@ -428,8 +455,9 @@ discard block |
||
| 428 | 455 | $userdoneid = $this->userdoneid; |
| 429 | 456 | |
| 430 | 457 | // Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...). |
| 431 | - if (empty($this->userassigned) || count($this->userassigned) == 0 || !is_array($this->userassigned)) |
|
| 432 | - $this->userassigned = array($userownerid=>array('id'=>$userownerid, 'transparency'=>$this->transparency)); |
|
| 458 | + if (empty($this->userassigned) || count($this->userassigned) == 0 || !is_array($this->userassigned)) { |
|
| 459 | + $this->userassigned = array($userownerid=>array('id'=>$userownerid, 'transparency'=>$this->transparency)); |
|
| 460 | + } |
|
| 433 | 461 | |
| 434 | 462 | if (!$this->type_id || !$this->type_code) |
| 435 | 463 | { |
@@ -537,10 +565,12 @@ discard block |
||
| 537 | 565 | //dol_syslog(var_export($this->userassigned, true)); |
| 538 | 566 | foreach ($this->userassigned as $key => $val) |
| 539 | 567 | { |
| 540 | - if (!is_array($val)) // For backward compatibility when val=id |
|
| 568 | + if (!is_array($val)) { |
|
| 569 | + // For backward compatibility when val=id |
|
| 541 | 570 | { |
| 542 | 571 | $val = array('id'=>$val); |
| 543 | 572 | } |
| 573 | + } |
|
| 544 | 574 | |
| 545 | 575 | if ($val['id'] > 0) |
| 546 | 576 | { |
@@ -643,7 +673,9 @@ discard block |
||
| 643 | 673 | // Create clone |
| 644 | 674 | $this->context['createfromclone'] = 'createfromclone'; |
| 645 | 675 | $result = $this->create($fuser); |
| 646 | - if ($result < 0) $error++; |
|
| 676 | + if ($result < 0) { |
|
| 677 | + $error++; |
|
| 678 | + } |
|
| 647 | 679 | |
| 648 | 680 | if (!$error) |
| 649 | 681 | { |
@@ -653,7 +685,9 @@ discard block |
||
| 653 | 685 | $parameters = array('objFrom'=>$objFrom); |
| 654 | 686 | $action = ''; |
| 655 | 687 | $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
| 656 | - if ($reshook < 0) $error++; |
|
| 688 | + if ($reshook < 0) { |
|
| 689 | + $error++; |
|
| 690 | + } |
|
| 657 | 691 | } |
| 658 | 692 | |
| 659 | 693 | // Call trigger |
@@ -714,10 +748,17 @@ discard block |
||
| 714 | 748 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; |
| 715 | 749 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; |
| 716 | 750 | $sql .= " WHERE "; |
| 717 | - if ($ref) $sql .= " a.id = ".((int) $ref); // No field ref, we use id |
|
| 718 | - elseif ($ref_ext) $sql .= " a.ref_ext = '".$this->db->escape($ref_ext)."'"; |
|
| 719 | - elseif ($email_msgid) $sql .= " a.email_msgid = '".$this->db->escape($email_msgid)."'"; |
|
| 720 | - else $sql .= " a.id = ".((int) $id); |
|
| 751 | + if ($ref) { |
|
| 752 | + $sql .= " a.id = ".((int) $ref); |
|
| 753 | + } |
|
| 754 | + // No field ref, we use id |
|
| 755 | + elseif ($ref_ext) { |
|
| 756 | + $sql .= " a.ref_ext = '".$this->db->escape($ref_ext)."'"; |
|
| 757 | + } elseif ($email_msgid) { |
|
| 758 | + $sql .= " a.email_msgid = '".$this->db->escape($email_msgid)."'"; |
|
| 759 | + } else { |
|
| 760 | + $sql .= " a.id = ".((int) $id); |
|
| 761 | + } |
|
| 721 | 762 | |
| 722 | 763 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
| 723 | 764 | $resql = $this->db->query($sql); |
@@ -758,11 +799,17 @@ discard block |
||
| 758 | 799 | $this->authorid = $obj->fk_user_author; |
| 759 | 800 | $this->usermodid = $obj->fk_user_mod; |
| 760 | 801 | |
| 761 | - if (!is_object($this->author)) $this->author = new stdClass(); // To avoid warning |
|
| 802 | + if (!is_object($this->author)) { |
|
| 803 | + $this->author = new stdClass(); |
|
| 804 | + } |
|
| 805 | + // To avoid warning |
|
| 762 | 806 | $this->author->id = $obj->fk_user_author; // deprecated |
| 763 | 807 | $this->author->firstname = $obj->firstname; // deprecated |
| 764 | 808 | $this->author->lastname = $obj->lastname; // deprecated |
| 765 | - if (!is_object($this->usermod)) $this->usermod = new stdClass(); // To avoid warning |
|
| 809 | + if (!is_object($this->usermod)) { |
|
| 810 | + $this->usermod = new stdClass(); |
|
| 811 | + } |
|
| 812 | + // To avoid warning |
|
| 766 | 813 | $this->usermod->id = $obj->fk_user_mod; // deprecated |
| 767 | 814 | |
| 768 | 815 | $this->userownerid = $obj->fk_user_action; |
@@ -812,7 +859,10 @@ discard block |
||
| 812 | 859 | if ($resql) |
| 813 | 860 | { |
| 814 | 861 | // If owner is known, we must but id first into list |
| 815 | - if ($this->userownerid > 0) $this->userassigned[$this->userownerid] = array('id'=>$this->userownerid); // Set first so will be first into list. |
|
| 862 | + if ($this->userownerid > 0) { |
|
| 863 | + $this->userassigned[$this->userownerid] = array('id'=>$this->userownerid); |
|
| 864 | + } |
|
| 865 | + // Set first so will be first into list. |
|
| 816 | 866 | |
| 817 | 867 | while ($obj = $this->db->fetch_object($resql)) |
| 818 | 868 | { |
@@ -821,7 +871,10 @@ discard block |
||
| 821 | 871 | switch ($obj->element_type) { |
| 822 | 872 | case 'user': |
| 823 | 873 | $this->userassigned[$obj->fk_element] = array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency); |
| 824 | - if (empty($this->userownerid)) $this->userownerid = $obj->fk_element; // If not defined (should not happened, we fix this) |
|
| 874 | + if (empty($this->userownerid)) { |
|
| 875 | + $this->userownerid = $obj->fk_element; |
|
| 876 | + } |
|
| 877 | + // If not defined (should not happened, we fix this) |
|
| 825 | 878 | break; |
| 826 | 879 | case 'socpeople': |
| 827 | 880 | $this->socpeopleassigned[$obj->fk_element] = array('id'=>$obj->fk_element, 'mandatory'=>$obj->mandatory, 'answer_status'=>$obj->answer_status, 'transparency'=>$obj->transparency); |
@@ -1006,17 +1059,34 @@ discard block |
||
| 1006 | 1059 | // Clean parameters |
| 1007 | 1060 | $this->label = trim($this->label); |
| 1008 | 1061 | $this->note_private = dol_htmlcleanlastbr(trim(!isset($this->note_private) ? $this->note : $this->note_private)); |
| 1009 | - if (empty($this->percentage)) $this->percentage = 0; |
|
| 1010 | - if (empty($this->priority) || !is_numeric($this->priority)) $this->priority = 0; |
|
| 1011 | - if (empty($this->transparency)) $this->transparency = 0; |
|
| 1012 | - if (empty($this->fulldayevent)) $this->fulldayevent = 0; |
|
| 1013 | - if ($this->percentage > 100) $this->percentage = 100; |
|
| 1062 | + if (empty($this->percentage)) { |
|
| 1063 | + $this->percentage = 0; |
|
| 1064 | + } |
|
| 1065 | + if (empty($this->priority) || !is_numeric($this->priority)) { |
|
| 1066 | + $this->priority = 0; |
|
| 1067 | + } |
|
| 1068 | + if (empty($this->transparency)) { |
|
| 1069 | + $this->transparency = 0; |
|
| 1070 | + } |
|
| 1071 | + if (empty($this->fulldayevent)) { |
|
| 1072 | + $this->fulldayevent = 0; |
|
| 1073 | + } |
|
| 1074 | + if ($this->percentage > 100) { |
|
| 1075 | + $this->percentage = 100; |
|
| 1076 | + } |
|
| 1014 | 1077 | //if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; |
| 1015 | - if ($this->datep && $this->datef) $this->durationp = ($this->datef - $this->datep); // deprecated |
|
| 1078 | + if ($this->datep && $this->datef) { |
|
| 1079 | + $this->durationp = ($this->datef - $this->datep); |
|
| 1080 | + } |
|
| 1081 | + // deprecated |
|
| 1016 | 1082 | //if ($this->date && $this->dateend) $this->durationa=($this->dateend - $this->date); |
| 1017 | - if ($this->datep && $this->datef && $this->datep > $this->datef) $this->datef = $this->datep; |
|
| 1083 | + if ($this->datep && $this->datef && $this->datep > $this->datef) { |
|
| 1084 | + $this->datef = $this->datep; |
|
| 1085 | + } |
|
| 1018 | 1086 | //if ($this->date && $this->dateend && $this->date > $this->dateend) $this->dateend=$this->date; |
| 1019 | - if ($this->fk_project < 0) $this->fk_project = 0; |
|
| 1087 | + if ($this->fk_project < 0) { |
|
| 1088 | + $this->fk_project = 0; |
|
| 1089 | + } |
|
| 1020 | 1090 | |
| 1021 | 1091 | // Check parameters |
| 1022 | 1092 | if ($this->percentage == 0 && $this->userdoneid > 0) |
@@ -1034,7 +1104,9 @@ discard block |
||
| 1034 | 1104 | |
| 1035 | 1105 | $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; |
| 1036 | 1106 | $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; |
| 1037 | - if ($this->type_id > 0) $sql .= ", fk_action = '".$this->db->escape($this->type_id)."'"; |
|
| 1107 | + if ($this->type_id > 0) { |
|
| 1108 | + $sql .= ", fk_action = '".$this->db->escape($this->type_id)."'"; |
|
| 1109 | + } |
|
| 1038 | 1110 | $sql .= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "null"); |
| 1039 | 1111 | $sql .= ", datep = ".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null'); |
| 1040 | 1112 | $sql .= ", datep2 = ".(strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : 'null'); |
@@ -1050,8 +1122,12 @@ discard block |
||
| 1050 | 1122 | $sql .= ", fk_user_mod = ".$user->id; |
| 1051 | 1123 | $sql .= ", fk_user_action = ".($userownerid > 0 ? "'".$this->db->escape($userownerid)."'" : "null"); |
| 1052 | 1124 | $sql .= ", fk_user_done = ".($userdoneid > 0 ? "'".$this->db->escape($userdoneid)."'" : "null"); |
| 1053 | - if (!empty($this->fk_element)) $sql .= ", fk_element=".($this->fk_element ? $this->db->escape($this->fk_element) : "null"); |
|
| 1054 | - if (!empty($this->elementtype)) $sql .= ", elementtype=".($this->elementtype ? "'".$this->db->escape($this->elementtype)."'" : "null"); |
|
| 1125 | + if (!empty($this->fk_element)) { |
|
| 1126 | + $sql .= ", fk_element=".($this->fk_element ? $this->db->escape($this->fk_element) : "null"); |
|
| 1127 | + } |
|
| 1128 | + if (!empty($this->elementtype)) { |
|
| 1129 | + $sql .= ", elementtype=".($this->elementtype ? "'".$this->db->escape($this->elementtype)."'" : "null"); |
|
| 1130 | + } |
|
| 1055 | 1131 | $sql .= " WHERE id=".$this->id; |
| 1056 | 1132 | |
| 1057 | 1133 | dol_syslog(get_class($this)."::update", LOG_DEBUG); |
@@ -1077,10 +1153,12 @@ discard block |
||
| 1077 | 1153 | |
| 1078 | 1154 | foreach ($this->userassigned as $key => $val) |
| 1079 | 1155 | { |
| 1080 | - if (!is_array($val)) // For backward compatibility when val=id |
|
| 1156 | + if (!is_array($val)) { |
|
| 1157 | + // For backward compatibility when val=id |
|
| 1081 | 1158 | { |
| 1082 | 1159 | $val = array('id'=>$val); |
| 1083 | 1160 | } |
| 1161 | + } |
|
| 1084 | 1162 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; |
| 1085 | 1163 | $sql .= " VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory']) ? '0' : $val['mandatory']).", ".(empty($val['transparency']) ? '0' : $val['transparency']).", ".(empty($val['answer_status']) ? '0' : $val['answer_status']).")"; |
| 1086 | 1164 | |
@@ -1165,23 +1243,27 @@ discard block |
||
| 1165 | 1243 | $sql = "SELECT a.id"; |
| 1166 | 1244 | $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; |
| 1167 | 1245 | $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; |
| 1168 | - if (!empty($socid)) $sql .= " AND a.fk_soc = ".$socid; |
|
| 1246 | + if (!empty($socid)) { |
|
| 1247 | + $sql .= " AND a.fk_soc = ".$socid; |
|
| 1248 | + } |
|
| 1169 | 1249 | if (!empty($elementtype)) |
| 1170 | 1250 | { |
| 1171 | 1251 | if ($elementtype == 'project') { |
| 1172 | 1252 | $sql .= ' AND a.fk_project = '.$fk_element; |
| 1173 | - } |
|
| 1174 | - elseif ($elementtype == 'contact') { |
|
| 1253 | + } elseif ($elementtype == 'contact') { |
|
| 1175 | 1254 | $sql .= ' AND a.id IN'; |
| 1176 | 1255 | $sql .= " (SELECT fk_actioncomm FROM ".MAIN_DB_PREFIX."actioncomm_resources WHERE"; |
| 1177 | 1256 | $sql .= " element_type = 'socpeople' AND fk_element = ".$fk_element.')'; |
| 1178 | - } |
|
| 1179 | - else { |
|
| 1257 | + } else { |
|
| 1180 | 1258 | $sql .= " AND a.fk_element = ".(int) $fk_element." AND a.elementtype = '".$db->escape($elementtype)."'"; |
| 1181 | 1259 | } |
| 1182 | 1260 | } |
| 1183 | - if (!empty($filter)) $sql .= $filter; |
|
| 1184 | - if ($sortorder && $sortfield) $sql .= $db->order($sortfield, $sortorder); |
|
| 1261 | + if (!empty($filter)) { |
|
| 1262 | + $sql .= $filter; |
|
| 1263 | + } |
|
| 1264 | + if ($sortorder && $sortfield) { |
|
| 1265 | + $sql .= $db->order($sortfield, $sortorder); |
|
| 1266 | + } |
|
| 1185 | 1267 | $sql .= $db->plimit($limit, 0); |
| 1186 | 1268 | |
| 1187 | 1269 | $resql = $db->query($sql); |
@@ -1226,16 +1308,24 @@ discard block |
||
| 1226 | 1308 | $sql = "SELECT count(a.id) as nb"; |
| 1227 | 1309 | } |
| 1228 | 1310 | $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; |
| 1229 | - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
| 1311 | + if (!$user->rights->societe->client->voir && !$user->socid) { |
|
| 1312 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
| 1313 | + } |
|
| 1230 | 1314 | if (!$user->rights->agenda->allactions->read) { |
| 1231 | 1315 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources AS ar ON a.id = ar.fk_actioncomm AND ar.element_type ='user' AND ar.fk_element = ".$user->id; |
| 1232 | 1316 | } |
| 1233 | 1317 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; |
| 1234 | 1318 | $sql .= " WHERE 1 = 1"; |
| 1235 | - if (empty($load_state_board)) $sql .= " AND a.percent >= 0 AND a.percent < 100"; |
|
| 1319 | + if (empty($load_state_board)) { |
|
| 1320 | + $sql .= " AND a.percent >= 0 AND a.percent < 100"; |
|
| 1321 | + } |
|
| 1236 | 1322 | $sql .= " AND a.entity IN (".getEntity('agenda').")"; |
| 1237 | - if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; |
|
| 1238 | - if ($user->socid) $sql .= " AND a.fk_soc = ".$user->socid; |
|
| 1323 | + if (!$user->rights->societe->client->voir && !$user->socid) { |
|
| 1324 | + $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; |
|
| 1325 | + } |
|
| 1326 | + if ($user->socid) { |
|
| 1327 | + $sql .= " AND a.fk_soc = ".$user->socid; |
|
| 1328 | + } |
|
| 1239 | 1329 | if (!$user->rights->agenda->allactions->read) { |
| 1240 | 1330 | $sql .= " AND (a.fk_user_author = ".$user->id." OR a.fk_user_action = ".$user->id." OR a.fk_user_done = ".$user->id; |
| 1241 | 1331 | $sql .= " OR ar.fk_element = ".$user->id; // Added by PV |
@@ -1252,7 +1342,9 @@ discard block |
||
| 1252 | 1342 | $response->label = $langs->trans("ActionsToDo"); |
| 1253 | 1343 | $response->labelShort = $langs->trans("ActionsToDoShort"); |
| 1254 | 1344 | $response->url = DOL_URL_ROOT.'/comm/action/list.php?action=show_list&actioncode=0&status=todo&mainmenu=agenda'; |
| 1255 | - if ($user->rights->agenda->allactions->read) $response->url .= '&filtert=-1'; |
|
| 1345 | + if ($user->rights->agenda->allactions->read) { |
|
| 1346 | + $response->url .= '&filtert=-1'; |
|
| 1347 | + } |
|
| 1256 | 1348 | $response->img = img_object('', "action", 'class="inline-block valigntextmiddle"'); |
| 1257 | 1349 | } |
| 1258 | 1350 | // This assignment in condition is not a bug. It allows walking the results. |
@@ -1260,15 +1352,20 @@ discard block |
||
| 1260 | 1352 | if (empty($load_state_board)) { |
| 1261 | 1353 | $response->nbtodo++; |
| 1262 | 1354 | $agenda_static->datep = $this->db->jdate($obj->dp); |
| 1263 | - if ($agenda_static->hasDelay()) $response->nbtodolate++; |
|
| 1355 | + if ($agenda_static->hasDelay()) { |
|
| 1356 | + $response->nbtodolate++; |
|
| 1357 | + } |
|
| 1264 | 1358 | } else { |
| 1265 | 1359 | $this->nb["actionscomm"] = $obj->nb; |
| 1266 | 1360 | } |
| 1267 | 1361 | } |
| 1268 | 1362 | |
| 1269 | 1363 | $this->db->free($resql); |
| 1270 | - if (empty($load_state_board)) return $response; |
|
| 1271 | - else return 1; |
|
| 1364 | + if (empty($load_state_board)) { |
|
| 1365 | + return $response; |
|
| 1366 | + } else { |
|
| 1367 | + return 1; |
|
| 1368 | + } |
|
| 1272 | 1369 | } else { |
| 1273 | 1370 | dol_print_error($this->db); |
| 1274 | 1371 | $this->error = $this->db->error(); |
@@ -1316,7 +1413,9 @@ discard block |
||
| 1316 | 1413 | } |
| 1317 | 1414 | |
| 1318 | 1415 | $this->date_creation = $this->db->jdate($obj->datec); |
| 1319 | - if (!empty($obj->fk_user_mod)) $this->date_modification = $this->db->jdate($obj->datem); |
|
| 1416 | + if (!empty($obj->fk_user_mod)) { |
|
| 1417 | + $this->date_modification = $this->db->jdate($obj->datem); |
|
| 1418 | + } |
|
| 1320 | 1419 | } |
| 1321 | 1420 | $this->db->free($result); |
| 1322 | 1421 | } else { |
@@ -1353,22 +1452,40 @@ discard block |
||
| 1353 | 1452 | global $langs; |
| 1354 | 1453 | |
| 1355 | 1454 | $labelStatus = $langs->trans('StatusNotApplicable'); |
| 1356 | - if ($percent == -1 && !$hidenastatus) $labelStatus = $langs->trans('StatusNotApplicable'); |
|
| 1357 | - elseif ($percent == 0) $labelStatus = $langs->trans('StatusActionToDo').' (0%)'; |
|
| 1358 | - elseif ($percent > 0 && $percent < 100) $labelStatus = $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; |
|
| 1359 | - elseif ($percent >= 100) $labelStatus = $langs->trans('StatusActionDone').' (100%)'; |
|
| 1455 | + if ($percent == -1 && !$hidenastatus) { |
|
| 1456 | + $labelStatus = $langs->trans('StatusNotApplicable'); |
|
| 1457 | + } elseif ($percent == 0) { |
|
| 1458 | + $labelStatus = $langs->trans('StatusActionToDo').' (0%)'; |
|
| 1459 | + } elseif ($percent > 0 && $percent < 100) { |
|
| 1460 | + $labelStatus = $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; |
|
| 1461 | + } elseif ($percent >= 100) { |
|
| 1462 | + $labelStatus = $langs->trans('StatusActionDone').' (100%)'; |
|
| 1463 | + } |
|
| 1360 | 1464 | |
| 1361 | 1465 | $labelStatusShort = $langs->trans('StatusNotApplicable'); |
| 1362 | - if ($percent == -1 && !$hidenastatus) $labelStatusShort = $langs->trans('NA'); |
|
| 1363 | - elseif ($percent == 0) $labelStatusShort = '0%'; |
|
| 1364 | - elseif ($percent > 0 && $percent < 100) $labelStatusShort = $percent.'%'; |
|
| 1365 | - elseif ($percent >= 100) $labelStatusShort = '100%'; |
|
| 1466 | + if ($percent == -1 && !$hidenastatus) { |
|
| 1467 | + $labelStatusShort = $langs->trans('NA'); |
|
| 1468 | + } elseif ($percent == 0) { |
|
| 1469 | + $labelStatusShort = '0%'; |
|
| 1470 | + } elseif ($percent > 0 && $percent < 100) { |
|
| 1471 | + $labelStatusShort = $percent.'%'; |
|
| 1472 | + } elseif ($percent >= 100) { |
|
| 1473 | + $labelStatusShort = '100%'; |
|
| 1474 | + } |
|
| 1366 | 1475 | |
| 1367 | 1476 | $statusType = 'status9'; |
| 1368 | - if ($percent == -1 && !$hidenastatus) $statusType = 'status9'; |
|
| 1369 | - if ($percent == 0) $statusType = 'status1'; |
|
| 1370 | - if ($percent > 0 && $percent < 100) $statusType = 'status3'; |
|
| 1371 | - if ($percent >= 100) $statusType = 'status6'; |
|
| 1477 | + if ($percent == -1 && !$hidenastatus) { |
|
| 1478 | + $statusType = 'status9'; |
|
| 1479 | + } |
|
| 1480 | + if ($percent == 0) { |
|
| 1481 | + $statusType = 'status1'; |
|
| 1482 | + } |
|
| 1483 | + if ($percent > 0 && $percent < 100) { |
|
| 1484 | + $statusType = 'status3'; |
|
| 1485 | + } |
|
| 1486 | + if ($percent >= 100) { |
|
| 1487 | + $statusType = 'status6'; |
|
| 1488 | + } |
|
| 1372 | 1489 | |
| 1373 | 1490 | return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); |
| 1374 | 1491 | } |
@@ -1390,19 +1507,34 @@ discard block |
||
| 1390 | 1507 | { |
| 1391 | 1508 | global $conf, $langs, $user, $hookmanager, $action; |
| 1392 | 1509 | |
| 1393 | - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips |
|
| 1510 | + if (!empty($conf->dol_no_mouse_hover)) { |
|
| 1511 | + $notooltip = 1; |
|
| 1512 | + } |
|
| 1513 | + // Force disable tooltips |
|
| 1394 | 1514 | |
| 1395 | 1515 | $canread = 0; |
| 1396 | - if ($user->rights->agenda->myactions->read && $this->authorid == $user->id) $canread = 1; // Can read my event |
|
| 1397 | - if ($user->rights->agenda->myactions->read && array_key_exists($user->id, $this->userassigned)) $canread = 1; // Can read my event i am assigned |
|
| 1398 | - if ($user->rights->agenda->allactions->read) $canread = 1; // Can read all event of other |
|
| 1516 | + if ($user->rights->agenda->myactions->read && $this->authorid == $user->id) { |
|
| 1517 | + $canread = 1; |
|
| 1518 | + } |
|
| 1519 | + // Can read my event |
|
| 1520 | + if ($user->rights->agenda->myactions->read && array_key_exists($user->id, $this->userassigned)) { |
|
| 1521 | + $canread = 1; |
|
| 1522 | + } |
|
| 1523 | + // Can read my event i am assigned |
|
| 1524 | + if ($user->rights->agenda->allactions->read) { |
|
| 1525 | + $canread = 1; |
|
| 1526 | + } |
|
| 1527 | + // Can read all event of other |
|
| 1399 | 1528 | if (!$canread) |
| 1400 | 1529 | { |
| 1401 | 1530 | $option = 'nolink'; |
| 1402 | 1531 | } |
| 1403 | 1532 | |
| 1404 | 1533 | $label = $this->label; |
| 1405 | - if (empty($label)) $label = $this->libelle; // For backward compatibility |
|
| 1534 | + if (empty($label)) { |
|
| 1535 | + $label = $this->libelle; |
|
| 1536 | + } |
|
| 1537 | + // For backward compatibility |
|
| 1406 | 1538 | |
| 1407 | 1539 | $result = ''; |
| 1408 | 1540 | |
@@ -1414,22 +1546,30 @@ discard block |
||
| 1414 | 1546 | } |
| 1415 | 1547 | if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
| 1416 | 1548 | { |
| 1417 | - if ($this->type_code != 'AC_OTH_AUTO') $labeltype = $langs->trans('ActionAC_MANUAL'); |
|
| 1549 | + if ($this->type_code != 'AC_OTH_AUTO') { |
|
| 1550 | + $labeltype = $langs->trans('ActionAC_MANUAL'); |
|
| 1551 | + } |
|
| 1418 | 1552 | } |
| 1419 | 1553 | |
| 1420 | 1554 | $tooltip = img_picto('', $this->picto).' <u>'.$langs->trans('Action').'</u>'; |
| 1421 | - if (!empty($this->ref)) |
|
| 1422 | - $tooltip .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref; |
|
| 1423 | - if (!empty($label)) |
|
| 1424 | - $tooltip .= '<br><b>'.$langs->trans('Title').':</b> '.$label; |
|
| 1425 | - if (!empty($labeltype)) |
|
| 1426 | - $tooltip .= '<br><b>'.$langs->trans('Type').':</b> '.$labeltype; |
|
| 1427 | - if (!empty($this->location)) |
|
| 1428 | - $tooltip .= '<br><b>'.$langs->trans('Location').':</b> '.$this->location; |
|
| 1429 | - if (isset($this->transparency)) |
|
| 1430 | - $tooltip .= '<br><b>'.$langs->trans('Busy').':</b> '.yn($this->transparency); |
|
| 1431 | - if (!empty($this->note_private)) |
|
| 1432 | - $tooltip .= '<br><b>'.$langs->trans('Note').':</b> '.(dol_textishtml($this->note_private) ? str_replace(array("\r", "\n"), "", $this->note_private) : str_replace(array("\r", "\n"), '<br>', $this->note_private)); |
|
| 1555 | + if (!empty($this->ref)) { |
|
| 1556 | + $tooltip .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref; |
|
| 1557 | + } |
|
| 1558 | + if (!empty($label)) { |
|
| 1559 | + $tooltip .= '<br><b>'.$langs->trans('Title').':</b> '.$label; |
|
| 1560 | + } |
|
| 1561 | + if (!empty($labeltype)) { |
|
| 1562 | + $tooltip .= '<br><b>'.$langs->trans('Type').':</b> '.$labeltype; |
|
| 1563 | + } |
|
| 1564 | + if (!empty($this->location)) { |
|
| 1565 | + $tooltip .= '<br><b>'.$langs->trans('Location').':</b> '.$this->location; |
|
| 1566 | + } |
|
| 1567 | + if (isset($this->transparency)) { |
|
| 1568 | + $tooltip .= '<br><b>'.$langs->trans('Busy').':</b> '.yn($this->transparency); |
|
| 1569 | + } |
|
| 1570 | + if (!empty($this->note_private)) { |
|
| 1571 | + $tooltip .= '<br><b>'.$langs->trans('Note').':</b> '.(dol_textishtml($this->note_private) ? str_replace(array("\r", "\n"), "", $this->note_private) : str_replace(array("\r", "\n"), '<br>', $this->note_private)); |
|
| 1572 | + } |
|
| 1433 | 1573 | $linkclose = ''; |
| 1434 | 1574 | //if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color) |
| 1435 | 1575 | // $linkclose = ' style="background-color:#'.$this->type_color.'"'; |
@@ -1450,21 +1590,29 @@ discard block |
||
| 1450 | 1590 | $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
| 1451 | 1591 | $linkclose = ($hookmanager->resPrint ? $hookmanager->resPrint : $linkclose); |
| 1452 | 1592 | */ |
| 1453 | - } else $linkclose .= ' class="'.$classname.'"'; |
|
| 1593 | + } else { |
|
| 1594 | + $linkclose .= ' class="'.$classname.'"'; |
|
| 1595 | + } |
|
| 1454 | 1596 | |
| 1455 | 1597 | $url = ''; |
| 1456 | - if ($option == 'birthday') |
|
| 1457 | - $url = DOL_URL_ROOT.'/contact/perso.php?id='.$this->id; |
|
| 1458 | - elseif ($option == 'holiday') |
|
| 1459 | - $url = DOL_URL_ROOT.'/holiday/card.php?id='.$this->id; |
|
| 1460 | - else $url = DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id; |
|
| 1598 | + if ($option == 'birthday') { |
|
| 1599 | + $url = DOL_URL_ROOT.'/contact/perso.php?id='.$this->id; |
|
| 1600 | + } elseif ($option == 'holiday') { |
|
| 1601 | + $url = DOL_URL_ROOT.'/holiday/card.php?id='.$this->id; |
|
| 1602 | + } else { |
|
| 1603 | + $url = DOL_URL_ROOT.'/comm/action/card.php?id='.$this->id; |
|
| 1604 | + } |
|
| 1461 | 1605 | |
| 1462 | 1606 | if ($option !== 'nolink') |
| 1463 | 1607 | { |
| 1464 | 1608 | // Add param to save lastsearch_values or not |
| 1465 | 1609 | $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); |
| 1466 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; |
|
| 1467 | - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; |
|
| 1610 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { |
|
| 1611 | + $add_save_lastsearch_values = 1; |
|
| 1612 | + } |
|
| 1613 | + if ($add_save_lastsearch_values) { |
|
| 1614 | + $url .= '&save_lastsearch_values=1'; |
|
| 1615 | + } |
|
| 1468 | 1616 | } |
| 1469 | 1617 | |
| 1470 | 1618 | $linkstart = '<a href="'.$url.'"'; |
@@ -1479,28 +1627,39 @@ discard block |
||
| 1479 | 1627 | if ($withpicto == 2) |
| 1480 | 1628 | { |
| 1481 | 1629 | $libelle = $label; |
| 1482 | - if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle = $labeltype; |
|
| 1630 | + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { |
|
| 1631 | + $libelle = $labeltype; |
|
| 1632 | + } |
|
| 1483 | 1633 | $libelleshort = ''; |
| 1484 | 1634 | } else { |
| 1485 | 1635 | $libelle = (empty($this->libelle) ? $label : $this->libelle.(($label && $label != $this->libelle) ? ' '.$label : '')); |
| 1486 | - if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) $libelle = $labeltype; |
|
| 1487 | - if ($maxlength < 0) $libelleshort = $this->ref; |
|
| 1488 | - else $libelleshort = dol_trunc($libelle, $maxlength); |
|
| 1636 | + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($libelle)) { |
|
| 1637 | + $libelle = $labeltype; |
|
| 1638 | + } |
|
| 1639 | + if ($maxlength < 0) { |
|
| 1640 | + $libelleshort = $this->ref; |
|
| 1641 | + } else { |
|
| 1642 | + $libelleshort = dol_trunc($libelle, $maxlength); |
|
| 1643 | + } |
|
| 1489 | 1644 | } |
| 1490 | 1645 | |
| 1491 | 1646 | if ($withpicto) |
| 1492 | 1647 | { |
| 1493 | - if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) // Add code into () |
|
| 1648 | + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { |
|
| 1649 | + // Add code into () |
|
| 1494 | 1650 | { |
| 1495 | 1651 | if ($labeltype) |
| 1496 | 1652 | { |
| 1497 | 1653 | $libelle .= (preg_match('/'.preg_quote($labeltype, '/').'/', $libelle) ? '' : ' ('.$langs->transnoentities("Action".$this->type_code).')'); |
| 1654 | + } |
|
| 1498 | 1655 | } |
| 1499 | 1656 | } |
| 1500 | 1657 | } |
| 1501 | 1658 | |
| 1502 | 1659 | $result .= $linkstart; |
| 1503 | - if ($withpicto) $result .= img_object(($notooltip ? '' : $langs->trans("ShowAction").': '.$libelle), ($overwritepicto ? $overwritepicto : 'action'), (($this->type_color && $overwritepicto) ? 'style="color: #'.$this->type_color.' !important;" ' : '').($notooltip ? 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"' : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
| 1660 | + if ($withpicto) { |
|
| 1661 | + $result .= img_object(($notooltip ? '' : $langs->trans("ShowAction").': '.$libelle), ($overwritepicto ? $overwritepicto : 'action'), (($this->type_color && $overwritepicto) ? 'style="color: #'.$this->type_color.' !important;" ' : '').($notooltip ? 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"' : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
| 1662 | + } |
|
| 1504 | 1663 | $result .= $libelleshort; |
| 1505 | 1664 | $result .= $linkend; |
| 1506 | 1665 | |
@@ -1508,8 +1667,11 @@ discard block |
||
| 1508 | 1667 | $hookmanager->initHooks(array('actiondao')); |
| 1509 | 1668 | $parameters = array('id'=>$this->id, 'getnomurl'=>$result); |
| 1510 | 1669 | $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
| 1511 | - if ($reshook > 0) $result = $hookmanager->resPrint; |
|
| 1512 | - else $result .= $hookmanager->resPrint; |
|
| 1670 | + if ($reshook > 0) { |
|
| 1671 | + $result = $hookmanager->resPrint; |
|
| 1672 | + } else { |
|
| 1673 | + $result .= $hookmanager->resPrint; |
|
| 1674 | + } |
|
| 1513 | 1675 | |
| 1514 | 1676 | return $result; |
| 1515 | 1677 | } |
@@ -1533,19 +1695,31 @@ discard block |
||
| 1533 | 1695 | if ($this->type_picto) { |
| 1534 | 1696 | $imgpicto = img_picto('', $this->type_picto, 'class="paddingright"'); |
| 1535 | 1697 | } else { |
| 1536 | - if ($this->type_code == 'AC_RDV') $imgpicto = img_picto('', 'meeting', $color, false, 0, 0, '', 'paddingright'); |
|
| 1537 | - elseif ($this->type_code == 'AC_TEL') $imgpicto = img_picto('', 'object_phoning', $color, false, 0, 0, '', 'paddingright'); |
|
| 1538 | - elseif ($this->type_code == 'AC_FAX') $imgpicto = img_picto('', 'object_phoning_fax', $color, false, 0, 0, '', 'paddingright'); |
|
| 1539 | - elseif ($this->type_code == 'AC_EMAIL' || $this->type_code == 'AC_EMAIL_IN') $imgpicto = img_picto('', 'object_email', $color, false, 0, 0, '', 'paddingright'); |
|
| 1540 | - elseif ($this->type_code == 'AC_INT') $imgpicto = img_picto('', 'object_intervention', $color, false, 0, 0, '', 'paddingright'); |
|
| 1541 | - elseif ($this->type_code == 'AC_OTH' && $this->code == 'TICKET_MSG') $imgpicto = img_picto('', 'object_conversation', $color, false, 0, 0, '', 'paddingright'); |
|
| 1542 | - elseif ($this->type != 'systemauto') $imgpicto = img_picto('', 'user-cog', $color, false, 0, 0, '', 'paddingright'); |
|
| 1543 | - else $imgpicto = img_picto('', 'cog', $color, false, 0, 0, '', 'paddingright'); |
|
| 1698 | + if ($this->type_code == 'AC_RDV') { |
|
| 1699 | + $imgpicto = img_picto('', 'meeting', $color, false, 0, 0, '', 'paddingright'); |
|
| 1700 | + } elseif ($this->type_code == 'AC_TEL') { |
|
| 1701 | + $imgpicto = img_picto('', 'object_phoning', $color, false, 0, 0, '', 'paddingright'); |
|
| 1702 | + } elseif ($this->type_code == 'AC_FAX') { |
|
| 1703 | + $imgpicto = img_picto('', 'object_phoning_fax', $color, false, 0, 0, '', 'paddingright'); |
|
| 1704 | + } elseif ($this->type_code == 'AC_EMAIL' || $this->type_code == 'AC_EMAIL_IN') { |
|
| 1705 | + $imgpicto = img_picto('', 'object_email', $color, false, 0, 0, '', 'paddingright'); |
|
| 1706 | + } elseif ($this->type_code == 'AC_INT') { |
|
| 1707 | + $imgpicto = img_picto('', 'object_intervention', $color, false, 0, 0, '', 'paddingright'); |
|
| 1708 | + } elseif ($this->type_code == 'AC_OTH' && $this->code == 'TICKET_MSG') { |
|
| 1709 | + $imgpicto = img_picto('', 'object_conversation', $color, false, 0, 0, '', 'paddingright'); |
|
| 1710 | + } elseif ($this->type != 'systemauto') { |
|
| 1711 | + $imgpicto = img_picto('', 'user-cog', $color, false, 0, 0, '', 'paddingright'); |
|
| 1712 | + } else { |
|
| 1713 | + $imgpicto = img_picto('', 'cog', $color, false, 0, 0, '', 'paddingright'); |
|
| 1714 | + } |
|
| 1544 | 1715 | } |
| 1545 | 1716 | } else { |
| 1546 | 1717 | // 2 picto: 1 for auto, 1 for manual |
| 1547 | - if ($this->type != 'systemauto') $imgpicto = img_picto('', 'user-cog', '', false, 0, 0, '', 'paddingright'); |
|
| 1548 | - else $imgpicto = img_picto('', 'cog', '', false, 0, 0, '', 'paddingright'); |
|
| 1718 | + if ($this->type != 'systemauto') { |
|
| 1719 | + $imgpicto = img_picto('', 'user-cog', '', false, 0, 0, '', 'paddingright'); |
|
| 1720 | + } else { |
|
| 1721 | + $imgpicto = img_picto('', 'cog', '', false, 0, 0, '', 'paddingright'); |
|
| 1722 | + } |
|
| 1549 | 1723 | } |
| 1550 | 1724 | return $imgpicto; |
| 1551 | 1725 | } |
@@ -1622,13 +1796,17 @@ discard block |
||
| 1622 | 1796 | dol_syslog(get_class($this)."::build_exportfile Build export file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".count($filters), LOG_DEBUG); |
| 1623 | 1797 | |
| 1624 | 1798 | // Check parameters |
| 1625 | - if (empty($format)) return -1; |
|
| 1799 | + if (empty($format)) { |
|
| 1800 | + return -1; |
|
| 1801 | + } |
|
| 1626 | 1802 | |
| 1627 | 1803 | // Clean parameters |
| 1628 | 1804 | if (!$filename) |
| 1629 | 1805 | { |
| 1630 | 1806 | $extension = 'vcs'; |
| 1631 | - if ($format == 'ical') $extension = 'ics'; |
|
| 1807 | + if ($format == 'ical') { |
|
| 1808 | + $extension = 'ics'; |
|
| 1809 | + } |
|
| 1632 | 1810 | $filename = $format.'.'.$extension; |
| 1633 | 1811 | } |
| 1634 | 1812 | |
@@ -1683,21 +1861,41 @@ discard block |
||
| 1683 | 1861 | $sql .= $hookmanager->resPrint; |
| 1684 | 1862 | |
| 1685 | 1863 | // We must filter on assignement table |
| 1686 | - if ($filters['logint']) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; |
|
| 1864 | + if ($filters['logint']) { |
|
| 1865 | + $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; |
|
| 1866 | + } |
|
| 1687 | 1867 | $sql .= " WHERE a.fk_action=c.id"; |
| 1688 | 1868 | $sql .= " AND a.entity IN (".getEntity('agenda').")"; |
| 1689 | 1869 | foreach ($filters as $key => $value) |
| 1690 | 1870 | { |
| 1691 | - if ($key == 'notolderthan' && $value != '') $sql .= " AND a.datep >= '".$this->db->idate($now - ($value * 24 * 60 * 60))."'"; |
|
| 1692 | - if ($key == 'year') $sql .= " AND a.datep BETWEEN '".$this->db->idate(dol_get_first_day($value, 1))."' AND '".$this->db->idate(dol_get_last_day($value, 12))."'"; |
|
| 1693 | - if ($key == 'id') $sql .= " AND a.id=".(is_numeric($value) ? $value : 0); |
|
| 1694 | - if ($key == 'idfrom') $sql .= " AND a.id >= ".(is_numeric($value) ? $value : 0); |
|
| 1695 | - if ($key == 'idto') $sql .= " AND a.id <= ".(is_numeric($value) ? $value : 0); |
|
| 1696 | - if ($key == 'project') $sql .= " AND a.fk_project=".(is_numeric($value) ? $value : 0); |
|
| 1697 | - if ($key == 'actiontype') $sql .= " AND c.type = '".$this->db->escape($value)."'"; |
|
| 1698 | - if ($key == 'notactiontype') $sql .= " AND c.type <> '".$this->db->escape($value)."'"; |
|
| 1871 | + if ($key == 'notolderthan' && $value != '') { |
|
| 1872 | + $sql .= " AND a.datep >= '".$this->db->idate($now - ($value * 24 * 60 * 60))."'"; |
|
| 1873 | + } |
|
| 1874 | + if ($key == 'year') { |
|
| 1875 | + $sql .= " AND a.datep BETWEEN '".$this->db->idate(dol_get_first_day($value, 1))."' AND '".$this->db->idate(dol_get_last_day($value, 12))."'"; |
|
| 1876 | + } |
|
| 1877 | + if ($key == 'id') { |
|
| 1878 | + $sql .= " AND a.id=".(is_numeric($value) ? $value : 0); |
|
| 1879 | + } |
|
| 1880 | + if ($key == 'idfrom') { |
|
| 1881 | + $sql .= " AND a.id >= ".(is_numeric($value) ? $value : 0); |
|
| 1882 | + } |
|
| 1883 | + if ($key == 'idto') { |
|
| 1884 | + $sql .= " AND a.id <= ".(is_numeric($value) ? $value : 0); |
|
| 1885 | + } |
|
| 1886 | + if ($key == 'project') { |
|
| 1887 | + $sql .= " AND a.fk_project=".(is_numeric($value) ? $value : 0); |
|
| 1888 | + } |
|
| 1889 | + if ($key == 'actiontype') { |
|
| 1890 | + $sql .= " AND c.type = '".$this->db->escape($value)."'"; |
|
| 1891 | + } |
|
| 1892 | + if ($key == 'notactiontype') { |
|
| 1893 | + $sql .= " AND c.type <> '".$this->db->escape($value)."'"; |
|
| 1894 | + } |
|
| 1699 | 1895 | // We must filter on assignement table |
| 1700 | - if ($key == 'logint') $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
| 1896 | + if ($key == 'logint') { |
|
| 1897 | + $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
| 1898 | + } |
|
| 1701 | 1899 | if ($key == 'logina') |
| 1702 | 1900 | { |
| 1703 | 1901 | $logina = $value; |
@@ -1709,8 +1907,11 @@ discard block |
||
| 1709 | 1907 | } |
| 1710 | 1908 | $userforfilter = new User($this->db); |
| 1711 | 1909 | $result = $userforfilter->fetch('', $logina); |
| 1712 | - if ($result > 0) $sql .= " AND a.fk_user_author ".$condition." ".$userforfilter->id; |
|
| 1713 | - elseif ($result < 0 || $condition == '=') $sql .= " AND a.fk_user_author = 0"; |
|
| 1910 | + if ($result > 0) { |
|
| 1911 | + $sql .= " AND a.fk_user_author ".$condition." ".$userforfilter->id; |
|
| 1912 | + } elseif ($result < 0 || $condition == '=') { |
|
| 1913 | + $sql .= " AND a.fk_user_author = 0"; |
|
| 1914 | + } |
|
| 1714 | 1915 | } |
| 1715 | 1916 | if ($key == 'logint') |
| 1716 | 1917 | { |
@@ -1723,8 +1924,11 @@ discard block |
||
| 1723 | 1924 | } |
| 1724 | 1925 | $userforfilter = new User($this->db); |
| 1725 | 1926 | $result = $userforfilter->fetch('', $logint); |
| 1726 | - if ($result > 0) $sql .= " AND ar.fk_element = ".$userforfilter->id; |
|
| 1727 | - elseif ($result < 0 || $condition == '=') $sql .= " AND ar.fk_element = 0"; |
|
| 1927 | + if ($result > 0) { |
|
| 1928 | + $sql .= " AND ar.fk_element = ".$userforfilter->id; |
|
| 1929 | + } elseif ($result < 0 || $condition == '=') { |
|
| 1930 | + $sql .= " AND ar.fk_element = 0"; |
|
| 1931 | + } |
|
| 1728 | 1932 | } |
| 1729 | 1933 | } |
| 1730 | 1934 | |
@@ -1904,10 +2108,18 @@ discard block |
||
| 1904 | 2108 | |
| 1905 | 2109 | // Define title and desc |
| 1906 | 2110 | $more = ''; |
| 1907 | - if ($login) $more = $langs->transnoentities("User").' '.$login; |
|
| 1908 | - if ($logina) $more = $langs->transnoentities("ActionsAskedBy").' '.$logina; |
|
| 1909 | - if ($logint) $more = $langs->transnoentities("ActionsToDoBy").' '.$logint; |
|
| 1910 | - if ($logind) $more = $langs->transnoentities("ActionsDoneBy").' '.$logind; |
|
| 2111 | + if ($login) { |
|
| 2112 | + $more = $langs->transnoentities("User").' '.$login; |
|
| 2113 | + } |
|
| 2114 | + if ($logina) { |
|
| 2115 | + $more = $langs->transnoentities("ActionsAskedBy").' '.$logina; |
|
| 2116 | + } |
|
| 2117 | + if ($logint) { |
|
| 2118 | + $more = $langs->transnoentities("ActionsToDoBy").' '.$logint; |
|
| 2119 | + } |
|
| 2120 | + if ($logind) { |
|
| 2121 | + $more = $langs->transnoentities("ActionsDoneBy").' '.$logind; |
|
| 2122 | + } |
|
| 1911 | 2123 | if ($more) |
| 1912 | 2124 | { |
| 1913 | 2125 | $title = 'Dolibarr actions '.$mysoc->name.' - '.$more; |
@@ -1924,14 +2136,19 @@ discard block |
||
| 1924 | 2136 | @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); |
| 1925 | 2137 | |
| 1926 | 2138 | // Write file |
| 1927 | - if ($format == 'vcal') $result = build_calfile($format, $title, $desc, $eventarray, $outputfiletmp); |
|
| 1928 | - elseif ($format == 'ical') $result = build_calfile($format, $title, $desc, $eventarray, $outputfiletmp); |
|
| 1929 | - elseif ($format == 'rss') $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp); |
|
| 2139 | + if ($format == 'vcal') { |
|
| 2140 | + $result = build_calfile($format, $title, $desc, $eventarray, $outputfiletmp); |
|
| 2141 | + } elseif ($format == 'ical') { |
|
| 2142 | + $result = build_calfile($format, $title, $desc, $eventarray, $outputfiletmp); |
|
| 2143 | + } elseif ($format == 'rss') { |
|
| 2144 | + $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp); |
|
| 2145 | + } |
|
| 1930 | 2146 | |
| 1931 | 2147 | if ($result >= 0) |
| 1932 | 2148 | { |
| 1933 | - if (dol_move($outputfiletmp, $outputfile, 0, 1)) $result = 1; |
|
| 1934 | - else { |
|
| 2149 | + if (dol_move($outputfiletmp, $outputfile, 0, 1)) { |
|
| 2150 | + $result = 1; |
|
| 2151 | + } else { |
|
| 1935 | 2152 | $this->error = 'Failed to rename '.$outputfiletmp.' into '.$outputfile; |
| 1936 | 2153 | dol_syslog(get_class($this)."::build_exportfile ".$this->error, LOG_ERR); |
| 1937 | 2154 | dol_delete_file($outputfiletmp, 0, 1); |
@@ -2046,8 +2263,12 @@ discard block |
||
| 2046 | 2263 | if ($fk_user > 0) { |
| 2047 | 2264 | $sql .= " AND fk_user = ".((int) $fk_user); |
| 2048 | 2265 | } |
| 2049 | - if (empty($conf->global->AGENDA_REMINDER_EMAIL)) $sql .= " AND typeremind != 'email'"; |
|
| 2050 | - if (empty($conf->global->AGENDA_REMINDER_BROWSER)) $sql .= " AND typeremind != 'browser'"; |
|
| 2266 | + if (empty($conf->global->AGENDA_REMINDER_EMAIL)) { |
|
| 2267 | + $sql .= " AND typeremind != 'email'"; |
|
| 2268 | + } |
|
| 2269 | + if (empty($conf->global->AGENDA_REMINDER_BROWSER)) { |
|
| 2270 | + $sql .= " AND typeremind != 'browser'"; |
|
| 2271 | + } |
|
| 2051 | 2272 | |
| 2052 | 2273 | $sql .= $this->db->order("dateremind", "ASC"); |
| 2053 | 2274 | $resql = $this->db->query($sql); |
@@ -2090,9 +2311,11 @@ discard block |
||
| 2090 | 2311 | $nbMailSend = 0; |
| 2091 | 2312 | $errorsMsg = array(); |
| 2092 | 2313 | |
| 2093 | - if (empty($conf->agenda->enabled)) // Should not happen. If module disabled, cron job should not be visible. |
|
| 2314 | + if (empty($conf->agenda->enabled)) { |
|
| 2315 | + // Should not happen. If module disabled, cron job should not be visible. |
|
| 2094 | 2316 | { |
| 2095 | 2317 | $langs->load("agenda"); |
| 2318 | + } |
|
| 2096 | 2319 | $this->output = $langs->trans('ModuleNotEnabled', $langs->transnoentitiesnoconv("Agenda")); |
| 2097 | 2320 | return 0; |
| 2098 | 2321 | } |
@@ -106,8 +106,11 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | $sql = "SELECT id, code, type, libelle as label, color, active, picto"; |
| 108 | 108 | $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; |
| 109 | - if (is_numeric($id)) $sql .= " WHERE id=".(int) $id; |
|
| 110 | - else $sql .= " WHERE code='".$this->db->escape($id)."'"; |
|
| 109 | + if (is_numeric($id)) { |
|
| 110 | + $sql .= " WHERE id=".(int) $id; |
|
| 111 | + } else { |
|
| 112 | + $sql .= " WHERE code='".$this->db->escape($id)."'"; |
|
| 113 | + } |
|
| 111 | 114 | |
| 112 | 115 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
| 113 | 116 | $resql = $this->db->query($sql); |
@@ -165,8 +168,12 @@ discard block |
||
| 165 | 168 | if ($active != '') { |
| 166 | 169 | $sql .= " AND active=".(int) $active; |
| 167 | 170 | } |
| 168 | - if (!empty($excludetype)) $sql .= " AND type <> '".$this->db->escape($excludetype)."'"; |
|
| 169 | - if ($morefilter) $sql .= " AND ".$morefilter; |
|
| 171 | + if (!empty($excludetype)) { |
|
| 172 | + $sql .= " AND type <> '".$this->db->escape($excludetype)."'"; |
|
| 173 | + } |
|
| 174 | + if ($morefilter) { |
|
| 175 | + $sql .= " AND ".$morefilter; |
|
| 176 | + } |
|
| 170 | 177 | $sql .= " ORDER BY type, position, module"; |
| 171 | 178 | |
| 172 | 179 | dol_syslog(get_class($this)."::liste_array", LOG_DEBUG); |
@@ -185,16 +192,31 @@ discard block |
||
| 185 | 192 | $qualified = 1; |
| 186 | 193 | |
| 187 | 194 | // $obj->type can be system, systemauto, module, moduleauto, xxx, xxxauto |
| 188 | - if ($qualified && $onlyautoornot > 0 && preg_match('/^system/', $obj->type) && !preg_match('/^AC_OTH/', $obj->code)) $qualified = 0; // We discard detailed system events. We keep only the 2 generic lines (AC_OTH and AC_OTH_AUTO) |
|
| 195 | + if ($qualified && $onlyautoornot > 0 && preg_match('/^system/', $obj->type) && !preg_match('/^AC_OTH/', $obj->code)) { |
|
| 196 | + $qualified = 0; |
|
| 197 | + } |
|
| 198 | + // We discard detailed system events. We keep only the 2 generic lines (AC_OTH and AC_OTH_AUTO) |
|
| 189 | 199 | |
| 190 | 200 | if ($qualified && $obj->module) |
| 191 | 201 | { |
| 192 | - if ($obj->module == 'invoice' && !$conf->facture->enabled) $qualified = 0; |
|
| 193 | - if ($obj->module == 'order' && !$conf->commande->enabled) $qualified = 0; |
|
| 194 | - if ($obj->module == 'propal' && !$conf->propal->enabled) $qualified = 0; |
|
| 195 | - if ($obj->module == 'invoice_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !$conf->supplier_invoice->enabled)) $qualified = 0; |
|
| 196 | - if ($obj->module == 'order_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !$conf->supplier_order->enabled)) $qualified = 0; |
|
| 197 | - if ($obj->module == 'shipping' && !$conf->expedition->enabled) $qualified = 0; |
|
| 202 | + if ($obj->module == 'invoice' && !$conf->facture->enabled) { |
|
| 203 | + $qualified = 0; |
|
| 204 | + } |
|
| 205 | + if ($obj->module == 'order' && !$conf->commande->enabled) { |
|
| 206 | + $qualified = 0; |
|
| 207 | + } |
|
| 208 | + if ($obj->module == 'propal' && !$conf->propal->enabled) { |
|
| 209 | + $qualified = 0; |
|
| 210 | + } |
|
| 211 | + if ($obj->module == 'invoice_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !$conf->supplier_invoice->enabled)) { |
|
| 212 | + $qualified = 0; |
|
| 213 | + } |
|
| 214 | + if ($obj->module == 'order_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !$conf->supplier_order->enabled)) { |
|
| 215 | + $qualified = 0; |
|
| 216 | + } |
|
| 217 | + if ($obj->module == 'shipping' && !$conf->expedition->enabled) { |
|
| 218 | + $qualified = 0; |
|
| 219 | + } |
|
| 198 | 220 | } |
| 199 | 221 | |
| 200 | 222 | if ($qualified) |
@@ -204,9 +226,13 @@ discard block |
||
| 204 | 226 | $code = $obj->code; |
| 205 | 227 | $typecalendar = $obj->type; |
| 206 | 228 | |
| 207 | - if ($onlyautoornot > 0 && $typecalendar == 'system') $code = 'AC_MANUAL'; |
|
| 208 | - elseif ($onlyautoornot > 0 && $typecalendar == 'systemauto') $code = 'AC_AUTO'; |
|
| 209 | - elseif ($onlyautoornot > 0) $code = 'AC_'.strtoupper($obj->module); |
|
| 229 | + if ($onlyautoornot > 0 && $typecalendar == 'system') { |
|
| 230 | + $code = 'AC_MANUAL'; |
|
| 231 | + } elseif ($onlyautoornot > 0 && $typecalendar == 'systemauto') { |
|
| 232 | + $code = 'AC_AUTO'; |
|
| 233 | + } elseif ($onlyautoornot > 0) { |
|
| 234 | + $code = 'AC_'.strtoupper($obj->module); |
|
| 235 | + } |
|
| 210 | 236 | |
| 211 | 237 | if ($shortlabel) |
| 212 | 238 | { |
@@ -252,9 +278,13 @@ discard block |
||
| 252 | 278 | } |
| 253 | 279 | } |
| 254 | 280 | |
| 255 | - if ($idorcode == 'id') $this->liste_array = $repid; |
|
| 256 | - elseif ($idorcode == 'code') $this->liste_array = $repcode; |
|
| 257 | - else $this->liste_array = $repall; |
|
| 281 | + if ($idorcode == 'id') { |
|
| 282 | + $this->liste_array = $repid; |
|
| 283 | + } elseif ($idorcode == 'code') { |
|
| 284 | + $this->liste_array = $repcode; |
|
| 285 | + } else { |
|
| 286 | + $this->liste_array = $repall; |
|
| 287 | + } |
|
| 258 | 288 | |
| 259 | 289 | return $this->liste_array; |
| 260 | 290 | } else { |
@@ -276,6 +306,8 @@ discard block |
||
| 276 | 306 | |
| 277 | 307 | // Check if translation available |
| 278 | 308 | $transcode = $langs->trans("Action".$this->code); |
| 279 | - if ($transcode != "Action".$this->code) return $transcode; |
|
| 309 | + if ($transcode != "Action".$this->code) { |
|
| 310 | + return $transcode; |
|
| 311 | + } |
|
| 280 | 312 | } |
| 281 | 313 | } |
@@ -39,7 +39,9 @@ discard block |
||
| 39 | 39 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
| 40 | 40 | |
| 41 | 41 | |
| 42 | -if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; |
|
| 42 | +if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) { |
|
| 43 | + $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3; |
|
| 44 | +} |
|
| 43 | 45 | |
| 44 | 46 | $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3); |
| 45 | 47 | $filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); |
@@ -60,22 +62,36 @@ discard block |
||
| 60 | 62 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
| 61 | 63 | $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; |
| 62 | 64 | $offset = $limit * $page; |
| 63 | -if (!$sortorder) $sortorder = "ASC"; |
|
| 64 | -if (!$sortfield) $sortfield = "a.datec"; |
|
| 65 | +if (!$sortorder) { |
|
| 66 | + $sortorder = "ASC"; |
|
| 67 | +} |
|
| 68 | +if (!$sortfield) { |
|
| 69 | + $sortfield = "a.datec"; |
|
| 70 | +} |
|
| 65 | 71 | |
| 66 | 72 | // Security check |
| 67 | 73 | $socid = GETPOST("search_socid", "int") ?GETPOST("search_socid", "int") : GETPOST("socid", "int"); |
| 68 | -if ($user->socid) $socid = $user->socid; |
|
| 74 | +if ($user->socid) { |
|
| 75 | + $socid = $user->socid; |
|
| 76 | +} |
|
| 69 | 77 | $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); |
| 70 | -if ($socid < 0) $socid = ''; |
|
| 78 | +if ($socid < 0) { |
|
| 79 | + $socid = ''; |
|
| 80 | +} |
|
| 71 | 81 | |
| 72 | 82 | $canedit = 1; |
| 73 | -if (!$user->rights->agenda->myactions->read) accessforbidden(); |
|
| 74 | -if (!$user->rights->agenda->allactions->read) $canedit = 0; |
|
| 75 | -if (!$user->rights->agenda->allactions->read || $filter == 'mine') // If no permission to see all, we show only affected to me |
|
| 83 | +if (!$user->rights->agenda->myactions->read) { |
|
| 84 | + accessforbidden(); |
|
| 85 | +} |
|
| 86 | +if (!$user->rights->agenda->allactions->read) { |
|
| 87 | + $canedit = 0; |
|
| 88 | +} |
|
| 89 | +if (!$user->rights->agenda->allactions->read || $filter == 'mine') { |
|
| 90 | + // If no permission to see all, we show only affected to me |
|
| 76 | 91 | { |
| 77 | 92 | $filtert = $user->id; |
| 78 | 93 | } |
| 94 | +} |
|
| 79 | 95 | |
| 80 | 96 | //$action=GETPOST('action','alpha'); |
| 81 | 97 | $action = 'show_peruser'; //We use 'show_week' mode |
@@ -93,11 +109,15 @@ discard block |
||
| 93 | 109 | if (GETPOST('search_actioncode', 'array')) |
| 94 | 110 | { |
| 95 | 111 | $actioncode = GETPOST('search_actioncode', 'array', 3); |
| 96 | - if (!count($actioncode)) $actioncode = '0'; |
|
| 97 | -} else { |
|
| 112 | + if (!count($actioncode)) { |
|
| 113 | + $actioncode = '0'; |
|
| 114 | + } |
|
| 115 | + } else { |
|
| 98 | 116 | $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode", "alpha") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); |
| 99 | 117 | } |
| 100 | -if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); |
|
| 118 | +if ($actioncode == '' && empty($actioncodearray)) { |
|
| 119 | + $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE); |
|
| 120 | +} |
|
| 101 | 121 | |
| 102 | 122 | $dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int')); |
| 103 | 123 | if ($dateselect > 0) |
@@ -112,21 +132,37 @@ discard block |
||
| 112 | 132 | $tmparray = explode('-', $tmp); |
| 113 | 133 | $begin_h = GETPOST('begin_h', 'int') != '' ? GETPOST('begin_h', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 9); |
| 114 | 134 | $end_h = GETPOST('end_h', 'int') ? GETPOST('end_h', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 18); |
| 115 | -if ($begin_h < 0 || $begin_h > 23) $begin_h = 9; |
|
| 116 | -if ($end_h < 1 || $end_h > 24) $end_h = 18; |
|
| 117 | -if ($end_h <= $begin_h) $end_h = $begin_h + 1; |
|
| 135 | +if ($begin_h < 0 || $begin_h > 23) { |
|
| 136 | + $begin_h = 9; |
|
| 137 | +} |
|
| 138 | +if ($end_h < 1 || $end_h > 24) { |
|
| 139 | + $end_h = 18; |
|
| 140 | +} |
|
| 141 | +if ($end_h <= $begin_h) { |
|
| 142 | + $end_h = $begin_h + 1; |
|
| 143 | +} |
|
| 118 | 144 | |
| 119 | 145 | $tmp = empty($conf->global->MAIN_DEFAULT_WORKING_DAYS) ? '1-5' : $conf->global->MAIN_DEFAULT_WORKING_DAYS; |
| 120 | 146 | $tmp = str_replace(' ', '', $tmp); // FIX 7533 |
| 121 | 147 | $tmparray = explode('-', $tmp); |
| 122 | 148 | $begin_d = GETPOST('begin_d', 'int') ?GETPOST('begin_d', 'int') : ($tmparray[0] != '' ? $tmparray[0] : 1); |
| 123 | 149 | $end_d = GETPOST('end_d', 'int') ?GETPOST('end_d', 'int') : ($tmparray[1] != '' ? $tmparray[1] : 5); |
| 124 | -if ($begin_d < 1 || $begin_d > 7) $begin_d = 1; |
|
| 125 | -if ($end_d < 1 || $end_d > 7) $end_d = 7; |
|
| 126 | -if ($end_d < $begin_d) $end_d = $begin_d + 1; |
|
| 150 | +if ($begin_d < 1 || $begin_d > 7) { |
|
| 151 | + $begin_d = 1; |
|
| 152 | +} |
|
| 153 | +if ($end_d < 1 || $end_d > 7) { |
|
| 154 | + $end_d = 7; |
|
| 155 | +} |
|
| 156 | +if ($end_d < $begin_d) { |
|
| 157 | + $end_d = $begin_d + 1; |
|
| 158 | +} |
|
| 127 | 159 | |
| 128 | -if ($status == '' && !GETPOSTISSET('status')) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); |
|
| 129 | -if (empty($action) && !GETPOSTISSET('action')) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); |
|
| 160 | +if ($status == '' && !GETPOSTISSET('status')) { |
|
| 161 | + $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); |
|
| 162 | +} |
|
| 163 | +if (empty($action) && !GETPOSTISSET('action')) { |
|
| 164 | + $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); |
|
| 165 | +} |
|
| 130 | 166 | |
| 131 | 167 | if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { |
| 132 | 168 | $action = 'show_month'; $day = ''; |
@@ -185,7 +221,9 @@ discard block |
||
| 185 | 221 | 'usergroup' => $usergroup, |
| 186 | 222 | ); |
| 187 | 223 | $reshook = $hookmanager->executeHooks('beforeAgendaPerUser', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
| 188 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 224 | +if ($reshook < 0) { |
|
| 225 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 226 | +} |
|
| 189 | 227 | |
| 190 | 228 | $form = new Form($db); |
| 191 | 229 | $companystatic = new Societe($db); |
@@ -223,29 +261,65 @@ discard block |
||
| 223 | 261 | //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day; |
| 224 | 262 | |
| 225 | 263 | $title = $langs->trans("DoneAndToDoActions"); |
| 226 | -if ($status == 'done') $title = $langs->trans("DoneActions"); |
|
| 227 | -if ($status == 'todo') $title = $langs->trans("ToDoActions"); |
|
| 264 | +if ($status == 'done') { |
|
| 265 | + $title = $langs->trans("DoneActions"); |
|
| 266 | +} |
|
| 267 | +if ($status == 'todo') { |
|
| 268 | + $title = $langs->trans("ToDoActions"); |
|
| 269 | +} |
|
| 228 | 270 | |
| 229 | 271 | $param = ''; |
| 230 | 272 | if ($actioncode || GETPOSTISSET('search_actioncode')) { |
| 231 | 273 | if (is_array($actioncode)) { |
| 232 | - foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); |
|
| 233 | - } else $param .= "&search_actioncode=".urlencode($actioncode); |
|
| 274 | + foreach ($actioncode as $str_action) { |
|
| 275 | + $param .= "&search_actioncode[]=".urlencode($str_action); |
|
| 276 | + } |
|
| 277 | + } else { |
|
| 278 | + $param .= "&search_actioncode=".urlencode($actioncode); |
|
| 279 | + } |
|
| 280 | + } |
|
| 281 | +if ($resourceid > 0) { |
|
| 282 | + $param .= "&search_resourceid=".urlencode($resourceid); |
|
| 283 | +} |
|
| 284 | +if ($status || GETPOSTISSET('status')) { |
|
| 285 | + $param .= "&search_status=".urlencode($status); |
|
| 286 | +} |
|
| 287 | +if ($filter) { |
|
| 288 | + $param .= "&search_filter=".urlencode($filter); |
|
| 289 | +} |
|
| 290 | +if ($filtert) { |
|
| 291 | + $param .= "&search_filtert=".urlencode($filtert); |
|
| 292 | +} |
|
| 293 | +if ($usergroup > 0) { |
|
| 294 | + $param .= "&search_usergroup=".urlencode($usergroup); |
|
| 295 | +} |
|
| 296 | +if ($socid > 0) { |
|
| 297 | + $param .= "&search_socid=".urlencode($socid); |
|
| 298 | +} |
|
| 299 | +if ($showbirthday) { |
|
| 300 | + $param .= "&search_showbirthday=1"; |
|
| 301 | +} |
|
| 302 | +if ($pid) { |
|
| 303 | + $param .= "&search_projectid=".urlencode($pid); |
|
| 304 | +} |
|
| 305 | +if ($type) { |
|
| 306 | + $param .= "&search_type=".urlencode($type); |
|
| 307 | +} |
|
| 308 | +if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser') { |
|
| 309 | + $param .= '&action='.urlencode($action); |
|
| 310 | +} |
|
| 311 | +if ($begin_h != '') { |
|
| 312 | + $param .= '&begin_h='.urlencode($begin_h); |
|
| 313 | +} |
|
| 314 | +if ($end_h != '') { |
|
| 315 | + $param .= '&end_h='.urlencode($end_h); |
|
| 316 | +} |
|
| 317 | +if ($begin_d != '') { |
|
| 318 | + $param .= '&begin_d='.urlencode($begin_d); |
|
| 319 | +} |
|
| 320 | +if ($end_d != '') { |
|
| 321 | + $param .= '&end_d='.urlencode($end_d); |
|
| 234 | 322 | } |
| 235 | -if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); |
|
| 236 | -if ($status || GETPOSTISSET('status')) $param .= "&search_status=".urlencode($status); |
|
| 237 | -if ($filter) $param .= "&search_filter=".urlencode($filter); |
|
| 238 | -if ($filtert) $param .= "&search_filtert=".urlencode($filtert); |
|
| 239 | -if ($usergroup > 0) $param .= "&search_usergroup=".urlencode($usergroup); |
|
| 240 | -if ($socid > 0) $param .= "&search_socid=".urlencode($socid); |
|
| 241 | -if ($showbirthday) $param .= "&search_showbirthday=1"; |
|
| 242 | -if ($pid) $param .= "&search_projectid=".urlencode($pid); |
|
| 243 | -if ($type) $param .= "&search_type=".urlencode($type); |
|
| 244 | -if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser') $param .= '&action='.urlencode($action); |
|
| 245 | -if ($begin_h != '') $param .= '&begin_h='.urlencode($begin_h); |
|
| 246 | -if ($end_h != '') $param .= '&end_h='.urlencode($end_h); |
|
| 247 | -if ($begin_d != '') $param .= '&begin_d='.urlencode($begin_d); |
|
| 248 | -if ($end_d != '') $param .= '&end_d='.urlencode($end_d); |
|
| 249 | 323 | $param .= "&maxprint=".urlencode($maxprint); |
| 250 | 324 | |
| 251 | 325 | $paramnoactionodate = $param; |
@@ -406,10 +480,18 @@ discard block |
||
| 406 | 480 | $tmpforcreatebutton = dol_getdate(dol_now(), true); |
| 407 | 481 | |
| 408 | 482 | $newparam .= '&month='.urlencode(str_pad($month, 2, "0", STR_PAD_LEFT)).'&year='.urlencode($tmpforcreatebutton['year']); |
| 409 | - if ($begin_h !== '') $newparam .= '&begin_h='.urlencode($begin_h); |
|
| 410 | - if ($end_h !== '') $newparam .= '&end_h='.urlencode($end_h); |
|
| 411 | - if ($begin_d !== '') $newparam .= '&begin_d='.urlencode($begin_d); |
|
| 412 | - if ($end_d !== '') $newparam .= '&end_d='.urlencode($end_d); |
|
| 483 | + if ($begin_h !== '') { |
|
| 484 | + $newparam .= '&begin_h='.urlencode($begin_h); |
|
| 485 | + } |
|
| 486 | + if ($end_h !== '') { |
|
| 487 | + $newparam .= '&end_h='.urlencode($end_h); |
|
| 488 | + } |
|
| 489 | + if ($begin_d !== '') { |
|
| 490 | + $newparam .= '&begin_d='.urlencode($begin_d); |
|
| 491 | + } |
|
| 492 | + if ($end_d !== '') { |
|
| 493 | + $newparam .= '&end_d='.urlencode($end_d); |
|
| 494 | + } |
|
| 413 | 495 | |
| 414 | 496 | //$param='month='.$monthshown.'&year='.$year; |
| 415 | 497 | $hourminsec = '100000'; |
@@ -442,7 +524,9 @@ discard block |
||
| 442 | 524 | |
| 443 | 525 | // DEFAULT CALENDAR + AUTOEVENT CALENDAR + CONFERENCEBOOTH CALENDAR |
| 444 | 526 | $sql = 'SELECT'; |
| 445 | -if ($usergroup > 0) $sql .= " DISTINCT"; |
|
| 527 | +if ($usergroup > 0) { |
|
| 528 | + $sql .= " DISTINCT"; |
|
| 529 | +} |
|
| 446 | 530 | $sql .= ' a.id, a.label,'; |
| 447 | 531 | $sql .= ' a.datep,'; |
| 448 | 532 | $sql .= ' a.datep2,'; |
@@ -452,12 +536,20 @@ discard block |
||
| 452 | 536 | $sql .= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,'; |
| 453 | 537 | $sql .= ' ca.code, ca.libelle as type_label, ca.color, ca.type as type_type, ca.picto as type_picto'; |
| 454 | 538 | $sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; |
| 455 | -if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
| 539 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
| 540 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; |
|
| 541 | +} |
|
| 456 | 542 | // We must filter on resource table |
| 457 | -if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; |
|
| 543 | +if ($resourceid > 0) { |
|
| 544 | + $sql .= ", ".MAIN_DB_PREFIX."element_resources as r"; |
|
| 545 | +} |
|
| 458 | 546 | // We must filter on assignement table |
| 459 | -if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; |
|
| 460 | -if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
| 547 | +if ($filtert > 0 || $usergroup > 0) { |
|
| 548 | + $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; |
|
| 549 | +} |
|
| 550 | +if ($usergroup > 0) { |
|
| 551 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element"; |
|
| 552 | +} |
|
| 461 | 553 | $sql .= ' WHERE a.fk_action = ca.id'; |
| 462 | 554 | $sql .= ' AND a.entity IN ('.getEntity('agenda').')'; |
| 463 | 555 | // Condition on actioncode |
@@ -465,16 +557,24 @@ discard block |
||
| 465 | 557 | { |
| 466 | 558 | if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
| 467 | 559 | { |
| 468 | - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; |
|
| 469 | - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; |
|
| 470 | - else { |
|
| 471 | - if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'"; |
|
| 472 | - if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'"; |
|
| 560 | + if ($actioncode == 'AC_NON_AUTO') { |
|
| 561 | + $sql .= " AND ca.type != 'systemauto'"; |
|
| 562 | + } elseif ($actioncode == 'AC_ALL_AUTO') { |
|
| 563 | + $sql .= " AND ca.type = 'systemauto'"; |
|
| 564 | + } else { |
|
| 565 | + if ($actioncode == 'AC_OTH') { |
|
| 566 | + $sql .= " AND ca.type != 'systemauto'"; |
|
| 567 | + } |
|
| 568 | + if ($actioncode == 'AC_OTH_AUTO') { |
|
| 569 | + $sql .= " AND ca.type = 'systemauto'"; |
|
| 570 | + } |
|
| 473 | 571 | } |
| 474 | 572 | } else { |
| 475 | - if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'"; |
|
| 476 | - elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'"; |
|
| 477 | - else { |
|
| 573 | + if ($actioncode == 'AC_NON_AUTO') { |
|
| 574 | + $sql .= " AND ca.type != 'systemauto'"; |
|
| 575 | + } elseif ($actioncode == 'AC_ALL_AUTO') { |
|
| 576 | + $sql .= " AND ca.type = 'systemauto'"; |
|
| 577 | + } else { |
|
| 478 | 578 | if (is_array($actioncode)) |
| 479 | 579 | { |
| 480 | 580 | $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')"; |
@@ -484,12 +584,22 @@ discard block |
||
| 484 | 584 | } |
| 485 | 585 | } |
| 486 | 586 | } |
| 487 | -if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); |
|
| 488 | -if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid); |
|
| 489 | -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; |
|
| 490 | -if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid; |
|
| 587 | +if ($resourceid > 0) { |
|
| 588 | + $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid); |
|
| 589 | +} |
|
| 590 | +if ($pid) { |
|
| 591 | + $sql .= " AND a.fk_project=".$db->escape($pid); |
|
| 592 | +} |
|
| 593 | +if (!$user->rights->societe->client->voir && !$socid) { |
|
| 594 | + $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")"; |
|
| 595 | +} |
|
| 596 | +if ($socid > 0) { |
|
| 597 | + $sql .= ' AND a.fk_soc = '.$socid; |
|
| 598 | +} |
|
| 491 | 599 | // We must filter on assignement table |
| 492 | -if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
| 600 | +if ($filtert > 0 || $usergroup > 0) { |
|
| 601 | + $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'"; |
|
| 602 | +} |
|
| 493 | 603 | if ($action == 'show_day') |
| 494 | 604 | { |
| 495 | 605 | $sql .= " AND ("; |
@@ -515,7 +625,9 @@ discard block |
||
| 515 | 625 | $sql .= " AND a.datep2 > '".$db->idate($lastdaytoshow + (60 * 60 * 24 * 2))."')"; |
| 516 | 626 | $sql .= ')'; |
| 517 | 627 | } |
| 518 | -if ($type) $sql .= " AND ca.id = ".$type; |
|
| 628 | +if ($type) { |
|
| 629 | + $sql .= " AND ca.id = ".$type; |
|
| 630 | +} |
|
| 519 | 631 | if ($status == '0') { $sql .= " AND a.percent = 0"; } |
| 520 | 632 | if ($status == '-1') { $sql .= " AND a.percent = -1"; } // Not applicable |
| 521 | 633 | if ($status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; } // Running already started |
@@ -525,8 +637,12 @@ discard block |
||
| 525 | 637 | if ($filtert > 0 || $usergroup > 0) |
| 526 | 638 | { |
| 527 | 639 | $sql .= " AND ("; |
| 528 | - if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert; |
|
| 529 | - if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; |
|
| 640 | + if ($filtert > 0) { |
|
| 641 | + $sql .= "ar.fk_element = ".$filtert; |
|
| 642 | + } |
|
| 643 | + if ($usergroup > 0) { |
|
| 644 | + $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup; |
|
| 645 | + } |
|
| 530 | 646 | $sql .= ")"; |
| 531 | 647 | } |
| 532 | 648 | // Sort on date |
@@ -583,12 +699,18 @@ discard block |
||
| 583 | 699 | if ($event->percentage <= 0) |
| 584 | 700 | { |
| 585 | 701 | $event->date_start_in_calendar = $datep; |
| 586 | - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; |
|
| 587 | - else $event->date_end_in_calendar = $datep; |
|
| 702 | + if ($datep2 != '' && $datep2 >= $datep) { |
|
| 703 | + $event->date_end_in_calendar = $datep2; |
|
| 704 | + } else { |
|
| 705 | + $event->date_end_in_calendar = $datep; |
|
| 706 | + } |
|
| 588 | 707 | } else { |
| 589 | 708 | $event->date_start_in_calendar = $datep; |
| 590 | - if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar = $datep2; |
|
| 591 | - else $event->date_end_in_calendar = $datep; |
|
| 709 | + if ($datep2 != '' && $datep2 >= $datep) { |
|
| 710 | + $event->date_end_in_calendar = $datep2; |
|
| 711 | + } else { |
|
| 712 | + $event->date_end_in_calendar = $datep; |
|
| 713 | + } |
|
| 592 | 714 | } |
| 593 | 715 | // Define ponctual property |
| 594 | 716 | if ($event->date_start_in_calendar == $event->date_end_in_calendar) |
@@ -606,8 +728,12 @@ discard block |
||
| 606 | 728 | //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'<br>'."\n"; |
| 607 | 729 | $event->fetch_userassigned(); // This load $event->userassigned |
| 608 | 730 | |
| 609 | - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar = $firstdaytoshow; |
|
| 610 | - if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar = ($lastdaytoshow - 1); |
|
| 731 | + if ($event->date_start_in_calendar < $firstdaytoshow) { |
|
| 732 | + $event->date_start_in_calendar = $firstdaytoshow; |
|
| 733 | + } |
|
| 734 | + if ($event->date_end_in_calendar >= $lastdaytoshow) { |
|
| 735 | + $event->date_end_in_calendar = ($lastdaytoshow - 1); |
|
| 736 | + } |
|
| 611 | 737 | |
| 612 | 738 | // Add an entry in actionarray for each day |
| 613 | 739 | $daycursor = $event->date_start_in_calendar; |
@@ -626,7 +752,9 @@ discard block |
||
| 626 | 752 | $j++; |
| 627 | 753 | |
| 628 | 754 | $daykey += 60 * 60 * 24; |
| 629 | - if ($daykey > $event->date_end_in_calendar) $loop = false; |
|
| 755 | + if ($daykey > $event->date_end_in_calendar) { |
|
| 756 | + $loop = false; |
|
| 757 | + } |
|
| 630 | 758 | } while ($loop); |
| 631 | 759 | |
| 632 | 760 | //print 'Event '.$i.' id='.$event->id.' (start='.dol_print_date($event->datep).'-end='.dol_print_date($event->datef); |
@@ -650,7 +778,9 @@ discard block |
||
| 650 | 778 | { |
| 651 | 779 | include_once $color_file; |
| 652 | 780 | } |
| 653 | -if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); |
|
| 781 | +if (!is_array($theme_datacolor)) { |
|
| 782 | + $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220)); |
|
| 783 | +} |
|
| 654 | 784 | |
| 655 | 785 | |
| 656 | 786 | $newparam = $param; // newparam is for birthday links |
@@ -689,10 +819,15 @@ discard block |
||
| 689 | 819 | print '<span class="hideonsmartphone" title="'.$langs->trans("VisibleTimeRange").'">'.$langs->trans("Hours").'</span>'; |
| 690 | 820 | print "\n".'<div class="ui-grid-a inline-block"><div class="ui-block-a nowraponall">'; |
| 691 | 821 | print '<input type="number" class="short" name="begin_h" value="'.$begin_h.'" min="0" max="23">'; |
| 692 | - if (empty($conf->dol_use_jmobile)) print ' - '; |
|
| 693 | - else print '</div><div class="ui-block-b">'; |
|
| 822 | + if (empty($conf->dol_use_jmobile)) { |
|
| 823 | + print ' - '; |
|
| 824 | + } else { |
|
| 825 | + print '</div><div class="ui-block-b">'; |
|
| 826 | + } |
|
| 694 | 827 | print '<input type="number" class="short" name="end_h" value="'.$end_h.'" min="1" max="24">'; |
| 695 | - if (empty($conf->dol_use_jmobile)) print ' '.$langs->trans("H"); |
|
| 828 | + if (empty($conf->dol_use_jmobile)) { |
|
| 829 | + print ' '.$langs->trans("H"); |
|
| 830 | + } |
|
| 696 | 831 | print '</div></div>'; |
| 697 | 832 | |
| 698 | 833 | print '<br>'; |
@@ -702,8 +837,11 @@ discard block |
||
| 702 | 837 | print '<span class="hideonsmartphone" title="'.$langs->trans("VisibleDaysRange").'">'.$langs->trans("DaysOfWeek").'</span>'; |
| 703 | 838 | print "\n".'<div class="ui-grid-a inline-block"><div class="ui-block-a">'; |
| 704 | 839 | print '<input type="number" class="short" name="begin_d" value="'.$begin_d.'" min="1" max="7">'; |
| 705 | - if (empty($conf->dol_use_jmobile)) print ' - '; |
|
| 706 | - else print '</div><div class="ui-block-b">'; |
|
| 840 | + if (empty($conf->dol_use_jmobile)) { |
|
| 841 | + print ' - '; |
|
| 842 | + } else { |
|
| 843 | + print '</div><div class="ui-block-b">'; |
|
| 844 | + } |
|
| 707 | 845 | print '<input type="number" class="short" name="end_d" value="'.$end_d.'" min="1" max="7">'; |
| 708 | 846 | print '</div></div>'; |
| 709 | 847 | } |
@@ -720,8 +858,11 @@ discard block |
||
| 720 | 858 | echo '<td align="center" colspan="'.($end_h - $begin_h).'">'; |
| 721 | 859 | echo '<span class="bold spandayofweek">'.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7)).'</span>'; |
| 722 | 860 | print "<br>"; |
| 723 | - if ($i) print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'), 'day'); |
|
| 724 | - else print dol_print_date($currentdaytoshow, 'day'); |
|
| 861 | + if ($i) { |
|
| 862 | + print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'), 'day'); |
|
| 863 | + } else { |
|
| 864 | + print dol_print_date($currentdaytoshow, 'day'); |
|
| 865 | + } |
|
| 725 | 866 | echo "</td>\n"; |
| 726 | 867 | $i++; |
| 727 | 868 | } |
@@ -763,7 +904,9 @@ discard block |
||
| 763 | 904 | $event->fetch_userassigned(); |
| 764 | 905 | $listofuserid = $event->userassigned; |
| 765 | 906 | foreach ($listofuserid as $userid => $tmp) { |
| 766 | - if (!in_array($userid, $usernamesid)) $usernamesid[$userid] = $userid; |
|
| 907 | + if (!in_array($userid, $usernamesid)) { |
|
| 908 | + $usernamesid[$userid] = $userid; |
|
| 909 | + } |
|
| 767 | 910 | } |
| 768 | 911 | } |
| 769 | 912 | } |
@@ -771,9 +914,13 @@ discard block |
||
| 771 | 914 | /* Use this list to have for all users */ |
| 772 | 915 | $sql = "SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity"; |
| 773 | 916 | $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; |
| 774 | - if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user"; |
|
| 917 | + if ($usergroup > 0) { |
|
| 918 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user"; |
|
| 919 | + } |
|
| 775 | 920 | $sql .= " WHERE u.statut = 1 AND u.entity IN (".getEntity('user').")"; |
| 776 | - if ($usergroup > 0) $sql .= " AND ug.fk_usergroup = ".$usergroup; |
|
| 921 | + if ($usergroup > 0) { |
|
| 922 | + $sql .= " AND ug.fk_usergroup = ".$usergroup; |
|
| 923 | + } |
|
| 777 | 924 | //print $sql; |
| 778 | 925 | $resql = $db->query($sql); |
| 779 | 926 | if ($resql) { |
@@ -788,7 +935,9 @@ discard block |
||
| 788 | 935 | $i++; |
| 789 | 936 | } |
| 790 | 937 | } |
| 791 | - } else dol_print_error($db); |
|
| 938 | + } else { |
|
| 939 | + dol_print_error($db); |
|
| 940 | + } |
|
| 792 | 941 | } |
| 793 | 942 | //var_dump($usernamesid); |
| 794 | 943 | foreach ($usernamesid as $id) |
@@ -862,10 +1011,16 @@ discard block |
||
| 862 | 1011 | //var_dump($curtime.' '.$tmpday.' '.$tmpmonth.' '.$tmpyear); |
| 863 | 1012 | |
| 864 | 1013 | $style = 'cal_current_month'; |
| 865 | - if ($iter_day == 6) $style .= ' cal_other_month'; |
|
| 1014 | + if ($iter_day == 6) { |
|
| 1015 | + $style .= ' cal_other_month'; |
|
| 1016 | + } |
|
| 866 | 1017 | $today = 0; |
| 867 | - if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) $today = 1; |
|
| 868 | - if ($today) $style = 'cal_today_peruser'; |
|
| 1018 | + if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) { |
|
| 1019 | + $today = 1; |
|
| 1020 | + } |
|
| 1021 | + if ($today) { |
|
| 1022 | + $style = 'cal_today_peruser'; |
|
| 1023 | + } |
|
| 869 | 1024 | |
| 870 | 1025 | show_day_events2($username, $tmpday, $tmpmonth, $tmpyear, 0, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, $showheader, $colorsbytype, $var); |
| 871 | 1026 | |
@@ -999,7 +1154,8 @@ discard block |
||
| 999 | 1154 | $mois = dol_print_date($daykey, '%m'); |
| 1000 | 1155 | $jour = dol_print_date($daykey, '%d'); |
| 1001 | 1156 | |
| 1002 | - if ($day == $jour && $month == $mois && $year == $annee) // Is it the day we are looking for when calling function ? |
|
| 1157 | + if ($day == $jour && $month == $mois && $year == $annee) { |
|
| 1158 | + // Is it the day we are looking for when calling function ? |
|
| 1003 | 1159 | { |
| 1004 | 1160 | // Scan all event for this date |
| 1005 | 1161 | foreach ($eventarray[$daykey] as $index => $event) |
@@ -1008,14 +1164,20 @@ discard block |
||
| 1008 | 1164 | //var_dump($event); |
| 1009 | 1165 | |
| 1010 | 1166 | $keysofuserassigned = array_keys($event->userassigned); |
| 1167 | + } |
|
| 1011 | 1168 | $ponct = ($event->date_start_in_calendar == $event->date_end_in_calendar); |
| 1012 | 1169 | |
| 1013 | - if (!in_array($username->id, $keysofuserassigned)) continue; // We discard record if event is from another user than user we want to show |
|
| 1170 | + if (!in_array($username->id, $keysofuserassigned)) { |
|
| 1171 | + continue; |
|
| 1172 | + } |
|
| 1173 | + // We discard record if event is from another user than user we want to show |
|
| 1014 | 1174 | //if ($username->id != $event->userownerid) continue; // We discard record if event is from another user than user we want to show |
| 1015 | 1175 | |
| 1016 | 1176 | $parameters = array(); |
| 1017 | 1177 | $reshook = $hookmanager->executeHooks('formatEvent', $parameters, $event, $action); // Note that $action and $object may have been modified by some hooks |
| 1018 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 1178 | + if ($reshook < 0) { |
|
| 1179 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 1180 | + } |
|
| 1019 | 1181 | |
| 1020 | 1182 | // Define $color (Hex string like '0088FF') and $cssclass of event |
| 1021 | 1183 | $color = -1; $cssclass = ''; $colorindex = -1; |
@@ -1032,9 +1194,13 @@ discard block |
||
| 1032 | 1194 | //var_dump($cacheusers[$event->userownerid]->color); |
| 1033 | 1195 | |
| 1034 | 1196 | // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) |
| 1035 | - if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; |
|
| 1197 | + if (!empty($cacheusers[$event->userownerid]->color)) { |
|
| 1198 | + $color = $cacheusers[$event->userownerid]->color; |
|
| 1199 | + } |
|
| 1036 | 1200 | |
| 1037 | - if (!empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color = $event->type_color; |
|
| 1201 | + if (!empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) { |
|
| 1202 | + $color = $event->type_color; |
|
| 1203 | + } |
|
| 1038 | 1204 | } elseif ($event->type_code == 'ICALEVENT') |
| 1039 | 1205 | { |
| 1040 | 1206 | $numical++; |
@@ -1065,22 +1231,31 @@ discard block |
||
| 1065 | 1231 | //var_dump($cacheusers[$event->userownerid]->color); |
| 1066 | 1232 | |
| 1067 | 1233 | // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) |
| 1068 | - if (!empty($cacheusers[$event->userownerid]->color)) $color = $cacheusers[$event->userownerid]->color; |
|
| 1234 | + if (!empty($cacheusers[$event->userownerid]->color)) { |
|
| 1235 | + $color = $cacheusers[$event->userownerid]->color; |
|
| 1236 | + } |
|
| 1069 | 1237 | |
| 1070 | - if (!empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) $color = $event->type_color; |
|
| 1238 | + if (!empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE)) { |
|
| 1239 | + $color = $event->type_color; |
|
| 1240 | + } |
|
| 1071 | 1241 | } |
| 1072 | 1242 | |
| 1073 | - if ($color < 0) // Color was not set on user card. Set color according to color index. |
|
| 1243 | + if ($color < 0) { |
|
| 1244 | + // Color was not set on user card. Set color according to color index. |
|
| 1074 | 1245 | { |
| 1075 | 1246 | // Define color index if not yet defined |
| 1076 | 1247 | $idusertouse = ($event->userownerid ? $event->userownerid : 0); |
| 1248 | + } |
|
| 1077 | 1249 | if (isset($colorindexused[$idusertouse])) |
| 1078 | 1250 | { |
| 1079 | 1251 | $colorindex = $colorindexused[$idusertouse]; // Color already assigned to this user |
| 1080 | 1252 | } else { |
| 1081 | 1253 | $colorindex = $nextindextouse; |
| 1082 | 1254 | $colorindexused[$idusertouse] = $colorindex; |
| 1083 | - if (!empty($theme_datacolor[$nextindextouse + 1])) $nextindextouse++; // Prepare to use next color |
|
| 1255 | + if (!empty($theme_datacolor[$nextindextouse + 1])) { |
|
| 1256 | + $nextindextouse++; |
|
| 1257 | + } |
|
| 1258 | + // Prepare to use next color |
|
| 1084 | 1259 | } |
| 1085 | 1260 | // Define color |
| 1086 | 1261 | $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); |
@@ -1098,7 +1273,9 @@ discard block |
||
| 1098 | 1273 | $c = dol_mktime((int) $h + 1, 0, 0, $month, $day, $year, 'tzuserrel', 0); |
| 1099 | 1274 | |
| 1100 | 1275 | $dateendtouse = $event->date_end_in_calendar; |
| 1101 | - if ($dateendtouse == $event->date_start_in_calendar) $dateendtouse++; |
|
| 1276 | + if ($dateendtouse == $event->date_start_in_calendar) { |
|
| 1277 | + $dateendtouse++; |
|
| 1278 | + } |
|
| 1102 | 1279 | |
| 1103 | 1280 | //print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'<br>'; |
| 1104 | 1281 | |
@@ -1111,10 +1288,15 @@ discard block |
||
| 1111 | 1288 | { |
| 1112 | 1289 | $tmpa = dol_getdate($event->date_start_in_calendar, true); |
| 1113 | 1290 | $tmpb = dol_getdate($event->date_end_in_calendar, true); |
| 1114 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel'); |
|
| 1115 | - else $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel'); |
|
| 1291 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { |
|
| 1292 | + $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel'); |
|
| 1293 | + } else { |
|
| 1294 | + $cases1[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel'); |
|
| 1295 | + } |
|
| 1296 | + } |
|
| 1297 | + if ($event->label) { |
|
| 1298 | + $cases1[$h][$event->id]['string'] .= ' - '.$event->label; |
|
| 1116 | 1299 | } |
| 1117 | - if ($event->label) $cases1[$h][$event->id]['string'] .= ' - '.$event->label; |
|
| 1118 | 1300 | $cases1[$h][$event->id]['typecode'] = $event->type_code; |
| 1119 | 1301 | $cases1[$h][$event->id]['color'] = $color; |
| 1120 | 1302 | if ($event->fk_project > 0) |
@@ -1157,10 +1339,15 @@ discard block |
||
| 1157 | 1339 | { |
| 1158 | 1340 | $tmpa = dol_getdate($event->date_start_in_calendar, true); |
| 1159 | 1341 | $tmpb = dol_getdate($event->date_end_in_calendar, true); |
| 1160 | - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel'); |
|
| 1161 | - else $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel'); |
|
| 1342 | + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) { |
|
| 1343 | + $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'hour', 'tzuserrel'); |
|
| 1344 | + } else { |
|
| 1345 | + $cases2[$h][$event->id]['string'] .= '-'.dol_print_date($event->date_end_in_calendar, 'dayhour', 'tzuserrel'); |
|
| 1346 | + } |
|
| 1347 | + } |
|
| 1348 | + if ($event->label) { |
|
| 1349 | + $cases2[$h][$event->id]['string'] .= ' - '.$event->label; |
|
| 1162 | 1350 | } |
| 1163 | - if ($event->label) $cases2[$h][$event->id]['string'] .= ' - '.$event->label; |
|
| 1164 | 1351 | $cases2[$h][$event->id]['typecode'] = $event->type_code; |
| 1165 | 1352 | $cases2[$h][$event->id]['color'] = $color; |
| 1166 | 1353 | if ($event->fk_project > 0) |
@@ -1223,53 +1410,86 @@ discard block |
||
| 1223 | 1410 | if (isset($cases1[$h]) && $cases1[$h] != '') |
| 1224 | 1411 | { |
| 1225 | 1412 | //$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
| 1226 | - if (count($cases1[$h]) > 1) $title1 .= count($cases1[$h]).' '.(count($cases1[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events")); |
|
| 1413 | + if (count($cases1[$h]) > 1) { |
|
| 1414 | + $title1 .= count($cases1[$h]).' '.(count($cases1[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events")); |
|
| 1415 | + } |
|
| 1227 | 1416 | $string1 = ' '; |
| 1228 | - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style1 = 'peruser_notbusy'; |
|
| 1229 | - else $style1 = 'peruser_busy'; |
|
| 1417 | + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) { |
|
| 1418 | + $style1 = 'peruser_notbusy'; |
|
| 1419 | + } else { |
|
| 1420 | + $style1 = 'peruser_busy'; |
|
| 1421 | + } |
|
| 1230 | 1422 | foreach ($cases1[$h] as $id => $ev) |
| 1231 | 1423 | { |
| 1232 | - if ($ev['busy']) $style1 = 'peruser_busy'; |
|
| 1424 | + if ($ev['busy']) { |
|
| 1425 | + $style1 = 'peruser_busy'; |
|
| 1426 | + } |
|
| 1233 | 1427 | } |
| 1234 | 1428 | } |
| 1235 | 1429 | if (isset($cases2[$h]) && $cases2[$h] != '') |
| 1236 | 1430 | { |
| 1237 | 1431 | //$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events")); |
| 1238 | - if (count($cases2[$h]) > 1) $title2 .= count($cases2[$h]).' '.(count($cases2[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events")); |
|
| 1432 | + if (count($cases2[$h]) > 1) { |
|
| 1433 | + $title2 .= count($cases2[$h]).' '.(count($cases2[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events")); |
|
| 1434 | + } |
|
| 1239 | 1435 | $string2 = ' '; |
| 1240 | - if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) $style2 = 'peruser_notbusy'; |
|
| 1241 | - else $style2 = 'peruser_busy'; |
|
| 1436 | + if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) { |
|
| 1437 | + $style2 = 'peruser_notbusy'; |
|
| 1438 | + } else { |
|
| 1439 | + $style2 = 'peruser_busy'; |
|
| 1440 | + } |
|
| 1242 | 1441 | foreach ($cases2[$h] as $id => $ev) |
| 1243 | 1442 | { |
| 1244 | - if ($ev['busy']) $style2 = 'peruser_busy'; |
|
| 1443 | + if ($ev['busy']) { |
|
| 1444 | + $style2 = 'peruser_busy'; |
|
| 1445 | + } |
|
| 1245 | 1446 | } |
| 1246 | 1447 | } |
| 1247 | 1448 | |
| 1248 | 1449 | $ids1 = ''; |
| 1249 | 1450 | $ids2 = ''; |
| 1250 | - if (is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) $ids1 = join(',', array_keys($cases1[$h])); |
|
| 1251 | - if (is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) $ids2 = join(',', array_keys($cases2[$h])); |
|
| 1451 | + if (is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) { |
|
| 1452 | + $ids1 = join(',', array_keys($cases1[$h])); |
|
| 1453 | + } |
|
| 1454 | + if (is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) { |
|
| 1455 | + $ids2 = join(',', array_keys($cases2[$h])); |
|
| 1456 | + } |
|
| 1252 | 1457 | |
| 1253 | - if ($h == $begin_h) echo '<td class="'.$style.'_peruserleft cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">'; |
|
| 1254 | - else echo '<td class="'.$style.' cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">'; |
|
| 1255 | - if (is_array($cases1[$h]) && count($cases1[$h]) == 1) // only 1 event |
|
| 1458 | + if ($h == $begin_h) { |
|
| 1459 | + echo '<td class="'.$style.'_peruserleft cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">'; |
|
| 1460 | + } else { |
|
| 1461 | + echo '<td class="'.$style.' cal_peruser'.($var ? ' cal_impair '.$style.'_impair' : '').'">'; |
|
| 1462 | + } |
|
| 1463 | + if (is_array($cases1[$h]) && count($cases1[$h]) == 1) { |
|
| 1464 | + // only 1 event |
|
| 1256 | 1465 | { |
| 1257 | 1466 | $output = array_slice($cases1[$h], 0, 1); |
| 1467 | + } |
|
| 1258 | 1468 | $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); |
| 1259 | - if ($output[0]['string']) $title1 .= ($title1 ? ' - ' : '').$output[0]['string']; |
|
| 1260 | - if ($output[0]['color']) $color1 = $output[0]['color']; |
|
| 1469 | + if ($output[0]['string']) { |
|
| 1470 | + $title1 .= ($title1 ? ' - ' : '').$output[0]['string']; |
|
| 1471 | + } |
|
| 1472 | + if ($output[0]['color']) { |
|
| 1473 | + $color1 = $output[0]['color']; |
|
| 1474 | + } |
|
| 1261 | 1475 | } elseif (is_array($cases1[$h]) && count($cases1[$h]) > 1) |
| 1262 | 1476 | { |
| 1263 | 1477 | $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); |
| 1264 | 1478 | $color1 = '222222'; |
| 1265 | 1479 | } |
| 1266 | 1480 | |
| 1267 | - if (is_array($cases2[$h]) && count($cases2[$h]) == 1) // only 1 event |
|
| 1481 | + if (is_array($cases2[$h]) && count($cases2[$h]) == 1) { |
|
| 1482 | + // only 1 event |
|
| 1268 | 1483 | { |
| 1269 | 1484 | $output = array_slice($cases2[$h], 0, 1); |
| 1485 | + } |
|
| 1270 | 1486 | $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); |
| 1271 | - if ($output[0]['string']) $title2 .= ($title2 ? ' - ' : '').$output[0]['string']; |
|
| 1272 | - if ($output[0]['color']) $color2 = $output[0]['color']; |
|
| 1487 | + if ($output[0]['string']) { |
|
| 1488 | + $title2 .= ($title2 ? ' - ' : '').$output[0]['string']; |
|
| 1489 | + } |
|
| 1490 | + if ($output[0]['color']) { |
|
| 1491 | + $color2 = $output[0]['color']; |
|
| 1492 | + } |
|
| 1273 | 1493 | } elseif (is_array($cases2[$h]) && count($cases2[$h]) > 1) |
| 1274 | 1494 | { |
| 1275 | 1495 | $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); |
@@ -1277,8 +1497,9 @@ discard block |
||
| 1277 | 1497 | } |
| 1278 | 1498 | print '<table class="nobordernopadding" width="100%">'; |
| 1279 | 1499 | print '<tr><td '; |
| 1280 | - if ($style1 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color1 ? $color1 : "888").' !important" '; |
|
| 1281 | - elseif ($color1) |
|
| 1500 | + if ($style1 == 'peruser_notbusy') { |
|
| 1501 | + print 'style="border: 1px solid #'.($color1 ? $color1 : "888").' !important" '; |
|
| 1502 | + } elseif ($color1) |
|
| 1282 | 1503 | { |
| 1283 | 1504 | print ($color1 ? 'style="background: #'.$color1.';"' : ''); |
| 1284 | 1505 | } |
@@ -1287,8 +1508,9 @@ discard block |
||
| 1287 | 1508 | print 'onclickopenref'.($title2 ? ' classfortooltip' : '').($title1 ? ' cursorpointer' : '').'" ref="ref_'.$username->id.'_'.sprintf("%04d", $year).'_'.sprintf("%02d", $month).'_'.sprintf("%02d", $day).'_'.sprintf("%02d", $h).'_00_'.($ids1 ? $ids1 : 'none').'"'.($title1 ? ' title="'.$title1.'"' : '').'>'; |
| 1288 | 1509 | print $string1; |
| 1289 | 1510 | print '</td><td '; |
| 1290 | - if ($style2 == 'peruser_notbusy') print 'style="border: 1px solid #'.($color2 ? $color2 : "888").' !important" '; |
|
| 1291 | - elseif ($color2) |
|
| 1511 | + if ($style2 == 'peruser_notbusy') { |
|
| 1512 | + print 'style="border: 1px solid #'.($color2 ? $color2 : "888").' !important" '; |
|
| 1513 | + } elseif ($color2) |
|
| 1292 | 1514 | { |
| 1293 | 1515 | print ($color2 ? 'style="background: #'.$color2.';"' : ''); |
| 1294 | 1516 | } |
@@ -128,9 +128,13 @@ discard block |
||
| 128 | 128 | if (!empty($conf->use_javascript_ajax) || $onlyselect) |
| 129 | 129 | { |
| 130 | 130 | //var_dump($selected); |
| 131 | - if ($selected == 'done') $selected = '100'; |
|
| 131 | + if ($selected == 'done') { |
|
| 132 | + $selected = '100'; |
|
| 133 | + } |
|
| 132 | 134 | print '<select '.($canedit ? '' : 'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'">'; |
| 133 | - if ($showempty) print '<option value=""'.($selected == '' ? ' selected' : '').'> </option>'; |
|
| 135 | + if ($showempty) { |
|
| 136 | + print '<option value=""'.($selected == '' ? ' selected' : '').'> </option>'; |
|
| 137 | + } |
|
| 134 | 138 | foreach ($listofstatus as $key => $val) |
| 135 | 139 | { |
| 136 | 140 | print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>'; |
@@ -140,7 +144,9 @@ discard block |
||
| 140 | 144 | } |
| 141 | 145 | } |
| 142 | 146 | print '</select>'; |
| 143 | - if ($selected == 0 || $selected == 100) $canedit = 0; |
|
| 147 | + if ($selected == 0 || $selected == 100) { |
|
| 148 | + $canedit = 0; |
|
| 149 | + } |
|
| 144 | 150 | |
| 145 | 151 | print ajax_combobox('select'.$htmlname); |
| 146 | 152 | |
@@ -178,28 +184,45 @@ discard block |
||
| 178 | 184 | $sortorder = 'DESC,DESC'; |
| 179 | 185 | |
| 180 | 186 | $listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0)); |
| 181 | - if (!is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions'); |
|
| 187 | + if (!is_array($listofactions)) { |
|
| 188 | + dol_print_error($this->db, 'FailedToGetActions'); |
|
| 189 | + } |
|
| 182 | 190 | |
| 183 | 191 | $num = count($listofactions); |
| 184 | 192 | if ($num || $forceshowtitle) |
| 185 | 193 | { |
| 186 | - if ($typeelement == 'invoice') $title = $langs->trans('ActionsOnBill'); |
|
| 187 | - elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title = $langs->trans('ActionsOnBill'); |
|
| 188 | - elseif ($typeelement == 'propal') $title = $langs->trans('ActionsOnPropal'); |
|
| 189 | - elseif ($typeelement == 'supplier_proposal') $title = $langs->trans('ActionsOnSupplierProposal'); |
|
| 190 | - elseif ($typeelement == 'order') $title = $langs->trans('ActionsOnOrder'); |
|
| 191 | - elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title = $langs->trans('ActionsOnOrder'); |
|
| 192 | - elseif ($typeelement == 'shipping') $title = $langs->trans('ActionsOnShipping'); |
|
| 193 | - elseif ($typeelement == 'fichinter') $title = $langs->trans('ActionsOnFicheInter'); |
|
| 194 | - elseif ($typeelement == 'project') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); |
|
| 195 | - elseif ($typeelement == 'task') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); |
|
| 196 | - elseif ($typeelement == 'member') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); |
|
| 197 | - else $title = $langs->trans("LatestLinkedEvents", $max ? $max : ''); |
|
| 194 | + if ($typeelement == 'invoice') { |
|
| 195 | + $title = $langs->trans('ActionsOnBill'); |
|
| 196 | + } elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') { |
|
| 197 | + $title = $langs->trans('ActionsOnBill'); |
|
| 198 | + } elseif ($typeelement == 'propal') { |
|
| 199 | + $title = $langs->trans('ActionsOnPropal'); |
|
| 200 | + } elseif ($typeelement == 'supplier_proposal') { |
|
| 201 | + $title = $langs->trans('ActionsOnSupplierProposal'); |
|
| 202 | + } elseif ($typeelement == 'order') { |
|
| 203 | + $title = $langs->trans('ActionsOnOrder'); |
|
| 204 | + } elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') { |
|
| 205 | + $title = $langs->trans('ActionsOnOrder'); |
|
| 206 | + } elseif ($typeelement == 'shipping') { |
|
| 207 | + $title = $langs->trans('ActionsOnShipping'); |
|
| 208 | + } elseif ($typeelement == 'fichinter') { |
|
| 209 | + $title = $langs->trans('ActionsOnFicheInter'); |
|
| 210 | + } elseif ($typeelement == 'project') { |
|
| 211 | + $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); |
|
| 212 | + } elseif ($typeelement == 'task') { |
|
| 213 | + $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); |
|
| 214 | + } elseif ($typeelement == 'member') { |
|
| 215 | + $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); |
|
| 216 | + } else { |
|
| 217 | + $title = $langs->trans("LatestLinkedEvents", $max ? $max : ''); |
|
| 218 | + } |
|
| 198 | 219 | |
| 199 | 220 | $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage ? '&'.$moreparambacktopage : ''); |
| 200 | 221 | |
| 201 | 222 | $projectid = $object->fk_project; |
| 202 | - if ($typeelement == 'project') $projectid = $object->id; |
|
| 223 | + if ($typeelement == 'project') { |
|
| 224 | + $projectid = $object->id; |
|
| 225 | + } |
|
| 203 | 226 | |
| 204 | 227 | $newcardbutton = ''; |
| 205 | 228 | if (!empty($conf->agenda->enabled) && !empty($user->rights->agenda->myactions->create)) |
@@ -232,7 +255,9 @@ discard block |
||
| 232 | 255 | $cursorevent = 0; |
| 233 | 256 | foreach ($listofactions as $actioncomm) |
| 234 | 257 | { |
| 235 | - if ($max && $cursorevent >= $max) break; |
|
| 258 | + if ($max && $cursorevent >= $max) { |
|
| 259 | + break; |
|
| 260 | + } |
|
| 236 | 261 | |
| 237 | 262 | $ref = $actioncomm->getNomUrl(1, -1); |
| 238 | 263 | $label = $actioncomm->getNomUrl(0, 36); |
@@ -282,8 +307,12 @@ discard block |
||
| 282 | 307 | $tmpb = dol_getdate($actioncomm->datef); |
| 283 | 308 | if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) |
| 284 | 309 | { |
| 285 | - if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($actioncomm->datef, 'hour', 'tzuserrel'); |
|
| 286 | - } else print '-'.dol_print_date($actioncomm->datef, 'dayhour', 'tzuserrel'); |
|
| 310 | + if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) { |
|
| 311 | + print '-'.dol_print_date($actioncomm->datef, 'hour', 'tzuserrel'); |
|
| 312 | + } |
|
| 313 | + } else { |
|
| 314 | + print '-'.dol_print_date($actioncomm->datef, 'dayhour', 'tzuserrel'); |
|
| 315 | + } |
|
| 287 | 316 | } |
| 288 | 317 | print '</td>'; |
| 289 | 318 | print '<td class="right">'; |
@@ -329,7 +358,9 @@ discard block |
||
| 329 | 358 | // phpcs:enable |
| 330 | 359 | global $langs, $user, $form, $conf; |
| 331 | 360 | |
| 332 | - if (!is_object($form)) $form = new Form($this->db); |
|
| 361 | + if (!is_object($form)) { |
|
| 362 | + $form = new Form($this->db); |
|
| 363 | + } |
|
| 333 | 364 | |
| 334 | 365 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; |
| 335 | 366 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
@@ -343,16 +374,24 @@ discard block |
||
| 343 | 374 | } |
| 344 | 375 | //asort($arraylist); |
| 345 | 376 | |
| 346 | - if ($selected == 'manual') $selected = 'AC_OTH'; |
|
| 347 | - if ($selected == 'auto') $selected = 'AC_OTH_AUTO'; |
|
| 377 | + if ($selected == 'manual') { |
|
| 378 | + $selected = 'AC_OTH'; |
|
| 379 | + } |
|
| 380 | + if ($selected == 'auto') { |
|
| 381 | + $selected = 'AC_OTH_AUTO'; |
|
| 382 | + } |
|
| 348 | 383 | |
| 349 | - if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); |
|
| 384 | + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) { |
|
| 385 | + unset($arraylist['AC_OTH_AUTO']); |
|
| 386 | + } |
|
| 350 | 387 | |
| 351 | 388 | $out = ''; |
| 352 | 389 | |
| 353 | 390 | if (!empty($multiselect)) |
| 354 | 391 | { |
| 355 | - if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); |
|
| 392 | + if (!is_array($selected) && !empty($selected)) { |
|
| 393 | + $selected = explode(',', $selected); |
|
| 394 | + } |
|
| 356 | 395 | $out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); |
| 357 | 396 | } else { |
| 358 | 397 | $out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth300'.($morecss ? ' '.$morecss : ''), 1); |
@@ -363,8 +402,11 @@ discard block |
||
| 363 | 402 | $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1); |
| 364 | 403 | } |
| 365 | 404 | |
| 366 | - if ($nooutput) return $out; |
|
| 367 | - else print $out; |
|
| 405 | + if ($nooutput) { |
|
| 406 | + return $out; |
|
| 407 | + } else { |
|
| 408 | + print $out; |
|
| 409 | + } |
|
| 368 | 410 | return ''; |
| 369 | 411 | } |
| 370 | 412 | } |
@@ -67,7 +67,9 @@ discard block |
||
| 67 | 67 | // phpcs:enable |
| 68 | 68 | global $conf, $langs; |
| 69 | 69 | |
| 70 | - if (!empty($conf->global->MAIN_DEFAULT_LANGUAGE_FILTER)) $filter[$conf->global->MAIN_DEFAULT_LANGUAGE_FILTER] = 1; |
|
| 70 | + if (!empty($conf->global->MAIN_DEFAULT_LANGUAGE_FILTER)) { |
|
| 71 | + $filter[$conf->global->MAIN_DEFAULT_LANGUAGE_FILTER] = 1; |
|
| 72 | + } |
|
| 71 | 73 | |
| 72 | 74 | $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12, 0, $mainlangonly); |
| 73 | 75 | |
@@ -77,16 +79,23 @@ discard block |
||
| 77 | 79 | if ($showempty && !$multiselect) |
| 78 | 80 | { |
| 79 | 81 | $out .= '<option value="0"'; |
| 80 | - if ($selected === '') $out .= ' selected'; |
|
| 82 | + if ($selected === '') { |
|
| 83 | + $out .= ' selected'; |
|
| 84 | + } |
|
| 81 | 85 | $out .= '>'; |
| 82 | - if ($showempty != '1') $out .= $showempty; |
|
| 83 | - else $out .= ' '; |
|
| 86 | + if ($showempty != '1') { |
|
| 87 | + $out .= $showempty; |
|
| 88 | + } else { |
|
| 89 | + $out .= ' '; |
|
| 90 | + } |
|
| 84 | 91 | $out .= '</option>'; |
| 85 | 92 | } |
| 86 | 93 | if ($showauto) |
| 87 | 94 | { |
| 88 | 95 | $out .= '<option value="auto"'; |
| 89 | - if ($selected === 'auto') $out .= ' selected'; |
|
| 96 | + if ($selected === 'auto') { |
|
| 97 | + $out .= ' selected'; |
|
| 98 | + } |
|
| 90 | 99 | $out .= '>'.$langs->trans("AutoDetectLang").'</option>'; |
| 91 | 100 | } |
| 92 | 101 | |
@@ -96,16 +105,24 @@ discard block |
||
| 96 | 105 | { |
| 97 | 106 | $valuetoshow = $value; |
| 98 | 107 | if ($showcode == 1) { |
| 99 | - if ($mainlangonly) $valuetoshow = '<span class="opacitymedium">'.preg_replace('/[_-].*$/', '', $key).'</span> - '.$value; |
|
| 100 | - else $valuetoshow = '<span class="opacitymedium">'.$key.'</span> - '.$value; |
|
| 108 | + if ($mainlangonly) { |
|
| 109 | + $valuetoshow = '<span class="opacitymedium">'.preg_replace('/[_-].*$/', '', $key).'</span> - '.$value; |
|
| 110 | + } else { |
|
| 111 | + $valuetoshow = '<span class="opacitymedium">'.$key.'</span> - '.$value; |
|
| 112 | + } |
|
| 101 | 113 | } |
| 102 | 114 | if ($showcode == 2) { |
| 103 | - if ($mainlangonly) $valuetoshow = $value.' <span class="opacitymedium">('.preg_replace('/[_-].*$/', '', $key).')</span>'; |
|
| 104 | - else $valuetoshow = $value.' <span class="opacitymedium">('.$key.')</span>'; |
|
| 115 | + if ($mainlangonly) { |
|
| 116 | + $valuetoshow = $value.' <span class="opacitymedium">('.preg_replace('/[_-].*$/', '', $key).')</span>'; |
|
| 117 | + } else { |
|
| 118 | + $valuetoshow = $value.' <span class="opacitymedium">('.$key.')</span>'; |
|
| 119 | + } |
|
| 105 | 120 | } |
| 106 | 121 | |
| 107 | 122 | $keytouse = $key; |
| 108 | - if ($mainlangonly) $keytouse = preg_replace('/[_-].*$/', '', $key); |
|
| 123 | + if ($mainlangonly) { |
|
| 124 | + $keytouse = preg_replace('/[_-].*$/', '', $key); |
|
| 125 | + } |
|
| 109 | 126 | |
| 110 | 127 | if ($filter && is_array($filter) && array_key_exists($keytouse, $filter)) { |
| 111 | 128 | continue; |
@@ -152,7 +169,9 @@ discard block |
||
| 152 | 169 | |
| 153 | 170 | |
| 154 | 171 | // Check parameters |
| 155 | - if (!is_array($dirmenuarray)) return -1; |
|
| 172 | + if (!is_array($dirmenuarray)) { |
|
| 173 | + return -1; |
|
| 174 | + } |
|
| 156 | 175 | |
| 157 | 176 | $menuarray = array(); |
| 158 | 177 | foreach ($conf->file->dol_document_root as $dirroot) |
@@ -170,17 +189,33 @@ discard block |
||
| 170 | 189 | { |
| 171 | 190 | if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && substr($file, 0, 5) != 'index') |
| 172 | 191 | { |
| 173 | - if (preg_match('/lib\.php$/i', $file)) continue; // We exclude library files |
|
| 174 | - if (preg_match('/eldy_(backoffice|frontoffice)\.php$/i', $file)) continue; // We exclude all menu manager files |
|
| 175 | - if (preg_match('/auguria_(backoffice|frontoffice)\.php$/i', $file)) continue; // We exclude all menu manager files |
|
| 176 | - if (preg_match('/smartphone_(backoffice|frontoffice)\.php$/i', $file)) continue; // We exclude all menu manager files |
|
| 192 | + if (preg_match('/lib\.php$/i', $file)) { |
|
| 193 | + continue; |
|
| 194 | + } |
|
| 195 | + // We exclude library files |
|
| 196 | + if (preg_match('/eldy_(backoffice|frontoffice)\.php$/i', $file)) { |
|
| 197 | + continue; |
|
| 198 | + } |
|
| 199 | + // We exclude all menu manager files |
|
| 200 | + if (preg_match('/auguria_(backoffice|frontoffice)\.php$/i', $file)) { |
|
| 201 | + continue; |
|
| 202 | + } |
|
| 203 | + // We exclude all menu manager files |
|
| 204 | + if (preg_match('/smartphone_(backoffice|frontoffice)\.php$/i', $file)) { |
|
| 205 | + continue; |
|
| 206 | + } |
|
| 207 | + // We exclude all menu manager files |
|
| 177 | 208 | |
| 178 | 209 | $filelib = preg_replace('/\.php$/i', '', $file); |
| 179 | 210 | $prefix = ''; |
| 180 | 211 | // 0=Recommanded, 1=Experimental, 2=Developpement, 3=Other |
| 181 | - if (preg_match('/^eldy/i', $file)) $prefix = '0'; |
|
| 182 | - elseif (preg_match('/^smartphone/i', $file)) $prefix = '2'; |
|
| 183 | - else $prefix = '3'; |
|
| 212 | + if (preg_match('/^eldy/i', $file)) { |
|
| 213 | + $prefix = '0'; |
|
| 214 | + } elseif (preg_match('/^smartphone/i', $file)) { |
|
| 215 | + $prefix = '2'; |
|
| 216 | + } else { |
|
| 217 | + $prefix = '3'; |
|
| 218 | + } |
|
| 184 | 219 | |
| 185 | 220 | if ($file == $selected) |
| 186 | 221 | { |
@@ -204,16 +239,30 @@ discard block |
||
| 204 | 239 | { |
| 205 | 240 | $tab = explode('_', $key); |
| 206 | 241 | $newprefix = $tab[0]; |
| 207 | - if ($newprefix == '1' && ($conf->global->MAIN_FEATURES_LEVEL < 1)) continue; |
|
| 208 | - if ($newprefix == '2' && ($conf->global->MAIN_FEATURES_LEVEL < 2)) continue; |
|
| 209 | - if ($newprefix != $oldprefix) // Add separators |
|
| 242 | + if ($newprefix == '1' && ($conf->global->MAIN_FEATURES_LEVEL < 1)) { |
|
| 243 | + continue; |
|
| 244 | + } |
|
| 245 | + if ($newprefix == '2' && ($conf->global->MAIN_FEATURES_LEVEL < 2)) { |
|
| 246 | + continue; |
|
| 247 | + } |
|
| 248 | + if ($newprefix != $oldprefix) { |
|
| 249 | + // Add separators |
|
| 210 | 250 | { |
| 211 | 251 | // Affiche titre |
| 212 | 252 | print '<option value="-1" disabled>'; |
| 213 | - if ($newprefix == '0') print '-- '.$langs->trans("VersionRecommanded").' --'; |
|
| 214 | - if ($newprefix == '1') print '-- '.$langs->trans("VersionExperimental").' --'; |
|
| 215 | - if ($newprefix == '2') print '-- '.$langs->trans("VersionDevelopment").' --'; |
|
| 216 | - if ($newprefix == '3') print '-- '.$langs->trans("Other").' --'; |
|
| 253 | + } |
|
| 254 | + if ($newprefix == '0') { |
|
| 255 | + print '-- '.$langs->trans("VersionRecommanded").' --'; |
|
| 256 | + } |
|
| 257 | + if ($newprefix == '1') { |
|
| 258 | + print '-- '.$langs->trans("VersionExperimental").' --'; |
|
| 259 | + } |
|
| 260 | + if ($newprefix == '2') { |
|
| 261 | + print '-- '.$langs->trans("VersionDevelopment").' --'; |
|
| 262 | + } |
|
| 263 | + if ($newprefix == '3') { |
|
| 264 | + print '-- '.$langs->trans("Other").' --'; |
|
| 265 | + } |
|
| 217 | 266 | print '</option>'; |
| 218 | 267 | $oldprefix = $newprefix; |
| 219 | 268 | } |
@@ -256,11 +305,21 @@ discard block |
||
| 256 | 305 | if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') |
| 257 | 306 | { |
| 258 | 307 | $filelib = preg_replace('/(_backoffice|_frontoffice)?\.php$/i', '', $file); |
| 259 | - if (preg_match('/^index/i', $filelib)) continue; |
|
| 260 | - if (preg_match('/^default/i', $filelib)) continue; |
|
| 261 | - if (preg_match('/^empty/i', $filelib)) continue; |
|
| 262 | - if (preg_match('/\.lib/i', $filelib)) continue; |
|
| 263 | - if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file, $expdevmenu)) continue; |
|
| 308 | + if (preg_match('/^index/i', $filelib)) { |
|
| 309 | + continue; |
|
| 310 | + } |
|
| 311 | + if (preg_match('/^default/i', $filelib)) { |
|
| 312 | + continue; |
|
| 313 | + } |
|
| 314 | + if (preg_match('/^empty/i', $filelib)) { |
|
| 315 | + continue; |
|
| 316 | + } |
|
| 317 | + if (preg_match('/\.lib/i', $filelib)) { |
|
| 318 | + continue; |
|
| 319 | + } |
|
| 320 | + if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file, $expdevmenu)) { |
|
| 321 | + continue; |
|
| 322 | + } |
|
| 264 | 323 | |
| 265 | 324 | $menuarray[$filelib] = 1; |
| 266 | 325 | } |
@@ -287,8 +346,11 @@ discard block |
||
| 287 | 346 | print ' selected'; |
| 288 | 347 | } |
| 289 | 348 | print '>'; |
| 290 | - if ($key == 'all') print $langs->trans("AllMenus"); |
|
| 291 | - else print $key; |
|
| 349 | + if ($key == 'all') { |
|
| 350 | + print $langs->trans("AllMenus"); |
|
| 351 | + } else { |
|
| 352 | + print $key; |
|
| 353 | + } |
|
| 292 | 354 | print '</option>'."\n"; |
| 293 | 355 | } |
| 294 | 356 | print '</select>'; |
@@ -340,7 +402,9 @@ discard block |
||
| 340 | 402 | ); |
| 341 | 403 | foreach ($arraytz as $lib => $gmt) { |
| 342 | 404 | print '<option value="'.$lib.'"'; |
| 343 | - if ($selected == $lib || $selected == $gmt) print ' selected'; |
|
| 405 | + if ($selected == $lib || $selected == $gmt) { |
|
| 406 | + print ' selected'; |
|
| 407 | + } |
|
| 344 | 408 | print '>'.$gmt.'</option>'."\n"; |
| 345 | 409 | } |
| 346 | 410 | print '</select>'; |
@@ -368,7 +432,9 @@ discard block |
||
| 368 | 432 | $sql = "SELECT code, label, width, height, unit"; |
| 369 | 433 | $sql .= " FROM ".MAIN_DB_PREFIX."c_paper_format"; |
| 370 | 434 | $sql .= " WHERE active=1"; |
| 371 | - if ($filter) $sql .= " AND code LIKE '%".$this->db->escape($filter)."%'"; |
|
| 435 | + if ($filter) { |
|
| 436 | + $sql .= " AND code LIKE '%".$this->db->escape($filter)."%'"; |
|
| 437 | + } |
|
| 372 | 438 | |
| 373 | 439 | $resql = $this->db->query($sql); |
| 374 | 440 | if ($resql) |
@@ -394,7 +460,9 @@ discard block |
||
| 394 | 460 | if ($showempty) |
| 395 | 461 | { |
| 396 | 462 | $out .= '<option value=""'; |
| 397 | - if ($selected == '') $out .= ' selected'; |
|
| 463 | + if ($selected == '') { |
|
| 464 | + $out .= ' selected'; |
|
| 465 | + } |
|
| 398 | 466 | $out .= '> </option>'; |
| 399 | 467 | } |
| 400 | 468 | foreach ($paperformat as $key => $value) |
@@ -229,7 +229,9 @@ discard block |
||
| 229 | 229 | |
| 230 | 230 | // Call triggers |
| 231 | 231 | $result = $this->call_trigger('PRODUCTLOT_CREATE', $user); |
| 232 | - if ($result < 0) $error++; |
|
| 232 | + if ($result < 0) { |
|
| 233 | + $error++; |
|
| 234 | + } |
|
| 233 | 235 | // End call triggers |
| 234 | 236 | } |
| 235 | 237 | } |
@@ -584,8 +586,12 @@ discard block |
||
| 584 | 586 | { |
| 585 | 587 | // Add param to save lastsearch_values or not |
| 586 | 588 | $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); |
| 587 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; |
|
| 588 | - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; |
|
| 589 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { |
|
| 590 | + $add_save_lastsearch_values = 1; |
|
| 591 | + } |
|
| 592 | + if ($add_save_lastsearch_values) { |
|
| 593 | + $url .= '&save_lastsearch_values=1'; |
|
| 594 | + } |
|
| 589 | 595 | } |
| 590 | 596 | |
| 591 | 597 | $linkclose = ''; |
@@ -598,7 +604,9 @@ discard block |
||
| 598 | 604 | } |
| 599 | 605 | $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; |
| 600 | 606 | $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; |
| 601 | - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); |
|
| 607 | + } else { |
|
| 608 | + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); |
|
| 609 | + } |
|
| 602 | 610 | |
| 603 | 611 | if ($option == 'nolink') { |
| 604 | 612 | $linkstart = '<span'; |
@@ -613,8 +621,12 @@ discard block |
||
| 613 | 621 | } |
| 614 | 622 | |
| 615 | 623 | $result .= $linkstart; |
| 616 | - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
| 617 | - if ($withpicto != 2) $result .= $this->batch; |
|
| 624 | + if ($withpicto) { |
|
| 625 | + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
| 626 | + } |
|
| 627 | + if ($withpicto != 2) { |
|
| 628 | + $result .= $this->batch; |
|
| 629 | + } |
|
| 618 | 630 | $result .= $linkend; |
| 619 | 631 | |
| 620 | 632 | return $result; |