crm-summit/app/Views/activities_detail.php

89 lines
2.2 KiB
PHP
Raw Normal View History

2024-04-24 13:20:52 +07:00
<h3>Activity Detail</h3>
<hr>
<?=$content;?>
<?php
$attachment = $attachment['attachment'];
$filelist = $attachment;
$file_array = explode (',', $filelist);
function resolve_attachment_relative_path($filename) {
$filename = trim($filename);
if ($filename === '') {
return '';
}
$normalized = str_replace('\\', '/', ltrim($filename, '/'));
$directCandidates = [];
if (strpos($normalized, 'file/') === 0 || strpos($normalized, 'upload/') === 0) {
$directCandidates[] = $normalized;
} else {
$directCandidates[] = 'upload/' . $normalized;
$directCandidates[] = 'file/' . $normalized;
}
foreach ($directCandidates as $candidate) {
$absolutePath = FCPATH . str_replace('/', DIRECTORY_SEPARATOR, $candidate);
if (is_file($absolutePath)) {
return $candidate;
}
}
$basename = basename($normalized);
if ($basename === '') {
return 'upload/' . $normalized;
}
$roots = ['file', 'upload'];
foreach ($roots as $root) {
$rootPath = FCPATH . $root . DIRECTORY_SEPARATOR;
$pattern = $rootPath . '*' . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . $basename;
$matches = @glob($pattern);
if ($matches !== false) {
foreach ($matches as $match) {
if (is_file($match)) {
$relative = str_replace('\\', '/', substr($match, strlen($rootPath)));
return $root . '/' . $relative;
}
}
}
}
return 'upload/' . $basename;
}
2024-04-24 13:20:52 +07:00
$i = 1;
foreach ($file_array as $value){
2024-04-24 13:20:52 +07:00
if($i == 1) {echo "<b>Attachment : </b><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/>";
2024-04-24 13:20:52 +07:00
$i++;
}
echo "<br/>";
2026-03-08 22:40:36 +07:00
$i = 1;
foreach ($certificates as $value){
// if($i == 1) {echo "<b>Attachment : </b><br/>";}
echo "Certificate : <a href='".$value['file_url']."' target='_blank'>".$value['cert_name']."</a><br/>";
$i++;
}
2024-04-24 13:20:52 +07:00
echo "<hr/>";
foreach ($actsend_log as $data) {
$logdate = $data['logdate'];
$replyto = $data['replyto'];
$emailto = $data['emailto'];
$emailcc = $data['emailcc'];
$emailbcc = $data['emailbcc'];
echo "<p style='margin-bottom:10px;'><b>$logdate</b><br/>
Reply to : $replyto<br/>
To : $emailto<br/>
cc : $emailcc<br/>
bcc : $emailbcc<br/>
</p>";
}
?>