du0204 2018-06-28 10:57
浏览 36
已采纳

PDF转换库的数据呈现问题

I'm working on a small functionality that render data retrieved from the database in a chart whereby data are diplayed monthly. Since the users are French speaking people, I'm trying to translate months data in French using the commented code snippet in the following script.

<?php

    function getMonths($begin, $end)
    {
        $monthsData = array();

        $dateBegin = new \DateTime($begin);
        $dateEnd = new \DateTime($end);

        while ($dateBegin->getTimestamp() < $dateEnd->getTimestamp()) {
            $monthsData[] = $dateBegin->format('F Y');
            $dateBegin->add(new \DateInterval('P1M'));
        }

        return $monthsData;
    }


    $monthsData = getMonths('2018-05-01', '2020-01-01' );


    $percentApporteurData = $_SESSION['reqPourcentageApporteur'];

    $recupapporteur = "select * from apporteuraffaire where id_apporteur ='".$useridapporteur."'";
    $execrecupapporteur = mysql_query($recupapporteur);
    $apporteur = mysql_fetch_assoc($execrecupapporteur);



    $recupcodepromo = "select * from codepromo where codepromo ='".$apporteur['codeapporteur']."'";
    $execrecupcodepromo = mysql_query($recupcodepromo);
    $codepromo = mysql_fetch_assoc($execrecupcodepromo);



  $listeventes = "select * from reporting_formulaire2 where codepromo ='".$codepromo['idcodepromo']."' and codepromo <> 0 and numeroattestation<>'' and statusachat>9 and statusachat<>15 and statusachat<>14 and statusachat<19 ORDER BY  `idformulaire2` DESC ";    
            $exelisteaffaire = mysql_query($listeventes);
            $nombreaffaire =  mysql_num_rows($exelisteaffaire);
            $rf2Data = mysql_fetch_assoc($exelisteaffaire);

            $_SESSION['rf2Data'] = $rf2Data;

?>

<?php
if ($nombreaffaire > 0) {
?>


<?php 
    $listeville="SELECT * FROM  `villedumaroc` where idville='".$apporteur['villeapporteur']."' ";
    $exelisteville=  mysql_query($listeville);
    $resultatville=mysql_fetch_assoc($exelisteville);
?>

<?php

$reqClients = "select DATE_FORMAT(datemodificationstatus, '%M %Y') AS datemodif, SUM(prixpack) AS montant_du_mois  
from reporting_formulaire2 where codepromo ='".$codepromo['idcodepromo']."' and codepromo <> 0 and numeroattestation<>'' 
and statusachat>9 and statusachat<>15 and statusachat<>14 and statusachat<19 
group by datemodif
ORDER BY  `idformulaire2` DESC";
$execReqClient = mysql_query($reqClients);

$grid = array();
while ($client = mysql_fetch_assoc($execReqClient) ) {
    $grid[$client['datemodif']] = number_format(($client['montant_du_mois'] * $percentApporteurData['pourcentage_valeur']/100), 2,',',' ');
}

}

?>

<div class="col-sm-offset-2">
    <center>
        <table class="table table-striped table-hover table-bordered">
    <tr>
        <td><strong>Mois</strong></td>
        <td><strong>Gains (Dhs)</strong></td>
        <td><strong>Fiche comptable du mois</strong></td>
    </tr>
    <?php
        foreach ($grid as $key => $value) {

        /*$yearMonths = array(
            "January" => "Janvier",
            "February" => "Février",
            "March" => "Mars",
            "April" => "Avril",
            "May" => "Mai",
            "June" => "Juin",
            "July" => "Juillet",
            "August" => "Août",
            "September" => "Septembre",
            "October" => "Octobre",
            "November" => "Novembre",
            "December" => "Décembre",
        );

        $key = explode(' ',$key);
        foreach ($yearMonths as $k => $v) {
            //$k = explode(' ', $k);
            if ($key[0] == $k) {
                $key = $v.' '.$key[1];
            }
        }*/




            ?>

                <tr>
                    <td><?php echo $key; ?></td>
                    <td><?php echo $value; ?></td>
                    <td>
                        <?php  ob_start(); ?> 
                        <div class="col-sm-12 col-xs-12 col-lg-12">
                            <table width='700px' colspan='1' rowspan='1'>
                                <tr>
                                    <td>
                                        <center>
                                            <br>
                                            <img src="img/logo-helvetica-by-sanad.png">
                                        </center>
                                    </td>
                                </tr>  
                            </table>
                            <br><br><br>

                        </div>

                        <div class="col-sm-12 col-xs-12 col-lg-12">

                        <table width='700px' colspan='1' rowspan='1'>
                            <tr>
                                <td>
                                    <center> 
                                        <br> 
                                        <b><u>AFFAIRES DU MOIS (<?php echo $key; ?>)</b></u> 
                                    </center>
                                </td>
                            </tr>
                        </table>    
                        <br><br>
                        <table style="border-style:solid; border-width:1px;background-color: grey;margin-top: 3px;margin-bottom: 3px;" border=1 width='700px' colspan='1' rowspan='1'>
                            <tr style="background-color: #fff;height: 40px;">
                                <td  align='left' style="height: 40px;width: 33%;padding: 0px 5px 5px 5px;">

                                    <center>   
                                        <table style="background-color: grey;width: 240px;height: 20px;">
                                            <tr><td style="text-align: center;"><p style="color: #fff;margin-bottom: 0px;"><b>Apporteur d&apos;affaires</b></p></td></tr>
                                        </table>
                                    </center>
                                    <br>
                                    <table style="width: 100%;border-color: gray;border-left: 0px;border-right: 0px;border-top: 0px;border-bottom: 0px;margin-top: 3px;" border="2"  cellpadding=2 cellspacing=2>
                                        <tr>
                                            <td style="width: 20%;">Nom et pr&eacute;nom</td>
                                            <td style="background-color: #ebebeb;width: 40%;">&nbsp;<?php echo $apporteur['nomapporteur']." ".$apporteur['prenomapporteur']; ?></td>
                                            <td style="width: 20%;" >&nbsp;E-mail</td>
                                            <td style="background-color: #ebebeb;width: 20%">&nbsp;<?php echo $apporteur['emailapporteur'];?></td>
                                        </tr>
                                        <tr>
                                            <td style="width: 20%;">T&eacute;l&eacute;phone</td>
                                            <td style="background-color: #ebebeb;width: 40%;">&nbsp;<?php echo $apporteur['telephoneapporteur'];?></td>
                                            <td style="width: 20%;" >&nbsp;Ville</td>
                                            <td style="background-color: #ebebeb;width: 20%">&nbsp;<?php echo $resultatville['nomville'];?></td>
                                        </tr>
                                    </table>
                                </td>    
                            </tr>
                        </table>
                        </div>
                        <br><br>

                    <div class="col-sm-12 col-xs-12 col-lg-12">

                        <table style="border-style:solid;border-color: grey; border-width:1px;background-color: grey;margin-top: 3px;margin-bottom: 3px;" border=1 width='700px' colspan='1' rowspan='1'>
                            <br><br>
                            <tr style="background-color: #fff;">
                                <td colspan="5">
                                    <center>
                                        <table style="background-color: grey; width: 240px;height: 20px;margin-top: 3px;margin-bottom: 3px;">
                                            <tr>
                                                <td style="text-align: center;">

                                                    <p style="color: #fff;margin-bottom: 0px;"><b>Commissions</b></p>

                                                </td>
                                            </tr>
                                        </table>
                                    </center>
                                </td>
                            </tr>
                            <br><br>
                            <tr style="background-color: #d6d6d6;font-weight: 700;">
                                <td>&nbsp;Client</td>
                                <td style="text-align: center;">&nbsp;Pack&nbsp;</td> 
                                <td style="text-align: center;">&nbsp;Prix du pack&nbsp;</td>
                                <td style="text-align: center;">&nbsp;Pourcentage&nbsp;</td>
                                <td style="text-align: center;">&nbsp;Commission&nbsp;</td>
                            </tr>    

                            <?php
                            $listeventes = "select nom, prenom, nomprenom, pack, prixpack, DATE_FORMAT(datemodificationstatus, '%M %Y') AS datemodifstatut  from reporting_formulaire2 where codepromo ='".$codepromo['idcodepromo']."' and codepromo <> 0 and numeroattestation<>'' and statusachat>9 and statusachat<>15 and statusachat<>14 and statusachat<19 ORDER BY  `idformulaire2` DESC ";    
            $exelisteaffaire = mysql_query($listeventes);
            $nombreaffaire =  mysql_num_rows($exelisteaffaire);
            //$rf2Data = mysql_fetch_assoc($exelisteaffaire);
                                $afrs = array();
                                $array = array();

                                    while ($ref = mysql_fetch_assoc($exelisteaffaire)) {
                                        $mois = $ref['datemodifstatut']; 
                                            $array[$mois] = array();
                                            $array[$mois][$ref['nomprenom']] = array();
                                            $array[$mois][$ref['nomprenom']]['nomprenom'] = $ref['nomprenom'] ;
                                        $array[$mois][$ref['nomprenom']]['pack'] = $ref['pack'];
                                        $array[$mois][$ref['nomprenom']]['prixpack'] = $ref['prixpack'];
                                        $array['pourcentage'] = $percentApporteurData['pourcentage_valeur'];
                                    }



                                    foreach ($array as $index => $val) {

                                        if ($index == $key) {

                                            foreach ($array[$key] as $n => $arr){


                            ?>
                            <tr style="background-color: #fff;">
                                <td><b>&nbsp;<?php echo $arr['nomprenom']; ?></b></td>
                                <td style="text-align: center;">&nbsp;<?php echo $arr['pack']; ?></td>
                                <td style="text-align: center;">&nbsp;<?php echo $arr['prixpack']; ?></td>
                                <td style="text-align: right;padding-right: 4px;">
                                    <?php 
                                        if (isset($percentApporteurData['pourcentage_valeur']) && is_numeric($percentApporteurData['pourcentage_valeur'])) {
                                            echo $percentApporteurData['pourcentage_valeur'];
                                        } else {
                                            echo "0";
                                        }
                                    ?>
                                </td>
                                <td style="text-align: right;padding-right: 4px;">
                                    <?php

                                        $percentage = 0;
                                        if (isset($percentApporteurData['pourcentage_valeur']) && is_numeric($percentApporteurData['pourcentage_valeur'])) {
                                            $percentage = $percentApporteurData['pourcentage_valeur'];
                                        }
                                        echo number_format(($arr['prixpack'] * $percentage / 100), 2,',',' ');
                                        $afr = $arr['prixpack'] * $percentage / 100;
                                        $afrs[] = $afr;
                                    ?>
                                </td>

                            </tr>
                            <?php

                                $totalAfrs = 0;
                                for ($i = 0; $i < count($afrs); $i++) { 
                                    $totalAfrs += $afrs[$i];

                                }

                                $array[$mois]['total'] = $totalAfrs;
                            ?>                         

                            <tr style="background-color: #fff;height: 20px;"><td colspan="5" height='40'></td></tr>                  

                            <tr style="background-color: #fff;">
                                <td colspan="4" style="text-align: right;"><b>Total&nbsp;</b></td>

                                <td style="background-color: #d6d6d6;text-align: right;padding-right: 4px;"> &nbsp;
                                    <?php
                                        echo number_format($totalAfrs,2,',',' ');  
                                    ?>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div>    
                        <p style="font-size: 12px;text-align: left;">  
                            <br><br><br><br>
                            Ce montant total de vos commissions <span style="font-weight: bold;">(<?php echo number_format($totalAfrs,2,',',' '); ?> Dhs)</span> vous sera vers&eacute; sur votre compte bancaire n&deg; <?php echo $apporteur['ribcomplet'];?>
                        </p>
                        <p style="font-size: 12px;text-align: left;">  
                            <br><br><br><br>
                            Fait &agrave; Casablanca, le <?php echo date('d/m/Y');?>
                        </p>
                        <br><br>
                    </div>                            

                    <?php $monthContent = ob_get_clean(); ?>   
                    <?php 

                        require_once( 'pdf/MPDF57/mpdf.php'); // Include mdpf
                        $stylesheet = file_get_contents('pdf/pdf.css'); // Get css content
                        $html = '<div id="pdf-content">
                                    Your PDF Content goes here (Text/HTML)
                                </div>';
                        // Setup PDF
                        //$mpdf = new mPDF('utf-8', 'A4-L'); // New PDF object with encoding & page size
                        $mpdf = new mPDF('utf-8', 'A4'); // New PDF object with encoding & page size
                        $mpdf->setAutoTopMargin = 'stretch'; // Set pdf top margin to stretch to avoid content overlapping
                        $mpdf->setAutoBottomMargin = 'stretch'; // Set pdf bottom margin to stretch to avoid content overlapping
                        // PDF header content
                        $mpdf->SetHTMLHeader('<div class="pdf-header">

                                              </div>'); 
                        // PDF footer content                      
                        $mpdf->SetHTMLFooter('<div class="pdf-footer">

                                              </div>'); 

                        $mpdf->WriteHTML($stylesheet,1); // Writing style to pdf
                        $content = mb_convert_encoding($content, 'UTF-8', 'UTF-8');
                        $mpdf->WriteHTML($monthContent); // Writing html to pdf
                        //$mpdf->Output('lubus_mdpf_demo6.pdf','D'); // For Download

                        //$nomfichierserveur="pdf/save/apporteuraffaire/comptabilite/test.pdf";
                        $fichierPDF = "pdf/save/apporteuraffaire/comptabilite/".str_replace(' ','',$key)."_".$apporteur['nomapporteur']."-".$apporteur['prenomapporteur']."_Fiche-Comptable.pdf";

                        $mpdf->Output($fichierPDF, 'F');//enregistrer sur serveur

                    ?> 

                        <a href="<?php echo $fichierPDF; ?>" class="list-group-item">
                            <img width="10%" height="10%" src="img/logopdf.png" />
                        </a>

                    </td>
                </tr>
            <?php

            }
                                        }
                                    }

        }
    ?>
</table>
    </center>
</div>

My script above is rendering this view: enter image description here

Whenever I uncomment the commented code snippet so I can translate months names in French, I'm having this output:

enter image description here

The output that you see above is the content of PDF files. Any suggestions?

P.S: this how the commented code snippet is working when tested separately:

<?php
$grid = array(
    "February 2018" => 498.90,
    "June 2018" => 1000,
    "May 2018" => 500.00,
    "April 2018" => 300.90,
    "March 2018" => 250.50,
);



$yearMonths = array(
    "January" => "Janvier",
    "February" => "Février",
    "March" => "Mars",
    "April" => "Avril",
    "May" => "Mai",
    "June" => "Juin",
    "July" => "Juillet",
    "August" => "Août",
    "September" => "Septembre",
    "October" => "Octobre",
    "November" => "Novembre",
    "December" => "Décembre",
    );

 $keys = array();   
foreach ($grid as $key => $value) {
    $key = explode(' ',$key);

    foreach ($yearMonths as $k => $v) {
        //$k = explode(' ', $k);
        if ($key[0] == $k) {
            $keys[] = $v.' '.$key[1];
        }
    }
}  

var_dump($keys);

array(5) {
  [0]=>
  string(13) "Février 2018"
  [1]=>
  string(9) "Juin 2018"
  [2]=>
  string(8) "Mai 2018"
  [3]=>
  string(10) "Avril 2018"
  [4]=>
  string(9) "Mars 2018"
}
  • 写回答

1条回答 默认 最新

  • douti6740 2018-06-29 15:10
    关注

    The problem was coming from the foreach loops below while loop. After making sure that only while loop is used, everything works like a charm. Here is my new code that is working fine:

    <?php
    
        function getMonths($begin, $end)
        {
            $monthsData = array();
    
            $dateBegin = new \DateTime($begin);
            $dateEnd = new \DateTime($end);
    
            while ($dateBegin->getTimestamp() < $dateEnd->getTimestamp()) {
                $monthsData[] = $dateBegin->format('F Y');
                $dateBegin->add(new \DateInterval('P1M'));
            }
    
            return $monthsData;
        }
    
    
        $monthsData = getMonths('2018-05-01', '2020-01-01' );
    
    
        $percentApporteurData = $_SESSION['reqPourcentageApporteur'];
    
        $recupapporteur = "select * from apporteuraffaire where id_apporteur ='".$useridapporteur."'";
        $execrecupapporteur = mysql_query($recupapporteur);
        $apporteur = mysql_fetch_assoc($execrecupapporteur);
    
    
    
        $recupcodepromo = "select * from codepromo where codepromo ='".$apporteur['codeapporteur']."'";
        $execrecupcodepromo = mysql_query($recupcodepromo);
        $codepromo = mysql_fetch_assoc($execrecupcodepromo);
    
    
    
      $listeventes = "select * from reporting_formulaire2 where codepromo ='".$codepromo['idcodepromo']."' and codepromo <> 0 and statusachat>7 and statusachat<>15 and statusachat<>14 and statusachat<19 ORDER BY  `idformulaire2` DESC ";    
                $exelisteaffaire = mysql_query($listeventes);
                $nombreaffaire =  mysql_num_rows($exelisteaffaire);
                $rf2Data = mysql_fetch_assoc($exelisteaffaire);
    
                $_SESSION['rf2Data'] = $rf2Data;
    
    ?>
    
    <?php
    if ($nombreaffaire > 0) {
    ?>
    
    
    <?php 
        $listeville="SELECT * FROM  `villedumaroc` where idville='".$apporteur['villeapporteur']."' ";
        $exelisteville=  mysql_query($listeville);
        $resultatville=mysql_fetch_assoc($exelisteville);
    ?>
    
    <?php
    
    $reqClients = "select DATE_FORMAT(datemodificationstatus, '%M %Y') AS datemodif, SUM(prixpack) AS montant_du_mois  
    from reporting_formulaire2 where codepromo ='".$codepromo['idcodepromo']."' and codepromo <> 0  
    and statusachat>7 and statusachat<>15 and statusachat<>14 and statusachat<19 
    group by datemodif
    ORDER BY  `idformulaire2` DESC";
    $execReqClient = mysql_query($reqClients);
    
    $grid = array();
    while ($client = mysql_fetch_assoc($execReqClient) ) {
        $grid[$client['datemodif']] = number_format(($client['montant_du_mois'] * $percentApporteurData['pourcentage_valeur']/100), 2,',',' ');
    }
    
    }
    
    ?>
    
    <div class="col-sm-offset-2">
        <center>
            <table class="table table-striped table-hover table-bordered">
        <tr>
            <td><strong>Mois</strong></td>
            <td><strong>Gains (Dhs)</strong></td>
            <td><strong>Fiche comptable du mois</strong></td>
        </tr>
        <?php
            foreach ($grid as $key => $value) {
                $yearMonths = array(
                "January" => "Janvier",
                "February" => "Février",
                "March" => "Mars",
                "April" => "Avril",
                "May" => "Mai",
                "June" => "Juin",
                "July" => "Juillet",
                "August" => "Août",
                "September" => "Septembre",
                "October" => "Octobre",
                "November" => "Novembre",
                "December" => "Décembre",
            );
    
            $key2 = explode(' ',$key);
            foreach ($yearMonths as $k => $v) {
                //$k = explode(' ', $k);
                if ($key2[0] == $k) {
                    $key2 = $v.' '.$key2[1];
                }
            }
                ?>
    
                    <tr>
                        <td><?php echo $key2; ?></td>
                        <td><?php echo $value; ?></td>
                        <td>
                            <?php  ob_start(); ?> 
                            <div class="col-sm-12 col-xs-12 col-lg-12">
                                <table width='700px' colspan='1' rowspan='1'>
                                    <tr>
                                        <td>
                                            <center>
                                                <br>
                                                <img src="img/logo-helvetica-by-sanad.png">
                                            </center>
                                        </td>
                                    </tr>  
                                </table>
                                <br><br><br>
    
                            </div>
    
                            <div class="col-sm-12 col-xs-12 col-lg-12">
    
                            <table width='700px' colspan='1' rowspan='1'>
                                <tr>
                                    <td>
                                        <center> 
                                            <br> 
                                            <b><u>AFFAIRES DU MOIS (<?php echo $key; ?>)</b></u> 
                                        </center>
                                    </td>
                                </tr>
                            </table>    
                            <br><br>
                            <table style="border-style:solid; border-width:1px;background-color: grey;margin-top: 3px;margin-bottom: 3px;" border=1 width='700px' colspan='1' rowspan='1'>
                                <tr style="background-color: #fff;height: 40px;">
                                    <td  align='left' style="height: 40px;width: 33%;padding: 0px 5px 5px 5px;">
    
                                        <center>   
                                            <table style="background-color: grey;width: 240px;height: 20px;">
                                                <tr><td style="text-align: center;"><p style="color: #fff;margin-bottom: 0px;"><b>Apporteur d&apos;affaires</b></p></td></tr>
                                            </table>
                                        </center>
                                        <br>
                                        <table style="width: 100%;border-color: gray;border-left: 0px;border-right: 0px;border-top: 0px;border-bottom: 0px;margin-top: 3px;" border="2"  cellpadding=2 cellspacing=2>
                                            <tr>
                                                <td style="width: 20%;">Nom et pr&eacute;nom</td>
                                                <td style="background-color: #ebebeb;width: 40%;">&nbsp;<?php echo $apporteur['nomapporteur']." ".$apporteur['prenomapporteur']; ?></td>
                                                <td style="width: 20%;" >&nbsp;E-mail</td>
                                                <td style="background-color: #ebebeb;width: 20%">&nbsp;<?php echo $apporteur['emailapporteur'];?></td>
                                            </tr>
                                            <tr>
                                                <td style="width: 20%;">T&eacute;l&eacute;phone</td>
                                                <td style="background-color: #ebebeb;width: 40%;">&nbsp;<?php echo $apporteur['telephoneapporteur'];?></td>
                                                <td style="width: 20%;" >&nbsp;Ville</td>
                                                <td style="background-color: #ebebeb;width: 20%">&nbsp;<?php echo $resultatville['nomville'];?></td>
                                            </tr>
                                        </table>
                                    </td>    
                                </tr>
                            </table>
                            </div>
                            <br><br>
    
                        <div class="col-sm-12 col-xs-12 col-lg-12">
    
                            <table style="border-style:solid;border-color: grey; border-width:1px;background-color: grey;margin-top: 3px;margin-bottom: 3px;" border=1 width='700px' colspan='1' rowspan='1'>
                                <br><br>
                                <tr style="background-color: #fff;">
                                    <td colspan="5">
                                        <center>
                                            <table style="background-color: grey; width: 240px;height: 20px;margin-top: 3px;margin-bottom: 3px;">
                                                <tr>
                                                    <td style="text-align: center;">
    
                                                        <p style="color: #fff;margin-bottom: 0px;"><b>Commissions</b></p>
    
                                                    </td>
                                                </tr>
                                            </table>
                                        </center>
                                    </td>
                                </tr>
                                <br><br>
                                <tr style="background-color: #d6d6d6;font-weight: 700;">
                                    <td>&nbsp;Client</td>
                                    <td style="text-align: center;">&nbsp;Pack&nbsp;</td> 
                                    <td style="text-align: center;">&nbsp;Prix du pack&nbsp;</td>
                                    <td style="text-align: center;">&nbsp;Pourcentage&nbsp;</td>
                                    <td style="text-align: center;">&nbsp;Commission&nbsp;</td>
                                </tr>    
    
                                <?php
                                $listeventes = "select nom, prenom, nomprenom, pack, prixpack, DATE_FORMAT(datemodificationstatus, '%M %Y') AS datemodifstatut  from reporting_formulaire2 where DATE_FORMAT(datemodificationstatus, '%M %Y') = '". $key ."' and codepromo ='".$codepromo['idcodepromo']."' and codepromo <> 0 and statusachat>7 and statusachat<>15 and statusachat<>14 and statusachat<19 ORDER BY  `idformulaire2` DESC ";    
                                $exelisteaffaire = mysql_query($listeventes);
                                $nombreaffaire =  mysql_num_rows($exelisteaffaire);
                                //$rf2Data = mysql_fetch_assoc($exelisteaffaire);
                                    $afrs = array();
                                    $array = array();
    
                                        while ($ref = mysql_fetch_assoc($exelisteaffaire)) {
    
                                ?>
                                <tr style="background-color: #fff;">
                                    <td><b>&nbsp;<?php echo $ref['nomprenom']; ?></b></td>
                                    <td style="text-align: center;">&nbsp;<?php echo $ref['pack']; ?></td>
                                    <td style="text-align: center;">&nbsp;<?php echo $ref['prixpack']; ?></td>
                                    <td style="text-align: right;padding-right: 4px;">
                                        <?php 
                                            if (isset($percentApporteurData['pourcentage_valeur']) && is_numeric($percentApporteurData['pourcentage_valeur'])) {
                                                echo $percentApporteurData['pourcentage_valeur'];
                                            } else {
                                                echo "0";
                                            }
                                        ?>
                                    </td>
                                    <td style="text-align: right;padding-right: 4px;">
                                        <?php
    
                                            $percentage = 0;
                                            if (isset($percentApporteurData['pourcentage_valeur']) && is_numeric($percentApporteurData['pourcentage_valeur'])) {
                                                $percentage = $percentApporteurData['pourcentage_valeur'];
                                            }
                                            echo number_format(($ref['prixpack'] * $percentage / 100), 2,',',' ');
                                            $afr = $ref['prixpack'] * $percentage / 100;
                                            $afrs[] = $afr;
                                        ?>
                                    </td>
    
                                </tr>
                                <?php
                                     }               
    
    
                                    $totalAfrs = 0;
    
                                    for ($i = 0; $i < count($afrs); $i++) { 
                                        $totalAfrs += $afrs[$i];
    
                                    }
    
                                    $array[$mois]['total'] = $totalAfrs;
                                ?>                         
    
                                <tr style="background-color: #fff;height: 20px;"><td colspan="5" height='40'></td></tr>                  
    
                                <tr style="background-color: #fff;">
                                    <td colspan="4" style="text-align: right;"><b>Total&nbsp;</b></td>
    
                                    <td style="background-color: #d6d6d6;text-align: right;padding-right: 4px;"> &nbsp;
                                        <?php
                                            echo number_format($totalAfrs,2,',',' ');  
                                        ?>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <div>    
                            <p style="font-size: 12px;text-align: left;">  
                                <br><br><br><br>
                                Ce montant total de vos commissions <span style="font-weight: bold;">(<?php echo number_format($totalAfrs,2,',',' '); ?> Dhs)</span> vous sera vers&eacute; sur votre compte bancaire n&deg; <?php echo $apporteur['ribcomplet'];?>
                            </p>
                            <p style="font-size: 12px;text-align: left;">  
                                <br><br><br><br>
                                Fait &agrave; Casablanca, le <?php echo date('d/m/Y');?>
                            </p>
                            <br><br>
                        </div>                            
    
                        <?php $monthContent = ob_get_clean(); ?>   
                        <?php 
    
                            require_once( 'pdf/MPDF57/mpdf.php'); // Include mdpf
                            $stylesheet = file_get_contents('pdf/pdf.css'); // Get css content
                            $html = '<div id="pdf-content">
                                        Your PDF Content goes here (Text/HTML)
                                    </div>';
                            // Setup PDF
                            //$mpdf = new mPDF('utf-8', 'A4-L'); // New PDF object with encoding & page size
                            $mpdf = new mPDF('utf-8', 'A4'); // New PDF object with encoding & page size
                            $mpdf->setAutoTopMargin = 'stretch'; // Set pdf top margin to stretch to avoid content overlapping
                            $mpdf->setAutoBottomMargin = 'stretch'; // Set pdf bottom margin to stretch to avoid content overlapping
                            // PDF header content
                            $mpdf->SetHTMLHeader('<div class="pdf-header">
    
                                                  </div>'); 
                            // PDF footer content                      
                            $mpdf->SetHTMLFooter('<div class="pdf-footer">
    
                                                  </div>'); 
    
                            $mpdf->WriteHTML($stylesheet,1); // Writing style to pdf
                            $monthContent = mb_convert_encoding($monthContent, 'UTF-8', 'UTF-8');
                            $mpdf->WriteHTML($monthContent); // Writing html to pdf
                            //$mpdf->Output('lubus_mdpf_demo6.pdf','D'); // For Download
    
                            //$nomfichierserveur="pdf/save/apporteuraffaire/comptabilite/test.pdf";
                            $fichierPDF = "pdf/save/apporteuraffaire/comptabilite/".str_replace(' ','',$key)."_".$apporteur['nomapporteur']."-".$apporteur['prenomapporteur']."_Fiche-Comptable.pdf";
    
                            $mpdf->Output($fichierPDF, 'F');//enregistrer sur serveur
    
                        ?> 
    
                            <a href="<?php echo $fichierPDF; ?>" class="list-group-item">
                                <img width="10%" height="10%" src="img/logopdf.png" />
                            </a>
    
                        </td>
                    </tr>
                <?php
    
    
    
    
            }
        ?>
    </table>
        </center>
    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题