IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MkFramework Discussion :

Html2pdf Ligne entête qui se répète pour chaque enregistrement


Sujet :

MkFramework

  1. #1
    Membre éprouvé
    Homme Profil pro
    Benevole
    Inscrit en
    Mai 2004
    Messages
    1 679
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Benevole
    Secteur : Enseignement

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 679
    Points : 954
    Points
    954
    Par défaut Html2pdf Ligne entête qui se répète pour chaque enregistrement
    Bonsoir Imikado

    Etant toujours sur mon projet je suis confronté a un problème de rendu. En effet au rendu avec Html2pdf, j'ai l'entête du tableau qui se répète :

    Voici le code dans le main de mon module :
    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
     
    public function _pdf(){
     
    	$tableauDobjet=model_mypaiment::getInstance()->findAll();
     	$sHTMLGlobal='';
     
    	foreach($tableauDobjet as $object){
     		$oView=$this->generateViewForObject($object);
    		$sHTMLGlobal.=$oView->show();
     	}
             $html2pdf=new HTML2PDF('P','A4','fr');
        	$html2pdf->WriteHTML($sHTMLGlobal);
        	$html2pdf->Output('fiche.pdf');
     }
     
     public function generateViewForObject($object){
    	$oView=new _view('mypaiment::pdf');
    	$oView->tmypaiment=$object;
     
    	$oView->tJoinmodel_naturepaiment=model_naturepaiment::getInstance()->getSelect();		
    	$oView->tJoinmodel_modepaiment=model_modepaiment::getInstance()->getSelect();		
    	$oView->tJoinmodel_paliers=model_paliers::getInstance()->getSelect();
     
    	return $oView;
    }

    Le code de ma vue :
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
     
    <style type="text/css">
    #centreur { 
            width:100%; text-align:center; 
            }
    .montableau { 
            width:500px; margin:auto; 
            }
            
    .montableau {
    border: medium solid #6495ed;
    border-collapse: collapse;
    width: 70%;
    }
    th {
    border: thin solid #6495ed;
    width: 20%;
    padding: 5px;
    background-color: #D0E3FA;
    }
    td {
    border: thin solid #6495ed;
    width: 20%;
    padding: 5px;
    text-align: center;
    background-color: #ffffff;
    }
    caption {
    font-family: sans-serif;
    }
     
    </style>
     
    <div id="centreur">
    <table class="montableau" border="1">
       <tr>
           <th>Code</th>
           <th>Nom Complet</th>
           <th>Palier</th>
           <th>Mode de Paiement</th>
           <th>Nature du Paiment</th>
           <th>Montant du Paiement</th>
           <th>Reference du Paiement</th>
       </tr>
     
       <tr>
           <td><?php echo $this->tmypaiment->codeunpai ?></td>
           <td><?php echo $this->tmypaiment->nomcomppai ?></td>
           <td><?php echo $this->tmypaiment->palierpai ?></td>
            <td><?php echo $this->tmypaiment->modepaie ?></td>
            <td><?php echo $this->tmypaiment->naturepai ?></td>
           <td><?php echo $this->tmypaiment->montpai ?></td>
           <td><?php echo $this->tmypaiment->refpai ?></td>
       </tr>
     
    </table>
    </div>

    et voici mon rendu :
    Nom : CaptureTableau.JPG
Affichages : 771
Taille : 38,1 Ko

    1 - Ici Code, Nom, Complet, Palier, Mode de Paiement, Nature du Paiement, Montant du Paiement, Reference du Paiement, se répètent pour chaque enregistrement, mais je ne sais comment résoudre se problème ? c'est à dire afficher une fois l’entête.

    2 - Pour Palier, Mode de Paiement, Nature du Paiement je veux bien récupérer ces données afférentes mais il me ramène les clés étrangères. je pense qu'il est bien possible de le faire avec tJoinmodel_... un peu comme dans ma fonction liste :
    extrait :
    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    <td><?php if(isset($this->tJoinmodel_paliers[$omypaiment->palierpai]))
    		{ echo $this->tJoinmodel_paliers[$omypaiment->palierpai];}
    		else{ echo $omypaiment->palierpai ;}?></td>

    Merci pour ton aide

  2. #2
    Rédacteur
    Avatar de imikado
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    5 239
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 239
    Points : 19 100
    Points
    19 100
    Billets dans le blog
    17
    Par défaut
    Bonjour,
    Oui c'est normal , je pense que vous avez mis le header + le code de la ligne au sein de votre vue generateViewForObject() (vue: mypaiment::pdf)

    vous devez ajouter une vue "debut" tableau pdf (avec juste le tableau + header)

    et fin de tableau avec le code de fin du tableau

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
     
    public function _pdf(){
     
    	$tableauDobjet=model_mypaiment::getInstance()->findAll();
     	$sHTMLGlobal='';
     
    	//ici appel code pdf header
    	$oViewHeader=$this->generateViewHeader();
    	$sHTMLGlobal.=$oViewHeader->show();
     
    	foreach($tableauDobjet as $object){
     		$oView=$this->generateViewForObject($object);
    		$sHTMLGlobal.=$oView->show();
     	}
     
    	//ici appel code pdf footer
    	$oViewFooter=$this->generateViewFooter();
    	$sHTMLGlobal.=$oViewFooter->show();
     
     
             $html2pdf=new HTML2PDF('P','A4','fr');
        	$html2pdf->WriteHTML($sHTMLGlobal);
        	$html2pdf->Output('fiche.pdf');
     }
    Framework php sécurisé et simple à prendre en main avec générateur web http://mkframework.com/ (hebergé sur developpez.com)
    Mes cours/tutoriaux

  3. #3
    Membre éprouvé
    Homme Profil pro
    Benevole
    Inscrit en
    Mai 2004
    Messages
    1 679
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Benevole
    Secteur : Enseignement

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 679
    Points : 954
    Points
    954
    Par défaut
    Bonjour Imikado

    j'avoue que j'ai pas bien compris. Mais voila ce que j'ai produit en fonction de ce que j'ai compris
    j'ai ajouté des lignes dans les deux fonctions code :

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
     
    public function generateViewHeader(){
    	$content = "<table><tr><td>ENTETE DE DOCUMENT</td></tr></table>";
    }
     
    public function generateViewFooter(){
    	$content = "<table><tr><td>PIED DE DOCUMENT</td></tr></table>";
     
    }
     
    public function generateViewForObject($object){
    	$oView=new _view('mypaiment::pdf');
    	$oView->tmypaiment=$object;
     
    	$oView->tJoinmodel_naturepaiment=model_naturepaiment::getInstance()->getSelect();		
    	$oView->tJoinmodel_modepaiment=model_modepaiment::getInstance()->getSelect();		
    	$oView->tJoinmodel_paliers=model_paliers::getInstance()->getSelect();
     
    	return $oView;
    }
     
    public function _pdf(){
     
    	$tableauDobjet=model_mypaiment::getInstance()->findAll();
     	$sHTMLGlobal='';
     
    	//ici appel code pdf header
    	$oViewHeader=$this->generateViewHeader();
    	$sHTMLGlobal.=$oViewHeader->show();
     
    	foreach($tableauDobjet as $object){
     		$oView=$this->generateViewForObject($object);
    		$sHTMLGlobal.=$oView->show();
     	}
     
    	//ici appel code pdf footer
    	$oViewFooter=$this->generateViewFooter();
    	$sHTMLGlobal.=$oViewFooter->show();
     
     
             $html2pdf=new HTML2PDF('P','A4','fr');
        	$html2pdf->WriteHTML($sHTMLGlobal);
        	$html2pdf->Output('fiche.pdf');
     }

    Mais à l'exécution j'ai le massage d'erreur suivant :
    Fatal error: Uncaught Error:
    Call to a member function show() on null in C:\wamp\www\mkframework\Projects\mybill\module\mypaiment\main.php on line 43
    ( ! ) Error: Call to a member function show() on null in C:\wamp\www\mkframework\Projects\mybill\module\mypaiment\main.php on line 43
    Merci de m'aider, je cherche toujours !

  4. #4
    Rédacteur
    Avatar de imikado
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    5 239
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 239
    Points : 19 100
    Points
    19 100
    Billets dans le blog
    17
    Par défaut
    Oui c'est normal, je suis parti du principe comme sur l'autre meethode que vous alliez instancier une object _view et le retourner (d'ou le show)

    hors ici vous envoyez une chaine de caractère dans ce cas il faut faire comme suit:

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
     
     
    public function generateViewHeader(){
    	$content = "<table><tr><td>ENTETE DE DOCUMENT</td></tr></table>";
    }
     
    public function generateViewFooter(){
    	$content = "<table><tr><td>PIED DE DOCUMENT</td></tr></table>";
     
    }
     
    public function generateViewForObject($object){
    	$oView=new _view('mypaiment::pdf');
    	$oView->tmypaiment=$object;
     
    	$oView->tJoinmodel_naturepaiment=model_naturepaiment::getInstance()->getSelect();		
    	$oView->tJoinmodel_modepaiment=model_modepaiment::getInstance()->getSelect();		
    	$oView->tJoinmodel_paliers=model_paliers::getInstance()->getSelect();
     
    	return $oView;
    }
     
    public function _pdf(){
     
    	$tableauDobjet=model_mypaiment::getInstance()->findAll();
     	$sHTMLGlobal='';
     
    	//ici appel code pdf header
    	$sHTMLGlobal.=$this->generateViewHeader();
     
    	foreach($tableauDobjet as $object){
     		$oView=$this->generateViewForObject($object);
    		$sHTMLGlobal.=$oView->show();
     	}
     
    	//ici appel code pdf footer
    	$sHTMLGlobal.=$this->generateViewFooter();
     
     
             $html2pdf=new HTML2PDF('P','A4','fr');
        	$html2pdf->WriteHTML($sHTMLGlobal);
        	$html2pdf->Output('fiche.pdf');
     }
    Framework php sécurisé et simple à prendre en main avec générateur web http://mkframework.com/ (hebergé sur developpez.com)
    Mes cours/tutoriaux

  5. #5
    Membre éprouvé
    Homme Profil pro
    Benevole
    Inscrit en
    Mai 2004
    Messages
    1 679
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Benevole
    Secteur : Enseignement

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 679
    Points : 954
    Points
    954
    Par défaut
    Bonjour Imikado

    Citation Envoyé par imikado Voir le message
    Oui c'est normal, je suis parti du principe comme sur l'autre methode que vous alliez instancier une object _view et le retourner (d'ou le show)
    j'aimerai bien savoir comment faire ? puis je avoir un bout de code ?

    Citation Envoyé par imikado Voir le message
    hors ici vous envoyez une chaine de caractère dans ce cas il faut faire comme suit:

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
     
     
    public function generateViewHeader(){
    	$content = "<table><tr><td>ENTETE DE DOCUMENT</td></tr></table>";
    }
     
    public function generateViewFooter(){
    	$content = "<table><tr><td>PIED DE DOCUMENT</td></tr></table>";
     
    }
     
    public function generateViewForObject($object){
    	$oView=new _view('mypaiment::pdf');
    	$oView->tmypaiment=$object;
     
    	$oView->tJoinmodel_naturepaiment=model_naturepaiment::getInstance()->getSelect();		
    	$oView->tJoinmodel_modepaiment=model_modepaiment::getInstance()->getSelect();		
    	$oView->tJoinmodel_paliers=model_paliers::getInstance()->getSelect();
     
    	return $oView;
    }
     
    public function _pdf(){
     
    	$tableauDobjet=model_mypaiment::getInstance()->findAll();
     	$sHTMLGlobal='';
     
    	//ici appel code pdf header
    	$sHTMLGlobal.=$this->generateViewHeader();
     
    	foreach($tableauDobjet as $object){
     		$oView=$this->generateViewForObject($object);
    		$sHTMLGlobal.=$oView->show();
     	}
     
    	//ici appel code pdf footer
    	$sHTMLGlobal.=$this->generateViewFooter();
     
     
             $html2pdf=new HTML2PDF('P','A4','fr');
        	$html2pdf->WriteHTML($sHTMLGlobal);
        	$html2pdf->Output('fiche.pdf');
     }
    je viens d'essaiyer ces lignes de codes mais pas de changement. l'entête se répète toujours.

    Merci

  6. #6
    Rédacteur
    Avatar de imikado
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    5 239
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2006
    Messages : 5 239
    Points : 19 100
    Points
    19 100
    Billets dans le blog
    17
    Par défaut
    Bonjour

    dans votre vue pdf, il faut enlever le header avec le tr et th

    pour info j'avais pas vu mon erreur dans mon exemple de code, c'est:

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
     
     
     
    public function generateViewHeader(){
    	$content = '
    <style type="text/css">
    #centreur { 
            width:100%; text-align:center; 
            }
    .montableau { 
            width:500px; margin:auto; 
            }
     
    .montableau {
    border: medium solid #6495ed;
    border-collapse: collapse;
    width: 70%;
    }
    th {
    border: thin solid #6495ed;
    width: 20%;
    padding: 5px;
    background-color: #D0E3FA;
    }
    td {
    border: thin solid #6495ed;
    width: 20%;
    padding: 5px;
    text-align: center;
    background-color: #ffffff;
    }
    caption {
    font-family: sans-serif;
    }
     
    </style>
     
    <div id="centreur">
    <table class="montableau" border="1">
       <tr>
           <th>Code</th>
           <th>Nom Complet</th>
           <th>Palier</th>
           <th>Mode de Paiement</th>
           <th>Nature du Paiment</th>
           <th>Montant du Paiement</th>
           <th>Reference du Paiement</th>
       </tr>
     
     
    ';
     
    	return $content;
    }
     
    public function generateViewFooter(){
    	$content = "<tr><th>PIED DE DOCUMENT</th></tr></table></div>";
    	return $content;
    }
     
    public function generateViewForObject($object){
    	$oView=new _view('mypaiment::pdf');
    	$oView->tmypaiment=$object;
     
    	$oView->tJoinmodel_naturepaiment=model_naturepaiment::getInstance()->getSelect();		
    	$oView->tJoinmodel_modepaiment=model_modepaiment::getInstance()->getSelect();		
    	$oView->tJoinmodel_paliers=model_paliers::getInstance()->getSelect();
     
    	return $oView;
    }
     
    public function _pdf(){
     
    	$tableauDobjet=model_mypaiment::getInstance()->findAll();
     	$sHTMLGlobal='';
     
    	//ici appel code pdf header
    	$sHTMLGlobal.=$this->generateViewHeader();
     
    	foreach($tableauDobjet as $object){
     		$oView=$this->generateViewForObject($object);
    		$sHTMLGlobal.=$oView->show();
     	}
     
    	//ici appel code pdf footer
    	$sHTMLGlobal.=$this->generateViewFooter();
     
     
             $html2pdf=new HTML2PDF('P','A4','fr');
        	$html2pdf->WriteHTML($sHTMLGlobal);
        	$html2pdf->Output('fiche.pdf');
     }

    modifier votre vue mypaiment::pdf ainsi:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
     
     
     
       <tr>
           <td><?php echo $this->tmypaiment->codeunpai ?></td>
           <td><?php echo $this->tmypaiment->nomcomppai ?></td>
           <td><?php echo $this->tmypaiment->palierpai ?></td>
            <td><?php echo $this->tmypaiment->modepaie ?></td>
            <td><?php echo $this->tmypaiment->naturepai ?></td>
           <td><?php echo $this->tmypaiment->montpai ?></td>
           <td><?php echo $this->tmypaiment->refpai ?></td>
       </tr>
    Framework php sécurisé et simple à prendre en main avec générateur web http://mkframework.com/ (hebergé sur developpez.com)
    Mes cours/tutoriaux

  7. #7
    Membre éprouvé
    Homme Profil pro
    Benevole
    Inscrit en
    Mai 2004
    Messages
    1 679
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Côte d'Ivoire

    Informations professionnelles :
    Activité : Benevole
    Secteur : Enseignement

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 679
    Points : 954
    Points
    954
    Par défaut
    Bonsoir Imikado

    je pense avoir bien compris maintenant, ça me donne du champ pour le reste.

    Merci

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 5
    Dernier message: 18/03/2013, 17h10
  2. Réponses: 3
    Dernier message: 04/07/2012, 13h33
  3. Réponses: 4
    Dernier message: 24/01/2011, 20h50
  4. Réponses: 11
    Dernier message: 01/03/2006, 10h32
  5. Réponses: 1
    Dernier message: 08/12/2005, 20h58

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo