Build T_SendEmailReports from qr_printout with id/url/result format
Done.php send_email_v2: query qr_printout to build structured reports
array [{"id","url","result"}] using QR_PrintOutGroup_ResultName instead
of relying on client-supplied reports param.
send_email.php: parse both old (URL string) and new (object) formats;
use result field as PDF attachment filename.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -283,8 +283,21 @@ foreach ($rows as $row) {
|
||||
$attachments = [];
|
||||
$tmp_files = [];
|
||||
|
||||
foreach ($reports as $idx => $url) {
|
||||
log_msg(" Downloading attachment " . ($idx + 1) . ": {$url}");
|
||||
foreach ($reports as $idx => $entry) {
|
||||
// Support both formats:
|
||||
// old: ["http://..."]
|
||||
// new: [{"id":"1","url":"http://...","result":"LAB"}]
|
||||
if (is_array($entry)) {
|
||||
$url = $entry['url'] ?? '';
|
||||
$result = $entry['result'] ?? ('hasil_lab_' . ($idx + 1));
|
||||
} else {
|
||||
$url = (string) $entry;
|
||||
$result = 'hasil_lab_' . ($idx + 1);
|
||||
}
|
||||
|
||||
if (empty($url)) continue;
|
||||
|
||||
log_msg(" Downloading attachment " . ($idx + 1) . " [{$result}]: {$url}");
|
||||
|
||||
$pdf = download_pdf($url);
|
||||
if ($pdf === false) {
|
||||
@@ -313,9 +326,10 @@ foreach ($rows as $row) {
|
||||
}
|
||||
}
|
||||
|
||||
$safe_result = preg_replace('/[^a-zA-Z0-9_\-]/', '_', $result);
|
||||
$attachments[] = [
|
||||
'path' => $final,
|
||||
'name' => 'hasil_lab_' . ($idx + 1) . '.pdf',
|
||||
'name' => $safe_result . '.pdf',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user