36 lines
1.2 KiB
PHP
Executable file
36 lines
1.2 KiB
PHP
Executable file
<?php
|
|
define('NOTOKENRENEWAL', 1);
|
|
require '../../../main.inc.php';
|
|
require_once __DIR__.'/../lib/subtotaltitle.lib.php';
|
|
require_once __DIR__.'/../class/DocumentTypeHelper.class.php';
|
|
|
|
$product_id = GETPOST('product_id', 'int');
|
|
$docType = GETPOST('document_type', 'alpha');
|
|
|
|
subtotaltitle_debug_log('🔓 remove_from_section: product=' . $product_id . ', docType=' . $docType);
|
|
|
|
if (!$product_id || !$docType) {
|
|
echo json_encode(['success' => false, 'error' => 'Missing parameters']);
|
|
exit;
|
|
}
|
|
|
|
// Hole die richtigen Tabellennamen für diesen Dokumenttyp
|
|
$tables = DocumentTypeHelper::getTableNames($docType);
|
|
if (!$tables) {
|
|
echo json_encode(['success' => false, 'error' => 'Invalid document type']);
|
|
exit;
|
|
}
|
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_lines_manager";
|
|
$sql .= " SET parent_section = NULL";
|
|
$sql .= " WHERE ".$tables['fk_line']." = ".(int)$product_id;
|
|
$sql .= " AND document_type = '".$db->escape($docType)."'";
|
|
|
|
$result = $db->query($sql);
|
|
|
|
if ($result) {
|
|
subtotaltitle_debug_log('✅ Produkt #' . $product_id . ' aus Section entfernt');
|
|
echo json_encode(['success' => true]);
|
|
} else {
|
|
echo json_encode(['success' => false, 'error' => $db->lasterror()]);
|
|
}
|