Skip to content

Commit 3dcedf4

Browse files
committed
Initial commit
0 parents  commit 3dcedf4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+11072
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
composer.phar
2+
/vendor/
3+
4+
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
5+
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
6+
# composer.lock
7+
env.php
8+
/logs/

.htaccess

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Rules to serve URLs which point to files directly
2+
# ----------
3+
RewriteEngine On
4+
#RewriteBase /
5+
RewriteCond %{REQUEST_FILENAME} !-f
6+
RewriteCond %{REQUEST_FILENAME} !-d
7+
RewriteRule ^(.*)$ ./index.php/$1 [L]

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Luis Cabrera Benito
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# sistema-pagos
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
namespace Parzibyte\Controladores;
3+
4+
use Parzibyte\Modelos\ModeloAjustes;
5+
6+
class ControladorAjustes
7+
{
8+
public static function index()
9+
{
10+
return view("ajustes");
11+
}
12+
13+
public static function guardarMuchos($ajustes)
14+
{
15+
$ajustes = json_decode(file_get_contents("php://input"));
16+
return json(ModeloAjustes::guardarMuchos($ajustes));
17+
}
18+
19+
public static function obtenerTodos()
20+
{
21+
return json(ModeloAjustes::obtenerTodos());
22+
}
23+
24+
}
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Parzibyte\Controladores;
4+
5+
use Parzibyte\Modelos\ModeloUsuarios;
6+
use Parzibyte\Servicios\SesionService;
7+
8+
class ControladorLogin
9+
{
10+
11+
public static function index()
12+
{
13+
return view("login");
14+
}
15+
16+
public static function login()
17+
{
18+
$datos = json_decode(file_get_contents("php://input"));
19+
return json(ModeloUsuarios::login($datos->correo, $datos->palabraSecreta));
20+
}
21+
public static function logout()
22+
{
23+
SesionService::destruir();
24+
redirect("/login");
25+
}
26+
}
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace Parzibyte\Controladores;
4+
5+
use Parzibyte\Modelos\ModeloPagos;
6+
7+
class ControladorPagos
8+
{
9+
10+
public static function index()
11+
{
12+
return view("pagos/pagos");
13+
}
14+
15+
public static function actualizar()
16+
{
17+
$datos = json_decode(file_get_contents("php://input"));
18+
$resultado = ModeloPagos::actualizar($datos->id, $datos->idPersona, $datos->monto, $datos->fecha);
19+
return json($resultado);
20+
}
21+
22+
public static function agregar()
23+
{
24+
$datos = json_decode(file_get_contents("php://input"));
25+
$resultado = ModeloPagos::agregar($datos->idPersona, $datos->monto, $datos->fecha);
26+
return json($resultado);
27+
}
28+
29+
public static function eliminar($idPago)
30+
{
31+
return json(ModeloPagos::eliminar($idPago));
32+
}
33+
34+
public static function obtener()
35+
{
36+
return json([
37+
"pagos" => ModeloPagos::obtener(),
38+
"total" => ModeloPagos::total(),
39+
]);
40+
}
41+
42+
}
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Parzibyte\Controladores;
4+
5+
use Parzibyte\Modelos\ModeloPersonas;
6+
7+
class ControladorPersonas
8+
{
9+
10+
public static function index()
11+
{
12+
return view("personas");
13+
}
14+
15+
public static function actualizar()
16+
{
17+
$datos = json_decode(file_get_contents("php://input"));
18+
return json(ModeloPersonas::actualizar($datos->nombre, $datos->id));
19+
}
20+
21+
public static function agregar()
22+
{
23+
$datos = json_decode(file_get_contents("php://input"));
24+
return json(ModeloPersonas::agregar($datos->nombre));
25+
}
26+
27+
public static function eliminar($idPersona)
28+
{
29+
return json(ModeloPersonas::eliminar($idPersona));
30+
}
31+
32+
public static function obtener()
33+
{
34+
return json(ModeloPersonas::obtener());
35+
}
36+
37+
}
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
namespace Parzibyte\Controladores;
3+
4+
use Exception;
5+
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
6+
use Mike42\Escpos\Printer;
7+
use Parzibyte\Modelos\ModeloPagos;
8+
use Parzibyte\Servicios\Comun;
9+
10+
class ControladorTickets
11+
{
12+
public static function imprimirTicketDePago($idPago)
13+
{
14+
try {
15+
$nombreImpresora = Comun::env("NOMBRE_IMPRESORA");
16+
} catch (Exception $e) {
17+
return false;
18+
}
19+
$connector = new WindowsPrintConnector($nombreImpresora);
20+
$printer = new Printer($connector);
21+
$pago = ModeloPagos::obtenerPorId($idPago);
22+
if (!$pago) {
23+
return false;
24+
}
25+
$repeticiones = 20;
26+
$printer->setTextSize(2, 2);
27+
$printer->text("Comprobante");
28+
$printer->feed();
29+
$printer->setTextSize(1, 1);
30+
$printer->text(str_repeat("=", $repeticiones));
31+
$printer->feed();
32+
$printer->text("Nombre: " . $pago->persona);
33+
$printer->feed();
34+
$printer->text("Monto: $" . number_format($pago->monto, 2, ".", ","));
35+
$printer->feed();
36+
$printer->text("Fecha: " . $pago->fecha);
37+
$printer->feed();
38+
$printer->text("Hash: " . $pago->hash);
39+
$printer->feed();
40+
$printer->text(str_repeat("=", $repeticiones));
41+
$printer->feed();
42+
43+
$printer->feed();
44+
$printer->text("Total abonado por ti: $" . number_format(ModeloPagos::totalDePersona($pago->idPersona), 2, ".", ","));
45+
$printer->feed();
46+
$printer->text("Total abonado por todos: $" . number_format(ModeloPagos::total(), 2, ".", ","));
47+
$printer->feed(2);
48+
$printer->text("(Calculados en la fecha de impreso este ticket)");
49+
50+
$printer->feed(5);
51+
$printer->cut();
52+
$printer->pulse();
53+
$printer->close();
54+
return true;
55+
}
56+
}
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Parzibyte\Controladores;
4+
5+
use Parzibyte\Modelos\ModeloUsuarios;
6+
7+
class ControladorUsuarios
8+
{
9+
10+
public static function index()
11+
{
12+
return view("usuarios");
13+
}
14+
15+
public static function actualizarPalabraSecreta()
16+
{
17+
$datos = json_decode(file_get_contents("php://input"));
18+
return json(ModeloUsuarios::actualizarPalabraSecreta($datos->id, $datos->palabraSecretaActual));
19+
}
20+
21+
public static function agregar()
22+
{
23+
$datos = json_decode(file_get_contents("php://input"));
24+
return json(ModeloUsuarios::agregar($datos->correo, $datos->palabraSecreta));
25+
}
26+
27+
public static function eliminar($idUsuario)
28+
{
29+
return json(ModeloUsuarios::eliminar($idUsuario));
30+
}
31+
32+
public static function obtener()
33+
{
34+
return json(ModeloUsuarios::obtener());
35+
}
36+
37+
}

app/Modelos/ModeloAjustes.php

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
namespace Parzibyte\Modelos;
3+
4+
use Parzibyte\Servicios\BD;
5+
use PDO;
6+
7+
class ModeloAjustes
8+
{
9+
public static function guardarMuchos($ajustes)
10+
{
11+
$bd = BD::obtener();
12+
$sentencia = $bd->prepare("update comun set valor = ? where clave = ?");
13+
$bd->beginTransaction();
14+
foreach ($ajustes as $ajuste) {
15+
$sentencia->execute([$ajuste->valor, $ajuste->clave]);
16+
}
17+
return $bd->commit();
18+
}
19+
20+
public static function obtenerTodos()
21+
{
22+
$bd = BD::obtener();
23+
$sentencia = $bd->query("select clave, valor from comun");
24+
return $sentencia->fetchAll(PDO::FETCH_OBJ);
25+
}
26+
27+
public static function obtenerPorClave($clave)
28+
{
29+
$bd = BD::obtener();
30+
$sentencia = $bd->prepare("select clave, valor from comun where clave = ?");
31+
$sentencia->execute([$clave]);
32+
return $sentencia->fetchObject();
33+
}
34+
35+
public static function insertar($clave, $valor)
36+
{
37+
$bd = BD::obtener();
38+
$sentencia = $bd->prepare("insert into comun(clave, valor) values (?, ?)");
39+
return $sentencia->execute([$clave, $valor]);
40+
}
41+
42+
public static function actualizar($clave, $valor)
43+
{
44+
$bd = BD::obtener();
45+
$sentencia = $bd->prepare("update comun set valor = ? where clave = ?");
46+
return $sentencia->execute([$valor, $clave]);
47+
}
48+
49+
public static function eliminar($clave)
50+
{
51+
$bd = BD::obtener();
52+
$sentencia = $bd->prepare("delete from comun where clave = ?");
53+
return $sentencia->execute([$clave]);
54+
}
55+
56+
}

0 commit comments

Comments
 (0)