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

$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'];

$insert = $db2->query("
  INSERT INTO api_acriss_location_modifiers (partner_id, location_id, acriss_code, modifier_percent)
  VALUES ($partner_id, $location_id, '$acriss_code', $modifier_percent)
");

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