Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- #error_reporting(E_ALL & ~E_NOTICE);
- ini_set("display_errors","on");
- //CONEXION
- include("./../../../lib/php/conexion_total.php");
- include("./../../../lib/php/datos_entidad.php");
- include("./../../phpgrid-full-v2.2/lib/inc/jqgrid_dist.php");
- //para rellenar el campo semana_1 y domingo
- $sql = "SELECT * FROM entidad LIMIT 0,1";
- $resultado = mysql_query($sql, $conn);
- $fila_entidad = mysql_fetch_array($resultado);
- $nombre_opciones = $fila_entidad['nombre_opciones'];
- //PROBLEMAS CON EXPORT
- // discriminacios dias de la semana actual y la siguiente
- include("../../../lib/php/mayus_minus_capital.inc.php");
- include("../../../lib/php/arrays_semana.php");
- //LISTADO TOTALES
- // nombre del archivo excel
- $n_archivo_l = 'lista_residentes_' . $n_dia . '_' . date('d-m-y');
- $g = new jqgrid();
- // export PDF file params
- $grid["export"] = array("filename"=>$n_archivo_l, "heading"=>$n_archivo_l, "orientation"=>"portrait", "paper"=>"a4");
- // for excel, sheet header
- $grid["export"]["sheetname"] = $n_archivo_l;
- // export filtered data or all data
- $grid["export"]["range"] = "filtered"; // or "all"
- // excel visual params
- $grid["cellEdit"] = true; // inline cell editing, like spreadsheet
- $grid["rownumbers"] = false;
- $grid["rownumWidth"] = 15;
- // excel visual params
- $grid["cellEdit"] = true; // inline cell editing, like spreadsheet
- $grid["rownumbers"] = false;
- $grid["rownumWidth"] = 15;
- $grid["responsive"] = true;
- // $grid["url"] = ""; // your paramterized URL -- defaults to REQUEST_URI
- $grid["rowNum"] = '30'; // by default 20
- $grid["sortname"] = 'nombre'; // by default sort grid by this field
- $grid["sortorder"] = "asc"; // ASC or DESC
- $grid["caption"] = "Lista de residentes"; // caption of grid
- $grid["autowidth"] = true; // expand grid to screen width
- //$grid["width"] = 600;
- $grid["height"] = 410;
- $grid["multiselect"] = true; // allow you to multi-select through checkboxes
- $grid["hiddengrid"] = false;
- $grid["rowactions"] = false;
- $grid["add_options"]["beforeInitData"] = "function(formid) { $('#hola').jqGrid('setColProp','sin_comedor',{editable:false}); }";
- $grid["add_options"]["afterShowForm"] = "function(formid) { $('#hola').jqGrid('setColProp','sin_comedor',{editable:false}); }";
- $grid["edit_options"]["beforeSubmit"] = "function(post,form){ return validate_form_once(post,form); }";
- $grid["add_options"]["beforeSubmit"] = "function(post,form){ return validate_form_once(post,form); }";
- $g->set_options($grid);
- $g->set_actions(array(
- "add"=>true, // allow/disallow add
- "edit"=>true, // allow/disallow edit
- "delete"=>true, // allow/disallow delete
- "rowactions"=>false, // show/hide row wise edit/del/save option
- "export_excel"=>true, // show/hide export to excel option - must set export xlsx params
- "export_pdf"=>true, // show/hide export to pdf option - must set pdf params
- "autofilter" => true, // show/hide autofilter for search
- "search" => 'simple', // show single/multi field search condition (e.g. simple or advance)
- "showhidecolumns" => false // show single/multi field search condition (e.g. simple or advance)
- )
- );
- // you can provide custom SQL query to display data
- $g->select_command = "SELECT
- id,
- nick,
- clave,
- nombre,
- apellidos,
- CONCAT(nombre, ' ', apellidos) as nombre_total,
- habitacion,
- semana_1,
- domingo,
- res_opciones_por_defecto,
- regimen,
- registro,
- email,
- curso,
- sin_comedor,
- 'enviar' as enviar_email
- FROM residentes WHERE nick != '' AND nombre != ''";
- // this db table will be used for add,edit,delete
- $g->table = "residentes";
- $col = array();
- $col["title"] = "id";
- $col["name"] = "id";
- $col["width"] = "2";
- $col["export"] = false;
- $col["hidden"] = true; // hide column by default
- $cols[] = $col;
- $col = array();
- $col["title"] = "nick";
- $col["name"] = "nick";
- $col["width"] = "1";
- $col["export"] = false;
- $col["hidden"] = false; // hide column by default
- $col["editable"] = true;
- $col["search"] = true;
- $col["visible"] = "xl";
- $cols[] = $col;
- $col = array();
- $col["title"] = "curso";
- $col["name"] = "curso";
- $col["width"] = "1";
- $col["export"] = false;
- $col["hidden"] = false; // hide column by default
- $col["editable"] = true;
- $col["search"] = true;
- $col["visible"] = "xl";
- $cols[] = $col;
- $col = array();
- $col["title"] = "clave";
- $col["name"] = "clave";
- $col["width"] = "1";
- //$col["align"] = "center";
- $col["editable"] = true;
- $col["export"] = true;
- $col["hidden"] = false ; // hide column by default
- $col["search"] = true; // this column is not searchable
- $col["editable"] = true;
- $col["visible"] = "xl";
- $cols[] = $col;
- $col = array();
- $col["title"] = "habitación";
- $col["name"] = "habitacion";
- $col["width"] = "1";
- //$col["align"] = "center";
- $col["editable"] = true;
- $col["export"] = true;
- $col["hidden"] = false ; // hide column by default
- $col["search"] = true; // this column is not searchable
- $cols[] = $col;
- $col = array();
- $col["title"] = "nombre";
- $col["name"] = "nombre";
- $col["editable"] = true;
- $col["width"] = "2";
- $col["export"] = true;
- $col["visible"] = "xl";
- $col["search"] = true;
- $cols[] = $col;
- $col = array();
- $col["title"] = "apellidos";
- $col["name"] = "apellidos";
- $col["width"] = "3";
- $col["editable"] = true;
- $col["export"] = true;
- $col["visible"] = "xl";
- $col["search"] = true;
- $cols[] = $col;
- $col = array();
- $col["title"] = "nombre residente";
- $col["name"] = "nombre_total";
- $col["editable"] = true;
- $col["width"] = "3";
- $col["export"] = true;
- $col["visible"] = "xs+";
- $col["search"] = true;
- $cols[] = $col;
- $col = array();
- $col["title"] = "email";
- $col["name"] = "email";
- $col["width"] = "3";
- $col["editable"] = true;
- $col["export"] = true;
- $col["visible"] = "xs+";
- $col["search"] = true;
- $cols[] = $col;
- $col = array();
- $col["title"] = "Regimen";
- $col["name"] = "regimen";
- $col["width"] = "1";
- $col["editable"] = true;
- $col["export"] = true;
- $col["search"] = true;
- $col["align"] = "center";
- $col["visible"] = "xl";
- $cols[] = $col;
- $col = array();
- $col["title"] = "semana_1";
- $col["name"] = "semana_1";
- $col["width"] = "1";
- $col["editable"] = true;
- $col["export"] = true;
- $col["search"] = true;
- $col["align"] = "center";
- $col["hidden"] = true;
- $col["editoptions"] = array("defaultValue"=>$opciones_por_defecto);
- $cols[] = $col;
- $col = array();
- $col["title"] = "domingo";
- $col["name"] = "domingo";
- $col["width"] = "1";
- $col["editable"] = true;
- $col["export"] = true;
- $col["search"] = true;
- $col["align"] = "center";
- $col["hidden"] = true;
- $col["editoptions"] = array("defaultValue"=>$opciones_por_defecto);
- $cols[] = $col;
- $col = array();
- $col["title"] = "opciones_por_defecto";
- $col["name"] = "res_opciones_por_defecto";
- $col["width"] = "1";
- $col["editable"] = true;
- $col["export"] = true;
- $col["search"] = true;
- $col["align"] = "center";
- $col["hidden"] = true;
- $col["editoptions"] = array("defaultValue"=>$opciones_por_defecto);
- $cols[] = $col;
- //escoger día sin comedor
- $col = array();
- $col["title"] = "sin comedor*";
- $col["name"] = "sin_comedor";
- $col["width"] = "3";
- $col["editable"] = true; // this column is editable
- $col["formatter"] = "date"; // format as date
- $col["formatoptions"] = array("srcformat"=>'Y-m-d',"newformat"=>'d/m/Y'); // http://docs.jquery.com/UI/Datepicker/formatDate
- $col["visible"] = "xl";
- $cols[] = $col;
- //enviar email_sin comida
- $col = array();
- $col["title"] = "Envía email**";
- $col["name"] = "enviar_email";
- $col["width"] = "2";
- $col["link"] = "./residentes/email_sin_comida.php?id={id}";
- $col["linkoptions"] = "target='_blank'"; // extra params with <a> tag
- $col["align"] = "center";
- $col["visible"] = "xl";
- $cols[] = $col;
- // pass the cooked columns to grid
- $g->set_columns($cols);
- // generate grid output, with unique grid name as 'list1'
- $residentes = $g->render('hola');
- ?>
- <body>
- <style type="text/css">
- input[type=checkbox] {
- display: block;
- width:15px;
- height: 15px;
- }
- </style>
- <div id="div_lista_residentes" style=" width:100%; margin: 0 auto; clear:both; float:left; padding:10px 0 20px 0;" >
- <? echo $residentes ?>
- </div>
- <div style=" float:left">
- (*) Es el día en que se deja a un usuario sin acceso al comedor. Después de seleccinar el día, hay que pulsar en otro campo para que se guarde el dato.<br>
- En la lista de comidas de ese día no se contará a este residente.<br>
- (**) Envía un email al usuario informándole de que en el dia seleccionado no tendrá comidas en el comedor.
- </div>
- <script>
- function my_validation(value,label)
- {
- if (value > 100)
- return [true,""];
- else
- return [false,label+": Should be greater than 100"];
- }
- function validate_form_once(post,form)
- {
- var str=[];
- if (post.nick== "")
- str[str.length] = " NICK necesario";
- if (post.clave== "")
- str[str.length] = " CLAVE necesaria";
- if (post.nombre== "")
- str[str.length] = " NOMBRE necesario";
- if (post.apellidos== "")
- str[str.length] = " APELLIDOS necesarios";
- if (post.habitacion== "")
- str[str.length] = " HABITACIÓN necesaria";
- if (post.email== "")
- str[str.length] = " EMAIL necesario";
- if (str.length == 0)
- return [true,""];
- else
- return [false,"ERRORES:<br>" + str];
- }
- // enable form validation in inline edit
- jQuery.extend(jQuery.jgrid.inlineEdit, {
- beforeSaveRow: function (o,rowid) {
- data = [];
- jQuery(".editable").each(function(){ data[jQuery(this).attr('name')] = jQuery(this).val(); });
- ret = validate_form_once(data);
- if (!ret[0])
- jQuery.jgrid.info_dialog(jQuery.jgrid.errors.errcap,
- '<div class="ui-state-error" style="text-align:left;padding:5px">'+ ret[1] +'</div>',
- jQuery.jgrid.edit.bClose,{buttonalign:'right'});
- jQuery("#info_dialog").abscenter();
- return ret[0];
- }
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement