Prepare the ground to have a full editable homearea page

This commit is contained in:
Laurent Destailleur 2016-02-07 13:10:36 +01:00
parent c71bb9d67c
commit 28c89dc3e3
2 changed files with 111 additions and 96 deletions

View File

@ -960,16 +960,15 @@ class FormOther
/** /**
* Show a HTML Tab with boxes of a particular area including personalized choices of user. * Get array with HTML tabs with boxes of a particular area including personalized choices of user.
* Class 'Form' must be known. * Class 'Form' must be known.
* *
* @param User $user Object User * @param User $user Object User
* @param String $areacode Code of area for pages (0=value for Home page) * @param String $areacode Code of area for pages (0=value for Home page)
* @return array array('selectboxlist'=>, 'boxactivated'=>, 'boxlist'=>) * @return array array('selectboxlist'=>, 'boxactivated'=>, 'boxlist'=>)
*/ */
static function printBoxesArea($user,$areacode) static function getBoxesArea($user,$areacode)
{ {
global $conf,$langs,$db; global $conf,$langs,$db;
@ -980,9 +979,8 @@ class FormOther
// $boxactivated will be array of boxes enabled into global setup // $boxactivated will be array of boxes enabled into global setup
// $boxidactivatedforuser will be array of boxes choosed by user // $boxidactivatedforuser will be array of boxes choosed by user
$selectboxlist=$boxlist=''; $selectboxlist='';
$boxactivated=InfoBox::listBoxes($db,'activated',$areacode,(empty($user->conf->$confuserzone)?null:$user)); // Search boxes of common+user (or common only if user has no specific setup) $boxactivated=InfoBox::listBoxes($db,'activated',$areacode,(empty($user->conf->$confuserzone)?null:$user)); // Search boxes of common+user (or common only if user has no specific setup)
//var_dump($boxactivated);
$boxidactivatedforuser=array(); $boxidactivatedforuser=array();
foreach($boxactivated as $box) foreach($boxactivated as $box)
@ -990,6 +988,7 @@ class FormOther
if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id]=$box->id; // We keep only boxes to show for user if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id]=$box->id; // We keep only boxes to show for user
} }
// Define selectboxlist
$arrayboxtoactivatelabel=array(); $arrayboxtoactivatelabel=array();
if (! empty($user->conf->$confuserzone)) if (! empty($user->conf->$confuserzone))
{ {
@ -1092,8 +1091,8 @@ class FormOther
$selectboxlist.='</script>'."\n"; $selectboxlist.='</script>'."\n";
} }
// Define boxlista and boxlistb
$nbboxactivated=count($boxidactivatedforuser); $nbboxactivated=count($boxidactivatedforuser);
//print load_fiche_titre(($nbboxactivated?$langs->trans("OtherInformationsBoxes"):''),$selectboxlist,'','','otherboxes');
if ($nbboxactivated) if ($nbboxactivated)
{ {
@ -1102,13 +1101,13 @@ class FormOther
$emptybox=new ModeleBoxes($db); $emptybox=new ModeleBoxes($db);
$boxlist.='<table width="100%" class="notopnoleftnoright">'; //$boxlist.='<table width="100%" class="notopnoleftnoright">';
$boxlist.='<tr><td class="notopnoleftnoright">'."\n"; //$boxlist.='<tr><td class="notopnoleftnoright">'."\n";
$boxlist.='<div class="fichehalfleft">'; //$boxlist.='<div class="fichehalfleft">';
$boxlist.="\n<!-- Box left container -->\n"; $boxlista.="\n<!-- Box left container -->\n";
$boxlist.='<div id="left" class="connectedSortable">'."\n"; $boxlista.='<div id="left" class="connectedSortable">'."\n";
// Define $box_max_lines // Define $box_max_lines
$box_max_lines=5; $box_max_lines=5;
@ -1124,9 +1123,9 @@ class FormOther
$ii++; $ii++;
//print 'box_id '.$boxactivated[$ii]->box_id.' '; //print 'box_id '.$boxactivated[$ii]->box_id.' ';
//print 'box_order '.$boxactivated[$ii]->box_order.'<br>'; //print 'box_order '.$boxactivated[$ii]->box_order.'<br>';
// Affichage boite key // Show box
$box->loadBox($box_max_lines); $box->loadBox($box_max_lines);
$boxlist.= $box->outputBox(); $boxlista.= $box->outputBox();
} }
} }
@ -1135,15 +1134,15 @@ class FormOther
$emptybox->box_id='A'; $emptybox->box_id='A';
$emptybox->info_box_head=array(); $emptybox->info_box_head=array();
$emptybox->info_box_contents=array(); $emptybox->info_box_contents=array();
$boxlist.= $emptybox->outputBox(array(),array()); $boxlista.= $emptybox->outputBox(array(),array());
} }
$boxlist.= "</div>\n"; $boxlista.= "</div>\n";
$boxlist.= "<!-- End box left container -->\n"; $boxlista.= "<!-- End box left container -->\n";
$boxlist.= '</div><div class="fichehalfright"><div class="ficheaddleft">'; //$boxlist.= '</div><div class="fichehalfright"><div class="ficheaddleft">';
$boxlist.= "\n<!-- Box right container -->\n"; $boxlistb.= "\n<!-- Box right container -->\n";
$boxlist.= '<div id="right" class="connectedSortable">'."\n"; $boxlistb.= '<div id="right" class="connectedSortable">'."\n";
$ii=0; $ii=0;
foreach ($boxactivated as $key => $box) foreach ($boxactivated as $key => $box)
@ -1155,9 +1154,9 @@ class FormOther
$ii++; $ii++;
//print 'box_id '.$boxactivated[$ii]->box_id.' '; //print 'box_id '.$boxactivated[$ii]->box_id.' ';
//print 'box_order '.$boxactivated[$ii]->box_order.'<br>'; //print 'box_order '.$boxactivated[$ii]->box_order.'<br>';
// Affichage boite key // Show box
$box->loadBox($box_max_lines); $box->loadBox($box_max_lines);
$boxlist.= $box->outputBox(); $boxlistb.= $box->outputBox();
} }
} }
@ -1166,19 +1165,19 @@ class FormOther
$emptybox->box_id='B'; $emptybox->box_id='B';
$emptybox->info_box_head=array(); $emptybox->info_box_head=array();
$emptybox->info_box_contents=array(); $emptybox->info_box_contents=array();
$boxlist.= $emptybox->outputBox(array(),array()); $boxlistb.= $emptybox->outputBox(array(),array());
} }
$boxlist.= "</div>\n"; $boxlistb.= "</div>\n";
$boxlist.= "<!-- End box right container -->\n"; $boxlistb.= "<!-- End box right container -->\n";
$boxlist.= '</div></div>'; //$boxlist.= '</div></div>';
$boxlist.= "\n"; //$boxlist.= "\n";
$boxlist.= "</td></tr>"; //$boxlist.= "</td></tr>";
$boxlist.= "</table>"; //$boxlist.= "</table>";
} }
return array('selectboxlist'=>count($boxactivated)?$selectboxlist:'', 'boxactivated'=>$boxactivated, 'boxlist'=>$boxlist); return array('selectboxlist'=>count($boxactivated)?$selectboxlist:'', 'boxactivated'=>$boxactivated, 'boxlista'=>$boxlista, 'boxlistb'=>$boxlistb);
} }

View File

@ -73,7 +73,7 @@ if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$langs->trans("HomeAr
llxHeader('',$title); llxHeader('',$title);
$resultboxes=FormOther::printBoxesArea($user,"0"); $resultboxes=FormOther::getBoxesArea($user,"0");
print load_fiche_titre($langs->trans("HomeArea"),$resultboxes['selectboxlist'],'title_home'); print load_fiche_titre($langs->trans("HomeArea"),$resultboxes['selectboxlist'],'title_home');
@ -107,38 +107,41 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
/* /*
* Informations area * Informations area
*/ */
$boxinfo='';
print '<table summary="Login info" class="noborder" width="100%">'; $boxinfo.= '<div class="box">';
print '<tr class="liste_titre"><th class="liste_titre" colspan="2">'.$langs->trans("Informations").'</th></tr>'; $boxinfo.= '<table summary="'.dol_escape_htmltag($langs->trans("LoginInformation")).'" class="noborder boxtable" width="100%">';
print '<tr '.$bc[false].'>'; $boxinfo.= '<tr class="liste_titre"><th class="liste_titre" colspan="2">'.$langs->trans("Informations").'</th></tr>';
print '<td class="nowrap">'.$langs->trans("User").'</td><td>'.$user->getNomUrl(0).'</td></tr>'; $boxinfo.= '<tr '.$bc[false].'>';
print '<tr '.$bc[true].'>'; $boxinfo.= '<td class="nowrap">'.$langs->trans("User").'</td><td>'.$user->getNomUrl(0).'</td></tr>';
print '<td class="nowrap">'.$langs->trans("PreviousConnexion").'</td><td>'; $boxinfo.= '<tr '.$bc[true].'>';
if ($user->datepreviouslogin) print dol_print_date($user->datepreviouslogin,"dayhour",'tzuser'); $boxinfo.= '<td class="nowrap">'.$langs->trans("PreviousConnexion").'</td><td>';
else print $langs->trans("Unknown"); if ($user->datepreviouslogin) $boxinfo.= dol_print_date($user->datepreviouslogin,"dayhour",'tzuser');
print '</td>'; else $boxinfo.= $langs->trans("Unknown");
print "</tr>\n"; $boxinfo.= '</td>';
print "</table>\n"; $boxinfo.= "</tr>\n";
$boxinfo.= "</table>\n";
$boxinfo.= '</div>';
print $boxinfo;
/* /*
* Dashboard Dolibarr states (statistics) * Dashboard Dolibarr states (statistics)
* Hidden for external users * Hidden for external users
*/ */
$boxstat='';
$langs->load("commercial"); $langs->load("commercial");
$langs->load("bills"); $langs->load("bills");
$langs->load("orders"); $langs->load("orders");
$langs->load("contracts"); $langs->load("contracts");
//print memory_get_usage();
if (empty($user->societe_id)) if (empty($user->societe_id))
{ {
print '<br>'; $boxstat.='<div class="box">';
print '<table summary="'.$langs->trans("DolibarrStateBoard").'" class="noborder" width="100%">'; $boxstat.='<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="noborder boxtable" width="100%">';
print '<tr class="liste_titre">'; $boxstat.='<tr class="liste_titre">';
print '<th class="liste_titre">'.$langs->trans("DolibarrStateBoard").'</th>'; $boxstat.='<th class="liste_titre">'.$langs->trans("DolibarrStateBoard").'</th>';
print '</tr>'; $boxstat.='</tr>';
print '<tr class="impair"><td class="tdboxstats nohover">'; $boxstat.='<tr class="impair"><td class="tdboxstats nohover">';
$var=true; $var=true;
@ -292,19 +295,21 @@ if (empty($user->societe_id))
$var=!$var; $var=!$var;
if (!empty($langfile[$key])) $langs->load($langfile[$key]); if (!empty($langfile[$key])) $langs->load($langfile[$key]);
$text=$langs->trans($titres[$key]); $text=$langs->trans($titres[$key]);
print '<a href="'.$links[$key].'" class="boxstatsindicator thumbstat nobold nounderline">'; $boxstat.='<a href="'.$links[$key].'" class="boxstatsindicator thumbstat nobold nounderline">';
print '<div class="boxstats">'; $boxstat.='<div class="boxstats">';
print '<span class="boxstatstext">'.img_object("",$icons[$key]).' '.$text.'</span><br>'; $boxstat.='<span class="boxstatstext">'.img_object("",$icons[$key]).' '.$text.'</span><br>';
print '<span class="boxstatsindicator">'.$board->nb[$val].'</span>'; $boxstat.='<span class="boxstatsindicator">'.$board->nb[$val].'</span>';
print '</div>'; $boxstat.='</div>';
print '</a>'; $boxstat.='</a>';
} }
} }
} }
print '</td></tr>'; $boxstat.='</td></tr>';
print '</table>'; $boxstat.='</table>';
$boxstat.='</div>';
} }
print $boxstat;
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">'; print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
@ -317,21 +322,18 @@ $showweather=empty($conf->global->MAIN_DISABLE_METEO)?1:0;
//Array that contains all WorkboardResponse classes to process them //Array that contains all WorkboardResponse classes to process them
$dashboardlines=array(); $dashboardlines=array();
print '<table class="noborder" width="100%">'."\n"; $boxwork='';
print '<tr class="liste_titre">'; $boxwork.='<table summary="'.dol_escape_htmltag($langs->trans("WorkingBoard")).'" class="noborder boxtable" width="100%">'."\n";
print '<th class="liste_titre" colspan="2">'.$langs->trans("DolibarrWorkBoard").'</th>'; $boxwork.='<tr class="liste_titre">';
print '<th class="liste_titre" align="right">'.$langs->trans("Number").'</th>'; $boxwork.='<th class="liste_titre" colspan="2">'.$langs->trans("DolibarrWorkBoard").'</th>';
print '<th class="liste_titre" align="right">'.$form->textwithpicto($langs->trans("Late"),$langs->trans("LateDesc")).'</th>'; $boxwork.='<th class="liste_titre" align="right">'.$langs->trans("Number").'</th>';
print '<th class="liste_titre">&nbsp;</th>'; $boxwork.='<th class="liste_titre" align="right">'.$form->textwithpicto($langs->trans("Late"),$langs->trans("LateDesc")).'</th>';
$boxwork.='<th class="liste_titre">&nbsp;</th>';
//print '<th class="liste_titre" width="20">&nbsp;</th>'; //print '<th class="liste_titre" width="20">&nbsp;</th>';
if ($showweather) print '<th class="liste_titre hideonsmartphone" width="80">&nbsp;</th>'; if ($showweather) $boxwork.='<th class="liste_titre hideonsmartphone" width="80">&nbsp;</th>';
print '</tr>'."\n"; $boxwork.='</tr>'."\n";
//
// Do not include sections without management permission // Do not include sections without management permission
//
require DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php'; require DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php';
// Number of actions to do (late) // Number of actions to do (late)
@ -357,7 +359,6 @@ if (! empty($conf->projet->enabled) && empty($conf->global->PROJECT_HIDE_TASKS)
{ {
include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
$board=new Task($db); $board=new Task($db);
$dashboardlines[] = $board->load_board($user); $dashboardlines[] = $board->load_board($user);
} }
@ -367,7 +368,6 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$board=new Propal($db); $board=new Propal($db);
$dashboardlines[] = $board->load_board($user,"opened"); $dashboardlines[] = $board->load_board($user,"opened");
// Number of commercial proposals CLOSED signed (billed) // Number of commercial proposals CLOSED signed (billed)
$dashboardlines[] = $board->load_board($user,"signed"); $dashboardlines[] = $board->load_board($user,"signed");
} }
@ -377,7 +377,6 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
{ {
include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$board=new Commande($db); $board=new Commande($db);
$dashboardlines[] = $board->load_board($user); $dashboardlines[] = $board->load_board($user);
} }
@ -386,7 +385,6 @@ if (! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->comma
{ {
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
$board=new CommandeFournisseur($db); $board=new CommandeFournisseur($db);
$dashboardlines[] = $board->load_board($user); $dashboardlines[] = $board->load_board($user);
} }
@ -396,7 +394,6 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
$board=new Contrat($db); $board=new Contrat($db);
$dashboardlines[] = $board->load_board($user,"inactives"); $dashboardlines[] = $board->load_board($user,"inactives");
// Number of active services (expired) // Number of active services (expired)
$dashboardlines[] = $board->load_board($user,"expired"); $dashboardlines[] = $board->load_board($user,"expired");
} }
@ -445,7 +442,6 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->appr
{ {
include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$board=new ExpenseReport($db); $board=new ExpenseReport($db);
$dashboardlines[] = $board->load_board($user,'toapprove'); $dashboardlines[] = $board->load_board($user,'toapprove');
} }
@ -454,7 +450,6 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->to_p
{ {
include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$board=new ExpenseReport($db); $board=new ExpenseReport($db);
$dashboardlines[] = $board->load_board($user,'topay'); $dashboardlines[] = $board->load_board($user,'topay');
} }
@ -483,55 +478,76 @@ foreach($valid_dashboardlines as $board)
foreach($valid_dashboardlines as $board) foreach($valid_dashboardlines as $board)
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td width="16">'.$board->img.'</td><td>'.$board->label.'</td>'; $boxwork.= '<tr '.$bc[$var].'><td width="16">'.$board->img.'</td><td>'.$board->label.'</td>';
print '<td align="right"><a class="dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator">'.$board->nbtodo.'</span></a></td>'; $boxwork.= '<td align="right"><a class="dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator">'.$board->nbtodo.'</span></a></td>';
print '<td align="right">'; $boxwork.= '<td align="right">';
//if ($board->nbtodolate > 0) //if ($board->nbtodolate > 0)
//{ //{
$textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days"); $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days");
print '<a title="'.dol_escape_htmltag($textlate).'" class="dashboardlineindicatorlate'.($board->nbtodolate>0?' dashboardlineko':' dashboardlineok').'" href="'.$board->url.'"><span class="dashboardlineindicatorlate'.($board->nbtodolate>0?' dashboardlineko':' dashboardlineok').'">'; $boxwork.= '<a title="'.dol_escape_htmltag($textlate).'" class="dashboardlineindicatorlate'.($board->nbtodolate>0?' dashboardlineko':' dashboardlineok').'" href="'.$board->url.'"><span class="dashboardlineindicatorlate'.($board->nbtodolate>0?' dashboardlineko':' dashboardlineok').'">';
print $board->nbtodolate; $boxwork.= $board->nbtodolate;
print '</span></a>'; $boxwork.= '</span></a>';
//} //}
print '</td>'; $boxwork.='</td>';
print '<td align="left">'; $boxwork.='<td align="left">';
if ($board->nbtodolate > 0) print img_picto($langs->trans("NActionsLate",$board->nbtodolate).' (>'.ceil($board->warning_delay).' '.$langs->trans("days").')',"warning"); if ($board->nbtodolate > 0) $boxwork.=img_picto($langs->trans("NActionsLate",$board->nbtodolate).' (>'.ceil($board->warning_delay).' '.$langs->trans("days").')',"warning");
else print '&nbsp;'; else $boxwork.='&nbsp;';
print '</td>'; $boxwork.='</td>';
/*print '<td class="nowrap" align="right">'; /*print '<td class="nowrap" align="right">';
print ' (>'.ceil($board->warning_delay).' '.$langs->trans("days").')'; print ' (>'.ceil($board->warning_delay).' '.$langs->trans("days").')';
print '</td>';*/ print '</td>';*/
if ($showweather) if ($showweather)
{ {
print '<td class="nohover hideonsmartphone" rowspan="'.$rowspan.'" width="80" style="border-left: 1px solid #DDDDDD" align="center">'; $boxwork.='<td class="nohover hideonsmartphone" rowspan="'.$rowspan.'" width="80" style="border-left: 1px solid #DDDDDD" align="center">';
$text=''; $text='';
if ($totallate > 0) $text=$langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",$totallate).')'; if ($totallate > 0) $text=$langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",$totallate).')';
$options='height="64px"'; $options='height="64px"';
if ($rowspan <= 2) $options='height="24"'; // Weather logo is smaller if dashboard has few elements if ($rowspan <= 2) $options='height="24"'; // Weather logo is smaller if dashboard has few elements
else if ($rowspan <= 3) $options='height="48"'; // Weather logo is smaller if dashboard has few elements else if ($rowspan <= 3) $options='height="48"'; // Weather logo is smaller if dashboard has few elements
print showWeather($totallate,$text,$options); $boxwork.=showWeather($totallate,$text,$options);
print '</td>'; $boxwork.='</td>';
$showweather=0; $showweather=0;
} }
print '</tr>'; $boxwork.='</tr>';
print "\n"; $boxwork.="\n";
} }
$boxwork.='</table>'; // End table array of working board
print '</table>'; // End table array print $boxwork;
print '</div></div></div><div class="clearboth"></div>';
print '<div class="fichecenter fichecenterbis">';
print '</div></div></div><div class="clearboth"></div><div class="fichecenter fichecenterbis">';
/* /*
* Show boxes * Show boxes
*/ */
print $resultboxes['boxlist']; $boxlist.='<table width="100%" class="notopnoleftnoright">';
$boxlist.='<tr><td class="notopnoleftnoright">'."\n";
$boxlist.='<div class="fichehalfleft">';
$boxlist.=$resultboxes['boxlista'];
$boxlist.= '</div><div class="fichehalfright"><div class="ficheaddleft">';
$boxlist.=$resultboxes['boxlistb'];
$boxlist.= '</div></div>';
$boxlist.= "\n";
$boxlist.= "</td></tr>";
$boxlist.= "</table>";
print $boxlist;
print '</div>'; print '</div>';
/* /*
* Show security warnings * Show security warnings
*/ */