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

$id = (int)$_POST['id'];
$partner_id = (int)$_POST['partner_id'];
$place_id = (int)$_POST['place_id'];

$query = $db2->query("
  UPDATE api_locations
  SET api_locations_partner_id = $partner_id,
      api_locations_place_id = $place_id
  WHERE api_locations_id = $id
");

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