require_once('../include/orm.php'); require_once('../include/globals.php'); require_once('../include/util.php'); $_procesos_diagrama_db_connected = $Link == ''; if($_procesos_diagrama_db_connected) $Link = connectDb(); define('DBCONNECTED', 1); debugstartpage(); //$_inmenusistemas/Procesos = 'yes'; if( isset($_x) ) { //if( $_x != '' ) { $_x = $_x == '' ? array() : StringTokenize($_x, ","); $_result = array(); $_result['version'] = array('actual' => 16); $_result['visibility'] = array(); $_initialvars = arrayExclude(get_defined_vars(), array("_*", "form_*", "s_*", "GLOBALS", "Link", "thisname")); } require('../main/base.events.php'); $_morecolumns = ""; if( !isset($_id) and $id != '' ) $_id = rand(1, 100000000); $diagrama = sessionget('form_diagrama_diagrama' . $_id); //logToFile('diagrama: ' . print_r($diagrama, true)); if( empty($_x) or in('onopen', $_x) ) { if( $id != "" and $id != "0" ) { $diagrama = loadObject($Link, "procesos.diagrama", $id); } else { $diagrama = newObject($Link, "procesos.diagrama"); //fillobjectfromrequest($diagrama); } } if( isormObject($diagrama) ) updateObjectFromRequest($Link, $diagrama); //makeglobals($diagrama, array('id', 'diagrama')); if( isset($_x) ) $_initialvars = arrayExclude(get_defined_vars(), array("_*", "form_*", "s_*", "GLOBALS", "Link", "thisname")); //$_initialvars['diagrama'] = objectToStructure($diagrama); if( isormObject($diagrama) ) $_initialvars = array_merge($_initialvars, objectToStructure($diagrama)); if( isormObject($diagrama) ) $diagrama->makeglobals(); //logToFile('diagrama after uofr: ' . print_r($diagrama, true)); // isbasewindow: // PHP Vars while( ($__action == "" or $__action == "executedonopen") and isset($_GET['_x']) and empty($_x) ) { $__row0 = array(); $__row0['__diagrama__1'] = ($id != "" and $id != "0" ) ? 'form-readonly readonly' : '' ; $__row0['__diagrama__2'] = ($id == "" ) ? 'listmode' : 'editmode' ; $__row0['__diagrama__3'] = $_id ; $__row0['__diagrama__4'] = $id == '0' ? 'Nueva ' : '' ; $__row0['__diagrama__5'] = $id > 0 ? ('#' . $id) : '' ; $__row0['__diagrama__6'] = buildUrlQueryFromGet(array('id' => '0', 'message' => '_delete_', 'errors' => '_delete_')) ; $__row0['__diagrama__7'] = buildUrlQueryFromGet(array('id' => '_delete_', 'message' => '_delete_', 'errors' => '_delete_')) ; $__row0['__diagrama__8'] = $s_access['modificacion'] ; $__row0['__diagrama__9'] = buildUrlQueryFromGet(array('id' => '_delete_', 'message' => '_delete_', 'errors' => '_delete_')) ; $__row0['__nombre__1'] = $diagrama->nombre ; $__row0['__explicacion__1'] = encodehtml($diagrama->explicacion) ; $__row0['__svg__1'] = encodehtml($diagrama->svg) ; $__row0['__visualizar__1'] = ($id != '' and $id != 0) ? 'display: inline !important;' : 'display: none !important;' ; $_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 = "Diagramas de modulos"; $_pdf->SetTopMargin(50); $_pdf->AliasNbPages(); $_pdf->AddPage(); } if( has($_x, 'pdf') or has($_x, 'pdfprint') or has($_x, 'pdfprint2') ) { $_pdf->title = "Diagrama"; //$_pdf->drawText("Diagrama",'Arial','',14); } if( has($_x, 'diagrama_list') ) { if( $_reorder != '' ) { $_changes = split('/', $_reorder); foreach($_changes as $_change) { $_change0 = split('-', $_change); $_id = $_change0[0]; $_position = $_change0[1]; $_table = 'procesos'; sqlexec($Link, "update $_table set position = $_position where id = $_id"); } } //logToFile('[diagrama_list] ' . print_r($_REQUEST, true) ); $q = $search['value']; $_order = "order by " . ($order[0]['column'] + 1) . " " . $order[0]['dir']; if( $order[0]['column'] == '' ) $_order = $orderby ; if( $start == '' ) $start = 0; if( $length == '' ) $length = 50; else if( $length == '-1' ) $length = 10000; $_additionalfilter = substr(getaccess(getSelfWindow(), 'buscar'), 14); if( trim($_additionalfilter) == '' ) $_additionalfilter = '1 = 1'; if( hasfeature('procesos.diagrama', 'procesos') ) $_morecolumns = ", status"; if( isset($my) and $my == 'mine' ) { if( isset($status) ) $_order = " and (select count(*) from emresp where form = 'procesos.diagrama' and objeto = procesos.id and usuario = '$s_idusuario' and estado = '$status') > 0 " . $_order; else $_order = " and (select count(*) from emresp where form = 'procesos.diagrama' and objeto = procesos.id and usuario = '$s_idusuario') > 0 " . $_order; } if( isset($status) ) $_result['data'] = sqltotablearray($Link, "select SQL_CALC_FOUND_ROWS procesos.id, procesos.nombre, procesos.modulo $_morecolumns from procesos where ($_additionalfilter) and (procesos.status = '" . mysql_escape($status) . "') $_order limit $start, $length"); else $_result['data'] = sqltotablearray($Link, "select SQL_CALC_FOUND_ROWS procesos.id, procesos.nombre, procesos.modulo $_morecolumns from procesos where ($_additionalfilter) $_order limit $start, $length"); $_result['draw'] = 0; $_result['recordsTotal'] = sqlget($Link, "select found_rows()"); $_result['recordsFiltered'] = $_result['recordsTotal']; //sizeof($_result['data']); //$_result['recordsFiltered'] = 50; print(json_encode($_result)); disconnectDb($Link); exit(0); } // aca iba session get, uofr y load/saveobject while( has($_x, 'diagrama_init') ) { $_result['diagrama'] = $diagrama->toarray(false); break; } while( has($_x, 'diagrama') ) { $diagrama->saveChanges(); //if( $errors == "" ) // validatediagrama(); if( $errors == "" ) { //logToFile("BEFORE SAVE: " . objectToHtml($diagrama)); saveObject($Link, $diagrama); if( hasfeature('procesos.diagrama', 'procesos') ) { require_once('../include/easyflexa.php'); if( $id == 0 ) setresponsables($diagrama); controlstatus($diagrama); } $id = $diagrama->id; //logToFile(objectToText($diagrama)); if( $_redirect != "" ) redirect($_redirect); sessionset('form_diagrama_diagrama' . $_id, $diagrama); if( $_result['redirect'] == '' ) redirect("?id=$id"); } break; } while( has($_x, 'diagrama__delete') ) { //if( $errors == "" ) // validatediagrama(); if( $errors == "" ) { //logToFile("BEFORE SAVE: " . objectToHtml($diagrama)); deleteObject($Link, $diagrama); //logToFile(objectToText($diagrama)); if( $_redirect != "" ) redirect($_redirect); sessionset('form_diagrama_diagrama' . $_id, null); if( $_result['redirect'] == '' ) { $_result['redirect'] = "?message=Diagrama eliminada"; } } break; } while( has($_x, 'diagrama_unload') ) { // Not used sessionclear('form_diagrama_diagrama' . $_id); break; } if( has($_x, 'section1') ) { } if( has($_x, 'modulo_select') ) { list($_result['modulo_select'], $_result['modulo_columns'], $_result['modulo_types']) = sqltoarraydd($Link, "select name, name from flexa1.ddmodule "); } sessionset('form_diagrama_diagrama' . $_id, $diagrama); //$diagrama -> ['changes'] if( isormObject($diagrama) ) $diagrama->makeglobals(); if( isset($_GET['_x']) and empty($_x) ) { $_result['visibility']['visualizar'] = ($id != '' and $id != 0); } 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=diagrama.xls"); //echo(''); //echo(''); echo(''); ?> } else { ?>
require('../main/base.head.php'); ?>