<?php
/**
 * @package linea21.core
 * @subpackage home
 * @author linea21 <info@linea21.com>
 * @version $id SVN
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 * 'Home' module is used into the back-office
 */

//////////// Check Inclusion de pages ////////////
if (!function_exists('AuthenthificationProcess')){
  include_once("../lib/lib_common.php");
  ReloadIndex('admin');
}
////////////
if (isset($_COOKIE['linea21_lastcon'])) $date = date("Y-m-d", $_COOKIE['linea21_lastcon']);
$result_yp = $sql_object -> DBSelect($req_yp);
if ($result_yp[0]['yellowp_id']=="") $nb_yp=0;
else $nb_yp = count($result_yp);
$link_yp = "index.php?rub=yellowpages&amp;todo=det&amp;id=";
$liste_yp = '';

if ($nb_yp<>0) {
  for ($i = 0;$i < count($result_yp);$i++) {
    $liste_yp .= "\t<li class=\"li2\"><a href=\"" . $link_yp . $result_yp[$i]['yellowp_id'] . "&amp;id=" . $result_yp[$i]['yellowp_id'] . "\" title=\"" . formatText($result_yp[$i]['yellowp_name'], '2ATT') . "\">" . formatText($result_yp[$i]['yellowp_name'], '2HTML') . "</a></li>\n\n";
  }
}else   $liste_yp .= "\t<li><div class=\"info\">" ._t('home','noupdate'). "</div></li>\n\n";



$result_sdi = $sql_object -> DBSelect($req_sdi);
if ($result_sdi[0]['sdii_id']=="") $nb_dashboard=0;
else $nb_dashboard = count($result_sdi);
$liste_dashboard = '';
$link_dashboard = "index.php?rub=dashboard&amp;todo=det&amp;id=";
if ($nb_dashboard<>0) {
  for ($i = 0;$i < count($result_sdi);$i++) {
    $liste_dashboard .= "\t<li class=\"li2\"><a href=\"" . $link_dashboard . $result_sdi[$i]['sdii_id'] . "&amp;scale_id=" . $result_sdi[$i]['scale_id'] . "\" title=\"" . formatText($result_sdi[$i]['sdii_name'], '2ATT') . "\">" . formatText($result_sdi[$i]['sdii_name'], '2HTML') . "</a> <span class=\"scale\">   (" . formatText($result_sdi[$i]['scale_denomination'], '2HTML') . ") </span></li>\n\n";
  }
}else   $liste_dashboard .= "\t<li><div class=\"info\">" ._t('home','noupdate'). "</div></li>\n\n";

if (isset($_COOKIE['linea21_lastcon'])){
  $req_user = SQL_getUser($date);
  $resultu = $sql_object -> DBSelect($req_user);
  if ($resultu[0]['user_id']=="") $nb_user=0;
  else $nb_user = count($resultu);
  $liste_user = '';
  $link_user = "index.php?rub=user&amp;todo=det&amp;id=";
  if ($nb_user<>0) {
    for ($i = 0;$i < count($resultu);$i++) {
      $liste_user .= "\t<li class=\"li2\"><a href=\"" . $link_user . $resultu[$i]['user_id'] . "\" title=\"" . formatText($resultu[$i]['user_login'], '2ATT') . "\">" . formatText($resultu[$i]['user_login'], '2HTML') . "</a></li>\n\n";
    }
  }else   $liste_user .= "\t<li><div class=\"info\">" ._t('home','noupdate'). "</div></li>\n\n";
}

$result_news = $sql_object -> DBSelect($req_news);
$liste_news = '';
if ($result_news[0]['news_id']=="") $nb_news=0;
else $nb_news = count($result_news);
$link_news = "index.php?rub=news&amp;todo=det&amp;id=";
if ($nb_news<>0) {
  for ($i = 0;$i < count($result_news);$i++) {
    $liste_news .= "\t<li class=\"li2\"><a href=\"" . $link_news . $result_news[$i]['news_id'] . "\" title=\"" . formatText($result_news[$i]['news_title'], '2ATT') . "\">" . formatText($result_news[$i]['news_title'], '2HTML') . "</a></li>\n\n";
  }
} else   $liste_news .= "\t<li><div class=\"info\">" ._t('home','noresult'). "</div></li>\n\n";


$result_publi = $sql_object -> DBSelect($req_publi);
$link_publi = "index.php?rub=publication&amp;todo=det&amp;id=";
if ($result_publi[0]['publi_id']=="") $nb_publi=0;
else $nb_publi = count($result_publi);
if ($nb_publi<>0) $liste_publi = "\t<li class=\"li2\"><a href=\"" . $link_publi . $result_publi[0]['publi_id'] . "\" title=\"" . formatText($result_publi[0]['publi_title'], '2HTML') . "\">" . formatText($result_publi[0]['publi_title'], '2HTML') . "</a></li>\n\n";
else  $liste_publi = "\t<li><div class=\"info\">" ._t('home','noresult'). "</div></li>\n\n";

$result_rep = $sql_object -> DBSelect($req_rep);
if ($result_rep[0]['workrep_id']=="") $nb_rep=0;
else $nb_rep = count($result_rep);
$link_rep = "index.php?rub=workshoprep&amp;todo=det&amp;id=";
if ($nb_rep<>0) $liste_rep = "\t<li class=\"li2\"><a href=\"" . $link_rep . $result_rep[0]['workrep_id'] . "\" title=\"" . formatText($result_rep[0]['workrep_title'], '2ATT') . "\">" . formatText($result_rep[0]['workrep_title'], '2HTML') . "</a></li>\n\n";
else  $liste_rep = "\t<li><div class=\"info\">" ._t('home','noresult'). "</div></li>\n\n";

$rProjects = $sql_object->DBSelect(SQL_getProjects(), 'OBJECT');
$lProjects = '';
if ($rProjects == 0) $nbProjects=0;
else $nbProjects = count($rProjects);
$link_projects = "index.php?rub=project&amp;todo=det&amp;id=";
if ($nbProjects > 0) {
  for ($i = 0;$i < count($rProjects);$i++) {
    $lProjects .= "\t<li class=\"li2\"><a href=\"" . $link_projects . $rProjects[$i]->project_id . "\" title=\"" . formatText($rProjects[$i]->project_name, '2ATT') . "\">" . formatText($rProjects[$i]->project_name, '2HTML') .' ('. $rProjects[$i]->project_estimated_date_display . ")</a></li>\n\n";
  }
} else   $lProjects .= "\t<li><div class=\"info\">" ._t('home','noresult'). "</div></li>\n\n";


?>
<div id="chemin">
<ul>
	<li><a href="index.php" class="chemin_home"><?php echo _t('way','home') ?></a>
	</li>
</ul>
</div>
<!--end barre haute -->
<?php
include_once(THEME_ADMIN_PATH."quickicons.php");

?>
<div class="contentcontainer"><?php include_once($dir . "/menurub.php");

?>
<div id="content"><?php
$listing = '';
$listing .= "<div class=\"scale\">" . _t('home','accueil') . ": <a href=\"mailto:".MAIL_LINEA."\" title=\"".MAIL_LINEA."\">".MAIL_LINEA."</a></div>";
$listing .= "<h2>" . _t('home','resume') . "</h2><br class=\"brendstep\" />";

if (HaveRight('dashboard') && defined('MOD_DASHBOARD') && MOD_DASHBOARD == 1) {
  $listing .= "<div class=\"workshop_det\"><a href=\"#\" onclick=\"$('#general').slideToggle();\">" . $nb_dashboard . " " . _t('home','dashboard') . "</a></div>";
  $listing .= "<div class=\"sdtheme\" id=\"general\" style=\"display:none;\" >\n";
  $listing .= "<ul>\n";
  $listing .= $liste_dashboard;
  $listing .= "</ul>\n";
  $listing .= "</div>\n";
}

if (IsSuperAdmin() && defined('MOD_PROJECT') && MOD_PROJECT == 1) {
  $listing .= "<div class=\"workshop_det\"><a href=\"#\" onclick=\"$('#projects').slideToggle();\">" . _t('home','project') . "</a></div>";
  $listing .= "<div class=\"sdtheme\" id=\"projects\" style=\"display:none;\" >\n";
  $listing .= "<ul>\n";
  $listing .= $lProjects;
  $listing .= "</ul>\n";
  $listing .= "</div>\n";
}

if (HaveRight('category_user') && defined('MOD_USER') && MOD_USER == 1){
  if (isset($_COOKIE['linea21_lastcon'])){
    $listing .= "<div class=\"workshop_det\"><a href=\"#\" onclick=\"$('#user').slideToggle();\">" . $nb_user . " " . _t('home','user') . "</a></div>";
    $listing .= "<div class=\"sdtheme\" id=\"user\" style=\"display:none;\" >\n";
    $listing .= "<ul>\n";
    $listing .= $liste_user;
    $listing .= "</ul>\n";
    $listing .= "</div>\n";
  }
}
if (IsSuperAdmin() && defined('MOD_WORKSHOP') && MOD_WORKSHOP == 1){
  $listing .= "<div class=\"workshop_det\"><a href=\"#\" onclick=\"$('#yp').slideToggle();\">" . $nb_yp . " " . _t('home','yp') . "</a></div>";
  $listing .= "<div class=\"sdtheme\" id=\"yp\" style=\"display:none;\" >\n";
  $listing .= "<ul>\n";
  $listing .= $liste_yp;
  $listing .= "</ul>\n";
  $listing .= "</div>\n";
}
if (HaveRight('news') && defined('MOD_NEWS') && MOD_NEWS == 1){
  $listing .= "<div class=\"h2sdtheme\"><span>" . _t('home','news') . "</span></div>";
  $listing .= "<div class=\"sdtheme\">\n";
  $listing .= "<ul>\n";
  $listing .= $liste_news;
  $listing .= "</ul>\n";
  $listing .= "</div>\n";
}
if (HaveRight('publication') && defined('MOD_PUBLICATION') && MOD_PUBLICATION == 1) {
  $listing .= "<div class=\"h2sdtheme\"><span>" . _t('home','publi') . "</span></div>";
  $listing .= "<div class=\"sdtheme\">\n";
  $listing .= "<ul>\n";
  $listing .= $liste_publi;
  $listing .= "</ul>\n";
  $listing .= "<div class=\"scale\">" . formatText($result_publi[0]['publi_resume'], '2HTML') . "</div>";
  $listing .= "</div>\n";
}
if (HaveRight('workshop') && defined('MOD_WORKSHOP') && MOD_WORKSHOP == 1){
  $listing .= "<div class=\"h2sdtheme\"><span>" . _t('home','report') . "</span></div>";
  $listing .= "<div class=\"sdtheme\">\n";
  $listing .= "<ul>\n";
  $listing .= $liste_rep;
  $listing .= "</ul>\n";
  $listing .= "<div class=\"scale\">" . formatText($result_rep[0]['workrep_resume'], '2HTML') . "</div>";
  $listing .= "</div>\n";
}

echo $listing;

?></div>
<?php include_once($dir . "/help.php");

?></div>

