Skip to content

Commit

Permalink
Fixing style errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
stickler-ci committed Jan 31, 2020
1 parent a001913 commit fee113b
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 49 deletions.
20 changes: 12 additions & 8 deletions htdocs/core/lib/date.lib.php
Expand Up @@ -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);
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down
23 changes: 11 additions & 12 deletions htdocs/core/lib/project.lib.php
Expand Up @@ -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;
Expand Down Expand Up @@ -1805,7 +1805,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
{
print '<tr class="oddeven trforbreak">'."\n";
print '<td colspan="'.(6+count($TWeek)).'">';
print $projectstatic->getNomUrl(1,'',0,'<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1);
if ($projectstatic->title)
{
Expand Down Expand Up @@ -1853,7 +1853,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &

// Planned Workload
print '<td align="right" class="leftborder plannedworkload">';
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 '</td>';

Expand All @@ -1868,7 +1868,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
if ($lines[$i]->duration)
{
print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
print convertSecondToTime($lines[$i]->duration,'allhourmin');
print convertSecondToTime($lines[$i]->duration, 'allhourmin');
print '</a>';
}
else print '--:--';
Expand All @@ -1877,7 +1877,7 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &
// Time spent by user
print '<td align="right">';
$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 "</td>\n";

Expand All @@ -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 ='<td align="center" class="hide">';
Expand All @@ -1936,13 +1935,13 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &

// Warning
print '<td align="right">';
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 '</td>';

Expand Down
2 changes: 1 addition & 1 deletion htdocs/projet/activity/perday.php
Expand Up @@ -147,7 +147,7 @@
* 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
Expand Down
46 changes: 22 additions & 24 deletions htdocs/projet/activity/permonth.php
Expand Up @@ -38,10 +38,10 @@
$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;
Expand All @@ -61,13 +61,13 @@
$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');
Expand All @@ -87,7 +87,7 @@
$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);
Expand Down Expand Up @@ -115,11 +115,11 @@
* 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='';
Expand All @@ -130,7 +130,7 @@
$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 = '';
}
Expand Down Expand Up @@ -228,7 +228,6 @@
}
else
{

foreach($timetoadd as $taskid => $value) // Loop on each task
{
$updateoftaskdone=0;
Expand All @@ -237,7 +236,7 @@
$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);
Expand Down Expand Up @@ -324,7 +323,7 @@

$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)
{
Expand Down Expand Up @@ -353,7 +352,7 @@
//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');

Expand All @@ -367,10 +366,10 @@

// Show navigation bar
$nav ='<a class="inline-block valignmiddle" href="?year='.$prev_year."&month=".$prev_month."&day=".$prev_day.$param.'">'.img_previous($langs->trans("Previous"))."</a>\n";
$nav.=" <span id=\"month_name\">".dol_print_date(dol_mktime(0,0,0,$month,1,$year),"%Y").", ".$langs->trans(date('F', mktime(0, 0, 0, $month, 10)))." </span>\n";
$nav.=" <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%Y").", ".$langs->trans(date('F', mktime(0, 0, 0, $month, 10)))." </span>\n";
$nav.='<a class="inline-block valignmiddle" href="?year='.$next_year."&month=".$next_month."&day=".$next_day.$param.'">'.img_next($langs->trans("Next"))."</a>\n";
$nav.=" &nbsp; (<a href=\"?year=".$nowyear."&month=".$nowmonth."&day=".$nowday.$param."\">".$langs->trans("Today")."</a>)";
$nav.='<br>'.$form->select_date(-1,'',0,0,2,"addtime",1,0,1).' ';
$nav.='<br>'.$form->select_date(-1, '', 0, 0, 2, "addtime", 1, 0, 1).' ';
$nav.=' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';

$picto='calendarweek';
Expand Down Expand Up @@ -418,7 +417,7 @@
$formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1);
print '</div>';
print ' ';
print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth150onsmartphone');
print $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid', 0, 'maxwidth150onsmartphone');
print '<input type="submit" class="button valignmiddle" name="assigntask" value="'.dol_escape_htmltag($titleassigntask).'">';
print '</div>';

Expand Down Expand Up @@ -464,7 +463,7 @@
print '<div class="liste_titre liste_titre_bydiv centpercent">';
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 '</div>';
}
Expand Down Expand Up @@ -559,7 +558,6 @@
{
foreach($TWeek as $weekNb)
{

$timeonothertasks=($totalforeachweek[$weekNb] - $totalforvisibletasks[$weekNb]);
if ($timeonothertasks)
{
Expand All @@ -584,7 +582,7 @@
if ($timeonothertasks)
{
print '<span class="timesheetalreadyrecorded" title="texttoreplace"><input type="text" class="center smallpadd" size="2" disabled="" id="timespent[-1]['.$weekNb.']" name="task[-1]['.$weekNb.']" value="';
print convertSecondToTime($timeonothertasks,'allhourmin');
print convertSecondToTime($timeonothertasks, 'allhourmin');
print '"></span>';
}
print '</td>';
Expand All @@ -603,7 +601,7 @@

foreach ($TWeek as $weekNb)
{
print '<td class="liste_total hide'.$weekNb.'" align="center"><div class="totalDay'.$weekNb.'">'. convertSecondToTime($totalforvisibletasks[$weekNb],'allhourmin').'</div></td>';
print '<td class="liste_total hide'.$weekNb.'" align="center"><div class="totalDay'.$weekNb.'">'. convertSecondToTime($totalforvisibletasks[$weekNb], 'allhourmin').'</div></td>';
}
print '<td class="liste_total center"><div class="totalDayAll">&nbsp;</div></td>
</tr>';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/projet/activity/perweek.php
Expand Up @@ -163,7 +163,7 @@
* 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
Expand Down
6 changes: 3 additions & 3 deletions htdocs/projet/class/project.class.php
Expand Up @@ -1806,14 +1806,14 @@ public function loadTimeSpent($datestart, $taskid = 0, $userid = 0)
* @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";
Expand All @@ -1837,7 +1837,7 @@ public function loadTimeSpentMonth($datestart, $taskid=0, $userid=0)
{
$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]))
Expand Down

0 comments on commit fee113b

Please sign in to comment.