<?php
///este archivo debe estar un nivel superior al directorio milfs 
session_start();
if(isset($_REQUEST['debug'])) {ini_set('display_errors', 'On');} 
//ini_set('display_errors', 'On');
require ('milfs/xajax/xajax.inc.php');
$xajax = new xajax();
require ('milfs/funciones/funciones.php');
require ('milfs/funciones/experimentales.php');
//require ('milfs/funciones/convert.php');
require ('milfs/funciones/login.php');
require_once ('milfs/includes/markdown.php');
require ("milfs/funciones/conex.php");

$xajax->processRequests(); 

if($_REQUEST['tipo'] == 'documento') {
	
	if($_REQUEST['id'] !="") {
		$linea = 	consultar_contenido_formulario("$_REQUEST[id]",'','','embebido','','impresion');
		$nombre="documento_$_REQUEST[id].odt";
	}else {
		$linea = landingpage_contenido_identificador("$_REQUEST[identificador]","$id_form","impresion",'paginado');
		$nombre="documento_$_REQUEST[identificador].docx";
	}

	
header('Content-Description: File Transfer');
//header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
header('Content-Type: application/vnd.oasis.opendocument.text');
header("Content-Disposition: attachment;filename=$nombre");
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');


echo "<html><body><h2>https://tupale.co</h2> $linea</body></html>";
return;

}elseif($_REQUEST['tipo'] == 'svg') {
	
	
	
	if($_REQUEST['id'] !="") {
	//	$linea = 	consultar_contenido_formulario("$_REQUEST[id]",'','','simple','','svg');
		$creacion =  exportar_svg($_REQUEST['id']);
		echo $creacion ;
		echo"$creacion  svg";
		return;
	}else {
	//	$linea = landingpage_contenido_identificador("$_REQUEST[identificador]","$id_form","impresion",'paginado');
	//	$nombre="documento_$_REQUEST[identificador].docx";
	}
/*header('Content-type: image/svg+xml');
echo '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   width="210mm"
   height="297mm"
   viewBox="0 0 744.09448819 1052.3622047"
   id="svg9084"
   version="1.1">
  <defs
     id="defs9086">
    <clipPath
       clipPathUnits="userSpaceOnUse"
       id="clipPath11049">

    </clipPath>
  </defs>
  <metadata
     id="metadata9089">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
';
echo $linea;
echo '</svg>';
//echo $linea;
return;
*/
}else{}


if(isset($_REQUEST['id']) AND $_REQUEST['id'] !="") {$formulario = $_REQUEST['id'];
$id_proyecto = remplacetas('form_id','id',"$formulario",'id_empresa','') ; $id_proyecto = $id_proyecto[0];

}else {$formulario = "";}
if(isset($_REQUEST['campo']) AND $_REQUEST['campo'] !="") {$id_campo = $_REQUEST['campo'];}else {$id_campo = "";}
if(isset($_REQUEST['proyecto']) AND $_REQUEST['proyecto'] !="") {$id_proyecto = $_REQUEST['proyecto'];}else {}
if($id_proyecto =="") {$id_proyecto= "1";}
$listado_formularios = portal_listado_formularios($id_proyecto);
$panel_formularios ="
				<div class='panel panel-default'>
					<div class='panel panel-heading'>
						<h3>Aplicaciones</h3>

					 </div>
					<div class='panel-body'>
						 <ul class='list-unstyled'>
						 $listado_formularios
						 
						 </ul>
					</div>
				</div>


";
$logo = remplacetas('empresa','id',"$id_proyecto",'imagen','') ;
$direccion = remplacetas('empresa','id',"$id_proyecto",'direccion','') ;
$telefono = remplacetas('empresa','id',"$id_proyecto",'telefono','') ;
$email = remplacetas('empresa','id',"$id_proyecto",'email','') ;
$razon_social = remplacetas('empresa','id',"$id_proyecto",'razon_social','') ;
$slogan = remplacetas('empresa','id',"$id_proyecto",'slogan','') ;
$formulario_publico = remplacetas('form_id','id',"$formulario",'publico',"") ;
		$empresa = 	remplacetas('form_id','id',"$formulario",'id_empresa',"") ;
if($formulario_publico[0] !="1" AND ($id_empresa[0] == $_SESSION['id_empresa']) ) {
$formulario_descripcion="";
$formulario_nombre="";	
$acciones="";
	 }
else {
$formulario_descripcion = remplacetas('form_id','id',"$formulario",'descripcion',"") ;
$formulario_nombre = remplacetas('form_id','id',"$formulario",'nombre',"") ;
$acciones=formulario_acciones("$formulario","");
}
?>
<!DOCTYPE html>
<html lang="en">
   <head >
    <meta charset="utf-8">
    <meta name="viewport" content="user-scalable=no, width=device-width,  maximum-scale=1,  initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
     <?php $xajax->printJavascript("milfs/xajax/");  ?>
    <link rel="shortcut icon" href="favicon-152.png">
	<link rel="apple-touch-icon-precomposed" href="favicon-152.png">
	<link href="milfs/css/font-awesome/css/font-awesome.css" rel="stylesheet">
<!-- 		<link rel="stylesheet" href="milfs/css/style.css" media="screen" /> -->
 <link href="https://getbootstrap.com/examples/sticky-footer-navbar/sticky-footer-navbar.css" rel="stylesheet"> 

<!-- <script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet.js"></script> -->

<!-- <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css" /> -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css?'.time().'" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous" >
	<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha256-k2/8zcNbxVIh5mnQ52A0r3a6jAgMGxFJFE2707UxGCk= sha512-ZV9KawG2Legkwp3nAlxLIVFudTauWuBpC10uEafMHYL0Sarrz5A7G79kXh5+5+woxQ5HM559XX2UZjMJ36Wplg==" crossorigin="anonymous">
<!-- <link href="milfs/css/estilos.php" rel="stylesheet">  -->
	<script src="milfs/js/jquery.min.js"></script>
<script src="milfs/js/jquery.timelinr-0.9.54.js"></script>
        <script src="./librerias/charts/Chart.bundle.js"></script>
    <script src="./librerias/charts/utils.js"></script>
<style type="text/css">
/*@font-face {
font-family: Brandon_light;
src: url("milfs/patos/fuentes/Brandon_light.otf") format("opentype");
}*/
body{

font-size: 18px;
color: black;
}

.modal-dialog {
  width: 95%;
  height: 95%;
  padding: 0;
}

.modal-content {
  /*height: 100%;*/
  border-radius: 0;
}
.container-fluid {
	padding: 0px !important;
	}
a.pie{
color: white !important;
}
a.menu{
color: white !important;
}
a:active{
color: black !important;
}

	</style>
	<!-- morris  -->
 <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css">
 <script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
 <script src="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.min.js"></script>
<!-- morris  -->
</head>
<body   >
      <!-- Static navbar -->

	
    <?php 

$empresas = drop('empresa','id','razon_social','?proyecto',"",'Selecciona un Proyecto');
$buscador = buscar_datos("*formato*","$formulario","grid","mostrar_contenido_buscador");
?>
	
	<div id ='contenedor' style='  ' class="container">
		<div class="col-md-12">
		
		<?php echo $empresas; echo "<h1><img class='img img-rounded' src='milfs/images/secure/?file=150/$logo[0]' style='max-height:100px;'>  $razon_social[0]<small><br>$slogan[0]</small></h1>";   ?>
		</div>
		<div class='row'>
			<div class='col-md-2'>
			
			<?php echo $panel_formularios ?>
			</div>
			<div class='col-md-10'>
				<div id='mostrar_contenido' class='container-fluid'>
				
				<?php echo "<h2>$formulario_nombre[0] <small><br>$formulario_descripcion[0]</small></h2> $acciones $buscador
				<div id='mostrar_contenido_buscador' class=''>
				</div>				
				 ";
				
										if($id_campo =="") {			
						echo portal_listado_campos("$formulario");
												}
												 ?> 
				
				</div>
				
			</div>
			
		</div>
	</div>

	<div class="" style="background-color: black; color:white; ">
<!-- 	<img class='img img-resposive' src="milfs/patos/images/pie.png" style="width:100%" alt=""> -->

	</div>
</div>
  <!-- Modal -->

<div class='modal fade  ' id='muestraInfo' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>
  <div class='modal-dialog modal-lg' style='  ' >
    <div class='modal-content'  style=' '>
    	<div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			<br>
      </div>
      <div class='modal-body'>
       <div id='muestra_form' class="row"></div>
      </div>
    </div>
  </div>

<!-- 
	       <div class='pie' style=" position: fixed;
  bottom: 0; 
  width: 100%;
  /* Set the fixed height of the footer here */
  
 ">
	      
        	</div> -->  


    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
<!--      <script src="milfs/js/jquery.min.js"></script>  -->
     <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
<!--     <script src="milfs/js/bootstrap.min.js"></script>  -->
    <script src="milfs/js/scripts.js"></script> 
        
</body>
</html>