Refactor API endpoints and update invoice generation

- Updated API calls in equipment.php, equipment_manage.php, and equipments_mass_update.php to use v2 endpoints.
- Changed payload decoding from decode_payload to json_decode for consistency.
- Enhanced invoice generation in factuur.php and webhook files to use a new email template and PDF structure.
- Added new email and PDF templates for invoices to improve formatting and readability.
- Improved marketing folder handling in marketing.php with better payload management.
- Updated CSS for marketing to enhance UI interactions.
- Added JavaScript checks for browser compatibility in softwaretool.php.
- Adjusted user permissions in settingsprofiles.php to reflect new features.
This commit is contained in:
“VeLiTi”
2026-01-14 13:31:22 +01:00
parent a0e1d386ad
commit 7aebb762d3
19 changed files with 1141 additions and 631 deletions

View File

@@ -40,13 +40,30 @@ if (isset($_GET['action'])) {
// Marketing folders
if ($action === 'marketing_folders') {
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Create folder - use standard format expected by POST API
$payload = [
'folder_name' => $_POST['folder_name'] ?? '',
'parent_id' => $_POST['parent_id'] ?? '',
'description' => $_POST['description'] ?? ''
// rowID is empty = insert (standard pattern)
];
// Pass through all POST data for create/update/delete
$payload = [];
// Always include id if present (for update/delete)
if (isset($_POST['id'])) {
$payload['id'] = $_POST['id'];
}
// Include delete flag if present
if (isset($_POST['delete'])) {
$payload['delete'] = $_POST['delete'];
}
// Only include other fields if they were sent
if (isset($_POST['folder_name'])) {
$payload['folder_name'] = $_POST['folder_name'];
}
if (isset($_POST['parent_id'])) {
$payload['parent_id'] = $_POST['parent_id'];
}
if (isset($_POST['description'])) {
$payload['description'] = $_POST['description'];
}
$response = ioServer('/v2/marketing_folders', json_encode($payload));
} else {
// Get folders
@@ -128,7 +145,19 @@ if (isset($_GET['action'])) {
// Marketing update
if ($action === 'marketing_update' && $_SERVER['REQUEST_METHOD'] === 'POST') {
$payload = $_POST;
$payload = ['file_id' => $_POST['file_id'] ?? ''];
// Only include fields that were actually sent
if (isset($_POST['title'])) {
$payload['title'] = $_POST['title'];
}
if (isset($_POST['folder_id'])) {
$payload['folder_id'] = $_POST['folder_id'];
}
if (isset($_POST['tags'])) {
$payload['tags'] = $_POST['tags'];
}
$response = ioServer('/v2/marketing_update', json_encode($payload));
header('Content-Type: application/json');
echo $response;
@@ -401,15 +430,64 @@ template_header('Marketing', 'marketing');
</div>
<div class="modal-footer">
<button id="saveEdit" class="btn btn-primary">
<i class="fa fa-save"></i> Save Changes
<i class="fa fa-save"></i>
</button>
<button class="modal-cancel btn btn-secondary">Cancel</button>
<button class="modal-cancel btn btn-secondary">X</button>
</div>
</div>
</div>
<?php endif; ?>
<!-- Edit Folder Modal -->
<?php if ($update_allowed === 1): ?>
<div id="editFolderModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>Edit Folder</h3>
<button class="modal-close">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="editFolderName">Folder Name:</label>
<input type="text" id="editFolderName" class="form-control" placeholder="Enter folder name">
</div>
<div class="form-group">
<label for="editParentFolder">Parent Folder:</label>
<select id="editParentFolder" class="form-control">
<option value="">Root Folder</option>
</select>
</div>
<div class="form-group">
<label for="editFolderDescription">Description:</label>
<textarea id="editFolderDescription" class="form-control" rows="3" placeholder="Optional description"></textarea>
</div>
</div>
<div class="modal-footer">
<button id="saveEditFolder" class="btn btn-primary">
<i class="fa fa-save"></i>
</button>
<?php if ($delete_allowed === 1): ?>
<button id="deleteFolder" class="btn btn-danger">
<i class="fa fa-trash"></i>
</button>
<?php endif; ?>
<button class="modal-cancel btn btn-secondary">X</button>
</div>
</div>
</div>
<?php endif; ?>
<script src="./assets/marketing.js"></script>
<script>
// Pass PHP permissions to JavaScript
window.marketingPermissions = {
canCreate: <?php echo $create_allowed; ?>,
canUpdate: <?php echo $update_allowed; ?>,
canDelete: <?php echo $delete_allowed; ?>
};
</script>
<?php
template_footer();