<?php
/**
 * @package linea21.modules
 * @subpackage workshoprep
 * @author linea21 <info@linea21.com>
 * @version $id SVN
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 * 'Workshoprep' (as Workshop Report) module is used by 'Workshop' modules
 */

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

//////////// Check Droits utilisateur ////////////
if (!HaveRight('workshop')) ReloadIndex('admin');
////////////

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

$req_det= SQL_getoneCompleteWorkshopRep($id);
$result=$sql_object->DBSelect($req_det);
if(count($result)>1) exit();

$workrep_title=formatText($result[0]['workrep_title'], '2HTML');
$workrep_resume=formatText($result[0]['workrep_resume'], '2HTML');
$workrep_comment=formatText(empty_none($result[0]['workrep_comment']), '2HTML');
$workrep_statut=display_statut($result[0]['workrep_statut']);
$display_date_crea=$result[0]['workrep_date_crea_display'];
$display_last_modify=$result[0]['workrep_last_modify_display'];
if($result[0]['workrep_published_date_display']=='01-01-0001') $display_published_date=$GLOBALS['lang']['workshoprep']['not_published'];
else $display_published_date=$result[0]['workrep_published_date_display'];
$workrep_workshop_name=formatText($result[0]['workshop_denomination'], '2HTML');
$workshop_title=' ('.$workrep_workshop_name.')';
$work_id=$result[0]['workrep_workshop_id'];

$link_sup=$rub_link."&amp;todo=sup&amp;id=";
$link_mod=$rub_link."&amp;todo=mod&amp;id=";

// formattage des données
include_once('../class/class.resources.php'); 
$resources_object = new resources;


	//prepa affichage des infos générales
	$reca_generals="<dl class=\"dl3\">\n";
	$reca_generals.="<dt  class=\"dl_intitule\">".$GLOBALS['lang']['workshoprep']['generals']." : </dt>\n";
	$reca_generals.="<dd>&nbsp;<br /></dd>\n";
	$reca_generals.="<dt>".$GLOBALS['lang']['workshoprep']['title']."</dt>\n";
	$reca_generals.="<dd>". $workrep_title."</dd>\n";
	$reca_generals.="<dt>". $GLOBALS['lang']['workshoprep']['resume']. "</dt>\n";
	$reca_generals.="<dd>".$workrep_resume."</dd>\n";
	$reca_generals.="<dt>". $GLOBALS['lang']['workshoprep']['workshop_product']. "</dt>\n";
	$reca_generals.="<dd>".$workrep_workshop_name."</dd>\n";
	$reca_generals.="<dt>".$GLOBALS['lang']['workshoprep']['published_on'] ."</dt>\n";
	$reca_generals.="<dd>".$display_published_date. "</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>". $workrep_statut. "</dd>\n";
	$reca_generals.="<dt>".$GLOBALS['lang']['workshoprep']['comment']." :</dt>\n";
	$reca_generals.="<dd>". $workrep_comment. "</dd>\n";
	$reca_generals.="</dl>\n";
	
	
	//prepa affichage des différentes parties du dossier
	$part_link_add="?rub=contents&amp;todo=add&amp;parent=".$id."&amp;type=W";
	$part_link_sup="?rub=contents&amp;todo=sup&amp;parent=".$id."&amp;type=W&amp;id=";
	$part_link_mod="?rub=contents&amp;todo=mod&amp;parent=".$id."&amp;type=W&amp;id=";
	$part_link_det="?rub=contents&amp;todo=det&amp;parent=".$id."&amp;type=W&amp;id=";
	$req_parts=SQL_getWorkshopParts($id);
	$result=$sql_object->DBSelect($req_parts);
	if($result==0) $contents_parts="<div class=\"info\">".$GLOBALS['lang']['workshoprep']['no_part']."</div>";
	else {
			$contents_parts="<ul>\n";
			for($i=0; $i<count($result); $i++) {
				$contents_parts.="<li class=\"li1\">\n";
				$contents_parts.="<a href=\"".$part_link_det.$result[$i]['workrepcon_id']."\" title=\"Détails du thème\">".formatText($result[$i]['workrepcon_title'], '2HTML')."</a>\n";
				$contents_parts.="<span class=\"text_det_it\">(".$GLOBALS['lang']['workshoprep']['part_number']. ($i+1).")</span>";
				if(AuthUser4Workshop($work_id, $sql_object) || IsSuperAdmin()) {
					$contents_parts.="\t<a href=\"".$part_link_sup.$result[$i]['workrepcon_id']."\" class=\"ico_sup\" title=\"".$GLOBALS['lang']['workshoprep']['del_part']."\"></a>\n";
					$contents_parts.="\t<a href=\"".$part_link_mod.$result[$i]['workrepcon_id']."\" class=\"ico_mod\" title=\"".$GLOBALS['lang']['workshoprep']['mod_part']."\"></a>\n";
				}
				$contents_parts.="</li>\n";
			}
			$contents_parts.="</ul>\n";
	}
	
	$reca_parts ="<br class=\"brendstep\" />\n";
	$reca_parts.="<div class=\"publi_det\">\n";
	$reca_parts.="<a name=\"publipart\" id=\"publipart\" href=\"#publipart\" onclick=\"$('#publi_part').slideToggle();\">".$GLOBALS['lang']['workshoprep']['parts']."</a>\n";
	$reca_parts.="</div>\n";
		$reca_parts.="<div id=\"publi_part\" style=\"display:none;\" >\n";
		if(AuthUser4Workshop($work_id, $sql_object) || IsSuperAdmin()) {
			$reca_parts.="\t<a href=\"".$part_link_add."\" class=\"ico_add2\" title=\"".$GLOBALS['lang']['workshoprep']['add_new_part']."\"></a><br class=\"brendstep\" />\n";
		}
		$reca_parts.=$contents_parts;
		$reca_parts.="</div>\n";
	
	$reca_parts.="<br class=\"brendstep\" />\n";
	
	//prepa affichage des ressources LINK associées
	$link_res_add="?rub=resources&amp;todo=add_l&amp;parent=".$id."&amp;type=W";
	$link_res_sup="?rub=resources&amp;todo=sup&amp;parent=".$id."&amp;type=W&amp;res=link&amp;id=";
	$link_res_mod="?rub=resources&amp;todo=mod_l&amp;parent=".$id."&amp;type=W&amp;res=link&amp;id=";
	$result=SQL_GetResources($id, 'WORKSHOP', 'LINK', $sql_object);
	if($result==0) {
		$contents_link="<div class=\"info\">".$GLOBALS['lang']['workshoprep']['no_link']."</div>";
	} else {
			$contents_link="<ul>\n";
			for($i=0; $i<count($result); $i++) {
				$contents_link.="<li class=\"li1\">\n";
				$contents_link.="<a href=\"".$result[$i]['linkres_text']."\" class=\"out\">".formatText($result[$i]['linkres_mask'], '2HTML')."</a>\n";
				if(AuthUser4Workshop($work_id, $sql_object) || IsSuperAdmin()) {
					$contents_link.="\t<a href=\"".$link_res_sup.$result[$i]['linkres_id']."\" class=\"ico_sup\" title=\"".$GLOBALS['lang']['workshoprep']['del_link']."\"></a>\n";
					$contents_link.="\t<a href=\"".$link_res_mod.$result[$i]['linkres_id']."\" class=\"ico_mod\" title=\"".$GLOBALS['lang']['workshoprep']['mod_link']."\"></a>\n";
				}
				$contents_link.="</li>\n";
			}
			$contents_link.="</ul>\n";
	}
	$reca_link='';
	$reca_link.="<div class=\"publi_det\">\n";
	$reca_link.="<a name=\"reslink\" id=\"reslink\" href=\"#reslink\" onclick=\"$('#res_link').slideToggle();\">".$GLOBALS['lang']['workshoprep']['link_res']."</a>\n";
	$reca_link.="</div>\n";
	$reca_link.="<div id=\"res_link\" style=\"display:none;\" >\n";
	if(AuthUser4Workshop($work_id, $sql_object) || IsSuperAdmin()) {
		$reca_link.="\t<a href=\"".$link_res_add."\" class=\"ico_add2\" title=\"".$GLOBALS['lang']['workshoprep']['add_new_linkres']."\"></a><br class=\"brendstep\" />\n";
	}
	$reca_link.=$contents_link;
	$reca_link.="</div>\n";
	$reca_link.="<br class=\"brendstep\" />\n";


		
	//prepa affichage des ressources biblio associés
	$biblio_res_add="?rub=resources&amp;todo=add_b&amp;parent=".$id."&amp;type=W";
	$biblio_res_sup="?rub=resources&amp;todo=sup&amp;parent=".$id."&amp;type=W&amp;res=biblio&amp;id=";
	$biblio_res_mod="?rub=resources&amp;todo=mod_b&amp;parent=".$id."&amp;type=W&amp;id=";
	$result=SQL_GetResources($id, 'WORKSHOP', 'BIBLIO', $sql_object);
	if($result==0) {
		$contents_biblio="<div class=\"info\">".$GLOBALS['lang']['workshoprep']['no_biblio']."</div>";
	} else {
			$contents_biblio="<ul>\n";
			for($i=0; $i<count($result); $i++) {
				if(!empty($result[$i]['bibliores_sub_title'])) $subtitle=formatText($result[$i]['bibliores_sub_title'], '2HTML').'. ';
				else $subtitle='';
				if(!empty($result[$i]['bibliores_editor'])) $editor=formatText($result[$i]['bibliores_editor'], '2HTML').'. ';
				else $editor='';
				if(!empty($result[$i]['bibliores_date'])) $biblio_date=formatText($result[$i]['bibliores_date'], '2HTML');
				else $biblio_date='';
				$contents_biblio.="<li class=\"li1\">\n";
				$contents_biblio.="<span class=\"text_det\">".formatText($result[$i]['bibliores_author'], '2HTML')." - </span><span class=\"text_det_it\">".formatText($result[$i]['bibliores_title'], '2HTML').",</span>\n";
				if(AuthUser4Workshop($work_id, $sql_object) || IsSuperAdmin()) {
					$contents_biblio.="\t<a href=\"".$biblio_res_sup.$result[$i]['bibliores_id']."\" class=\"ico_sup\" title=\"".$GLOBALS['lang']['workshoprep']['del_biblio']."\"></a>\n";
					$contents_biblio.="\t<a href=\"".$biblio_res_mod.$result[$i]['bibliores_id']."\" class=\"ico_mod\" title=\"".$GLOBALS['lang']['workshoprep']['mod_biblio']."\"></a>\n";
				}
				$contents_biblio.="<p class=\"text_det\">".$subtitle.$editor.$biblio_date."</p>\n";
				$contents_biblio.="</li>\n";
			}
			$contents_biblio.="</ul>\n";
	}
	$reca_biblio='';
	$reca_biblio.="<div class=\"publi_det\">\n";
	$reca_biblio.="<a name=\"resmulti\" id=\"resmulti\" href=\"#resmulti\" onclick=\"$('#res_biblio').slideToggle();\">".$GLOBALS['lang']['workshoprep']['biblio_res']."</a>\n";
	$reca_biblio.="</div>\n";
	$reca_biblio.="<div id=\"res_biblio\" style=\"display:none;\" >\n";
	if(AuthUser4Workshop($work_id, $sql_object) || IsSuperAdmin()) {
		$reca_biblio.="\t<a href=\"".$biblio_res_add."\" class=\"ico_add2\" title=\"".$GLOBALS['lang']['workshoprep']['add_new_bibliores']."\"></a><br class=\"brendstep\" />\n";
	}
	$reca_biblio.=$contents_biblio;
	$reca_biblio.="</div>\n";
	$reca_biblio.="<br class=\"brendstep\" />\n";
	$rub_link="index.php?rub=workshop";
?>
<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($GLOBALS['lang']['workshoprep']['det']. " : " .$workrep_title.$workshop_title); ?></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
		echo "<h2>".formatTitleh2($workrep_title.$workshop_title)."</h2>\n";
		if(AuthUser4Workshop($work_id, $sql_object) || IsSuperAdmin()) {
			echo "\t<a href=\"".$link_sup.$id."\" class=\"ico_sup2\" title=\"".$GLOBALS['lang']['workshoprep']['sup']."\"></a>\n";
			echo "\t<a href=\"".$link_mod.$id."\" class=\"ico_mod2\" title=\"".$GLOBALS['lang']['workshoprep']['mod']."\"></a>\n";
		}
		echo $reca_generals;
		echo $reca_parts;
		echo $reca_link;
		echo $reca_biblio;
?>

		
		

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