From fee113bfb5bf928fa4630305490668fb28029b23 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 31 Jan 2020 10:26:33 +0000 Subject: [PATCH] Fixing style errors. --- htdocs/core/lib/date.lib.php | 20 +++++++----- htdocs/core/lib/project.lib.php | 23 +++++++------- htdocs/projet/activity/perday.php | 2 +- htdocs/projet/activity/permonth.php | 46 +++++++++++++-------------- htdocs/projet/activity/perweek.php | 2 +- htdocs/projet/class/project.class.php | 6 ++-- 6 files changed, 50 insertions(+), 49 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index b604ea831b1..43a28a4b05c 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -970,8 +970,9 @@ function monthArray($outputlangs, $short = 0) * @return array Week numbers */ -function getWeekNumbersOfMonth($month, $year) { - $nb_days = cal_days_in_month(CAL_GREGORIAN,$month, $year); +function getWeekNumbersOfMonth($month, $year) +{ + $nb_days = cal_days_in_month(CAL_GREGORIAN, $month, $year); $TWeek = array(); for($day = 1; $day < $nb_days; $day++) { $week_number = getWeekNumber($day, $month, $year); @@ -987,11 +988,12 @@ function getWeekNumbersOfMonth($month, $year) { * @param int $year Year number * @return array First day of week */ -function getFirstDayOfEachWeek($TWeek, $year) { +function getFirstDayOfEachWeek($TWeek, $year) +{ $TFirstDayOfWeek = array(); foreach($TWeek as $weekNb) { - if(in_array('01',$TWeek) && in_array('52',$TWeek) && $weekNb == '01') $year++;//Si on a la 1re semaine et la semaine 52 c'est qu'on change d'année - $TFirstDayOfWeek[$weekNb] = date('d',strtotime($year.'W'.$weekNb)); + if(in_array('01', $TWeek) && in_array('52', $TWeek) && $weekNb == '01') $year++;//Si on a la 1re semaine et la semaine 52 c'est qu'on change d'année + $TFirstDayOfWeek[$weekNb] = date('d', strtotime($year.'W'.$weekNb)); } return $TFirstDayOfWeek; } @@ -1003,10 +1005,11 @@ function getFirstDayOfEachWeek($TWeek, $year) { * @param int $year Year number * @return array Last day of week */ -function getLastDayOfEachWeek($TWeek, $year) { +function getLastDayOfEachWeek($TWeek, $year) +{ $TLastDayOfWeek = array(); foreach($TWeek as $weekNb) { - $TLastDayOfWeek[$weekNb] = date('d',strtotime($year.'W'.$weekNb.'+6 days')); + $TLastDayOfWeek[$weekNb] = date('d', strtotime($year.'W'.$weekNb.'+6 days')); } return $TLastDayOfWeek; } @@ -1019,7 +1022,8 @@ function getLastDayOfEachWeek($TWeek, $year) { * @param int $year Year number * @return int Week number */ -function getWeekNumber($day, $month, $year) { +function getWeekNumber($day, $month, $year) +{ $date = new DateTime($year.'-'.$month.'-'.$day); $week = $date->format("W"); return $week; diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index e2f08e7c092..d7275d3343a 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1729,7 +1729,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ * @param int $oldprojectforbreak Old project id of last project break * @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks */ -function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak=0, $TWeek=array()) +function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $TWeek = array()) { global $conf, $db, $user, $bc, $langs; global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; @@ -1805,7 +1805,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & { print ''."\n"; print ''; - print $projectstatic->getNomUrl(1,'',0,''.$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + print $projectstatic->getNomUrl(1, '', 0, ''.$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); if ($projectstatic->title) { @@ -1853,7 +1853,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & // Planned Workload print ''; - if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload,'allhourmin'); + if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); else print '--:--'; print ''; @@ -1868,7 +1868,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & if ($lines[$i]->duration) { print ''; - print convertSecondToTime($lines[$i]->duration,'allhourmin'); + print convertSecondToTime($lines[$i]->duration, 'allhourmin'); print ''; } else print '--:--'; @@ -1877,7 +1877,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & // Time spent by user print ''; $tmptimespent=$taskstatic->getSummaryOfTimeSpent($fuser->id); - if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin'); + if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin'); else print '--:--'; print "\n"; @@ -1901,20 +1901,19 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & //TODO // Fields to show current time $tableCell=''; $modeinput='hours'; - $TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y',$firstdaytoshow)); + $TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y', $firstdaytoshow)); $TFirstDay[reset($TWeek)] = 1; foreach($TFirstDay as &$fday) { $fday--; } foreach ($TWeek as $weekNb) { - $weekWorkLoad = $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]; $totalforeachweek[$weekNb]+=$weekWorkLoad; $alreadyspent=''; - if ($weekWorkLoad > 0) $alreadyspent=convertSecondToTime($weekWorkLoad,'allhourmin'); - $alttitle=$langs->trans("AddHereTimeSpentForWeek",$weekNb); + if ($weekWorkLoad > 0) $alreadyspent=convertSecondToTime($weekWorkLoad, 'allhourmin'); + $alttitle=$langs->trans("AddHereTimeSpentForWeek", $weekNb); $tableCell =''; @@ -1936,13 +1935,13 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & // Warning print ''; - if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); - else if ($disabledtask) + if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject")); + elseif ($disabledtask) { $titleassigntask = $langs->trans("AssignTaskToMe"); if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); - print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); + print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); } print ''; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 9e056ba5029..2489104eb34 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -147,7 +147,7 @@ $search_array_options_task = $extrafields->getOptionalsFromPost($object->table_e * Actions */ $parameters = array('id' => $id, 'taskid' => $taskid, 'projectid' => $projectid); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Purge criteria 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 diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index e35a47551b1..93c1edb6757 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -38,10 +38,10 @@ require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; $langs->loadLangs(array('projects','users','companies')); $hookmanager->initHooks(array('timesheetpermonthcard')); -$action=GETPOST('action','aZ09'); -$mode=GETPOST("mode",'alpha'); -$id=GETPOST('id','int'); -$taskid=GETPOST('taskid','int'); +$action=GETPOST('action', 'aZ09'); +$mode=GETPOST("mode", 'alpha'); +$id=GETPOST('id', 'int'); +$taskid=GETPOST('taskid', 'int'); $mine=0; if ($mode == 'mine') $mine=1; @@ -61,13 +61,13 @@ $nowday=$nowtmp['mday']; $nowmonth=$nowtmp['mon']; $nowyear=$nowtmp['year']; -$year=GETPOST('reyear')?GETPOST('reyear','int'):(GETPOST("year")?GETPOST("year","int"):date("Y")); -$month=GETPOST('remonth')?GETPOST('remonth','int'):(GETPOST("month")?GETPOST("month","int"):date("m")); -$day=GETPOST('reday')?GETPOST('reday','int'):(GETPOST("day")?GETPOST("day","int"):date("d")); +$year=GETPOST('reyear')?GETPOST('reyear', 'int'):(GETPOST("year")?GETPOST("year", "int"):date("Y")); +$month=GETPOST('remonth')?GETPOST('remonth', 'int'):(GETPOST("month")?GETPOST("month", "int"):date("m")); +$day=GETPOST('reday')?GETPOST('reday', 'int'):(GETPOST("day")?GETPOST("day", "int"):date("d")); $day = (int) $day; -$week=GETPOST("week","int")?GETPOST("week","int"):date("W"); +$week=GETPOST("week", "int")?GETPOST("week", "int"):date("W"); -$search_categ=GETPOST("search_categ",'alpha'); +$search_categ=GETPOST("search_categ", 'alpha'); $search_usertoprocessid=GETPOST('search_usertoprocessid', 'int'); $search_task_ref=GETPOST('search_task_ref', 'alpha'); $search_task_label=GETPOST('search_task_label', 'alpha'); @@ -87,7 +87,7 @@ $next_year = $next['year']; $next_month = $next['month']; $next_day = 1; $TWeek = getWeekNumbersOfMonth($month, $year); -$firstdaytoshow = dol_mktime(0,0,0,$month,1,$year); +$firstdaytoshow = dol_mktime(0, 0, 0, $month, 1, $year); $TFirstDays = getFirstDayOfEachWeek($TWeek, $year); $TFirstDays[reset($TWeek)] = '01'; //first day of month $TLastDays = getLastDayOfEachWeek($TWeek, $year); @@ -115,11 +115,11 @@ $object=new Task($db); * Actions */ $parameters = array('id' => $id, 'taskid' => $taskid, 'projectid' => $projectid, 'TWeek' => $TWeek, 'TFirstDays' => $TFirstDays, 'TLastDays' => $TLastDays); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Purge criteria -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 +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 { $action = ''; $search_categ=''; @@ -130,7 +130,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_thirdparty = ''; $search_declared_progress = ''; } -if (GETPOST("button_search_x",'alpha') || GETPOST("button_search.x",'alpha') || GETPOST("button_search",'alpha')) +if (GETPOST("button_search_x", 'alpha') || GETPOST("button_search.x", 'alpha') || GETPOST("button_search", 'alpha')) { $action = ''; } @@ -228,7 +228,6 @@ if ($action == 'addtime' && $user->rights->projet->lire) } else { - foreach($timetoadd as $taskid => $value) // Loop on each task { $updateoftaskdone=0; @@ -237,7 +236,7 @@ if ($action == 'addtime' && $user->rights->projet->lire) $amountoadd=$timetoadd[$taskid][$key]; if (! empty($amountoadd)) { - $tmpduration=explode(':',$amountoadd); + $tmpduration=explode(':', $amountoadd); $newduration=0; if (! empty($tmpduration[0])) $newduration+=($tmpduration[0] * 3600); if (! empty($tmpduration[1])) $newduration+=($tmpduration[1] * 60); @@ -324,7 +323,7 @@ $holiday = new Holiday($db); $title=$langs->trans("TimeSpent"); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,(empty($usertoprocess->id)?2:0),1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess, (empty($usertoprocess->id)?2:0), 1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project //var_dump($projectsListId); if ($id) { @@ -353,7 +352,7 @@ $tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($proj //var_dump($taskrole); -llxHeader("",$title,"",'','','',array('/core/js/timesheet.js')); +llxHeader("", $title, "", '', '', '', array('/core/js/timesheet.js')); //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, '', 'title_project'); @@ -367,10 +366,10 @@ $param.=($search_task_label?'&search_task_label='.$search_task_label:''); // Show navigation bar $nav =''.img_previous($langs->trans("Previous"))."\n"; -$nav.=" ".dol_print_date(dol_mktime(0,0,0,$month,1,$year),"%Y").", ".$langs->trans(date('F', mktime(0, 0, 0, $month, 10)))." \n"; +$nav.=" ".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%Y").", ".$langs->trans(date('F', mktime(0, 0, 0, $month, 10)))." \n"; $nav.=''.img_next($langs->trans("Next"))."\n"; $nav.="   (".$langs->trans("Today").")"; -$nav.='
'.$form->select_date(-1,'',0,0,2,"addtime",1,0,1).' '; +$nav.='
'.$form->select_date(-1, '', 0, 0, 2, "addtime", 1, 0, 1).' '; $nav.=' '; $picto='calendarweek'; @@ -418,7 +417,7 @@ print '
'; $formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); print '
'; print ' '; -print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth150onsmartphone'); +print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone'); print ''; print ''; @@ -464,7 +463,7 @@ if (! empty($moreforfilter)) print '
'; print $moreforfilter; $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; } @@ -559,7 +558,6 @@ if (count($tasksarray) > 0) { foreach($TWeek as $weekNb) { - $timeonothertasks=($totalforeachweek[$weekNb] - $totalforvisibletasks[$weekNb]); if ($timeonothertasks) { @@ -584,7 +582,7 @@ if (count($tasksarray) > 0) if ($timeonothertasks) { print ''; } print ''; @@ -603,7 +601,7 @@ if (count($tasksarray) > 0) foreach ($TWeek as $weekNb) { - print '
'. convertSecondToTime($totalforvisibletasks[$weekNb],'allhourmin').'
'; + print '
'. convertSecondToTime($totalforvisibletasks[$weekNb], 'allhourmin').'
'; } print '
 
'; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 085b54b9bdb..563b7ca19c9 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -163,7 +163,7 @@ $search_array_options_task = $extrafields->getOptionalsFromPost('projet_task', ' * Actions */ $parameters = array('id' => $id, 'taskid' => $taskid, 'projectid' => $projectid); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); // Purge criteria 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 diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 048ea819187..ce1c8fdaf17 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1806,14 +1806,14 @@ class Project extends CommonObject * @param int $userid Time spent by a particular user * @return int <0 if OK, >0 if KO */ - public function loadTimeSpentMonth($datestart, $taskid=0, $userid=0) + public function loadTimeSpentMonth($datestart, $taskid = 0, $userid = 0) { $error=0; $this->monthWorkLoad=array(); $this->monthWorkLoadPerTask=array(); - if (empty($datestart)) dol_print_error('','Error datestart parameter is empty'); + if (empty($datestart)) dol_print_error('', 'Error datestart parameter is empty'); $sql = "SELECT ptt.rowid as taskid, ptt.task_duration, ptt.task_date, ptt.task_datehour, ptt.fk_task"; $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt"; @@ -1837,7 +1837,7 @@ class Project extends CommonObject { $obj=$this->db->fetch_object($resql); if(!empty($obj->task_date)) { - $date = explode('-',$obj->task_date); + $date = explode('-', $obj->task_date); $week_number = getWeekNumber($date[2], $date[1], $date[0]); } if (empty($weekalreadyfound[$week_number]))