template processing docx

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • item
    Active Community Member
    • Mar 2017
    • 1480

    template processing docx

    Hello Teams,

    i know big deal with 6.0 and too todo list
    is there any possibility to have docx templating ?

    phpWord can give opportuinity to use the templating :

    $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('PS_FR.docx') ; => of course change to a templateId
    $templateProcessor->setValue('patientName', $patient->get('name'));

    templating word is too {{patientName}} .. so no need new language.

    and like pdf at the end :

    $templateProcessor->saveAs('php://output');
    $docxData = ob_get_contents();

    i will search if someone can give me direction

    Best Regards
    Last edited by item; 10-14-2020, 06:48 PM.
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​
  • item
    Active Community Member
    • Mar 2017
    • 1480

    #2
    For someone need tips about how phpWord :

    PHP Code:
    <?php
    
    $i=1;
    $templateProcessor->cloneRow('userId', count($usersList));
    foreach($usersList as $user){
    $templateProcessor->setValue('userId#'.$i , $i);
    $templateProcessor->setValue('userName#'.$i , $user->get('name'));
    $templateProcessor->setValue('userEmailAddress#'.$i , $user->get('emailAddress'));
    $i++;
    }
    $i=1;
    $templateProcessor->cloneRow('contactId', count($contactList) + count($leadList));
    foreach($contactList as $contact){
    $status = $meeting->getLinkMultipleColumn('contacts', 'status', $contact->id);
    $templateProcessor->setValue('contactId#'.$i , $i);
    $templateProcessor->setValue('contactName#'.$i, $contact->get('name'));
    $templateProcessor->setValue('contactProfession#'.$i, $contact->get('professionName'));
    $templateProcessor->setValue('contactPhoneNumber#'.$i, $contact->get('phoneNumber'));
    $templateProcessor->setValue('contactEmailAddress#'.$i, $contact->get('emailAddress'));
    $templateProcessor->setValue('status#'.$i, $status);
    
    $i++;
    }
    foreach($leadList as $lead){
    $status = $meeting->getLinkMultipleColumn('leads', 'status', $lead->id);
    $templateProcessor->setValue('contactId#'.$i , $i);
    $templateProcessor->setValue('contactName#'.$i, $lead->get('name'));
    $templateProcessor->setValue('contactProfession#'.$i, $lead->get('fonction'));
    $templateProcessor->setValue('contactPhoneNumber#'.$i, $lead->get('phoneNumber'));
    $templateProcessor->setValue('contactEmailAddress#'.$i, $lead->get('emailAddress'));
    $templateProcessor->setValue('status#'.$i, $status);
    $i++;
    }
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

    Comment

    Working...