Hi,
whith this, you can print in pdf what you will
in this sample, is for contact.
custom/metadat/pdfDefs/Contact.json
custom/Classes/Pdf/Contact/PdfDataLoader.php
and in PDF template just insert :
here sample is all fake criteria.. but just 2 files, and you can "load any data from any entity" for print in pdf of the main entity
doc : https://docs.espocrm.com/development...-defs/#pdfdefs
whith this, you can print in pdf what you will
in this sample, is for contact.
custom/metadat/pdfDefs/Contact.json
PHP Code:
{
"dataLoaderClassNameList": [
"__APPEND__",
"Espo\\Custom\\Classes\\Pdf\\Contact\\PdfDataLoader"
]
}
custom/Classes/Pdf/Contact/PdfDataLoader.php
PHP Code:
<?php
namespace Espo\Custom\Classes\Pdf\Contact;
use Espo\Tools\Pdf\Data\DataLoader;
use Espo\Tools\Pdf\Params;
use Espo\ORM\Entity;
use Espo\Core\ORM\EntityManager;
use Espo\Core\Utils\Log;
use stdClass;
class PdfDataLoader implements DataLoader
{
private $em;
private $log;
public function __construct( EntityManager $entityManager , Log $log)
{
$this->em = $entityManager;
$this->log = $log;
}
public function load(Entity $entity, Params $params): stdClass
{
$account = $this->em->getRDBRepository('Account')
->where([ // where clause
'name' => 'blabla',
])
->findOne();
if (!$account){
return (object) [];
}
return (object) [
'accountPostalCode' => $account->get('postalCode'),
'ct' => $account->get('ct1') .'/' .$account->get('ct2'),
];
}
}
PHP Code:
{{accountPostalCode}} {{ct}}
here sample is all fake criteria.. but just 2 files, and you can "load any data from any entity" for print in pdf of the main entity
doc : https://docs.espocrm.com/development...-defs/#pdfdefs
Comment