fix: align activity uploads and attachments
This commit is contained in:
parent
318a78b1ff
commit
e2d29cd12a
@ -283,3 +283,8 @@ final class HealthTest extends CIUnitTestCase
|
|||||||
- PHP 8.1 or higher
|
- PHP 8.1 or higher
|
||||||
- Extensions required: `intl`, `mbstring`, `json`
|
- Extensions required: `intl`, `mbstring`, `json`
|
||||||
- MySQLi database driver by default
|
- 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.
|
||||||
|
|||||||
@ -1026,10 +1026,15 @@ class Activities extends Controller {
|
|||||||
echo 'Error: ' . $_FILES['file']['error'] . '<br>';
|
echo 'Error: ' . $_FILES['file']['error'] . '<br>';
|
||||||
}
|
}
|
||||||
else {
|
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
|
public function act_content($actid, $filter_email=false) { // Parameter Ke-2 Untuk Email
|
||||||
$db = \Config\Database::connect();
|
$db = \Config\Database::connect();
|
||||||
|
|||||||
@ -6,10 +6,31 @@ $attachment = $attachment['attachment'];
|
|||||||
$filelist = $attachment;
|
$filelist = $attachment;
|
||||||
$file_array = explode (',', $filelist);
|
$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;
|
$i = 1;
|
||||||
foreach ($file_array as $value){
|
foreach ($file_array as $value){
|
||||||
if($i == 1) {echo "<b>Attachment : </b><br/>";}
|
if($i == 1) {echo "<b>Attachment : </b><br/>";}
|
||||||
echo "<a href='".base_url()."upload/$value' target='_blank'>$value </a><br/>";
|
$trimmedValue = trim($value);
|
||||||
|
if ($trimmedValue === '') {
|
||||||
|
$i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$relativePath = resolve_attachment_relative_path($trimmedValue);
|
||||||
|
echo "<a href='".base_url($relativePath)."' target='_blank'>$trimmedValue </a><br/>";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
echo "<br/>";
|
echo "<br/>";
|
||||||
|
|||||||
@ -1178,6 +1178,9 @@ toggleCalibrateAccordion();
|
|||||||
// }
|
// }
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src="<?=base_url();?>/assets/uppy/uppy-full.js"></script>
|
<script>
|
||||||
|
window.crmActivitiesUploadEndpoint = <?= json_encode(base_url('activities/upload')) ?>;
|
||||||
|
</script>
|
||||||
|
<script type="module" src="<?=base_url();?>/assets/uppy/uppy-old.js"></script>
|
||||||
<?= $this->endSection() ?>
|
<?= $this->endSection() ?>
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
import { Uppy, Dashboard, XHRUpload } from "https://releases.transloadit.com/uppy/v3.15.0/uppy.min.mjs";
|
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({
|
// var uppy = new Uppy({
|
||||||
// onBeforeFileAdded: (currentFile, files) => {
|
// onBeforeFileAdded: (currentFile, files) => {
|
||||||
|
|
||||||
@ -22,14 +24,17 @@ import { Uppy, Dashboard, XHRUpload } from "https://releases.transloadit.com/upp
|
|||||||
var uppy = new Uppy({
|
var uppy = new Uppy({
|
||||||
onBeforeFileAdded: (currentFile, files) => {
|
onBeforeFileAdded: (currentFile, files) => {
|
||||||
|
|
||||||
const month = (new Date().getMonth() + 1).toString().padStart(2, '0');
|
const now = new Date();
|
||||||
const day = (new Date().getDate()).toString().padStart(2, '0');
|
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
|
// Menghilangkan koma (,) dalam nama file
|
||||||
const sanitizedFileName = currentFile.name.replace(/,/g, '');
|
const sanitizedFileName = currentFile.name.replace(/,/g, '');
|
||||||
|
|
||||||
// TAHUN-BULAN-HARI_TIMESTAMP - NAMA_FILE
|
// Format: HHMMSSmmm_FILENAME
|
||||||
const name = `${new Date().getFullYear()}-${month}-${day}_${Date.now()} - ${sanitizedFileName}`;
|
const name = `${hours}${minutes}${seconds}${milliseconds}_${sanitizedFileName}`;
|
||||||
|
|
||||||
// Membuat objek file yang dimodifikasi
|
// Membuat objek file yang dimodifikasi
|
||||||
const modifiedFile = {
|
const modifiedFile = {
|
||||||
@ -52,7 +57,7 @@ onBeforeFileAdded: (currentFile, files) => {
|
|||||||
height: 300,
|
height: 300,
|
||||||
})
|
})
|
||||||
|
|
||||||
.use(XHRUpload, { endpoint: "/activities/upload", method: 'post' });
|
.use(XHRUpload, { endpoint: uploadEndpoint, method: 'post' });
|
||||||
|
|
||||||
uppy.on("complete", (result) => {
|
uppy.on("complete", (result) => {
|
||||||
let array = result.successful;
|
let array = result.successful;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user