-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,772 changed files
with
449,604 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
session_start(); | ||
#if (empty($_SESSION['ID'])) { | ||
# header("Location: ../login.php"); | ||
#} | ||
include "Conexión.php"; | ||
|
||
$id = $_GET['id']; | ||
$cantidad = $_GET['cantidad']; | ||
$operación = strval($_GET['operación']); | ||
# $usuario = strval($_GET['usuario']); | ||
|
||
$autor = $_SESSION['Nombre']; | ||
|
||
$conexión = mysqli_connect("localhost", "kalicel", "kalicelrepair", "kalicel"); | ||
|
||
$consulta = "SELECT * FROM `displays` WHERE `id_display` = $id"; | ||
$resultado = mysqli_query($conexión, $consulta) or die("Error en la consulta a la base de datos"); | ||
|
||
while ($columna = mysqli_fetch_array($resultado)) { | ||
$datosDisplay['Marca'] = $columna['modelo_display']; | ||
$datosDisplay['Modelo'] = $columna['marca_display']; | ||
$datosDisplay['Color'] = $columna['color_display']; | ||
} | ||
|
||
function crearOperación($clave, $acción, $autor, $marca, $modelo, $color) | ||
{ | ||
$sql = ("INSERT INTO `operaciones` VALUES ('', '" . ucfirst($acción) . "', '" . ucfirst($acción) . " de $modelo - $marca (display); color " . lcfirst($color) . ".', '$autor', current_timestamp)"); | ||
|
||
#switch ($autor) { | ||
# case 'Luis Enrique': | ||
# $claveAutor = 1; | ||
# break; | ||
# case 'Rosalba Nazareth': | ||
# $claveAutor = 2; | ||
# break; | ||
# case 'Dante': | ||
# $claveAutor = 3; | ||
# break; | ||
# | ||
# default: | ||
# echo "Fatal al elegir autor de sesión..."; | ||
# break; | ||
#} | ||
|
||
#include "enviar_email.php"; | ||
|
||
return $sql; //"INSERT INTO `operaciones` VALUES('', 'Prueba de script', 'Estoy insertando operaciones de prueba', '$autor', current_timestamp)"; | ||
} | ||
|
||
switch ($operación) { | ||
case 'alta': | ||
$nuevaCantidad = ($cantidad + 1); | ||
$registraOperación = crearOperación($id, "alta", $autor, $datosDisplay['Marca'], $datosDisplay['Modelo'], $datosDisplay['Color']); | ||
modificacionesRegistros($nuevaCantidad, $id, $registraOperación); | ||
break; | ||
case 'baja': | ||
$nuevaCantidad = ($cantidad - 1); | ||
$registraOperación = crearOperación($id, "baja", $autor, $datosDisplay['Marca'], $datosDisplay['Modelo'], $datosDisplay['Color']); | ||
modificacionesRegistros($nuevaCantidad, $id, $registraOperación); | ||
break; | ||
default: | ||
header("location: FallaSwitchActualización.php"); | ||
break; | ||
} | ||
|
||
//Esta función busca preparar este archivo de PHP [backend] para poder no sólo realizar las bajas y | ||
//bajas de productos manuales con botones, sino también dar la opción de reciclar este script para | ||
//crear nuevos registros en la base de datos de refacciones | ||
function modificacionesRegistros($nuevaCantidad, $id, $registraOperación) | ||
{ | ||
// Actualización de la cantidad de displays | ||
$modificaCantidad = ("UPDATE displays SET cantidad_display = $nuevaCantidad WHERE id_display = $id"); | ||
|
||
$conexión = new mysqli("localhost", "kalicel", "kalicelrepair", "kalicel"); | ||
|
||
if ($conexión->connect_error) { | ||
die("Connection failed: " . $conexión->connect_error); | ||
} | ||
|
||
$conexión->query($modificaCantidad); | ||
$conexión->query($registraOperación); | ||
#echo $modificaCantidad; | ||
|
||
|
||
//$resultado = mysqli_query($conexión, $modificaCantidad) or die("No se ejecutó la çonsulta de actualización..."); | ||
|
||
if ($conexión->query($modificaCantidad) === TRUE) { | ||
#echo "Actualización exitosa"; | ||
} else { | ||
#echo "Error en la actualización del registro: : " . $conexión->error; | ||
} | ||
|
||
$conexión->close(); | ||
|
||
echo ($nuevaCantidad); | ||
|
||
|
||
// Registro de edición en la actividad de usuarios (historial de seguridad) | ||
# $modificaCantidad = ("UPDATE `displays` SET `cantidad_display` = $nuevaCantidad WHERE `id_display`= " . $id); | ||
# echo $modificaCantidad; | ||
# $resultado = mysqli_query($conexión, $modificaCantidad) or die("No se ejecutó la çonsulta de actualización..."); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
$conexión = new mysqli("localhost", "kalicel", "kalicelrepair", "kalicel"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<?php | ||
session_start(); | ||
$búsqueda = $_GET['búsqueda']; | ||
|
||
function ConstruirTablaCarga() | ||
{ | ||
$conexión = mysqli_connect("localhost", "kalicel", "kalicelrepair", "kalicel"); | ||
$comilla = '"'; | ||
$consulta = "SELECT * FROM `displays`"; | ||
$resultado = mysqli_query($conexión, $consulta) or die("Error en la consulta a la base de datos"); | ||
|
||
echo ("<table class='table my-0' id='dataTable'> | ||
<thead> | ||
<tr> | ||
<th>ID</th> | ||
<th>Modelo</th> | ||
<th>Marca</th> | ||
<th>Color</th> | ||
<th>Cantidad</th> | ||
<th>Caja</th> | ||
<th>Calidad</th> | ||
<th>Versión</th> | ||
</tr> | ||
</thead> | ||
<tbody id='cuerpoTabla'>"); | ||
while ($columna = mysqli_fetch_array($resultado)) { | ||
|
||
echo "<tr>"; | ||
echo "<td>" . $columna['id_display'] . "</td>"; | ||
echo "<td>" . $columna['modelo_display'] . "</td>"; | ||
echo "<td>" . $columna['marca_display'] . "</td>"; | ||
echo "<td>" . $columna['color_display'] . "</td>"; | ||
echo "<td><button id='baja" . $columna['id_display'] . "' class='btn btn-primary btn-baja' onclick='javascript:bajaAltaCantidad(" . $columna['id_display'] . ", " . $comilla . "baja" . $comilla . ");' type='button'>-</button><span id='cantidad" . $columna['id_display'] . "'>" . $columna['cantidad_display'] . "</span><button id='alta" . $columna['id_display'] . "' class='btn btn-primary btn-alta' onclick='javascript:bajaAltaCantidad(" . $columna['id_display'] . ", " . $comilla . "alta" . $comilla . ");' type='button'>+</button></td>"; | ||
echo "<td>" . $columna['caja_display'] . "</td>"; | ||
echo "<td>" . $columna['calidad_display'] . "</td>"; | ||
echo "<td>" . $columna['versión_display'] . "</td>"; | ||
echo "</tr>"; | ||
} | ||
echo ("</tbody> | ||
<tfoot> | ||
<tr> | ||
<td><strong>ID</strong></td> | ||
<td><strong>Modelo</strong></td> | ||
<td><strong>Marca</strong></td> | ||
<td><strong>Color</strong></td> | ||
<td><strong>Cantidad</strong></td> | ||
<td><strong>Caja</strong></td> | ||
<td>Calidad</td> | ||
<td>Versión</td> | ||
</tr> | ||
</tfoot> | ||
</table>"); | ||
|
||
mysqli_close($conexión); | ||
} | ||
|
||
# ConstruirTablaCarga(); | ||
|
||
|
||
function ConstruirTablaBúsqueda($búsqueda) | ||
{ | ||
$conexión = mysqli_connect("localhost", "kalicel", "kalicelrepair", "kalicel"); | ||
$comilla = '"'; | ||
$columnas = ["id_display", "modelo_display", "marca_display", "color_display", "cantidad_display", "versión_display", "caja_display"]; | ||
|
||
// Diseño de lógica de filtros | ||
$where = "WHERE ("; | ||
$cuenta = count($columnas); | ||
for ($i = 0; $i < $cuenta; $i++) { | ||
$where .= $columnas[$i] . " LIKE '%" . $búsqueda . "%' OR "; | ||
} | ||
$where = substr_replace($where, "", -3); | ||
$where .= ")"; | ||
|
||
|
||
|
||
$consulta = "SELECT * FROM `displays` $where"; | ||
#echo $consulta; | ||
$resultado = mysqli_query($conexión, $consulta) or die("Error en la consulta a la base de datos"); | ||
|
||
echo ("<table class='table my-0' id='dataTable'> | ||
<thead> | ||
<tr> | ||
<th>ID</th> | ||
<th>Modelo</th> | ||
<th>Marca</th> | ||
<th>Color</th> | ||
<th>Cantidad</th> | ||
<th>Caja</th> | ||
<th>Calidad</th> | ||
<th>Versión</th> | ||
</tr> | ||
</thead> | ||
<tbody id='cuerpoTabla'>"); | ||
while ($columna = mysqli_fetch_array($resultado)) { | ||
|
||
echo "<tr>"; | ||
echo "<td>" . $columna['id_display'] . "</td>"; | ||
echo "<td>" . $columna['modelo_display'] . "</td>"; | ||
echo "<td>" . $columna['marca_display'] . "</td>"; | ||
echo "<td>" . $columna['color_display'] . "</td>"; | ||
echo "<td><button id='baja" . $columna['id_display'] . "' class='btn btn-primary btn-baja' onclick='javascript:bajaAltaCantidad(" . $columna['id_display'] . ", " . $comilla . "baja" . $comilla . ");' type='button'>-</button><span id='cantidad" . $columna['id_display'] . "'>" . $columna['cantidad_display'] . "</span><button id='alta" . $columna['id_display'] . "' class='btn btn-primary btn-alta' onclick='javascript:bajaAltaCantidad(" . $columna['id_display'] . ", " . $comilla . "alta" . $comilla . ");' type='button'>+</button></td>"; | ||
echo "<td>" . $columna['caja_display'] . "</td>"; | ||
echo "<td>" . $columna['calidad_display'] . "</td>"; | ||
echo "<td>" . $columna['versión_display'] . "</td>"; | ||
echo "</tr>"; | ||
} | ||
echo ("</tbody> | ||
<tfoot> | ||
<tr> | ||
<td><strong>ID</strong></td> | ||
<td><strong>Modelo</strong></td> | ||
<td><strong>Marca</strong></td> | ||
<td><strong>Color</strong></td> | ||
<td><strong>Cantidad</strong></td> | ||
<td><strong>Caja</strong></td> | ||
<td>Calidad</td> | ||
<td>Versión</td> | ||
</tr> | ||
</tfoot> | ||
</table>"); | ||
|
||
mysqli_close($conexión); | ||
} | ||
|
||
if ($búsqueda != "" || $búsqueda != null) { | ||
ConstruirTablaBúsqueda($búsqueda); | ||
} else { | ||
ConstruirTablaCarga($búsqueda); | ||
#echo "Filtro desactivado"; | ||
} |
Oops, something went wrong.