Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // include db config
- include_once("config.php");
- // include and create object
- include(PHPGRID_LIBPATH."inc/jqgrid_dist.php");
- // Database config file to be passed in phpgrid constructor
- $db_conf = array(
- "type" => PHPGRID_DBTYPE,
- "server" => PHPGRID_DBHOST,
- "user" => PHPGRID_DBUSER,
- "password" => PHPGRID_DBPASS,
- "database" => PHPGRID_DBNAME
- );
- $g = new jqgrid($db_conf);
- // export XLS file
- // export to excel parameters
- $opt = array();
- $opt["rowNum"] = 50; // by default 20
- $opt["sortname"] = 'Contribuente'; // by default sort grid by this field
- $opt["sortorder"] = "asc"; // ASC or DESC
- $opt["caption"] = "Utenti AER ma privi di abbinamento con Halley"; // caption of grid
- $opt["autowidth"] = true; // expand grid to screen width
- $opt["multiselect"] = false; // allow you to multi-select through checkboxes
- $opt["rowactions"] = true; // allow you to multi-select through checkboxes
- // export XLS file
- // export to excel parameters
- $grid["export"] = array("format"=>"csv", "filename"=>"archivio_utenti_aer");
- $g->set_options($opt);
- $g->set_actions(array(
- "add"=>false, // allow/disallow add
- "edit"=>false, // allow/disallow edit
- "delete"=>false, // allow/disallow delete
- "rowactions"=>true, // show/hide row wise edit/del/save option
- "export"=>true, // show/hide export to excel option
- "autofilter" => true, // show/hide autofilter for search
- "search" => "false" // show single/multi field search condition (e.g. simple or advance)
- )
- );
- // set few params
- $grid["caption"] = "Utenti AER ma privi di abbinamento con Halley";
- $grid["multiselect"] = false;
- $grid["height"] = "1500";
- $grid["autowidth"] = true;
- $grid["rowNum"] = 50;
- $grid["view_options"] = array('width'=>'420');
- // Prima va messa la query personalizzata poi la tabella principale da cui far comparire la griglia e i comandi.
- $sql = "SELECT ht_ass_garbage.Dispositivo, ht_ass_garbage.CodUtenzaDispositivo,ht_ass_garbage.Cognome_ragione_soc_,ht_ass_garbage.Nome ,ht_ass_garbage.Cod_fiscale, ht_ass_garbage.Conferimento FROM ht_ass_garbage LEFT JOIN ht_ass_h_aer ON ht_ass_garbage.CodUtenzaDispositivo = ht_ass_h_aer.CodUtenzaDispositivo";
- $g->select_command = $sql;
- $g->table = "ht_ass_garbage";
- $col = array();
- $col["title"] = "ID"; // caption of column, can use HTML tags too
- $col["name"] = "Seriale"; // grid column name, same as db field or alias from sql
- $col["width"] = "35"; // width on grid
- $col["show"] = array("list"=>false, "add"=>true, "edit"=>true, "view"=>true);
- $cols[] = $col;
- $col = array();
- $col["title"] = "Cod.Ut."; // caption of column, can use HTML tags too
- $col["name"] = "Codice_utenza"; // grid column name, same as db field or alias from sql
- $col["width"] = "35"; // width on grid
- $col["show"] = array("list"=>false, "add"=>true, "edit"=>true, "view"=>true);
- $cols[] = $col;
- $col = array();
- $col["title"] = "Contribuente"; // caption of column, can use HTML tags too
- $col["name"] = "Contribuente"; // grid column name, same as db field or alias from sql
- $col["width"] = "100"; // width on grid
- $cols[] = $col;
- $col = array();
- $col["title"] = "Cod.Fiscale"; // caption of column, can use HTML tags too
- $col["name"] = "Cod_fiscale"; // grid column name, same as db field or alias from sql
- $col["width"] = "80"; // width on grid
- $cols[] = $col;
- $col = array();
- $col["title"] = "T.Ut."; // caption of column, can use HTML tags too
- $col["name"] = "Tipo_utenza"; // grid column name, same as db field or alias from sql
- $col["search"] = false; // this column is not searchable
- $col["width"] = "25"; // width on grid
- $cols[] = $col;
- $col = array();
- $col["title"] = "ht_ass_aer"; // caption of column, can use HTML tags too
- $col["name"] = "ht_ass_h_aer.CodUtenzaDispositivo"; // grid column name, same as db field or alias from sql
- $col["search"] = false; // this column is not searchable
- $col["width"] = "25"; // width on grid
- $cols[] = $col;
- $g->set_columns($cols);
- $out = $g->render("list1");
- $lang_path = strstr(realpath("."),"demos",true)."lib/js/jqgrid/js/i18n";
- $cdir = scandir($lang_path);
- foreach ($cdir as $key => $value)
- {
- if (!in_array($value,array(".","..")))
- {
- $langs[] = $value;
- }
- }
- // if set from page
- if (!empty($_GET["lang"]))
- $i = $_GET["lang"];
- else
- $i = "grid.locale-en.js";
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <link rel="stylesheet" type="text/css" media="screen" href="lib/js/themes/sunny/jquery-ui.custom.css"></link>
- <link rel="stylesheet" type="text/css" media="screen" href="lib/js/jqgrid/css/ui.jqgrid.css"></link>
- <script src="lib/js/jquery.min.js" type="text/javascript"></script>
- <script src="lib/js/jqgrid/js/i18n/grid.locale-it.js" type="text/javascript"></script>
- <script src="lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
- <script src="lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
- </head>
- <body>
- <?php echo $out?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement