<?php
/**
 * @package linea21.modules
 * @subpackage workshop
 * @author linea21 <info@linea21.com>
 * @version $id SVN
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */

//////////// Check Inclusion de pages //////////// 
if (!function_exists('AuthenthificationProcess')){ 
include_once("../lib/lib_common.php");
ReloadIndex('admin');
}
////////////

if (isset($_POST['id'])) $id = $_POST['id'];
if (isset($_GET['id'])) $id = $_GET['id'];

include_once("../lib/lib_common.php");
$req_det = SQL_getoneCompleteWorkshop($id);
$result = $sql_object -> DBSelect($req_det);
if (count($result) > 1) exit();

$link_det = $rub_link . "&amp;todo=det&amp;id=";
$link_sup = $rub_link . "&amp;todo=sup&amp;id=";
$link_mod = $rub_link . "&amp;todo=mod&amp;id=";
$link_det_u = "index.php?rub=user&amp;todo=det&amp;id=";
$link_sup_u = $rub_link . "&amp;todo=sup_u&amp;id=";
$link_add_cal = $rub_link . "&amp;todo=add_cal&amp;id=";
$link_mod_cal = $rub_link . "&amp;todo=mod_cal&amp;id=";
$link_sup_cal = $rub_link . "&amp;todo=sup_cal&amp;id=";
$link_list_cal = $rub_link . "&amp;todo=list_cal&amp;id=";

$workshop_denomination = formatText($result[0]['workshop_denomination'], '2HTML');
$workshop_resume = formatText($result[0]['workshop_resume'], '2HTML');

if (empty($result[0]['workshop_comment'])) $workshop_comment = $GLOBALS['lang']['divers']['none'];
else $workshop_comment = formatText($result[0]['workshop_comment'], '2HTML');

$theme_denomination = formatText($result[0]['theme_name'], '2HTML');
$level_denomination = formatText($result[0]['level_name'], '2HTML');
$workshop_statut = display_statut($result[0]['workshop_statut']);
$display_date_crea = $result[0]['workshop_date_crea_display'];
$display_last_modify = $result[0]['workshop_last_modify_display'];

$req_list_cal = SQL_getoneListCalWorkshop($id);
$result_cal = $sql_object -> DBSelect($req_list_cal);

$reca_task = '';
$datenow= strtotime("now");
$inter=1*24*3600; 
$j=0;
$reca_task = "<br class=\"brendstep\" /><br class=\"brendstep\" />";
if ($result_cal<>0) {
for($i = 0; $i < count($result_cal); $i++) {

$datetask=$result_cal[$i]['workcal_task_date_display'];
$datetask=explode("-", $datetask);
$jour = $datetask[0];
$mois = $datetask[1];
$annee = $datetask[2];
$datetask2 = mktime (0, 0, 0, $mois, $jour, $annee);
	
if (($datetask2+$inter)>$datenow){
    $reca_task .= "\n<div class=\"task\">\n";
    $reca_task .= "<span class=\"date_task\">" . $result_cal[$i]['workcal_task_date_display'] . "</span>\n";
    $reca_task .= "<span class=\"titre_task\">" . formatText($result_cal[$i]['workcal_task'], '2HTML') . "</span>\n";
	if (WorkshopAuth_id (GetSessionElement('id'), $sql_object, $id)==true || IsSuperAdmin()){
	$reca_task .= "<a href=\"" . $link_sup_cal . $id . "&amp;task_id=".$result_cal[$i]['workcal_id']."\" title=\"" . $GLOBALS['lang']['workshop']['sup_cal'] . "\" class=\"ico_sup2\"></a>";
	$reca_task .= "<a href=\"" . $link_mod_cal . $id . "&amp;task_id=".$result_cal[$i]['workcal_id']."\" title=\"" . $GLOBALS['lang']['workshop']['mod_cal'] . "\" class=\"ico_mod2\"></a>";
    }
	$reca_task .= "<br class=\"brendstep\" /><p class=\"text_task\">" . linkin_content(formatText($result_cal[$i]['workcal_task_details'], '2HTML')) . "</p></div>\n";
	$reca_task .= "<br class=\"brendstep\" />";
	if (IsSuperAdmin())
	$reca_task .= "<a href=\"" . $link_det_u.$result_cal[$i]['workcal_posted_by']."\" title=\"" . $GLOBALS['lang']['workshop']['com_author'] . "\" class=\"auth_task\">". formatText($result_cal[$i]['user_login'], '2HTML') . "</a>\n";	
	else $reca_task .= "<span class=\"auth_task\">". formatText($result_cal[$i]['user_login'], '2HTML') . "</span>\n";	
	
}
else {
if ($j==0) {
  $reca_task .= "<br class=\"brendstep\" />";
}
 	$reca_task .= "\n<div class=\"task\" id=\"task_out\">\n";
    $reca_task .= "<span class=\"date_task\" id=\"date_task_out\">" . $result_cal[$i]['workcal_task_date_display'] . "</span>\n";
    $reca_task .= "<span class=\"titre_task\" id=\"titre_task_out\">" . formatText($result_cal[$i]['workcal_task'], '2HTML') . "</span>\n";	
	if (WorkshopAuth_id (GetSessionElement('id'), $sql_object, $id)==true || IsSuperAdmin()){
	$reca_task .= "<a href=\"" . $link_sup_cal . $id . "&amp;task_id=".$result_cal[$i]['workcal_id']."\" title=\"" . $GLOBALS['lang']['workshop']['sup_cal'] . "\" class=\"ico_sup2\"></a>";
    $reca_task .= "<a href=\"" . $link_mod_cal . $id . "&amp;task_id=".$result_cal[$i]['workcal_id']."\" title=\"" . $GLOBALS['lang']['workshop']['mod_cal'] . "\" class=\"ico_mod2\"></a>";
    }
	$reca_task .= "<br class=\"brendstep\" /><p class=\"text_task\" id=\"text_task_out\" style=\"color:#AAAAAA;\">" . linkin_content(formatText($result_cal[$i]['workcal_task_details'], '2HTML')) . "</p></div>\n";
	$reca_task .= "<br class=\"brendstep\" />";
	if (IsSuperAdmin())
	$reca_task .= "<a href=\"" . $link_det_u.$result_cal[$i]['workcal_posted_by']."\" title=\"" . $GLOBALS['lang']['workshop']['com_author'] . "\" class=\"auth_task\">". formatText($result_cal[$i]['user_login'], '2HTML') . "</a>\n";	
	else $reca_task .= "<span class=\"auth_task\">". formatText($result_cal[$i]['user_login'], '2HTML') . "</span>\n";
	$j++;
}
} 
}
else {
$reca_task="<div class=\"info\">".$GLOBALS['lang']['workshop']['no_cal']."</div>";
}
?>
<div id="chemin">
	<ul>
		<li>
			<a href="index.php"><?php echo $GLOBALS['lang']['way']['home'];
?></a>
		</li>
		<li>
			<a href="<?php echo $rub_link;
?>"><?php echo $GLOBALS['lang']['menu']['workshop'];
?></a>
		</li>
		<li>
			<span><?php echo formatnavTitle($GLOBALS['lang']['workshop']['list_cal'] . " : " . $workshop_denomination);
?></span>
		</li>
	</ul>
</div>
  <!--end barre haute -->
<?php
include_once("quickicons.php");

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

?>
<div id="content">
<?php afflinkbar($todo,$id, $lang); ?>
		<?php
echo "<h2>" . $GLOBALS['lang']['workshop']['list_cal'] . " : " . $workshop_denomination . "</h2>\n";
if (WorkshopAuth_id (GetSessionElement('id'), $sql_object, $id)==true || IsSuperAdmin())
echo "<a href=\"".$link_add_cal.$id."\" title=\"".$GLOBALS['lang']['workshop']['add_cal']."\" class=\"ico_add2\"></a><br class=\"brendstep\" />";
?>

<?php echo $reca_task;
?>
<br class="brendstep" />
</div>
<?php include_once($dir . "/help.php");
?>
</div>
