Categories > OpenTBS with DOCX >

Path for picture with SF2 controller

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: ErA
Date: 2014-06-30
Time: 17:37

Path for picture with SF2 controller

Hi,

I'm looking for import a picture in a DOCX with SF2.
But when i do the changepicture it only show the path i gave in parameter.
I think the path i give to him is not the right path.

Is there someone who already find the right path to give in SF2 controller to export the picture in the DOCX file?

Thank you!
By: Skrol29
Date: 2014-06-30
Time: 23:58

Re: Path for picture with SF2 controller

Hi,

I don't know Symfony (SF2) but you can check the value given by SF2 that is supposed to be the file path.
By: ErA
Date: 2014-07-01
Time: 08:57

Re: Path for picture with SF2 controller

I trie all the ways, the web path, local path, server path but none of them work. It always show me only the path on the DOCX but it not load the picture.

The path are like:

-localhost/avatar/picture.png
-www/web/avatar/picture.png
-C:/user/.../www/web/avatar/picture.png
By: Skrol29
Date: 2014-07-06
Time: 02:26

Re: Path for picture with SF2 controller

Only the directory path can work, not the URL.

> C:/user/.../www/web/avatar/picture.png

This is a directory path but maybe the relative part "..." cannot be processed.
By: ErA
Date: 2014-07-07
Time: 09:25

Re: Path for picture with SF2 controller

Ok, so if i need to use a picture on my document i have to keep the picture on the current server. That not a problem.

But i try like you say to give the full directory:

C:/Users/Me/MyProject/symfony/web/avatar/picture.png and it only give me the path in the document.

If it can't find the picture does it give the path file? I really don't understand how it works...
By: Skrol29
Date: 2014-07-07
Time: 11:12

Re: Path for picture with SF2 controller

> Ok, so if i need to use a picture on my document i have to keep the picture on the current server.

Yes.

> I really don't understand how it works...

The principle is this: if your data item is the path for a picture file on the server, then parameter "ope=changepic" enables you to change the picture close to the TBS filed with a target picture.

Example:

Let's say we have the data item at the PHP side:
$my_path = 'C:/Users/Me/MyProject/symfony/web/avatar/picture.png';


DOCX side, without "changepic":
{default picture here} [onshow.my_path]
will display :
{default picture here} C:/Users/Me/MyProject/symfony/web/avatar/picture.png


DOCX side, with "changepic"
{default picture here} [onshow.my_path;ope=changepic;tagpos=after]
will display :
{new avatar picture here}
By: ErA
Date: 2014-07-07
Time: 12:05

Re: Path for picture with SF2 controller

Thank you very much for your answers.
I understand the concept, now in application it doesn't work for me that's weird.
I apply exactly what you say and it always give me the path and not the picture.
The path is good, i give it to TBS manually.
The only thing that can be a problem is the merge in TBS. Maybe it dosen't work in a mergeBlock?

I try a mergefield instead my mergeblock and it give an error when i try the onshow:
TinyButStrong Error in field [onshow.image...]: the key 'image' does not exist or is not set in VarRef. (VarRef seems refers to $GLOBALS) This message can be cancelled using parameter 'noerr'.

So it doesn't find my field but in my call to TBS i have:

$TBS->MergeField('image', 'C:/Users/Me/MyProject/symfony/web/avatar/picture.png');
By: Skrol29
Date: 2014-07-07
Time: 13:02

Re: Path for picture with SF2 controller

Hi,

[onshow] are automatic TBS fields that are processed by TBS when you call TBS->Show().
[onshow.image] is supposed to display the global variable $image when you call TBS->Show().
Si if there is no global variable $image at this time, it cannot work.


The command:
  $TBS->MergeField('image', 'C:/Users/Me/MyProject/symfony/web/avatar/picture.png');
will merge a field named [image]. Not [onshow.image].
By: ErA
Date: 2014-07-07
Time: 14:20

Re: Path for picture with SF2 controller

Hi again,

Thank you and forgive my stupidity ^^.

After some tests I'm going to give up. It doesn't work at all. No matter what I test, I always finish with my path on the DOCX and no image.
My call to OpenTBS feel good, my path is right, i use the proper call in my DOCX, I really don't understand why it's not working.

I give my code if you have an idea.

Call in OPENTBS:
$image = 'C:/Users/Me/MyProject/symfony/web/avatar/picture.png';
$template = $edition->getAbsolutePath(); 
$TBS->LoadTemplate($template);
$TBS->MergeField('image', 'C:/Users/Me/MyProject/symfony/web/avatar/picture.png');
$TBS->Show(OPENTBS_DOWNLOAD, $output_file_name);

Call in my DOCX:
[image;ope=changepic;tagpos=after]

Thank you!
By: Skrol29
Date: 2014-07-07
Time: 14:30

Re: Path for picture with SF2 controller

Hi,

Your last snippet seems correct.

Few things to check:
- You have a picture in the template placed before the field [image;ope=changepic;tagpos=after]
- The field has no formating break. The ensure this, select the TBS field definition, cut it, and then "past without formating".

It it still doesn't work, can you precise your versions of TBS + OpenTBS + Ms Word, and eventually send the template to me.
By: ErA
Date: 2014-07-07
Time: 14:59

Re: Path for picture with SF2 controller

Hi,

Really thank you for your help and support, it help a lot!
I will post all the code because it can be use by someone else!
Here's the versions:
- TBS: 3.8.0
- OpenTBS: 1.9.0
- MSWORD: 2013 build 15.0.4623.1000 32bits

The real call to TBS in the symfony2 controller:
public function telechargementFicheUsagerAction($slug, $template_name){

        // prevent from a PHP configuration problem when using mktime() and date()
        if (version_compare(PHP_VERSION,'5.1.0')>=0) {
                if (ini_get('date.timezone')=='') {
                        date_default_timezone_set('UTC');
                }
        }
        $TBS = new ClsOpenTBS(); // objet clsTinyButStrong
        $TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN);
       
        $pr = $this->getDoctrine()->getRepository('ImagoImagoBundle:EditionWord');
        $edition = $pr->findOneBySlug($template_name);

        $pr = $this->getDoctrine()->getRepository('ImagoImagoBundle:Usager');
        $usager = $pr->findOneBySlug($slug);
       
        // Traitement des dates
        $date = new DateTime();
        $date_naissance = $usager->getPersonne()->getDateNaissance() ? $usager->getPersonne()->getDateNaissance()->format('d/m/Y') : "";
       
       
        $date_situation = $usager->getContexteFamilial() && $usager->getContexteFamilial()->getDateSituation()  ? $usager->getContexteFamilial()->getDateSituation()->format('d/m/Y') : "";
       
        $date_jour = date('Ymd');
       
        $date_debut_secu = $usager->getSecuriteSocialeUsager() && $usager->getSecuriteSocialeUsager()->getDateDebut()  ? $usager->getSecuriteSocialeUsager()->getDateDebut()->format('d/m/Y'): "";
        $date_fin_secu =  $usager->getSecuriteSocialeUsager() && $usager->getSecuriteSocialeUsager()->getDateFin() ? $usager->getSecuriteSocialeUsager()->getDateFin()->format('d/m/Y'): "";
        $date_debut_mut = $usager->getMutuelleUsager() && $usager->getMutuelleUsager()->getDebutContrat() ? $usager->getMutuelleUsager()->getDebutContrat()->format('d/m/Y'): "";
        $date_fin_mut = $usager->getMutuelleUsager() && $usager->getMutuelleUsager()->getFinContrat() ? $usager->getMutuelleUsager()->getFinContrat()->format('d/m/Y'): "";

        // Traitement des libellés
        $nationalite = $usager->getPersonne()->getNationalite() ? $usager->getPersonne()->getNationalite()->getLibelle():"";
        $pays_naissance = $usager->getPaysNaissance() ? $usager->getPaysNaissance()->getLibelle():"";
        $situation_parents = $usager->getContexteFamilial() && $usager->getContexteFamilial()->getParentsSepares() ? $usager->getContexteFamilial()->getParentsSepares()->getLibelle() :"";
        $situation_usager = $usager->getContexteFamilial() && $usager->getContexteFamilial()->getSituation() ? $usager->getContexteFamilial()->getSituation()->getLibelle() :"";
        $regime_secu =  $usager->getSecuriteSocialeUsager() && $usager->getSecuriteSocialeUsager()->getRegime() ? $usager->getSecuriteSocialeUsager()->getRegime()->getRegime() :"";
        $caisse_secu = $usager->getSecuriteSocialeUsager() && $usager->getSecuriteSocialeUsager()->getCaisse() ? $usager->getSecuriteSocialeUsager()->getCaisse()->getNom() :"";
        $mutuelle =  $usager->getMutuelleUsager() && $usager->getMutuelleUsager()->getMutuelle() ? $usager->getMutuelleUsager()->getMutuelle()->getNom() :"";
       
        $session = new Session();
        // Chargement des informations générales suivant le cas ou l'on est dans un établissement ou un pôle
        // Chargement des infos de l'établissement
        if($session->get('etablissement'))
        {
            $etablissement = $this->getDoctrine()->getRepository('ImagoImagoBundle:Etablissement')->findOneBySlug($session->get('etablissement'));
            $association = $etablissement->getAssociation();
            $type_etablissement = $etablissement->getTypeEtablissement() ? $etablissement->getTypeEtablissement()->getLibelle() : "";
            $adresse_etablissement = $etablissement->getAdresse() ? $etablissement->getAdresse()->getAdresse1()." ".$etablissement->getAdresse()->getAdresse2() : "";
            $code_postal_etablissement = $etablissement->getAdresse() ? $etablissement->getAdresse()->getCodePostal() : "";
            $ville_etablissement = $etablissement->getAdresse() ? $etablissement->getAdresse()->getVille() : "";
            $pays_etablissement = $etablissement->getAdresse() && $etablissement->getAdresse()->getPays() ? $etablissement->getAdresse()->getPays()->getLibelle() : "";
            $adresse_association = $association->getAdresse() ? $association->getAdresse()->getAdresse1()." ".$association->getAdresse()->getAdresse2() : "";
            $code_postal_association = $association->getAdresse() ? $association->getAdresse()->getCodePostal() : "";
            $ville_association = $association->getAdresse() ? $association->getAdresse()->getVille() : "";
            $pays_association = $association->getAdresse() && $association->getAdresse()->getPays() ? $association->getAdresse()->getPays()->getLibelle() : "";
            $info = array(
                            'date_jour'=> utf8_decode($date->format('d/m/Y')),
                            'nom_pole'=> "",
                            'nom_etablissement'=> utf8_decode($etablissement->getNom()),
                            'type_etablissement'=> utf8_decode($type_etablissement),
                            'adresse_etablissement'=> utf8_decode($adresse_etablissement),
                            'code-postal_etablissement'=> utf8_decode($code_postal_etablissement),
                            'ville_etablissement'=> utf8_decode($ville_etablissement),
                            'pays_etablissement'=> utf8_decode($pays_etablissement),
                            'telephone_etablissement'=> utf8_decode($etablissement->getTelephone()),
                            'fax_etablissement'=> utf8_decode($etablissement->getFax()),
                            'mail_etablissement'=> utf8_decode($etablissement->getMail()),
                            'site_etablissement' => utf8_decode($etablissement->getSite()),
                            'ape_etablissement'=> utf8_decode($etablissement->getApe()),
                            'siret_etablissement' => utf8_decode($etablissement->getSiret()),
                            'finness_etablissement' => utf8_decode($etablissement->getFinness()),
                            'notes_etablissement' => utf8_decode($etablissement->getNotes()),
                            'nom_association'=> utf8_decode($association->getNom()),
                            'adresse_association'=> utf8_decode($adresse_association),
                            'code-postal_association'=> utf8_decode($code_postal_association),
                            'ville_association'=> utf8_decode($ville_association),
                            'pays_association'=> utf8_decode($pays_association),
                            'telephone_association'=> utf8_decode($association->getTel()),
                            'fax_association'=> utf8_decode($association->getFax()),
                            'mail_association'=> utf8_decode($association->getMail()),
                            'site_association' => utf8_decode($association->getSite()),
                            'ape_association'=> utf8_decode($association->getApe()),
                            'notes_association'=> utf8_decode($association->getNotes()),
                        );
        }
        // Chargement des informations du pôle
        else if($session->get('pole'))
        {
            $pole = $this->getDoctrine()->getRepository('ImagoImagoBundle:Pole')->findOneBySlug($session->get('pole'));
            $etablissements = $pole->getEtablissements();
            $association = $etablissements[0]->getAssociation();
            $adresse_association = $association->getAdresse() ? $association->getAdresse()->getAdresse1()." ".$association->getAdresse()->getAdresse2() : "";
            $code_postal_association = $association->getAdresse() ? $association->getAdresse()->getCodePostal() : "";
            $ville_association = $association->getAdresse() ? $association->getAdresse()->getVille() : "";
            $pays_association = $association->getAdresse() && $association->getAdresse()->getPays() ? $association->getAdresse()->getPays()->getLibelle() : "";
            $info = array(
                            'date_jour'=> utf8_decode($date->format('d/m/Y')),
                            'nom_pole'=> utf8_decode($pole->getLibelle()),
                            'nom_etablissement'=> "",
                            'type_etablissement'=> "",
                            'adresse_etablissement'=> "",
                            'code-postal_etablissement'=> "",
                            'ville_etablissement'=> "",
                            'pays_etablissement'=> "",
                            'telephone_etablissement'=> "",
                            'fax_etablissement'=> "",
                            'mail_etablissement'=> "",
                            'site_etablissement' => "",
                            'ape_etablissement'=> "",
                            'siret_etablissement' => "",
                            'finness_etablissement' => "",
                            'notes_etablissement' => "",
                            'nom_association'=> utf8_decode($association->getNom()),
                            'adresse_association'=> utf8_decode($adresse_association),
                            'code-postal_association'=> utf8_decode($code_postal_association),
                            'ville_association'=> utf8_decode($ville_association),
                            'pays_association'=> utf8_decode($pays_association),
                            'telephone_association'=> utf8_decode($association->getTel()),
                            'fax_association'=> utf8_decode($association->getFax()),
                            'mail_association'=> utf8_decode($association->getMail()),
                            'site_association' => utf8_decode($association->getSite()),
                            'ape_association'=> utf8_decode($association->getApe()),
                            'notes_association'=> utf8_decode($association->getNotes()),
                        );
        }       
       
        // Traitement des adresses de l'usager
        $adresses = array();
        foreach($usager->getPersonne()->getAdresses() as $adresse){
            // Traitement des libellés
            $pays = $adresse->getPays() ? $adresse->getPays()->getLibelle(): "";
            $type_adresse = $adresse->getTypeAdresse() ? $adresse->getTypeAdresse()->getLibelle(): "";
            $type_domicile = $adresse->getTypeDomicile() ? $adresse->getTypeDomicile()->getLibelle():"";
            // Traitement des adresses
            $adresses[] = array(
                'type_adresse'=> utf8_decode($type_adresse),
                'type_domicile'=> utf8_decode($type_domicile),
                'adresse'=> utf8_decode($adresse->getAdresse1().' - '.$adresse->getAdresse2()),
                'code_postal'=> utf8_decode($adresse->getCodePostal()),
                'ville'=> utf8_decode($adresse->getVille()),
                'pays'=> utf8_decode($pays),
                'telephone_fixe'=> utf8_decode($adresse->getTelephone())
            );
        }

        // Traitement des relations personnelles de l'usager
        $relationsPersonnelles = array();
        foreach($usager->getRelationsPersonnes() as $relation){
            $relationsPersonnelles[] = array(
                'nom_relation'=> utf8_decode($relation->getContact()->getPersonne()->getNom()),
                'prenom_relation'=> utf8_decode($relation->getContact()->getPersonne()->getPrenom()),
                'type_relation'=> utf8_decode($relation->getTypeRelation()->getLibelle()),
            );
        }
        // Traitement des relations professionnelles de l'usager
        $relationsProfessionnelles = array();
        foreach($usager->getRelationsProfessionnels() as $relation){
            $relationsProfessionnelles[] = array(
                'nom_relation'=> utf8_decode($relation->getProfessionelExterne()->getPersonne()->getNom()),
                'prenom_relation'=> utf8_decode($relation->getProfessionelExterne()->getPersonne()->getPrenom()),
            );
        }
        // Traitement des mesures de protection de l'usager
        $mesuresProtections = array();
        foreach($usager->getPersonne()->getProtectionJuridiques() as $protection){
            // Traitement des dates
            $date_deb = $protection->getDateDebutProtection() ? $protection->getDateDebutProtection()->format('d/m/Y') : "";
            $date_fin = $protection->getDateFinProtection() ? $protection->getDateFinProtection()->format('d/m/Y') : "";
            $date_fin_test = $protection->getDateFinProtection() ? $protection->getDateFinProtection()->format('Ymd') : "";
            if($date_jour<=$date_fin_test||$date_fin_test==""){$actif=1;}else{$actif=0;}
            // Traitement des libellés
            $type_mesure = $protection->getTypeMesure() ? $protection->getTypeMesure()->getLibelle() :"";
            $tribunal = $protection->getTribunal() ? $protection->getTribunal()->getNom() :"";
            if($protection->getMandataire1()){
                $mandataire1 = $protection->getMandataire1()->getPrenom().' '.$protection->getMandataire1()->getNom();
            }else{
                $mandataire1 = "";
            }
           
            if($protection->getMandataire2()){
                $mandataire2 = $protection->getMandataire2()->getPrenom().' '.$protection->getMandataire2()->getNom();
            }else{
                $mandataire2 = "";
            }
           
            if($protection->getDroitVote() == 1){
               $droitVote="Oui";
            }else{
               $droitVote="Non";
            }
           
            // Traitement des mesures
            $mesuresProtections[] = array(
                'type_mesure'=> utf8_decode($type_mesure),
                'date_deb'=> $date_deb,
                'date_fin'=> $date_fin,
                'numero_dossier'=> utf8_decode($protection->getNumDossier()),
                'etat'=> utf8_decode($protection->getEtat()),
                'tribunal'=> utf8_decode($tribunal),
                'mandataire1'=> utf8_decode($mandataire1),
                'mandataire2'=> utf8_decode($mandataire2),
                'droit_vote'=> utf8_decode($droitVote),
                'actif'=> $actif,
            );
        }
        // Traitement des MDPH de l'usager
        $mdphs = array();
        foreach($usager->getMdphs() as $mdph){
            // Traitement des dates
            $date_deb = $mdph->getDateDebutPec() ? $mdph->getDateDebutPec()->format('d/m/Y') : "";
            $date_fin = $mdph->getDateFinPec() ? $mdph->getDateFinPec()->format('d/m/Y') : "";
            $date_fin_test = $mdph->getDateFinPec() ? $mdph->getDateFinPec()->format('Ymd') : "";
            if($date_jour<=$date_fin_test||$date_fin_test==""){$actif=1;}else{$actif=0;}
            // Traitement des libellés
            $type_orientation = $mdph->getTypeOrientation() ? $mdph->getTypeOrientation()->getLibelle() :"";
            $nom_mdph = $mdph->getMdph() ? $mdph->getMdph()->getNom() :"";
            // Traitement des mesures
            $mdphs[] = array(
                'type_orientation'=> utf8_decode($type_orientation),
                'mdph'=> utf8_decode($nom_mdph),
                'ref_dossier_cdaph'=> utf8_decode($mdph->getRefDossier()),
                'date_deb'=> $date_deb,
                'date_fin'=> $date_fin,
                'actif' => $actif,
            );
        }
        // Traitement des CAF de l'usager
        $cafs = array();
        foreach($usager->getPrestationsFamiliales() as $caf){
            // Traitement des dates
            $date_deb = $caf->getDateDebut() ? $caf->getDateDebut()->format('d/m/Y') : "";
            $date_fin = $caf->getDateFin() ? $caf->getDateFin()->format('d/m/Y') : "";
            $date_fin_test = $caf->getDateFin() ? $caf->getDateFin()->format('Ymd') : "";
            if($date_jour<=$date_fin_test||$date_fin_test==""){$actif=1;}else{$actif=0;}
            // Traitement des libellés
            $organisme = $caf->getOrganisme() ? $caf->getOrganisme()->getNom() :"";
            $allocation = $caf->getTypePrestation() ? $caf->getTypePrestation()->getLibelle() :"";
            // Traitement des mesures
            $cafs[] = array(
                'organisme'=> utf8_decode($organisme),
                'allocation'=> utf8_decode($allocation),
                'allocataire'=> utf8_decode($caf->getAllocataire()->getPrenom().' '.$caf->getAllocataire()->getNom()),
                'numero_allocataire'=> utf8_decode($caf->getNumAllocataire()),
                'date_deb'=> $date_deb,
                'date_fin'=> $date_fin,
                'actif' => $actif,
            );
        }
        // Traitement des Assurances de l'usager
        $assurances = array();
        foreach($usager->getAssurances() as $assurance){
            // Traitement des dates
            $date_deb = $assurance->getDebutContrat() ? $assurance->getDebutContrat()->format('d/m/Y') : "";
            $date_fin = $assurance->getFinContrat() ? $assurance->getFinContrat()->format('d/m/Y') : "";
            $date_fin_test = $assurance->getFinContrat() ? $assurance->getFinContrat()->format('Ymd') : "";
            if($date_jour<=$date_fin_test||$date_fin_test==""){$actif=1;}else{$actif=0;}
            // Traitement des libellés
            $compagnie = $assurance->getCompagnie() ? $assurance->getCompagnie()->getNom() :"";
            $type_contrat = $assurance->getTypeAssurance() ? $assurance->getTypeAssurance()->getLibelle() :"";
            $assure = $assurance->getAssure() ? $assurance->getAssure()->getPrenom().' '.$assurance->getAssure()->getNom() : "";
            // Traitement des mesures
            $assurances[] = array(
                'compagnie'=> utf8_decode($compagnie),
                'type_contrat'=> utf8_decode($type_contrat),
                'titulaire'=> utf8_decode($assure),
                'numero_contrat'=> utf8_decode($assurance->getNumContrat()),
                'date_deb'=> $date_deb,
                'date_fin'=> $date_fin,
                'actif'=> $actif,
            );
        }
        // Traitement du parcours de l'usager
        $parcours = array();
        foreach($usager->getEntreesEtablissement() as $entree){
            // Traitement des dates
            $date_deb = $entree->getDateEntree() ? $entree->getDateEntree()->format('d/m/Y') : "";
            $date_fin = $entree->getDateSortie() ? $entree->getDateSortie()->format('d/m/Y') : "";
            $date_fin_test = $entree->getDateSortie() ? $entree->getDateSortie()->format('Ymd') : "";
            if($date_jour<=$date_fin_test||$date_fin_test==""){$actif=1;}else{$actif=0;}
            // Traitement des libellés
            $etablissement = $entree->getEtablissement() ? $entree->getEtablissement()->getNom() :"";
            $unite = $entree->getUnite() ? $entree->getUnite()->getNom() :"";
            $groupe = $entree->getGroupe() ? $entree->getGroupe()->getNom() :"";
            // Traitement des mesures
            $parcours[] = array(
                'etablissement'=> utf8_decode($etablissement),
                'unite'=> utf8_decode($unite),
                'groupe'=> utf8_decode($groupe),
                'date_deb'=> $date_deb,
                'date_fin'=> $date_fin,
                'actif'=> $actif,
            );
        }
        // Traitement des données globales
        $data = array();
        $nb_enfants =  $usager->getContexteFamilial() ? $usager->getContexteFamilial()->getNbEnfants() :"";
        $nb_freres =  $usager->getContexteFamilial() ? $usager->getContexteFamilial()->getNbFreresSoeurs() :"";
        $rang_fratrie =  $usager->getContexteFamilial() ? $usager->getContexteFamilial()->getNbFreresSoeurs() :"";
        $titulaire_autorise = $usager->getPersonne()->getProtectionParentale() ? $usager->getPersonne()->getProtectionParentale()->getTitulaireAutorise() : "";
        $assure_secu = $usager->getSecuriteSocialeUsager() && $usager->getSecuriteSocialeUsager()->getAssure() ? $usager->getSecuriteSocialeUsager()->getAssure()->getNom().' '.$usager->getSecuriteSocialeUsager()->getAssure()->getPrenom() : "";
        $num_secu = $usager->getSecuriteSocialeUsager() ? $usager->getSecuriteSocialeUsager()->getNumSecu() :""; 
        $assure_mutuelle =  $usager->getMutuelleUsager() && $usager->getMutuelleUsager()->getAssure() ? $usager->getMutuelleUsager()->getAssure()->getNom().' '.$usager->getMutuelleUsager()->getAssure()->getPrenom() : "";
        $num_mutuelle = $usager->getMutuelleUsager() ? $usager->getMutuelleUsager()->getNumAdherent() : "";
        $dpt_naissance = $usager->getDeptNaissance() ? $usager->getDeptNaissance()->getLibelle() : "";
       
        $data[] = array(
                        // Informations générales
                        'info'=>$info,
                        /*
                         * Etat Civil
                         */
                         // Personne
                        'personne'=>array(
                            'photo'=>'C:/Users/Nicolas/IMAGO/symfony/web/avatar/franchette-aurore.png',
                            'civilite'=> utf8_decode($usager->getPersonne()->getCivilite()->getLibelle()),
                            'civilite-abreviation'=> utf8_decode($usager->getPersonne()->getCivilite()->getAbreviation()),
                            'nom'=>utf8_decode($usager->getPersonne()->getNom()) ,
                            'prenom'=>utf8_decode($usager->getPersonne()->getPrenom()),
                            'sexe'=>utf8_decode($usager->getPersonne()->getSexe()),
                            'nationalite'=>utf8_decode($nationalite)
                         ),
                        // Naissance
                        'naissance'=>array(
                            'date_naissance'=>$date_naissance,
                            'lieu_naissance'=>utf8_decode($usager->getLieuNaissance()),
                            'departement_naissance'=>utf8_decode($dpt_naissance),
                            'pays_naissance'=>utf8_decode($pays_naissance),
                         ),
                        // Famille
                        'famille'=>array(
                            'situation_usager'=>utf8_decode($situation_usager),
                            'date_situation'=>$date_situation,
                            'nombre_enfants'=>utf8_decode($nb_enfants),
                            'situation_parents'=>utf8_decode($situation_parents),
                            'nombre_freres_soeurs'=>utf8_decode($nb_freres),
                            'rang_fratrie'=>utf8_decode($rang_fratrie)
                         ),
                        /*
                         * Coordonnées
                         */
                        // Contact direct Usager
                        'contact_direct_usager'=>array(
                            'telephone_portable'=>utf8_decode($usager->getTelPortable()),
                            'mail'=>utf8_decode($usager->getPersonne()->getMail())
                        ),
                        /*
                         * Protection
                         */
                         // Autorité parentale
                         'autorite_parentale'=>array(
                             'responsable'=>utf8_decode($titulaire_autorise),
                            
                         ),
                         /*
                          * Droits Ouverts
                          */
                          // Sécurité sociale
                         'securite_sociale'=>array(
                             'regime'=> utf8_decode($regime_secu),
                             'caisse'=> utf8_decode($caisse_secu),
                             'assure'=> utf8_decode($assure_secu),
                             'numero_secu'=> utf8_decode($num_secu),
                             'date_deb'=> $date_debut_secu,
                             'date_fin'=> $date_fin_secu
                         ),
                          // Mutuelle
                         'mutuelle'=>array(
                             'mutuelle'=> utf8_decode($mutuelle),
                             'adherent'=> utf8_decode($assure_mutuelle),
                             'numero_contrat'=> utf8_decode($num_mutuelle),
                             'date_deb'=> $date_debut_mut,
                             'date_fin'=>$date_fin_mut
                         ),
                        );  
        // -----------------
        // Load the template
        // -----------------
        $template = $edition->getAbsolutePath();
       
        $TBS->LoadTemplate($template); // Also merge some [onload] automatic fields (depends of the type of document).

        // Chargement des données de bases de l'usager
        $TBS->MergeBlock('imago', $data);
        // Chargement des adresses de l'usager
        $TBS->MergeBlock('imago-adresses', $adresses);
        // Chargement des relations personnelles de l'usager
        $TBS->MergeBlock('imago-relations-personnelles', $relationsPersonnelles);
        // Chargement des relations professionnelles de l'usager
        $TBS->MergeBlock('imago-relations_professionnelles', $relationsProfessionnelles);
        // Chargement des mesures de protections de l'usager
        $TBS->MergeBlock('imago-mesures_protections', $mesuresProtections);
        // Chargement des MDPHs de l'usager
        $TBS->MergeBlock('imago-mdphs', $mdphs);
        // Chargement des CAFs de l'usager
        $TBS->MergeBlock('imago-cafs', $cafs);
        // Chargement des assurances de l'usager
        $TBS->MergeBlock('imago-assurances', $assurances);   
        // Chargement du parcours de l'usager
        $TBS->MergeBlock('imago-parcours', $parcours);       
       
        // -----------------
        // Load the template headers/footers
        // -----------------
        $files= array('header1.xml', 'header2.xml', 'header3.xml', 'footer1.xml', 'footer2.xml', 'footer3.xml');
        foreach ($files as $f) {
          $fpath = 'word/' . $f;
          if ($TBS->Plugin(OPENTBS_FILEEXISTS, $fpath)) {
             $TBS->LoadTemplate('#' . $fpath);
             $TBS->MergeBlock('imago',$data);
          }
        }
       
        $output_file_name = $template_name.'-'.$usager->getPersonne()->getPrenom().'-'.$usager->getPersonne()->getNom().'.docx';
       
        $TBS->Show(OPENTBS_DOWNLOAD, $output_file_name); // Also merges all [onshow] automatic fields.
       
        // A changer
        var_dump($TBS); die();
    
       
    }

The template:
[imago.info.date_jour]
Association : [imago.info.nom_association]
Adresse : [imago.info.adresse_association]
CP : [imago.info.code-postal_association]
Ville : [imago.info.ville_association]
Pays : [imago.info.pays_association]
Tel : [imago.info.telephone_association]
Fax : [imago.info.fax_association]
Mail : [imago.info.mail_association]
Site : [imago.info.site_association]
APE :[imago.info.ape_association]
Notes : [imago.info.notes_association]

Etablissement : [imago.info.nom_etablissement]
Type : [imago.info.type_etablissement]
Adresse : [imago.info.adresse_etablissement]
CP : [imago.info.code-postal_etablissement]
Ville : [imago.info.ville_etablissement]
Pays : [imago.info.pays_etablissement]
Tel : [imago.info.telephone_etablissement]
Fax : [imago.info.fax_etablissement]
Mail : [imago.info.mail_etablissement]
Site : [imago.info.site_etablissement]
APE :[imago.info.ape_etablissement]
Notes : [imago.info.notes_etablissement]

Fiche Usager
[imago.personne.photo;ope=changepic;tagpos=after]
Civilité : [imago.personne.civilite]
Civilité courte : [imago.personne.civilite-abreviation]
Nom : [imago.personne.nom]
Prénom : [imago. personne.prenom]
Nationalité : [imago. personne.nationalite]
[imago.personne.photo;ope=changepic;tagpos=after]

Naissance
Date de naissance : [imago.naissance.date_naissance]
Lieu de naissance : [imago.naissance.lieu_naissance]
Département de naissance : [imago.naissance.departement_naissance]
Pays de naissance : [imago.naissance.pays_naissance]
Famille
Situation : [imago.famille.situation_usager]
Date de situation : [imago.famille.date_situation]
Nombre d’enfants : [imago.famille.nombre_enfants]
Situation parents : [imago.famille.situation_parents]
Nombre de frère(s) et/ou sœur(s) : [imago.famille.nombre_freres_soeurs]
Rang dans la fratrie : [imago.famille.rang_fratrie]

Coordonnées
Contact direct de l’usager :
-    Telephone portable : [imago.contact_direct_usager.telephone_portable]
-    Adresse mail : [imago.contact_direct_usager.mail]
Adresses :
[imago-adresses;block=begin;when [imago-adresses.type_adresse]=’Adresse personnelle’]
-     [imago-adresses.type_adresse]
o    [imago-adresses.type_domicile]
o    [imago-adresses.adresse]
o    [imago-adresses.code_postal]
o    [imago-adresses.ville]
o    [imago-adresses.pays]
o    [imago-adresses.telephone_fixe]
[imago-adresses;block=end]
Relations
Relations personnelles :
[imago-relations-personnelles;block=begin;when [imago-relations-personnelles.type_relation]=’Mère’]
-    [imago-relations-personnelles.nom_relation] [imago-relations-personnelles.prenom_relation]
[imago-relations-personnelles;block=end]
[imago-relations-personnelles;block=begin;when [imago-relations-personnelles.type_relation]=’Père’]
-    [imago-relations-personnelles.nom_relation] [imago-relations-personnelles.prenom_relation]
[imago-relations-personnelles;block=end]

Relations professionnelles :
[imago-relations_professionnelles;block=begin]
-    [imago-relations_professionnelles.nom_relation] [imago-relations_professionnelles.prenom_relation]
[imago-relations_professionnelles;block=end]
Protection
Autorité parentale :
    Responsable : [imago.autorite_parentale.responsable]
Mesures de protection :
[imago-mesures_protections;block=begin]
-    [imago-mesures_protections.type_mesure] du [imago-mesures_protections.date_deb] au [imago-mesures_protections.date_fin]
o    Numéro de dossier : [imago-mesures_protections.numero_dossier]
o    Etat : [imago-mesures_protections.etat]
o    Tribunal : [imago-mesures_protections.tribunal]
o    Mandataire 1 : [imago-mesures_protections.mandataire1]
o    Mandataire 2 : [imago-mesures_protections.mandataire2]
o    Droit de vote :  [imago-mesures_protections.droit_vote]
[imago-mesures_protections;block=end]
Droits ouverts
Santé :
    Sécurité sociale :
        Régime : [imago.securite_sociale.regime]
        Caisse : [imago.securite_sociale.caisse]
        Assuré : [imago.securite_sociale.assure]
        N° Sécurité Sociale : [imago.securite_sociale.numero_secu]
Date de début de prise en charge : [imago.securite_sociale.date_deb]
Date de fin de prise en charge : [imago.securite_sociale.date_fin]
    Mutuelle :
        Mutuelle : [imago.mutuelle.mutuelle]
        Adhérent : [imago.mutuelle.adherent]
        N° de contrat : [imago.mutuelle.numero_contrat]
        Date de début de contrat : [imago.mutuelle.date_deb]
        Date de fin de contrat : [imago.mutuelle.date_fin]
MDPH :

[imago-mdphs;block=begin;when [imago-mdphs.actif]=1]
-    N°[imago-mdphs. ref_dossier_cdaph] - [imago-mdphs.type_orientation] du [imago-mdphs.date_deb] au [imago-mdphs.date_fin]
o    Type d’orientation : [imago-mdphs.type_orientation]
o    MDPH : [imago-mdphs.mdph]
o    Référence du dossier CDAPH : [imago-mdphs.ref_dossier_cdaph]
o    Date de début : [imago-mdphs.date_deb]
o    Date de fin : [imago-mdphs.date_fin]
[imago-mdphs;block=end]

CAF :
[imago-cafs;block=begin]
-    N°[imago-cafs.numero_allocataire] du [imago-cafs.date_deb] au [imago-cafs.date_fin]
o    Organisme : [imago-cafs.organisme]
o    Allocation : [imago-cafs.allocation]
o    Allocataire : [imago-cafs.allocataire]
o    N° d’allocataire : [imago-cafs.numero_allocataire]
o    Date de début : [imago-cafs.date_deb]
o    Date de fin : [imago-cafs.date_fin]
[imago-cafs;block=end]

Assurances :
[imago-assurances;block=begin]
-    N°[imago-assurances.numero_contrat] - [imago-assurances.type_contrat] du [imago-assurances.date_deb] au [imago-assurances.date_fin]
o    Compagnie : [imago-assurances.compagnie]
o    Type de contrat : [imago-assurances.type_contrat]
o    Titulaire : [imago-assurances.titulaire]
o    N° de contrat : imago-assurances.numero_contrat]
o    Date de début : [imago-assurances.date_deb]
o    Date de fin : [imago-assurances.date_fin]
[imago-assurances;block=end]
       

Vie dans l’assocation
Parcours :
[imago-parcours;block=begin]
-    [imago-parcours.etablissement] du [imago-parcours.date_deb] au [imago-parcours.date_fin]
o    Etablissement : [imago-parcours.etablissement]
o    Unité : [imago-parcours.unite]
o    Groupe : [imago-parcours.groupe]
o    Date de début : [imago-parcours.date_deb]
o    Date de fin : [imago-parcours.date_fin]
[imago-parcours;block=end]


It's quite huge I know but maybe there is something wrong in this!
By: Skrol29
Date: 2014-07-08
Time: 11:35

Re: Path for picture with SF2 controller

fr: Peux-tu m'envoyer le modèle DOCX et le résultat DOCX ?

en: can you send to me the DOCX template and the DOCX result ?
By: ErA
Date: 2014-07-08
Time: 11:54

Re: Path for picture with SF2 controller

FR: C'est envoyé.
EN: It's sent.
By: ErA
Date: 2014-07-09
Time: 14:49

Re: Path for picture with SF2 controller

Hi all,

I want to thank Skrol29 for his help and support to solve my issue.

The fact was that I forget to insert a default picture in my DOCX. The TBS tag has to go in the desciption property of the picture.
At this time my picture was well import in my DOCX but the result file was corrupted.
The var_dump($TBS) in my call was responsible of this error because of HTML injection in the picture import which corrupted the DOCX result.

Thank you very much again Skrol29. This issue is resolved.
By: Skrol29
Date: 2014-07-09
Time: 14:54

Re: Path for picture with SF2 controller

You're welcome.