require_once('../include/orm.php'); require_once('../include/globals.php'); require_once('../include/util.php'); $_procesos_configurar_db_connected = $Link == ''; if($_procesos_configurar_db_connected) $Link = connectDb(); define('DBCONNECTED', 1); debugstartpage(); if( isset($_x) ) { //if( $_x != '' ) { $_x = $_x == '' ? array() : StringTokenize($_x, ","); $_result = array(); $_result['version'] = array('actual' => 49); $_result['visibility'] = array(); $_initialvars = arrayExclude(get_defined_vars(), array("_*", "form_*", "s_*", "GLOBALS", "Link", "thisname")); } require('../include/base.events.php'); $_morecolumns = ""; if( !isset($_id) and $id != '' ) $_id = rand(1, 100000000); $estado = sessionget('form_configurar_estado' . $_id); //logToFile('estado: ' . print_r($estado, true)); if( empty($_x) or in('onopen', $_x) ) { if( $id != "" and $id != "0" ) { $estado = loadObject($Link, "procesos.estado", $id); } else { $estado = newObject($Link, "procesos.estado"); //fillobjectfromrequest($estado); } } if( isormObject($estado) ) updateObjectFromRequest($Link, $estado); //makeglobals($estado, array('id', 'estado')); if( isset($_x) ) $_initialvars = arrayExclude(get_defined_vars(), array("_*", "form_*", "s_*", "GLOBALS", "Link", "thisname")); //$_initialvars['estado'] = objectToStructure($estado); if( isormObject($estado) ) $_initialvars = array_merge($_initialvars, objectToStructure($estado)); if( isormObject($estado) ) $estado->makeglobals(); //logToFile('estado after uofr: ' . print_r($estado, true)); // isbasewindow: // On Open while( ($__action == "" or $__action == "executedonopen") and (empty($_x) or in('onopen', $_x)) ) { $__action = "executedonopen"; $__tempresult = sqlexec($Link, "select title from ddform where concat(module, '.', name) = '" . mysql_escape($form) . "'"); while( $__temprow = mysql_fetch_array($__tempresult)) { $title = $__temprow[0]; } // 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['__estado__1'] = ($id == "" ) ? 'listmode' : 'editmode' ; $__row0['__estado__2'] = $_id ; $__row0['__estado__3'] = $id == '0' ? 'Nueva ' : '' ; $__row0['__estado__4'] = "Configuración de estado $title" ; $__row0['__estado__5'] = $id > 0 ? ('#' . $id) : '' ; $__row0['__estado__6'] = "Configuración de estado $title" ; $__row0['__estado__7'] = buildUrlQueryFromGet(array('id' => '0', 'message' => '_delete_', 'errors' => '_delete_')) ; $__row0['__estado__8'] = "Configuración de estado $title" ; $__row0['__estado__9'] = buildUrlQueryFromGet(array('id' => '_delete_', 'message' => '_delete_', 'errors' => '_delete_')) ; $__row0['__estado__10'] = buildUrlQueryFromGet(array('id' => '_delete_', 'message' => '_delete_', 'errors' => '_delete_')) ; $__row0['__descripcion__1'] = $estado->descripcion ; $__row0['__notas__1'] = encodehtml($estado->notas) ; $__row0['__orden__1'] = $estado->orden ; $__row0['__modeloenvio__1'] = $estado->modeloenvio->id ; $__row0['__modeloenvio__2'] = genSelectOptionsDb($Link, "select id , nombre,asunto,criterio from cmmodel where (criterio is not null) order by nombre, asunto, criterio", "", "- Seleccionar -"); ; $__row0['__cc__1'] = $estado->cc ; $__row0['__form__1'] = $estado->form ; $__row0['__condicionseteoauto__1'] = encodehtml($estado->condicionseteoauto) ; $__row0['__condicioncontrol__1'] = encodehtml($estado->condicioncontrol) ; $__row0['__textocontrol__1'] = encodehtml($estado->textocontrol) ; $_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, 'pdf') or has($_x, 'pdfprint') or has($_x, 'pdfprint2') ) { $_pdf->title = "Configuración de estado $title"; //$_pdf->drawText("Configuración de estado $title",'Arial','',14); } if( has($_x, 'estado_list') ) { if( $_reorder != '' ) { $_changes = split('/', $_reorder); foreach($_changes as $_change) { $_change0 = split('-', $_change); $_id = $_change0[0]; $_position = $_change0[1]; $_table = 'estados'; sqlexec($Link, "update $_table set position = $_position where id = $_id"); } } //logToFile('[estado_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.estado', 'procesos') ) $_morecolumns = ", status"; if( isset($my) and $my == 'mine' ) { if( isset($status) ) $_order = " and (select count(*) from emresp where form = 'procesos.estado' and objeto = estados.id and usuario = '$s_idusuario' and estado = '$status') > 0 " . $_order; else $_order = " and (select count(*) from emresp where form = 'procesos.estado' and objeto = estados.id and usuario = '$s_idusuario') > 0 " . $_order; } if( isset($status) ) $_result['data'] = sqltotablearray($Link, "select SQL_CALC_FOUND_ROWS estados.id, estados.descripcion, estados.orden, estados.activo, (select temp.nombre from cmmodel as temp where temp.id = estados.modeloenvio) as modeloenvio $_morecolumns from estados where ($_additionalfilter) and (form = '" . mysql_escape($form) . "') and (estados.status = '" . mysql_escape($status) . "') and (estados.descripcion like '%" . mysql_escape($q) . "%' or (estados.descripcion is null and '" . mysql_escape($q) . "' = '') or estados.usuariospermitidos like '%" . mysql_escape($q) . "%' or (estados.usuariospermitidos is null and '" . mysql_escape($q) . "' = '') ) $_order limit $start, $length"); else $_result['data'] = sqltotablearray($Link, "select SQL_CALC_FOUND_ROWS estados.id, estados.descripcion, estados.orden, estados.activo, (select temp.nombre from cmmodel as temp where temp.id = estados.modeloenvio) as modeloenvio $_morecolumns from estados where ($_additionalfilter) and (form = '" . mysql_escape($form) . "') and (estados.descripcion like '%" . mysql_escape($q) . "%' or (estados.descripcion is null and '" . mysql_escape($q) . "' = '') or estados.usuariospermitidos like '%" . mysql_escape($q) . "%' or (estados.usuariospermitidos is null and '" . mysql_escape($q) . "' = '') ) $_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, 'estado_init') ) { $_result['estado'] = $estado->toarray(false); break; } while( has($_x, 'estado') ) { $estado->saveChanges(); //if( $errors == "" ) // validateestado(); if( $errors == "" ) { //logToFile("BEFORE SAVE: " . objectToHtml($estado)); saveObject($Link, $estado); if( hasfeature('procesos.estado', 'procesos') ) { require_once('../include/easyflexa.php'); if( $id == 0 ) setresponsables($estado); controlstatus($estado); } $id = $estado->id; //logToFile(objectToText($estado)); if( $_redirect != "" ) redirect($_redirect); sessionset('form_configurar_estado' . $_id, $estado); if( $_result['redirect'] == '' ) redirect("?id=$id"); } break; } while( has($_x, 'estado__delete') ) { //if( $errors == "" ) // validateestado(); if( $errors == "" ) { //logToFile("BEFORE SAVE: " . objectToHtml($estado)); deleteObject($Link, $estado); //logToFile(objectToText($estado)); if( $_redirect != "" ) redirect($_redirect); sessionset('form_configurar_estado' . $_id, null); if( $_result['redirect'] == '' ) { $_result['redirect'] = "?message=Configuración de estado $title eliminada"; } } break; } while( has($_x, 'estado_unload') ) { // Not used sessionclear('form_configurar_estado' . $_id); break; } if( has($_x, 'unnamed2') ) { } if( has($_x, 'usuariospermitidos_select') ) { list( $_result['usuariospermitidos_select'], $_result['usuariospermitidos_total'] ) = sqltoarraywithtotal($Link, "select SQL_CALC_FOUND_ROWS id,concat(apellido,', ',nombre) from /* " . mysql_escape($s_userstable) . " */ cmcont where tipo = 'Usuario' and (nombre like '%" . mysql_escape($q) . "%' or apellido like '%" . mysql_escape($q) . "%') order by apellido" , array("id", "text", "*") ); } if( has($_x, 'pordefecto_select') ) { /** * si,no */ $_result['pordefecto_select'] = [["si","si"],["no","no"]]; } if( has($_x, 'modeloenvio_select') ) { list($_result['modeloenvio_select'], $_result['modeloenvio_columns'], $_result['modeloenvio_types']) = sqltoarraydd($Link, "select id , nombre,asunto,criterio from cmmodel where (criterio is not null) order by nombre, asunto, criterio limit 500"); } if( has($_x, 'funcionesavanzadas') ) { } sessionset('form_configurar_estado' . $_id, $estado); //$estado -> ['changes'] if( isormObject($estado) ) $estado->makeglobals(); 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 { ?>
require('../include/base.head.php'); ?> class="popup" } ?> >