<?php
include('../include/auth.php');
include('../include/lskfjwfe.php');
header('Content-Type: application/json');

$id = (int)$_POST['id'];
$partner_id = (int)$_POST['partner_id'];
$location_id = (int)$_POST['location_id'];
$acriss_code = mysqli_real_escape_string($db2, $_POST['acriss_code']);
$modifier_percent = (float)$_POST['modifier_percent'];

$update = $db2->query("
  UPDATE api_acriss_location_modifiers 
  SET partner_id = $partner_id, location_id = $location_id, acriss_code = '$acriss_code', modifier_percent = $modifier_percent
  WHERE id = $id
");

if ($update) {
  $details = mysqli_real_escape_string($db2, json_encode($_POST));
  $db2->query("INSERT INTO action_logs (action, details, user) VALUES ('update_modifier', '$details', '$user')");
  echo json_encode(['success' => true]);
} else {
  echo json_encode(['success' => false, 'error' => mysqli_error($db2)]);
}
