@@ -140,9 +140,9 @@ |
||
| 140 | 140 | $lista = array(); |
| 141 | 141 | if($data) { |
| 142 | 142 | foreach($data as $d) { |
| 143 | - $item = new residentes_facturacion_programada_edificaciones($d); |
|
| 144 | - $this->infoAdicional($item); |
|
| 145 | - $lista[] = $item; |
|
| 143 | + $item = new residentes_facturacion_programada_edificaciones($d); |
|
| 144 | + $this->infoAdicional($item); |
|
| 145 | + $lista[] = $item; |
|
| 146 | 146 | } |
| 147 | 147 | return $lista; |
| 148 | 148 | } |
@@ -126,7 +126,7 @@ |
||
| 126 | 126 | 'page_to' => __CLASS__, |
| 127 | 127 | 'type' => 'head', |
| 128 | 128 | 'text' => '<script src="' . |
| 129 | - FS_PATH . |
|
| 129 | + FS_PATH . |
|
| 130 | 130 | 'plugins/residentes/view/js/jsPDF/plugins/split_text_to_size.min.js" ' . |
| 131 | 131 | 'type="text/javascript"></script>', |
| 132 | 132 | 'params' => '' |
@@ -311,7 +311,7 @@ |
||
| 311 | 311 | $listaReferencias = $this->filter_request_array('referencia'); |
| 312 | 312 | foreach ($listaReferencias as $referencia) { |
| 313 | 313 | $sql = "SELECT count(referencia) as facturado from lineasfacturascli where referencia = '".$referencia."' ". |
| 314 | - " AND idfactura IN (select idfactura from facturascli WHERE codcliente = '".$codcliente."');"; |
|
| 314 | + " AND idfactura IN (select idfactura from facturascli WHERE codcliente = '".$codcliente."');"; |
|
| 315 | 315 | $data = $this->db->select($sql); |
| 316 | 316 | if (!$data[0]['facturado']) { |
| 317 | 317 | $listaResidentes[$codcliente][] = $referencia; |
@@ -444,9 +444,9 @@ |
||
| 444 | 444 | echo json_encode($hijos, JSON_THROW_ON_ERROR); |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - /** |
|
| 448 | - * funcion para guardar los codigos de las edificaciones base Manzana, Zona, Grupo, Edificio, etc |
|
| 449 | - */ |
|
| 447 | + /** |
|
| 448 | + * funcion para guardar los codigos de las edificaciones base Manzana, Zona, Grupo, Edificio, etc |
|
| 449 | + */ |
|
| 450 | 450 | public function agregar($objeto) |
| 451 | 451 | { |
| 452 | 452 | $inicio = \filter_input(INPUT_POST, 'inicio'); |
@@ -192,8 +192,8 @@ |
||
| 192 | 192 | public function all_ocupados() |
| 193 | 193 | { |
| 194 | 194 | $sql = "SELECT re.*, c.nombre FROM ".$this->table_name." as re, clientes as c ". |
| 195 | - " WHERE ocupado = TRUE and re.codcliente != '' and re.codcliente = c.codcliente ". |
|
| 196 | - " ORDER BY re.codigo_interno, re.numero"; |
|
| 195 | + " WHERE ocupado = TRUE and re.codcliente != '' and re.codcliente = c.codcliente ". |
|
| 196 | + " ORDER BY re.codigo_interno, re.numero"; |
|
| 197 | 197 | $data = $this->db->select($sql); |
| 198 | 198 | return $this->listaInfo($data); |
| 199 | 199 | } |
@@ -126,7 +126,7 @@ |
||
| 126 | 126 | 'page_to' => __CLASS__, |
| 127 | 127 | 'type' => 'head', |
| 128 | 128 | 'text' => '<script src="' . |
| 129 | - FS_PATH . |
|
| 129 | + FS_PATH . |
|
| 130 | 130 | 'plugins/residentes/view/js/jsPDF/plugins/split_text_to_size.min.js" ' . |
| 131 | 131 | 'type="text/javascript"></script>', |
| 132 | 132 | 'params' => '' |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | - /********************************************************************* |
|
| 2 | + /********************************************************************* |
|
| 3 | 3 | * exFPDF extend FPDF v1.81 * |
| 4 | 4 | * * |
| 5 | 5 | * Version: 2.2 * |
@@ -7,378 +7,378 @@ discard block |
||
| 7 | 7 | * Author: Dan Machado * |
| 8 | 8 | * Require FPDF v1.81, formatedstring v1.0 * |
| 9 | 9 | **********************************************************************/ |
| 10 | - include 'formatedstring.php'; |
|
| 11 | - class exFPDF extends FPDF |
|
| 12 | - { |
|
| 10 | + include 'formatedstring.php'; |
|
| 11 | + class exFPDF extends FPDF |
|
| 12 | + { |
|
| 13 | 13 | public function PageBreak(){ |
| 14 | - return $this->PageBreakTrigger; |
|
| 15 | - } |
|
| 14 | + return $this->PageBreakTrigger; |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public function current_font($c){ |
|
| 18 | - if($c=='family'){ |
|
| 19 | - return $this->FontFamily; |
|
| 20 | - } |
|
| 21 | - elseif($c=='style'){ |
|
| 22 | - return $this->FontStyle; |
|
| 23 | - } |
|
| 24 | - elseif($c=='size'){ |
|
| 25 | - return $this->FontSizePt; |
|
| 26 | - } |
|
| 27 | - } |
|
| 17 | + public function current_font($c){ |
|
| 18 | + if($c=='family'){ |
|
| 19 | + return $this->FontFamily; |
|
| 20 | + } |
|
| 21 | + elseif($c=='style'){ |
|
| 22 | + return $this->FontStyle; |
|
| 23 | + } |
|
| 24 | + elseif($c=='size'){ |
|
| 25 | + return $this->FontSizePt; |
|
| 26 | + } |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - public function get_color($c){ |
|
| 30 | - if($c=='fill'){ |
|
| 31 | - return $this->FillColor; |
|
| 32 | - } |
|
| 33 | - elseif($c=='text'){ |
|
| 34 | - return $this->TextColor; |
|
| 35 | - } |
|
| 36 | - } |
|
| 29 | + public function get_color($c){ |
|
| 30 | + if($c=='fill'){ |
|
| 31 | + return $this->FillColor; |
|
| 32 | + } |
|
| 33 | + elseif($c=='text'){ |
|
| 34 | + return $this->TextColor; |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - public function get_page_width(){ |
|
| 39 | - return $this->w; |
|
| 40 | - } |
|
| 38 | + public function get_page_width(){ |
|
| 39 | + return $this->w; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function get_margin($c){ |
|
| 43 | - if($c=='l'){ |
|
| 44 | - return $this->lMargin; |
|
| 45 | - } |
|
| 46 | - elseif($c=='r'){ |
|
| 47 | - return $this->rMargin; |
|
| 48 | - } |
|
| 49 | - elseif($c=='t'){ |
|
| 50 | - return $this->tMargin; |
|
| 51 | - } |
|
| 52 | - } |
|
| 42 | + public function get_margin($c){ |
|
| 43 | + if($c=='l'){ |
|
| 44 | + return $this->lMargin; |
|
| 45 | + } |
|
| 46 | + elseif($c=='r'){ |
|
| 47 | + return $this->rMargin; |
|
| 48 | + } |
|
| 49 | + elseif($c=='t'){ |
|
| 50 | + return $this->tMargin; |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function get_linewidth(){ |
|
| 55 | - return $this->LineWidth; |
|
| 56 | - } |
|
| 54 | + public function get_linewidth(){ |
|
| 55 | + return $this->LineWidth; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function get_orientation(){ |
|
| 59 | - return $this->CurOrientation; |
|
| 60 | - } |
|
| 61 | - static private $hex=array('0'=>0,'1'=>1,'2'=>2,'3'=>3,'4'=>4,'5'=>5,'6'=>6,'7'=>7,'8'=>8,'9'=>9, |
|
| 62 | - 'A'=>10,'B'=>11,'C'=>12,'D'=>13,'E'=>14,'F'=>15); |
|
| 58 | + public function get_orientation(){ |
|
| 59 | + return $this->CurOrientation; |
|
| 60 | + } |
|
| 61 | + static private $hex=array('0'=>0,'1'=>1,'2'=>2,'3'=>3,'4'=>4,'5'=>5,'6'=>6,'7'=>7,'8'=>8,'9'=>9, |
|
| 62 | + 'A'=>10,'B'=>11,'C'=>12,'D'=>13,'E'=>14,'F'=>15); |
|
| 63 | 63 | |
| 64 | - public function is_rgb($str){ |
|
| 65 | - $a=true; |
|
| 66 | - $tmp=explode(',', trim($str, ',')); |
|
| 67 | - foreach($tmp as $color){ |
|
| 68 | - if(!is_numeric($color) || $color<0 || $color>255){ |
|
| 64 | + public function is_rgb($str){ |
|
| 65 | + $a=true; |
|
| 66 | + $tmp=explode(',', trim($str, ',')); |
|
| 67 | + foreach($tmp as $color){ |
|
| 68 | + if(!is_numeric($color) || $color<0 || $color>255){ |
|
| 69 | 69 | $a=false; |
| 70 | 70 | break; |
| 71 | - } |
|
| 72 | - } |
|
| 73 | - return $a; |
|
| 74 | - } |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + return $a; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - public function is_hex($str){ |
|
| 77 | - $a=true; |
|
| 78 | - $str=strtoupper($str); |
|
| 79 | - $n=strlen($str); |
|
| 80 | - if(($n==7 || $n==4) && $str[0]=='#'){ |
|
| 81 | - for($i=1; $i<$n; $i++){ |
|
| 76 | + public function is_hex($str){ |
|
| 77 | + $a=true; |
|
| 78 | + $str=strtoupper($str); |
|
| 79 | + $n=strlen($str); |
|
| 80 | + if(($n==7 || $n==4) && $str[0]=='#'){ |
|
| 81 | + for($i=1; $i<$n; $i++){ |
|
| 82 | 82 | if(!isset(self::$hex[$str[$i]])){ |
| 83 | - $a=false; |
|
| 84 | - break; |
|
| 83 | + $a=false; |
|
| 84 | + break; |
|
| 85 | + } |
|
| 85 | 86 | } |
| 86 | - } |
|
| 87 | - } |
|
| 88 | - else{ |
|
| 89 | - $a=false; |
|
| 90 | - } |
|
| 91 | - return $a; |
|
| 92 | - } |
|
| 87 | + } |
|
| 88 | + else{ |
|
| 89 | + $a=false; |
|
| 90 | + } |
|
| 91 | + return $a; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - public function hextodec($str){ |
|
| 95 | - $result=array(); |
|
| 96 | - $str=strtoupper(substr($str,1)); |
|
| 97 | - $n=strlen($str); |
|
| 98 | - for($i=0; $i<3; $i++){ |
|
| 99 | - if($n==6){ |
|
| 94 | + public function hextodec($str){ |
|
| 95 | + $result=array(); |
|
| 96 | + $str=strtoupper(substr($str,1)); |
|
| 97 | + $n=strlen($str); |
|
| 98 | + for($i=0; $i<3; $i++){ |
|
| 99 | + if($n==6){ |
|
| 100 | 100 | $result[$i]=self::$hex[$str[2*$i]]*16+self::$hex[$str[2*$i+1]]; |
| 101 | - } |
|
| 102 | - else{ |
|
| 101 | + } |
|
| 102 | + else{ |
|
| 103 | 103 | $result[$i]=self::$hex[$str[$i]]*16+self::$hex[$str[$i]]; |
| 104 | - } |
|
| 105 | - } |
|
| 106 | - return $result; |
|
| 107 | - } |
|
| 108 | - static private $options=array('F'=>'', 'T'=>'', 'D'=>''); |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + return $result; |
|
| 107 | + } |
|
| 108 | + static private $options=array('F'=>'', 'T'=>'', 'D'=>''); |
|
| 109 | 109 | |
| 110 | - public function resetColor($str, $p='F'){ |
|
| 111 | - if(isset(self::$options[$p]) && self::$options[$p]!=$str){ |
|
| 112 | - self::$options[$p]=$str; |
|
| 113 | - $array=array(); |
|
| 114 | - if($this->is_hex($str)){ |
|
| 110 | + public function resetColor($str, $p='F'){ |
|
| 111 | + if(isset(self::$options[$p]) && self::$options[$p]!=$str){ |
|
| 112 | + self::$options[$p]=$str; |
|
| 113 | + $array=array(); |
|
| 114 | + if($this->is_hex($str)){ |
|
| 115 | 115 | $array=$this->hextodec($str); |
| 116 | - } |
|
| 117 | - elseif($this->is_rgb($str)){ |
|
| 116 | + } |
|
| 117 | + elseif($this->is_rgb($str)){ |
|
| 118 | 118 | $array=explode(',', trim($str, ',')); |
| 119 | 119 | for($i=0; $i<3; $i++){ |
| 120 | - if(!isset($array[$i])){ |
|
| 121 | - $array[$i]=0; |
|
| 122 | - } |
|
| 120 | + if(!isset($array[$i])){ |
|
| 121 | + $array[$i]=0; |
|
| 122 | + } |
|
| 123 | + } |
|
| 123 | 124 | } |
| 124 | - } |
|
| 125 | - else{ |
|
| 125 | + else{ |
|
| 126 | 126 | $array=array(null, null, null); |
| 127 | 127 | $i=0; |
| 128 | 128 | $tmp=explode(' ', $str); |
| 129 | 129 | foreach($tmp as $c){ |
| 130 | - if(is_numeric($c)){ |
|
| 131 | - $array[$i]=$c*256; |
|
| 132 | - $i++; |
|
| 133 | - } |
|
| 130 | + if(is_numeric($c)){ |
|
| 131 | + $array[$i]=$c*256; |
|
| 132 | + $i++; |
|
| 133 | + } |
|
| 134 | 134 | } |
| 135 | - } |
|
| 136 | - if($p=='T'){ |
|
| 135 | + } |
|
| 136 | + if($p=='T'){ |
|
| 137 | 137 | $this->SetTextColor($array[0],$array[1],$array[2]); |
| 138 | - } |
|
| 139 | - elseif($p=='D'){ |
|
| 138 | + } |
|
| 139 | + elseif($p=='D'){ |
|
| 140 | 140 | $this->SetDrawColor($array[0],$array[1], $array[2]); |
| 141 | - } |
|
| 142 | - elseif($p=='F'){ |
|
| 141 | + } |
|
| 142 | + elseif($p=='F'){ |
|
| 143 | 143 | $this->SetFillColor($array[0],$array[1],$array[2]); |
| 144 | - } |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - static private $font_def=''; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + static private $font_def=''; |
|
| 148 | 148 | |
| 149 | - public function resetFont($font_family, $font_style, $font_size){ |
|
| 150 | - if(self::$font_def!=$font_family .'-' . $font_style . '-' .$font_size){ |
|
| 151 | - self::$font_def=$font_family .'-' . $font_style . '-' .$font_size; |
|
| 152 | - $this->SetFont($font_family, $font_style, $font_size); |
|
| 153 | - } |
|
| 154 | - } |
|
| 149 | + public function resetFont($font_family, $font_style, $font_size){ |
|
| 150 | + if(self::$font_def!=$font_family .'-' . $font_style . '-' .$font_size){ |
|
| 151 | + self::$font_def=$font_family .'-' . $font_style . '-' .$font_size; |
|
| 152 | + $this->SetFont($font_family, $font_style, $font_size); |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - public function resetStaticData(){ |
|
| 157 | - self::$font_def=''; |
|
| 158 | - self::$options=array('F'=>'', 'T'=>'', 'D'=>''); |
|
| 159 | - } |
|
| 160 | - /*********************************************************************** |
|
| 156 | + public function resetStaticData(){ |
|
| 157 | + self::$font_def=''; |
|
| 158 | + self::$options=array('F'=>'', 'T'=>'', 'D'=>''); |
|
| 159 | + } |
|
| 160 | + /*********************************************************************** |
|
| 161 | 161 | * |
| 162 | 162 | * Based on FPDF method SetFont |
| 163 | 163 | * |
| 164 | 164 | ************************************************************************/ |
| 165 | 165 | |
| 166 | - private function &FontData($family, $style, $size){ |
|
| 167 | - if($family=='') |
|
| 168 | - $family = $this->FontFamily; |
|
| 169 | - else |
|
| 170 | - $family = strtolower($family); |
|
| 171 | - $style = strtoupper($style); |
|
| 172 | - if(strpos($style,'U')!==false){ |
|
| 173 | - $this->underline = true; |
|
| 174 | - $style = str_replace('U','',$style); |
|
| 175 | - } |
|
| 176 | - if($style=='IB') |
|
| 177 | - $style = 'BI'; |
|
| 178 | - $fontkey = $family.$style; |
|
| 179 | - if(!isset($this->fonts[$fontkey])){ |
|
| 180 | - if($family=='arial') |
|
| 181 | - $family = 'helvetica'; |
|
| 182 | - if(in_array($family,$this->CoreFonts)){ |
|
| 166 | + private function &FontData($family, $style, $size){ |
|
| 167 | + if($family=='') |
|
| 168 | + $family = $this->FontFamily; |
|
| 169 | + else |
|
| 170 | + $family = strtolower($family); |
|
| 171 | + $style = strtoupper($style); |
|
| 172 | + if(strpos($style,'U')!==false){ |
|
| 173 | + $this->underline = true; |
|
| 174 | + $style = str_replace('U','',$style); |
|
| 175 | + } |
|
| 176 | + if($style=='IB') |
|
| 177 | + $style = 'BI'; |
|
| 178 | + $fontkey = $family.$style; |
|
| 179 | + if(!isset($this->fonts[$fontkey])){ |
|
| 180 | + if($family=='arial') |
|
| 181 | + $family = 'helvetica'; |
|
| 182 | + if(in_array($family,$this->CoreFonts)){ |
|
| 183 | 183 | if($family=='symbol' || $family=='zapfdingbats') |
| 184 | 184 | $style = ''; |
| 185 | 185 | $fontkey = $family.$style; |
| 186 | 186 | if(!isset($this->fonts[$fontkey])) |
| 187 | 187 | $this->AddFont($family,$style); |
| 188 | - } |
|
| 189 | - else |
|
| 190 | - $this->Error('Undefined font: '.$family.' '.$style); |
|
| 191 | - } |
|
| 192 | - $result['FontSize'] = $size/$this->k; |
|
| 193 | - $result['CurrentFont']=&$this->fonts[$fontkey]; |
|
| 194 | - return $result; |
|
| 195 | - } |
|
| 188 | + } |
|
| 189 | + else |
|
| 190 | + $this->Error('Undefined font: '.$family.' '.$style); |
|
| 191 | + } |
|
| 192 | + $result['FontSize'] = $size/$this->k; |
|
| 193 | + $result['CurrentFont']=&$this->fonts[$fontkey]; |
|
| 194 | + return $result; |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | 197 | |
| 198 | - private function setLines(&$fstring, $p, $q){ |
|
| 199 | - $parced_str=& $fstring->parced_str; |
|
| 200 | - $lines=& $fstring->lines; |
|
| 201 | - $linesmap=& $fstring->linesmap; |
|
| 202 | - $cfty=$fstring->get_current_style($p); |
|
| 203 | - $ffs=$cfty['font-family'] . $cfty['style']; |
|
| 204 | - if(!isset($fstring->used_fonts[$ffs])){ |
|
| 205 | - $fstring->used_fonts[$ffs]=& $this->FontData($cfty['font-family'], $cfty['style'], $cfty['font-size']); |
|
| 206 | - } |
|
| 207 | - $cw=& $fstring->used_fonts[$ffs]['CurrentFont']['cw']; |
|
| 208 | - $wmax = $fstring->width*1000*$this->k; |
|
| 209 | - $j=count($lines)-1; |
|
| 210 | - $k=strlen($lines[$j]); |
|
| 211 | - if(!isset($linesmap[$j][0])) { |
|
| 212 | - $linesmap[$j]=array($p,$p, 0); |
|
| 213 | - } |
|
| 214 | - $sl=$cw[' ']*$cfty['font-size']; |
|
| 215 | - $x=$a=$linesmap[$j][2]; |
|
| 216 | - if($k>0){ |
|
| 217 | - $x+=$sl; |
|
| 218 | - $lines[$j].=' '; |
|
| 219 | - $linesmap[$j][2]+=$sl; |
|
| 220 | - } |
|
| 221 | - $u=$p; |
|
| 222 | - $t=''; |
|
| 223 | - $l=$p+$q; |
|
| 224 | - $ftmp=''; |
|
| 225 | - for($i=$p; $i<$l; $i++){ |
|
| 198 | + private function setLines(&$fstring, $p, $q){ |
|
| 199 | + $parced_str=& $fstring->parced_str; |
|
| 200 | + $lines=& $fstring->lines; |
|
| 201 | + $linesmap=& $fstring->linesmap; |
|
| 202 | + $cfty=$fstring->get_current_style($p); |
|
| 203 | + $ffs=$cfty['font-family'] . $cfty['style']; |
|
| 204 | + if(!isset($fstring->used_fonts[$ffs])){ |
|
| 205 | + $fstring->used_fonts[$ffs]=& $this->FontData($cfty['font-family'], $cfty['style'], $cfty['font-size']); |
|
| 206 | + } |
|
| 207 | + $cw=& $fstring->used_fonts[$ffs]['CurrentFont']['cw']; |
|
| 208 | + $wmax = $fstring->width*1000*$this->k; |
|
| 209 | + $j=count($lines)-1; |
|
| 210 | + $k=strlen($lines[$j]); |
|
| 211 | + if(!isset($linesmap[$j][0])) { |
|
| 212 | + $linesmap[$j]=array($p,$p, 0); |
|
| 213 | + } |
|
| 214 | + $sl=$cw[' ']*$cfty['font-size']; |
|
| 215 | + $x=$a=$linesmap[$j][2]; |
|
| 216 | + if($k>0){ |
|
| 217 | + $x+=$sl; |
|
| 218 | + $lines[$j].=' '; |
|
| 219 | + $linesmap[$j][2]+=$sl; |
|
| 220 | + } |
|
| 221 | + $u=$p; |
|
| 222 | + $t=''; |
|
| 223 | + $l=$p+$q; |
|
| 224 | + $ftmp=''; |
|
| 225 | + for($i=$p; $i<$l; $i++){ |
|
| 226 | 226 | if($ftmp!=$ffs){ |
| 227 | 227 | $cfty=$fstring->get_current_style($i); |
| 228 | 228 | $ffs=$cfty['font-family'] . $cfty['style']; |
| 229 | 229 | if(!isset($fstring->used_fonts[$ffs])){ |
| 230 | - $fstring->used_fonts[$ffs]=& $this->FontData($cfty['font-family'], $cfty['style'], $cfty['font-size']); |
|
| 230 | + $fstring->used_fonts[$ffs]=& $this->FontData($cfty['font-family'], $cfty['style'], $cfty['font-size']); |
|
| 231 | 231 | } |
| 232 | 232 | $cw=& $fstring->used_fonts[$ffs]['CurrentFont']['cw']; |
| 233 | 233 | $ftmp=$ffs; |
| 234 | - } |
|
| 235 | - $x+=$cw[$parced_str[$i]]*$cfty['font-size']; |
|
| 236 | - if($x>$wmax){ |
|
| 234 | + } |
|
| 235 | + $x+=$cw[$parced_str[$i]]*$cfty['font-size']; |
|
| 236 | + if($x>$wmax){ |
|
| 237 | 237 | if($a>0){ |
| 238 | - $t=substr($parced_str,$p, $i-$p); |
|
| 239 | - $lines[$j]=substr($lines[$j],0,$k); |
|
| 240 | - $linesmap[$j][1]=$p-1; |
|
| 241 | - $linesmap[$j][2]=$a; |
|
| 242 | - $x-=($a+$sl); |
|
| 243 | - $a=0; |
|
| 244 | - $u=$p; |
|
| 238 | + $t=substr($parced_str,$p, $i-$p); |
|
| 239 | + $lines[$j]=substr($lines[$j],0,$k); |
|
| 240 | + $linesmap[$j][1]=$p-1; |
|
| 241 | + $linesmap[$j][2]=$a; |
|
| 242 | + $x-=($a+$sl); |
|
| 243 | + $a=0; |
|
| 244 | + $u=$p; |
|
| 245 | 245 | } |
| 246 | 246 | else{ |
| 247 | - $x=$cw[$parced_str[$i]]*$cfty['font-size']; |
|
| 248 | - $t=''; |
|
| 249 | - $u=$i; |
|
| 247 | + $x=$cw[$parced_str[$i]]*$cfty['font-size']; |
|
| 248 | + $t=''; |
|
| 249 | + $u=$i; |
|
| 250 | 250 | } |
| 251 | 251 | $j++; |
| 252 | 252 | $lines[$j]=$t; |
| 253 | 253 | $linesmap[$j]=array(); |
| 254 | 254 | $linesmap[$j][0]=$u; |
| 255 | 255 | $linesmap[$j][2]=0; |
| 256 | - } |
|
| 257 | - $lines[$j].=$parced_str[$i]; |
|
| 258 | - $linesmap[$j][1]=$i; |
|
| 259 | - $linesmap[$j][2]=$x; |
|
| 260 | - } |
|
| 261 | - return; |
|
| 262 | - } |
|
| 256 | + } |
|
| 257 | + $lines[$j].=$parced_str[$i]; |
|
| 258 | + $linesmap[$j][1]=$i; |
|
| 259 | + $linesmap[$j][2]=$x; |
|
| 260 | + } |
|
| 261 | + return; |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - public function &extMultiCell($font_family, $font_style, $font_size, $font_color, $w, $txt){ |
|
| 265 | - $result=array(); |
|
| 266 | - if($w==0){ |
|
| 267 | - return $result; |
|
| 268 | - } |
|
| 269 | - $this->current_font=array('font-family'=>$font_family, 'style'=>$font_style, 'font-size'=>$font_size, 'font-color'=>$font_color); |
|
| 270 | - $fstring=new formatedString($txt, $w, $this->current_font); |
|
| 271 | - $word=''; |
|
| 272 | - $p=0; |
|
| 273 | - $i=0; |
|
| 274 | - $n=strlen($fstring->parced_str); |
|
| 275 | - while($i<$n){ |
|
| 276 | - $word.=$fstring->parced_str[$i]; |
|
| 277 | - if($fstring->parced_str[$i]=="\n" || $fstring->parced_str[$i]==' ' || $i==$n-1){ |
|
| 264 | + public function &extMultiCell($font_family, $font_style, $font_size, $font_color, $w, $txt){ |
|
| 265 | + $result=array(); |
|
| 266 | + if($w==0){ |
|
| 267 | + return $result; |
|
| 268 | + } |
|
| 269 | + $this->current_font=array('font-family'=>$font_family, 'style'=>$font_style, 'font-size'=>$font_size, 'font-color'=>$font_color); |
|
| 270 | + $fstring=new formatedString($txt, $w, $this->current_font); |
|
| 271 | + $word=''; |
|
| 272 | + $p=0; |
|
| 273 | + $i=0; |
|
| 274 | + $n=strlen($fstring->parced_str); |
|
| 275 | + while($i<$n){ |
|
| 276 | + $word.=$fstring->parced_str[$i]; |
|
| 277 | + if($fstring->parced_str[$i]=="\n" || $fstring->parced_str[$i]==' ' || $i==$n-1){ |
|
| 278 | 278 | $word=trim($word); |
| 279 | 279 | $this->setLines($fstring, $p, strlen($word)); |
| 280 | 280 | $p=$i+1; |
| 281 | 281 | $word=''; |
| 282 | 282 | if($fstring->parced_str[$i]=="\n" && $i<$n-1){ |
| 283 | - $z=0; |
|
| 284 | - $j=count($fstring->lines); |
|
| 285 | - $fstring->lines[$j]=''; |
|
| 286 | - $fstring->linesmap[$j]=array(); |
|
| 283 | + $z=0; |
|
| 284 | + $j=count($fstring->lines); |
|
| 285 | + $fstring->lines[$j]=''; |
|
| 286 | + $fstring->linesmap[$j]=array(); |
|
| 287 | 287 | } |
| 288 | - } |
|
| 289 | - $i++; |
|
| 290 | - } |
|
| 291 | - if($n==0){ |
|
| 292 | - return $result; |
|
| 293 | - } |
|
| 294 | - $n=count($fstring->lines); |
|
| 295 | - for($i=0; $i<$n; $i++){ |
|
| 296 | - $result[$i]=$fstring->break_by_style($i); |
|
| 297 | - } |
|
| 298 | - return $result; |
|
| 299 | - } |
|
| 288 | + } |
|
| 289 | + $i++; |
|
| 290 | + } |
|
| 291 | + if($n==0){ |
|
| 292 | + return $result; |
|
| 293 | + } |
|
| 294 | + $n=count($fstring->lines); |
|
| 295 | + for($i=0; $i<$n; $i++){ |
|
| 296 | + $result[$i]=$fstring->break_by_style($i); |
|
| 297 | + } |
|
| 298 | + return $result; |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - private function GetMixStringWidth($line){ |
|
| 302 | - $w = 0; |
|
| 303 | - foreach($line['chunks'] as $i=>$chunk){ |
|
| 304 | - $t=0; |
|
| 305 | - $cf=& $this->FontData($line['style'][$i]['font-family'], $line['style'][$i]['style'], $line['style'][$i]['font-size']); |
|
| 306 | - $cw=& $cf['CurrentFont']['cw']; |
|
| 307 | - $s=implode('', explode(' ',$chunk)); |
|
| 308 | - $l = strlen($s); |
|
| 309 | - for($j=0;$j<$l;$j++){ |
|
| 301 | + private function GetMixStringWidth($line){ |
|
| 302 | + $w = 0; |
|
| 303 | + foreach($line['chunks'] as $i=>$chunk){ |
|
| 304 | + $t=0; |
|
| 305 | + $cf=& $this->FontData($line['style'][$i]['font-family'], $line['style'][$i]['style'], $line['style'][$i]['font-size']); |
|
| 306 | + $cw=& $cf['CurrentFont']['cw']; |
|
| 307 | + $s=implode('', explode(' ',$chunk)); |
|
| 308 | + $l = strlen($s); |
|
| 309 | + for($j=0;$j<$l;$j++){ |
|
| 310 | 310 | $t+=$cw[$s[$j]]; |
| 311 | - } |
|
| 312 | - $w+=$t*$line['style'][$i]['font-size']; |
|
| 313 | - } |
|
| 314 | - return $w; |
|
| 315 | - } |
|
| 311 | + } |
|
| 312 | + $w+=$t*$line['style'][$i]['font-size']; |
|
| 313 | + } |
|
| 314 | + return $w; |
|
| 315 | + } |
|
| 316 | 316 | |
| 317 | - public function CellBlock($w, $lh, &$lines, $align='J'){ |
|
| 318 | - if($w==0){ |
|
| 319 | - return; |
|
| 320 | - } |
|
| 321 | - $ctmp=''; |
|
| 322 | - $ftmp=''; |
|
| 323 | - foreach($lines as $i=>$line){ |
|
| 324 | - $k = $this->k; |
|
| 325 | - if($this->y+$lh*$line['height']>$this->PageBreakTrigger){ |
|
| 317 | + public function CellBlock($w, $lh, &$lines, $align='J'){ |
|
| 318 | + if($w==0){ |
|
| 319 | + return; |
|
| 320 | + } |
|
| 321 | + $ctmp=''; |
|
| 322 | + $ftmp=''; |
|
| 323 | + foreach($lines as $i=>$line){ |
|
| 324 | + $k = $this->k; |
|
| 325 | + if($this->y+$lh*$line['height']>$this->PageBreakTrigger){ |
|
| 326 | 326 | break; |
| 327 | - } |
|
| 328 | - $dx=0; |
|
| 329 | - $dw=0; |
|
| 330 | - if($line['width']!=0){ |
|
| 327 | + } |
|
| 328 | + $dx=0; |
|
| 329 | + $dw=0; |
|
| 330 | + if($line['width']!=0){ |
|
| 331 | 331 | if($align=='R'){ |
| 332 | - $dx = $w-$line['width']/($this->k*1000); |
|
| 332 | + $dx = $w-$line['width']/($this->k*1000); |
|
| 333 | 333 | } |
| 334 | 334 | elseif($align=='C'){ |
| 335 | - $dx = ($w-$line['width']/($this->k*1000))/2; |
|
| 335 | + $dx = ($w-$line['width']/($this->k*1000))/2; |
|
| 336 | 336 | } |
| 337 | 337 | if($align=='J'){ |
| 338 | - $tmp=explode(' ', implode('',$line['chunks'])); |
|
| 339 | - $ns=count($tmp); |
|
| 340 | - if($ns>1){ |
|
| 341 | - $sx=implode('',$tmp); |
|
| 342 | - $delta=$this->GetMixStringWidth($line)/($this->k*1000); |
|
| 343 | - $dw=($w-$delta)*(1/($ns-1)); |
|
| 344 | - } |
|
| 338 | + $tmp=explode(' ', implode('',$line['chunks'])); |
|
| 339 | + $ns=count($tmp); |
|
| 340 | + if($ns>1){ |
|
| 341 | + $sx=implode('',$tmp); |
|
| 342 | + $delta=$this->GetMixStringWidth($line)/($this->k*1000); |
|
| 343 | + $dw=($w-$delta)*(1/($ns-1)); |
|
| 344 | + } |
|
| 345 | 345 | } |
| 346 | - } |
|
| 347 | - $xx=$this->x+$dx; |
|
| 348 | - foreach($line['chunks'] as $tj=>$txt){ |
|
| 346 | + } |
|
| 347 | + $xx=$this->x+$dx; |
|
| 348 | + foreach($line['chunks'] as $tj=>$txt){ |
|
| 349 | 349 | $this->resetFont($line['style'][$tj]['font-family'], $line['style'][$tj]['style'], $line['style'][$tj]['font-size']); |
| 350 | 350 | $this->resetColor($line['style'][$tj]['font-color'], 'T'); |
| 351 | 351 | $y=$this->y+0.5*$lh*$line['height'] +0.3*$line['height']/$this->k; |
| 352 | 352 | if($dw){ |
| 353 | - $tmp=explode(' ', $txt); |
|
| 354 | - foreach($tmp as $e=>$tt){ |
|
| 355 | - if($e>0){ |
|
| 356 | - $xx+=$dw; |
|
| 357 | - if($tt==''){ |
|
| 353 | + $tmp=explode(' ', $txt); |
|
| 354 | + foreach($tmp as $e=>$tt){ |
|
| 355 | + if($e>0){ |
|
| 356 | + $xx+=$dw; |
|
| 357 | + if($tt==''){ |
|
| 358 | 358 | continue; |
| 359 | - } |
|
| 360 | - } |
|
| 361 | - $this->Text($xx, $y, $tt); |
|
| 362 | - if($line['style'][$tj]['href']){ |
|
| 363 | - $yr=$this->y+0.5*($lh*$line['height']-$line['height']/$this->k); |
|
| 364 | - $this->Link($xx, $yr, $this->GetStringWidth($txt),$line['height']/$this->k, $line['style'][$tj]['href']); |
|
| 365 | - } |
|
| 366 | - $xx+=$this->GetStringWidth($tt); |
|
| 367 | - } |
|
| 359 | + } |
|
| 360 | + } |
|
| 361 | + $this->Text($xx, $y, $tt); |
|
| 362 | + if($line['style'][$tj]['href']){ |
|
| 363 | + $yr=$this->y+0.5*($lh*$line['height']-$line['height']/$this->k); |
|
| 364 | + $this->Link($xx, $yr, $this->GetStringWidth($txt),$line['height']/$this->k, $line['style'][$tj]['href']); |
|
| 365 | + } |
|
| 366 | + $xx+=$this->GetStringWidth($tt); |
|
| 367 | + } |
|
| 368 | 368 | } |
| 369 | 369 | else{ |
| 370 | - $this->Text($xx, $y, $txt); |
|
| 371 | - if($line['style'][$tj]['href']){ |
|
| 372 | - $yr=$this->y+0.5*($lh*$line['height']-$line['height']/$this->k); |
|
| 373 | - $this->Link($xx, $yr, $this->GetStringWidth($txt),$line['height']/$this->k, $line['style'][$tj]['href']); |
|
| 374 | - } |
|
| 375 | - $xx+=$this->GetStringWidth($txt); |
|
| 370 | + $this->Text($xx, $y, $txt); |
|
| 371 | + if($line['style'][$tj]['href']){ |
|
| 372 | + $yr=$this->y+0.5*($lh*$line['height']-$line['height']/$this->k); |
|
| 373 | + $this->Link($xx, $yr, $this->GetStringWidth($txt),$line['height']/$this->k, $line['style'][$tj]['href']); |
|
| 374 | + } |
|
| 375 | + $xx+=$this->GetStringWidth($txt); |
|
| 376 | + } |
|
| 376 | 377 | } |
| 377 | - } |
|
| 378 | - unset($lines[$i]); |
|
| 379 | - $this->y += $lh*$line['height']; |
|
| 380 | - } |
|
| 381 | - } |
|
| 378 | + unset($lines[$i]); |
|
| 379 | + $this->y += $lh*$line['height']; |
|
| 380 | + } |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | 383 | } |
| 384 | 384 | ?> |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | - /********************************************************************** |
|
| 2 | + /********************************************************************** |
|
| 3 | 3 | * formateString * |
| 4 | 4 | * * |
| 5 | 5 | * Version: 1.2 * |
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | * Author: Dan Machado * |
| 8 | 8 | * Use within exfpdf class * |
| 9 | 9 | **********************************************************************/ |
| 10 | - class formatedString |
|
| 11 | - { |
|
| 10 | + class formatedString |
|
| 11 | + { |
|
| 12 | 12 | public $parced_str; |
| 13 | 13 | public $style_map; |
| 14 | 14 | public $positions; |
@@ -20,191 +20,191 @@ discard block |
||
| 20 | 20 | public $used_fonts; |
| 21 | 21 | |
| 22 | 22 | private function get_style($str){ |
| 23 | - $style=array('font-family'=>false, 'font-weight'=>false, 'font-style'=>false, |
|
| 24 | - 'font-size'=>false, 'font-color'=>false, 'href'=>''); |
|
| 25 | - $tmp=explode(';', trim($str, '",\', ')); |
|
| 26 | - foreach($tmp as $x){ |
|
| 27 | - if($x && strpos($x,':')>0){ |
|
| 28 | - $r=explode(':',$x); |
|
| 29 | - $r[0]=trim($r[0]); |
|
| 30 | - $r[1]=trim($r[1]); |
|
| 31 | - if(isset($style[$r[0]]) || $r[0]=='style'){ |
|
| 23 | + $style=array('font-family'=>false, 'font-weight'=>false, 'font-style'=>false, |
|
| 24 | + 'font-size'=>false, 'font-color'=>false, 'href'=>''); |
|
| 25 | + $tmp=explode(';', trim($str, '",\', ')); |
|
| 26 | + foreach($tmp as $x){ |
|
| 27 | + if($x && strpos($x,':')>0){ |
|
| 28 | + $r=explode(':',$x); |
|
| 29 | + $r[0]=trim($r[0]); |
|
| 30 | + $r[1]=trim($r[1]); |
|
| 31 | + if(isset($style[$r[0]]) || $r[0]=='style'){ |
|
| 32 | 32 | if($r[0]=='style' || $r[0]=='font-style'){ |
| 33 | - $r[1]=strtoupper($r[1]); |
|
| 34 | - if(strpos($r[1], 'B')!==false){ |
|
| 35 | - $style['font-weight']='B'; |
|
| 36 | - } |
|
| 37 | - if(strpos($r[1], 'I')!==false){ |
|
| 38 | - $style['font-style']='I'; |
|
| 39 | - } |
|
| 40 | - if(strpos($r[1], 'U')!==false){ |
|
| 41 | - $style['font-style'].='U'; |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - elseif($r[1]){ |
|
| 45 | - if($r[0]=='href'){ |
|
| 46 | - $style[$r[0]]=implode(':', array_slice($r,1)); |
|
| 47 | - } |
|
| 48 | - else{ |
|
| 49 | - $style[$r[0]]=$r[1]; |
|
| 50 | - } |
|
| 51 | - } |
|
| 33 | + $r[1]=strtoupper($r[1]); |
|
| 34 | + if(strpos($r[1], 'B')!==false){ |
|
| 35 | + $style['font-weight']='B'; |
|
| 36 | + } |
|
| 37 | + if(strpos($r[1], 'I')!==false){ |
|
| 38 | + $style['font-style']='I'; |
|
| 39 | + } |
|
| 40 | + if(strpos($r[1], 'U')!==false){ |
|
| 41 | + $style['font-style'].='U'; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + elseif($r[1]){ |
|
| 45 | + if($r[0]=='href'){ |
|
| 46 | + $style[$r[0]]=implode(':', array_slice($r,1)); |
|
| 47 | + } |
|
| 48 | + else{ |
|
| 49 | + $style[$r[0]]=$r[1]; |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | 52 | } |
| 53 | - } |
|
| 54 | - } |
|
| 55 | - return $style; |
|
| 56 | - } |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + return $style; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | - private function style_merge($style1, $style2){ |
|
| 60 | - $result=$style1; |
|
| 61 | - foreach($style2 as $k=>$v){ |
|
| 62 | - if($v){ |
|
| 59 | + private function style_merge($style1, $style2){ |
|
| 60 | + $result=$style1; |
|
| 61 | + foreach($style2 as $k=>$v){ |
|
| 62 | + if($v){ |
|
| 63 | 63 | $result[$k]=$v; |
| 64 | - } |
|
| 65 | - } |
|
| 66 | - return $result; |
|
| 67 | - } |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + return $result; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - private function style_parcer($text, &$font_data){ |
|
| 70 | - $str=trim(strtr($text, array("\r"=>'', "\t"=>''))); |
|
| 71 | - $rep=array('[bB]{1}'=>'B', '[iI]{1}'=>'I', '[iI]{1}[ ]*[bB]{1}'=>'BI', '[bB]{1}[ ]*[iI]{1}'=>'BI' ); |
|
| 72 | - foreach($rep as $a=>$v){ |
|
| 73 | - $str=preg_replace('/<[ ]*'.$a.'[ ]*>/', "<$v>", $str); |
|
| 74 | - $str=preg_replace('/<[ ]*\/+[ ]*'.$a.'[ ]*>/', "</$v>", $str); |
|
| 75 | - } |
|
| 76 | - $str=preg_replace('/<BI>/', '<s "font-weight:B;font-style:I">', $str); |
|
| 77 | - $str=preg_replace('/<\/BI>/', "</s>", $str); |
|
| 78 | - $str=preg_replace('/<B>/', '<s "font-weight:B;">', $str); |
|
| 79 | - $str=preg_replace('/<\/B>/', "</s>", $str); |
|
| 80 | - $str=preg_replace('/<I>/', '<s "font-style:I;">', $str); |
|
| 81 | - $str=preg_replace('/<\/I>/', "</s>", $str); |
|
| 82 | - $open=array(); |
|
| 83 | - $total=array(); |
|
| 84 | - $lt="<s"; |
|
| 85 | - $rt="</s>"; |
|
| 86 | - $j=strpos($str, $lt, 0); |
|
| 87 | - while($j!==false){ |
|
| 69 | + private function style_parcer($text, &$font_data){ |
|
| 70 | + $str=trim(strtr($text, array("\r"=>'', "\t"=>''))); |
|
| 71 | + $rep=array('[bB]{1}'=>'B', '[iI]{1}'=>'I', '[iI]{1}[ ]*[bB]{1}'=>'BI', '[bB]{1}[ ]*[iI]{1}'=>'BI' ); |
|
| 72 | + foreach($rep as $a=>$v){ |
|
| 73 | + $str=preg_replace('/<[ ]*'.$a.'[ ]*>/', "<$v>", $str); |
|
| 74 | + $str=preg_replace('/<[ ]*\/+[ ]*'.$a.'[ ]*>/', "</$v>", $str); |
|
| 75 | + } |
|
| 76 | + $str=preg_replace('/<BI>/', '<s "font-weight:B;font-style:I">', $str); |
|
| 77 | + $str=preg_replace('/<\/BI>/', "</s>", $str); |
|
| 78 | + $str=preg_replace('/<B>/', '<s "font-weight:B;">', $str); |
|
| 79 | + $str=preg_replace('/<\/B>/', "</s>", $str); |
|
| 80 | + $str=preg_replace('/<I>/', '<s "font-style:I;">', $str); |
|
| 81 | + $str=preg_replace('/<\/I>/', "</s>", $str); |
|
| 82 | + $open=array(); |
|
| 83 | + $total=array(); |
|
| 84 | + $lt="<s"; |
|
| 85 | + $rt="</s>"; |
|
| 86 | + $j=strpos($str, $lt, 0); |
|
| 87 | + while($j!==false){ |
|
| 88 | 88 | if($j>0 && ord($str[$j-1])==92){ |
| 89 | 89 | $j=strpos($str, $lt, $j+1); |
| 90 | 90 | continue; |
| 91 | - } |
|
| 92 | - $k=strpos($str, '>',$j+1); |
|
| 93 | - $open[$j]=substr($str, $j+2, $k-($j+2)); |
|
| 94 | - $total[]=$j; |
|
| 95 | - $j=strpos($str, $lt, $j+1); |
|
| 96 | - } |
|
| 97 | - $j=strpos($str, $rt, 0); |
|
| 98 | - while($j!==false){ |
|
| 99 | - $total[]=$j; |
|
| 100 | - $j=strpos($str, $rt, $j+1); |
|
| 101 | - } |
|
| 102 | - sort($total); |
|
| 91 | + } |
|
| 92 | + $k=strpos($str, '>',$j+1); |
|
| 93 | + $open[$j]=substr($str, $j+2, $k-($j+2)); |
|
| 94 | + $total[]=$j; |
|
| 95 | + $j=strpos($str, $lt, $j+1); |
|
| 96 | + } |
|
| 97 | + $j=strpos($str, $rt, 0); |
|
| 98 | + while($j!==false){ |
|
| 99 | + $total[]=$j; |
|
| 100 | + $j=strpos($str, $rt, $j+1); |
|
| 101 | + } |
|
| 102 | + sort($total); |
|
| 103 | 103 | |
| 104 | - $cs=''; |
|
| 105 | - foreach($font_data as $k=>$v){ |
|
| 106 | - $cs.=$k . ':'. $v . '; '; |
|
| 107 | - } |
|
| 108 | - $cs=$this->get_style($cs); |
|
| 109 | - $tmp=array($cs); |
|
| 110 | - $blocks=array(); |
|
| 111 | - $blockstyle=array(); |
|
| 112 | - $n=count($total); |
|
| 113 | - $k=0; |
|
| 114 | - for($i=0; $i<$n; $i++){ |
|
| 115 | - $blocks[]=substr($str, $k, $total[$i]-$k); |
|
| 116 | - $blockstyle[]=$cs; |
|
| 117 | - if(isset($open[$total[$i]])){ |
|
| 104 | + $cs=''; |
|
| 105 | + foreach($font_data as $k=>$v){ |
|
| 106 | + $cs.=$k . ':'. $v . '; '; |
|
| 107 | + } |
|
| 108 | + $cs=$this->get_style($cs); |
|
| 109 | + $tmp=array($cs); |
|
| 110 | + $blocks=array(); |
|
| 111 | + $blockstyle=array(); |
|
| 112 | + $n=count($total); |
|
| 113 | + $k=0; |
|
| 114 | + for($i=0; $i<$n; $i++){ |
|
| 115 | + $blocks[]=substr($str, $k, $total[$i]-$k); |
|
| 116 | + $blockstyle[]=$cs; |
|
| 117 | + if(isset($open[$total[$i]])){ |
|
| 118 | 118 | $cs=$this->style_merge($cs, $this->get_style($open[$total[$i]])); |
| 119 | 119 | array_push($tmp, $cs); |
| 120 | 120 | $k=strpos($str, '>',$total[$i]+1)+1; |
| 121 | - } |
|
| 122 | - else{ |
|
| 121 | + } |
|
| 122 | + else{ |
|
| 123 | 123 | $k=$total[$i]+4; |
| 124 | 124 | array_pop($tmp); |
| 125 | 125 | $l=count($tmp)-1; |
| 126 | 126 | $cs=$tmp[$l]; |
| 127 | - } |
|
| 128 | - } |
|
| 129 | - if($k<strlen($str)){ |
|
| 130 | - $blocks[]=substr($str, $k); |
|
| 131 | - $blockstyle[]=$cs; |
|
| 132 | - } |
|
| 133 | - $n=count($blocks); |
|
| 134 | - for($i=0; $i<$n; $i++){ |
|
| 135 | - $this->parced_str.=strtr($blocks[$i], array('\<s'=>'<s')); |
|
| 136 | - if(strlen($blocks[$i])>0){ |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + if($k<strlen($str)){ |
|
| 130 | + $blocks[]=substr($str, $k); |
|
| 131 | + $blockstyle[]=$cs; |
|
| 132 | + } |
|
| 133 | + $n=count($blocks); |
|
| 134 | + for($i=0; $i<$n; $i++){ |
|
| 135 | + $this->parced_str.=strtr($blocks[$i], array('\<s'=>'<s')); |
|
| 136 | + if(strlen($blocks[$i])>0){ |
|
| 137 | 137 | $blockstyle[$i]['style']=$blockstyle[$i]['font-weight'] . $blockstyle[$i]['font-style']; |
| 138 | 138 | unset($blockstyle[$i]['font-weight']); |
| 139 | 139 | unset($blockstyle[$i]['font-style']); |
| 140 | 140 | $this->style_map[strlen($this->parced_str)-1]=$blockstyle[$i]; |
| 141 | - } |
|
| 142 | - } |
|
| 143 | - } |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - public function __construct($text, $width, &$font_data){ |
|
| 146 | - $this->iterator=0; |
|
| 147 | - $this->parced_str=''; |
|
| 148 | - $this->style_map=array(); |
|
| 149 | - $this->style_parcer($text, $font_data); |
|
| 150 | - $this->positions=array_keys($this->style_map); |
|
| 151 | - $this->np=(bool)count($this->positions); |
|
| 152 | - $this->width=$width; |
|
| 153 | - $this->lines=array(''); |
|
| 154 | - $this->linesmap[0]=array(0, 0, 0); |
|
| 155 | - $this->used_fonts=array(); |
|
| 156 | - } |
|
| 145 | + public function __construct($text, $width, &$font_data){ |
|
| 146 | + $this->iterator=0; |
|
| 147 | + $this->parced_str=''; |
|
| 148 | + $this->style_map=array(); |
|
| 149 | + $this->style_parcer($text, $font_data); |
|
| 150 | + $this->positions=array_keys($this->style_map); |
|
| 151 | + $this->np=(bool)count($this->positions); |
|
| 152 | + $this->width=$width; |
|
| 153 | + $this->lines=array(''); |
|
| 154 | + $this->linesmap[0]=array(0, 0, 0); |
|
| 155 | + $this->used_fonts=array(); |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - public function get_str(){ |
|
| 159 | - return $this->parced_str; |
|
| 160 | - } |
|
| 158 | + public function get_str(){ |
|
| 159 | + return $this->parced_str; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - public function get_current_style($i){ |
|
| 163 | - if(!$this->np){ |
|
| 164 | - return ''; |
|
| 165 | - } |
|
| 166 | - while($this->positions[$this->iterator]<$i){ |
|
| 167 | - $this->iterator++; |
|
| 168 | - } |
|
| 169 | - return $this->style_map[$this->positions[$this->iterator]]; |
|
| 170 | - } |
|
| 162 | + public function get_current_style($i){ |
|
| 163 | + if(!$this->np){ |
|
| 164 | + return ''; |
|
| 165 | + } |
|
| 166 | + while($this->positions[$this->iterator]<$i){ |
|
| 167 | + $this->iterator++; |
|
| 168 | + } |
|
| 169 | + return $this->style_map[$this->positions[$this->iterator]]; |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | 172 | |
| 173 | - public function break_by_style($t){ |
|
| 174 | - $i=$this->linesmap[$t][0]; |
|
| 175 | - $j=$this->linesmap[$t][1]; |
|
| 176 | - $this->iterator=0; |
|
| 177 | - $result=array('chunks'=>array(), 'style'=>array(), 'height'=>0, 'width'=>$this->linesmap[$t][2]); |
|
| 178 | - if(strlen($this->parced_str)==0){ |
|
| 179 | - return $result; |
|
| 180 | - } |
|
| 181 | - $cs=$this->get_current_style($i); |
|
| 182 | - $result['height']=$cs['font-size']; |
|
| 183 | - $r=0; |
|
| 184 | - $result['chunks'][$r]=''; |
|
| 185 | - $result['style'][$r]=$cs; |
|
| 186 | - while($this->parced_str[$j]==' '){ |
|
| 187 | - $j--; |
|
| 188 | - } |
|
| 189 | - $tmp=$i; |
|
| 190 | - for($k=$i; $k<=$j; $k++){ |
|
| 191 | - if($this->parced_str[$tmp]==' ' && $this->parced_str[$k]==' '){ |
|
| 173 | + public function break_by_style($t){ |
|
| 174 | + $i=$this->linesmap[$t][0]; |
|
| 175 | + $j=$this->linesmap[$t][1]; |
|
| 176 | + $this->iterator=0; |
|
| 177 | + $result=array('chunks'=>array(), 'style'=>array(), 'height'=>0, 'width'=>$this->linesmap[$t][2]); |
|
| 178 | + if(strlen($this->parced_str)==0){ |
|
| 179 | + return $result; |
|
| 180 | + } |
|
| 181 | + $cs=$this->get_current_style($i); |
|
| 182 | + $result['height']=$cs['font-size']; |
|
| 183 | + $r=0; |
|
| 184 | + $result['chunks'][$r]=''; |
|
| 185 | + $result['style'][$r]=$cs; |
|
| 186 | + while($this->parced_str[$j]==' '){ |
|
| 187 | + $j--; |
|
| 188 | + } |
|
| 189 | + $tmp=$i; |
|
| 190 | + for($k=$i; $k<=$j; $k++){ |
|
| 191 | + if($this->parced_str[$tmp]==' ' && $this->parced_str[$k]==' '){ |
|
| 192 | 192 | $tmp=$k; |
| 193 | 193 | continue; |
| 194 | - } |
|
| 194 | + } |
|
| 195 | 195 | if($cs!=$this->get_current_style($k)) { |
| 196 | 196 | $r++; |
| 197 | 197 | $cs=$this->get_current_style($k); |
| 198 | 198 | $result['chunks'][$r]=''; |
| 199 | 199 | $result['style'][$r]=$cs; |
| 200 | 200 | if($result['height']<$cs['font-size']){ |
| 201 | - $result['height']=$cs['font-size']; |
|
| 201 | + $result['height']=$cs['font-size']; |
|
| 202 | 202 | } |
| 203 | - } |
|
| 204 | - $result['chunks'][$r].=$this->parced_str[$k]; |
|
| 205 | - $tmp=$k; |
|
| 206 | - } |
|
| 207 | - return $result; |
|
| 208 | - } |
|
| 203 | + } |
|
| 204 | + $result['chunks'][$r].=$this->parced_str[$k]; |
|
| 205 | + $tmp=$k; |
|
| 206 | + } |
|
| 207 | + return $result; |
|
| 208 | + } |
|
| 209 | 209 | } |
| 210 | 210 | ?> |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | - /********************************************************************* |
|
| 2 | + /********************************************************************* |
|
| 3 | 3 | * FPDF easyTable * |
| 4 | 4 | * * |
| 5 | 5 | * Version: 2.0 * |
@@ -10,584 +10,584 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class EasyTable |
| 12 | 12 | { |
| 13 | - const LP=0.4; |
|
| 14 | - const XPadding=1; |
|
| 15 | - const YPadding=1; |
|
| 16 | - const IMGPadding=0.5; |
|
| 17 | - const PBThreshold=30; |
|
| 18 | - static private $table_counter=false; |
|
| 19 | - static private $style=array('width'=>false, 'border'=>false, 'border-color'=>false, |
|
| 20 | - 'border-width'=>false, 'line-height'=>false, |
|
| 21 | - 'align'=>'', 'valign'=>'', 'bgcolor'=>false, 'split-row'=>false, 'l-margin'=>false, |
|
| 22 | - 'font-family'=>false, 'font-style'=>false,'font-size'=>false, 'font-color'=>false, |
|
| 23 | - 'paddingX'=>false, 'paddingY'=>false); |
|
| 24 | - private $pdf_obj; |
|
| 25 | - private $document_style; |
|
| 26 | - private $table_style; |
|
| 27 | - private $col_num; |
|
| 28 | - private $col_width; |
|
| 29 | - private $baseX; |
|
| 30 | - private $row_style_def; |
|
| 31 | - private $row_style; |
|
| 32 | - private $row_heights; |
|
| 33 | - private $row_data; |
|
| 34 | - private $rows; |
|
| 35 | - private $total_rowspan; |
|
| 36 | - private $col_counter; |
|
| 37 | - private $grid; |
|
| 38 | - private $blocks; |
|
| 39 | - private $overflow; |
|
| 40 | - private $header_row; |
|
| 41 | - private $new_table; |
|
| 13 | + const LP=0.4; |
|
| 14 | + const XPadding=1; |
|
| 15 | + const YPadding=1; |
|
| 16 | + const IMGPadding=0.5; |
|
| 17 | + const PBThreshold=30; |
|
| 18 | + static private $table_counter=false; |
|
| 19 | + static private $style=array('width'=>false, 'border'=>false, 'border-color'=>false, |
|
| 20 | + 'border-width'=>false, 'line-height'=>false, |
|
| 21 | + 'align'=>'', 'valign'=>'', 'bgcolor'=>false, 'split-row'=>false, 'l-margin'=>false, |
|
| 22 | + 'font-family'=>false, 'font-style'=>false,'font-size'=>false, 'font-color'=>false, |
|
| 23 | + 'paddingX'=>false, 'paddingY'=>false); |
|
| 24 | + private $pdf_obj; |
|
| 25 | + private $document_style; |
|
| 26 | + private $table_style; |
|
| 27 | + private $col_num; |
|
| 28 | + private $col_width; |
|
| 29 | + private $baseX; |
|
| 30 | + private $row_style_def; |
|
| 31 | + private $row_style; |
|
| 32 | + private $row_heights; |
|
| 33 | + private $row_data; |
|
| 34 | + private $rows; |
|
| 35 | + private $total_rowspan; |
|
| 36 | + private $col_counter; |
|
| 37 | + private $grid; |
|
| 38 | + private $blocks; |
|
| 39 | + private $overflow; |
|
| 40 | + private $header_row; |
|
| 41 | + private $new_table; |
|
| 42 | 42 | |
| 43 | - private function get_available($colspan, $rowspan){ |
|
| 44 | - static $k=0; |
|
| 45 | - if(count($this->grid)==0){ |
|
| 46 | - $k=0; |
|
| 47 | - } |
|
| 48 | - while(isset($this->grid[$k])){ |
|
| 49 | - $k++; |
|
| 50 | - } |
|
| 51 | - for($i=0; $i<=$colspan; $i++){ |
|
| 52 | - for($j=0; $j<=$rowspan; $j++){ |
|
| 43 | + private function get_available($colspan, $rowspan){ |
|
| 44 | + static $k=0; |
|
| 45 | + if(count($this->grid)==0){ |
|
| 46 | + $k=0; |
|
| 47 | + } |
|
| 48 | + while(isset($this->grid[$k])){ |
|
| 49 | + $k++; |
|
| 50 | + } |
|
| 51 | + for($i=0; $i<=$colspan; $i++){ |
|
| 52 | + for($j=0; $j<=$rowspan; $j++){ |
|
| 53 | 53 | $this->grid[$k+$i+$j*$this->col_num]=true; |
| 54 | - } |
|
| 55 | - } |
|
| 56 | - return $k; |
|
| 57 | - } |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + return $k; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - private function get_style($str, $c){ |
|
| 60 | - $result=self::$style; |
|
| 61 | - if($c=='C'){ |
|
| 62 | - $result['colspan']=0; |
|
| 63 | - $result['rowspan']=0; |
|
| 64 | - $result['img']=false; |
|
| 65 | - } |
|
| 66 | - if($c=='C' || $c=='R'){ |
|
| 67 | - unset($result['width']); |
|
| 68 | - unset($result['border-width']); |
|
| 69 | - unset($result['split-row']); |
|
| 70 | - unset($result['l-margin']); |
|
| 71 | - } |
|
| 72 | - if($c=='R' || $c=='T'){ |
|
| 73 | - if($c=='R'){ |
|
| 59 | + private function get_style($str, $c){ |
|
| 60 | + $result=self::$style; |
|
| 61 | + if($c=='C'){ |
|
| 62 | + $result['colspan']=0; |
|
| 63 | + $result['rowspan']=0; |
|
| 64 | + $result['img']=false; |
|
| 65 | + } |
|
| 66 | + if($c=='C' || $c=='R'){ |
|
| 67 | + unset($result['width']); |
|
| 68 | + unset($result['border-width']); |
|
| 69 | + unset($result['split-row']); |
|
| 70 | + unset($result['l-margin']); |
|
| 71 | + } |
|
| 72 | + if($c=='R' || $c=='T'){ |
|
| 73 | + if($c=='R'){ |
|
| 74 | 74 | $result['c-align']=array_pad(array(), $this->col_num, 'L'); |
| 75 | - } |
|
| 76 | - else{ |
|
| 75 | + } |
|
| 76 | + else{ |
|
| 77 | 77 | $result['c-align']=array(); |
| 78 | - } |
|
| 79 | - } |
|
| 80 | - if($c=='R'){ |
|
| 81 | - $result['min-height']=false; |
|
| 82 | - } |
|
| 83 | - $tmp=explode(';', $str); |
|
| 84 | - foreach($tmp as $x){ |
|
| 85 | - if($x && strpos($x,':')>0){ |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + if($c=='R'){ |
|
| 81 | + $result['min-height']=false; |
|
| 82 | + } |
|
| 83 | + $tmp=explode(';', $str); |
|
| 84 | + foreach($tmp as $x){ |
|
| 85 | + if($x && strpos($x,':')>0){ |
|
| 86 | 86 | $r=explode(':',$x); |
| 87 | 87 | $r[0]=trim($r[0]); |
| 88 | 88 | $r[1]=trim($r[1]); |
| 89 | 89 | if(isset($result[$r[0]])){ |
| 90 | - $result[$r[0]]=$r[1]; |
|
| 90 | + $result[$r[0]]=$r[1]; |
|
| 91 | + } |
|
| 91 | 92 | } |
| 92 | - } |
|
| 93 | - } |
|
| 94 | - return $result; |
|
| 95 | - } |
|
| 93 | + } |
|
| 94 | + return $result; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - private function inherating(&$sty, $setting, $c){ |
|
| 98 | - if($c=='C'){ |
|
| 99 | - $sty[$setting]=$this->row_style[$setting]; |
|
| 100 | - } |
|
| 101 | - elseif($c=='R'){ |
|
| 102 | - $sty[$setting]=$this->table_style[$setting]; |
|
| 103 | - } |
|
| 104 | - else{ |
|
| 105 | - $sty[$setting]=$this->document_style[$setting]; |
|
| 106 | - } |
|
| 107 | - } |
|
| 97 | + private function inherating(&$sty, $setting, $c){ |
|
| 98 | + if($c=='C'){ |
|
| 99 | + $sty[$setting]=$this->row_style[$setting]; |
|
| 100 | + } |
|
| 101 | + elseif($c=='R'){ |
|
| 102 | + $sty[$setting]=$this->table_style[$setting]; |
|
| 103 | + } |
|
| 104 | + else{ |
|
| 105 | + $sty[$setting]=$this->document_style[$setting]; |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | |
| 110 | - private function set_style($str, $c, $pos=''){ |
|
| 111 | - $sty=$this->get_style($str, $c); |
|
| 112 | - if($c=='T'){ |
|
| 113 | - if(is_numeric($sty['width'])){ |
|
| 110 | + private function set_style($str, $c, $pos=''){ |
|
| 111 | + $sty=$this->get_style($str, $c); |
|
| 112 | + if($c=='T'){ |
|
| 113 | + if(is_numeric($sty['width'])){ |
|
| 114 | 114 | $sty['width']=min(abs($sty['width']),$this->document_style['document_width']); |
| 115 | 115 | if($sty['width']==0){ |
| 116 | - $sty['width']=$this->document_style['document_width']; |
|
| 116 | + $sty['width']=$this->document_style['document_width']; |
|
| 117 | + } |
|
| 117 | 118 | } |
| 118 | - } |
|
| 119 | - else{ |
|
| 119 | + else{ |
|
| 120 | 120 | $x=strpos($sty['width'], '%'); |
| 121 | 121 | if($x!=false){ |
| 122 | - $x=min(abs(substr($sty['width'], 0, $x)), 100); |
|
| 123 | - if($x){ |
|
| 124 | - $sty['width']=$x*$this->document_style['document_width']/100.0; |
|
| 125 | - } |
|
| 126 | - else{ |
|
| 127 | - $sty['width']=$this->document_style['document_width']; |
|
| 128 | - } |
|
| 122 | + $x=min(abs(substr($sty['width'], 0, $x)), 100); |
|
| 123 | + if($x){ |
|
| 124 | + $sty['width']=$x*$this->document_style['document_width']/100.0; |
|
| 125 | + } |
|
| 126 | + else{ |
|
| 127 | + $sty['width']=$this->document_style['document_width']; |
|
| 128 | + } |
|
| 129 | 129 | } |
| 130 | 130 | else{ |
| 131 | - $sty['width']=$this->document_style['document_width']; |
|
| 131 | + $sty['width']=$this->document_style['document_width']; |
|
| 132 | + } |
|
| 132 | 133 | } |
| 133 | - } |
|
| 134 | - if(!is_numeric($sty['l-margin'])){ |
|
| 134 | + if(!is_numeric($sty['l-margin'])){ |
|
| 135 | 135 | $sty['l-margin']=0; |
| 136 | - } |
|
| 137 | - else{ |
|
| 136 | + } |
|
| 137 | + else{ |
|
| 138 | 138 | $sty['l-margin']=abs($sty['l-margin']); |
| 139 | - } |
|
| 140 | - if(is_numeric($sty['border-width'])){ |
|
| 139 | + } |
|
| 140 | + if(is_numeric($sty['border-width'])){ |
|
| 141 | 141 | $sty['border-width']=abs($sty['border-width']); |
| 142 | - } |
|
| 143 | - else{ |
|
| 142 | + } |
|
| 143 | + else{ |
|
| 144 | 144 | $sty['border-width']=false; |
| 145 | - } |
|
| 146 | - if($sty['split-row']=='false'){ |
|
| 145 | + } |
|
| 146 | + if($sty['split-row']=='false'){ |
|
| 147 | 147 | $sty['split-row']=false; |
| 148 | - } |
|
| 149 | - elseif($sty['split-row']!==false){ |
|
| 148 | + } |
|
| 149 | + elseif($sty['split-row']!==false){ |
|
| 150 | 150 | $sty['split-row']=true; |
| 151 | - } |
|
| 152 | - } |
|
| 153 | - if($c=='R'){ |
|
| 154 | - if(!is_numeric($sty['min-height']) || $sty['min-height']<0){ |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + if($c=='R'){ |
|
| 154 | + if(!is_numeric($sty['min-height']) || $sty['min-height']<0){ |
|
| 155 | 155 | $sty['min-height']=0; |
| 156 | - } |
|
| 157 | - } |
|
| 158 | - if(!is_numeric($sty['paddingX'])){ |
|
| 159 | - if($c=='C' || $c=='R'){ |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + if(!is_numeric($sty['paddingX'])){ |
|
| 159 | + if($c=='C' || $c=='R'){ |
|
| 160 | 160 | $this->inherating($sty, 'paddingX', $c); |
| 161 | - } |
|
| 162 | - else{ |
|
| 161 | + } |
|
| 162 | + else{ |
|
| 163 | 163 | $sty['paddingX']=self::XPadding; |
| 164 | - } |
|
| 165 | - } |
|
| 166 | - $sty['paddingX']=abs($sty['paddingX']); |
|
| 167 | - if(!is_numeric($sty['paddingY'])){ |
|
| 168 | - if($c=='C' || $c=='R'){ |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + $sty['paddingX']=abs($sty['paddingX']); |
|
| 167 | + if(!is_numeric($sty['paddingY'])){ |
|
| 168 | + if($c=='C' || $c=='R'){ |
|
| 169 | 169 | $this->inherating($sty, 'paddingY', $c); |
| 170 | - } |
|
| 171 | - else{ |
|
| 170 | + } |
|
| 171 | + else{ |
|
| 172 | 172 | $sty['paddingY']=self::YPadding; |
| 173 | - } |
|
| 174 | - } |
|
| 175 | - $sty['paddingY']=abs($sty['paddingY']); |
|
| 176 | - if($sty['border']===false && ($c=='C' || $c=='R')){ |
|
| 177 | - $this->inherating($sty, 'border', $c); |
|
| 178 | - } |
|
| 179 | - else{ |
|
| 180 | - $border=array('T'=>1, 'R'=>1, 'B'=>1, 'L'=>1); |
|
| 181 | - if(!(is_numeric($sty['border']) && $sty['border']==1)){ |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + $sty['paddingY']=abs($sty['paddingY']); |
|
| 176 | + if($sty['border']===false && ($c=='C' || $c=='R')){ |
|
| 177 | + $this->inherating($sty, 'border', $c); |
|
| 178 | + } |
|
| 179 | + else{ |
|
| 180 | + $border=array('T'=>1, 'R'=>1, 'B'=>1, 'L'=>1); |
|
| 181 | + if(!(is_numeric($sty['border']) && $sty['border']==1)){ |
|
| 182 | 182 | foreach($border as $k=>$v){ |
| 183 | - $border[$k]=0; |
|
| 184 | - if(strpos($sty['border'], $k)!==false){ |
|
| 185 | - $border[$k]=1; |
|
| 186 | - } |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - $sty['border']=$border; |
|
| 190 | - } |
|
| 191 | - $color_settings=array('bgcolor', 'font-color', 'border-color'); |
|
| 192 | - foreach($color_settings as $setting){ |
|
| 193 | - if($sty[$setting]===false || !($this->pdf_obj->is_hex($sty[$setting]) || $this->pdf_obj->is_rgb($sty[$setting]))){ |
|
| 183 | + $border[$k]=0; |
|
| 184 | + if(strpos($sty['border'], $k)!==false){ |
|
| 185 | + $border[$k]=1; |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + $sty['border']=$border; |
|
| 190 | + } |
|
| 191 | + $color_settings=array('bgcolor', 'font-color', 'border-color'); |
|
| 192 | + foreach($color_settings as $setting){ |
|
| 193 | + if($sty[$setting]===false || !($this->pdf_obj->is_hex($sty[$setting]) || $this->pdf_obj->is_rgb($sty[$setting]))){ |
|
| 194 | 194 | if($c=='C' || $c=='R'){ |
| 195 | - $this->inherating($sty, $setting, $c); |
|
| 195 | + $this->inherating($sty, $setting, $c); |
|
| 196 | 196 | } |
| 197 | 197 | elseif($setting=='font-color'){ |
| 198 | - $sty[$setting]=$this->document_style[$setting]; |
|
| 198 | + $sty[$setting]=$this->document_style[$setting]; |
|
| 199 | + } |
|
| 199 | 200 | } |
| 200 | - } |
|
| 201 | - else{ |
|
| 201 | + else{ |
|
| 202 | 202 | $sty[$setting]=$sty[$setting]; |
| 203 | - } |
|
| 204 | - } |
|
| 205 | - $font_settings=array('font-family', 'font-style', 'font-size'); |
|
| 206 | - foreach($font_settings as $setting){ |
|
| 207 | - if($sty[$setting]===false){ |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + $font_settings=array('font-family', 'font-style', 'font-size'); |
|
| 206 | + foreach($font_settings as $setting){ |
|
| 207 | + if($sty[$setting]===false){ |
|
| 208 | 208 | $this->inherating($sty, $setting, $c); |
| 209 | - } |
|
| 210 | - } |
|
| 211 | - if(is_numeric($sty['line-height'])){ |
|
| 212 | - $sty['line-height']=self::LP*abs($sty['line-height']); |
|
| 213 | - } |
|
| 214 | - else{ |
|
| 215 | - if($c=='C' || $c=='R'){ |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | + if(is_numeric($sty['line-height'])){ |
|
| 212 | + $sty['line-height']=self::LP*abs($sty['line-height']); |
|
| 213 | + } |
|
| 214 | + else{ |
|
| 215 | + if($c=='C' || $c=='R'){ |
|
| 216 | 216 | $this->inherating($sty,'line-height', $c); |
| 217 | - } |
|
| 218 | - else{ |
|
| 217 | + } |
|
| 218 | + else{ |
|
| 219 | 219 | $sty['line-height']=self::LP; |
| 220 | - } |
|
| 221 | - } |
|
| 222 | - if($c=='C'){ |
|
| 223 | - if($sty['img']){ |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | + if($c=='C'){ |
|
| 223 | + if($sty['img']){ |
|
| 224 | 224 | $tmp=explode(',', $sty['img']); |
| 225 | 225 | if(file_exists($tmp[0])){ |
| 226 | - $sty['img']=array('path'=>'', 'h'=>0, 'w'=>0); |
|
| 227 | - $img=@ getimagesize($tmp[0]); |
|
| 228 | - $sty['img']['path']=$tmp[0]; |
|
| 229 | - for($i=1; $i<3; $i++){ |
|
| 230 | - if(isset($tmp[$i])){ |
|
| 231 | - $tmp[$i]=trim(strtolower($tmp[$i])); |
|
| 232 | - if($tmp[$i][0]=='w' || $tmp[$i][0]=='h'){ |
|
| 226 | + $sty['img']=array('path'=>'', 'h'=>0, 'w'=>0); |
|
| 227 | + $img=@ getimagesize($tmp[0]); |
|
| 228 | + $sty['img']['path']=$tmp[0]; |
|
| 229 | + for($i=1; $i<3; $i++){ |
|
| 230 | + if(isset($tmp[$i])){ |
|
| 231 | + $tmp[$i]=trim(strtolower($tmp[$i])); |
|
| 232 | + if($tmp[$i][0]=='w' || $tmp[$i][0]=='h'){ |
|
| 233 | 233 | $t=substr($tmp[$i],1); |
| 234 | 234 | if(is_numeric($t)){ |
| 235 | - $sty['img'][$tmp[$i][0]]=abs($t); |
|
| 235 | + $sty['img'][$tmp[$i][0]]=abs($t); |
|
| 236 | + } |
|
| 236 | 237 | } |
| 237 | - } |
|
| 238 | - } |
|
| 239 | - } |
|
| 240 | - $ration=$img[0]/$img[1]; |
|
| 241 | - if($sty['img']['w']+$sty['img']['h']==0){ |
|
| 242 | - $sty['img']['w']=$img[0]; |
|
| 243 | - $sty['img']['h']=$img[1]; |
|
| 244 | - } |
|
| 245 | - elseif($sty['img']['w']==0){ |
|
| 246 | - $sty['img']['w']=$sty['img']['h']*$ration; |
|
| 247 | - } |
|
| 248 | - elseif($sty['img']['h']==0){ |
|
| 249 | - $sty['img']['h']=$sty['img']['w']/$ration; |
|
| 250 | - } |
|
| 238 | + } |
|
| 239 | + } |
|
| 240 | + $ration=$img[0]/$img[1]; |
|
| 241 | + if($sty['img']['w']+$sty['img']['h']==0){ |
|
| 242 | + $sty['img']['w']=$img[0]; |
|
| 243 | + $sty['img']['h']=$img[1]; |
|
| 244 | + } |
|
| 245 | + elseif($sty['img']['w']==0){ |
|
| 246 | + $sty['img']['w']=$sty['img']['h']*$ration; |
|
| 247 | + } |
|
| 248 | + elseif($sty['img']['h']==0){ |
|
| 249 | + $sty['img']['h']=$sty['img']['w']/$ration; |
|
| 250 | + } |
|
| 251 | 251 | } |
| 252 | 252 | else{ |
| 253 | - $sty['img']='failed to open stream: file ' . $tmp[0] .' does not exist'; |
|
| 253 | + $sty['img']='failed to open stream: file ' . $tmp[0] .' does not exist'; |
|
| 254 | + } |
|
| 254 | 255 | } |
| 255 | - } |
|
| 256 | - if(is_numeric($sty['colspan']) && $sty['colspan']>0){ |
|
| 256 | + if(is_numeric($sty['colspan']) && $sty['colspan']>0){ |
|
| 257 | 257 | $sty['colspan']--; |
| 258 | - } |
|
| 259 | - else{ |
|
| 258 | + } |
|
| 259 | + else{ |
|
| 260 | 260 | $sty['colspan']=0; |
| 261 | - } |
|
| 262 | - if(is_numeric($sty['rowspan']) && $sty['rowspan']>0){ |
|
| 261 | + } |
|
| 262 | + if(is_numeric($sty['rowspan']) && $sty['rowspan']>0){ |
|
| 263 | 263 | $sty['rowspan']--; |
| 264 | - } |
|
| 265 | - else{ |
|
| 264 | + } |
|
| 265 | + else{ |
|
| 266 | 266 | $sty['rowspan']=0; |
| 267 | - } |
|
| 268 | - if($sty['valign']==false && ($sty['rowspan']>0 || $sty['img']!==false)){ |
|
| 267 | + } |
|
| 268 | + if($sty['valign']==false && ($sty['rowspan']>0 || $sty['img']!==false)){ |
|
| 269 | 269 | $sty['valign']='M'; |
| 270 | - } |
|
| 271 | - if($sty['align']==false && $sty['img']!==false){ |
|
| 270 | + } |
|
| 271 | + if($sty['align']==false && $sty['img']!==false){ |
|
| 272 | 272 | $sty['align']='C'; |
| 273 | - } |
|
| 274 | - } |
|
| 275 | - if($c=='T' || $c=='R'){ |
|
| 276 | - $tmp=explode('{',$sty['align']); |
|
| 277 | - if($c=='T'){ |
|
| 273 | + } |
|
| 274 | + } |
|
| 275 | + if($c=='T' || $c=='R'){ |
|
| 276 | + $tmp=explode('{',$sty['align']); |
|
| 277 | + if($c=='T'){ |
|
| 278 | 278 | $sty['align']=trim($tmp[0]); |
| 279 | - } |
|
| 280 | - if(isset($tmp[1])){ |
|
| 279 | + } |
|
| 280 | + if(isset($tmp[1])){ |
|
| 281 | 281 | $tmp[1]=trim($tmp[1], '}'); |
| 282 | 282 | if(strlen($tmp[1])){ |
| 283 | - for($i=0; $i<strlen($tmp[1]); $i++){ |
|
| 284 | - if(preg_match("/[LCRJ]/", $tmp[1][$i])!=0){ |
|
| 285 | - $sty['c-align'][$i]=$tmp[1][$i]; |
|
| 286 | - } |
|
| 287 | - else{ |
|
| 288 | - $sty['c-align'][$i]='L'; |
|
| 289 | - } |
|
| 290 | - } |
|
| 283 | + for($i=0; $i<strlen($tmp[1]); $i++){ |
|
| 284 | + if(preg_match("/[LCRJ]/", $tmp[1][$i])!=0){ |
|
| 285 | + $sty['c-align'][$i]=$tmp[1][$i]; |
|
| 286 | + } |
|
| 287 | + else{ |
|
| 288 | + $sty['c-align'][$i]='L'; |
|
| 289 | + } |
|
| 290 | + } |
|
| 291 | 291 | } |
| 292 | 292 | if($c=='R'){ |
| 293 | - $sty['align']='L'; |
|
| 294 | - $sty['c-align']=array_slice($sty['c-align'],0,$this->col_num); |
|
| 293 | + $sty['align']='L'; |
|
| 294 | + $sty['c-align']=array_slice($sty['c-align'],0,$this->col_num); |
|
| 295 | 295 | } |
| 296 | - } |
|
| 297 | - } |
|
| 298 | - if($sty['align']!='L' && $sty['align']!='C' && $sty['align']!='R' && $sty['align']!='J'){ |
|
| 299 | - if($c=='C'){ |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | + if($sty['align']!='L' && $sty['align']!='C' && $sty['align']!='R' && $sty['align']!='J'){ |
|
| 299 | + if($c=='C'){ |
|
| 300 | 300 | $sty['align']=$this->row_style['c-align'][$pos]; |
| 301 | - } |
|
| 302 | - elseif($c=='R'){ |
|
| 301 | + } |
|
| 302 | + elseif($c=='R'){ |
|
| 303 | 303 | $sty['align']='L'; |
| 304 | 304 | $sty['c-align']=$this->table_style['c-align']; |
| 305 | - } |
|
| 306 | - else{ |
|
| 305 | + } |
|
| 306 | + else{ |
|
| 307 | + $sty['align']='C'; |
|
| 308 | + } |
|
| 309 | + } |
|
| 310 | + elseif($c=='T' && $sty['align']=='J'){ |
|
| 307 | 311 | $sty['align']='C'; |
| 308 | - } |
|
| 309 | - } |
|
| 310 | - elseif($c=='T' && $sty['align']=='J'){ |
|
| 311 | - $sty['align']='C'; |
|
| 312 | - } |
|
| 313 | - if($sty['valign']!='T' && $sty['valign']!='M' && $sty['valign']!='B'){ |
|
| 314 | - if($c=='C' || $c=='R'){ |
|
| 312 | + } |
|
| 313 | + if($sty['valign']!='T' && $sty['valign']!='M' && $sty['valign']!='B'){ |
|
| 314 | + if($c=='C' || $c=='R'){ |
|
| 315 | 315 | $this->inherating($sty, 'valign', $c); |
| 316 | - } |
|
| 317 | - else{ |
|
| 316 | + } |
|
| 317 | + else{ |
|
| 318 | 318 | $sty['valign']='T'; |
| 319 | - } |
|
| 320 | - } |
|
| 321 | - return $sty; |
|
| 322 | - } |
|
| 319 | + } |
|
| 320 | + } |
|
| 321 | + return $sty; |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | - private function row_content_loop($counter, $f){ |
|
| 325 | - $t=0; |
|
| 326 | - if($counter>0){ |
|
| 327 | - $t=$this->rows[$counter-1]; |
|
| 328 | - } |
|
| 329 | - for($index=$t; $index<$this->rows[$counter]; $index++){ |
|
| 330 | - $f($index); |
|
| 331 | - } |
|
| 332 | - } |
|
| 324 | + private function row_content_loop($counter, $f){ |
|
| 325 | + $t=0; |
|
| 326 | + if($counter>0){ |
|
| 327 | + $t=$this->rows[$counter-1]; |
|
| 328 | + } |
|
| 329 | + for($index=$t; $index<$this->rows[$counter]; $index++){ |
|
| 330 | + $f($index); |
|
| 331 | + } |
|
| 332 | + } |
|
| 333 | 333 | |
| 334 | - private function mk_border($i, $y, $split){ |
|
| 335 | - $w=$this->row_data[$i][2]; |
|
| 336 | - $h=$this->row_data[$i][5]; |
|
| 337 | - if($split){ |
|
| 338 | - $h=$this->pdf_obj->PageBreak()-$y; |
|
| 339 | - } |
|
| 340 | - if($this->row_data[$i][1]['border-color']!=false){ |
|
| 341 | - $this->pdf_obj->resetColor($this->row_data[$i][1]['border-color'], 'D'); |
|
| 342 | - } |
|
| 343 | - $a=array(1, 1, 1, 0); |
|
| 344 | - $borders=array('L'=>3, 'T'=>0, 'R'=>1, 'B'=>2); |
|
| 345 | - foreach($borders as $border=>$j){ |
|
| 346 | - if($this->row_data[$i][1]['border'][$border]){ |
|
| 334 | + private function mk_border($i, $y, $split){ |
|
| 335 | + $w=$this->row_data[$i][2]; |
|
| 336 | + $h=$this->row_data[$i][5]; |
|
| 337 | + if($split){ |
|
| 338 | + $h=$this->pdf_obj->PageBreak()-$y; |
|
| 339 | + } |
|
| 340 | + if($this->row_data[$i][1]['border-color']!=false){ |
|
| 341 | + $this->pdf_obj->resetColor($this->row_data[$i][1]['border-color'], 'D'); |
|
| 342 | + } |
|
| 343 | + $a=array(1, 1, 1, 0); |
|
| 344 | + $borders=array('L'=>3, 'T'=>0, 'R'=>1, 'B'=>2); |
|
| 345 | + foreach($borders as $border=>$j){ |
|
| 346 | + if($this->row_data[$i][1]['border'][$border]){ |
|
| 347 | 347 | if($border=='B'){ |
| 348 | - if($split==0){ |
|
| 349 | - $this->pdf_obj->Line($this->row_data[$i][6]+(1+$a[($j+2)%4])%2*$w, $y+(1+$a[($j+1)%4])%2 * $h, $this->row_data[$i][6]+$a[$j%4]*$w, $y+($a[($j+3)%4])%2 *$h); |
|
| 350 | - } |
|
| 348 | + if($split==0){ |
|
| 349 | + $this->pdf_obj->Line($this->row_data[$i][6]+(1+$a[($j+2)%4])%2*$w, $y+(1+$a[($j+1)%4])%2 * $h, $this->row_data[$i][6]+$a[$j%4]*$w, $y+($a[($j+3)%4])%2 *$h); |
|
| 350 | + } |
|
| 351 | 351 | } |
| 352 | 352 | else{ |
| 353 | - $this->pdf_obj->Line($this->row_data[$i][6]+(1+$a[($j+2)%4])%2*$w, $y+(1+$a[($j+1)%4])%2 * $h, $this->row_data[$i][6]+$a[$j%4]*$w, $y+($a[($j+3)%4])%2 *$h); |
|
| 353 | + $this->pdf_obj->Line($this->row_data[$i][6]+(1+$a[($j+2)%4])%2*$w, $y+(1+$a[($j+1)%4])%2 * $h, $this->row_data[$i][6]+$a[$j%4]*$w, $y+($a[($j+3)%4])%2 *$h); |
|
| 354 | 354 | } |
| 355 | - } |
|
| 356 | - } |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | 357 | |
| 358 | - if($this->row_data[$i][1]['border-color']!=false){ |
|
| 359 | - $this->pdf_obj->resetColor($this->document_style['bgcolor'], 'D'); |
|
| 360 | - } |
|
| 361 | - if($split){ |
|
| 362 | - $this->pdf_obj->row_data[$i][1]['border']['T']=0; |
|
| 363 | - } |
|
| 364 | - } |
|
| 358 | + if($this->row_data[$i][1]['border-color']!=false){ |
|
| 359 | + $this->pdf_obj->resetColor($this->document_style['bgcolor'], 'D'); |
|
| 360 | + } |
|
| 361 | + if($split){ |
|
| 362 | + $this->pdf_obj->row_data[$i][1]['border']['T']=0; |
|
| 363 | + } |
|
| 364 | + } |
|
| 365 | 365 | |
| 366 | - private function print_text($i, $y, $split){ |
|
| 367 | - $padding=$this->row_data[$i][1]['padding-y']; |
|
| 368 | - $k=$padding; |
|
| 369 | - if($this->row_data[$i][1]['img']!==false){ |
|
| 370 | - if($this->row_data[$i][1]['valign']=='B'){ |
|
| 366 | + private function print_text($i, $y, $split){ |
|
| 367 | + $padding=$this->row_data[$i][1]['padding-y']; |
|
| 368 | + $k=$padding; |
|
| 369 | + if($this->row_data[$i][1]['img']!==false){ |
|
| 370 | + if($this->row_data[$i][1]['valign']=='B'){ |
|
| 371 | 371 | $k+=$this->row_data[$i][1]['img']['h']+self::IMGPadding; |
| 372 | - } |
|
| 373 | - } |
|
| 374 | - $l=0; |
|
| 375 | - if(count($this->row_data[$i][0])){ |
|
| 376 | - $x=$this->row_data[$i][6]+$this->row_data[$i][1]['paddingX']; |
|
| 377 | - $xpadding=2*$this->row_data[$i][1]['paddingX']; |
|
| 378 | - $l=count($this->row_data[$i][0])* $this->row_data[$i][1]['line-height']*$this->row_data[$i][1]['font-size']; |
|
| 379 | - $this->pdf_obj->SetXY($x, $y+$k); |
|
| 380 | - $this->pdf_obj->CellBlock($this->row_data[$i][2]-$xpadding, $this->row_data[$i][1]['line-height'], $this->row_data[$i][0], $this->row_data[$i][1]['align']); |
|
| 381 | - $this->pdf_obj->resetFont($this->document_style['font-family'], $this->document_style['font-style'], $this->document_style['font-size']); |
|
| 382 | - $this->pdf_obj->resetColor($this->document_style['font-color'], 'T'); |
|
| 383 | - } |
|
| 384 | - if($this->row_data[$i][1]['img']!==false ){ |
|
| 385 | - $x=$this->row_data[$i][6]; |
|
| 386 | - $k=$padding; |
|
| 387 | - if($this->row_data[$i][1]['valign']!='B'){ |
|
| 372 | + } |
|
| 373 | + } |
|
| 374 | + $l=0; |
|
| 375 | + if(count($this->row_data[$i][0])){ |
|
| 376 | + $x=$this->row_data[$i][6]+$this->row_data[$i][1]['paddingX']; |
|
| 377 | + $xpadding=2*$this->row_data[$i][1]['paddingX']; |
|
| 378 | + $l=count($this->row_data[$i][0])* $this->row_data[$i][1]['line-height']*$this->row_data[$i][1]['font-size']; |
|
| 379 | + $this->pdf_obj->SetXY($x, $y+$k); |
|
| 380 | + $this->pdf_obj->CellBlock($this->row_data[$i][2]-$xpadding, $this->row_data[$i][1]['line-height'], $this->row_data[$i][0], $this->row_data[$i][1]['align']); |
|
| 381 | + $this->pdf_obj->resetFont($this->document_style['font-family'], $this->document_style['font-style'], $this->document_style['font-size']); |
|
| 382 | + $this->pdf_obj->resetColor($this->document_style['font-color'], 'T'); |
|
| 383 | + } |
|
| 384 | + if($this->row_data[$i][1]['img']!==false ){ |
|
| 385 | + $x=$this->row_data[$i][6]; |
|
| 386 | + $k=$padding; |
|
| 387 | + if($this->row_data[$i][1]['valign']!='B'){ |
|
| 388 | 388 | $k+=$l+self::IMGPadding; |
| 389 | - } |
|
| 390 | - if($this->imgbreak($i, $y)==0 && $y+$k+$this->row_data[$i][1]['img']['h']<$this->pdf_obj->PageBreak()){ |
|
| 389 | + } |
|
| 390 | + if($this->imgbreak($i, $y)==0 && $y+$k+$this->row_data[$i][1]['img']['h']<$this->pdf_obj->PageBreak()){ |
|
| 391 | 391 | $x+=$this->row_data[$i][1]['paddingX']; |
| 392 | 392 | if($this->row_data[$i][2]>$this->row_data[$i][1]['img']['w']){ |
| 393 | - if($this->row_data[$i][1]['align']=='C'){ |
|
| 394 | - $x-=$this->row_data[$i][1]['paddingX']; |
|
| 395 | - $x+=($this->row_data[$i][2]-$this->row_data[$i][1]['img']['w'])/2; |
|
| 396 | - } |
|
| 397 | - elseif($this->row_data[$i][1]['align']=='R'){ |
|
| 398 | - $x+=$this->row_data[$i][2]-$this->row_data[$i][1]['img']['w']; |
|
| 399 | - $x-=2*$this->row_data[$i][1]['paddingX']; |
|
| 400 | - } |
|
| 393 | + if($this->row_data[$i][1]['align']=='C'){ |
|
| 394 | + $x-=$this->row_data[$i][1]['paddingX']; |
|
| 395 | + $x+=($this->row_data[$i][2]-$this->row_data[$i][1]['img']['w'])/2; |
|
| 396 | + } |
|
| 397 | + elseif($this->row_data[$i][1]['align']=='R'){ |
|
| 398 | + $x+=$this->row_data[$i][2]-$this->row_data[$i][1]['img']['w']; |
|
| 399 | + $x-=2*$this->row_data[$i][1]['paddingX']; |
|
| 400 | + } |
|
| 401 | 401 | } |
| 402 | 402 | $this->pdf_obj->Image($this->row_data[$i][1]['img']['path'], $x, $y+$k, $this->row_data[$i][1]['img']['w'], $this->row_data[$i][1]['img']['h']); |
| 403 | - } |
|
| 404 | - } |
|
| 405 | - } |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | + } |
|
| 406 | 406 | |
| 407 | 407 | |
| 408 | - private function mk_bg($i, $T, $split){ |
|
| 409 | - $h=$this->row_data[$i][5]; |
|
| 410 | - if($split){ |
|
| 411 | - $h=$this->pdf_obj->PageBreak()-$T; |
|
| 412 | - } |
|
| 413 | - if($this->row_data[$i][1]['bgcolor']!=false){ |
|
| 414 | - $this->pdf_obj->resetColor($this->row_data[$i][1]['bgcolor']); |
|
| 415 | - $this->pdf_obj->Rect($this->row_data[$i][6], $T, $this->row_data[$i][2], $h, 'F'); |
|
| 416 | - $this->pdf_obj->resetColor($this->document_style['bgcolor']); |
|
| 417 | - } |
|
| 418 | - } |
|
| 408 | + private function mk_bg($i, $T, $split){ |
|
| 409 | + $h=$this->row_data[$i][5]; |
|
| 410 | + if($split){ |
|
| 411 | + $h=$this->pdf_obj->PageBreak()-$T; |
|
| 412 | + } |
|
| 413 | + if($this->row_data[$i][1]['bgcolor']!=false){ |
|
| 414 | + $this->pdf_obj->resetColor($this->row_data[$i][1]['bgcolor']); |
|
| 415 | + $this->pdf_obj->Rect($this->row_data[$i][6], $T, $this->row_data[$i][2], $h, 'F'); |
|
| 416 | + $this->pdf_obj->resetColor($this->document_style['bgcolor']); |
|
| 417 | + } |
|
| 418 | + } |
|
| 419 | 419 | |
| 420 | - private function printing_loop($swap=false){ |
|
| 421 | - $this->swap_data($swap); |
|
| 422 | - $y=$this->pdf_obj->GetY(); |
|
| 423 | - $tmp=array(); |
|
| 424 | - $rw=array(); |
|
| 425 | - $ztmp=array(); |
|
| 426 | - $total_cells=count($this->row_data); |
|
| 427 | - while(count($tmp)!=$total_cells){ |
|
| 428 | - $a=count($this->rows); |
|
| 429 | - $h=0; |
|
| 430 | - $y=$this->pdf_obj->GetY(); |
|
| 431 | - for($j=0; $j<count($this->rows); $j++){ |
|
| 420 | + private function printing_loop($swap=false){ |
|
| 421 | + $this->swap_data($swap); |
|
| 422 | + $y=$this->pdf_obj->GetY(); |
|
| 423 | + $tmp=array(); |
|
| 424 | + $rw=array(); |
|
| 425 | + $ztmp=array(); |
|
| 426 | + $total_cells=count($this->row_data); |
|
| 427 | + while(count($tmp)!=$total_cells){ |
|
| 428 | + $a=count($this->rows); |
|
| 429 | + $h=0; |
|
| 430 | + $y=$this->pdf_obj->GetY(); |
|
| 431 | + for($j=0; $j<count($this->rows); $j++){ |
|
| 432 | 432 | $T=$y+$h; |
| 433 | 433 | if($T<$this->pdf_obj->PageBreak()){ |
| 434 | 434 | |
| 435 | - $this->row_content_loop($j, function($index)use($T, $tmp){ |
|
| 436 | - if(!isset($tmp[$index])){ |
|
| 437 | - $split_cell=$this->scan_for_breaks($index,$T, false); |
|
| 438 | - $this->mk_bg($index, $T, $split_cell); |
|
| 439 | - } |
|
| 440 | - }); |
|
| 441 | - if(!isset($rw[$j])){ |
|
| 442 | - if($this->pdf_obj->PageBreak()-($T+$this->row_heights[$j])>=0){ |
|
| 443 | - $h+=$this->row_heights[$j]; |
|
| 444 | - } |
|
| 445 | - else{ |
|
| 446 | - $a=$j+1; |
|
| 447 | - break; |
|
| 448 | - } |
|
| 449 | - } |
|
| 435 | + $this->row_content_loop($j, function($index)use($T, $tmp){ |
|
| 436 | + if(!isset($tmp[$index])){ |
|
| 437 | + $split_cell=$this->scan_for_breaks($index,$T, false); |
|
| 438 | + $this->mk_bg($index, $T, $split_cell); |
|
| 439 | + } |
|
| 440 | + }); |
|
| 441 | + if(!isset($rw[$j])){ |
|
| 442 | + if($this->pdf_obj->PageBreak()-($T+$this->row_heights[$j])>=0){ |
|
| 443 | + $h+=$this->row_heights[$j]; |
|
| 444 | + } |
|
| 445 | + else{ |
|
| 446 | + $a=$j+1; |
|
| 447 | + break; |
|
| 448 | + } |
|
| 449 | + } |
|
| 450 | 450 | } |
| 451 | 451 | else{ |
| 452 | - $a=$j+1; |
|
| 453 | - break; |
|
| 452 | + $a=$j+1; |
|
| 453 | + break; |
|
| 454 | + } |
|
| 454 | 455 | } |
| 455 | - } |
|
| 456 | - $h=0; |
|
| 457 | - for($j=0; $j<$a; $j++){ |
|
| 456 | + $h=0; |
|
| 457 | + for($j=0; $j<$a; $j++){ |
|
| 458 | 458 | $T=$y+$h; |
| 459 | 459 | if($T<$this->pdf_obj->PageBreak()){ |
| 460 | 460 | |
| 461 | - $this->row_content_loop($j, function($index)use($T, &$tmp, &$ztmp){ |
|
| 462 | - if(!isset($tmp[$index])){ |
|
| 463 | - $split_cell=$this->scan_for_breaks($index,$T); |
|
| 464 | - $this->mk_border($index, $T, $split_cell); |
|
| 465 | - $this->print_text($index, $T, $split_cell); |
|
| 466 | - if($split_cell==0){ |
|
| 461 | + $this->row_content_loop($j, function($index)use($T, &$tmp, &$ztmp){ |
|
| 462 | + if(!isset($tmp[$index])){ |
|
| 463 | + $split_cell=$this->scan_for_breaks($index,$T); |
|
| 464 | + $this->mk_border($index, $T, $split_cell); |
|
| 465 | + $this->print_text($index, $T, $split_cell); |
|
| 466 | + if($split_cell==0){ |
|
| 467 | 467 | $tmp[$index]=$index; |
| 468 | - } |
|
| 469 | - else{ |
|
| 468 | + } |
|
| 469 | + else{ |
|
| 470 | 470 | $ztmp[]=$index; |
| 471 | - } |
|
| 472 | - } |
|
| 473 | - }); |
|
| 474 | - if(!isset($rw[$j])){ |
|
| 475 | - $tw=$this->pdf_obj->PageBreak()-($T+$this->row_heights[$j]); |
|
| 476 | - if($tw>=0){ |
|
| 477 | - $h+=$this->row_heights[$j]; |
|
| 478 | - $rw[$j]=$j; |
|
| 479 | - } |
|
| 480 | - else{ |
|
| 481 | - $this->row_heights[$j]=$this->overflow-$tw; |
|
| 482 | - } |
|
| 483 | - } |
|
| 484 | - } |
|
| 485 | - } |
|
| 486 | - if(count($tmp)!=$total_cells){ |
|
| 471 | + } |
|
| 472 | + } |
|
| 473 | + }); |
|
| 474 | + if(!isset($rw[$j])){ |
|
| 475 | + $tw=$this->pdf_obj->PageBreak()-($T+$this->row_heights[$j]); |
|
| 476 | + if($tw>=0){ |
|
| 477 | + $h+=$this->row_heights[$j]; |
|
| 478 | + $rw[$j]=$j; |
|
| 479 | + } |
|
| 480 | + else{ |
|
| 481 | + $this->row_heights[$j]=$this->overflow-$tw; |
|
| 482 | + } |
|
| 483 | + } |
|
| 484 | + } |
|
| 485 | + } |
|
| 486 | + if(count($tmp)!=$total_cells){ |
|
| 487 | 487 | foreach($ztmp as $index){ |
| 488 | - $this->row_data[$index][5]=$this->row_data[$index][7]+$this->overflow; |
|
| 489 | - if(isset($this->row_data[$index][8])){ |
|
| 490 | - $this->row_data[$index][1]['padding-y']=$this->row_data[$index][8]; |
|
| 491 | - unset($this->row_data[$index][8]); |
|
| 492 | - } |
|
| 488 | + $this->row_data[$index][5]=$this->row_data[$index][7]+$this->overflow; |
|
| 489 | + if(isset($this->row_data[$index][8])){ |
|
| 490 | + $this->row_data[$index][1]['padding-y']=$this->row_data[$index][8]; |
|
| 491 | + unset($this->row_data[$index][8]); |
|
| 492 | + } |
|
| 493 | 493 | } |
| 494 | 494 | $this->overflow=0; |
| 495 | 495 | $ztmp=array(); |
| 496 | 496 | $this->pdf_obj->addPage($this->document_style['orientation']); |
| 497 | - } |
|
| 498 | - else{ |
|
| 497 | + } |
|
| 498 | + else{ |
|
| 499 | 499 | $y+=$h; |
| 500 | - } |
|
| 501 | - } |
|
| 502 | - $this->pdf_obj->SetXY($this->baseX, $y); |
|
| 503 | - $this->swap_data($swap); |
|
| 504 | - } |
|
| 500 | + } |
|
| 501 | + } |
|
| 502 | + $this->pdf_obj->SetXY($this->baseX, $y); |
|
| 503 | + $this->swap_data($swap); |
|
| 504 | + } |
|
| 505 | 505 | |
| 506 | - private function imgbreak($i, $y){ |
|
| 507 | - $li=$y+$this->row_data[$i][1]['padding-y']; |
|
| 508 | - $ls=$this->row_data[$i][1]['img']['h']; |
|
| 509 | - if($this->row_data[$i][1]['valign']=='B'){ |
|
| 510 | - $ls+=$li; |
|
| 511 | - } |
|
| 512 | - else{ |
|
| 513 | - $li+=$this->row_data[$i][3]-$this->row_data[$i][1]['img']['h']; |
|
| 514 | - $ls+=$li; |
|
| 515 | - } |
|
| 516 | - $result=0; |
|
| 517 | - if($li<$this->pdf_obj->PageBreak() && $this->pdf_obj->PageBreak()<$ls){ |
|
| 518 | - $result=$this->pdf_obj->PageBreak()-$li; |
|
| 519 | - } |
|
| 520 | - return $result; |
|
| 521 | - } |
|
| 506 | + private function imgbreak($i, $y){ |
|
| 507 | + $li=$y+$this->row_data[$i][1]['padding-y']; |
|
| 508 | + $ls=$this->row_data[$i][1]['img']['h']; |
|
| 509 | + if($this->row_data[$i][1]['valign']=='B'){ |
|
| 510 | + $ls+=$li; |
|
| 511 | + } |
|
| 512 | + else{ |
|
| 513 | + $li+=$this->row_data[$i][3]-$this->row_data[$i][1]['img']['h']; |
|
| 514 | + $ls+=$li; |
|
| 515 | + } |
|
| 516 | + $result=0; |
|
| 517 | + if($li<$this->pdf_obj->PageBreak() && $this->pdf_obj->PageBreak()<$ls){ |
|
| 518 | + $result=$this->pdf_obj->PageBreak()-$li; |
|
| 519 | + } |
|
| 520 | + return $result; |
|
| 521 | + } |
|
| 522 | 522 | |
| 523 | - private function scan_for_breaks($index, $H, $l=true){ |
|
| 524 | - $print_cell=0; |
|
| 525 | - $h=($H+$this->row_data[$index][5])-$this->pdf_obj->PageBreak(); |
|
| 526 | - if($h>0){ |
|
| 527 | - if($l){ |
|
| 523 | + private function scan_for_breaks($index, $H, $l=true){ |
|
| 524 | + $print_cell=0; |
|
| 525 | + $h=($H+$this->row_data[$index][5])-$this->pdf_obj->PageBreak(); |
|
| 526 | + if($h>0){ |
|
| 527 | + if($l){ |
|
| 528 | 528 | $rr=$this->pdf_obj->PageBreak()-($H+$this->row_data[$index][1]['padding-y']); |
| 529 | 529 | if($rr>0){ |
| 530 | - $mx=0; |
|
| 531 | - if(count($this->row_data[$index][0]) && $this->row_data[$index][1]['img']!==false){ |
|
| 532 | - $mx=$this->imgbreak($index, $H); |
|
| 533 | - if($mx==0){ |
|
| 534 | - if($this->row_data[$index][1]['valign']=='B'){ |
|
| 530 | + $mx=0; |
|
| 531 | + if(count($this->row_data[$index][0]) && $this->row_data[$index][1]['img']!==false){ |
|
| 532 | + $mx=$this->imgbreak($index, $H); |
|
| 533 | + if($mx==0){ |
|
| 534 | + if($this->row_data[$index][1]['valign']=='B'){ |
|
| 535 | 535 | $rr-=$this->row_data[$index][1]['img']['h']; |
| 536 | - } |
|
| 537 | - } |
|
| 538 | - } |
|
| 539 | - $nh=0; |
|
| 540 | - $keys=array_keys($this->row_data[$index][0]); |
|
| 541 | - foreach($keys as $i){ |
|
| 542 | - $nh+=$this->row_data[$index][0][$i]['height']; |
|
| 543 | - } |
|
| 544 | - $nh*=$this->row_data[$index][1]['line-height']; |
|
| 545 | - if($mx==0 && $rr<$nh){ |
|
| 546 | - $nw=0; |
|
| 547 | - foreach($keys as $i){ |
|
| 548 | - $nw+=$this->row_data[$index][0][$i]['height']*$this->row_data[$index][1]['line-height']; |
|
| 549 | - if($nw>$rr){ |
|
| 536 | + } |
|
| 537 | + } |
|
| 538 | + } |
|
| 539 | + $nh=0; |
|
| 540 | + $keys=array_keys($this->row_data[$index][0]); |
|
| 541 | + foreach($keys as $i){ |
|
| 542 | + $nh+=$this->row_data[$index][0][$i]['height']; |
|
| 543 | + } |
|
| 544 | + $nh*=$this->row_data[$index][1]['line-height']; |
|
| 545 | + if($mx==0 && $rr<$nh){ |
|
| 546 | + $nw=0; |
|
| 547 | + foreach($keys as $i){ |
|
| 548 | + $nw+=$this->row_data[$index][0][$i]['height']*$this->row_data[$index][1]['line-height']; |
|
| 549 | + if($nw>$rr){ |
|
| 550 | 550 | $nw-=$this->row_data[$index][0][$i]['height']*$this->row_data[$index][1]['line-height']; |
| 551 | 551 | $mx=$rr-$nw; |
| 552 | 552 | break; |
| 553 | - } |
|
| 554 | - } |
|
| 555 | - } |
|
| 556 | - $this->overflow=max($this->overflow, $mx); |
|
| 557 | - $this->row_data[$index][8]=1; |
|
| 553 | + } |
|
| 554 | + } |
|
| 555 | + } |
|
| 556 | + $this->overflow=max($this->overflow, $mx); |
|
| 557 | + $this->row_data[$index][8]=1; |
|
| 558 | 558 | } |
| 559 | 559 | else{ |
| 560 | - $this->row_data[$index][8]=-1*$rr; |
|
| 560 | + $this->row_data[$index][8]=-1*$rr; |
|
| 561 | 561 | } |
| 562 | 562 | $this->row_data[$index][7]=$h; |
| 563 | - } |
|
| 564 | - $print_cell=1; |
|
| 565 | - } |
|
| 566 | - return $print_cell; |
|
| 567 | - } |
|
| 563 | + } |
|
| 564 | + $print_cell=1; |
|
| 565 | + } |
|
| 566 | + return $print_cell; |
|
| 567 | + } |
|
| 568 | 568 | |
| 569 | - private function swap_data($swap){ |
|
| 570 | - if($swap==false){ |
|
| 571 | - return; |
|
| 572 | - } |
|
| 573 | - static $data=array(); |
|
| 574 | - if(count($data)==0){ |
|
| 575 | - $data=array('header_data'=>$this->header_row['row_data'], 'row_heights'=>&$this->row_heights, 'row_data'=>&$this->row_data, 'rows'=>&$this->rows); |
|
| 576 | - unset($this->row_heights, $this->row_data, $this->rows); |
|
| 577 | - $this->row_heights=&$this->header_row['row_heights']; |
|
| 578 | - $this->row_data=&$this->header_row['row_data']; |
|
| 579 | - $this->rows=&$this->header_row['rows']; |
|
| 580 | - } |
|
| 581 | - else{ |
|
| 582 | - $this->header_row['row_data']=$data['header_data']; |
|
| 583 | - unset($this->row_heights, $this->row_data, $this->rows); |
|
| 584 | - $this->row_heights=$data['row_heights']; |
|
| 585 | - $this->row_data=$data['row_data']; |
|
| 586 | - $this->rows=$data['rows']; |
|
| 587 | - $data=array(); |
|
| 588 | - } |
|
| 589 | - } |
|
| 590 | - /******************************************************************** |
|
| 569 | + private function swap_data($swap){ |
|
| 570 | + if($swap==false){ |
|
| 571 | + return; |
|
| 572 | + } |
|
| 573 | + static $data=array(); |
|
| 574 | + if(count($data)==0){ |
|
| 575 | + $data=array('header_data'=>$this->header_row['row_data'], 'row_heights'=>&$this->row_heights, 'row_data'=>&$this->row_data, 'rows'=>&$this->rows); |
|
| 576 | + unset($this->row_heights, $this->row_data, $this->rows); |
|
| 577 | + $this->row_heights=&$this->header_row['row_heights']; |
|
| 578 | + $this->row_data=&$this->header_row['row_data']; |
|
| 579 | + $this->rows=&$this->header_row['rows']; |
|
| 580 | + } |
|
| 581 | + else{ |
|
| 582 | + $this->header_row['row_data']=$data['header_data']; |
|
| 583 | + unset($this->row_heights, $this->row_data, $this->rows); |
|
| 584 | + $this->row_heights=$data['row_heights']; |
|
| 585 | + $this->row_data=$data['row_data']; |
|
| 586 | + $this->rows=$data['rows']; |
|
| 587 | + $data=array(); |
|
| 588 | + } |
|
| 589 | + } |
|
| 590 | + /******************************************************************** |
|
| 591 | 591 | |
| 592 | 592 | function __construct( FPDF-object $fpdf_obj, Mix $num_cols[, string $style = '' ]) |
| 593 | 593 | ----------------------------------------------------- |
@@ -628,110 +628,110 @@ discard block |
||
| 628 | 628 | An easyTable object |
| 629 | 629 | ***********************************************************************/ |
| 630 | 630 | |
| 631 | - public function __construct($fpdf_obj, $num_cols, $style=''){ |
|
| 632 | - if(self::$table_counter){ |
|
| 633 | - error_log('Please use the end_table method to terminate the last table'); |
|
| 634 | - exit(); |
|
| 635 | - } |
|
| 636 | - self::$table_counter=true; |
|
| 637 | - $this->pdf_obj=&$fpdf_obj; |
|
| 638 | - $this->document_style['bgcolor']=$this->pdf_obj->get_color('fill'); |
|
| 639 | - $this->document_style['font-family']=$this->pdf_obj->current_font('family'); |
|
| 640 | - $this->document_style['font-style']=$this->pdf_obj->current_font('style'); |
|
| 641 | - $this->document_style['font-size']=$this->pdf_obj->current_font('size'); |
|
| 642 | - $this->document_style['font-color']=$this->pdf_obj->get_color('text'); |
|
| 643 | - $this->document_style['document_width']=$this->pdf_obj->GetPageWidth()-$this->pdf_obj->get_margin('l')-$this->pdf_obj->get_margin('r'); |
|
| 644 | - $this->document_style['orientation']=$this->pdf_obj->get_orientation(); |
|
| 645 | - $this->document_style['line-width']=$this->pdf_obj->get_linewidth(); |
|
| 646 | - $this->table_style=$this->set_style($style, 'T'); |
|
| 647 | - $this->col_num=false; |
|
| 648 | - $this->col_width=array(); |
|
| 649 | - if(is_int($num_cols) && $num_cols!=0){ |
|
| 650 | - $this->col_num=abs($num_cols); |
|
| 651 | - $this->col_width=array_pad(array(), abs($num_cols), $this->table_style['width']/abs($num_cols)); |
|
| 652 | - } |
|
| 653 | - elseif(is_string($num_cols)){ |
|
| 654 | - $num_cols=trim($num_cols, '}, '); |
|
| 655 | - if($num_cols[0]!='{' && $num_cols[0]!='%'){ |
|
| 631 | + public function __construct($fpdf_obj, $num_cols, $style=''){ |
|
| 632 | + if(self::$table_counter){ |
|
| 633 | + error_log('Please use the end_table method to terminate the last table'); |
|
| 634 | + exit(); |
|
| 635 | + } |
|
| 636 | + self::$table_counter=true; |
|
| 637 | + $this->pdf_obj=&$fpdf_obj; |
|
| 638 | + $this->document_style['bgcolor']=$this->pdf_obj->get_color('fill'); |
|
| 639 | + $this->document_style['font-family']=$this->pdf_obj->current_font('family'); |
|
| 640 | + $this->document_style['font-style']=$this->pdf_obj->current_font('style'); |
|
| 641 | + $this->document_style['font-size']=$this->pdf_obj->current_font('size'); |
|
| 642 | + $this->document_style['font-color']=$this->pdf_obj->get_color('text'); |
|
| 643 | + $this->document_style['document_width']=$this->pdf_obj->GetPageWidth()-$this->pdf_obj->get_margin('l')-$this->pdf_obj->get_margin('r'); |
|
| 644 | + $this->document_style['orientation']=$this->pdf_obj->get_orientation(); |
|
| 645 | + $this->document_style['line-width']=$this->pdf_obj->get_linewidth(); |
|
| 646 | + $this->table_style=$this->set_style($style, 'T'); |
|
| 647 | + $this->col_num=false; |
|
| 648 | + $this->col_width=array(); |
|
| 649 | + if(is_int($num_cols) && $num_cols!=0){ |
|
| 650 | + $this->col_num=abs($num_cols); |
|
| 651 | + $this->col_width=array_pad(array(), abs($num_cols), $this->table_style['width']/abs($num_cols)); |
|
| 652 | + } |
|
| 653 | + elseif(is_string($num_cols)){ |
|
| 654 | + $num_cols=trim($num_cols, '}, '); |
|
| 655 | + if($num_cols[0]!='{' && $num_cols[0]!='%'){ |
|
| 656 | 656 | error_log('Bad format for columns in Table constructor'); |
| 657 | 657 | exit(); |
| 658 | - } |
|
| 659 | - $tmp=explode('{', $num_cols); |
|
| 660 | - $tp=trim($tmp[0]); |
|
| 661 | - $num_cols=explode(',', $tmp[1]); |
|
| 662 | - $w=0; |
|
| 663 | - foreach($num_cols as $c){ |
|
| 658 | + } |
|
| 659 | + $tmp=explode('{', $num_cols); |
|
| 660 | + $tp=trim($tmp[0]); |
|
| 661 | + $num_cols=explode(',', $tmp[1]); |
|
| 662 | + $w=0; |
|
| 663 | + foreach($num_cols as $c){ |
|
| 664 | 664 | if(!is_numeric($c)){ |
| 665 | - error_log('Bad parameter format for columns in Table constructor'); |
|
| 666 | - exit(); |
|
| 665 | + error_log('Bad parameter format for columns in Table constructor'); |
|
| 666 | + exit(); |
|
| 667 | 667 | } |
| 668 | 668 | if(abs($c)){ |
| 669 | - $w+=abs($c); |
|
| 670 | - $this->col_width[]=abs($c); |
|
| 669 | + $w+=abs($c); |
|
| 670 | + $this->col_width[]=abs($c); |
|
| 671 | 671 | } |
| 672 | 672 | else{ |
| 673 | - error_log('Column width can not be zero'); |
|
| 673 | + error_log('Column width can not be zero'); |
|
| 674 | + } |
|
| 674 | 675 | } |
| 675 | - } |
|
| 676 | - $this->col_num=count($this->col_width); |
|
| 677 | - if($tp=='%'){ |
|
| 676 | + $this->col_num=count($this->col_width); |
|
| 677 | + if($tp=='%'){ |
|
| 678 | 678 | if($w!=100){ |
| 679 | - error_log('The sum of the percentages of the columns is not 100'); |
|
| 680 | - exit(); |
|
| 679 | + error_log('The sum of the percentages of the columns is not 100'); |
|
| 680 | + exit(); |
|
| 681 | 681 | } |
| 682 | 682 | foreach($this->col_width as $i=>$c){ |
| 683 | - $this->col_width[$i]=$c*$this->table_style['width']/100; |
|
| 683 | + $this->col_width[$i]=$c*$this->table_style['width']/100; |
|
| 684 | + } |
|
| 684 | 685 | } |
| 685 | - } |
|
| 686 | - elseif($w!=$this->table_style['width'] && $w){ |
|
| 686 | + elseif($w!=$this->table_style['width'] && $w){ |
|
| 687 | 687 | if($w<$this->document_style['document_width']){ |
| 688 | - $this->table_style['width']=$w; |
|
| 688 | + $this->table_style['width']=$w; |
|
| 689 | 689 | } |
| 690 | 690 | else{ |
| 691 | - $this->table_style['width']=$this->document_style['document_width']; |
|
| 692 | - $d=$this->table_style['width']/$w; |
|
| 693 | - for($i=0; $i<count($num_cols); $i++){ |
|
| 694 | - $this->col_width[$i]*=$d; |
|
| 695 | - } |
|
| 696 | - } |
|
| 697 | - } |
|
| 698 | - } |
|
| 699 | - if($this->col_num==false){ |
|
| 700 | - error_log('Unspecified number of columns in Table constructor'); |
|
| 701 | - exit(); |
|
| 702 | - } |
|
| 703 | - $this->table_style['c-align']=array_pad($this->table_style['c-align'], $this->col_num, 'L'); |
|
| 704 | - if($this->table_style['l-margin']){ |
|
| 705 | - $this->baseX=$this->pdf_obj->get_margin('l')+min($this->table_style['l-margin'],$this->document_style['document_width']-$this->table_style['width']); |
|
| 706 | - } |
|
| 707 | - else{ |
|
| 708 | - if($this->table_style['align']=='L'){ |
|
| 691 | + $this->table_style['width']=$this->document_style['document_width']; |
|
| 692 | + $d=$this->table_style['width']/$w; |
|
| 693 | + for($i=0; $i<count($num_cols); $i++){ |
|
| 694 | + $this->col_width[$i]*=$d; |
|
| 695 | + } |
|
| 696 | + } |
|
| 697 | + } |
|
| 698 | + } |
|
| 699 | + if($this->col_num==false){ |
|
| 700 | + error_log('Unspecified number of columns in Table constructor'); |
|
| 701 | + exit(); |
|
| 702 | + } |
|
| 703 | + $this->table_style['c-align']=array_pad($this->table_style['c-align'], $this->col_num, 'L'); |
|
| 704 | + if($this->table_style['l-margin']){ |
|
| 705 | + $this->baseX=$this->pdf_obj->get_margin('l')+min($this->table_style['l-margin'],$this->document_style['document_width']-$this->table_style['width']); |
|
| 706 | + } |
|
| 707 | + else{ |
|
| 708 | + if($this->table_style['align']=='L'){ |
|
| 709 | 709 | $this->baseX=$this->pdf_obj->get_margin('l'); |
| 710 | - } |
|
| 711 | - elseif($this->table_style['align']=='R'){ |
|
| 710 | + } |
|
| 711 | + elseif($this->table_style['align']=='R'){ |
|
| 712 | 712 | $this->baseX=$this->pdf_obj->get_margin('l')+$this->document_style['document_width']-$this->table_style['width']; |
| 713 | - } |
|
| 714 | - else{ |
|
| 713 | + } |
|
| 714 | + else{ |
|
| 715 | 715 | $this->baseX=$this->pdf_obj->get_margin('l')+($this->document_style['document_width']-$this->table_style['width'])/2; |
| 716 | - } |
|
| 717 | - } |
|
| 718 | - $this->row_style_def=$this->set_style('', 'R'); |
|
| 719 | - $this->row_style=$this->row_style_def; |
|
| 720 | - $this->row_heights=array(); |
|
| 721 | - $this->row_data=array(); |
|
| 722 | - $this->rows=array(); |
|
| 723 | - $this->total_rowspan=0; |
|
| 724 | - $this->col_counter=0; |
|
| 725 | - $this->grid=array(); |
|
| 726 | - $this->blocks=array(); |
|
| 727 | - $this->overflow=0; |
|
| 728 | - if($this->table_style['border-width']!=false){ |
|
| 729 | - $this->pdf_obj->SetLineWidth($this->table_style['border-width']); |
|
| 730 | - } |
|
| 731 | - $this->header_row=array(); |
|
| 732 | - $this->new_table=true; |
|
| 733 | - } |
|
| 734 | - /*********************************************************************** |
|
| 716 | + } |
|
| 717 | + } |
|
| 718 | + $this->row_style_def=$this->set_style('', 'R'); |
|
| 719 | + $this->row_style=$this->row_style_def; |
|
| 720 | + $this->row_heights=array(); |
|
| 721 | + $this->row_data=array(); |
|
| 722 | + $this->rows=array(); |
|
| 723 | + $this->total_rowspan=0; |
|
| 724 | + $this->col_counter=0; |
|
| 725 | + $this->grid=array(); |
|
| 726 | + $this->blocks=array(); |
|
| 727 | + $this->overflow=0; |
|
| 728 | + if($this->table_style['border-width']!=false){ |
|
| 729 | + $this->pdf_obj->SetLineWidth($this->table_style['border-width']); |
|
| 730 | + } |
|
| 731 | + $this->header_row=array(); |
|
| 732 | + $this->new_table=true; |
|
| 733 | + } |
|
| 734 | + /*********************************************************************** |
|
| 735 | 735 | |
| 736 | 736 | function rowStyle( string $style ) |
| 737 | 737 | ------------------------------------------------------------- |
@@ -749,10 +749,10 @@ discard block |
||
| 749 | 749 | This function should be called before the first cell of the current row |
| 750 | 750 | ***********************************************************************/ |
| 751 | 751 | |
| 752 | - public function rowStyle($style){ |
|
| 753 | - $this->row_style=$this->set_style($style, 'R'); |
|
| 754 | - } |
|
| 755 | - /*********************************************************************** |
|
| 752 | + public function rowStyle($style){ |
|
| 753 | + $this->row_style=$this->set_style($style, 'R'); |
|
| 754 | + } |
|
| 755 | + /*********************************************************************** |
|
| 756 | 756 | |
| 757 | 757 | function easyCell( string $data [, string $style = '' ]) |
| 758 | 758 | ------------------------------------------------------------------------ |
@@ -768,62 +768,62 @@ discard block |
||
| 768 | 768 | void |
| 769 | 769 | ***********************************************************************/ |
| 770 | 770 | |
| 771 | - public function easyCell($data, $style=''){ |
|
| 772 | - if($this->col_counter<$this->col_num){ |
|
| 773 | - $sty=$this->set_style($style, 'C', $this->col_counter); |
|
| 774 | - $this->col_counter++; |
|
| 775 | - $row_number=count($this->rows); |
|
| 776 | - $cell_index=count($this->row_data); |
|
| 777 | - $cell_pos=$this->get_available($sty['colspan'], $sty['rowspan']); |
|
| 778 | - $colm=$cell_pos %$this->col_num; |
|
| 779 | - if($sty['img']!=false && $data!='' && $sty['valign']=='M'){ |
|
| 771 | + public function easyCell($data, $style=''){ |
|
| 772 | + if($this->col_counter<$this->col_num){ |
|
| 773 | + $sty=$this->set_style($style, 'C', $this->col_counter); |
|
| 774 | + $this->col_counter++; |
|
| 775 | + $row_number=count($this->rows); |
|
| 776 | + $cell_index=count($this->row_data); |
|
| 777 | + $cell_pos=$this->get_available($sty['colspan'], $sty['rowspan']); |
|
| 778 | + $colm=$cell_pos %$this->col_num; |
|
| 779 | + if($sty['img']!=false && $data!='' && $sty['valign']=='M'){ |
|
| 780 | 780 | $sty['valign']=$this->row_style['valign']; |
| 781 | - } |
|
| 782 | - if($sty['rowspan']){ |
|
| 781 | + } |
|
| 782 | + if($sty['rowspan']){ |
|
| 783 | 783 | $this->total_rowspan=max($this->total_rowspan, $sty['rowspan']); |
| 784 | 784 | $this->blocks[$cell_index]=array($cell_index, $row_number, $sty['rowspan']); |
| 785 | - } |
|
| 786 | - $w=$this->col_width[$colm]; |
|
| 787 | - $r=0; |
|
| 788 | - while($r<$sty['colspan'] && $this->col_counter<$this->col_num){ |
|
| 785 | + } |
|
| 786 | + $w=$this->col_width[$colm]; |
|
| 787 | + $r=0; |
|
| 788 | + while($r<$sty['colspan'] && $this->col_counter<$this->col_num){ |
|
| 789 | 789 | $this->col_counter++; |
| 790 | 790 | $colm++; |
| 791 | 791 | $w+=$this->col_width[$colm]; |
| 792 | 792 | $r++; |
| 793 | - } |
|
| 794 | - $w-=2*$sty['paddingX']; |
|
| 795 | - if($sty['img']!==false && is_string($sty['img'])){ |
|
| 793 | + } |
|
| 794 | + $w-=2*$sty['paddingX']; |
|
| 795 | + if($sty['img']!==false && is_string($sty['img'])){ |
|
| 796 | 796 | $data=$sty['img']; |
| 797 | 797 | $sty['img']=false; |
| 798 | - } |
|
| 799 | - $data=& $this->pdf_obj->extMultiCell($sty['font-family'], $sty['font-style'], $sty['font-size'], $sty['font-color'], $w, $data); |
|
| 800 | - $h=0; |
|
| 801 | - $rn=count($data); |
|
| 802 | - for($ri=0; $ri<$rn; $ri++){ |
|
| 798 | + } |
|
| 799 | + $data=& $this->pdf_obj->extMultiCell($sty['font-family'], $sty['font-style'], $sty['font-size'], $sty['font-color'], $w, $data); |
|
| 800 | + $h=0; |
|
| 801 | + $rn=count($data); |
|
| 802 | + for($ri=0; $ri<$rn; $ri++){ |
|
| 803 | 803 | $h+=$data[$ri]['height']*$sty['line-height']; |
| 804 | - } |
|
| 805 | - if($sty['img']){ |
|
| 804 | + } |
|
| 805 | + if($sty['img']){ |
|
| 806 | 806 | if($sty['img']['w']>$w){ |
| 807 | - $sty['img']['h']=$w*$sty['img']['h']/$sty['img']['w']; |
|
| 808 | - $sty['img']['w']=$w; |
|
| 807 | + $sty['img']['h']=$w*$sty['img']['h']/$sty['img']['w']; |
|
| 808 | + $sty['img']['w']=$w; |
|
| 809 | 809 | } |
| 810 | 810 | if($h){ |
| 811 | - $h+=self::IMGPadding; |
|
| 811 | + $h+=self::IMGPadding; |
|
| 812 | 812 | } |
| 813 | 813 | $h+=$sty['img']['h']; |
| 814 | - } |
|
| 815 | - $w+=2*$sty['paddingX']; |
|
| 814 | + } |
|
| 815 | + $w+=2*$sty['paddingX']; |
|
| 816 | 816 | |
| 817 | - $posx=$this->baseX; |
|
| 818 | - $d=$cell_pos %$this->col_num; |
|
| 819 | - for($k=0; $k<$d; $k++){ |
|
| 817 | + $posx=$this->baseX; |
|
| 818 | + $d=$cell_pos %$this->col_num; |
|
| 819 | + for($k=0; $k<$d; $k++){ |
|
| 820 | 820 | $posx+=$this->col_width[$k]; |
| 821 | - } |
|
| 822 | - $this->row_data[$cell_index]=array($data, $sty, $w, $h, $cell_pos, 0, $posx, 0); |
|
| 821 | + } |
|
| 822 | + $this->row_data[$cell_index]=array($data, $sty, $w, $h, $cell_pos, 0, $posx, 0); |
|
| 823 | 823 | |
| 824 | - } |
|
| 825 | - } |
|
| 826 | - /*********************************************************************** |
|
| 824 | + } |
|
| 825 | + } |
|
| 826 | + /*********************************************************************** |
|
| 827 | 827 | |
| 828 | 828 | function printRow ( [ bool $setAsHeader = false ] ) |
| 829 | 829 | ------------------------------------------------------------------------ |
@@ -848,98 +848,98 @@ discard block |
||
| 848 | 848 | total_rowspan=max(total_rowspan, max(rowspan of cell in the current row))-1; |
| 849 | 849 | ***********************************************************************/ |
| 850 | 850 | |
| 851 | - public function printRow($setAsHeader=false){ |
|
| 852 | - $this->col_counter=0; |
|
| 853 | - $row_number=count($this->rows); |
|
| 854 | - $this->rows[$row_number]=count($this->row_data); |
|
| 855 | - $mx=$this->row_style['min-height']; |
|
| 851 | + public function printRow($setAsHeader=false){ |
|
| 852 | + $this->col_counter=0; |
|
| 853 | + $row_number=count($this->rows); |
|
| 854 | + $this->rows[$row_number]=count($this->row_data); |
|
| 855 | + $mx=$this->row_style['min-height']; |
|
| 856 | 856 | |
| 857 | - $this->row_content_loop($row_number, function($index)use(&$mx){ |
|
| 858 | - if($this->row_data[$index][1]['rowspan']==0){ |
|
| 857 | + $this->row_content_loop($row_number, function($index)use(&$mx){ |
|
| 858 | + if($this->row_data[$index][1]['rowspan']==0){ |
|
| 859 | 859 | $mx=max($mx, $this->row_data[$index][3]+2*$this->row_data[$index][1]['paddingY']); |
| 860 | - } |
|
| 861 | - }); |
|
| 862 | - $this->row_heights[$row_number]=$mx; |
|
| 860 | + } |
|
| 861 | + }); |
|
| 862 | + $this->row_heights[$row_number]=$mx; |
|
| 863 | 863 | |
| 864 | - if($this->total_rowspan>0){ |
|
| 865 | - $this->total_rowspan--; |
|
| 866 | - } |
|
| 867 | - else{ |
|
| 868 | - $row_number=count($this->rows); |
|
| 869 | - if(count($this->blocks)>0){ |
|
| 864 | + if($this->total_rowspan>0){ |
|
| 865 | + $this->total_rowspan--; |
|
| 866 | + } |
|
| 867 | + else{ |
|
| 868 | + $row_number=count($this->rows); |
|
| 869 | + if(count($this->blocks)>0){ |
|
| 870 | 870 | |
| 871 | 871 | foreach($this->blocks as $bk_id=>$block){ |
| 872 | - $h=0; |
|
| 873 | - for($i=$block[1]; $i<=$block[1]+$block[2]; $i++){ |
|
| 874 | - $h+=$this->row_heights[$i]; |
|
| 875 | - } |
|
| 876 | - $t=$this->row_data[$block[0]][3]+2*$this->row_data[$block[0]][1]['paddingY']; |
|
| 877 | - if($h>0 && $h<$t){ |
|
| 878 | - for($i=$block[1]; $i<=$block[1]+$block[2]; $i++){ |
|
| 879 | - $this->row_heights[$i]*=$t/$h; |
|
| 880 | - } |
|
| 881 | - } |
|
| 872 | + $h=0; |
|
| 873 | + for($i=$block[1]; $i<=$block[1]+$block[2]; $i++){ |
|
| 874 | + $h+=$this->row_heights[$i]; |
|
| 875 | + } |
|
| 876 | + $t=$this->row_data[$block[0]][3]+2*$this->row_data[$block[0]][1]['paddingY']; |
|
| 877 | + if($h>0 && $h<$t){ |
|
| 878 | + for($i=$block[1]; $i<=$block[1]+$block[2]; $i++){ |
|
| 879 | + $this->row_heights[$i]*=$t/$h; |
|
| 880 | + } |
|
| 881 | + } |
|
| 882 | 882 | } |
| 883 | 883 | foreach($this->blocks as $j=>$block){ |
| 884 | - $h=0; |
|
| 885 | - for($i=$block[1]; $i<=$block[1]+$block[2]; $i++){ |
|
| 886 | - $h+=$this->row_heights[$i]; |
|
| 887 | - } |
|
| 888 | - $this->row_data[$j][5]=$h; |
|
| 889 | - } |
|
| 890 | - } |
|
| 891 | - $block_height=0; |
|
| 892 | - for($j=0; $j<$row_number; $j++){ |
|
| 884 | + $h=0; |
|
| 885 | + for($i=$block[1]; $i<=$block[1]+$block[2]; $i++){ |
|
| 886 | + $h+=$this->row_heights[$i]; |
|
| 887 | + } |
|
| 888 | + $this->row_data[$j][5]=$h; |
|
| 889 | + } |
|
| 890 | + } |
|
| 891 | + $block_height=0; |
|
| 892 | + for($j=0; $j<$row_number; $j++){ |
|
| 893 | 893 | |
| 894 | - $this->row_content_loop($j, function($index)use($j, $block_height){ |
|
| 895 | - if($this->row_data[$index][1]['rowspan']==0){ |
|
| 896 | - $this->row_data[$index][5]=$this->row_heights[$j]; |
|
| 897 | - } |
|
| 898 | - $this->row_data[$index][1]['padding-y']=$this->row_data[$index][1]['paddingY']; |
|
| 899 | - if($this->row_data[$index][1]['valign']=='M' || ($this->row_data[$index][1]['img'] && count($this->row_data[$index][0]))){ |
|
| 900 | - $this->row_data[$index][1]['padding-y']=($this->row_data[$index][5]-$this->row_data[$index][3])/2; |
|
| 901 | - } |
|
| 902 | - elseif($this->row_data[$index][1]['valign']=='B'){ |
|
| 903 | - $this->row_data[$index][1]['padding-y']=$this->row_data[$index][5]-($this->row_data[$index][3]+$this->row_data[$index][1]['paddingY']); |
|
| 904 | - } |
|
| 894 | + $this->row_content_loop($j, function($index)use($j, $block_height){ |
|
| 895 | + if($this->row_data[$index][1]['rowspan']==0){ |
|
| 896 | + $this->row_data[$index][5]=$this->row_heights[$j]; |
|
| 897 | + } |
|
| 898 | + $this->row_data[$index][1]['padding-y']=$this->row_data[$index][1]['paddingY']; |
|
| 899 | + if($this->row_data[$index][1]['valign']=='M' || ($this->row_data[$index][1]['img'] && count($this->row_data[$index][0]))){ |
|
| 900 | + $this->row_data[$index][1]['padding-y']=($this->row_data[$index][5]-$this->row_data[$index][3])/2; |
|
| 901 | + } |
|
| 902 | + elseif($this->row_data[$index][1]['valign']=='B'){ |
|
| 903 | + $this->row_data[$index][1]['padding-y']=$this->row_data[$index][5]-($this->row_data[$index][3]+$this->row_data[$index][1]['paddingY']); |
|
| 904 | + } |
|
| 905 | 905 | }); |
| 906 | 906 | $block_height+=$this->row_heights[$j]; |
| 907 | - } |
|
| 908 | - if($setAsHeader===true){ |
|
| 907 | + } |
|
| 908 | + if($setAsHeader===true){ |
|
| 909 | 909 | if(count($this->header_row)==0){ |
| 910 | - $this->header_row['row_heights']=$this->row_heights; |
|
| 911 | - $this->header_row['row_data']=$this->row_data; |
|
| 912 | - $this->header_row['rows']=$this->rows; |
|
| 910 | + $this->header_row['row_heights']=$this->row_heights; |
|
| 911 | + $this->header_row['row_data']=$this->row_data; |
|
| 912 | + $this->header_row['rows']=$this->rows; |
|
| 913 | + } |
|
| 913 | 914 | } |
| 914 | - } |
|
| 915 | - if($this->table_style['split-row']==false && $this->pdf_obj->PageBreak()<$this->pdf_obj->GetY()+max($block_height,$this->row_heights[0])){ |
|
| 915 | + if($this->table_style['split-row']==false && $this->pdf_obj->PageBreak()<$this->pdf_obj->GetY()+max($block_height,$this->row_heights[0])){ |
|
| 916 | 916 | $this->pdf_obj->addPage($this->document_style['orientation']); |
| 917 | 917 | if(count($this->header_row)>0){ |
| 918 | - $this->printing_loop(true); |
|
| 918 | + $this->printing_loop(true); |
|
| 919 | + } |
|
| 919 | 920 | } |
| 920 | - } |
|
| 921 | 921 | |
| 922 | - if($this->new_table){ |
|
| 922 | + if($this->new_table){ |
|
| 923 | 923 | if(count($this->header_row)>0){ |
| 924 | - $r=$this->pdf_obj->PageBreak()-($this->pdf_obj->GetY()+$block_height); |
|
| 925 | - if($r<0 || $r<self::PBThreshold){ |
|
| 926 | - $this->pdf_obj->addPage($this->document_style['orientation']); |
|
| 927 | - } |
|
| 924 | + $r=$this->pdf_obj->PageBreak()-($this->pdf_obj->GetY()+$block_height); |
|
| 925 | + if($r<0 || $r<self::PBThreshold){ |
|
| 926 | + $this->pdf_obj->addPage($this->document_style['orientation']); |
|
| 927 | + } |
|
| 928 | 928 | } |
| 929 | 929 | $this->new_table=false; |
| 930 | - } |
|
| 931 | - $this->printing_loop(); |
|
| 932 | - $this->grid=array(); |
|
| 933 | - $this->row_data=array(); |
|
| 934 | - $this->rows=array(); |
|
| 935 | - $this->row_heights=array(); |
|
| 936 | - $this->blocks=array(); |
|
| 937 | - $this->overflow=0; |
|
| 938 | - $this->new_table=false; |
|
| 939 | - } |
|
| 940 | - $this->row_style=$this->row_style_def; |
|
| 941 | - } |
|
| 942 | - /*********************************************************************** |
|
| 930 | + } |
|
| 931 | + $this->printing_loop(); |
|
| 932 | + $this->grid=array(); |
|
| 933 | + $this->row_data=array(); |
|
| 934 | + $this->rows=array(); |
|
| 935 | + $this->row_heights=array(); |
|
| 936 | + $this->blocks=array(); |
|
| 937 | + $this->overflow=0; |
|
| 938 | + $this->new_table=false; |
|
| 939 | + } |
|
| 940 | + $this->row_style=$this->row_style_def; |
|
| 941 | + } |
|
| 942 | + /*********************************************************************** |
|
| 943 | 943 | |
| 944 | 944 | function endTable( [int $bottomMargin=2]) |
| 945 | 945 | ------------------------------------------ |
@@ -955,32 +955,32 @@ discard block |
||
| 955 | 955 | Void |
| 956 | 956 | ***********************************************************************/ |
| 957 | 957 | |
| 958 | - public function endTable($bottomMargin=2){ |
|
| 959 | - self::$table_counter=false; |
|
| 960 | - if($this->table_style['border-width']!=false){ |
|
| 961 | - $this->pdf_obj->SetLineWidth($this->document_style['line-width']); |
|
| 962 | - } |
|
| 963 | - $this->pdf_obj->SetX($this->pdf_obj->get_margin('l')); |
|
| 964 | - $this->pdf_obj->Ln($bottomMargin); |
|
| 965 | - $this->pdf_obj->resetStaticData(); |
|
| 966 | - unset($this->pdf_obj); |
|
| 967 | - unset($this->document_style); |
|
| 968 | - unset($this->table_style); |
|
| 969 | - unset($this->col_num); |
|
| 970 | - unset($this->col_width); |
|
| 971 | - unset($this->baseX); |
|
| 972 | - unset($this->row_style_def); |
|
| 973 | - unset($this->row_style); |
|
| 974 | - unset($this->row_heights); |
|
| 975 | - unset($this->row_data); |
|
| 976 | - unset($this->rows); |
|
| 977 | - unset($this->total_rowspan); |
|
| 978 | - unset($this->col_counter); |
|
| 979 | - unset($this->grid); |
|
| 980 | - unset($this->blocks); |
|
| 981 | - unset($this->overflow); |
|
| 982 | - unset($this->header_row); |
|
| 983 | - } |
|
| 958 | + public function endTable($bottomMargin=2){ |
|
| 959 | + self::$table_counter=false; |
|
| 960 | + if($this->table_style['border-width']!=false){ |
|
| 961 | + $this->pdf_obj->SetLineWidth($this->document_style['line-width']); |
|
| 962 | + } |
|
| 963 | + $this->pdf_obj->SetX($this->pdf_obj->get_margin('l')); |
|
| 964 | + $this->pdf_obj->Ln($bottomMargin); |
|
| 965 | + $this->pdf_obj->resetStaticData(); |
|
| 966 | + unset($this->pdf_obj); |
|
| 967 | + unset($this->document_style); |
|
| 968 | + unset($this->table_style); |
|
| 969 | + unset($this->col_num); |
|
| 970 | + unset($this->col_width); |
|
| 971 | + unset($this->baseX); |
|
| 972 | + unset($this->row_style_def); |
|
| 973 | + unset($this->row_style); |
|
| 974 | + unset($this->row_heights); |
|
| 975 | + unset($this->row_data); |
|
| 976 | + unset($this->rows); |
|
| 977 | + unset($this->total_rowspan); |
|
| 978 | + unset($this->col_counter); |
|
| 979 | + unset($this->grid); |
|
| 980 | + unset($this->blocks); |
|
| 981 | + unset($this->overflow); |
|
| 982 | + unset($this->header_row); |
|
| 983 | + } |
|
| 984 | 984 | |
| 985 | 985 | } |
| 986 | 986 | ?> |