<?php 
# ************** LICENCE ****************
/*
	Copyright (c) PORTANEO.
*/
# ***************************************
# Display user groups
#
# !! be careful, this file must be saved under uft8 format, and display an e accentuated here : é
# ***************************************
$not_access=1;
$granted="I";

$page = (isset($_GET['page']))      ?       $_GET['page']       :       0;

require_once('includes_mobile.php');
require_once('../../../../db_layer/'.__DBTYPE.'/portal.php');
require_once('../includes/template.inc.php');
require_once('../../../../db_layer/'.__DBTYPE.'/enterprise.php');

$selectedTab = '';
$previousStr = '';
$nextStr = '';

if (isset($_GET['tab']) && !empty($_GET['tab'])) {
	$selectedTab = $_GET['tab'];
}

$options = defineHeader();
    
echo page_begining();

echo '<div id="header">';
    echo generate_header($options);
echo '</div>';

echo '<div id="wrapper">';
echo '<div id="page">';		

echo '<div class="page_title"><span>'.lg('mygroups').'</span></div>';

//select groups
$DB->getResults($mobGetUserWorkingGroups,$DB->escape($_SESSION['user_id']),$DB->escape($page));
$nbRes = $DB->nbResults();
if ($nbRes == 0) {
	echo generate_warning('info',''.lg("noGroupForMe").'','','');
    echo "</div>";
    echo "</div>";
	echo generate_footer("group");
	exit();
}
$inc = 0;
while ( ($row = $DB->fetch(0)) && $inc<10 ) {
    $description = $row['description'];
    $group_id = $row['id'];
    if (strlen($description)>75) {
        $description = formatString($description,75).'...';
    }
	echo '
		  <a href="groupbook.php?id='.$group_id.'" style="text-decoration:none;">
           <div class="users">
			<div class="title">
                <span><img src="../../../'.displayPicture($row['picture']).'" class="avatar" width="50" height="50" style="float: left;margin-right: 5px;"></span>
                <span>'.$row['name'].'</span>
			</div>';
            if ($row['description']!='') echo '<div class="subtitle"><span>'.$description.'</span></div>';
	echo ' </div>
          </a>';
    $inc++;
}
$DB->freeResults();
          
if ($page!=0) {
	$previousStr = '<a href="group.php?page='.($page-10).'">'.lg("page_back").'</a>';
}
if ($nbRes == 11) {
	$nextStr = '<a href="group.php?page='.($page+10).'">'.lg("page_next").'</a>';
}
		
echo '<center><div>'.$previousStr.' &nbsp;&nbsp; '.$nextStr.'</div></center>'; 

echo "</div>";
echo "</div>";

echo generate_footer("group");
?>