<? session_start();
if(!isset($_SESSION['usuario']))
{
 	echo "<script languaje='JavaScript'>";       
	echo "parent.location.href='index.php'; ";
	echo "</script>";
}

include ("clases/rsptaforo.class.php");
include ("clases/alumno.class.php"); $objalu=new alumno();
include ("clases/doc_curso.class.php"); $objcla=new doc_curso();
include ("clases/curso.class.php"); $objcur=new curso();
include ("clases/foro.class.php"); include ("clases/autor.class.php");
$cod=$_REQUEST['id'];
$obja=new foro(); $objar=new rsptaforo(); $objdoc = new autor();
if($obja->BuscarPorCodigo($cod))
   {
	$con = $obja->getConcepto();
	$det = $obja->getDetalle();
	$fp = $obja->getFechapub();
	$usu = $obja->getUsuario();
	if($objdoc->BuscarPorCodigo($usu))
	  {
		$nom = $objdoc->getNombres()." ".$objdoc->getApellidos();
	  }
	  $iddoc_curso = $obja->getIddoc_curso();
	 if($objcla->BuscarPorCodigo($iddoc_curso))
	  {
		 $idcurso = $objcla->getIdcurso();
		 if($objcur->BuscarPorCodigo($idcurso)){
		    $curso = $objcur->getCurso();
		 }
	  }
   }
?>
<html>
	<head><title>MI FORO</title>
	
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="Shortcut Icon" type="image/x-icon" href="assets/icons/book.ico" />
    <script src="js/sweet-alert.min.js"></script>
    <link rel="stylesheet" href="css/sweet-alert.css">
    <link rel="stylesheet" href="css/material-design-iconic-font.min.css">
    <link rel="stylesheet" href="css/normalize.css">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/jquery.mCustomScrollbar.css">
    <link rel="stylesheet" href="css/timeline.css">
    <link rel="stylesheet" href="css/style.css">
	<link rel="stylesheet" href="css2/css.css">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script>window.jQuery || document.write('<script src="js/jquery-1.11.2.min.js"><\/script>')</script>
    <script src="js/modernizr.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/jquery.mCustomScrollbar.concat.min.js"></script>
    <script src="js/main.js"></script>

<script src="editor/ckeditor/ckeditor.js" type=text/javascript></script>


	</head>
	
	<script language="javascript">
	function consultar(f){
	f.action = 'mancurso.php';
	f.submit();return true;
	}	
	
	
	$(document).ready(function() {
  $('a[data-toggle=modal], button[data-toggle=modal]').click(function () {
    var data_id = '';
	var data_des= '';
    if (typeof $(this).data('id') !== 'undefined') {
      data_id = $(this).data('id');	   
    }
    $('#responde').val(data_id);
  })
});	
	</script>
	<script>
	function rellenar(r){		   
			 document.f2.responde.value=r;
			 }
	</script>
	
<style>
.text_docentes{ font-size:12px; font-family:Arial, Helvetica, sans-serif;}
</style>
<style>
.text_entrada{ font-size:12px; font-family:Arial, Helvetica, sans-serif;}
</style>
	<body >
	
	<div class="container">
<form name="f" action="" method="post">
  <div class="panel-heading">
    <h1>      Publicacion: <?=$con;?>  
     (  <?=$curso;?>
      )<a href="pagdocente.php?id=<?=$usu;?>" class="close" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-share" aria-hidden="true"></span></a></h1>
	<?=$det;?>
	<div class="text_docentes text-muted"><?="(Pub: ".$fp.")";?> Por:<?=$nom;?>
	</div>    
  </div> 
  <div class="form-group">
  COMENTARIOS DE  FORO
            
            
  <a href="#" target="trabajos" data-id="<?=$idalu;?>" data-title="Editar" data-toggle="modal" data-target="#comenta" class="btn btn-warning"><span class="glyphicon glyphicon-comment" aria-hidden="true"></span> Comentar</a>
  
  </div>
  <div id="form-group">
  <table class="table table-responsive">
    
  <? 
			/////////////////////////////////////////////////////////////////////////////////////
			$obj = new rsptaforo();		  
			 
			  $lista = $obj->ListarPorForo($cod);
			  
			  for($i = 0; $i<count($lista); $i++)
			  {
			    if($objalu->BuscarPorNombre($lista[$i]["usuario"])) 
				{
				    $lista[$i]["foto"] = $objalu->getFoto();
					$lista[$i]["Nombres"] = $objalu->getNombres()." ".$objalu->getApellidos();  $f = "fotosa";
				}else{
				        if($objdoc->BuscarPorNombre($lista[$i]["usuario"])) 
						{
							$lista[$i]["foto"] = $objdoc->getFoto();
							$lista[$i]["Nombres"] = $objdoc->getNombres()." ".$objdoc->getApellidos(); $f = "fotos";
						}
				     }
			// echo "<code>";
			  ?>
			 
	
	   <tr onMouseOver="this.style.backgroundColor='#f5f5f5'" onMouseOut="this.style.backgroundColor='#FFFFFF'" class="text_entrada">
	     <td width="6%">
			 <?php if($objalu->getFoto()!="")
			        {?>
              <img src="<?=$f;?>/<?php echo $lista[$i]["foto"];?>" width="57" height="53" class="img-thumbnail img-circle" />
			 <?php } else{
			  				if($objdoc->getFoto()!=""){
			  ?>         		<img src="<?=$f;?>/<?php echo $lista[$i]["foto"];?>" width="52" height="49" class="img-thumbnail img-circle" />
				     <?php 
					  		 }	else { ?><img src="<?=$f;?>/<?php echo "student.png";?>" width="52" height="49" class="img-thumbnail img-circle" />
					   <?    		 }
					      }
					 ?>		 </td>
		   <td width="94%">
			  <div class="text-muted text_docentes"><?php  echo $lista[$i]["Nombres"]." ".$lista[$i]["rspta"];?>: | <span class="glyphicon glyphicon-calendar"></span>:	<?=$lista[$i]["fechapub"];?>			  
			  <button type="button" class="btn btn-default btn-xs" data-id="<?=$lista[$i]["Nombres"]." ".$lista[$i]["rspta"];?>" data-title="Edit" data-toggle="modal" data-target="#comenta" onClick="rellenar('<?=$lista[$i]["Nombres"]." ".$lista[$i]["rspta"];?>');"><span class="glyphicon glyphicon-comment"></span></button>
			  
			  </div>
			  
			  <? 
			    // echo "</code>";
				 }
			  ?>    		   </td>
	   </tr>
	   
      </table>
	     
  </div>
  </form>
  <p>&nbsp;</p>
  <form name="f2" action="controladores/procesarspta.php" method="post" enctype="multipart/form-data">
  <div class="modal fade" id="comenta" tabindex="-1" role="dialog" aria-labelledby="comenta" aria-hidden="true">
   <div class="modal-dialog">
    <div class="modal-content">
	  <div class="modal-header">
				 <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
				 <h4 class="modal-title custom_align" id="Heading">Agregar Comentario</h4>
			  </div>
			  <div class="modal-body">
				  <div class="form-group">
				  <input name="responde" id="responde" type="hidden" size="60">
				  <textarea name="rspta" id="rspta" cols="50" class="form-control" ></textarea><script>
                CKEDITOR.replace( 'rspta' );
            </script>
				  <input type="hidden" name="usuario" value="<?=$_SESSION['usuario'];?>">	
				  </div>
			 </div>
        <div class="modal-footer ">
		      <input type="submit" name="b" value="Registrar" class="btn btn-success btn-lg">
			  <input type="hidden" name="text" value="A">
			  <input type="hidden" name="idforo" value="<?=$cod;?>" class="inputbox">
		  </div>         
      
     </div>
    <!-- /.modal-content --> 
    </div>
      <!-- /.modal-dialog --> 
    </div>
    </form>
	
</center>
</div>
	</body>	
</html>