1
0
forked from qwerty/milfs

OPENDATA soporte para plantillas en la visualizacion de datos

This commit is contained in:
fredyrivera 2015-11-14 08:53:11 -05:00
parent 24ad351cbd
commit 4672b97a69
3 changed files with 25 additions and 170 deletions

27
milfs/funciones/funciones.php Executable file → Normal file
View File

@ -964,7 +964,7 @@ $resultado = "
}
$xajax->registerFunction("mostrar_modal");
function portal_filtro_cadena($formulario,$id_campo,$control){
function portal_filtro_cadena($formulario,$id_campo,$control,$div,$plantilla){
$cadena = remplacetas('form_datos','control',"$control",'contenido',"form_id = '$formulario' AND id_campo ='$id_campo' ") ;
$consulta ="SELECT * FROM form_campos ,form_datos
WHERE form_datos.form_id = '$formulario' AND form_campos.id = form_datos.id_campo AND form_datos.id_campo = '$id_campo' AND contenido = '$cadena[0]'
@ -975,7 +975,10 @@ $sql=mysql_query($consulta,$link);
if (mysql_num_rows($sql)!=0){
while( $row = mysql_fetch_array( $sql ) ) {
$datos = contenido_mostrar("$formulario","$row[control]",'',"");
$datos = contenido_mostrar("$formulario","$row[control]",'',"$plantilla");
if($plantilla == "") {
$listado .= "<div class='panel panel-default'>
<div class='panel-heading'><h3>$cadena[0]<a class='btn btn-info pull-right' target='api' href='http://$_SERVER[HTTP_HOST]/milfs/api.php?identificador=$row[control]' >{json}</a></h3> </div>
<div class='panel-body'>
@ -984,6 +987,7 @@ $listado .= "<div class='panel panel-default'>
</div>
</div>
";
}else{$listado .= $datos; }
}
$resultado = "
<br>
@ -991,15 +995,18 @@ $resultado = "
";
}
if ($div ==""){$div="mostrar_contenido";}
else {$div = "$div";}
$respuesta = new xajaxResponse('utf-8');
$respuesta->addAssign("mostrar_contenido","innerHTML","$resultado");
$respuesta->addAssign("$div","innerHTML","$resultado");
return $respuesta;
}
$xajax->registerFunction("portal_filtro_cadena");
function portal_filtro_campos($formulario,$id_campo){
function portal_filtro_campos($formulario,$id_campo,$div,$plantilla){
$formulario_descripcion = remplacetas('form_id','id',"$formulario",'descripcion',"") ;
$formulario_nombre = remplacetas('form_id','id',"$formulario",'nombre',"") ;
$campo_nombre = remplacetas('form_campos','id',"$id_campo",'campo_nombre',"") ;
@ -1012,7 +1019,7 @@ $sql=mysql_query($consulta,$link);
if (mysql_num_rows($sql)!=0){
while( $row = mysql_fetch_array( $sql ) ) {
$listado .= "<li class='list-group-item'><a href='#' onclick=\"xajax_portal_filtro_cadena('$formulario','$id_campo','$row[control]') \" title='$row[control]'>$row[contenido]</a></li>";
$listado .= "<li class='list-group-item'><a href='#' onclick=\"xajax_portal_filtro_cadena('$formulario','$id_campo','$row[control]','$div') \" title='$row[control]'>$row[contenido]</a></li>";
}
$resultado = "
<ul class='list-group'>
@ -1027,7 +1034,7 @@ return $resultado;
function portal_filtro_campos_select($formulario,$id_campo){
function portal_filtro_campos_select($formulario,$id_campo,$div,$plantilla){
$formulario_descripcion = remplacetas('form_id','id',"$formulario",'descripcion',"") ;
$formulario_nombre = remplacetas('form_id','id',"$formulario",'nombre',"") ;
$campo_nombre = remplacetas('form_campos','id',"$id_campo",'campo_nombre',"") ;
@ -1043,7 +1050,7 @@ while( $row = mysql_fetch_array( $sql ) ) {
$listado .= "<option value = '$row[control]'>$row[contenido]</option>";
}
$resultado = "
<select class='form-control' onchange=\"xajax_portal_filtro_cadena('$formulario','$id_campo',(this.value)) \" >
<select class='form-control' onchange=\"xajax_portal_filtro_cadena('$formulario','$id_campo',(this.value),'$div','$plantilla') \" >
<option =''>$campo_nombre[0]</option>
$listado
</select>
@ -4830,8 +4837,12 @@ $sql=mysql_query($consulta,$link);
$control=mysql_result($sql,0,"control");
if (mysql_num_rows($sql)!=0){
mysql_data_seek($sql, 0);
$resultado = contenido_mostrar("$id_form","$control",'',"$plantilla");
while( $row = mysql_fetch_array( $sql ) )
{
$resultado .= contenido_mostrar("$row[form_id]","$row[control]",'',"$plantilla");
}
}
$respuesta = new xajaxResponse('utf-8');
$respuesta->addAssign("mostrar_resultado","innerHTML",$resultado);
return $respuesta;

View File

@ -11,7 +11,7 @@ require ('milfs/funciones/login.php');
require_once ('milfs/includes/markdown.php');
require ("milfs/funciones/conex.php");
$formulario ="5";
$campo_filtro ="5";
$campo_filtro ="74";
$xajax->processRequests();
$logo = remplacetas('empresa','id','1','imagen') ;
$direccion = remplacetas('empresa','id','1','direccion') ;
@ -109,7 +109,10 @@ color: black !important;
<div class='btn btn-success btn-block' onclick ="xajax_mostrar_modal('<?php echo $formulario; ?>','','');"> <i class='fa fa-plus-square'></i> Agregar </a></div>
</div>
<div class='col-sm-7 col-md-5' >
<?php echo formulario_campos_filtro("$formulario","$campo_filtro","","xajax_mostrar_coincidencias_plantilla('$formulario','$campo_filtro',(this.value),'grid'); "); ?>
<div class='input-group'>
<span class='input-group-addon'>Filtro <i class='fa fa-filter'></i> </span>
<?php echo portal_filtro_campos_select($formulario,"$campo_filtro","mostrar_resultado","grid"); ?>
</div>
</div>
<?php echo buscar_datos("","$formulario","grid","mostrar_resultado"); ?>
</div>
@ -161,4 +164,4 @@ color: black !important;
<script src="milfs/js/scripts.js"></script>
</body>
</html>
</html>

View File

@ -1,159 +0,0 @@
<?php
session_start();
//ini_set('display_errors', 'On');
require ('xajax/xajax.inc.php');
$xajax = new xajax();
require ('funciones/funciones.php');
require ('funciones/convert.php');
require ("funciones/conex.php");
require ("includes/markdown.php");
$xajax->processRequests();
if($_REQUEST[id2] =='') {$agregar= $_REQUEST[id];}else {$agregar = $_REQUEST[id2];}
$formulario_nombre = remplacetas('form_id','id',$_REQUEST[id],'nombre') ;
$agregar_nombre = remplacetas('form_id','id',$agregar,'nombre') ;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title><?php echo $formulario_nombre[0] ?> MILFS</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox.js/v2.1.2/mapbox.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox.js/v2.1.2/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<!DOCTYPE html>
<html lang="en">
<head >
<title><?php echo $formulario_nombre[0] ?> MILFS</title>
<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="">
<meta name="author" content="fredyrivera" >
<?php $xajax->printJavascript("xajax/"); ?>
<link rel="shortcut icon" href="favicon-152.png">
<link rel="apple-touch-icon-precomposed" href="favicon-152.png">
<link href="css/font-awesome/css/font-awesome.css" rel="stylesheet">
<link href="http://getbootstrap.com/examples/sticky-footer-navbar/sticky-footer-navbar.css" rel="stylesheet">
<script src='https://api.tiles.mapbox.com/mapbox.js/v2.1.2/mapbox.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox.js/v2.1.2/mapbox.css' rel='stylesheet' />
<!-- <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css" /> -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/estilos.php?hghgS" rel="stylesheet">
<style type="text/css">
body { padding: 0; margin: 0; }
.leaflet-popup-content { width:600px !important; }
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<!-- <link rel="points" type="application/json" href="json.lab.php?id=<?php echo $_REQUEST["id"] ?>"> -->
</head>
<body >
<audio id="foobar" src="images/audios/audio6.mp3" preload="auto" autoplay loop controls></audio>
<style>
.info {
width: 800px;
height: 90%;
overflow-y: auto;
overflow-x: hidden;
position:absolute;
top:100px;
left:50px;
}
.info div {
border-radius:3px;
}
</style>
<div id='map'></div>
<div id='info' class='info' draggable="true"></div>
<script>
L.mapbox.accessToken = 'pk.eyJ1IjoiaHVtYW5vIiwiYSI6IlgyRTFNdFEifQ.OmQBXmcVg_zq-vMpr8P5vQ';
var map = L.mapbox.map('map', 'humano.jki5hno0')
.setView([40, -74.50], 15);
// As with any other AJAX request, this technique is subject to the Same Origin Policy:
// http://en.wikipedia.org/wiki/Same_origin_policy
var featureLayer = L.mapbox.featureLayer()
//.loadURL('json.lab.php?id=<?php echo $id ?>')
.loadURL('json.lab.php?id=<?php echo $_REQUEST[id] ?>&id2=<?php echo $_REQUEST[id2] ?>')
// Once this layer loads, we set a timer to load it again in a few seconds.
.on('ready', run)
.addTo(map);
// Add custom popups to each using our custom feature properties
featureLayer.on('layeradd', function(e) {
var marker = e.layer,
feature = marker.feature;
// Create custom popup content
var popupContent = '' + feature.properties.name + '' +
feature.properties.title +'';
var aviso = feature.properties.name;
info.innerHTML = aviso;
// http://leafletjs.com/reference.html#popup
marker.bindPopup(popupContent,{
closeButton: false,
minWidth: 320
});
marker.setIcon(L.icon(feature.properties.icon));
});
function run() {
featureLayer.eachLayer(function(l) {
map.panTo(l.getLatLng());
});
window.setTimeout(function() {
//featureLayer.loadURL('json.lab.php?id=<?php echo $_REQUEST[id] ?>');
featureLayer.loadURL('json.lab.php?id=<?php echo $_REQUEST[id] ?>&id2=<?php echo $_REQUEST[id2] ?>');
//featureLayer.loadURL('https://wanderdrone.appspot.com/');
//alert("Hola");
info.innerHTML = aviso;
},15000);
}
</script>
<div class="panel-map" id='panel_map_<?php echo $_REQUEST[id] ?>' style="z-index: 2 !important;">
<div role='row' class='row center-block' style="; "><?php echo mapa_ficha("$_REQUEST[id]");?></div>
<a class="btn btn-primary btn-block" href="#" onclick="xajax_formulario_modal('<?php echo $agregar ?>'); ">Agregar<br> <?php echo $agregar_nombre[0]; ?></a>
<a onClick="window.location.reload()">*</a>
</div>
<!-- Modal -->
<div class='modal fade ' id='muestraInfo' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' 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'>&times;</button>
<h4 class='modal-title' id='myModalLabel_info'><div id='titulo_modal'></div></h4>
</div>
<div class='modal-body'>
<div id='muestra_form'></div>
</div>
<div class='modal-footer' id='pie_modal'>
</div>
</div>
</div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/scripts.js"></script>
</body>
</html>