chnaged logic for multi pdf upload in upload daily task report #1047

Merged
jothi merged 1 commits from ranjith-dev into master 2026-09-18 05:41:53 +00:00

View File

@@ -90,7 +90,8 @@ class SendDailyTaskReport extends Command
$rows[] = [
'sno' => $sno++,
'name' => $this->extractNameFromFilename($filename),
'project-name' => $this->extractProjectName($text),
// 'project-name' => $this->extractProjectName($text),
'project-name' => $pdf ? $this->extractProjectName($pdf) : 'Unknown project',
'task' => $this->extractTaskTitle($text),
'status' => $this->extractStatus($text),
'completed' => $this->extractPercentComplete($text),
@@ -214,12 +215,29 @@ class SendDailyTaskReport extends Command
return '0%';
}
protected function extractProjectName(string $text): string
{
$normalized = str_replace("\xC2\xA0", ' ', $text);
// protected function extractProjectName(string $text): string
// {
// $normalized = str_replace("\xC2\xA0", ' ', $text);
// Footer pattern: <page#><date>\t<Project Name> at the very end of the PDF text
if (preg_match('/\d{1,2}-\d{2}-\d{4}\s*\t\s*(.+?)\s*$/s', $normalized, $matches)) {
// // Footer pattern: <page#><date>\t<Project Name> at the very end of the PDF text
// if (preg_match('/\d{1,2}-\d{2}-\d{4}\s*\t\s*(.+?)\s*$/s', $normalized, $matches)) {
// return trim($matches[1]);
// }
// return 'Unknown project';
// }
protected function extractProjectName($pdf): string
{
$pages = $pdf->getPages();
if (empty($pages)) {
return 'Unknown project';
}
$firstPageText = str_replace("\xC2\xA0", ' ', $pages[0]->getText());
if (preg_match('/\d{1,2}-\d{2}-\d{4}\s*\t\s*(.+?)\s*$/s', $firstPageText, $matches)) {
return trim($matches[1]);
}