[EDIT] CAMBIOS PARA MYSQL EN PROGRESO

parent 5da179ab
......@@ -68,13 +68,18 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20171018</version>
<version>20230618</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/sqljdbc42 -->
<dependency>
<!-- <dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
</dependency> -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.44</version>
</dependency>
</dependencies>
......@@ -127,17 +132,7 @@
</execution>
</executions>
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.wildfly.plugins</groupId>-->
<!-- <artifactId>wildfly-maven-plugin</artifactId>-->
<!-- <version>3.0.2.Final</version>-->
<!-- <configuration>-->
<!-- <hostname>172.16.1.33</hostname>-->
<!-- <port>9990</port>-->
<!-- <username>wildfly</username>-->
<!-- <password>Saco1357$</password>-->
<!-- </configuration>-->
<!-- </plugin>-->
</plugins>
</build>
......
......@@ -5,7 +5,7 @@
*/
package com.mycompany.moduloseguridad.dao;
import com.mycompany.moduloseguridad.sqlserverdao.SqlServerDAOFactory;
import com.mycompany.moduloseguridad.mysqldao.MySQLDAOFactory;
/**
*
......@@ -13,16 +13,13 @@ import com.mycompany.moduloseguridad.sqlserverdao.SqlServerDAOFactory;
*/
public abstract class DAOFactory {
public static final int SQLSERVER = 1;
public static final int MYSQL = 2;
public static final int MYSQL = 1;
public static DAOFactory getDAOFactory(int Motor_Base) {
switch (Motor_Base) {
case SQLSERVER:
return new SqlServerDAOFactory();
default:
return null;
if (Motor_Base == MYSQL) {
return new MySQLDAOFactory();
}
return null;
}
public abstract TipoUsuarioDAO getTipoUsuario();
......
......@@ -14,7 +14,7 @@ import org.json.JSONObject;
*/
public interface MenuDAO {
public JSONArray listarProyecto() throws Exception;
public JSONArray listarProyecto(int estado) throws Exception;
public JSONArray listarTipoDeUsuario(int proyecto) throws Exception;
......
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mycompany.moduloseguridad.dao;
import org.json.JSONObject;
/**
*
* @author sistem17user
*/
public interface TipoUsuarioDAO {
public JSONObject listarProyectos() throws Exception;
JSONObject listarProyectos() throws Exception;
public JSONObject listarTiposUsuarios(int codigoProyecto) throws Exception;
JSONObject listarTiposUsuarios(int codigoProyecto) throws Exception;
public JSONObject asignarAcciones(JSONObject datos) throws Exception;
JSONObject asignarAcciones(JSONObject datos) throws Exception;
public JSONObject activarDesactivarAccion(JSONObject datos) throws Exception;
JSONObject activarDesactivarAccion(JSONObject datos) throws Exception;
public JSONObject activarDesactivarTipoUsuario(JSONObject datos) throws Exception;
JSONObject activarDesactivarTipoUsuario(JSONObject datos) throws Exception;
public JSONObject listarAcciones(JSONObject datos) throws Exception;
JSONObject listarAcciones(JSONObject datos) throws Exception;
public JSONObject listarCboAcciones() throws Exception;
JSONObject listarCboAcciones() throws Exception;
public JSONObject listadoPrincipal(String filtro, int filtrado, int proyecto, int vstart, int vlength, String draw) throws Exception;
JSONObject listadoPrincipal(String filtro, int filtrado, int proyecto, int vstart, int vlength, String draw, int estado) throws Exception;
public int activarTipoUsuario(int codigo) throws Exception;
int activarTipoUsuario(int codigo) throws Exception;
public int desactivarTipoUsuario(int codigo) throws Exception;
int desactivarTipoUsuario(int codigo) throws Exception;
public int editarTipoUsuario(int codigo, String nombre) throws Exception;
int editarTipoUsuario(int codigo, String nombre) throws Exception;
public int crearTipoUsuario(String nombre) throws Exception;
int crearTipoUsuario(String nombre) throws Exception;
public int validarTipoUsuario(int codigo) throws Exception;
int validarTipoUsuario(int codigo) throws Exception;
public int validarNombreTipoUsuario(String nombreInicial, String nombreIngreso, int tipo) throws Exception;
int validarNombreTipoUsuario(String nombreInicial, String nombreIngreso, int tipo) throws Exception;
}
\ No newline at end of file
......@@ -3,13 +3,10 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mycompany.moduloseguridad.sqlserverdao;
package com.mycompany.moduloseguridad.mysqldao;
import java.sql.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.mycompany.moduloseguridad.utilities.ResponseHelper;
import com.mycompany.moduloseguridad.dao.MenuDAO;
import org.json.JSONArray;
......@@ -19,22 +16,25 @@ import org.json.JSONObject;
*
* @author sistem17user
*/
public class MenuSqlServerDAO implements MenuDAO {
public class MenuMYSQLDAO implements MenuDAO {
@Override
public JSONArray listarProyecto() throws Exception {
public JSONArray listarProyecto(int estado) throws Exception {
String base = "security";
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
String query = "";
boolean estadoFinal = estado != 1;
JSONArray lista = new JSONArray();
try {
query = "select pd.cod_proyecto, p.nom from proyecto_detalle as pd "
+ "inner join proyecto as p "
+ "on p.cod_proyecto = pd.cod_proyecto "
+ "group by pd.cod_proyecto, p.nom ";
con = SqlServerDAOFactory.getConnectionSQL(base);
+ "on p.cod_proyecto = pd.cod_proyecto " +
"where p.est = " + estadoFinal
+ " group by pd.cod_proyecto, p.nom ";
System.out.println(query);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next()) {
......@@ -44,9 +44,11 @@ public class MenuSqlServerDAO implements MenuDAO {
lista.put(obj);
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listarProyecto: " + e.getMessage());
} finally {
assert con != null;
con.close();
assert pst != null;
pst.close();
}
return lista;
......@@ -65,7 +67,7 @@ public class MenuSqlServerDAO implements MenuDAO {
+ "inner join tipo_usuario as tu "
+ "on pd.cod_tipo_usuario = tu.cod_tipo_usuario "
+ "where cod_proyecto = " + proyecto + "";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next()) {
......@@ -75,9 +77,11 @@ public class MenuSqlServerDAO implements MenuDAO {
lista.put(obj);
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listarTipoDeUsuario: " + e.getMessage());
} finally {
assert con != null;
con.close();
assert pst != null;
pst.close();
}
return lista;
......@@ -118,7 +122,7 @@ public class MenuSqlServerDAO implements MenuDAO {
+ " where tc.cod_proyecto_detalle = " + proyecto_detalle + ""
+ " order by ord ";
}
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next()) {
......@@ -132,9 +136,11 @@ public class MenuSqlServerDAO implements MenuDAO {
lista.put(obj);
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listarTituloCompleto: " + e.getMessage());
} finally {
assert con != null;
con.close();
assert pst != null;
pst.close();
}
return lista;
......@@ -177,7 +183,7 @@ public class MenuSqlServerDAO implements MenuDAO {
+ " and cod_titulo = " + titulo + ""
+ " order by ord ";
}
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next()) {
......@@ -195,9 +201,11 @@ public class MenuSqlServerDAO implements MenuDAO {
lista.put(obj);
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listarModuloCompleto: " + e.getMessage());
} finally {
assert con != null;
con.close();
assert pst != null;
pst.close();
}
return lista;
......@@ -240,7 +248,7 @@ public class MenuSqlServerDAO implements MenuDAO {
+ " and cod_modulo = " + modulo + ""
+ " order by ord ";
}
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next()) {
......@@ -256,9 +264,11 @@ public class MenuSqlServerDAO implements MenuDAO {
lista.put(obj);
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listarCategoriaCompleto: " + e.getMessage());
} finally {
assert con != null;
con.close();
assert pst != null;
pst.close();
}
return lista;
......@@ -301,7 +311,7 @@ public class MenuSqlServerDAO implements MenuDAO {
+ " and cod_categoria = " + categoria + ""
+ " order by ord ";
}
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next()) {
......@@ -316,9 +326,11 @@ public class MenuSqlServerDAO implements MenuDAO {
lista.put(obj);
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listarSubCategoriaCompleto: " + e.getMessage());
} finally {
assert con != null;
con.close();
assert pst != null;
pst.close();
}
return lista;
......@@ -334,7 +346,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
String sql
= " update titulo "
+ " set nom = RTRIM(UPPER(?)), "
......@@ -387,7 +399,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
int visible = 0;
//validando el visible
......@@ -453,7 +465,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
String sql
= " update categoria "
+ " set nom = RTRIM(UPPER(?)), "
......@@ -508,7 +520,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
String sql
= " update subcategoria "
+ " set nom = RTRIM(UPPER(?)), "
......@@ -565,10 +577,9 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
sql = " insert into titulo (nom, ico, est) "
+ " values(upper(?), ?, 1) ";
sql = " insert into titulo (nom, ico, est) values(upper(?), ?, 1) ";
pst = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
pst.setString(1, datos.getString("nombre"));
pst.setString(2, datos.getString("icono"));
......@@ -580,9 +591,9 @@ public class MenuSqlServerDAO implements MenuDAO {
sql = " insert into titulo_configuracion (cod_titulo,cod_proyecto_detalle, ord,est) "
+ " select ?, cod_proyecto_detalle, "
+ " ( "
+ " select isnull((select top 1 isnull(ord + 1, 1) from titulo_configuracion "
+ " select ifnull((select ifnull(ord + 1, 1) from titulo_configuracion "
+ " where cod_proyecto_detalle = pd.cod_proyecto_detalle "
+ " order by ord desc ), 1) "
+ " order by ord desc limit 1), 1) "
+ " ), 1 "
+ " from proyecto_detalle as pd ";
if (datos.getInt("tipo") == 1) {
......@@ -611,7 +622,7 @@ public class MenuSqlServerDAO implements MenuDAO {
}
} catch (SQLException e) {
e.printStackTrace();
System.out.println("Error al insertar titulo -> " + e.getMessage() + " [" + e.getErrorCode() + "]");
response.setStatus(false);
response.setMessage("Error -> " + e.getMessage() + " [" + e.getErrorCode() + "]");
} finally {
......@@ -623,7 +634,7 @@ public class MenuSqlServerDAO implements MenuDAO {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
System.out.println("Error al cerrar conexion -> " + e.getMessage() + " [" + e.getErrorCode() + "]");
response.setStatus(false);
response.setMessage("Error -> " + e.getMessage() + " [" + e.getErrorCode() + "]");
}
......@@ -647,7 +658,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
sql = " insert into categoria (cod_modulo, nom, tip, url, est) "
+ "values(?, upper(?), ?, ?, 1) ";
......@@ -664,9 +675,9 @@ public class MenuSqlServerDAO implements MenuDAO {
sql = " insert into categoria_configuracion (cod_categoria,cod_proyecto_detalle, ord,est) "
+ " select ?, cod_proyecto_detalle, "
+ " ( "
+ " select isnull((select top 1 isnull(ord + 1, 1) from categoria_configuracion "
+ " select ifnull((select ifnull(ord + 1, 1) from categoria_configuracion "
+ " where cod_proyecto_detalle = pd.cod_proyecto_detalle "
+ " order by ord desc ), 1) "
+ " order by ord desc limit 1), 1) "
+ " ), 1 "
+ " from proyecto_detalle as pd ";
if (datos.getInt("tipo") == 1) {
......@@ -731,7 +742,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
sql = " insert into modulo (cod_titulo, nom, ico, tip, url, est) "
+ " values(?, upper(?), ?, ?, ?, 1) ";
......@@ -749,9 +760,9 @@ public class MenuSqlServerDAO implements MenuDAO {
sql = " insert into modulo_configuracion (cod_modulo,cod_proyecto_detalle, ord,est) "
+ " select ?, cod_proyecto_detalle, "
+ " ( "
+ " select isnull((select top 1 isnull(ord + 1, 1) from modulo_configuracion "
+ " select ifnull((select ifnull(ord + 1, 1) from modulo_configuracion "
+ " where cod_proyecto_detalle = pd.cod_proyecto_detalle "
+ " order by ord desc ), 1) "
+ " order by ord desc limit 1), 1) "
+ " ), 1 "
+ " from proyecto_detalle as pd ";
if (datos.getInt("tipo") == 1) {
......@@ -816,7 +827,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
sql = " insert into subcategoria (cod_categoria, nom, url, est) "
+ " values(?, upper(?), ?, 1) ";
......@@ -832,9 +843,9 @@ public class MenuSqlServerDAO implements MenuDAO {
sql = " insert into subcategoria_configuracion (cod_subcategoria,cod_proyecto_detalle, ord,est) "
+ " select ?, cod_proyecto_detalle, "
+ " ( "
+ " select isnull((select top 1 isnull(ord + 1, 1) from subcategoria_configuracion "
+ " select ifnull((select ifnull(ord + 1, 1) from subcategoria_configuracion "
+ " where cod_proyecto_detalle = pd.cod_proyecto_detalle "
+ " order by ord desc ), 1) "
+ " order by ord desc limit 1), 1) "
+ " ), 1 "
+ " from proyecto_detalle as pd ";
if (datos.getInt("tipo") == 1) {
......@@ -896,7 +907,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
String sql
= " update titulo_configuracion "
+ " set ord = ? "
......@@ -956,7 +967,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
String sql
= " update modulo_configuracion "
+ " set ord = ? "
......@@ -1014,7 +1025,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
String sql
= " update categoria_configuracion "
+ " set ord = ? "
......@@ -1073,7 +1084,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
String sql
= " update subcategoria_configuracion "
+ " set ord = ? "
......@@ -1138,7 +1149,7 @@ public class MenuSqlServerDAO implements MenuDAO {
String cadena = "";
String condicion = "";
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
switch (datos.getInt("jerarquia")) {
case 1:
cadena = "titulo, ico, '', ''";
......@@ -1167,10 +1178,10 @@ public class MenuSqlServerDAO implements MenuDAO {
cant = rs.getInt("cant");
if (cant >= 1) {
sql
= " SELECT top 1 nom, cod_" + cadena + " FROM " + datos.getString("tabla") + " "
= " SELECT nom, cod_" + cadena + " FROM " + datos.getString("tabla") + " "
+ " WHERE SIMILARITY_1_1_0.JaroWinkler(UPPER(nom),UPPER(?)) >= 0.75 "
+ " " + condicion + " "
+ " ORDER BY SIMILARITY_1_1_0.Levenshtein(UPPER(nom), UPPER(?)) DESC ";
+ " ORDER BY SIMILARITY_1_1_0.Levenshtein(UPPER(nom), UPPER(?)) DESC LIMIT 1 ";
pst = con.prepareStatement(sql);
pst.setString(1, datos.getString("nombre"));
pst.setString(2, datos.getString("nombre"));
......@@ -1228,7 +1239,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
sql = " select count(*) as cant from titulo_configuracion as tc "
+ " inner join proyecto_detalle as pd "
......@@ -1249,9 +1260,9 @@ public class MenuSqlServerDAO implements MenuDAO {
sql = " insert into titulo_configuracion (cod_titulo,cod_proyecto_detalle, ord,est) "
+ " select ?, cod_proyecto_detalle, "
+ " ( "
+ " select isnull((select top 1 isnull(ord + 1, 1) from titulo_configuracion "
+ " select ifnull((select ifnull(ord + 1, 1) from titulo_configuracion "
+ " where cod_proyecto_detalle = pd.cod_proyecto_detalle "
+ " order by ord desc ), 1) "
+ " order by ord desc limit 1 ), 1) "
+ " ), 1 "
+ " from proyecto_detalle as pd ";
if (datos.getInt("tipo") == 1) {
......@@ -1311,7 +1322,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
sql = " select count(*) as cant from modulo_configuracion as tc "
+ " inner join proyecto_detalle as pd "
......@@ -1332,9 +1343,9 @@ public class MenuSqlServerDAO implements MenuDAO {
sql = " insert into modulo_configuracion (cod_modulo,cod_proyecto_detalle, ord,est) "
+ " select ?, cod_proyecto_detalle, "
+ " ( "
+ " select isnull((select top 1 isnull(ord + 1, 1) from modulo_configuracion "
+ " select ifnull((select ifnull(ord + 1, 1) from modulo_configuracion "
+ " where cod_proyecto_detalle = pd.cod_proyecto_detalle "
+ " order by ord desc ), 1) "
+ " order by ord desc limit 1), 1) "
+ " ), 1 "
+ " from proyecto_detalle as pd ";
if (datos.getInt("tipo") == 1) {
......@@ -1393,7 +1404,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
sql = " select count(*) as cant from categoria_configuracion as tc "
+ " inner join proyecto_detalle as pd "
......@@ -1414,9 +1425,9 @@ public class MenuSqlServerDAO implements MenuDAO {
sql = " insert into categoria_configuracion (cod_categoria,cod_proyecto_detalle, ord,est) "
+ " select ?, cod_proyecto_detalle, "
+ " ( "
+ " select isnull((select top 1 isnull(ord + 1, 1) from categoria_configuracion "
+ " select ifnull((select ifnull(ord + 1, 1) from categoria_configuracion "
+ " where cod_proyecto_detalle = pd.cod_proyecto_detalle "
+ " order by ord desc ), 1) "
+ " order by ord desc limit 1), 1) "
+ " ), 1 "
+ " from proyecto_detalle as pd ";
if (datos.getInt("tipo") == 1) {
......@@ -1476,7 +1487,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
sql = " select count(*) as cant from subcategoria_configuracion as tc "
+ " inner join proyecto_detalle as pd "
......@@ -1497,9 +1508,9 @@ public class MenuSqlServerDAO implements MenuDAO {
sql = " insert into subcategoria_configuracion (cod_subcategoria,cod_proyecto_detalle, ord,est) "
+ " select ?, cod_proyecto_detalle, "
+ " ( "
+ " select isnull((select top 1 isnull(ord + 1, 1) from subcategoria_configuracion "
+ " select ifnull((select ifnull(ord + 1, 1) from subcategoria_configuracion "
+ " where cod_proyecto_detalle = pd.cod_proyecto_detalle "
+ " order by ord desc ), 1) "
+ " order by ord desc limit 1), 1) "
+ " ), 1 "
+ " from proyecto_detalle as pd ";
if (datos.getInt("tipo") == 1) {
......@@ -1560,14 +1571,14 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
sql = " select count(*) as cant, cod_proyecto from proyecto_detalle as pd "
+ " inner join titulo_configuracion as tc "
+ " on tc.cod_proyecto_detalle = pd.cod_proyecto_detalle"
+ " inner join titulo as t "
+ " on t.cod_titulo = tc.cod_titulo "
+ " where t.cod_titulo = ? "
+ " where t.cod_titulo = ? and pd.est = true"
+ " group by pd.cod_proyecto ";
pst = con.prepareStatement(sql);
pst.setInt(1, datos.getInt("codigo"));
......@@ -1624,14 +1635,14 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
sql = " select count(*) as cant, cod_proyecto from proyecto_detalle as pd "
+ " inner join modulo_configuracion as tc "
+ " on tc.cod_proyecto_detalle = pd.cod_proyecto_detalle"
+ " inner join modulo as t "
+ " on t.cod_modulo = tc.cod_modulo "
+ " where t.cod_modulo = ? "
+ " where t.cod_modulo = ? and pd.est = true"
+ " group by pd.cod_proyecto ";
pst = con.prepareStatement(sql);
pst.setInt(1, datos.getInt("codigo"));
......@@ -1688,14 +1699,14 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
sql = " select count(*) as cant, cod_proyecto from proyecto_detalle as pd "
+ " inner join categoria_configuracion as tc "
+ " on tc.cod_proyecto_detalle = pd.cod_proyecto_detalle"
+ " inner join categoria as t "
+ " on t.cod_categoria = tc.cod_categoria "
+ " where t.cod_categoria = ? "
+ " where t.cod_categoria = ? and pd.est = true"
+ " group by pd.cod_proyecto ";
pst = con.prepareStatement(sql);
pst.setInt(1, datos.getInt("codigo"));
......@@ -1752,14 +1763,14 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
sql = " select count(*) as cant, cod_proyecto from proyecto_detalle as pd "
+ " inner join subcategoria_configuracion as tc "
+ " on tc.cod_proyecto_detalle = pd.cod_proyecto_detalle"
+ " inner join subcategoria as t "
+ " on t.cod_subcategoria = tc.cod_subcategoria "
+ " where t.cod_subcategoria = ? "
+ " where t.cod_subcategoria = ? and pd.est = true"
+ " group by pd.cod_proyecto ";
pst = con.prepareStatement(sql);
pst.setInt(1, datos.getInt("codigo"));
......@@ -1820,19 +1831,16 @@ public class MenuSqlServerDAO implements MenuDAO {
existencia = " and tc.cod_proyecto_detalle = " + datos.getInt("detalle") + " ";
}
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
sql = "select top " + length + " a.cod_titulo, a.nom, a.ico, "
+ "ISNULL( "
con = MySQLDAOFactory.getConnectionSQL(base);
sql = "select a.cod_titulo, a.nom, a.ico, "
+ "IFNULL( "
+ "(select count(*) as cant from titulo_configuracion as tc "
+ "inner join proyecto_detalle as pd "
+ "on pd.cod_proyecto_detalle = tc.cod_proyecto_detalle "
+ "where tc.cod_titulo = a.cod_titulo "
+ existencia + "), 0) "
+ "from titulo as a "
+ "where a.cod_titulo not in "
+ "(select top " + start + " b.cod_titulo from titulo as b "
+ "ORDER BY 1 desc) "
+ "ORDER BY 1 desc ; ";
+ "ORDER BY 1 desc limit "+start+","+length+" ; ";
pst = con.prepareStatement(sql);
rsLlave = pst.executeQuery();
while (rsLlave.next()) {
......@@ -1903,9 +1911,9 @@ public class MenuSqlServerDAO implements MenuDAO {
existencia = " and mc.cod_proyecto_detalle = " + datos.getInt("detalle") + " ";
}
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
sql = " select top " + length + " a.cod_modulo, a.nom, a.ico, a.tip, a.url, "
+ " ISNULL( "
con = MySQLDAOFactory.getConnectionSQL(base);
sql = " select a.cod_modulo, a.nom, a.ico, a.tip, a.url, "
+ " IFNULL( "
+ " (select count(*) as cant "
+ " from modulo_configuracion as mc "
+ " inner join proyecto_detalle as pd "
......@@ -1913,12 +1921,9 @@ public class MenuSqlServerDAO implements MenuDAO {
+ " where mc.cod_modulo = a.cod_modulo "
+ existencia + " ), 0) "
+ " from modulo as a "
+ " where a.cod_modulo not in "
+ " (select top " + start + " b.cod_modulo from modulo as b "
+ " where 1 = 1 " + condicion
+ " ORDER BY 1 desc) "
+ " where true "
+ condicion
+ " ORDER BY 1 desc ; ";
+ "ORDER BY 1 desc limit "+start+","+length+" ; ";
pst = con.prepareStatement(sql);
rsLlave = pst.executeQuery();
while (rsLlave.next()) {
......@@ -1990,9 +1995,9 @@ public class MenuSqlServerDAO implements MenuDAO {
existencia = " and cc.cod_proyecto_detalle = " + datos.getInt("detalle") + " ";
}
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
sql = "select top " + length + " a.cod_categoria, a.nom, a.tip, a.url, "
+ "ISNULL( "
con = MySQLDAOFactory.getConnectionSQL(base);
sql = "select a.cod_categoria, a.nom, a.tip, a.url, "
+ "IFNULL( "
+ "(select count(*) as cant "
+ "from categoria_configuracion as cc "
+ "inner join proyecto_detalle as pd "
......@@ -2000,12 +2005,9 @@ public class MenuSqlServerDAO implements MenuDAO {
+ "where cc.cod_categoria = a.cod_categoria "
+ existencia + " ), 0) "
+ "from categoria as a "
+ "where a.cod_categoria not in "
+ "(select top " + start + " b.cod_categoria from categoria as b "
+ "where 1 = 1 " + condicion
+ "ORDER BY 1 desc) "
+ "where true "
+ condicion
+ "ORDER BY 1 desc ; ";
+ "ORDER BY 1 desc limit "+start+","+length+" ; ";
pst = con.prepareStatement(sql);
rsLlave = pst.executeQuery();
while (rsLlave.next()) {
......@@ -2077,8 +2079,8 @@ public class MenuSqlServerDAO implements MenuDAO {
existencia = " and sc.cod_proyecto_detalle = " + datos.getInt("detalle") + " ";
}
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
sql = "select top " + length + " a.cod_subcategoria, a.nom, a.url, "
con = MySQLDAOFactory.getConnectionSQL(base);
sql = "select a.cod_subcategoria, a.nom, a.url, "
+ "ISNULL( "
+ "(select count(*) as cant "
+ "from subcategoria_configuracion as sc "
......@@ -2087,12 +2089,9 @@ public class MenuSqlServerDAO implements MenuDAO {
+ "where sc.cod_subcategoria = a.cod_subcategoria "
+ existencia + " ), 0) "
+ "from subcategoria as a "
+ "where a.cod_subcategoria not in "
+ "(select top " + start + " b.cod_subcategoria from subcategoria as b "
+ "where 1 = 1 " + condicion
+ "ORDER BY 1 desc) "
+ "where true "
+ condicion
+ "ORDER BY 1 desc ; ";
+ "ORDER BY 1 desc limit "+start+","+length+" ; ";
pst = con.prepareStatement(sql);
rsLlave = pst.executeQuery();
while (rsLlave.next()) {
......@@ -2156,7 +2155,7 @@ public class MenuSqlServerDAO implements MenuDAO {
String sql;
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
if (datos.getInt("configuracion") != 0) {
sql = "select count(*) as cant from modulo as s "
......@@ -2236,7 +2235,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
if (datos.getInt("configuracion") != 0) {
sql = " delete from titulo_configuracion "
......@@ -2309,7 +2308,7 @@ public class MenuSqlServerDAO implements MenuDAO {
String sql;
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
if (datos.getInt("configuracion") != 0) {
sql = "select count(*) as cant from categoria as s "
......@@ -2389,7 +2388,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
if (datos.getInt("configuracion") != 0) {
sql = " delete from modulo_configuracion "
......@@ -2462,7 +2461,7 @@ public class MenuSqlServerDAO implements MenuDAO {
String sql;
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
if (datos.getInt("configuracion") != 0) {
sql = "select count(*) as cant from subcategoria as s "
......@@ -2542,7 +2541,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
if (datos.getInt("configuracion") != 0) {
sql = " delete from categoria_configuracion "
......@@ -2627,7 +2626,7 @@ public class MenuSqlServerDAO implements MenuDAO {
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
if (datos.getInt("configuracion") != 0) {
sql = " delete from subcategoria_configuracion "
......@@ -2689,7 +2688,7 @@ public class MenuSqlServerDAO implements MenuDAO {
String sql;
JSONArray rs;
try {
con = SqlServerDAOFactory.getConnectionSQL("SECURITY");
con = MySQLDAOFactory.getConnectionSQL("SECURITY");
con.setAutoCommit(false);
JSONArray arrayTitulos = datos.getJSONArray("titulos");
JSONArray arrayModulos = datos.getJSONArray("modulos");
......@@ -2807,7 +2806,7 @@ public class MenuSqlServerDAO implements MenuDAO {
String sql;
JSONArray rs;
try {
con = SqlServerDAOFactory.getConnectionSQL("SECURITY");
con = MySQLDAOFactory.getConnectionSQL("SECURITY");
con.setAutoCommit(false);
JSONArray arrayTitulos = datos.getJSONArray("titulos");
JSONArray arrayModulos = datos.getJSONArray("modulos");
......
......@@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mycompany.moduloseguridad.sqlserverdao;
package com.mycompany.moduloseguridad.mysqldao;
import java.sql.Connection;
import java.sql.DriverManager;
......@@ -14,12 +14,7 @@ import com.mycompany.moduloseguridad.dao.TipoUsuarioDAO;
import com.mycompany.moduloseguridad.dao.UsuarioDAO;
import com.mycompany.moduloseguridad.utilities.dotenSrv;
/**
*
* @author Felipe
*
*/
public class SqlServerDAOFactory extends DAOFactory {
public class MySQLDAOFactory extends DAOFactory {
public static Connection getConnectionSQL(String base) {
Connection conexion = null;
......@@ -29,18 +24,18 @@ public class SqlServerDAOFactory extends DAOFactory {
String userSgbd = "";
String passwordSgbd = "";
if (base.equalsIgnoreCase("security")) {
host = dotenSrv.obtenerValorVariableEntorno("SQLSERVER_SECURITY_DB_HOST");
port = dotenSrv.obtenerValorVariableEntorno("SQLSERVER_SECURITY_DB_PORT");
databaseName = dotenSrv.obtenerValorVariableEntorno("SQLSERVER_SECURITY_DB_NAME");
userSgbd = dotenSrv.obtenerValorVariableEntorno("SQLSERVER_SECURITY_DB_USER");
passwordSgbd = dotenSrv.obtenerValorVariableEntorno("SQLSERVER_SECURITY_DB_PASS");
String url = "jdbc:sqlserver://"+host+":"+port+";databaseName="+databaseName;
host = dotenSrv.obtenerValorVariableEntorno("MYSQL_SECURITY_DB_HOST");
port = dotenSrv.obtenerValorVariableEntorno("MYSQL_SECURITY_DB_PORT");
databaseName = dotenSrv.obtenerValorVariableEntorno("MYSQL_SECURITY_DB_NAME");
userSgbd = dotenSrv.obtenerValorVariableEntorno("MYSQL_SECURITY_DB_USER");
passwordSgbd = dotenSrv.obtenerValorVariableEntorno("MYSQL_SECURITY_DB_PASS");
String url = "jdbc:mysql://" + host + ":" + port + "/" + databaseName + "?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull";
// System.out.println("Conectando a la base de datos : "+url+ " con el usuario : "+userSgbd+ " y password : "+passwordSgbd);
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Class.forName("com.mysql.jdbc.Driver");/*Produccion*/
conexion = DriverManager.getConnection(url, userSgbd, passwordSgbd);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error al conectarse a la bd");
System.out.println("Error al conectarse a la bd : "+e.getMessage());
}
}
return conexion;
......@@ -48,21 +43,21 @@ public class SqlServerDAOFactory extends DAOFactory {
@Override
public TipoUsuarioDAO getTipoUsuario() {
return new TipoUsuarioSqlServerDAO();
return new TipoUsuarioMYSQLDAO();
}
@Override
public ProyectoDAO getProyectoDAO() {
return new ProyectoSqlServerDAO();
return new ProyectoMYSQLDAO();
}
@Override
public UsuarioDAO getUsuarioDAO() {
return new UsuarioSqlServerDAO();
return new UsuarioMYSQLDAO();
}
@Override
public MenuDAO getMenuDAO() {
return new MenuSqlServerDAO();
return new MenuMYSQLDAO();
}
}
\ No newline at end of file
......@@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mycompany.moduloseguridad.sqlserverdao;
package com.mycompany.moduloseguridad.mysqldao;
import java.sql.Connection;
import java.sql.PreparedStatement;
......@@ -18,7 +18,7 @@ import org.json.JSONObject;
*
* @author sistem17user
*/
public class ProyectoSqlServerDAO implements ProyectoDAO {
public class ProyectoMYSQLDAO implements ProyectoDAO {
@Override
public JSONObject listarProyecto(JSONObject datos, int vstart, int vlength, String draw) throws Exception {
......@@ -43,13 +43,11 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
} else {
busqueda += "and est = 1";
}
query = " select TOP " + vlength + " cod_proyecto, nom, est, url from proyecto "
+ " where cod_proyecto NOT IN "
+ " ( "
+ " SELECT top " + vstart + " "
+ " cod_proyecto from proyecto ORDER BY cod_proyecto) "
query = " select cod_proyecto, nom, est, url from proyecto "
+ " where true"
+ " " + busqueda + " ";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
System.out.println("query: " + query);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next()) {
......@@ -69,7 +67,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
+ " " + busqueda + " ";
PreparedStatement pst2 = null;
ResultSet rs2 = null;
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query2);
rs = pst.executeQuery();
rs.next();
......@@ -100,7 +98,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
+ " set nom = '" + nombre + "', "
+ " url = '" + url + "' "
+ " where cod_proyecto = " + codigo + "";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -123,7 +121,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
query = " update proyecto "
+ " set est = 1 "
+ " where cod_proyecto = " + codigo + "";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -146,7 +144,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
query = " update proyecto "
+ " set est = 0 "
+ " where cod_proyecto = " + codigo + "";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -169,7 +167,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
ResultSet rsLlave = null;
String query = "";
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
con.setAutoCommit(false);
query = " insert into proyecto_detalle (cod_proyecto, cod_tipo_usuario, est) "
+ " values (" + proyecto + ", " + tipoUsuario + ", 1) ";
......@@ -212,15 +210,11 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
JSONArray lista = new JSONArray();
int conta = vstart;
try {
query = " select TOP " + vlength + " tu.nom, pd.est, pd.cod_proyecto_detalle from proyecto_detalle as pd "
query = " select tu.nom, pd.est, pd.cod_proyecto_detalle from proyecto_detalle as pd "
+ " inner join tipo_usuario as tu "
+ " on tu.cod_tipo_usuario = pd.cod_tipo_usuario "
+ " where cod_proyecto_detalle NOT IN "
+ " ( "
+ " SELECT top " + vstart + " "
+ " cod_proyecto_detalle from proyecto_detalle ORDER BY cod_proyecto_detalle) "
+ " and cod_proyecto = " + filtro + "";
con = SqlServerDAOFactory.getConnectionSQL(base);
+ " where cod_proyecto = " + filtro + " LIMIT " +vstart+", "+ vlength + ";";
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next()) {
......@@ -238,7 +232,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
+ " where cod_proyecto = " + filtro + " ";
PreparedStatement pst2 = null;
ResultSet rs2 = null;
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query2);
rs = pst.executeQuery();
rs.next();
......@@ -267,7 +261,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
try {
query = " insert into proyecto (nom, url, est)"
+ " values ('" + nombre + "', '" + url + "', 1) ";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -290,7 +284,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
query = " update proyecto_detalle "
+ " set est = 1 "
+ " where cod_proyecto_detalle = " + codigo + "";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -313,7 +307,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
query = " update proyecto_detalle "
+ " set est = 0 "
+ " where cod_proyecto_detalle = " + codigo + "";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -338,7 +332,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
+ " not in (select pd.cod_tipo_usuario from proyecto_detalle as pd "
+ " where pd.cod_proyecto = " + proyecto + ") "
+ " and est = 1 ";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next()) {
......@@ -366,7 +360,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
try {
query = " delete from proyecto_detalle "
+ " where cod_proyecto_detalle = " + codigoDetalle + "";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -396,7 +390,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
+ "where p.cod_proyecto = " + codigo + "\n"
+ "and ud.est = 1 ";
System.out.println("QUERY " + query);
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next()) {
......@@ -427,7 +421,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
if (tipo == 1) {
query += " and nom != '" + nombreActual + "' ";
}
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
rs.next();
......@@ -457,7 +451,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
if (tipo == 1) {
query += " and url != '" + urlActual + "' ";
}
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
rs.next();
......@@ -483,7 +477,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
query = " select count(*) as cant from usuario_detalle "
+ " where cod_proyecto_detalle = " + codigo + " "
+ " and est = 1 ";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
rs.next();
......@@ -508,7 +502,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
try {
query = " select count(*) as cant from titulo_configuracion "
+ " where cod_proyecto_detalle = " + codigo + "";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rsQuery = pst.executeQuery();
rsQuery.next();
......@@ -531,7 +525,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
ResultSet rsQuery = null;
String query = "";
try {
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
query = " delete from titulo_configuracion "
+ " where cod_proyecto_detalle = " + codigo + "";
pst = con.prepareStatement(query);
......@@ -567,7 +561,7 @@ public class ProyectoSqlServerDAO implements ProyectoDAO {
String sql = "";
ResponseHelper response = new ResponseHelper();
try {
con = SqlServerDAOFactory.getConnectionSQL("security");
con = MySQLDAOFactory.getConnectionSQL("security");
// con.setAutoCommit(false);
sql = " update usuario_detalle\n"
+ "set est = 0\n"
......
......@@ -3,13 +3,11 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mycompany.moduloseguridad.sqlserverdao;
package com.mycompany.moduloseguridad.mysqldao;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.mycompany.moduloseguridad.utilities.GeneralMethods;
import com.mycompany.moduloseguridad.dao.TipoUsuarioDAO;
import com.mycompany.moduloseguridad.utilities.DAOHelper;
......@@ -20,7 +18,7 @@ import org.json.JSONObject;
*
* @author sistem17user
*/
public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
public class TipoUsuarioMYSQLDAO implements TipoUsuarioDAO {
@Override
public JSONObject listarProyectos() throws Exception {
......@@ -35,7 +33,7 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
try {
query = "select cod_proyecto, nom from proyecto where proyecto.est = 1;";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next()) {
......@@ -74,7 +72,7 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
"inner join tipo_usuario on proyecto_detalle.cod_tipo_usuario = tipo_usuario.cod_tipo_usuario\n" +
"where proyecto_detalle.cod_proyecto = " + codigoProyecto;
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next()) {
......@@ -96,7 +94,7 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
}
@Override
public JSONObject listadoPrincipal(String filtro, int filtrado, int proyecto, int vstart, int vlength, String draw) throws Exception {
public JSONObject listadoPrincipal(String filtro, int filtrado, int proyecto, int vstart, int vlength, String draw, int estado) throws Exception {
String base = "security";
Connection cnx = null;
String query = "";
......@@ -106,8 +104,8 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
try {
cnx = SqlServerDAOFactory.getConnectionSQL(base);
String sql = "{CALL SP_TA_GESTIÓN_USUARIO(?,?,?,?,?,?,?,?,?,?)}";
cnx = MySQLDAOFactory.getConnectionSQL(base);
String sql = "{CALL SP_TA_GESTIÓN_USUARIO(?,?,?,?,?,?,?,?,?,?,?)}";
JSONArray params = new JSONArray()
.put(1)
......@@ -116,6 +114,7 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
.put(0)
.put(0)
.put(0)
.put(estado)
.put(vstart)
.put(vlength)
.put(String.class)
......@@ -146,8 +145,8 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
String mensaje = "";
try {
cnx = SqlServerDAOFactory.getConnectionSQL(base);
String sql = "{CALL SP_TA_GESTIÓN_USUARIO(?,?,?,?,?,?,?,?,?,?)}";
cnx = MySQLDAOFactory.getConnectionSQL(base);
String sql = "{CALL SP_TA_GESTIÓN_USUARIO(?,?,?,?,?,?,?,?,?,?,?)}";
JSONArray params = new JSONArray()
.put(3)
......@@ -158,6 +157,7 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
.put(0)
.put(0)
.put(0)
.put(0)
.put(String.class)
.put(Integer.class);
......@@ -177,17 +177,14 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
public JSONObject listarAcciones(JSONObject datos) throws Exception {
String base = "security";
Connection cnx = null;
String query = "";
JSONArray arrayjson = new JSONArray();
Connection cnx;
JSONArray arrayjson;
JSONObject response = new JSONObject();
int total = 0;
int total;
try {
cnx = SqlServerDAOFactory.getConnectionSQL(base);
String sql = "{CALL SP_TA_GESTIÓN_USUARIO(?,?,?,?,?,?,?,?,?,?)}";
cnx = MySQLDAOFactory.getConnectionSQL(base);
String sql = "{CALL SP_TA_GESTIÓN_USUARIO(?,?,?,?,?,?,?,?,?,?,?)}";
JSONArray params = new JSONArray()
.put(2)
.put(0)
......@@ -195,12 +192,12 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
.put(datos.getInt("proyectoDetalle"))
.put(0)
.put(0)
.put(0)
.put(datos.getInt("start"))
.put(datos.getInt("length"))
.put(String.class)
.put(Integer.class);
arrayjson = DAOHelper.queryProcedure(cnx, sql, params);
total = params.getInt(1);
......@@ -227,8 +224,8 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
try {
cnx = SqlServerDAOFactory.getConnectionSQL(base);
String sql = "{CALL SP_TA_GESTIÓN_USUARIO(?,?,?,?,?,?,?,?,?,?)}";
cnx = MySQLDAOFactory.getConnectionSQL(base);
String sql = "{CALL SP_TA_GESTIÓN_USUARIO(?,?,?,?,?,?,?,?,?,?,?)}";
JSONArray params = new JSONArray()
.put(4)
......@@ -239,6 +236,7 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
.put(datos.getInt("codigoAccionDetalle"))
.put(0)
.put(0)
.put(0)
.put(String.class)
.put(Integer.class);
......@@ -263,8 +261,8 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
try {
cnx = SqlServerDAOFactory.getConnectionSQL(base);
String sql = "{CALL SP_TA_GESTIÓN_USUARIO(?,?,?,?,?,?,?,?,?,?)}";
cnx = MySQLDAOFactory.getConnectionSQL(base);
String sql = "{CALL SP_TA_GESTIÓN_USUARIO(?,?,?,?,?,?,?,?,?,?,?)}";
JSONArray params = new JSONArray()
.put(5)
......@@ -275,6 +273,7 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
.put(0)
.put(0)
.put(0)
.put(0)
.put(String.class)
.put(Integer.class);
......@@ -302,7 +301,7 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
try {
query = "select *from accion;";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next()) {
......@@ -334,7 +333,7 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
query = " update tipo_usuario "
+ " set est = 1"
+ " where cod_tipo_usuario = " + codigo + " ";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -357,7 +356,7 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
query = " update tipo_usuario "
+ " set est = 0"
+ " where cod_tipo_usuario = " + codigo + " ";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -380,7 +379,7 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
query = " update tipo_usuario "
+ " set nom = '" + nombre + "'"
+ " where cod_tipo_usuario = " + codigo + " ";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -404,7 +403,7 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
// ResultSet rst = metadata.getColumns(null, null, "titulo", "nom");
query = " insert into tipo_usuario (nom, est)"
+ " values ('" + nombre + "', 1) ";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -432,7 +431,7 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
+ " on p.cod_proyecto = pd.cod_proyecto "
+ " where tu.cod_tipo_usuario = " + codigo + " "
+ " and p.est = 1 ";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
rs.next();
......@@ -461,7 +460,7 @@ public class TipoUsuarioSqlServerDAO implements TipoUsuarioDAO {
if (tipo == 1) {
query += " and nom != '" + nombreInicial + "' ";
}
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
rs.next();
......
......@@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mycompany.moduloseguridad.sqlserverdao;
package com.mycompany.moduloseguridad.mysqldao;
import java.sql.Connection;
import java.sql.PreparedStatement;
......@@ -18,7 +18,7 @@ import org.json.JSONObject;
*
* @author sistem17user
*/
public class UsuarioSqlServerDAO implements UsuarioDAO {
public class UsuarioMYSQLDAO implements UsuarioDAO {
@Override
public JSONArray listarUsuario(JSONObject datos, int vstart, int vlength, int draw) throws Exception {
......@@ -59,7 +59,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
+ " select cod_usuario, cod_trabajador, usu, est, cantidad from tablaOrdenada "
+ " where cantidad BETWEEN "+vstart+" and "+vlength*draw
+ " ORDER BY usu ASC";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
......@@ -117,7 +117,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
+ " LEFT JOIN proyecto_detalle AS pd ON pd.cod_proyecto_detalle = ud.cod_proyecto_detalle "
+ " WHERE 1 = 1 " + busqueda + " "
+ " GROUP BY a.cod_usuario ";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next()) {
......@@ -144,7 +144,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
+ " set usu = upper('" + usuario + "'),"
+ " con = '" + clave + "'"
+ " where cod_usuario = " + codigo + "";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -167,7 +167,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
query = " update usuario "
+ " set est = 1 "
+ " where cod_usuario = " + codigo + "";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -190,7 +190,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
query = " update usuario "
+ " set est = 0 "
+ " where cod_usuario = " + codigo + "";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
if (rs == 1) {
......@@ -198,7 +198,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
+ " set est = 0 "
+ " where cod_usuario = " + codigo;
}
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -220,7 +220,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
try {
query = " insert into usuario (cod_trabajador, usu, con, est) "
+ " values ('" + codigoTrabajador + "', upper('" + usuario + "'), '" + clave + "', 1) ";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -244,7 +244,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
query = " select count(*) as cant "
+ " from usuario "
+ " where cod_trabajador = '" + codigoTrabajador + "'";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
rs.next();
......@@ -268,7 +268,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
try {
query = " delete from usuario "
+ " where cod_usuario = " + codigo + "";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -299,7 +299,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
+ " inner join tipo_usuario as tu "
+ " on tu.cod_tipo_usuario = pd.cod_tipo_usuario "
+ " where ud.cod_usuario = " + filtro + "";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next()) {
......@@ -346,7 +346,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
try {
query = " delete from usuario_detalle "
+ " where cod_usuario_detalle = " + codigo + "";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -369,7 +369,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
query = " update usuario_detalle "
+ " set est = 1 "
+ " where cod_usuario_detalle = " + codigo + "";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -392,7 +392,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
query = " update usuario_detalle "
+ " set est = 0 "
+ " where cod_usuario_detalle = " + codigo + "";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -415,7 +415,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
query = " insert into usuario_detalle "
+ " (cod_usuario, cod_proyecto_detalle, est) "
+ " values(" + usuario + ", " + proyectoDetalle + ", 1) ";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeUpdate();
} catch (Exception e) {
......@@ -440,7 +440,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
+ "inner join proyecto as p "
+ "on p.cod_proyecto = pd.cod_proyecto "
+ "group by pd.cod_proyecto, p.nom ";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next()) {
......@@ -490,7 +490,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
+ " cod_proyecto = " + proyecto + " "
+ valid;
System.out.println("LISTADO TIPO USUARIO ---> " + query);
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
while (rs.next()) {
......@@ -519,7 +519,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
try {
query = " select count(*) as cant from usuario_detalle "
+ " where cod_usuario = " + codigo + " ";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
rs.next();
......@@ -544,7 +544,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
try {
query = " select count(*) as cant from usuario "
+ " where upper(usu) = upper('" + nombre + "')";
con = SqlServerDAOFactory.getConnectionSQL(base);
con = MySQLDAOFactory.getConnectionSQL(base);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
rs.next();
......@@ -569,7 +569,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
try {
query = " select count(*) as cant from auditoria "
+ " where cod_usuario_detalle = " + codigo + "";
con = SqlServerDAOFactory.getConnectionSQL(GeneralVariables.nameDB);
con = MySQLDAOFactory.getConnectionSQL(GeneralVariables.nameDB);
pst = con.prepareStatement(query);
rs = pst.executeQuery();
rs.next();
......@@ -603,7 +603,7 @@ public class UsuarioSqlServerDAO implements UsuarioDAO {
condicion = " where a.est = 1";
}
}
con = SqlServerDAOFactory.getConnectionSQL(GeneralVariables.nameDB);
con = MySQLDAOFactory.getConnectionSQL(GeneralVariables.nameDB);
sql = " SELECT a.cod_usuario, a.cod_trabajador, a.usu, a.est FROM usuario as a" + condicion;
pst = con.prepareStatement(sql);
rSet = pst.executeQuery();
......
......@@ -16,13 +16,13 @@ import org.json.JSONObject;
*/
public class MenuService {
DAOFactory fabrica = DAOFactory.getDAOFactory(DAOFactory.SQLSERVER);
DAOFactory fabrica = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
MenuDAO dao = fabrica.getMenuDAO();
public JSONArray listarProyecto() {
public JSONArray listarProyecto(int estado) {
JSONArray obj = null;
try {
obj = dao.listarProyecto();
obj = dao.listarProyecto(estado);
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -16,7 +16,7 @@ import org.json.JSONObject;
*/
public class ProyectoService {
DAOFactory fabrica = DAOFactory.getDAOFactory(DAOFactory.SQLSERVER);
DAOFactory fabrica = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
ProyectoDAO dao = fabrica.getProyectoDAO();
public JSONObject listarProyecto(JSONObject filtro, int vstart, int vlength, String draw) {
......
......@@ -15,7 +15,7 @@ import org.json.JSONObject;
*/
public class TipoUsuarioService {
DAOFactory fabrica = DAOFactory.getDAOFactory(DAOFactory.SQLSERVER);
DAOFactory fabrica = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
TipoUsuarioDAO dao = fabrica.getTipoUsuario();
public JSONObject listarProyectos() {
......@@ -23,7 +23,7 @@ public class TipoUsuarioService {
try {
obj = dao.listarProyectos();
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listado principal service" + e.getMessage());
}
return obj;
}
......@@ -33,7 +33,7 @@ public class TipoUsuarioService {
try {
obj = dao.listarTiposUsuarios(codigoProyecto);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listado principal service" + e.getMessage());
}
return obj;
}
......@@ -43,7 +43,7 @@ public class TipoUsuarioService {
try {
obj = dao.asignarAcciones(datos);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listado principal service" + e.getMessage());
}
return obj;
}
......@@ -53,7 +53,7 @@ public class TipoUsuarioService {
try {
obj = dao.listarAcciones(datos);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listado principal service" + e.getMessage());
}
return obj;
}
......@@ -63,7 +63,7 @@ public class TipoUsuarioService {
try {
obj = dao.listarCboAcciones();
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listado principal service" + e.getMessage());
}
return obj;
}
......@@ -73,7 +73,7 @@ public class TipoUsuarioService {
try {
obj = dao.activarDesactivarAccion(datos);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listado principal service" + e.getMessage());
}
return obj;
}
......@@ -83,17 +83,17 @@ public class TipoUsuarioService {
try {
obj = dao.activarDesactivarTipoUsuario(datos);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listado principal service" + e.getMessage());
}
return obj;
}
public JSONObject listadoPrincipal(String filtro,int filtrado, int proyecto, int vstart, int vlength, String draw) {
public JSONObject listadoPrincipal(String filtro,int filtrado, int proyecto, int vstart, int vlength, String draw, int estado) {
JSONObject obj = null;
try {
obj = dao.listadoPrincipal(filtro,filtrado, proyecto, vstart, vlength, draw);
obj = dao.listadoPrincipal(filtro,filtrado, proyecto, vstart, vlength, draw,estado);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listado principal service" + e.getMessage());
}
return obj;
}
......@@ -103,7 +103,7 @@ public class TipoUsuarioService {
try {
rs = dao.desactivarTipoUsuario(codigo);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listado principal service" + e.getMessage());
}
return rs;
}
......@@ -113,7 +113,7 @@ public class TipoUsuarioService {
try {
rs = dao.activarTipoUsuario(codigo);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listado principal service" + e.getMessage());
}
return rs;
}
......@@ -123,7 +123,7 @@ public class TipoUsuarioService {
try {
rs = dao.editarTipoUsuario(codigo, nombre);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listado principal service" + e.getMessage());
}
return rs;
}
......@@ -133,7 +133,7 @@ public class TipoUsuarioService {
try {
rs = dao.crearTipoUsuario(nombre);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listado principal service" + e.getMessage());
}
return rs;
}
......@@ -143,7 +143,7 @@ public class TipoUsuarioService {
try {
cant = dao.validarTipoUsuario(codigo);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listado principal service" + e.getMessage());
}
return cant;
}
......@@ -153,7 +153,7 @@ public class TipoUsuarioService {
try {
cant = dao.validarNombreTipoUsuario(nombreInicial, nombreIngreso, tipo);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error en listado principal service" + e.getMessage());
}
return cant;
}
......
......@@ -16,7 +16,7 @@ import org.json.JSONObject;
*/
public class UsuarioService {
DAOFactory fabrica = DAOFactory.getDAOFactory(DAOFactory.SQLSERVER);
DAOFactory fabrica = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
UsuarioDAO dao = fabrica.getUsuarioDAO();
public JSONArray listarUsuario(JSONObject datos, int vstart, int vlength, int draw) {
......
......@@ -67,6 +67,7 @@ public class MantenimientoMenuServlet extends HttpServlet {
break;
default:
break;
}
}
......@@ -74,7 +75,8 @@ public class MantenimientoMenuServlet extends HttpServlet {
response.setContentType("application/json");
PrintWriter out = response.getWriter();
MenuService srv = new MenuService();
JSONArray rs = srv.listarProyecto();
int estado = Integer.parseInt(request.getParameter("estado"));
JSONArray rs = srv.listarProyecto(estado);
out.println(rs);
}
......@@ -104,6 +106,7 @@ public class MantenimientoMenuServlet extends HttpServlet {
int iModulo = 0;
JSONObject obj1 = new JSONObject();
JSONObject objTitulo = (JSONObject) listaTitulo.get(i);
System.out.println("objTitulo "+i + " : "+ objTitulo);
String nombreTitulo = objTitulo.getString("nombreTitulo");
int codigoTitulo = objTitulo.getInt("codigoTitulo");
int configuracionTitulo = objTitulo.getInt("configuracionTitulo");
......@@ -126,6 +129,7 @@ public class MantenimientoMenuServlet extends HttpServlet {
int iCategoria = 0;
JSONObject obj2 = new JSONObject();
JSONObject objModulo = (JSONObject) listaModulo.get(j);
System.out.println("objModulo "+i + " - "+j+" : "+ objModulo);
boolean esVisible = objModulo.getBoolean("esVisible");
String nombreModulo = objModulo.getString("nombreModulo");
int codigoModulo = objModulo.getInt("codigoModulo");
......
......@@ -159,12 +159,13 @@ public class TipoUsuarioServlet extends HttpServlet {
String filtro = request.getParameter("filtro");
int filtrado = Integer.parseInt(request.getParameter("filtrado"));
int cboProyecto = Integer.parseInt(request.getParameter("valorCboProyecto"));
int estado = Integer.parseInt(request.getParameter("estado"));
String draw = request.getParameter("draw");
int vstart = Integer.parseInt(request.getParameter("start"));
int vlength = Integer.parseInt(request.getParameter("length"));
JSONObject json = service.listadoPrincipal(filtro, filtrado, cboProyecto, vstart, vlength, draw);
JSONObject json = service.listadoPrincipal(filtro, filtrado, cboProyecto, vstart, vlength, draw,estado);
out.println(json);
}
......
......@@ -124,7 +124,7 @@ public class UsuarioServlet extends HttpServlet {
JSONObject obj = json.getJSONObject(i);
String codigoTrabajador = obj.getString("codigoTrabajador");
JSONObject prs = listarPersonalPorCodigo(codigoTrabajador);
if(!prs.isEmpty()){
objeto.put("codigoUsuario", obj.getInt("codigoUsuario"));
objeto.put("numeral", obj.getInt("numeral"));
objeto.put("usuario", obj.getString("usuario"));
......@@ -133,9 +133,9 @@ public class UsuarioServlet extends HttpServlet {
objeto.put("nombreCargo", prs.getString("nom_car"));
objeto.put("nombreUsuario", prs.getString("nom_per") + " " + prs.getString("ape_pat_per") + " " + prs.getString("ape_mat_per"));
objeto.put("nombreSede", prs.getString("nom_sed"));
lista.put(objeto);
}
}
int cantidad = srv.cantidadRegistros(filtro);
retorno.put("data", lista);
retorno.put("draw", draw);
......@@ -212,7 +212,7 @@ public class UsuarioServlet extends HttpServlet {
PrintWriter out = response.getWriter();
String tipoDocumento = request.getParameter("tipoDocumento");
String numeroDocumento = request.getParameter("numeroDocumento");
JSONObject rs = listarPersonalPorTipoDocNumDoc(tipoDocumento, numeroDocumento, "1");
JSONObject rs = listarPersonalPorTipoDocNumDoc(tipoDocumento, numeroDocumento);
out.println(rs);
}
......@@ -338,12 +338,12 @@ public class UsuarioServlet extends HttpServlet {
out.println(rs);
}
private JSONObject listarPersonalPorTipoDocNumDoc(java.lang.String tipoDocumento, java.lang.String numeroDocumento, java.lang.String estado) throws IOException {
private JSONObject listarPersonalPorTipoDocNumDoc(String tipoDocumento, String numeroDocumento) throws IOException {
JSONObject respuesta = null;
JSONObject obj = new JSONObject()
.put("tipoDocumento", tipoDocumento)
.put("numeroDocumento", numeroDocumento)
.put("estado", estado);
.put("estado", "1");
HttpRequest httpRequest = new HttpRequest();
String r = httpRequest.getRespuesta(RequestPath.listarPersonalPorTipoDocNumDoc, HttpRequest.POST, obj, "");//Respuesta del server
respuesta = new JSONObject(r);
......@@ -376,30 +376,32 @@ public class UsuarioServlet extends HttpServlet {
JSONObject obj = lista.getJSONObject(i);
String codigoTrabajador = obj.getString("codigoTrabajador");
JSONObject prs = listarPersonalPorCodigo(codigoTrabajador);
String nombreCompleto = prs.getString("nomPer") + " " + prs.getString("apePatPer") + " " + prs.getString("apeMatPer");
String cargo = prs.getString("nomCar");
if (!prs.isEmpty()) {
String nombreCompleto = prs.getString("nom_per") + " " + prs.getString("ape_pat_per") + " " + prs.getString("ape_mat_per");
String cargo = prs.getString("nom_car");
if (tipo == 4 && (nombreCompleto.toUpperCase()).contains(busqueda.toUpperCase())) {
_final.put("codigoUsuario", obj.getInt("codigoUsuario"));
_final.put("numeral", obj.getInt("numeral"));
_final.put("usuario", obj.getString("usuario"));
_final.put("estadoUsuario", obj.getInt("estadoUsuario"));
_final.put("nombreArea", prs.getString("nomAre"));
_final.put("nombreCargo", prs.getString("nomCar"));
_final.put("nombreUsuario", prs.getString("nomPer") + " " + prs.getString("apePatPer") + " " + prs.getString("apeMatPer"));
_final.put("nombreSede", prs.getString("nomSed"));
_final.put("nombreArea", prs.getString("nom_are"));
_final.put("nombreCargo", prs.getString("nom_car"));
_final.put("nombreUsuario", prs.getString("nom_per") + " " + prs.getString("ape_pat_per") + " " + prs.getString("ape_mat_per"));
_final.put("nombreSede", prs.getString("nom_sed"));
listaFinal.put(_final);
} else if (tipo == 5 && (cargo.toUpperCase()).equals(busqueda.toUpperCase())) {
} else if (tipo == 5 && (cargo).equalsIgnoreCase(busqueda)) {
_final.put("codigoUsuario", obj.getInt("codigoUsuario"));
_final.put("numeral", obj.getInt("numeral"));
_final.put("usuario", obj.getString("usuario"));
_final.put("estadoUsuario", obj.getInt("estadoUsuario"));
_final.put("nombreArea", prs.getString("nomAre"));
_final.put("nombreCargo", prs.getString("nomCar"));
_final.put("nombreUsuario", prs.getString("nomPer") + " " + prs.getString("apePatPer") + " " + prs.getString("apeMatPer"));
_final.put("nombreSede", prs.getString("nomSed"));
_final.put("nombreArea", prs.getString("nom_are"));
_final.put("nombreCargo", prs.getString("nom_car"));
_final.put("nombreUsuario", prs.getString("nom_per") + " " + prs.getString("ape_pat_per") + " " + prs.getString("ape_mat_per"));
_final.put("nombreSede", prs.getString("nom_sed"));
listaFinal.put(_final);
}
}
}
out.println(listaFinal);
}
......@@ -413,10 +415,12 @@ public class UsuarioServlet extends HttpServlet {
for (int i = 0; i < lista.length(); i++) {
JSONObject obj = lista.getJSONObject(i);
JSONObject prs = listarPersonalPorCodigo(obj.getString("codigoTrabajador"));
if(!prs.isNull("nom_car")){
if (!cargos.contains(prs.getString("nom_car"))) {
cargos.add(prs.getString("nom_car"));
}
}
}
out.print(new JSONArray(cargos));
}
}
\ No newline at end of file
......@@ -82,13 +82,14 @@ public final class DAOHelper {
JSONArray result = new JSONArray();
JSONObject outputParamTypes = new JSONObject();
JSONArray params = null;
JSONArray outputParams = new JSONArray();
try (CallableStatement cs = cn.prepareCall(query);){
if (parameters != null && parameters.length > 0) {
params = parameters[0];
int index = 1;
for (Object parameter : params) {
if (parameter instanceof Class) {
outputParams.put(index);
registerOutputParameter(cs, index++, parameter, outputParamTypes);
} else {
setPreparedStatement(cs, index++, parameter);
......@@ -96,7 +97,7 @@ public final class DAOHelper {
}
}
boolean isResultSet = cs.execute();
System.out.println("CONSULTA\n" + cs.toString());
if (isResultSet) {
try(final ResultSet rs = cs.getResultSet()){
ResultSetMetaData rm = rs.getMetaData();
......@@ -116,18 +117,21 @@ public final class DAOHelper {
result.put(obj);
}
if (outputParamTypes.length() > 0) {
if (!outputParamTypes.isEmpty()) {
clearJSONArray(params);
}
for (String key : outputParamTypes.keySet()) {
int indexOutputParams = Integer.parseInt(key);
int type = outputParamTypes.getInt(key);
getOutputParameter(cs, indexOutputParams, type, params);
JSONArray finalParams = params;
outputParams.forEach((index) -> {
int type = outputParamTypes.getInt(String.valueOf(index));
try {
getOutputParameter(cs, (Integer) index, type, finalParams);
} catch (SQLException e) {
throw new RuntimeException(e);
}
System.out.println("CONSULTA\n" + cs.toString());
});
} catch (Exception ex) {
ex.printStackTrace();
System.out.println(""+ex.getMessage());
System.out.println(ex.getMessage());
}
return result;
}
......@@ -337,12 +341,9 @@ public final class DAOHelper {
private static void getOutputParameter(CallableStatement cs, int cont, int tipo, JSONArray parameter) throws SQLException {
switch (tipo) {
case Types.INTEGER:
case Types.NUMERIC:
parameter.put(cs.getInt(cont));
break;
case Types.VARCHAR:
case Types.CHAR:
parameter.put(cs.getString(cont));
break;
case Types.BOOLEAN:
parameter.put(cs.getBoolean(cont));
break;
......
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mycompany.moduloseguridad.utilities;
import java.io.BufferedReader;
......@@ -12,12 +7,10 @@ import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import org.json.JSONObject;
/**
*
* @author Percy Oliver Quispe Huarcaya
*/
public final class HttpRequest {
public static final String POST = "POST";
......@@ -47,19 +40,19 @@ public final class HttpRequest {
}
public String getRespuesta(String path, String requestMethod, JSONObject obj, String authorization) throws IOException {
String respuesta = "";
StringBuilder respuesta = new StringBuilder();
URL url = getConn(path);
HttpURLConnection conn = setDefaultValues(url, requestMethod, authorization);
OutputStream os = conn.getOutputStream();
os.write(obj.toString().getBytes("UTF-8"));
os.write(obj.toString().getBytes(StandardCharsets.UTF_8));
os.close();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
String linea;
while ((linea = rd.readLine()) != null) {
respuesta += linea;
respuesta.append(linea);
}
rd.close();
conn.disconnect();
return respuesta;
return respuesta.toString();
}
}
\ No newline at end of file
......@@ -65,7 +65,7 @@ span .error{
}
.password{
font-family: password;
font-family: password, serif;
font-size: 16px;
}
......@@ -150,13 +150,13 @@ label {
}
.row {
padding-left: 0px;
padding-right: 0px;
padding-left: 0;
padding-right: 0;
}
.datatable-scroll{
border-top: 1px solid #bbbbbb9c;
border-bottom: 0px;
border-bottom: 0;
}
.panel-heading .visible-elements {
......@@ -170,7 +170,7 @@ label {
.dataTables_info {
float: left;
padding: 13px 0;
margin-bottom: 0px;
margin-bottom: 0;
}
.tp-animation-button{
......@@ -269,7 +269,7 @@ a.disabled {
padding: 8px 10px;
background: white;
border-top: 1px solid #e7eaec;
margin-left: 0px;
margin-left: 0;
font-size: 11px;
text-align: center;
}
......@@ -290,10 +290,10 @@ a.disabled {
}
.panel {
margin-bottom: 0px !important;
margin-bottom: 0 !important;
}
.row {
margin-left: 0px;
margin-left: 0;
}
table.display tbody tr:hover td {
......@@ -301,15 +301,15 @@ table.display tbody tr:hover td {
}
.modulo {
padding-left: 120px;
padding-left: 5vw;
}
.categoria{
padding-left: 240px;
padding-left: 10vw;
}
.subcategoria{
padding-left: 360px;
padding-left: 15vw;
}
.modal-header[class*=bg-] {
......
......@@ -23,6 +23,9 @@
type: 'POST',
url: "../servlet/MantenimientoMenuServlet?accion=listarProyecto",
dataType: 'JSON',
data: {
estado: document.getElementById("cbkEstado").checked ? 1 : 0
},
success: function (result) {
var print = " <option value=''>SELECCIONE PROYECTO</option> ";
for (var i in result) {
......@@ -100,7 +103,6 @@
"bFilter": false,
"serverSide": true,
"processing": true,
"aaSorting": [],
"ordering": false,
"bLengthChange": false,
"bInfo": false,
......@@ -112,11 +114,11 @@
],
"iDisplayLength": -1,
"columnDefs": [
{targets: 0, orderable: false, width: "45%"},
{targets: 1, orderable: false, width: "5%", className: "text-center"},
{targets: 2, orderable: false, width: "7%", className: "text-center"},
{targets: 3, orderable: false, width: "10%"},
{targets: 4, orderable: false, width: "15%", className: "text-center"}
{targets: 0, orderable: false, width: "65%"},
{targets: 1, orderable: false, width: "7,5%", className: "text-center"},
{targets: 2, orderable: false, width: "7.5%", className: "text-center"},
{targets: 3, orderable: false, width: "5%", },
{targets: 4, orderable: false, width: "15%",className: "text-center"}
],
"columns": [
{"data": "jerarquia",
......@@ -181,7 +183,11 @@
}
], initComplete: function (nopor, data) {
$("#tblMenu").addClass("table table-responsive table-striped table-hover table-bordered");
}, rowCallback: function (row, data) {
if(data.esVisible === false){
$(row).css("background-color","#ffeaea");
}
},
});
} else {
table = $("#tblMenu").DataTable();
......@@ -292,9 +298,12 @@
</label>
<input id="chkVisible" name="chkEsVisible" class="icp-opts form-control switch" type="checkbox"/>
</div>
<div class='col-md-12 hide' id="formHide">
&nbsp;
<div class="frm col-md-12" id ="formPermisos">
<span>Permisos</span>
<table id="tablaPermisosVista">
</table>
</div>
</div>
<div class="col-md-12 pull-right form-group">
<div class="text-right" style="font-size: small">
......@@ -354,7 +363,7 @@
validarDependenciaEditar(data);
}
if(visible){
if(!visible){
$("#chkVisible").prop("checked", true);
}else{
$("#chkVisible").removeAttr("checked");
......@@ -443,7 +452,7 @@
"url": txturl,
"nombre": $('#editarNombre').val(),
"icono": $('#editarIcono').val(),
"esVisible": $("#chkVisible").is(':checked')
"esVisible": !$("#chkVisible").is(':checked')
};
$.ajax({
type: 'POST',
......@@ -1459,5 +1468,3 @@
});
}
};
\ No newline at end of file
......@@ -85,7 +85,7 @@
"bLengthChange": false,
"bInfo": true,
"paging": true,
"iDisplayLength": 5,
"iDisplayLength": 10,
"columnDefs": [
{targets: 0, orderable: false, width: "7%", className: "text-center"},
{targets: 1, orderable: false, width: "30%", className: "text-left"},
......@@ -248,7 +248,8 @@
var json = {
"filtro": filtro,
"filtrado":tipoFiltrado,
"valorCboProyecto":cboProyecto
"valorCboProyecto":cboProyecto,
"estado": document.getElementById('cbkEstado').checked ? 0 : 1
};
tabla = $("#tblTipoUsuario").DataTable({
......
......@@ -25,7 +25,7 @@
cursor: pointer;
background-color: green;
border-radius: 25px;
transition: all 1s;
transition: all 0.5s;
}
.switch:before{
content: "";
......@@ -40,11 +40,11 @@
transition-delay: .1s;
box-shadow: inset 2px 0px 4px rgba(0,0,0,.5),
-2px 0px 2px rgba(0,0,0,.5);
animation: off 1s forwards;
animation: off 0.5s forwards;
}
.switch:checked{
background-color: white;
transition: all 1s;
background-color: #e70000;
transition: all 0.5s;
}
.switch:checked:before{
transition: all .5s;
......@@ -54,7 +54,7 @@
2px 0px 2px rgba(0,0,0,.5);
transition-delay: .1s;
right: 43px;
animation: on 1s forwards;
animation: on 0.5s forwards;
}
@keyframes on{
......@@ -84,9 +84,12 @@
<div class="panel-heading" style="padding: 8px 15px">
<h6 class="panel-title" style="font-size: 15px; font-family: inherit"><i class="icon icon-search4"></i>&nbsp; Búsqueda de Menús</h6>
<div class="heading-elements">
<ul class="icons-list">
<li><a data-action="collapse"></a></li>
</ul>
<div class="checkbox checkbox-switchery">
<label>
<span id="txtEstado"></span>
<input type="checkbox" id="cbkEstado">
</label>
</div>
</div>
</div>
<div class="panel-body" id="panelSearch">
......@@ -95,7 +98,7 @@
<div class='col-md-6'>
<div class="form-group">
<label> Proyecto: </label>
<span id="spanAterik" class="asterisk">(*)</span>
<span class="asterisk">(*)</span>
<select id="cboProyecto" class="form-control">
<option value="">SELECCIONE PROYECTO</option>
</select>
......@@ -104,7 +107,7 @@
<div class='col-md-6'>
<div class="form-group">
<label>Tipo de Usuario: </label>
<span id="spanAterik" class="asterisk">(*)</span>
<span class="asterisk">(*)</span>
<select id="cboTipoUsuario" class="form-control">
<option value="">SELECCIONE TIPO DE USUARIO</option>
</select>
......@@ -113,7 +116,15 @@
</div>
</form>
<div class="row">
<div class="col-md-12">
<div class="col-md-12" style="display: flex; justify-content: space-between">
<div class="form-group">
<div class="text-left" style="display: flex; justify-content: center; align-items: center; gap: 1rem;">
<div>
No visibles :
</div>
<div style="background: #ffeaea; width: 1rem; height: 1rem; border: 1px solid black; display: block"></div>
</div>
</div>
<div class="form-group">
<div class="text-right">
<span class="text-danger">(*) </span> Campo obligatorio
......@@ -133,7 +144,7 @@
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-10 col-centered">
<div class="col-sm-12 col-md-12 col-lg-11 col-centered">
<div class="panel panel-primary card-3 hide" style="margin-top: 30px" id="panelTabla">
<div class="panel-heading" style="padding: 8px 15px">
<h6 class="panel-title" style="font-size: 15px; font-family: inherit"><i class="fa fa-list"></i>&nbsp; Listado del Menu</h6>
......@@ -157,10 +168,23 @@
</div>
</div>
</div>
<!-- / content -->
<%@include file="templates/footer-body.jsp" %>
<!--js-->
<script src="../js/pages/MantenimientoMenu.js" type="text/javascript"></script>
<!--js-->
<script>
let switchery = new Switchery(document.querySelector('#cbkEstado'), {color: 'red', secondaryColor: 'green'})
document.querySelector('#txtEstado').innerText = 'MOSTRANDO ACTIVOS';
document.querySelector('#cbkEstado').checked = false;
document.querySelector('#cbkEstado').onchange = function () {
if (document.querySelector('#cbkEstado').checked) {
document.querySelector('#txtEstado').innerText = 'MOSTRANDO INACTIVOS';
} else {
document.querySelector('#txtEstado').innerText = 'MOSTRANDO ACTIVOS';
}
listarProyectos();
document.querySelector('#btnLimpiar').click();
};
</script>
</body>
</html>
\ No newline at end of file
......@@ -25,9 +25,12 @@
<div class="panel-heading" style="padding: 8px 15px">
<h6 class="panel-title" style="font-size: 15px; font-family: inherit"><i class="icon icon-search4"></i>&nbsp; Búsqueda de Tipos de Usuario</h6>
<div class="heading-elements">
<ul class="icons-list">
<li><a data-action="collapse"></a></li>
</ul>
<div class="checkbox checkbox-switchery">
<label>
<span id="txtEstado"></span>
<input type="checkbox" id="cbkEstado">
</label>
</div>
</div>
</div>
<div class="panel-body" id="panelSearch">
......@@ -108,6 +111,19 @@
<!--js-->
<script src="../js/lib/jquery-editable-select.min.js" type="text/javascript"></script>
<script src="../js/pages/tipoUsuario.js" type="text/javascript"></script>
<script>
let switchery = new Switchery(document.querySelector('#cbkEstado'), {color: 'red', secondaryColor: 'green'})
document.querySelector('#txtEstado').innerText = 'MOSTRANDO ACTIVOS';
document.querySelector('#cbkEstado').checked = false;
document.querySelector('#cbkEstado').onchange = function () {
if (document.querySelector('#cbkEstado').checked) {
document.querySelector('#txtEstado').innerText = 'MOSTRANDO INACTIVOS';
} else {
document.querySelector('#txtEstado').innerText = 'MOSTRANDO ACTIVOS';
}
document.querySelector('#btnBuscar').click();
};
</script>
<!--js-->
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment