-
-
Save ACTIVA-E/4d1b2e399c1ea53e457d9d2efc3b280a to your computer and use it in GitHub Desktop.
Custumer.php using Grid4php
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 = "ev_address"; | |
if($_SESSION['admin']){ | |
$g->select_command = "Select ev_address.*, ev_who_customer.own From ev_address Left Join ev_who_customer On ev_who_customer.id_customer = ev_address.id_customer Where ev_address.deleted = 0"; | |
} | |
else | |
{ | |
$g->select_command = "Select ev_address.*, ev_who_customer.own From ev_who_customer Inner Join ev_address On ev_who_customer.id_customer = ev_address.id_customer Where ev_address.deleted=0 And ev_who_customer.username ='".$_SESSION['name']."'"; | |
} | |
$grid["sortname"] = 'alias'; | |
$grid["sortorder"] = "ASC"; | |
$grid["autowidth"] = false; | |
$grid["forceFit"] = false; | |
$grid["autoresize"] = true; | |
$grid["hidegrid"] = true; | |
$grid["scroll"] = true; | |
$grid["height"] = "500"; | |
$grid["hidegrid"] = true; | |
$grid["multiSort"] = true; | |
$grid["cmTemplate"]["visible"] = "xs+"; // show all column on small screens | |
$grid["shrinkToFit"] = false; // enable horizontal scrollbar | |
$grid["search_options"]["autofilter"] = "xs+"; | |
$g->set_options($grid); | |
if($_SESSION['admin']) { | |
$g->set_actions(array("export"=>true)); | |
} | |
$g->set_actions(array( "add"=>true, | |
"bulkedit"=>false, | |
"delete"=>false, | |
"view"=>true, | |
"rowactions"=>false, | |
"autofilter"=>true, | |
"search"=>false, | |
"inlineadd" => false, | |
"showhidecolumns" => true | |
) | |
); | |
$col = array(); | |
$col["title"] = "id_address"; | |
$col["name"] = "id_address"; | |
$col["fixed"] = true; | |
$col["width"] = "0"; | |
$col["editable"] = false; | |
$col["viewable"] = false; | |
$col["hidedlg"] = true; | |
$col["frozen"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Mio?"; | |
$col["name"] = "own"; | |
$col["fixed"] = true; | |
$col["width"] = "40"; | |
$col["editable"] = false; | |
$col["frozen"] = true; | |
$col["formatter"] = "checkbox"; | |
$col["edittype"] = "checkbox"; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Alias*"; | |
$col["name"] = "alias"; | |
$col["fixed"] = true; | |
$col["width"] = "200"; | |
$col["editable"] = true; | |
$col["frozen"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Empresa*"; | |
$col["name"] = "company"; | |
$col["fixed"] = true; | |
$col["width"] = "200"; | |
$col["editable"] = true; | |
$col["frozen"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Nombre*"; | |
$col["name"] = "firstname"; | |
$col["fixed"] = true; | |
$col["width"] = "100"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Apellidos*"; | |
$col["name"] = "lastname"; | |
$col["fixed"] = true; | |
$col["width"] = "100"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Prioridad"; | |
$col["name"] = "priority"; | |
$col["fixed"] = true; | |
$col["width"] = "70"; | |
$col["editable"] = true; | |
$col["edittype"] = "select"; | |
$col["editoptions"] = array("value"=>'1:Alto;2:Medio;3:Bajo;4:Muy bajo;9:No(explicar);:'); | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Apertura"; | |
$col["name"] = "opening"; | |
$col["fixed"] = true; | |
$col["width"] = "70"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Dirección 1*"; | |
$col["name"] = "address1"; | |
$col["fixed"] = true; | |
$col["width"] = "100"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Dirección 2*"; | |
$col["name"] = "address2"; | |
$col["fixed"] = true; | |
$col["width"] = "100"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "País*"; | |
$col["name"] = "id_country"; | |
$col["fixed"] = true; | |
$col["width"] = "100"; | |
$col["editable"] = true; | |
$col["edittype"] = "select"; // render as select | |
$str = $g->get_dropdown_values("Select pre2732_country_lang.id_country as k, pre2732_country_lang.name as v From pre2732_country Inner Join pre2732_country_lang On pre2732_country.id_country = pre2732_country_lang.id_country Where pre2732_country_lang.id_lang = 1 And pre2732_country.active = 1 Order by pre2732_country_lang.name"); | |
$col["editoptions"] = array("value"=>":Select...;".$str, defaultValue=> "6"); | |
//$col["editoptions"] = array("value"=>":Select...;".$str, defaultValue=> "6","onchange" => array( "update_field" => "id_state", | |
// "sql" => "Select pre2732_state.id_state as k, pre2732_state.name As v From pre2732_country Inner //Join pre2732_state On pre2732_country.id_country = pre2732_state.id_country Where pre2732_country.id_country = '{id_country}' Order by pre2732_state.name" | |
// )); | |
$col["formatter"] = "select"; // display label, not value | |
$col["stype"] = "select-multiple"; // enable dropdown search | |
$col["searchoptions"] = array("value" => ":;".$str); | |
$col["editrules"] = array("required"=>false); // and is required | |
$col["show"] = array("list"=>true, "add"=>true, "edit"=>true, "view"=>true, "bulkedit"=>false); | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Provincia*"; | |
$col["name"] = "id_state"; | |
$col["fixed"] = true; | |
$col["width"] = "150"; | |
$col["editable"] = true; | |
$col["edittype"] = "select"; // render as select | |
$str = $g->get_dropdown_values("Select pre2732_state.id_state as k, pre2732_state.name As v From pre2732_country Inner Join pre2732_state On pre2732_country.id_country = pre2732_state.id_country Order by pre2732_state.name"); | |
$col["editoptions"] = array("value"=>":Select...;".$str); | |
$col["formatter"] = "select"; // display label, not value | |
$col["stype"] = "select-multiple"; // enable dropdown search | |
$col["searchoptions"] = array("value" => ":;".$str); | |
$col["editrules"] = array("required"=>false); // and is required | |
$col["show"] = array("list"=>true, "add"=>true, "edit"=>true, "view"=>true, "bulkedit"=>false); | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Cod.Pos.*"; | |
$col["name"] = "postcode"; | |
$col["fixed"] = true; | |
$col["width"] = "60"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Población*"; | |
$col["name"] = "city"; | |
$col["fixed"] = true; | |
$col["width"] = "100"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "CIF*"; | |
$col["name"] = "vat_number"; | |
$col["fixed"] = true; | |
$col["width"] = "80"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Pago/Entrega*"; | |
$col["name"] = "other"; | |
$col["fixed"] = true; | |
$col["width"] = "100"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "T.Entregas*"; | |
$col["name"] = "phone"; | |
$col["fixed"] = true; | |
$col["width"] = "80"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "T.Segund.*"; | |
$col["name"] = "phone_mobile"; | |
$col["fixed"] = true; | |
$col["width"] = "80"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Nombre mail"; | |
$col["name"] = "mailing_name"; | |
$col["fixed"] = true; | |
$col["width"] = "80"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Email 1"; | |
$col["name"] = "email_1"; | |
$col["fixed"] = true; | |
$col["width"] = "60"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Email 2"; | |
$col["name"] = "email_2"; | |
$col["fixed"] = true; | |
$col["width"] = "60"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Actividad"; | |
$col["name"] = "activity"; | |
$col["fixed"] = true; | |
$col["width"] = "150"; | |
$col["editable"] = true; | |
$col["edittype"] = "select"; | |
$str = $g->get_dropdown_values("Select id_activity as k, id_activity as v From ev_activity Order By id_activity"); | |
$col["editoptions"] = array("value"=>":;".$str); | |
$col["formatter"] = "select"; | |
$col["stype"] = "select-multiple"; // enable dropdown search | |
$col["searchoptions"] = array("value" => ":;".$str); | |
$col["editrules"] = array("required"=>false); | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Categoría"; | |
$col["name"] = "category"; | |
$col["fixed"] = true; | |
$col["width"] = "80"; | |
$col["editable"] = true; | |
$col["edittype"] = "select"; | |
$str = $g->get_dropdown_values("Select id_category as k, id_category as v From ev_category Order By id_category"); | |
$col["editoptions"] = array("value"=>":;".$str); | |
$col["formatter"] = "select"; | |
$col["stype"] = "select-multiple"; // enable dropdown search | |
$col["searchoptions"] = array("value" => ":;".$str); | |
$col["editrules"] = array("required"=>false); | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Servicio"; | |
$col["name"] = "service"; | |
$col["fixed"] = true; | |
$col["width"] = "0"; | |
$col["editable"] = false; | |
$col["viewable"] = false; | |
$col["hidedlg"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Fuente"; | |
$col["name"] = "source"; | |
$col["fixed"] = true; | |
$col["width"] = "60"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Notas generales"; | |
$col["name"] = "note_general"; | |
$col["fixed"] = true; | |
$col["width"] = "200"; | |
$col["editable"] = true; | |
$col["edittype"] = "textarea"; | |
$col["editoptions"] = array("rows"=>10, "cols"=>40); | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Notas Productos"; | |
$col["name"] = "note_products"; | |
$col["fixed"] = true; | |
$col["width"] = "200"; | |
$col["editable"] = true; | |
$col["edittype"] = "textarea"; | |
$col["editoptions"] = array("rows"=>10, "cols"=>40); | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Descuento"; | |
$col["name"] = "discounts"; | |
$col["fixed"] = true; | |
$col["width"] = "100"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "C.Banco"; | |
$col["name"] = "bank_account"; | |
$col["fixed"] = true; | |
$col["width"] = "100"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "DNI*"; | |
$col["name"] = "dni"; | |
$col["fixed"] = true; | |
$col["width"] = "0"; | |
$col["editable"] = false; | |
$col["viewable"] = false; | |
$col["hidedlg"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Web"; | |
$col["name"] = "url"; | |
$col["fixed"] = true; | |
$col["width"] = "60"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "IVA?"; | |
$col["name"] = "VAT"; | |
$col["fixed"] = true; | |
$col["width"] = "0"; | |
$col["editable"] = false; | |
$col["viewable"] = false; | |
$col["hidedlg"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Rec.?"; | |
$col["name"] = "other_tax"; | |
$col["fixed"] = true; | |
$col["width"] = "50"; | |
$col["editable"] = true; | |
$col["viewable"] = true; | |
$col["hidedlg"] = false; | |
$col["formatter"] = "checkbox"; | |
$col["edittype"] = "checkbox"; | |
$col["editoptions"] = array("value"=>"-1:0", defaultValue=> "0"); | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Tipo Cl"; | |
$col["name"] = "tipo_cliente"; | |
$col["fixed"] = true; | |
$col["width"] = "0"; | |
$col["editable"] = false; | |
$col["viewable"] = false; | |
$col["hidedlg"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Destino"; | |
$col["name"] = "destino"; | |
$col["fixed"] = true; | |
$col["width"] = "0"; | |
$col["editable"] = false; | |
$col["viewable"] = false; | |
$col["hidedlg"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "V.P"; | |
$col["name"] = "version_precio"; | |
$col["fixed"] = true; | |
$col["width"] = "0"; | |
$col["editable"] = false; | |
$col["viewable"] = false; | |
$col["hidedlg"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Map?"; | |
$col["name"] = "google_export"; | |
$col["fixed"] = true; | |
$col["width"] = "60"; | |
$col["editable"] = true; | |
$col["viewable"] = false; | |
$col["hidedlg"] = true; | |
$col["formatter"] = "checkbox"; | |
$col["edittype"] = "checkbox"; | |
$col["editoptions"] = array("value"=>"1:0", defaultValue=> "0"); | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "DA"; | |
$col["name"] = "date_add"; | |
$col["fixed"] = true; | |
$col["width"] = "0"; | |
$col["editable"] = false; | |
$col["viewable"] = false; | |
$col["hidedlg"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "DU"; | |
$col["name"] = "date_upd"; | |
$col["fixed"] = true; | |
$col["width"] = "0"; | |
$col["editable"] = false; | |
$col["viewable"] = false; | |
$col["hidedlg"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "DU"; | |
$col["name"] = "date_upd"; | |
$col["fixed"] = true; | |
$col["width"] = "0"; | |
$col["editable"] = false; | |
$col["viewable"] = false; | |
$col["hidedlg"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Act."; | |
$col["name"] = "active"; | |
$col["fixed"] = true; | |
$col["width"] = "0"; | |
$col["editable"] = false; | |
$col["viewable"] = false; | |
$col["hidedlg"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Grupo"; | |
$col["name"] = "group"; | |
$col["fixed"] = true; | |
$col["width"] = "60"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Idioma"; | |
$col["name"] = "language"; | |
$col["fixed"] = true; | |
$col["width"] = "60"; | |
$col["editable"] = true; | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Precios"; | |
$col["name"] = "id_customer"; | |
$col["dbname"] = "ev_address.id_customer"; | |
$col["fixed"] = true; | |
$col["width"] = "0"; | |
$col["editable"] = true; | |
$col["viewable"] = true; | |
//$col["hidedlg"] = false; | |
$col["edittype"] = "select"; // render as select | |
$str = $g->get_dropdown_values("Select ev_who.id_default_customer as k, pre2732_group_lang.name as v From pre2732_group_lang Inner Join pre2732_customer On pre2732_group_lang.id_group = pre2732_customer.id_default_group Inner Join ev_who On pre2732_customer.id_customer = ev_who.id_default_customer Where ev_who.username = '".$_SESSION['name']."' And pre2732_group_lang.id_lang = 1 Order By pre2732_group_lang.name"); | |
$col["editoptions"] = array("value"=>$str); | |
$col["formatter"] = "select"; // display label, not value | |
$col["editrules"] = array("required"=>true); // and is required | |
$col["show"] = array("list"=>false, "add"=>true, "edit"=>false, "view"=>false, "bulkedit"=>false); | |
$cols[] = $col; | |
$col = array(); | |
$col["title"] = "Borrar?"; | |
$col["name"] = "deleted"; | |
$col["fixed"] = true; | |
$col["width"] = "60"; | |
$col["editable"] = true; | |
$col["viewable"] = true; | |
$col["hidedlg"] = false; | |
$col["formatter"] = "checkbox"; | |
$col["edittype"] = "checkbox"; | |
$col["editoptions"] = array("value"=>"1:0", defaultValue=> "0"); | |
$cols[] = $col; | |
/* RETIRADO PARA QUE NO PROBLEMAS A LA HORA DE BUSCAR CUANDO NO HAYA HECHO EL FILTRO DEL select_command | |
$col = array(); | |
$col["title"] = "User"; | |
$col["name"] = "username"; | |
$col["fixed"] = true; | |
$col["width"] = "0"; | |
$col["editable"] = false; | |
$col["viewable"] = false; | |
$col["hidedlg"] = true; | |
$cols[] = $col; | |
*/ | |
$g->set_columns($cols); | |
$out = $g->render("list1"); | |
?> | |
<!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 rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-ui-multiselect-widget/1.17/jquery.multiselect.css"> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-ui-multiselect-widget/1.17/jquery.multiselect.filter.css"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-ui-multiselect-widget/1.17/jquery.multiselect.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-ui-multiselect-widget/1.17/jquery.multiselect.filter.js"></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;">Clientes</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