subtotaltitle/ajax/remove_from_section.php

25 lines
No EOL
674 B
PHP
Executable file

<?php
define('NOTOKENRENEWAL', 1);
require '../../../main.inc.php';
require_once __DIR__.'/../lib/subtotaltitle.lib.php';
$product_id = GETPOST('product_id', 'int');
subtotaltitle_debug_log('🔓 remove_from_section: product=' . $product_id);
if (!$product_id) {
echo json_encode(['success' => false, 'error' => 'Missing product_id']);
exit;
}
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_lines_manager";
$sql .= " SET parent_section = NULL";
$sql .= " WHERE fk_facturedet = ".(int)$product_id;
$result = $db->query($sql);
if ($result) {
echo json_encode(['success' => true]);
} else {
echo json_encode(['success' => false, 'error' => $db->lasterror()]);
}