require_once('../include/orm.php');
require_once('../include/globals.php');
require_once('../include/util.php');
$_planos_planoedita_db_connected = $Link == '';
if($_planos_planoedita_db_connected) $Link = connectDb();
define('DBCONNECTED', 1);
debugstartpage();
if( isset($_x) ) {
//if( $_x != '' ) {
$_x = $_x == '' ? array() : StringTokenize($_x, ",");
$_result = array();
$_result['version'] = array('actual' => 261);
$_result['visibility'] = array();
$_initialvars = arrayExclude(get_defined_vars(), array("_*", "form_*", "s_*", "GLOBALS", "Link", "thisname"));
}
require('../consorcios3/base.events.php');
// isbasewindow:
// On Open
while( ($__action == "" or $__action == "executedonopen") and (empty($_x) or in('onopen', $_x)) ) {
$__action = "executedonopen";
$__tempresult = sqlexec($Link, "select nombre, torre, piso, tipologia, vista, archivo, tamano,dibujar from planos where id = " . mysql_escape($id) . "");
while( $__temprow = mysql_fetch_array($__tempresult)) {
$planonombre = $__temprow[0];
$planotorre = $__temprow[1];
$planopiso = $__temprow[2];
$planotipologia = $__temprow[3];
$planovista = $__temprow[4];
$archivo = $__temprow[5];
$tamano = $__temprow[6];
$dibujar = $__temprow[7];
}
$__tempresult = sqlexec($Link, "select w, h from rect where plano = '" . mysql_escape($id) . "' order by id desc limit 1");
while( $__temprow = mysql_fetch_array($__tempresult)) {
$lastw = $__temprow[0];
$lasth = $__temprow[1];
}
debug("dibujar",$dibujar);
if( $lastw == "" ) $lastw = 50;
if( $lasth == "" ) $lasth = 50;
//print("Planonombre: $planonombre
");
//print("Planotorre: $planotorre
");
//print("Planopiso: $planopiso
");
//print("TORRE: $torre PISO: $piso");
list($ancho, $alto, $tipo, $atributos) = getimagesize("../files/planos/$archivo");
//print("Planotorre: $planotorre Planopiso: $planopiso
");
// Si puso header location para ir a otra pagina cierra el script
if( !isset($_x) and $__exiting ) {
disconnectDb($Link); exit(0);
}
break;
}
// PHP Vars
while( ($__action == "" or $__action == "executedonopen") and isset($_GET['_x']) and empty($_x) ) {
$__row0 = array();
$__row0['__unnamed1__1'] = $ancho ;
$__row0['__unnamed1__2'] = $alto ;
$__row0['__unnamed1__3'] = $ancho ;
$__row0['__unnamed1__4'] = $alto ;
$__row0['__unnamed1__5'] = $ancho ;
$__row0['__unnamed1__6'] = $alto ;
$__row0['__unnamed1__7'] = $ancho ;
$__row0['__unnamed1__8'] = $alto ;
$__row0['__contenedorimagen__1'] = $archivo ;
$__row0['__selectorunidad__1'] = ($x / $ancho) * 100 ;
$__row0['__selectorunidad__2'] = ($y / $alto) * 100 ;
$__row0['__selectorunidad__3'] = ($w / $ancho) * 100 ;
$__row0['__selectorunidad__4'] = ($h / $alto) * 100 ;
$__row0['__selectorunidad__5'] = ($x / $ancho) * 100 ;
$__row0['__selectorunidad__6'] = ($y / $alto) * 100 ;
$__row0['__selectorunidad__7'] = ($w / $ancho) * 100 ;
$__row0['__selectorunidad__8'] = ($h / $alto) * 100 ;
$__row0['__selectorunidad__9'] = $descripcion ;
$__row0['__selectorunidad__10'] = $rectid ;
$__row0['__selectorunidad__11'] = $torre00 ;
$__row0['__selectorunidad__12'] = $piso ;
$__row0['__selectorunidad__13'] = $departamento ;
$__row0['__editarrect__1'] = $editarrect ;
$__row0['__botoneditar__1'] = $proyecto ;
$__row0['__botoneditar__2'] = $id ;
$__row0['__botonfinalizar__1'] = $proyecto ;
$__row0['__botonfinalizar__2'] = $id ;
$__row0['__unnamed2__1'] = $unnamed2 ;
$__row0['__x__1'] = $x ;
$__row0['__y__1'] = $y ;
$__row0['__w__1'] = $w ;
$__row0['__h__1'] = $h ;
$__row0['__unnamed12__1'] = $unnamed12 ;
$__row0['__unnamed12__2'] = $planonombre ;
$_result['morevars'] = $__row0;
break;
}
if( has($_x, 'pdf') or has($_x, 'pdfprint') or has($_x, 'pdfprint2') ) {
require_once('../include/fpdfreport.php');
$_pdf = new PDF((isset($_orientation) ? $_orientation : 'P'),'pt', (isset($_size) ? $_size : 'A4' ));
$_pdf->initialPage = ($_page != '' ? $_page : 1);
//$_pdf->SetAutoPageBreak(true);
$_pdf->title = "";
$_pdf->SetTopMargin(50);
$_pdf->AliasNbPages();
$_pdf->AddPage();
}
if( has($_x, 'selectorunidad') ) {
$_result['selectorunidad'] = array();
foreach(sqltoarray($Link, "select rect.id as rectid, rect.unidad, rect.x, rect.y, rect.w, rect.h, rect.link, Unidades.denominacion, Unidades.tipounidad, Unidades.torre, Unidades.piso, Unidades.departamento, if(ifnull(rect.unidad,'0')=0, rect.link, Unidades.denominacion) as descripcion from rect left outer join Unidades on rect.unidad = Unidades.id where rect.plano = '$id'") as $__row0) {
makeglobals($__row0);
$_result['selectorunidad'][] = $__row0;
}
}
if( has($_x, 'agregarunidad_select') ) {
list($_result['agregarunidad_select'], $_result['agregarunidad_columns'], $_result['agregarunidad_types']) = sqltoarraydd($Link, "select id, concat(ifnull((select nombre from tipos where tipou = Unidades.tipou), ''), ' ', departamento) from Unidades where emprendimientoid = '" . mysql_escape($proyecto) . "' and ('" . mysql_escape($planotorre) . "' = '' or torre like '" . mysql_escape($planotorre) . "%') and ('" . mysql_escape($planopiso) . "' = '' or piso = '" . mysql_escape($planopiso) . "') and id not in (select unidad from rect where plano = '" . mysql_escape($id) . "' and unidad is not null) ");
}
while( has($_x, "agregarunidad__onchange") ) {
//
// Si puso header location para ir a otra pagina cierra el script
if( !isset($_x) and $__exiting ) {
disconnectDb($Link); exit(0);
}
break;
}
if( has($_x, 'agregarvinculo_select') ) {
list($_result['agregarvinculo_select'], $_result['agregarvinculo_columns'], $_result['agregarvinculo_types']) = sqltoarraydd($Link, "select id, nombre from planos where emprendimiento = '" . mysql_escape($proyecto) . "' and id != '" . mysql_escape($id) . "'");
}
while( has($_x, "agregarvinculo__onchange") ) {
//
// Si puso header location para ir a otra pagina cierra el script
if( !isset($_x) and $__exiting ) {
disconnectDb($Link); exit(0);
}
break;
}
if( has($_x, 'transicion_select') ) {
/**
* rotateleft,rotateright,rotateup,rotatedown
*/
$_result['transicion_select'] = [["rotateleft","rotateleft"],["rotateright","rotateright"],["rotateup","rotateup"],["rotatedown","rotatedown"]];
}
while( has($_x,'botoneliminar') ) {
/** CODIGO ORIGINAL ONCLICK
$onclick
**/
if( $editarrect != "" ) {
//message("Rectangulo " . $editarrect . " eliminado");
$idrect = "";
//select id into $idrect from rect where plano = '$id' and unidad = '$editarunidad';
sqlexec($Link, "delete from rect where id = " . mysql_escape($editarrect) . "");
redirect("?proyecto=$proyecto&id=$id&message=Rectangulo eliminado");
}
// Si puso header location para ir a otra pagina cierra el script
if( !isset($_x) and $__exiting ) {
disconnectDb($Link); exit(0);
}
break;
}
while( has($_x,'botonaceptar') ) {
/** CODIGO ORIGINAL ONCLICK
$onclick
**/
if( $agregarvinculo != "" ) {
//message("Agregar plano " . $agregarvinculo . " coordenadas $x, $y $w x $h transicion " . $transicion);
$link = "../emprendimientos/plano.php?proyecto=$proyecto&id=" . $agregarvinculo;
sqlexec($Link, "insert into rect(plano, link, x, y, w, h, transicion) values('" . mysql_escape($id) . "', '" . mysql_escape($link) . "', " . mysql_escape($x) . ", " . mysql_escape($y) . ", " . mysql_escape($w) . ", " . mysql_escape($h) . ", '" . mysql_escape($transicion) . "' )");
redirect("?proyecto=$proyecto&id=$id&message=Agregado vinculo al plano");
} else if( $agregarunidad != "" ) {
//message("Unidad " . $agregarunidad . " coordenadas $x, $y $w x $h");
$idrect = "";
$__tempresult = sqlexec($Link, "select id from rect where plano = '" . mysql_escape($id) . "' and unidad = '" . mysql_escape($agregarunidad) . "'");
while( $__temprow = mysql_fetch_array($__tempresult)) {
$idrect = $__temprow[0];
}
if( $editarrect != "" ) {
sqlexec($Link, "update rect set x = " . mysql_escape($x) . ", y = " . mysql_escape($y) . ", w = " . mysql_escape($w) . ", h = " . mysql_escape($h) . ", unidad = " . mysql_escape($agregarunidad) . ", link = null where id = " . mysql_escape($editarrect) . "");
redirect("?proyecto=$proyecto&id=$id&message=Actualizada unidad al plano");
} else if( $idrect == "" ) {
sqlexec($Link, "insert into rect(plano, unidad, x, y, w, h) values('" . mysql_escape($id) . "', " . mysql_escape($agregarunidad) . ", " . mysql_escape($x) . ", " . mysql_escape($y) . ", " . mysql_escape($w) . ", " . mysql_escape($h) . " )");
redirect("?proyecto=$proyecto&id=$id&message=Agregada unidad al plano");
} else {
sqlexec($Link, "update rect set x = " . mysql_escape($x) . ", y = " . mysql_escape($y) . ", w = " . mysql_escape($w) . ", h = " . mysql_escape($h) . " where id = " . mysql_escape($idrect) . "");
redirect("?proyecto=$proyecto&id=$id&message=Actualizada unidad al plano");
}
} else if( $editarrect != "" ) {
//message("Rectangulo " . $editarrect . " coordenadas $x, $y $w x $h");
$idrect = "";
//select id into $idrect from rect where plano = '$id' and unidad = '$editarunidad';
sqlexec($Link, "update rect set x = " . mysql_escape($x) . ", y = " . mysql_escape($y) . ", w = " . mysql_escape($w) . ", h = " . mysql_escape($h) . " where id = " . mysql_escape($editarrect) . "");
redirect("?proyecto=$proyecto&id=$id&message=Actualizado recangulo en plano coordenadas $x, $y $w x $h");
}
// Si puso header location para ir a otra pagina cierra el script
if( !isset($_x) and $__exiting ) {
disconnectDb($Link); exit(0);
}
break;
}
if( has($_x, 'pdf') or has($_x, 'pdfprint') or has($_x, 'pdfprint2') ) {
$_pdf->Output();
}
?>
if( !isset($_x) ) {
?>
if( isset($_export) ) { ?>
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=.xls");
//echo('');
//echo('');
echo('');
?> } else { ?>