forked from science-ation/science-ation
Update LPDF to handle tables without a header row
Update LPDF to add a "..." to a table field if all of the text didnt fit in the table field
This commit is contained in:
parent
b956f4c2d3
commit
668d410207
44
lpdf.php
44
lpdf.php
@ -359,14 +359,22 @@ class lpdf
|
|||||||
|
|
||||||
function addTable($table,$align="center")
|
function addTable($table,$align="center")
|
||||||
{
|
{
|
||||||
$height['tableheader']=0.2;
|
if(is_array($table['header']))
|
||||||
|
{
|
||||||
|
$table_cols=count($table['header']);
|
||||||
|
$height['tableheader']=0.2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$table_cols=count($table['data']);
|
||||||
|
$height['tableheader']=0;
|
||||||
|
}
|
||||||
$height['tabledata']=0.18;
|
$height['tabledata']=0.18;
|
||||||
|
|
||||||
$this->yloc-=$height['tableheader'];
|
$this->yloc-=$height['tableheader'];
|
||||||
$top_of_table=$this->yloc;
|
$top_of_table=$this->yloc;
|
||||||
|
|
||||||
$table_width=array_sum($table['widths']);
|
$table_width=array_sum($table['widths']);
|
||||||
$table_cols=count($table['header']);
|
|
||||||
$table_padding=0.03;
|
$table_padding=0.03;
|
||||||
|
|
||||||
switch($align)
|
switch($align)
|
||||||
@ -376,22 +384,21 @@ class lpdf
|
|||||||
case "right"; $xpos_of_table=$this->page_width-$this->page_margin-$table_width; break;
|
case "right"; $xpos_of_table=$this->page_width-$this->page_margin-$table_width; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw the top line of the table (above the table header)
|
//draw the top line of the table (above the table header)
|
||||||
pdf_moveto($this->pdf,$this->loc($xpos_of_table),$this->loc($this->yloc+$height['tableheader']));
|
pdf_moveto($this->pdf,$this->loc($xpos_of_table),$this->loc($this->yloc+$height['tableheader']));
|
||||||
pdf_lineto($this->pdf,$this->loc($xpos_of_table+$table_width),$this->loc($this->yloc+$height['tableheader']));
|
pdf_lineto($this->pdf,$this->loc($xpos_of_table+$table_width),$this->loc($this->yloc+$height['tableheader']));
|
||||||
pdf_stroke($this->pdf);
|
pdf_stroke($this->pdf);
|
||||||
|
|
||||||
//draw the top line of the table (below the table header)
|
|
||||||
pdf_moveto($this->pdf,$this->loc($xpos_of_table),$this->loc($this->yloc));
|
|
||||||
pdf_lineto($this->pdf,$this->loc($xpos_of_table+$table_width),$this->loc($this->yloc));
|
|
||||||
pdf_stroke($this->pdf);
|
|
||||||
|
|
||||||
//do the header first
|
//do the header first
|
||||||
if($table['header'])
|
if(is_array($table['header']))
|
||||||
{
|
{
|
||||||
pdf_setfont($this->pdf,$this->headerfont,12);
|
//draw the top line of the table (below the table header)
|
||||||
|
pdf_moveto($this->pdf,$this->loc($xpos_of_table),$this->loc($this->yloc));
|
||||||
|
pdf_lineto($this->pdf,$this->loc($xpos_of_table+$table_width),$this->loc($this->yloc));
|
||||||
|
pdf_stroke($this->pdf);
|
||||||
|
|
||||||
$xpos=$xpos_of_table;
|
$xpos=$xpos_of_table;
|
||||||
|
pdf_setfont($this->pdf,$this->headerfont,12);
|
||||||
|
|
||||||
for($c=0;$c<$table_cols;$c++)
|
for($c=0;$c<$table_cols;$c++)
|
||||||
{
|
{
|
||||||
@ -416,7 +423,16 @@ class lpdf
|
|||||||
{
|
{
|
||||||
$width=$table['widths'][$c];
|
$width=$table['widths'][$c];
|
||||||
|
|
||||||
pdf_show_boxed($this->pdf,$dataline[$c],$this->loc($xpos+$table_padding),$this->loc($this->yloc),$this->loc($width-2*$table_padding),$this->loc($height['tabledata']),$table['dataalign'][$c],null);
|
$notfit=pdf_show_boxed($this->pdf,$dataline[$c],$this->loc($xpos+$table_padding),$this->loc($this->yloc),$this->loc($width-2*$table_padding),$this->loc($height['tabledata']),$table['dataalign'][$c],null);
|
||||||
|
|
||||||
|
//put a little "..." at the end of the field
|
||||||
|
if($notfit)
|
||||||
|
{
|
||||||
|
pdf_setfont($this->pdf,$this->normalfont,8);
|
||||||
|
pdf_show_boxed($this->pdf,"...",$this->loc($xpos+$width-0.10),$this->loc($this->yloc-0.05),$this->loc(0.10),$this->loc($height['tabledata']),$table['dataalign'][$c],null);
|
||||||
|
pdf_setfont($this->pdf,$this->normalfont,10);
|
||||||
|
}
|
||||||
|
|
||||||
$xpos+=$width;
|
$xpos+=$width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
send_header("Participant Registration");
|
send_header("Participant Registration");
|
||||||
echo error(i18n("Invalid registration number (%1) for email address %2",array($_POST['regnum'],$_SESSION['email'])));
|
echo error(i18n("Invalid registration number (%1) for email address %2",array($_POST['regnum'],$_SESSION['email'])));
|
||||||
$_POST['action']="login";
|
$_POST['action']="login";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user