Skip to content

Commit

Permalink
Antes de cambio del libro
Browse files Browse the repository at this point in the history
  • Loading branch information
rrruuuyyy committed Mar 26, 2020
1 parent 7afb316 commit 4006dcb
Show file tree
Hide file tree
Showing 13 changed files with 467 additions and 79 deletions.
Binary file removed public/calculos/Ingresos_Egresos_Agosto_2019.xlsx
Binary file not shown.
Binary file removed public/calculos/Ingresos_Egresos_Octubre_2019.xlsx
Binary file not shown.
Binary file not shown.
19 changes: 19 additions & 0 deletions src/config/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@ class db{
private $base = 'conta-express';


// Conectar a BD
public function connect(){
$conexion_mysql = "mysql:host=$this->host;dbname=$this->base";
$conexionDB = new PDO($conexion_mysql, $this->usuario, $this->password,[]);
$conexionDB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

//Esta linea arregla la codificacion sino no aparecen en la salida en JSON quedan NULL
$conexionDB -> exec("set names utf8");
return $conexionDB;
}
}
class db_sat{
// Variables de conexión
private $host = 'localhost';
private $usuario = 'root';
private $password = '';
private $base = 'catalogo_sat';


// Conectar a BD
public function connect(){
$conexion_mysql = "mysql:host=$this->host;dbname=$this->base";
Expand Down
1 change: 1 addition & 0 deletions src/config/xml_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public static function obtener($archivo_xml){
$CFDI->Otros = (object)[];
$Conceptos = [];
$UUID_vinculados = [];
error_reporting(0);
$xml = simplexml_load_file( $archivo_xml );
// if( $xml === false ){
// return false;
Expand Down
74 changes: 74 additions & 0 deletions src/routes/busqueda_catalogo_sat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
//Obtener todos los clientes
$app->post('/api/busqueda_catalogo/producto_servicio', function(Request $request, Response $response){
$busqueda = $request->getParam('busqueda');
// Verificacion del token
// $auth = new Auth();
// $token = $auth->Check($token);
// if($token['status'] === false){
// echo json_encode($token);
// return;
// }
// Fin Verificacion
$consulta = "SELECT * FROM producto_servicio WHERE id LIKE '%{$busqueda}%' OR descripcion LIKE '%{$busqueda}%' OR palabrasSimilares LIKE '%{$busqueda}%' ";
try{
// Instanciar la base de datos
$db = new db_sat();

// Conexión
$db = $db->connect();
$ejecutar = $db->query($consulta);
$clientes = $ejecutar->fetchAll(PDO::FETCH_OBJ);
$db = null;

//Exportar y mostrar en formato JSON
$mensaje = array(
'status' => true,
'mensaje' => 'Catalogo productos y servicios cargados',
'rest' => $clientes
);
echo json_encode($mensaje);
return;
} catch(PDOException $e){
$mensaje = array(
'status' => false,
'mensaje' => 'Error al cargar productos y servicios',
'error' => $e->getMessage()
);
echo json_encode($mensaje);
return;
}
});
$app->post('/api/busqueda_catalogo/unidades_medida', function(Request $request, Response $response){
$busqueda = $request->getParam('busqueda');
$consulta = "SELECT * FROM clave_unidad WHERE id LIKE '%{$busqueda}%' OR nombre LIKE '%{$busqueda}%' ";
try{
// Instanciar la base de datos
$db = new db_sat();

// Conexión
$db = $db->connect();
$ejecutar = $db->query($consulta);
$unidades = $ejecutar->fetchAll(PDO::FETCH_OBJ);
$db = null;

//Exportar y mostrar en formato JSON
$mensaje = array(
'status' => true,
'mensaje' => 'Catalogo undades de medida cargados',
'rest' => $unidades
);
echo json_encode($mensaje);
return;
} catch(PDOException $e){
$mensaje = array(
'status' => false,
'mensaje' => 'Error al cargar unidades de medida',
'error' => $e->getMessage()
);
echo json_encode($mensaje);
return;
}
});
42 changes: 42 additions & 0 deletions src/routes/cliente_cliente.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
//Obtener todos los clientes
$app->post('/api/clientes_cliente/get', function(Request $request, Response $response){
$idcliente = $request->getParam('idcliente');
$token = $request->getParam('token');
// Verificacion del token
// $auth = new Auth();
// $token = $auth->Check($token);
// if($token['status'] === false){
// echo json_encode($token);
// return;
// }
// Fin Verificacion
$consulta = "SELECT * FROM cliente_cliente WHERE idcliente='$idcliente'";
try{
// Instanciar la base de datos
$db = new db();

// Conexión
$db = $db->connect();
$ejecutar = $db->query($consulta);
$clientes = $ejecutar->fetchAll(PDO::FETCH_OBJ);
$db = null;

//Exportar y mostrar en formato JSON
$mensaje = array(
'status' => true,
'mensaje' => 'Clientes cargados correctamente',
'rest' => $clientes
);
return json_encode($mensaje);
} catch(PDOException $e){
$mensaje = array(
'status' => false,
'mensaje' => 'Error al cargar clientes',
'error' => $e->getMessage()
);
return json_encode($mensaje);
}
});
79 changes: 0 additions & 79 deletions src/routes/index.html

This file was deleted.

Loading

0 comments on commit 4006dcb

Please sign in to comment.