* * AJAX: Leistung hinzufügen */ if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '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('/stundenzettel/class/stundenzettel.class.php'); header('Content-Type: application/json'); // Security check if (!$user->hasRight('stundenzettel', 'write')) { echo json_encode(array('success' => false, 'error' => 'Permission denied')); exit; } $stundenzettel_id = GETPOST('stundenzettel_id', 'int'); $date = GETPOST('date', 'alpha'); $time_start = GETPOST('time_start', 'alpha'); $time_end = GETPOST('time_end', 'alpha'); $description = GETPOST('description', 'restricthtml'); if (empty($stundenzettel_id)) { echo json_encode(array('success' => false, 'error' => 'Missing stundenzettel_id')); exit; } $stundenzettel = new Stundenzettel($db); if ($stundenzettel->fetch($stundenzettel_id) <= 0) { echo json_encode(array('success' => false, 'error' => 'Stundenzettel not found')); exit; } // Nur im Entwurf bearbeitbar if ($stundenzettel->status != Stundenzettel::STATUS_DRAFT) { echo json_encode(array('success' => false, 'error' => 'Stundenzettel is not in draft status')); exit; } $result = $stundenzettel->addLeistung($user, $date, $time_start, $time_end, $description); if ($result > 0) { echo json_encode(array( 'success' => true, 'leistung_id' => $result )); } else { echo json_encode(array('success' => false, 'error' => 'Failed to add leistung')); }