Announcement

Collapse
No announcement yet.

Template for Printing multiple records of entity

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Hello espcrm , emillod,
    Yes with espocrm all is possible.. and what emillod ask is possible .. but not out-of-box .. so need code :

    first create a field for entity :
    activityList activityList Json Array
    then services :
    PHP Code:
    <?php

    namespace Espo\Custom\Services;
    use 
    \Espo\ORM\Entity as Entity;

    class 
    Patient extends \Espo\Core\Templates\Services\Person
    {
    public function 
    loadAdditionalFields(Entity $entity)
    {
    parent::loadAdditionalFields($entity);

    $sql "SELECT id, name, 'Call' as entityType, date_start as dateStart, status, description FROM `call` where parent_type='Patient' AND parent_id='" .$entity->id ."' AND deleted='0'
    UNION
    SELECT id, name, 'Meeting' as entityType, date_start as dateStart, status, description FROM `meeting` where parent_type='Patient' AND parent_id='" 
    .$entity->id ."' AND deleted='0'
    UNION
    SELECT id, name, 'Email' as entityType, date_sent as dateStart, status, body_plain as description FROM `email` where parent_type='Patient' AND parent_id='" 
    .$entity->id ."' AND deleted='0' AND status NOT IN ('Failed', 'Draft')
    ORDER BY dateStart DESC"
    ;
    $pdo $this->getEntityManager()->getPDO();
    //$GLOBALS['log']->warning( $sql);
    $sth $pdo->prepare($sql);
    $sth->execute();
    $row $sth->fetchAll(\PDO::FETCH_ASSOC);

    foreach (
    $row as $i => $v) {
    $activityDataList[$i] = (object) $v;
    }


    $activityList json_decode(json_encode($activityDataListtrue));

    $entity->set('activityList',$activityList );
    //$GLOBALS['log']->warning( $entity->get('calls' ) );
    }

    public function 
    loadAdditionalFieldsForPdf(Entity $entity)
    {
    $this->loadAdditionalFields($entity);

    }
    }

    then on your pdf .. you can loop activityList

    but need code ..of course, this is my solution with my skill ... but for me not complicate for out-of-box code ..
    PrintPdfPerPage
    PrintPdfAsOne .. somethink like this as button

    Regards

    Comment


    • espcrm
      espcrm commented
      Editing a comment
      Awesome. I probably won't be using it but I'm sure it is useful for other. Added to #learning thread

  • #17
    item hello. thank you very much.
    That's workaround, but if you want to use this in all entities, you'll need to modify all entities..
    It'll be easier if espo devs decide to add this as built-in feature

    Comment

    Working...
    X