diff --git a/AGENTS.md b/AGENTS.md index a93c25d..7909b61 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -283,3 +283,8 @@ final class HealthTest extends CIUnitTestCase - PHP 8.1 or higher - Extensions required: `intl`, `mbstring`, `json` - MySQLi database driver by default + +## Agent Preferences + +- Prefer Serena tools (`serena_get_symbols_overview`, `serena_find_symbol`, `serena_search_for_pattern`) for codebase exploration before falling back to `Read`, `Glob`, or `Grep`. +- Reserve `bash` for execution tasks (git, composer, php spark, etc.) and use Serena output to avoid unnecessary token use. diff --git a/app/Controllers/Activities.php b/app/Controllers/Activities.php index b0a27ca..c4a0ff8 100644 --- a/app/Controllers/Activities.php +++ b/app/Controllers/Activities.php @@ -1026,10 +1026,15 @@ class Activities extends Controller { echo 'Error: ' . $_FILES['file']['error'] . '
'; } else { - move_uploaded_file($_FILES['file']['tmp_name'], 'upload/' . $_FILES['file']['name'] ); + $subfolder = date('Y/m'); + $uploadDir = FCPATH . "upload/$subfolder/"; + if (!is_dir($uploadDir)) { + mkdir($uploadDir, 0755, true); + } + move_uploaded_file($_FILES['file']['tmp_name'], $uploadDir . $_FILES['file']['name']); } } - } + } public function act_content($actid, $filter_email=false) { // Parameter Ke-2 Untuk Email $db = \Config\Database::connect(); @@ -2228,4 +2233,4 @@ class Activities extends Controller { return view('activities_getsitecontacts', $data); } -} \ No newline at end of file +} diff --git a/app/Views/activities_detail.php b/app/Views/activities_detail.php index bb2ac0d..5e67e9b 100644 --- a/app/Views/activities_detail.php +++ b/app/Views/activities_detail.php @@ -6,10 +6,31 @@ $attachment = $attachment['attachment']; $filelist = $attachment; $file_array = explode (',', $filelist); +function resolve_attachment_relative_path($filename) { + $uploadRoot = FCPATH . 'upload' . DIRECTORY_SEPARATOR; + $pattern = $uploadRoot . '*' . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . $filename; + $matches = @glob($pattern); + if ($matches !== false) { + foreach ($matches as $match) { + if (is_file($match)) { + $relative = str_replace('\\', '/', substr($match, strlen($uploadRoot))); + return 'upload/' . $relative; + } + } + } + return 'upload/' . $filename; +} + $i = 1; -foreach ($file_array as $value){ +foreach ($file_array as $value){ if($i == 1) {echo "Attachment :
";} - echo "$value
"; + $trimmedValue = trim($value); + if ($trimmedValue === '') { + $i++; + continue; + } + $relativePath = resolve_attachment_relative_path($trimmedValue); + echo "$trimmedValue
"; $i++; } echo "
"; diff --git a/app/Views/activities_editor.php b/app/Views/activities_editor.php index d127c4a..7c257f4 100644 --- a/app/Views/activities_editor.php +++ b/app/Views/activities_editor.php @@ -1178,6 +1178,9 @@ toggleCalibrateAccordion(); // } - + + endSection() ?> diff --git a/public/assets/uppy/uppy-old.js b/public/assets/uppy/uppy-old.js index 28ee471..2105044 100644 --- a/public/assets/uppy/uppy-old.js +++ b/public/assets/uppy/uppy-old.js @@ -1,5 +1,7 @@ import { Uppy, Dashboard, XHRUpload } from "https://releases.transloadit.com/uppy/v3.15.0/uppy.min.mjs"; +const uploadEndpoint = window.crmActivitiesUploadEndpoint ?? "/activities/upload"; + // var uppy = new Uppy({ // onBeforeFileAdded: (currentFile, files) => { @@ -22,14 +24,17 @@ import { Uppy, Dashboard, XHRUpload } from "https://releases.transloadit.com/upp var uppy = new Uppy({ onBeforeFileAdded: (currentFile, files) => { - const month = (new Date().getMonth() + 1).toString().padStart(2, '0'); - const day = (new Date().getDate()).toString().padStart(2, '0'); + const now = new Date(); + const hours = now.getHours().toString().padStart(2, '0'); + const minutes = now.getMinutes().toString().padStart(2, '0'); + const seconds = now.getSeconds().toString().padStart(2, '0'); + const milliseconds = now.getMilliseconds().toString().padStart(3, '0'); // Menghilangkan koma (,) dalam nama file const sanitizedFileName = currentFile.name.replace(/,/g, ''); - // TAHUN-BULAN-HARI_TIMESTAMP - NAMA_FILE - const name = `${new Date().getFullYear()}-${month}-${day}_${Date.now()} - ${sanitizedFileName}`; + // Format: HHMMSSmmm_FILENAME + const name = `${hours}${minutes}${seconds}${milliseconds}_${sanitizedFileName}`; // Membuat objek file yang dimodifikasi const modifiedFile = { @@ -52,7 +57,7 @@ onBeforeFileAdded: (currentFile, files) => { height: 300, }) -.use(XHRUpload, { endpoint: "/activities/upload", method: 'post' }); +.use(XHRUpload, { endpoint: uploadEndpoint, method: 'post' }); uppy.on("complete", (result) => { let array = result.successful;