<?php
require_once 'conexion2.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  $id = $_POST['cliente_id'];
  $balance = floatval($_POST['balance']);
  $due = floatval($_POST['due']);

  $stmt = $pdo->prepare("UPDATE customer_to_store SET balance = ?, due = ? WHERE customer_id = ?");
  if ($stmt->execute([$balance, $due, $id])) {
    header("Location: actualizar_saldos.php?msg=ok");
  } else {
    echo "Error al guardar los cambios.";
  }
}
