Add: fonction permettant de compter le nombre de ligne dans un texte, ceci afin de dterminer le nombre de ligne dans une description produit pour ne plus avoir de dbordement dans les pdf

This commit is contained in:
Regis Houssin 2007-05-08 11:13:30 +00:00
parent ac9826f3a2
commit 07a8ee6e28
2 changed files with 25 additions and 4 deletions

View File

@ -192,6 +192,7 @@ class pdf_propale_azur extends ModelePDFPropales
$tab_top_newpage = 50;
$tab_height = 110;
$tab_height_newpage = 150;
$tab_height_middlepage = 190;
// Affiche notes
if ($propale->note_public)
@ -321,8 +322,13 @@ class pdf_propale_azur extends ModelePDFPropales
$this->tva[(string) $propale->lignes[$i]->tva_tx] += $tvaligne;
$nexY+=2; // Passe espace entre les lignes
//on récupère la description du produit suivant
$follow_descproduitservice = $propale->lignes[$i+1]->desc;
//on compte le nombre de ligne afin de vérifier la place disponible
$nblineFollowDesc = (num_lines($follow_descproduitservice)*4);
if ($nexY > ($tab_top+$tab_height) && $i < ($nblignes - 1))
if (($nexY+$nblineFollowDesc) > ($tab_top+$tab_height) && $i < ($nblignes - 1))
{
if ($pagenb == 1)
{
@ -330,7 +336,7 @@ class pdf_propale_azur extends ModelePDFPropales
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
$this->_tableau($pdf, $tab_top_newpage, $tab_height_middlepage, $nexY, $outputlangs);
}
$this->_pagefoot($pdf,$outputlangs);
@ -355,8 +361,8 @@ class pdf_propale_azur extends ModelePDFPropales
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $tab_height, $nexY, $outputlangs);
$bottomlasttab=$tab_top_newpage + $tab_height + 1;
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1;
}
// Affiche zone infos

View File

@ -2598,6 +2598,21 @@ function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0)
return $nbOpenDay;
}
/**
\brief Fonction retournant le nombre de lignes dans un texte formaté
\param texte Texte
\return nblines Nombre de lignes
*/
function num_lines($texte)
{
$repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " ");
$texte = strtr($texte, $repTable);
$pattern = '/(<[^>]+>)/Uu';
$a = preg_split($pattern, $texte, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
$nblines = ((count($a)+1)/2);
return $nblines;
}
/**
\brief Récupère la valeur d'un champ, effectue un traitement Ajax et affiche le résultat
\param htmlname nom et id du champ