diff --git a/src/Command/ConvertUploadsCommand.php b/src/Command/ConvertUploadsCommand.php index 5358925..17692f0 100644 --- a/src/Command/ConvertUploadsCommand.php +++ b/src/Command/ConvertUploadsCommand.php @@ -47,6 +47,7 @@ class ConvertUploadsCommand extends Command ->setMimeType('application/pdf') ; } catch (\Throwable $e) { + $output->writeln(''.$e->getMessage().''); } $progressBar->advance(); diff --git a/src/Command/StampUploadsCommand.php b/src/Command/StampUploadsCommand.php new file mode 100644 index 0000000..16d78ad --- /dev/null +++ b/src/Command/StampUploadsCommand.php @@ -0,0 +1,56 @@ +entityManager->createQueryBuilder(); + $dispositions = $qb + ->select('disposition', 'upload') + ->from(Disposition::class, 'disposition') + ->innerJoin('disposition.documents', 'upload') + ->where($qb->expr()->andX( + $qb->expr()->eq('upload.type', ':type'), + $qb->expr()->eq('upload.status', ':status') + )) + ->setParameter('type', Upload::TYPE_INVOICE) + ->setParameter('status', Upload::STATUS_PAID) + ->getQuery() + ->getResult(); + + $progressBar = new ProgressBar($output, count($dispositions)); + $progressBar->start(); + + foreach ($dispositions as $disposition) { + $this->invoiceApprover->render($disposition); + $progressBar->advance(); + } + + $this->entityManager->flush(); + $progressBar->finish(); + + return Command::SUCCESS; + } +} diff --git a/src/Service/Pdf/InvoiceApprover.php b/src/Service/Pdf/InvoiceApprover.php index ec240f6..1e1fbed 100644 --- a/src/Service/Pdf/InvoiceApprover.php +++ b/src/Service/Pdf/InvoiceApprover.php @@ -23,7 +23,8 @@ class InvoiceApprover extends AbstractPdfRenderer } // Load template - $filepath = sprintf('%s/uploads/invoice/%s', $this->config['project_dir'], $originalFilename); + $folder = substr($originalFilename, 0, 1); + $filepath = sprintf('%s/uploads/invoice/%s/%s', $this->config['project_dir'], $folder, $originalFilename); if (false === file_exists($filepath)) { throw new \InvalidArgumentException('Uploaded document not found at '.$filepath); }