Merge pull request #8331 from atm-alexis/NEW_hidden_conf_for_nb_weeks_to_swho
NEW hidden conf AGENDA_NB_WEEKS_IN_VIEW_PER_USER to set nb weeks to show into per user view
This commit is contained in:
commit
8aec5cf6fa
@ -245,7 +245,9 @@ $next_day = $next['day'];
|
|||||||
|
|
||||||
// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
|
// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
|
||||||
$firstdaytoshow=dol_mktime(0,0,0,$first_month,$first_day,$first_year);
|
$firstdaytoshow=dol_mktime(0,0,0,$first_month,$first_day,$first_year);
|
||||||
$lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd');
|
|
||||||
|
$nb_weeks_to_show = !empty($conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER) ? (int)$conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7 : 7;
|
||||||
|
$lastdaytoshow=dol_time_plus_duree($firstdaytoshow, $nb_weeks_to_show, 'd');
|
||||||
//print $firstday.'-'.$first_month.'-'.$first_year;
|
//print $firstday.'-'.$first_month.'-'.$first_year;
|
||||||
//print dol_print_date($firstdaytoshow,'dayhour');
|
//print dol_print_date($firstdaytoshow,'dayhour');
|
||||||
//print dol_print_date($lastdaytoshow,'dayhour');
|
//print dol_print_date($lastdaytoshow,'dayhour');
|
||||||
@ -465,7 +467,7 @@ if ($filtert > 0 || $usergroup > 0)
|
|||||||
}
|
}
|
||||||
// Sort on date
|
// Sort on date
|
||||||
$sql.= ' ORDER BY fk_user_action, datep'; //fk_user_action
|
$sql.= ' ORDER BY fk_user_action, datep'; //fk_user_action
|
||||||
//print $sql;exit;
|
|
||||||
|
|
||||||
dol_syslog("comm/action/peruser.php", LOG_DEBUG);
|
dol_syslog("comm/action/peruser.php", LOG_DEBUG);
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
@ -619,15 +621,18 @@ echo '<input type="hidden" name="newdate" id="newdate">' ;
|
|||||||
|
|
||||||
//print "begin_d=".$begin_d." end_d=".$end_d;
|
//print "begin_d=".$begin_d." end_d=".$end_d;
|
||||||
|
|
||||||
|
$currentdaytoshow = $firstdaytoshow;
|
||||||
echo '<div class="div-table-responsive">';
|
echo '<div class="div-table-responsive">';
|
||||||
echo '<table width="100%" class="noborder nocellnopadd cal_month">';
|
|
||||||
|
|
||||||
echo '<tr class="liste_titre">';
|
while($currentdaytoshow<$lastdaytoshow) {
|
||||||
echo '<td></td>';
|
|
||||||
$i=0; // 0 = sunday,
|
echo '<table width="100%" class="noborder nocellnopadd cal_month">';
|
||||||
while ($i < 7)
|
|
||||||
{
|
echo '<tr class="liste_titre">';
|
||||||
|
echo '<td></td>';
|
||||||
|
$i=0; // 0 = sunday,
|
||||||
|
while ($i < 7)
|
||||||
|
{
|
||||||
if (($i + 1) < $begin_d || ($i + 1) > $end_d)
|
if (($i + 1) < $begin_d || ($i + 1) > $end_d)
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
@ -636,18 +641,18 @@ while ($i < 7)
|
|||||||
echo '<td align="center" colspan="'.($end_h - $begin_h).'">';
|
echo '<td align="center" colspan="'.($end_h - $begin_h).'">';
|
||||||
echo $langs->trans("Day".(($i+(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)) % 7));
|
echo $langs->trans("Day".(($i+(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1)) % 7));
|
||||||
print "<br>";
|
print "<br>";
|
||||||
if ($i) print dol_print_date(dol_time_plus_duree($firstdaytoshow, $i, 'd'),'day');
|
if ($i) print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'),'day');
|
||||||
else print dol_print_date($firstdaytoshow,'day');
|
else print dol_print_date($currentdaytoshow,'day');
|
||||||
echo "</td>\n";
|
echo "</td>\n";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
|
|
||||||
echo '<tr class="liste_titre">';
|
echo '<tr class="liste_titre">';
|
||||||
echo '<td></td>';
|
echo '<td></td>';
|
||||||
$i=0;
|
$i=0;
|
||||||
while ($i < 7)
|
while ($i < 7)
|
||||||
{
|
{
|
||||||
if (($i + 1) < $begin_d || ($i + 1) > $end_d)
|
if (($i + 1) < $begin_d || ($i + 1) > $end_d)
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
@ -661,16 +666,16 @@ while ($i < 7)
|
|||||||
}
|
}
|
||||||
echo "</td>\n";
|
echo "</td>\n";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
|
|
||||||
|
|
||||||
// Define $usernames
|
// Define $usernames
|
||||||
$usernames = array(); //init
|
$usernames = array(); //init
|
||||||
$usernamesid = array();
|
$usernamesid = array();
|
||||||
/* Use this to have list of users only if users have events */
|
/* Use this to have list of users only if users have events */
|
||||||
if (! empty($conf->global->AGENDA_SHOWOWNERONLY_ONPERUSERVIEW))
|
if (! empty($conf->global->AGENDA_SHOWOWNERONLY_ONPERUSERVIEW))
|
||||||
{
|
{
|
||||||
foreach ($eventarray as $daykey => $notused)
|
foreach ($eventarray as $daykey => $notused)
|
||||||
{
|
{
|
||||||
// Get all assigned users for each event
|
// Get all assigned users for each event
|
||||||
@ -684,10 +689,10 @@ if (! empty($conf->global->AGENDA_SHOWOWNERONLY_ONPERUSERVIEW))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Use this list to have for all users */
|
/* Use this list to have for all users */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql = "SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity";
|
$sql = "SELECT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||||
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user";
|
if ($usergroup > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug ON u.rowid = ug.fk_user";
|
||||||
@ -710,53 +715,53 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else dol_print_error($db);
|
else dol_print_error($db);
|
||||||
}
|
}
|
||||||
//var_dump($usernamesid);
|
//var_dump($usernamesid);
|
||||||
foreach($usernamesid as $id)
|
foreach($usernamesid as $id)
|
||||||
{
|
{
|
||||||
$tmpuser=new User($db);
|
$tmpuser=new User($db);
|
||||||
$result=$tmpuser->fetch($id);
|
$result=$tmpuser->fetch($id);
|
||||||
$usernames[]=$tmpuser;
|
$usernames[]=$tmpuser;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if ($filtert > 0)
|
if ($filtert > 0)
|
||||||
{
|
{
|
||||||
$tmpuser = new User($db);
|
$tmpuser = new User($db);
|
||||||
$tmpuser->fetch($filtert);
|
$tmpuser->fetch($filtert);
|
||||||
$usernames[] = $tmpuser;
|
$usernames[] = $tmpuser;
|
||||||
}
|
}
|
||||||
else if ($usergroup)
|
else if ($usergroup)
|
||||||
{
|
{
|
||||||
$tmpgroup = new UserGroup($db);
|
$tmpgroup = new UserGroup($db);
|
||||||
$tmpgroup->fetch($usergroup);
|
$tmpgroup->fetch($usergroup);
|
||||||
$usernames = $tmpgroup->listUsersForGroup();
|
$usernames = $tmpgroup->listUsersForGroup();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$tmpgroup = new UserGroup($db);
|
$tmpgroup = new UserGroup($db);
|
||||||
//$tmpgroup->fetch($usergroup); No fetch, we want all users for all groups
|
//$tmpgroup->fetch($usergroup); No fetch, we want all users for all groups
|
||||||
$usernames = $tmpgroup->listUsersForGroup();
|
$usernames = $tmpgroup->listUsersForGroup();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
// Load array of colors by type
|
// Load array of colors by type
|
||||||
$colorsbytype=array();
|
$colorsbytype=array();
|
||||||
$labelbytype=array();
|
$labelbytype=array();
|
||||||
$sql="SELECT code, color, libelle FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position";
|
$sql="SELECT code, color, libelle FROM ".MAIN_DB_PREFIX."c_actioncomm ORDER BY position";
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
while ($obj = $db->fetch_object($resql))
|
while ($obj = $db->fetch_object($resql))
|
||||||
{
|
{
|
||||||
$colorsbytype[$obj->code]=$obj->color;
|
$colorsbytype[$obj->code]=$obj->color;
|
||||||
$labelbytype[$obj->code]=$obj->libelle;
|
$labelbytype[$obj->code]=$obj->libelle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop on each user to show calendar
|
// Loop on each user to show calendar
|
||||||
$todayarray=dol_getdate($now,'fast');
|
$todayarray=dol_getdate($now,'fast');
|
||||||
$sav = $tmpday;
|
$sav = $tmpday;
|
||||||
$showheader = true;
|
$showheader = true;
|
||||||
$var = false;
|
$var = false;
|
||||||
foreach ($usernames as $username)
|
foreach ($usernames as $username)
|
||||||
{
|
{
|
||||||
$var = ! $var;
|
$var = ! $var;
|
||||||
echo "<tr>";
|
echo "<tr>";
|
||||||
echo '<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var?' cal_impair':'').'">';
|
echo '<td class="tdoverflowmax100 cal_current_month cal_peruserviewname'.($var?' cal_impair':'').'">';
|
||||||
@ -768,6 +773,7 @@ foreach ($usernames as $username)
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
for ($iter_day = 0; $iter_day < 8; $iter_day++)
|
for ($iter_day = 0; $iter_day < 8; $iter_day++)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (($i + 1) < $begin_d || ($i + 1) > $end_d)
|
if (($i + 1) < $begin_d || ($i + 1) > $end_d)
|
||||||
{
|
{
|
||||||
$i++;
|
$i++;
|
||||||
@ -775,7 +781,7 @@ foreach ($usernames as $username)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show days of the current week
|
// Show days of the current week
|
||||||
$curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd');
|
$curtime = dol_time_plus_duree($currentdaytoshow, $iter_day, 'd');
|
||||||
$tmparray = dol_getdate($curtime,'fast');
|
$tmparray = dol_getdate($curtime,'fast');
|
||||||
$tmpday = $tmparray['mday'];
|
$tmpday = $tmparray['mday'];
|
||||||
$tmpmonth = $tmparray['mon'];
|
$tmpmonth = $tmparray['mon'];
|
||||||
@ -793,9 +799,15 @@ foreach ($usernames as $username)
|
|||||||
}
|
}
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
$showheader = false;
|
$showheader = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "</table>\n";
|
||||||
|
echo "<br />";
|
||||||
|
|
||||||
|
$currentdaytoshow = dol_time_plus_duree($currentdaytoshow, 7, 'd');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "</table>\n";
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && ! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE))
|
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && ! empty($conf->global->AGENDA_USE_COLOR_PER_EVENT_TYPE))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user