widths=$w; } public function SetAligns($a) { //Set the array of column alignments $this->aligns=$a; } function RowAja($data) { //Calculate the height of the row $nb=0; for($i=0;$iNbLines($this->widths[$i],$data[$i])); $h=5*$nb; //Issue a page break first if needed $this->CheckPageBreak($h); //Draw the cells of the row for($i=0;$iwidths[$i]; $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L'; //Save the current position $x=$this->GetX(); $y=$this->GetY(); //Draw the border $this->Rect($x,$y,$w,$h); //Print the text $this->MultiCell($w,5,$data[$i],0,$a); //Put the position to the right of the cell $this->SetXY($x+$w,$y); } //Go to the next line $this->Ln($h); } public function Row($data,$border=0,$fill=0,$draw=0) { //Calculate the height of the row $nb=0; for($i=0;$iNbLines($this->widths[$i],$data[$i])); } $h=5*$nb; //Issue a page break first if needed $this->CheckPageBreak($h); //Draw the cells of the row for($i=0;$iwidths[$i]; $nb1=$this->NbLines($this->widths[$i],$data[$i]); $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L'; // $h1=isset($this->height[$i]) ? $this->height[$i] :5; //Save the current position $x=$this->GetX(); $y=$this->GetY(); //Draw the border $this->Rect($x,$y,$w,$h,$draw); //Print the text $this->MultiCell($w,($h/$nb1),$data[$i],$border,$a,$fill); //Put the position to the right of the cell $this->SetXY($x+$w,$y); } //Go to the next line $this->Ln($h); } public function RowNoBorder($data,$border=0,$fill=0,$draw=0) { //Calculate the height of the row $border=0; $nb=0; for($i=0;$iNbLines($this->widths[$i],$data[$i])); } $h=5*$nb; //Issue a page break first if needed $this->CheckPageBreak($h); //Draw the cells of the row for($i=0;$iwidths[$i]; $nb1=$this->NbLines($this->widths[$i],$data[$i]); $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L'; // $h1=isset($this->height[$i]) ? $this->height[$i] :5; //Save the current position $x=$this->GetX(); $y=$this->GetY(); //Draw the border // $this->Rect($x,$y,$w,$h,$draw); //Print the text $this->MultiCell($w,($h/$nb1),$data[$i],$border,$a,$fill); //Put the position to the right of the cell $this->SetXY($x+$w,$y); } //Go to the next line $this->Ln($h); } public function Rowb($data,$border=0,$fill=0,$draw=0,$besar=10) { //Calculate the height of the row $nb=0; for($i=0;$iNbLines($this->widths[$i],$data[$i])); } $h=$besar*$nb; //Issue a page break first if needed $this->CheckPageBreak($h); //Draw the cells of the row for($i=0;$iwidths[$i]; $nb1=$this->NbLines($this->widths[$i],$data[$i]); $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L'; // $h1=isset($this->height[$i]) ? $this->height[$i] :5; //Save the current position $x=$this->GetX(); $y=$this->GetY(); //Draw the border $this->Rect($x,$y,$w,$h,$draw); //Print the text $this->MultiCell($w,($h/$nb1),$data[$i],$border,$a,$fill); //Put the position to the right of the cell $this->SetXY($x+$w,$y); } //Go to the next line $this->Ln($h); } public function Rowbp($data,$border=0,$fill=0,$draw=0,$besar=10,$padding=0) { //Calculate the height of the row $nb=0; for($i=0;$iNbLines($this->widths[$i]-($padding*2),$data[$i])); } $h=$besar*$nb; //Issue a page break first if needed $this->CheckPageBreak($h); //Draw the cells of the row for($i=0;$iwidths[$i]-($padding*2); $nb1=$this->NbLines($this->widths[$i]-($padding*2),$data[$i]); $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L'; // $h1=isset($this->height[$i]) ? $this->height[$i] :5; //Save the current position $xB=$x=$this->GetX(); $yB=$y=$this->GetY(); //Draw the border if($border) $this->Rect($x,$y,$w+($padding*2),$h+($padding*2),$draw); if($padding > 0) { // $x+=$padding; // $y+=$padding; // $w-=$padding; // $h-=$padding; $this->SetXY($x+$padding,$y+$padding); } //Print the text $this->MultiCell($w,$besar,$data[$i],0,$a,$fill); //Put the position to the right of the cell $this->SetXY($x+$w+($padding*2),$y); } //Go to the next line $this->Ln($h+($padding*2)); } public function CheckPageBreak($h) { //If the height h would cause an overflow, add a new page immediately if($this->GetY()+$h>$this->PageBreakTrigger) $this->AddPage($this->CurOrientation); } public function NbLines($w,$txt) { //Computes the number of lines a MultiCell of width w will take $cw=&$this->CurrentFont['cw']; if($w==0) $w=$this->w-$this->rMargin-$this->x; $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; $s=str_replace("\r",'',$txt); $nb=strlen($s); if($nb>0 and $s[$nb-1]=="\n") $nb--; $sep=-1; $i=0; $j=0; $l=0; $nl=1; while($i<$nb) { $c=$s[$i]; if($c=="\n") { $i++; $sep=-1; $j=$i; $l=0; $nl++; continue; } if($c==' ') $sep=$i; $l+=$cw[$c]; if($l>$wmax) { if($sep==-1) { if($i==$j) $i++; } else $i=$sep+1; $sep=-1; $j=$i; $l=0; $nl++; } else $i++; } return $nl; } public function Header() { } public function Footer() { } public function Rotate($angle,$x=-1,$y=-1) { if($x==-1) $x=$this->x; if($y==-1) $y=$this->y; if($this->angle!=0) $this->_out('Q'); $this->angle=$angle; if($angle!=0) { $angle*=M_PI/180; $c=cos($angle); $s=sin($angle); $cx=$x*$this->k; $cy=($this->h-$y)*$this->k; $this->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy)); } } public function _endpage() { if($this->angle!=0) { $this->angle=0; $this->_out('Q'); } parent::_endpage(); } public function RotatedText($x,$y,$txt,$angle) { //Text rotated around its origin $this->Rotate($angle,$x,$y); $this->Text($x,$y,$txt); $this->Rotate(0); } public function RotatedImage($file,$x,$y,$w,$h,$angle) { //Image rotated around its upper-left corner $this->Rotate($angle,$x,$y); $this->Image($file,$x,$y,$w,$h); $this->Rotate(0); } function SetDash($black=false, $white=false) { if($black and $white) $s=sprintf('[%.3f %.3f] 0 d', $black*$this->k, $white*$this->k); else $s='[] 0 d'; $this->_out($s); } function CustomMultiCell($widthBeforeCell=0, $width, $height, $text, $border=0, $align='L', $fill=0) { if($widthBeforeCell<>0){ $this->cell($widthBeforeCell); } $nb1=$this->NbLines($width,$text); // var_dump($nb1);exit; $this->MultiCell($width,3,$text,$border,$align,$fill); } /** * Function to set permissions as well as user and owner passwords * * - permissions is an array with values taken from the following list: * copy, print, modify, annot-forms * If a value is present it means that the permission is granted * - If a user password is set, user will be prompted before document is opened * - If an owner password is set, document can be opened in privilege mode with no * restriction if that password is entered */ function SetProtection($permissions=array(), $user_pass='', $owner_pass=null) { $options = array('print' => 4, 'modify' => 8, 'copy' => 16, 'annot-forms' => 32 ); $protection = 192; foreach($permissions as $permission) { if (!isset($options[$permission])) $this->Error('Incorrect permission: '.$permission); $protection += $options[$permission]; } if ($owner_pass === null) $owner_pass = uniqid(rand()); $this->encrypted = true; $this->padding = "\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08". "\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A"; $this->_generateencryptionkey($user_pass, $owner_pass, $protection); } function CustomMultiCellResultOnb($widthBeforeCell=0, $width, $height, $text, $border=0, $align='L', $fill=0) { if($widthBeforeCell<>0){ $this->cell($widthBeforeCell); } $this->MultiCell($width,$height,$text,$border,$align,$fill); } /**************************************************************************** * * * Private methods * * * ****************************************************************************/ function _putstream($s) { if ($this->encrypted) { $s = RC4($this->_objectkey($this->n), $s); } parent::_putstream($s); } function _textstring($s) { if ($this->encrypted) { $s = RC4($this->_objectkey($this->n), $s); } return parent::_textstring($s); } /** * Compute key depending on object number where the encrypted data is stored */ function _objectkey($n) { return substr($this->_md5_16($this->encryption_key.pack('VXxx',$n)),0,10); } function _putresources() { parent::_putresources(); if ($this->encrypted) { $this->_newobj(); $this->enc_obj_id = $this->n; $this->_out('<<'); $this->_putencryption(); $this->_out('>>'); $this->_out('endobj'); } } function _putencryption() { $this->_out('/Filter /Standard'); $this->_out('/V 1'); $this->_out('/R 2'); $this->_out('/O ('.$this->_escape($this->Ovalue).')'); $this->_out('/U ('.$this->_escape($this->Uvalue).')'); $this->_out('/P '.$this->Pvalue); } function _puttrailer() { parent::_puttrailer(); if ($this->encrypted) { $this->_out('/Encrypt '.$this->enc_obj_id.' 0 R'); $this->_out('/ID [()()]'); } } /** * Get MD5 as binary string */ function _md5_16($string) { return pack('H*',md5($string)); } /** * Compute O value */ function _Ovalue($user_pass, $owner_pass) { $tmp = $this->_md5_16($owner_pass); $owner_RC4_key = substr($tmp,0,5); return RC4($owner_RC4_key, $user_pass); } /** * Compute U value */ function _Uvalue() { return RC4($this->encryption_key, $this->padding); } /** * Compute encryption key */ function _generateencryptionkey($user_pass, $owner_pass, $protection) { // Pad passwords $user_pass = substr($user_pass.$this->padding,0,32); $owner_pass = substr($owner_pass.$this->padding,0,32); // Compute O value $this->Ovalue = $this->_Ovalue($user_pass,$owner_pass); // Compute encyption key $tmp = $this->_md5_16($user_pass.$this->Ovalue.chr($protection)."\xFF\xFF\xFF"); $this->encryption_key = substr($tmp,0,5); // Compute U value $this->Uvalue = $this->_Uvalue(); // Compute P value $this->Pvalue = -(($protection^255)+1); } function WriteTag($w, $h, $txt, $border=0, $align="J", $fill=false, $padding=0) { $this->wLine=$w; $this->hLine=$h; $this->Text=trim($txt); $this->Text=preg_replace("/\n|\r|\t/","",$this->Text); $this->border=$border; $this->align=$align; $this->fill=$fill; $this->Padding=$padding; $this->Xini=$this->GetX(); $this->href=""; $this->PileStyle=array(); $this->TagHref=array(); $this->LastLine=false; $this->NextLineBegin=array(); $this->SetSpace(); $this->Padding(); $this->LineLength(); $this->BorderTop(); while($this->Text!="") { $this->MakeLine(); $this->PrintLine(); } $this->BorderBottom(); } function SetStyle($tag, $family, $style, $size, $color, $indent=-1) { $tag=trim($tag); $this->TagStyle[$tag]['family']=trim($family); $this->TagStyle[$tag]['style']=trim($style); $this->TagStyle[$tag]['size']=trim($size); $this->TagStyle[$tag]['color']=trim($color); $this->TagStyle[$tag]['indent']=$indent; } // Private Functions function SetSpace() // Minimal space between words { $tag=$this->Parser($this->Text); $this->FindStyle($tag[2],0); $this->DoStyle(0); $this->Space=$this->GetStringWidth(" "); } function Padding() { if(preg_match("/^.+,/",$this->Padding)) { $tab=explode(",",$this->Padding); $this->lPadding=$tab[0]; $this->tPadding=$tab[1]; if(isset($tab[2])) $this->bPadding=$tab[2]; else $this->bPadding=$this->tPadding; if(isset($tab[3])) $this->rPadding=$tab[3]; else $this->rPadding=$this->lPadding; } else { $this->lPadding=$this->Padding; $this->tPadding=$this->Padding; $this->bPadding=$this->Padding; $this->rPadding=$this->Padding; } if($this->tPadding<$this->LineWidth) $this->tPadding=$this->LineWidth; } function LineLength() { if($this->wLine==0) $this->wLine=$this->w - $this->Xini - $this->rMargin; $this->wTextLine = $this->wLine - $this->lPadding - $this->rPadding; } function BorderTop() { $border=0; if($this->border==1) $border="TLR"; else if(!is_numeric($this->border)) { $border = $this->border; if(empty($this->border)) { $border = 0; } else { $border = ''; $border.=strpos($this->border, 'T') !== false ? 'T' : ''; $border.=strpos($this->border, 'L') !== false ? 'L' : ''; $border.=strpos($this->border, 'R') !== false ? 'R' : ''; } } $this->Cell($this->wLine,$this->tPadding,"",$border,0,'C',$this->fill); $y=$this->GetY()+$this->tPadding; $this->SetXY($this->Xini,$y); } function BorderBottom() { $border=0; if($this->border==1) $border="BLR"; else if(!is_numeric($this->border)) { $border = $this->border; if(empty($this->border)) { $border = 0; } else { $border = ''; $border.=strpos($this->border, 'B') !== false ? 'B' : ''; $border.=strpos($this->border, 'L') !== false ? 'L' : ''; $border.=strpos($this->border, 'R') !== false ? 'R' : ''; } } $this->Cell($this->wLine,$this->bPadding,"",$border,0,'C',$this->fill); } function DoStyle($tag) // Applies a style { $tag=trim($tag); $this->SetFont($this->TagStyle[$tag]['family'], $this->TagStyle[$tag]['style'], $this->TagStyle[$tag]['size']); $tab=explode(",",$this->TagStyle[$tag]['color']); if(count($tab)==1) $this->SetTextColor($tab[0]); else $this->SetTextColor($tab[0],$tab[1],$tab[2]); } function FindStyle($tag, $ind) // Inheritance from parent elements { $tag=trim($tag); // Family if($this->TagStyle[$tag]['family']!="") $family=$this->TagStyle[$tag]['family']; else { foreach($this->PileStyle as $val) { $val=trim($val); if($this->TagStyle[$val]['family']!="") { $family=$this->TagStyle[$val]['family']; break; } } } // Style $style=""; $style1=strtoupper($this->TagStyle[$tag]['style']); if($style1!="N") { $bold=false; $italic=false; $underline=false; foreach($this->PileStyle as $val) { $val=trim($val); $style1=strtoupper($this->TagStyle[$val]['style']); if($style1=="N") break; else { if(strpos($style1,"B")!==false) $bold=true; if(strpos($style1,"I")!==false) $italic=true; if(strpos($style1,"U")!==false) $underline=true; } } if($bold) $style.="B"; if($italic) $style.="I"; if($underline) $style.="U"; } // Size if($this->TagStyle[$tag]['size']!=0) $size=$this->TagStyle[$tag]['size']; else { foreach($this->PileStyle as $val) { $val=trim($val); if($this->TagStyle[$val]['size']!=0) { $size=$this->TagStyle[$val]['size']; break; } } } // Color if($this->TagStyle[$tag]['color']!="") $color=$this->TagStyle[$tag]['color']; else { foreach($this->PileStyle as $val) { $val=trim($val); if($this->TagStyle[$val]['color']!="") { $color=$this->TagStyle[$val]['color']; break; } } } // Result $this->TagStyle[$ind]['family']=$family; $this->TagStyle[$ind]['style']=$style; $this->TagStyle[$ind]['size']=$size; $this->TagStyle[$ind]['color']=$color; $this->TagStyle[$ind]['indent']=$this->TagStyle[$tag]['indent']; } function Parser($text) { $tab=array(); // Closing tag if(preg_match("|^(]+)>)|",$text,$regs)) { $tab[1]="c"; $tab[2]=trim($regs[2]); } // Opening tag else if(preg_match("|^(<([^>]+)>)|",$text,$regs)) { $regs[2]=preg_replace("/^a/","a ",$regs[2]); $tab[1]="o"; $tab[2]=trim($regs[2]); // Presence of attributes if(preg_match("/(.+) (.+)='(.+)'/",$regs[2])) { $tab1=preg_split("/ +/",$regs[2]); $tab[2]=trim($tab1[0]); foreach($tab1 as $i=>$couple) { if($i>0) { $tab2=explode("=",$couple); $tab2[0]=trim($tab2[0]); $tab2[1]=trim($tab2[1]); $end=strlen($tab2[1])-2; $tab[$tab2[0]]=substr($tab2[1],1,$end); } } } } // Space else if(preg_match("/^( )/",$text,$regs)) { $tab[1]="s"; $tab[2]=' '; } // Text else if(preg_match("/^([^< ]+)/",$text,$regs)) { $tab[1]="t"; $tab[2]=trim($regs[1]); } $begin=strlen($regs[1]); $end=strlen($text); $text=substr($text, $begin, $end); $tab[0]=$text; return $tab; } function MakeLine() { $this->Text.=" "; $this->LineLength=array(); $this->TagHref=array(); $Length=0; $this->nbSpace=0; $i=$this->BeginLine(); $this->TagName=array(); if($i==0) { $Length=$this->StringLength[0]; $this->TagName[0]=1; $this->TagHref[0]=$this->href; } while($Length<$this->wTextLine) { $tab=$this->Parser($this->Text); $this->Text=$tab[0]; if($this->Text=="") { $this->LastLine=true; break; } if($tab[1]=="o") { array_unshift($this->PileStyle,$tab[2]); $this->FindStyle($this->PileStyle[0],$i+1); $this->DoStyle($i+1); $this->TagName[$i+1]=1; if($this->TagStyle[$tab[2]]['indent']!=-1) { $Length+=$this->TagStyle[$tab[2]]['indent']; $this->Indent=$this->TagStyle[$tab[2]]['indent']; } if($tab[2]=="a") $this->href=$tab['href']; } if($tab[1]=="c") { array_shift($this->PileStyle); if(isset($this->PileStyle[0])) { $this->FindStyle($this->PileStyle[0],$i+1); $this->DoStyle($i+1); } $this->TagName[$i+1]=1; if($this->TagStyle[$tab[2]]['indent']!=-1) { $this->LastLine=true; $this->Text=trim($this->Text); break; } if($tab[2]=="a") $this->href=""; } if($tab[1]=="s") { $i++; $Length+=$this->Space; $this->Line2Print[$i]=""; if($this->href!="") $this->TagHref[$i]=$this->href; } if($tab[1]=="t") { $i++; $this->StringLength[$i]=$this->GetStringWidth($tab[2]); $Length+=$this->StringLength[$i]; $this->LineLength[$i]=$Length; $this->Line2Print[$i]=$tab[2]; if($this->href!="") $this->TagHref[$i]=$this->href; } } trim($this->Text); if($Length>$this->wTextLine || $this->LastLine==true) $this->EndLine(); } function BeginLine() { $this->Line2Print=array(); $this->StringLength=array(); if(isset($this->PileStyle[0])) { $this->FindStyle($this->PileStyle[0],0); $this->DoStyle(0); } if(count($this->NextLineBegin)>0) { $this->Line2Print[0]=$this->NextLineBegin['text']; $this->StringLength[0]=$this->NextLineBegin['length']; $this->NextLineBegin=array(); $i=0; } else { preg_match("/^(( *(<([^>]+)>)* *)*)(.*)/",$this->Text,$regs); $regs[1]=str_replace(" ", "", $regs[1]); $this->Text=$regs[1].$regs[5]; $i=-1; } return $i; } function EndLine() { if(end($this->Line2Print)!="" && $this->LastLine==false) { $this->NextLineBegin['text']=array_pop($this->Line2Print); $this->NextLineBegin['length']=end($this->StringLength); array_pop($this->LineLength); } while(end($this->Line2Print)==="") array_pop($this->Line2Print); $this->Delta=$this->wTextLine-end($this->LineLength); $this->nbSpace=0; for($i=0; $iLine2Print); $i++) { if($this->Line2Print[$i]=="") $this->nbSpace++; } } function PrintLine() { $border=0; if($this->border==1) $border="LR"; else if(!is_numeric($this->border)) { $border = $this->border; if(empty($this->border)) { $border = 0; } else { $border = ''; $border.=strpos($this->border, 'L') !== false ? 'L' : ''; $border.=strpos($this->border, 'R') !== false ? 'R' : ''; } } $this->Cell($this->wLine,$this->hLine,"",$border,0,'C',$this->fill); $y=$this->GetY(); $this->SetXY($this->Xini+$this->lPadding,$y); if($this->Indent!=-1) { if($this->Indent!=0) $this->Cell($this->Indent,$this->hLine); $this->Indent=-1; } $space=$this->LineAlign(); $this->DoStyle(0); for($i=0; $iLine2Print); $i++) { if(isset($this->TagName[$i])) $this->DoStyle($i); if(isset($this->TagHref[$i])) $href=$this->TagHref[$i]; else $href=''; if($this->Line2Print[$i]=="") $this->Cell($space,$this->hLine," ",0,0,'C',false,$href); else $this->Cell($this->StringLength[$i],$this->hLine,$this->Line2Print[$i],0,0,'C',false,$href); } $this->LineBreak(); if($this->LastLine && $this->Text!="") $this->EndParagraph(); $this->LastLine=false; } function LineAlign() { $space=$this->Space; if($this->align=="J") { if($this->nbSpace!=0) $space=$this->Space + ($this->Delta/$this->nbSpace); if($this->LastLine) $space=$this->Space; } if($this->align=="R") $this->Cell($this->Delta,$this->hLine); if($this->align=="C") $this->Cell($this->Delta/2,$this->hLine); return $space; } function LineBreak() { $x=$this->Xini; $y=$this->GetY()+$this->hLine; $this->SetXY($x,$y); } function EndParagraph() { $border=0; if($this->border==1) $border="LR"; $this->Cell($this->wLine,$this->hLine/2,"",$border,0,'C',$this->fill); $x=$this->Xini; $y=$this->GetY()+$this->hLine/2; $this->SetXY($x,$y); } //Cell with horizontal scaling if text is too wide function CellFit($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $scale=false, $force=true) { //Get string width $str_width=$this->GetStringWidth($txt); //Calculate ratio to fit cell if($w==0) $w = $this->w-$this->rMargin-$this->x; $ratio = ($w-$this->cMargin*2)/$str_width; $fit = ($ratio < 1 || ($ratio > 1 && $force)); if ($fit) { if ($scale) { //Calculate horizontal scaling $horiz_scale=$ratio*100.0; //Set horizontal scaling $this->_out(sprintf('BT %.2F Tz ET',$horiz_scale)); } else { //Calculate character spacing in points $char_space=($w-$this->cMargin*2-$str_width)/max(strlen($txt)-1,1)*$this->k; //Set character spacing $this->_out(sprintf('BT %.2F Tc ET',$char_space)); } //Override user alignment (since text will fill up cell) $align=''; } //Pass on to Cell method $this->Cell($w,$h,$txt,$border,$ln,$align,$fill,$link); //Reset character spacing/horizontal scaling if ($fit) $this->_out('BT '.($scale ? '100 Tz' : '0 Tc').' ET'); } //Cell with character spacing only if necessary function CellFitSpace($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') { $this->CellFit($w,$h,$txt,$border,$ln,$align,$fill,$link,false,false); } public function RowForDownloadAttendance($data,$border=0,$fill=0,$draw=0) { //Calculate the height of the row $nb=0; for($i=0;$iNbLines($this->widths[$i],$data[$i])); } $h=4*$nb; //Issue a page break first if needed $this->CheckPageBreak($h); //Draw the cells of the row for($i=0;$iwidths[$i]; $nb1=$this->NbLines($this->widths[$i],$data[$i]); $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L'; //Save the current position $x=$this->GetX(); $y=$this->GetY(); //Draw the border $this->Rect($x,$y,$w,$h,$draw); $this->SetTextColor(0, 0, 0); $tempNote = explode(' ',$data[$i]); if($data[$i]=='Missing'|| $data[$i]=='Missing Finger In' || $data[$i]=='AWN' || $data[$i]=='Late In' || $data[$i]=='time in not in range shift !!' || $data[$i]=='Missing Finger Out' || $data[$i]=='Early Out' || $data[$i]=='Late In Early Out' || $tempNote[0]=='Undisciplined'){ // $this->SetTextColor(81, 156, 132); $this->SetTextColor(255, 48, 33); } if($i==3&& $data[9]=='Late In'){ $this->SetTextColor(255, 48, 33); } if($i==6&& $data[9]=='Early Out'){ $this->SetTextColor(255, 48, 33); } if(($i==3||$i==6)&& $data[9]=='Late In Early Out'){ $this->SetTextColor(255, 48, 33); } //Print the text $this->MultiCell($w,($h/$nb1),$data[$i],$border,$a,$fill); //Put the position to the right of the cell $this->SetXY($x+$w,$y); } //Go to the next line $this->Ln($h); } function drawTextBox($strText, $w, $h, $align='L', $valign='T', $border=true, $withLine = false) { $xi=$this->GetX(); $yi=$this->GetY(); $hrow=$this->FontSize; $textrows=$this->drawRows($w,$hrow,$strText,0,$align,0,0,0); $maxrows=floor($h/$this->FontSize); $rows=min($textrows,$maxrows); $dy=0; if (strtoupper($valign)=='M') $dy=($h-$rows*$this->FontSize)/2; if (strtoupper($valign)=='B') $dy=$h-$rows*$this->FontSize; $this->SetY($yi+$dy); $this->SetX($xi); $this->drawRows($w,$hrow,$strText,0,$align,false,$rows,1); if ($border) $this->Rect($xi,$yi,$w,$h); } function drawRows($w, $h, $txt, $border=0, $align='J', $fill=false, $maxline=0, $prn=0) { if(!isset($this->CurrentFont)) $this->Error('No font has been set'); $cw=$this->CurrentFont['cw']; if($w==0) $w=$this->w-$this->rMargin-$this->x; $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; $s=str_replace("\r",'',(string)$txt); $nb=strlen($s); if($nb>0 && $s[$nb-1]=="\n") $nb--; $b=0; if($border) { if($border==1) { $border='LTRB'; $b='LRT'; $b2='LR'; } else { $b2=''; if(is_int(strpos($border,'L'))) $b2.='L'; if(is_int(strpos($border,'R'))) $b2.='R'; $b=is_int(strpos($border,'T')) ? $b2.'T' : $b2; } } $sep=-1; $i=0; $j=0; $l=0; $ns=0; $nl=1; while($i<$nb) { //Get next character $c=$s[$i]; if($c=="\n") { //Explicit line break if($this->ws>0) { $this->ws=0; if ($prn==1) $this->_out('0 Tw'); } if ($prn==1) { $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); } $i++; $sep=-1; $j=$i; $l=0; $ns=0; $nl++; if($border && $nl==2) $b=$b2; if ( $maxline && $nl > $maxline ) return substr($s,$i); continue; } if($c==' ') { $sep=$i; $ls=$l; $ns++; } $l+=$cw[$c]; if($l>$wmax) { //Automatic line break if($sep==-1) { if($i==$j) $i++; if($this->ws>0) { $this->ws=0; if ($prn==1) $this->_out('0 Tw'); } if ($prn==1) { $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); } } else { if($align=='J') { $this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; if ($prn==1) $this->_out(sprintf('%.3F Tw',$this->ws*$this->k)); } if ($prn==1){ $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill); } $i=$sep+1; } $sep=-1; $j=$i; $l=0; $ns=0; $nl++; if($border && $nl==2) $b=$b2; if ( $maxline && $nl > $maxline ) return substr($s,$i); } else $i++; } //Last chunk if($this->ws>0) { $this->ws=0; if ($prn==1) $this->_out('0 Tw'); } if($border && is_int(strpos($border,'B'))) $b.='B'; if ($prn==1) { $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); } $this->x=$this->lMargin; return $nl; } } // if(function_exists('mcrypt_encrypt')) // { // function RC4($key, $data) // { // return mcrypt_encrypt(MCRYPT_ARCFOUR, $key, $data, MCRYPT_MODE_STREAM, ''); // } // } // else // { function RC4($key, $data) { static $last_key, $last_state; if($key != $last_key) { $k = str_repeat($key, 256/strlen($key)+1); $state = range(0, 255); $j = 0; for ($i=0; $i<256; $i++){ $t = $state[$i]; $j = ($j + $t + ord($k[$i])) % 256; $state[$i] = $state[$j]; $state[$j] = $t; } $last_key = $key; $last_state = $state; } else $state = $last_state; $len = strlen($data); $a = 0; $b = 0; $out = ''; for ($i=0; $i<$len; $i++){ $a = ($a+1) % 256; $t = $state[$a]; $b = ($b+$t) % 256; $state[$a] = $state[$b]; $state[$b] = $t; $k = $state[($state[$a]+$state[$b]) % 256]; $out .= chr(ord($data[$i]) ^ $k); } return $out; } // }