-
-
Save ACTIVA-E/edd104a9fd6b40d91b474dbdb5c3d185 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* PHP Grid Component | |
* | |
* @author Abu Ghufran <gridphp@gmail.com> - http://www.phpgrid.org | |
* @version 2.0.0 | |
* @license: see license.txt included in package | |
*/ | |
// We need to use sessions, so you should always start sessions using the below code. | |
session_start(); | |
// If the user is not logged in redirect to the login page... | |
if (!isset($_SESSION['loggedin'])) { | |
header('Location: index'); | |
exit; | |
} | |
include_once("./config.php"); | |
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); | |
$g->table = "evq_todos"; | |
if(!$_SESSION['admin']){ | |
$g->select_command = 'Select * from evq_todos where (who = "'.$_SESSION['who'].'" or author = "'.$_SESSION['who'].'")'; | |
} | |
$grid["sortname"] = "open, date_due, fullname"; | |
$grid["sortorder"] = "ASC"; | |
$grid["autowidth"] = false; | |
$grid["shrinkToFit"] = false; | |
$grid["forceFit"] = false; | |
$grid["autoresize"] = true; | |
$grid["hidegrid"] = true; | |
$grid["scroll"] = true; | |
$grid["height"] = "500"; | |
$grid["hidegrid"] = true; | |
$grid["multiSort"] = true; | |
$g->set_options($grid); | |
if($_SESSION['admin']) { | |
$g->set_actions(array("export"=>true)); | |
} | |
$g->set_actions(array( "bulkedit"=>true, | |
"view"=>true, | |
"autofilter"=>true, | |
"showhidecolumns" => true | |
) | |
); | |
$col = array(); | |
$col["title"] = "Abierto"; | |
$col["name"] = "open"; | |
$col["fixed"] = true; | |
$col["width"] = "60"; | |
$col["editable"] = true; | |
$col["frozen"] = true; | |
$col["formatter"] = "checkbox"; | |
$col["edittype"] = "checkbox"; | |
$col["editoptions"] = array("value"=>"Yes:No", defaultValue=> "Yes"); | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Cliente"; | |
$col["name"] = "id_address"; | |
$col["fixed"] = true; | |
$col["width"] = "200"; | |
$col["editable"] = true; | |
$col["frozen"] = true; | |
$col["edittype"] = "select"; // render as select | |
# fetch data from database, with alias k for key, v for value | |
$str = $g->get_dropdown_values("Select id_address as k, fullname as v From evq_fullname Order By fullname"); | |
$col["editoptions"] = array("value"=>":Select...;".$str); | |
$col["formatter"] = "select"; // display label, not value | |
$col["stype"] = "select"; // enable dropdown search | |
$col["searchoptions"] = array("value" => ":;".$str); | |
$col["editrules"] = array("required"=>true); // and is required | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Tipo"; | |
$col["name"] = "note_type"; | |
$col["fixed"] = true; | |
$col["width"] = "100"; | |
$col["editable"] = true; | |
$col["frozen"] = true; | |
$col["edittype"] = "select"; | |
$col["editoptions"]["value"] = get_note_type(); | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Responsable"; | |
$col["name"] = "who"; | |
$col["fixed"] = true; | |
$col["width"] = "100"; | |
$col["editable"] = false; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Fecha"; | |
$col["name"] = "date_due"; | |
$col["fixed"] = true; | |
$col["width"] = "100"; | |
$col["editable"] = true; | |
$col["formatter"] = "datetime"; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Nota"; | |
$col["name"] = "note"; | |
$col["fixed"] = true; | |
$col["width"] = "250"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Registro"; | |
$col["name"] = "date_add"; | |
$col["fixed"] = false; | |
$col["width"] = "100"; | |
$col["editable"] = false; | |
$col["viewable"] = true; | |
$col["hidedlg"] = false; | |
$col["formatter"] = "date"; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Autor"; | |
$col["name"] = "author"; | |
$col["fixed"] = true; | |
$col["width"] = "100"; | |
$col["editable"] = false; | |
$col["viewable"] = true; | |
$col["default"] = $_SESSION['who']; | |
$cols[] = $col; | |
$g->set_columns($cols); | |
$out = $g->render("list1"); | |
function get_note_type() | |
{ | |
$link = mysqli_connect(PHPGRID_DBHOST, PHPGRID_DBUSER, PHPGRID_DBPASS, PHPGRID_DBNAME); | |
if (mysqli_connect_errno()) { | |
printf("Falló la conexión: %s\n", mysqli_connect_error()); | |
exit(); | |
} | |
$str = array(); | |
$note_types=array(); | |
if ($qry = mysqli_query($link, "Select type From ev_note_type Order By type")) { | |
while($res = mysqli_fetch_array($qry)) { | |
$note_types[utf8_encode($res['type'])] = utf8_encode($res['type']); | |
} | |
foreach ($note_types as $k => $v) | |
$str[] = "$v:$v"; | |
} | |
mysqli_free_result($qry); | |
mysqli_close($link); | |
return implode(";",$str); | |
} | |
?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
<html> | |
<head> | |
<title>Clientes</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css"> | |
<link rel="stylesheet" type="text/css" media="screen" href="./lib/js/themes/sunny/jquery-ui.custom.css" /> | |
<link rel="stylesheet" type="text/css" media="screen" href="./lib/js/jqgrid/css/ui.jqgrid.css" /> | |
<script src="./lib/js/jquery.min.js" type="text/javascript"></script> | |
<script src="./lib/js/jqgrid/js/i18n/grid.locale-en.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> | |
<link href="style.css" rel="stylesheet" type="text/css"> | |
</head> | |
<body style="margin: 0px;"> | |
<table style="width:100%;background-color:#000000;"> | |
<tr> | |
<td style="width:34%"><img class="img-responsive" src="Dorado-Blanco-1-0400.png" alt="esVinum" style="block-size: 40px; padding-left: 10px;"></td> | |
<td style="text-align: center; color: #cccccc;">Acciones</td> | |
<td style="text-align: right; padding-right: 10px;"><a href="menu.php" style="color: #cccccc;"><i class="fas fa-sign-out-alt"></i>Menu</a></td> | |
</tr> | |
</table> | |
</body> | |
<div> | |
<?php echo $out?> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment