diff --git a/.DS_Store b/.DS_Store index 1b6483b..9d4c452 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index b32e0bd..4a636e1 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ assets/database/migration_v3.sql api/.DS_Store api/v1/.DS_Store api/v2/.DS_Store +api/.DS_Store +assets/.DS_Store +assets/images/.DS_Store diff --git a/api/.DS_Store b/api/.DS_Store index 25bea50..362cceb 100644 Binary files a/api/.DS_Store and b/api/.DS_Store differ diff --git a/api/v1/.DS_Store b/api/v1/.DS_Store index cb2f10e..ad7d9dd 100644 Binary files a/api/v1/.DS_Store and b/api/v1/.DS_Store differ diff --git a/api/v2/.DS_Store b/api/v2/.DS_Store index c28ab40..16d8e39 100644 Binary files a/api/v2/.DS_Store and b/api/v2/.DS_Store differ diff --git a/api/v2/post/marketing_update.php b/api/v2/post/marketing_update.php new file mode 100644 index 0000000..1062147 --- /dev/null +++ b/api/v2/post/marketing_update.php @@ -0,0 +1,71 @@ +soldto) || $partner->soldto == ''){$soldto_search = '%';} else {$soldto_search = '-%';} + +//default whereclause +list($whereclause,$condition) = getWhereclauselvl2("",$permission,$partner,''); + +//QUERY AND VERIFY ALLOWED +if (isAllowed('marketing',$profile,$permission,'U') === 1){ + // Get JSON input + $input = json_decode(file_get_contents('php://input'), true); + + $file_id = $input['file_id'] ?? ''; + $folder_id = $input['folder_id'] ?? ''; + $tags = $input['tags'] ?? []; + $title = $input['title'] ?? ''; + + if (empty($file_id)) { + echo json_encode(['success' => false, 'error' => 'File ID is required']); + exit; + } + + try { + // Update file + $update_sql = 'UPDATE `marketing_files` SET `title` = ?, `folder_id` = ? WHERE `id` = ? AND `accounthierarchy` LIKE ?'; + $stmt = $pdo->prepare($update_sql); + $stmt->execute([ + $title, + $folder_id ?: null, + $file_id, + $condition + ]); + + if ($stmt->rowCount() === 0) { + echo json_encode(['success' => false, 'error' => 'File not found or access denied']); + exit; + } + + // Update tags - first remove existing + $pdo->prepare('DELETE FROM `marketing_file_tags` WHERE `file_id` = ?')->execute([$file_id]); + + // Insert new tags + if (!empty($tags)) { + $tag_sql = 'INSERT IGNORE INTO `marketing_tags` (`tag_name`) VALUES (?)'; + $tag_stmt = $pdo->prepare($tag_sql); + + $file_tag_sql = 'INSERT INTO `marketing_file_tags` (`file_id`, `tag_id`) SELECT ?, id FROM marketing_tags WHERE tag_name = ?'; + $file_tag_stmt = $pdo->prepare($file_tag_sql); + + foreach ($tags as $tag) { + $tag_stmt->execute([trim($tag)]); + $file_tag_stmt->execute([$file_id, trim($tag)]); + } + } + + echo json_encode(['success' => true, 'message' => 'File updated successfully']); + } catch (Exception $e) { + echo json_encode(['success' => false, 'error' => 'Update failed: ' . $e->getMessage()]); + } +} else { + echo json_encode(['success' => false, 'error' => 'Insufficient permissions']); +} +?> \ No newline at end of file diff --git a/assets/.DS_Store b/assets/.DS_Store index 7502f1f..1ba4cf5 100644 Binary files a/assets/.DS_Store and b/assets/.DS_Store differ diff --git a/assets/images/.DS_Store b/assets/images/.DS_Store index a97d4fb..12648ae 100644 Binary files a/assets/images/.DS_Store and b/assets/images/.DS_Store differ diff --git a/assets/marketing.js b/assets/marketing.js index 30f8c9c..d5581f7 100644 --- a/assets/marketing.js +++ b/assets/marketing.js @@ -100,6 +100,11 @@ class MarketingFileManager { this.deleteFile(this.selectedFile); } }); + + // Save edit + document.getElementById('saveEdit')?.addEventListener('click', () => { + this.saveEdit(); + }); } bindUploadEvents() { @@ -359,6 +364,9 @@ class MarketingFileManager { +