<?php
require_once '../../config/database.php';
require_once '../../includes/helpers.php';
require_post();
$data = json_input();
require_fields($data, ['producto_id', 'sucursal_id', 'stock_minimo']);
$pdo = getConnection();
try {
    $stmt = $pdo->prepare("UPDATE inventario_sucursal SET stock_minimo = ? WHERE producto_id = ? AND sucursal_id = ?");
    $stmt->execute([(int)$data['stock_minimo'], (int)$data['producto_id'], (int)$data['sucursal_id']]);
    json_success("Stock mínimo actualizado");
} catch(Exception $e) {
    json_error($e->getMessage());
}
?>
