<?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
 */

if(isset($_POST['id']))	$id=$_POST['id'];
if(isset($_GET['id']))	$id=$_GET['id'];
//////////// Check Inclusion de pages //////////// 
if (!function_exists('AuthenthificationProcess')){ 
include_once("../lib/lib_common.php");
ReloadIndex('admin');
}
////////////

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

if ($result[0]['workshop_statut']<>'P' && !IsSuperAdmin()){ 
include_once("../lib/lib_common.php");
ReloadIndex('admin');
}

$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_det_theme="index.php?rub=theme&amp;todo=det&amp;id=";
$link_det_level="index.php?rub=level&amp;todo=det&amp;id=";
$link_sup_u=$rub_link."&amp;todo=sup_u&amp;id=";
$link_add_u=$rub_link."&amp;todo=add_u&amp;id=";
$link_list_cal=$rub_link."&amp;todo=list_cal&amp;id=";
$link_list_com=$rub_link."&amp;todo=list_com&amp;id=";
$link_sup_rep="index.php?rub=workshoprep&amp;todo=sup&amp;id=";
$link_mod_rep="index.php?rub=workshoprep&amp;todo=mod&amp;id=";
$link_det_rep="index.php?rub=workshoprep&amp;todo=det&amp;id=";
$link_add_rep="index.php?rub=workshoprep&amp;todo=add&amp;work_id=";

$workshop_denomination=formatText($result[0]['workshop_denomination'], '2HTML');
$workshop_resume=empty_nc(formatText($result[0]['workshop_resume'], '2HTML'));
$workshop_comment=empty_nc(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'];
$workshop_object= new workshop ;

$req_user=SQL_getWorkshopUserList($id);
$result_user = $sql_object -> DBSelect($req_user);

//récupération des organisateurs du workshop
$form_organizer='';
$j=0;
for($i=0; $i<count($result_user); $i++) {
 if ($result_user[$i]['jwu_user_right']=='O' || $result_user[$i]['jwu_user_right']=='A'){
 $j++;
if ($j<>1) $form_organizer.=" ".MAIL_SEPARATOR." ";
$form_organizer.=$result_user[$i]['user_login'];
}
}

// formattage des données

	//prepa affichage des infos générales
	$reca_generals="<dl class=\"dl3\">\n";
	$reca_generals.="<dt  class=\"dl_intitule\">".$GLOBALS['lang']['workshop']['generals']." : </dt>\n";
	$reca_generals.="<dd>&nbsp;<br /></dd>\n";
	$reca_generals.="<dt>".$GLOBALS['lang']['workshop']['title']."</dt>\n";
	$reca_generals.="<dd>". $workshop_denomination."</dd>\n";
	$reca_generals.="<dt>". $GLOBALS['lang']['workshop']['resume']. "</dt>\n";
	$reca_generals.="<dd>".$workshop_resume."</dd>\n";
	$reca_generals.="<dt>".$GLOBALS['lang']['workshop']['theme']." :</dt>\n";
	if (IsSuperAdmin())
	$reca_generals.="<dd><a href=\"".$link_det_theme.$result[0]['workshop_theme']."\" title=\"".$theme_denomination."\">".$theme_denomination."</a></dd>\n";
	else $reca_generals.="<dd>".$theme_denomination."</dd>\n";
	$reca_generals.="<dt>".$GLOBALS['lang']['workshop']['level']." :</dt>\n";
	if (IsSuperAdmin())
	$reca_generals.="<dd><a href=\"".$link_det_level.$result[0]['workshop_level']."\" title=\"".$level_denomination."\">".$level_denomination."</a></dd>\n";
	
	else $reca_generals.="<dd>".$level_denomination."</dd>\n";
	
	$reca_generals.="<dt>".$GLOBALS['lang']['divers']['date_crea'] ."</dt>\n";
	$reca_generals.="<dd>". $display_date_crea. "</dd>\n";
	$reca_generals.="<dt>".$GLOBALS['lang']['divers']['last_modify'] ."</dt>\n";
	$reca_generals.="<dd>". $display_last_modify. "</dd>\n";
	$reca_generals.="<dt>".$GLOBALS['lang']['divers']['statut']." :</dt>\n";
	$reca_generals.="<dd>". $workshop_statut. "</dd>\n";
	$reca_generals.="<dt>".$GLOBALS['lang']['workshop']['comment']." :</dt>\n";
	$reca_generals.="<dd>". $workshop_comment. "</dd>\n";
	$reca_generals.="<dt>".$GLOBALS['lang']['workshop']['organizer']." :</dt>\n";
	$reca_generals.="<dd>". $form_organizer. "</dd>\n";
	$reca_generals.="</dl>\n";
	
	
	// Récuperation des différentes parties
	
	//prepa affichage des utilisateurs du workgroup
	
	if($result_user==false) $contents_user="<div class=\"info\">".$GLOBALS['lang']['workshop']['no_user']."</div>";
	else {
			$contents_user= "<table cellspacing=\"0\" cellpadding=\"3\" class=\"table2\">\n";
		    $contents_user.="<thead>\n";
			$contents_user.="<tr>\n"; 
			$contents_user.="<td>".$GLOBALS['lang']['workshop']['user']."</td>\n";
			$contents_user.="<td> <span class=\"semnone\">".$GLOBALS['lang']['divers']['actions']."</span></td>\n";
			$contents_user.="</tr>\n";
			$contents_user.="</thead>\n";
			$contents_user.="<tbody>\n";	
			$mailing_list='';
			
			
			for($i=0; $i<count($result_user); $i++) {
			
	$contents_user.="<tr>\n";
	$contents_user.="<td>";
	if (IsSuperAdmin())
	$contents_user.="<a href=\"".$link_det_u.$result_user[$i]['jwu_user_id']."\" title=\"".formatText($GLOBALS['lang']['workshop']['user'], '2HTML')."\">".formatText($result_user[$i]['user_login'], '2HTML')."</a>\n";
    else 
	$contents_user.="<span>".formatText($result_user[$i]['user_login'], '2HTML')."</span>";
	if ($result_user[$i]['jwu_user_right']=='O' || $result_user[$i]['jwu_user_right']=='A')
	$contents_user.="<span class=\"text_det_it\">(".display_statut($result_user[$i]['jwu_user_right']).")</span> ";
	$contents_user.="</td>\n";
	if (WorkshopAuth_id(GetSessionElement('id'), $sql_object, $id)==true || IsSuperAdmin()){
	$contents_user.="<td><div class=\"iconetab\">";
	if ($result_user[$i]['jwu_user_right']<>'O')
	$contents_user.="<a href=\"".$link_sup_u.$id."&amp;u_id=".$result_user[$i]['jwu_user_id']."\" title=\"".$GLOBALS['lang']['workshop']['del_user']."\" class=\"ico_sup\"></a>\n";
	else if (IsSuperAdmin())
	$contents_user.="<a href=\"".$link_sup_u.$id."&amp;u_id=".$result_user[$i]['jwu_user_id']."\" title=\"".$GLOBALS['lang']['workshop']['del_user']."\" class=\"ico_sup\"></a>\n";
	$contents_user.="<a href=\"mailto:".$result_user[$i]['profile_email']."\" title=\"".$result_user[$i]['profile_email']."\" class=\"ico_mail\"></a></div></td>";
	}
	else $contents_user.="<td>&nbsp;</td>\n";
	$contents_user.="</tr>\n";
	$mailing_list.=$result_user[$i]['profile_email'].MAIL_SEPARATOR."%20";
			}
			$contents_user.="</tbody>";
$contents_user.="</table>";
	}
	
	$reca_user ="<br class=\"brendstep\" />\n";
	$reca_user.="<div class=\"workshop_det\">\n";
	$reca_user.="<a name=\"workshopuser\" id=\"workshopuser\" href=\"#workshopuser\" onclick=\"$('#workshop_user').slideToggle();\">".$GLOBALS['lang']['workshop']['user']."</a>\n";
	$reca_user.="</div>\n";
	$reca_user.="<div id=\"workshop_user\" style=\"display:none;\" >\n";
	if (WorkshopAuth_id (GetSessionElement('id'), $sql_object, $id)==true || IsSuperAdmin())
	$reca_user.="<a href=\"".$link_add_u.$id."\" title=\"".$GLOBALS['lang']['workshop']['add_new_user']."\" class=\"ico_add2\"></a><br class=\"brendstep\" />"; 	
	$reca_user.=$contents_user;
	if (WorkshopAuth_id (GetSessionElement('id'), $sql_object, $id)==true || IsSuperAdmin())
	$reca_user.="<div class=\"mailing_list\"><a href=\"mailto:".$mailing_list."\" title=\"".$GLOBALS['lang']['workshop']['mailing_list']."\"> <img src=\"../gfx/" .THEME_ADMIN. "/images/admin/ico_mail2.gif\" alt=\"".$GLOBALS['lang']['workshop']['mailing_list']."\" /> &nbsp;".$GLOBALS['lang']['workshop']['mailing_list']."</a></div>";
	$reca_user.="</div>\n";
	$reca_user.="<br class=\"brendstep\" />\n";
	
	//prepa affichage des rapports d'un workgroup
	
	$req_workshop_report= SQL_getWorkshopReportList($id);
$result_report=$sql_object->DBSelect($req_workshop_report);
	
	//$workshop_report_object= new workshop_report ;

	$link_res_sup="?rub=resources&amp;todo=sup&amp;id=&amp;parent=".$id."&amp;type=P&amp;id=";
	$link_mod=$rub_link."&amp;todo=mod&amp;id=";
	
	if($result_report==0) {
		$contents_report="<div class=\"info\">".$GLOBALS['lang']['workshop']['no_report']."</div>";
	} else {
			$contents_report= "<table cellspacing=\"0\" cellpadding=\"3\" class=\"table2\">\n";
			$contents_report.="<thead>\n";
			$contents_report.="<tr>\n"; 
			$contents_report.="<td>".$GLOBALS['lang']['workshop']['title_report']."</td>\n";
			$contents_report.="<td>".$GLOBALS['lang']['divers']['statut']."</td>\n";
			$contents_report.="<td>".$GLOBALS['lang']['divers']['date_crea']."</td>\n";
			$contents_report.="<td> <span class=\"semnone\">".$GLOBALS['lang']['divers']['actions']."</span></td>\n";
			$contents_report.="</tr>\n";
			$contents_report.="</thead>\n";
			$contents_report.="<tbody>\n";	
	
			for($i=0; $i<count($result_report); $i++) {
	
	$workshop_report_title=formatText(cutText($result_report[$i]['workrep_title'], 60, 1), '2HTML'); 
	
	$contents_report.="<tr>\n";
	$contents_report.="<td width=\"50%\"><a href=\"".$link_det_rep.$result_report[$i]['workrep_id']."\" title=\"".$workshop_report_title."\">".$workshop_report_title."</a></td>\n";
	$contents_report.="<td>".display_statut($result_report[$i]['workrep_statut'])."</td>\n";
	$contents_report.="<td>".$result_report[$i]['workrep_date_crea_display']."</td>\n";
	if (WorkshopAuth_id (GetSessionElement('id'), $sql_object, $id)==true || IsSuperAdmin()){
	$contents_report.="<td><div class=\"iconetab\"><a href=\"".$link_sup_rep.$result_report[$i]['workrep_id']."\" title=\"".$GLOBALS['lang']['workshop']['del_report']."\" class=\"ico_sup\"></a>\n";
	$contents_report.="<a href=\"".$link_mod_rep.$result_report[$i]['workrep_id']."\" title=\"".$GLOBALS['lang']['workshop']['mod_report']."\" class=\"ico_mod\"></a></div></td>";
	}
	else $contents_report.="<td>&nbsp;</td>\n";
	$contents_report.="</tr>\n";
}

$contents_report.="</tbody>";
$contents_report.="</table>";
			}
			
	$reca_report='';
	$reca_report.="<div class=\"workshop_det\">\n";
	$reca_report.="<a name=\"resreport\" id=\"resreport\" href=\"#resreport\" onclick=\"$('#res_report').slideToggle();\">".$GLOBALS['lang']['workshop']['report']."</a>\n";
	$reca_report.="</div>\n";
	$reca_report.="<div id=\"res_report\" style=\"display:none;\" >\n";
	if (WorkshopAuth_id (GetSessionElement('id'), $sql_object, $id)==true || IsSuperAdmin())
	$reca_report.="<a href=\"".$link_add_rep.$id."\" title=\"".$GLOBALS['lang']['workshop']['add_new_report']."\" class=\"ico_add2\"></a><br class=\"brendstep\" />"; 		
	$reca_report.=$contents_report;
	$reca_report.="</div>\n";
	$reca_report.="<br class=\"brendstep\" />\n";
	
	$navtitle=$GLOBALS['lang']['workshop']['det']." : ".$workshop_denomination;
?>
<div id="chemin">
	<ul>
		<li>
			<a href="index.php"><? echo $GLOBALS['lang']['way']['home']; ?></a>
		</li>
		<li>
			<a href="<?php echo $rub_link; ?>"><? echo $GLOBALS['lang']['menu']['workshop'];?></a>
		</li>
		<li>
			<span><? echo formatnavTitle($navtitle); ?></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); 
		echo "<h2>".formatTitleh2($workshop_denomination)."</h2>\n";
		if (IsSuperAdmin()){
		echo "<a href=\"".$link_sup.$id."\" title=\"".$GLOBALS['lang']['workshop']['sup']."\" class=\"ico_sup2\"></a>";
		echo "<a href=\"".$link_mod.$id."\" title=\"".$GLOBALS['lang']['workshop']['mod']."\" class=\"ico_mod2\"></a><br class=\"brendstep\" />"; 		 		
		}
		echo $reca_generals;
		echo $reca_user;
		echo $reca_report;
?>

		
		

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