kundenkarte/ajax/favorite_update.php
data 6b3b6d7e95 feat(schematic): Terminal-Farben, Leitungen hinter Blöcken, Zeichenmodus v11.0
Terminal-Farben nach Verbindung:
- Terminals zeigen Farbe der angeschlossenen Leitung
- Grau = keine Verbindung, farbig = Leitung angeschlossen
- Neue Hilfsfunktion getTerminalConnectionColor()

Leitungen hinter Blöcken:
- Layer-Reihenfolge geändert: connections vor blocks
- Professionelleres Erscheinungsbild

Zeichenmodus-Verbesserungen:
- Rechtsklick/Escape bricht nur Linie ab, nicht Modus
- Crosshair-Cursor überall im SVG während Zeichenmodus
- 30px Hit-Area für bessere Klickbarkeit

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-04 13:44:52 +01:00

78 lines
1.9 KiB
PHP

<?php
/* Copyright (C) 2026 Alles Watt lauft
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*/
/**
* \file ajax/favorite_update.php
* \brief AJAX handler for updating favorite product quantity
*/
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1');
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
// Load Dolibarr environment
$res = 0;
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res && file_exists("../../../../main.inc.php")) $res = @include "../../../../main.inc.php";
if (!$res && file_exists("../../../../../main.inc.php")) $res = @include "../../../../../main.inc.php";
if (!$res) die("Include of main fails");
dol_include_once('/kundenkarte/class/favoriteproduct.class.php');
// Check permission
if (!$user->hasRight('kundenkarte', 'write')) {
http_response_code(403);
echo json_encode(array('error' => 'Permission denied'));
exit;
}
header('Content-Type: application/json');
$id = GETPOSTINT('id');
$qty = GETPOST('qty', 'alpha');
if ($id <= 0) {
echo json_encode(array('error' => 'Invalid ID'));
exit;
}
// Simple check: just needs to be numeric
if (!is_numeric($qty)) {
echo json_encode(array('error' => 'Invalid quantity'));
exit;
}
$qty = (float) $qty;
$favoriteProduct = new FavoriteProduct($db);
$result = $favoriteProduct->fetch($id);
if ($result <= 0) {
echo json_encode(array('error' => 'Record not found'));
exit;
}
$favoriteProduct->qty = $qty;
$result = $favoriteProduct->update($user);
if ($result > 0) {
echo json_encode(array(
'success' => true,
'id' => $id,
'qty' => $qty
));
} else {
echo json_encode(array('error' => $favoriteProduct->error));
}