Autosave: 20260220-162206

This commit is contained in:
Flatlogic Bot 2026-02-20 16:22:07 +00:00
parent 9e7939eebb
commit 8914f6e2df
19 changed files with 18 additions and 15 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 555 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

@ -14,6 +14,7 @@ if (!function_exists('db')) {
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
$pdo->exec("SET time_zone = '-05:00'");
}
return $pdo;
}

View File

@ -216,7 +216,7 @@ $(document).ready(function() {
"language": {
"url": "//cdn.datatables.net/plug-ins/1.10.25/i18n/Spanish.json"
},
"order": [[ <?php echo ($user_role !== 'Asesor' ? 13 : 12); ?>, "desc" ]],
"order": [[ 0, "desc" ]],
"paging": false,
"lengthChange": false,
"info": false

View File

@ -155,6 +155,7 @@ include 'layout_header.php';
<th>Celular</th>
<th>Producto</th>
<th>Sede de Envío</th>
<th>Cantidad</th>
<th>Monto Total</th>
<th>Monto Debe</th>
<th> De Orden</th>
@ -176,6 +177,7 @@ include 'layout_header.php';
<td><?php echo htmlspecialchars($pedido['celular']); ?></td>
<td><?php echo htmlspecialchars($pedido['producto']); ?></td>
<td><?php echo htmlspecialchars($pedido['sede_envio'] ?? 'N/A'); ?></td>
<td><?php echo htmlspecialchars($pedido['cantidad'] ?? '1'); ?></td>
<td><?php echo htmlspecialchars($pedido['monto_total']); ?></td>
<td><?php echo htmlspecialchars($pedido['monto_debe']); ?></td>
<td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="codigo_rastreo"><?php echo htmlspecialchars($pedido['codigo_rastreo'] ?? 'N/A'); ?></td>
@ -219,7 +221,7 @@ $(document).ready(function() {
"language": {
"url": "//cdn.datatables.net/plug-ins/1.10.25/i18n/Spanish.json"
},
"order": [[ <?php echo ($user_role !== 'Asesor' ? 13 : 12); ?>, "desc" ]],
"order": [[ 0, "desc" ]],
"paging": false,
"lengthChange": false,
"info": false

View File

@ -313,7 +313,7 @@ $(document).ready(function() {
"language": {
"url": "//cdn.datatables.net/plug-ins/1.10.25/i18n/Spanish.json"
},
"order": [[ <?php echo ($user_role !== 'Asesor' ? 14 : 13); ?>, "desc" ]], // Adjusted index for new column
"order": [[ 0, "desc" ]],
"paging": false,
"lengthChange": false,
"info": false

View File

@ -20,24 +20,24 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$pdo->beginTransaction();
// 1. Actualizar o insertar en stock_sedes
$sql_stock = "INSERT INTO stock_sedes (id_producto, id_sede, cantidad)
VALUES (:product_id, :sede_id, :cantidad)
ON DUPLICATE KEY UPDATE cantidad = cantidad + :cantidad";
$sql_stock = "INSERT INTO stock_sedes (product_id, sede_id, quantity)
VALUES (:product_id, :sede_id, :quantity)
ON DUPLICATE KEY UPDATE quantity = quantity + :quantity";
$stmt_stock = $pdo->prepare($sql_stock);
$stmt_stock->bindParam(':product_id', $product_id, PDO::PARAM_INT);
$stmt_stock->bindParam(':sede_id', $sede_id, PDO::PARAM_INT);
$stmt_stock->bindParam(':cantidad', $cantidad, PDO::PARAM_INT);
$stmt_stock->bindParam(':quantity', $cantidad, PDO::PARAM_INT);
$stmt_stock->execute();
// 2. Registrar el movimiento
$sql_movement = "INSERT INTO stock_movements (product_id, sede_id, tipo_movimiento, cantidad, origen)
VALUES (:product_id, :sede_id, 'entrada', :cantidad, 'manual')";
$sql_movement = "INSERT INTO stock_movements (product_id, sede_id, `type`, quantity, movement_date)
VALUES (:product_id, :sede_id, 'entrada', :quantity, NOW())";
$stmt_movement = $pdo->prepare($sql_movement);
$stmt_movement->bindParam(':product_id', $product_id, PDO::PARAM_INT);
$stmt_movement->bindParam(':sede_id', $sede_id, PDO::PARAM_INT);
$stmt_movement->bindParam(':cantidad', $cantidad, PDO::PARAM_INT);
$stmt_movement->bindParam(':quantity', $cantidad, PDO::PARAM_INT);
$stmt_movement->execute();
$pdo->commit();

View File

@ -20,14 +20,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$pdo->beginTransaction();
// 1. Verificar stock actual
$sql_check = "SELECT cantidad FROM stock_sedes WHERE id_producto = :product_id AND id_sede = :sede_id FOR UPDATE";
$sql_check = "SELECT quantity FROM stock_sedes WHERE product_id = :product_id AND sede_id = :sede_id FOR UPDATE";
$stmt_check = $pdo->prepare($sql_check);
$stmt_check->bindParam(':product_id', $product_id, PDO::PARAM_INT);
$stmt_check->bindParam(':sede_id', $sede_id, PDO::PARAM_INT);
$stmt_check->execute();
$current_stock_row = $stmt_check->fetch(PDO::FETCH_ASSOC);
$current_stock = $current_stock_row ? (int)$current_stock_row['cantidad'] : 0;
$current_stock = ($current_stock_row && isset($current_stock_row['quantity'])) ? (int)$current_stock_row['quantity'] : 0;
if ($current_stock < $quantity) {
$response['message'] = "Stock insuficiente. Stock actual: {$current_stock} unidades.";
@ -37,7 +37,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
// 2. Actualizar stock_sedes
$sql_update = "UPDATE stock_sedes SET cantidad = cantidad - :quantity WHERE id_producto = :product_id AND id_sede = :sede_id";
$sql_update = "UPDATE stock_sedes SET quantity = quantity - :quantity WHERE product_id = :product_id AND sede_id = :sede_id";
$stmt_update = $pdo->prepare($sql_update);
$stmt_update->bindParam(':quantity', $quantity, PDO::PARAM_INT);
$stmt_update->bindParam(':product_id', $product_id, PDO::PARAM_INT);
@ -45,8 +45,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$stmt_update->execute();
// 3. Registrar el movimiento
$sql_movement = "INSERT INTO stock_movements (product_id, sede_id, tipo_movimiento, cantidad, origen)
VALUES (:product_id, :sede_id, 'salida', :quantity, 'manual')";
$sql_movement = "INSERT INTO stock_movements (product_id, sede_id, type, quantity, movement_date)
VALUES (:product_id, :sede_id, 'salida_manual', :quantity, NOW())";
$stmt_movement = $pdo->prepare($sql_movement);
$stmt_movement->bindParam(':product_id', $product_id, PDO::PARAM_INT);
$stmt_movement->bindParam(':sede_id', $sede_id, PDO::PARAM_INT);