@@ -1010,6 +1010,9 @@ |
||
1010 | 1010 | return $this->x; |
1011 | 1011 | } |
1012 | 1012 | |
1013 | +/** |
|
1014 | + * @param integer $x |
|
1015 | + */ |
|
1013 | 1016 | function SetX($x) |
1014 | 1017 | { |
1015 | 1018 | // Set x position |
@@ -77,14 +77,14 @@ discard block |
||
77 | 77 | *******************************************************************************/ |
78 | 78 | function FPDF($props = array()) |
79 | 79 | { |
80 | - if(count($props) == 3) |
|
80 | + if (count($props) == 3) |
|
81 | 81 | { |
82 | - list($orientation,$unit,$format) = $props; |
|
83 | - $this->initialize($orientation,$unit,$format); |
|
82 | + list($orientation, $unit, $format) = $props; |
|
83 | + $this->initialize($orientation, $unit, $format); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | -function initialize($orientation='P',$unit='mm',$size='A4') |
|
87 | +function initialize($orientation = 'P', $unit = 'mm', $size = 'A4') |
|
88 | 88 | { |
89 | 89 | // Some checks |
90 | 90 | $this->_dochecks(); |
@@ -182,12 +182,12 @@ discard block |
||
182 | 182 | * @param double $left |
183 | 183 | * @param double $top |
184 | 184 | */ |
185 | -function SetMargins($left, $top, $right=null) |
|
185 | +function SetMargins($left, $top, $right = null) |
|
186 | 186 | { |
187 | 187 | // Set left, top and right margins |
188 | 188 | $this->lMargin = $left; |
189 | 189 | $this->tMargin = $top; |
190 | - if($right===null) { |
|
190 | + if ($right === null) { |
|
191 | 191 | $right = $left; |
192 | 192 | } |
193 | 193 | $this->rMargin = $right; |
@@ -216,25 +216,25 @@ discard block |
||
216 | 216 | /** |
217 | 217 | * @param boolean $auto |
218 | 218 | */ |
219 | -function SetAutoPageBreak($auto, $margin=0) |
|
219 | +function SetAutoPageBreak($auto, $margin = 0) |
|
220 | 220 | { |
221 | 221 | // Set auto page break mode and triggering margin |
222 | 222 | $this->AutoPageBreak = $auto; |
223 | 223 | $this->bMargin = $margin; |
224 | - $this->PageBreakTrigger = $this->h-$margin; |
|
224 | + $this->PageBreakTrigger = $this->h - $margin; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
228 | 228 | * @param string $zoom |
229 | 229 | */ |
230 | -function SetDisplayMode($zoom, $layout='default') |
|
230 | +function SetDisplayMode($zoom, $layout = 'default') |
|
231 | 231 | { |
232 | 232 | // Set display mode in viewer |
233 | - if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) |
|
233 | + if ($zoom == 'fullpage' || $zoom == 'fullwidth' || $zoom == 'real' || $zoom == 'default' || ! is_string($zoom)) |
|
234 | 234 | $this->ZoomMode = $zoom; |
235 | 235 | else |
236 | 236 | $this->Error('Incorrect zoom display mode: '.$zoom); |
237 | - if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') |
|
237 | + if ($layout == 'single' || $layout == 'continuous' || $layout == 'two' || $layout == 'default') |
|
238 | 238 | $this->LayoutMode = $layout; |
239 | 239 | else |
240 | 240 | $this->Error('Incorrect layout display mode: '.$layout); |
@@ -412,14 +412,14 @@ discard block |
||
412 | 412 | return $this->page; |
413 | 413 | } |
414 | 414 | |
415 | -function SetDrawColor($r, $g=null, $b=null) |
|
415 | +function SetDrawColor($r, $g = null, $b = null) |
|
416 | 416 | { |
417 | 417 | // Set color for all stroking operations |
418 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
419 | - $this->DrawColor = sprintf('%.3F G',$r/255); |
|
418 | + if (($r == 0 && $g == 0 && $b == 0) || $g === null) |
|
419 | + $this->DrawColor = sprintf('%.3F G', $r / 255); |
|
420 | 420 | else |
421 | - $this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); |
|
422 | - if($this->page>0) |
|
421 | + $this->DrawColor = sprintf('%.3F %.3F %.3F RG', $r / 255, $g / 255, $b / 255); |
|
422 | + if ($this->page > 0) |
|
423 | 423 | $this->_out($this->DrawColor); |
424 | 424 | } |
425 | 425 | |
@@ -428,26 +428,26 @@ discard block |
||
428 | 428 | * @param integer $g |
429 | 429 | * @param integer $b |
430 | 430 | */ |
431 | -function SetFillColor($r, $g=null, $b=null) |
|
431 | +function SetFillColor($r, $g = null, $b = null) |
|
432 | 432 | { |
433 | 433 | // Set color for all filling operations |
434 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
435 | - $this->FillColor = sprintf('%.3F g',$r/255); |
|
434 | + if (($r == 0 && $g == 0 && $b == 0) || $g === null) |
|
435 | + $this->FillColor = sprintf('%.3F g', $r / 255); |
|
436 | 436 | else |
437 | - $this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
438 | - $this->ColorFlag = ($this->FillColor!=$this->TextColor); |
|
439 | - if($this->page>0) |
|
437 | + $this->FillColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255); |
|
438 | + $this->ColorFlag = ($this->FillColor != $this->TextColor); |
|
439 | + if ($this->page > 0) |
|
440 | 440 | $this->_out($this->FillColor); |
441 | 441 | } |
442 | 442 | |
443 | -function SetTextColor($r, $g=null, $b=null) |
|
443 | +function SetTextColor($r, $g = null, $b = null) |
|
444 | 444 | { |
445 | 445 | // Set color for text |
446 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
447 | - $this->TextColor = sprintf('%.3F g',$r/255); |
|
446 | + if (($r == 0 && $g == 0 && $b == 0) || $g === null) |
|
447 | + $this->TextColor = sprintf('%.3F g', $r / 255); |
|
448 | 448 | else |
449 | - $this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
450 | - $this->ColorFlag = ($this->FillColor!=$this->TextColor); |
|
449 | + $this->TextColor = sprintf('%.3F %.3F %.3F rg', $r / 255, $g / 255, $b / 255); |
|
450 | + $this->ColorFlag = ($this->FillColor != $this->TextColor); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | function GetStringWidth($s) |
@@ -457,18 +457,18 @@ discard block |
||
457 | 457 | $cw = &$this->CurrentFont['cw']; |
458 | 458 | $w = 0; |
459 | 459 | $l = strlen($s); |
460 | - for($i=0;$i<$l;$i++) { |
|
460 | + for ($i = 0; $i < $l; $i++) { |
|
461 | 461 | $w += $cw[$s[$i]]; |
462 | 462 | } |
463 | - return $w*$this->FontSize/1000; |
|
463 | + return $w * $this->FontSize / 1000; |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | function SetLineWidth($width) |
467 | 467 | { |
468 | 468 | // Set line width |
469 | 469 | $this->LineWidth = $width; |
470 | - if($this->page>0) { |
|
471 | - $this->_out(sprintf('%.2F w',$width*$this->k)); |
|
470 | + if ($this->page > 0) { |
|
471 | + $this->_out(sprintf('%.2F w', $width * $this->k)); |
|
472 | 472 | } |
473 | 473 | } |
474 | 474 | |
@@ -479,57 +479,57 @@ discard block |
||
479 | 479 | function Line($x1, $y1, $x2, $y2) |
480 | 480 | { |
481 | 481 | // Draw a line |
482 | - $this->_out(sprintf('%.2F %.2F m %.2F %.2F l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k)); |
|
482 | + $this->_out(sprintf('%.2F %.2F m %.2F %.2F l S', $x1 * $this->k, ($this->h - $y1) * $this->k, $x2 * $this->k, ($this->h - $y2) * $this->k)); |
|
483 | 483 | } |
484 | 484 | |
485 | -function Rect($x, $y, $w, $h, $style='') |
|
485 | +function Rect($x, $y, $w, $h, $style = '') |
|
486 | 486 | { |
487 | 487 | // Draw a rectangle |
488 | - if($style=='F') { |
|
488 | + if ($style == 'F') { |
|
489 | 489 | $op = 'f'; |
490 | - } elseif($style=='FD' || $style=='DF') { |
|
490 | + } elseif ($style == 'FD' || $style == 'DF') { |
|
491 | 491 | $op = 'B'; |
492 | 492 | } else { |
493 | 493 | $op = 'S'; |
494 | 494 | } |
495 | - $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); |
|
495 | + $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s', $x * $this->k, ($this->h - $y) * $this->k, $w * $this->k, -$h * $this->k, $op)); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
499 | 499 | * @param string $family |
500 | 500 | */ |
501 | -function AddFont($family, $style='', $file='') |
|
501 | +function AddFont($family, $style = '', $file = '') |
|
502 | 502 | { |
503 | 503 | // Add a TrueType, OpenType or Type1 font |
504 | 504 | $family = strtolower($family); |
505 | - if($file=='') { |
|
506 | - $file = str_replace(' ','',$family).strtolower($style).'.php'; |
|
505 | + if ($file == '') { |
|
506 | + $file = str_replace(' ', '', $family).strtolower($style).'.php'; |
|
507 | 507 | } |
508 | 508 | $style = strtoupper($style); |
509 | - if($style=='IB') { |
|
509 | + if ($style == 'IB') { |
|
510 | 510 | $style = 'BI'; |
511 | 511 | } |
512 | 512 | $fontkey = $family.$style; |
513 | - if(isset($this->fonts[$fontkey])) { |
|
513 | + if (isset($this->fonts[$fontkey])) { |
|
514 | 514 | return; |
515 | 515 | } |
516 | 516 | $info = $this->_loadfont($file); |
517 | - $info['i'] = count($this->fonts)+1; |
|
518 | - if(!empty($info['diff'])) |
|
517 | + $info['i'] = count($this->fonts) + 1; |
|
518 | + if ( ! empty($info['diff'])) |
|
519 | 519 | { |
520 | 520 | // Search existing encodings |
521 | - $n = array_search($info['diff'],$this->diffs); |
|
522 | - if(!$n) |
|
521 | + $n = array_search($info['diff'], $this->diffs); |
|
522 | + if ( ! $n) |
|
523 | 523 | { |
524 | - $n = count($this->diffs)+1; |
|
524 | + $n = count($this->diffs) + 1; |
|
525 | 525 | $this->diffs[$n] = $info['diff']; |
526 | 526 | } |
527 | 527 | $info['diffn'] = $n; |
528 | 528 | } |
529 | - if(!empty($info['file'])) |
|
529 | + if ( ! empty($info['file'])) |
|
530 | 530 | { |
531 | 531 | // Embedded font |
532 | - if($info['type']=='TrueType') { |
|
532 | + if ($info['type'] == 'TrueType') { |
|
533 | 533 | $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']); |
534 | 534 | } else { |
535 | 535 | $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']); |
@@ -541,48 +541,48 @@ discard block |
||
541 | 541 | /** |
542 | 542 | * @param string $family |
543 | 543 | */ |
544 | -function SetFont($family, $style='', $size=0) |
|
544 | +function SetFont($family, $style = '', $size = 0) |
|
545 | 545 | { |
546 | 546 | // Select a font; size given in points |
547 | - if($family=='') { |
|
547 | + if ($family == '') { |
|
548 | 548 | $family = $this->FontFamily; |
549 | 549 | } else { |
550 | 550 | $family = strtolower($family); |
551 | 551 | } |
552 | 552 | $style = strtoupper($style); |
553 | - if(strpos($style,'U')!==false) |
|
553 | + if (strpos($style, 'U') !== false) |
|
554 | 554 | { |
555 | 555 | $this->underline = true; |
556 | - $style = str_replace('U','',$style); |
|
556 | + $style = str_replace('U', '', $style); |
|
557 | 557 | } else { |
558 | 558 | $this->underline = false; |
559 | 559 | } |
560 | - if($style=='IB') { |
|
560 | + if ($style == 'IB') { |
|
561 | 561 | $style = 'BI'; |
562 | 562 | } |
563 | - if($size==0) { |
|
563 | + if ($size == 0) { |
|
564 | 564 | $size = $this->FontSizePt; |
565 | 565 | } |
566 | 566 | // Test if font is already selected |
567 | - if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) { |
|
567 | + if ($this->FontFamily == $family && $this->FontStyle == $style && $this->FontSizePt == $size) { |
|
568 | 568 | return; |
569 | 569 | } |
570 | 570 | // Test if font is already loaded |
571 | 571 | $fontkey = $family.$style; |
572 | - if(!isset($this->fonts[$fontkey])) |
|
572 | + if ( ! isset($this->fonts[$fontkey])) |
|
573 | 573 | { |
574 | 574 | // Test if one of the core fonts |
575 | - if($family=='arial') { |
|
575 | + if ($family == 'arial') { |
|
576 | 576 | $family = 'helvetica'; |
577 | 577 | } |
578 | - if(in_array($family,$this->CoreFonts)) |
|
578 | + if (in_array($family, $this->CoreFonts)) |
|
579 | 579 | { |
580 | - if($family=='symbol' || $family=='zapfdingbats') { |
|
580 | + if ($family == 'symbol' || $family == 'zapfdingbats') { |
|
581 | 581 | $style = ''; |
582 | 582 | } |
583 | 583 | $fontkey = $family.$style; |
584 | - if(!isset($this->fonts[$fontkey])) { |
|
585 | - $this->AddFont($family,$style); |
|
584 | + if ( ! isset($this->fonts[$fontkey])) { |
|
585 | + $this->AddFont($family, $style); |
|
586 | 586 | } |
587 | 587 | } else { |
588 | 588 | $this->Error('Undefined font: '.$family.' '.$style); |
@@ -654,79 +654,79 @@ discard block |
||
654 | 654 | return $this->AutoPageBreak; |
655 | 655 | } |
656 | 656 | |
657 | -function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') |
|
657 | +function Cell($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '') |
|
658 | 658 | { |
659 | 659 | // Output a cell |
660 | 660 | $k = $this->k; |
661 | - if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) |
|
661 | + if ($this->y + $h > $this->PageBreakTrigger && ! $this->InHeader && ! $this->InFooter && $this->AcceptPageBreak()) |
|
662 | 662 | { |
663 | 663 | // Automatic page break |
664 | 664 | $x = $this->x; |
665 | 665 | $ws = $this->ws; |
666 | - if($ws>0) |
|
666 | + if ($ws > 0) |
|
667 | 667 | { |
668 | 668 | $this->ws = 0; |
669 | 669 | $this->_out('0 Tw'); |
670 | 670 | } |
671 | - $this->AddPage($this->CurOrientation,$this->CurPageSize); |
|
671 | + $this->AddPage($this->CurOrientation, $this->CurPageSize); |
|
672 | 672 | $this->x = $x; |
673 | - if($ws>0) |
|
673 | + if ($ws > 0) |
|
674 | 674 | { |
675 | 675 | $this->ws = $ws; |
676 | - $this->_out(sprintf('%.3F Tw',$ws*$k)); |
|
676 | + $this->_out(sprintf('%.3F Tw', $ws * $k)); |
|
677 | 677 | } |
678 | 678 | } |
679 | - if($w==0) |
|
680 | - $w = $this->w-$this->rMargin-$this->x; |
|
679 | + if ($w == 0) |
|
680 | + $w = $this->w - $this->rMargin - $this->x; |
|
681 | 681 | $s = ''; |
682 | - if($fill || $border==1) |
|
682 | + if ($fill || $border == 1) |
|
683 | 683 | { |
684 | - if($fill) |
|
685 | - $op = ($border==1) ? 'B' : 'f'; |
|
684 | + if ($fill) |
|
685 | + $op = ($border == 1) ? 'B' : 'f'; |
|
686 | 686 | else |
687 | 687 | $op = 'S'; |
688 | - $s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); |
|
688 | + $s = sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op); |
|
689 | 689 | } |
690 | - if(is_string($border)) |
|
690 | + if (is_string($border)) |
|
691 | 691 | { |
692 | 692 | $x = $this->x; |
693 | 693 | $y = $this->y; |
694 | - if(strpos($border,'L')!==false) |
|
695 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); |
|
696 | - if(strpos($border,'T')!==false) |
|
697 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); |
|
698 | - if(strpos($border,'R')!==false) |
|
699 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
700 | - if(strpos($border,'B')!==false) |
|
701 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
694 | + if (strpos($border, 'L') !== false) |
|
695 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, $x * $k, ($this->h - ($y + $h)) * $k); |
|
696 | + if (strpos($border, 'T') !== false) |
|
697 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - $y) * $k); |
|
698 | + if (strpos($border, 'R') !== false) |
|
699 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', ($x + $w) * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k); |
|
700 | + if (strpos($border, 'B') !== false) |
|
701 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - ($y + $h)) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k); |
|
702 | 702 | } |
703 | - if($txt!=='') |
|
703 | + if ($txt !== '') |
|
704 | 704 | { |
705 | - if($align=='R') |
|
706 | - $dx = $w-$this->cMargin-$this->GetStringWidth($txt); |
|
707 | - elseif($align=='C') |
|
708 | - $dx = ($w-$this->GetStringWidth($txt))/2; |
|
705 | + if ($align == 'R') |
|
706 | + $dx = $w - $this->cMargin - $this->GetStringWidth($txt); |
|
707 | + elseif ($align == 'C') |
|
708 | + $dx = ($w - $this->GetStringWidth($txt)) / 2; |
|
709 | 709 | else |
710 | 710 | $dx = $this->cMargin; |
711 | - if($this->ColorFlag) |
|
711 | + if ($this->ColorFlag) |
|
712 | 712 | $s .= 'q '.$this->TextColor.' '; |
713 | - $txt2 = str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt))); |
|
714 | - $s .= sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2); |
|
715 | - if($this->underline) |
|
716 | - $s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
717 | - if($this->ColorFlag) |
|
713 | + $txt2 = str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt))); |
|
714 | + $s .= sprintf('BT %.2F %.2F Td (%s) Tj ET', ($this->x + $dx) * $k, ($this->h - ($this->y + .5 * $h + .3 * $this->FontSize)) * $k, $txt2); |
|
715 | + if ($this->underline) |
|
716 | + $s .= ' '.$this->_dounderline($this->x + $dx, $this->y + .5 * $h + .3 * $this->FontSize, $txt); |
|
717 | + if ($this->ColorFlag) |
|
718 | 718 | $s .= ' Q'; |
719 | - if($link) |
|
720 | - $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); |
|
719 | + if ($link) |
|
720 | + $this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $this->GetStringWidth($txt), $this->FontSize, $link); |
|
721 | 721 | } |
722 | - if($s) |
|
722 | + if ($s) |
|
723 | 723 | $this->_out($s); |
724 | 724 | $this->lasth = $h; |
725 | - if($ln>0) |
|
725 | + if ($ln > 0) |
|
726 | 726 | { |
727 | 727 | // Go to next line |
728 | 728 | $this->y += $h; |
729 | - if($ln==1) |
|
729 | + if ($ln == 1) |
|
730 | 730 | $this->x = $this->lMargin; |
731 | 731 | } |
732 | 732 | else |
@@ -737,21 +737,21 @@ discard block |
||
737 | 737 | * @param integer $w |
738 | 738 | * @param integer $h |
739 | 739 | */ |
740 | -function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false) |
|
740 | +function MultiCell($w, $h, $txt, $border = 0, $align = 'J', $fill = false) |
|
741 | 741 | { |
742 | 742 | // Output text with automatic or explicit line breaks |
743 | 743 | $cw = &$this->CurrentFont['cw']; |
744 | - if($w==0) |
|
745 | - $w = $this->w-$this->rMargin-$this->x; |
|
746 | - $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
|
747 | - $s = str_replace("\r",'',$txt); |
|
744 | + if ($w == 0) |
|
745 | + $w = $this->w - $this->rMargin - $this->x; |
|
746 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
747 | + $s = str_replace("\r", '', $txt); |
|
748 | 748 | $nb = strlen($s); |
749 | - if($nb>0 && $s[$nb-1]=="\n") |
|
749 | + if ($nb > 0 && $s[$nb - 1] == "\n") |
|
750 | 750 | $nb--; |
751 | 751 | $b = 0; |
752 | - if($border) |
|
752 | + if ($border) |
|
753 | 753 | { |
754 | - if($border==1) |
|
754 | + if ($border == 1) |
|
755 | 755 | { |
756 | 756 | $border = 'LTRB'; |
757 | 757 | $b = 'LRT'; |
@@ -116,26 +116,28 @@ discard block |
||
116 | 116 | if (defined('FPDF_FONTPATH')) |
117 | 117 | { |
118 | 118 | $this->fontpath = FPDF_FONTPATH; |
119 | - if (substr($this->fontpath, -1) != '/' && substr($this->fontpath, -1) != '\\') |
|
120 | - $this->fontpath .= '/'; |
|
121 | - } |
|
122 | - elseif (is_dir(dirname(__FILE__).'/font')) |
|
123 | - $this->fontpath = dirname(__FILE__).'/font/'; |
|
124 | - else |
|
125 | - $this->fontpath = ''; |
|
119 | + if (substr($this->fontpath, -1) != '/' && substr($this->fontpath, -1) != '\\') { |
|
120 | + $this->fontpath .= '/'; |
|
121 | + } |
|
122 | + } elseif (is_dir(dirname(__FILE__).'/font')) { |
|
123 | + $this->fontpath = dirname(__FILE__).'/font/'; |
|
124 | + } else { |
|
125 | + $this->fontpath = ''; |
|
126 | + } |
|
126 | 127 | // Core fonts |
127 | 128 | $this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats'); |
128 | 129 | // Scale factor |
129 | - if ($unit == 'pt') |
|
130 | - $this->k = 1; |
|
131 | - elseif ($unit == 'mm') |
|
132 | - $this->k = 72 / 25.4; |
|
133 | - elseif ($unit == 'cm') |
|
134 | - $this->k = 72 / 2.54; |
|
135 | - elseif ($unit == 'in') |
|
136 | - $this->k = 72; |
|
137 | - else |
|
138 | - $this->Error('Incorrect unit: '.$unit); |
|
130 | + if ($unit == 'pt') { |
|
131 | + $this->k = 1; |
|
132 | + } elseif ($unit == 'mm') { |
|
133 | + $this->k = 72 / 25.4; |
|
134 | + } elseif ($unit == 'cm') { |
|
135 | + $this->k = 72 / 2.54; |
|
136 | + } elseif ($unit == 'in') { |
|
137 | + $this->k = 72; |
|
138 | + } else { |
|
139 | + $this->Error('Incorrect unit: '.$unit); |
|
140 | + } |
|
139 | 141 | // Page sizes |
140 | 142 | $this->StdPageSizes = array('a3'=>array(841.89, 1190.55), 'a4'=>array(595.28, 841.89), 'a5'=>array(420.94, 595.28), |
141 | 143 | 'letter'=>array(612, 792), 'legal'=>array(612, 1008)); |
@@ -149,15 +151,14 @@ discard block |
||
149 | 151 | $this->DefOrientation = 'P'; |
150 | 152 | $this->w = $size[0]; |
151 | 153 | $this->h = $size[1]; |
152 | - } |
|
153 | - elseif ($orientation == 'l' || $orientation == 'landscape') |
|
154 | + } elseif ($orientation == 'l' || $orientation == 'landscape') |
|
154 | 155 | { |
155 | 156 | $this->DefOrientation = 'L'; |
156 | 157 | $this->w = $size[1]; |
157 | 158 | $this->h = $size[0]; |
158 | - } |
|
159 | - else |
|
160 | - $this->Error('Incorrect orientation: '.$orientation); |
|
159 | + } else { |
|
160 | + $this->Error('Incorrect orientation: '.$orientation); |
|
161 | + } |
|
161 | 162 | $this->CurOrientation = $this->DefOrientation; |
162 | 163 | $this->wPt = $this->w * $this->k; |
163 | 164 | $this->hPt = $this->h * $this->k; |
@@ -197,9 +198,10 @@ discard block |
||
197 | 198 | { |
198 | 199 | // Set left margin |
199 | 200 | $this->lMargin = $margin; |
200 | - if ($this->page > 0 && $this->x < $margin) |
|
201 | - $this->x = $margin; |
|
202 | -} |
|
201 | + if ($this->page > 0 && $this->x < $margin) { |
|
202 | + $this->x = $margin; |
|
203 | + } |
|
204 | + } |
|
203 | 205 | |
204 | 206 | function SetTopMargin($margin) |
205 | 207 | { |
@@ -230,15 +232,17 @@ discard block |
||
230 | 232 | function SetDisplayMode($zoom, $layout='default') |
231 | 233 | { |
232 | 234 | // Set display mode in viewer |
233 | - if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) |
|
234 | - $this->ZoomMode = $zoom; |
|
235 | - else |
|
236 | - $this->Error('Incorrect zoom display mode: '.$zoom); |
|
237 | - if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') |
|
238 | - $this->LayoutMode = $layout; |
|
239 | - else |
|
240 | - $this->Error('Incorrect layout display mode: '.$layout); |
|
241 | -} |
|
235 | + if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) { |
|
236 | + $this->ZoomMode = $zoom; |
|
237 | + } else { |
|
238 | + $this->Error('Incorrect zoom display mode: '.$zoom); |
|
239 | + } |
|
240 | + if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') { |
|
241 | + $this->LayoutMode = $layout; |
|
242 | + } else { |
|
243 | + $this->Error('Incorrect layout display mode: '.$layout); |
|
244 | + } |
|
245 | + } |
|
242 | 246 | |
243 | 247 | /** |
244 | 248 | * @param boolean $compress |
@@ -246,49 +250,55 @@ discard block |
||
246 | 250 | function SetCompression($compress) |
247 | 251 | { |
248 | 252 | // Set page compression |
249 | - if (function_exists('gzcompress')) |
|
250 | - $this->compress = $compress; |
|
251 | - else |
|
252 | - $this->compress = false; |
|
253 | -} |
|
253 | + if (function_exists('gzcompress')) { |
|
254 | + $this->compress = $compress; |
|
255 | + } else { |
|
256 | + $this->compress = false; |
|
257 | + } |
|
258 | + } |
|
254 | 259 | |
255 | 260 | function SetTitle($title, $isUTF8 = false) |
256 | 261 | { |
257 | 262 | // Title of document |
258 | - if ($isUTF8) |
|
259 | - $title = $this->_UTF8toUTF16($title); |
|
263 | + if ($isUTF8) { |
|
264 | + $title = $this->_UTF8toUTF16($title); |
|
265 | + } |
|
260 | 266 | $this->title = $title; |
261 | 267 | } |
262 | 268 | |
263 | 269 | function SetSubject($subject, $isUTF8 = false) |
264 | 270 | { |
265 | 271 | // Subject of document |
266 | - if ($isUTF8) |
|
267 | - $subject = $this->_UTF8toUTF16($subject); |
|
272 | + if ($isUTF8) { |
|
273 | + $subject = $this->_UTF8toUTF16($subject); |
|
274 | + } |
|
268 | 275 | $this->subject = $subject; |
269 | 276 | } |
270 | 277 | |
271 | 278 | function SetAuthor($author, $isUTF8 = false) |
272 | 279 | { |
273 | 280 | // Author of document |
274 | - if ($isUTF8) |
|
275 | - $author = $this->_UTF8toUTF16($author); |
|
281 | + if ($isUTF8) { |
|
282 | + $author = $this->_UTF8toUTF16($author); |
|
283 | + } |
|
276 | 284 | $this->author = $author; |
277 | 285 | } |
278 | 286 | |
279 | 287 | function SetKeywords($keywords, $isUTF8 = false) |
280 | 288 | { |
281 | 289 | // Keywords of document |
282 | - if ($isUTF8) |
|
283 | - $keywords = $this->_UTF8toUTF16($keywords); |
|
290 | + if ($isUTF8) { |
|
291 | + $keywords = $this->_UTF8toUTF16($keywords); |
|
292 | + } |
|
284 | 293 | $this->keywords = $keywords; |
285 | 294 | } |
286 | 295 | |
287 | 296 | function SetCreator($creator, $isUTF8 = false) |
288 | 297 | { |
289 | 298 | // Creator of document |
290 | - if ($isUTF8) |
|
291 | - $creator = $this->_UTF8toUTF16($creator); |
|
299 | + if ($isUTF8) { |
|
300 | + $creator = $this->_UTF8toUTF16($creator); |
|
301 | + } |
|
292 | 302 | $this->creator = $creator; |
293 | 303 | } |
294 | 304 | |
@@ -313,10 +323,12 @@ discard block |
||
313 | 323 | function Close() |
314 | 324 | { |
315 | 325 | // Terminate document |
316 | - if ($this->state == 3) |
|
317 | - return; |
|
318 | - if ($this->page == 0) |
|
319 | - $this->AddPage(); |
|
326 | + if ($this->state == 3) { |
|
327 | + return; |
|
328 | + } |
|
329 | + if ($this->page == 0) { |
|
330 | + $this->AddPage(); |
|
331 | + } |
|
320 | 332 | // Page footer |
321 | 333 | $this->InFooter = true; |
322 | 334 | $this->Footer(); |
@@ -330,8 +342,9 @@ discard block |
||
330 | 342 | function AddPage($orientation = '', $size = '') |
331 | 343 | { |
332 | 344 | // Start a new page |
333 | - if ($this->state == 0) |
|
334 | - $this->Open(); |
|
345 | + if ($this->state == 0) { |
|
346 | + $this->Open(); |
|
347 | + } |
|
335 | 348 | $family = $this->FontFamily; |
336 | 349 | $style = $this->FontStyle.($this->underline ? 'U' : ''); |
337 | 350 | $fontsize = $this->FontSizePt; |
@@ -357,15 +370,18 @@ discard block |
||
357 | 370 | $this->LineWidth = $lw; |
358 | 371 | $this->_out(sprintf('%.2F w', $lw * $this->k)); |
359 | 372 | // Set font |
360 | - if ($family) |
|
361 | - $this->SetFont($family, $style, $fontsize); |
|
373 | + if ($family) { |
|
374 | + $this->SetFont($family, $style, $fontsize); |
|
375 | + } |
|
362 | 376 | // Set colors |
363 | 377 | $this->DrawColor = $dc; |
364 | - if ($dc != '0 G') |
|
365 | - $this->_out($dc); |
|
378 | + if ($dc != '0 G') { |
|
379 | + $this->_out($dc); |
|
380 | + } |
|
366 | 381 | $this->FillColor = $fc; |
367 | - if ($fc != '0 g') |
|
368 | - $this->_out($fc); |
|
382 | + if ($fc != '0 g') { |
|
383 | + $this->_out($fc); |
|
384 | + } |
|
369 | 385 | $this->TextColor = $tc; |
370 | 386 | $this->ColorFlag = $cf; |
371 | 387 | // Page header |
@@ -379,8 +395,9 @@ discard block |
||
379 | 395 | $this->_out(sprintf('%.2F w', $lw * $this->k)); |
380 | 396 | } |
381 | 397 | // Restore font |
382 | - if ($family) |
|
383 | - $this->SetFont($family, $style, $fontsize); |
|
398 | + if ($family) { |
|
399 | + $this->SetFont($family, $style, $fontsize); |
|
400 | + } |
|
384 | 401 | // Restore colors |
385 | 402 | if ($this->DrawColor != $dc) |
386 | 403 | { |
@@ -415,13 +432,15 @@ discard block |
||
415 | 432 | function SetDrawColor($r, $g=null, $b=null) |
416 | 433 | { |
417 | 434 | // Set color for all stroking operations |
418 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
419 | - $this->DrawColor = sprintf('%.3F G',$r/255); |
|
420 | - else |
|
421 | - $this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); |
|
422 | - if($this->page>0) |
|
423 | - $this->_out($this->DrawColor); |
|
424 | -} |
|
435 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
436 | + $this->DrawColor = sprintf('%.3F G',$r/255); |
|
437 | + } else { |
|
438 | + $this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); |
|
439 | + } |
|
440 | + if($this->page>0) { |
|
441 | + $this->_out($this->DrawColor); |
|
442 | + } |
|
443 | + } |
|
425 | 444 | |
426 | 445 | /** |
427 | 446 | * @param integer $r |
@@ -431,22 +450,25 @@ discard block |
||
431 | 450 | function SetFillColor($r, $g=null, $b=null) |
432 | 451 | { |
433 | 452 | // Set color for all filling operations |
434 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
435 | - $this->FillColor = sprintf('%.3F g',$r/255); |
|
436 | - else |
|
437 | - $this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
453 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
454 | + $this->FillColor = sprintf('%.3F g',$r/255); |
|
455 | + } else { |
|
456 | + $this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
457 | + } |
|
438 | 458 | $this->ColorFlag = ($this->FillColor!=$this->TextColor); |
439 | - if($this->page>0) |
|
440 | - $this->_out($this->FillColor); |
|
441 | -} |
|
459 | + if($this->page>0) { |
|
460 | + $this->_out($this->FillColor); |
|
461 | + } |
|
462 | + } |
|
442 | 463 | |
443 | 464 | function SetTextColor($r, $g=null, $b=null) |
444 | 465 | { |
445 | 466 | // Set color for text |
446 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
447 | - $this->TextColor = sprintf('%.3F g',$r/255); |
|
448 | - else |
|
449 | - $this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
467 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
468 | + $this->TextColor = sprintf('%.3F g',$r/255); |
|
469 | + } else { |
|
470 | + $this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
471 | + } |
|
450 | 472 | $this->ColorFlag = ($this->FillColor!=$this->TextColor); |
451 | 473 | } |
452 | 474 | |
@@ -594,20 +616,23 @@ discard block |
||
594 | 616 | $this->FontSizePt = $size; |
595 | 617 | $this->FontSize = $size / $this->k; |
596 | 618 | $this->CurrentFont = &$this->fonts[$fontkey]; |
597 | - if ($this->page > 0) |
|
598 | - $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); |
|
599 | -} |
|
619 | + if ($this->page > 0) { |
|
620 | + $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); |
|
621 | + } |
|
622 | + } |
|
600 | 623 | |
601 | 624 | function SetFontSize($size) |
602 | 625 | { |
603 | 626 | // Set font size in points |
604 | - if ($this->FontSizePt == $size) |
|
605 | - return; |
|
627 | + if ($this->FontSizePt == $size) { |
|
628 | + return; |
|
629 | + } |
|
606 | 630 | $this->FontSizePt = $size; |
607 | 631 | $this->FontSize = $size / $this->k; |
608 | - if ($this->page > 0) |
|
609 | - $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); |
|
610 | -} |
|
632 | + if ($this->page > 0) { |
|
633 | + $this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); |
|
634 | + } |
|
635 | + } |
|
611 | 636 | |
612 | 637 | function AddLink() |
613 | 638 | { |
@@ -620,10 +645,12 @@ discard block |
||
620 | 645 | function SetLink($link, $y = 0, $page = -1) |
621 | 646 | { |
622 | 647 | // Set destination of internal link |
623 | - if ($y == -1) |
|
624 | - $y = $this->y; |
|
625 | - if ($page == -1) |
|
626 | - $page = $this->page; |
|
648 | + if ($y == -1) { |
|
649 | + $y = $this->y; |
|
650 | + } |
|
651 | + if ($page == -1) { |
|
652 | + $page = $this->page; |
|
653 | + } |
|
627 | 654 | $this->links[$link] = array($page, $y); |
628 | 655 | } |
629 | 656 | |
@@ -641,10 +668,12 @@ discard block |
||
641 | 668 | { |
642 | 669 | // Output a string |
643 | 670 | $s = sprintf('BT %.2F %.2F Td (%s) Tj ET', $x * $this->k, ($this->h - $y) * $this->k, $this->_escape($txt)); |
644 | - if ($this->underline && $txt != '') |
|
645 | - $s .= ' '.$this->_dounderline($x, $y, $txt); |
|
646 | - if ($this->ColorFlag) |
|
647 | - $s = 'q '.$this->TextColor.' '.$s.' Q'; |
|
671 | + if ($this->underline && $txt != '') { |
|
672 | + $s .= ' '.$this->_dounderline($x, $y, $txt); |
|
673 | + } |
|
674 | + if ($this->ColorFlag) { |
|
675 | + $s = 'q '.$this->TextColor.' '.$s.' Q'; |
|
676 | + } |
|
648 | 677 | $this->_out($s); |
649 | 678 | } |
650 | 679 | |
@@ -676,62 +705,75 @@ discard block |
||
676 | 705 | $this->_out(sprintf('%.3F Tw',$ws*$k)); |
677 | 706 | } |
678 | 707 | } |
679 | - if($w==0) |
|
680 | - $w = $this->w-$this->rMargin-$this->x; |
|
708 | + if($w==0) { |
|
709 | + $w = $this->w-$this->rMargin-$this->x; |
|
710 | + } |
|
681 | 711 | $s = ''; |
682 | 712 | if($fill || $border==1) |
683 | 713 | { |
684 | - if($fill) |
|
685 | - $op = ($border==1) ? 'B' : 'f'; |
|
686 | - else |
|
687 | - $op = 'S'; |
|
714 | + if($fill) { |
|
715 | + $op = ($border==1) ? 'B' : 'f'; |
|
716 | + } else { |
|
717 | + $op = 'S'; |
|
718 | + } |
|
688 | 719 | $s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); |
689 | 720 | } |
690 | 721 | if(is_string($border)) |
691 | 722 | { |
692 | 723 | $x = $this->x; |
693 | 724 | $y = $this->y; |
694 | - if(strpos($border,'L')!==false) |
|
695 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); |
|
696 | - if(strpos($border,'T')!==false) |
|
697 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); |
|
698 | - if(strpos($border,'R')!==false) |
|
699 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
700 | - if(strpos($border,'B')!==false) |
|
701 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
725 | + if(strpos($border,'L')!==false) { |
|
726 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); |
|
727 | + } |
|
728 | + if(strpos($border,'T')!==false) { |
|
729 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); |
|
730 | + } |
|
731 | + if(strpos($border,'R')!==false) { |
|
732 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
733 | + } |
|
734 | + if(strpos($border,'B')!==false) { |
|
735 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
736 | + } |
|
702 | 737 | } |
703 | 738 | if($txt!=='') |
704 | 739 | { |
705 | - if($align=='R') |
|
706 | - $dx = $w-$this->cMargin-$this->GetStringWidth($txt); |
|
707 | - elseif($align=='C') |
|
708 | - $dx = ($w-$this->GetStringWidth($txt))/2; |
|
709 | - else |
|
710 | - $dx = $this->cMargin; |
|
711 | - if($this->ColorFlag) |
|
712 | - $s .= 'q '.$this->TextColor.' '; |
|
740 | + if($align=='R') { |
|
741 | + $dx = $w-$this->cMargin-$this->GetStringWidth($txt); |
|
742 | + } elseif($align=='C') { |
|
743 | + $dx = ($w-$this->GetStringWidth($txt))/2; |
|
744 | + } else { |
|
745 | + $dx = $this->cMargin; |
|
746 | + } |
|
747 | + if($this->ColorFlag) { |
|
748 | + $s .= 'q '.$this->TextColor.' '; |
|
749 | + } |
|
713 | 750 | $txt2 = str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt))); |
714 | 751 | $s .= sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2); |
715 | - if($this->underline) |
|
716 | - $s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
717 | - if($this->ColorFlag) |
|
718 | - $s .= ' Q'; |
|
719 | - if($link) |
|
720 | - $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); |
|
752 | + if($this->underline) { |
|
753 | + $s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
754 | + } |
|
755 | + if($this->ColorFlag) { |
|
756 | + $s .= ' Q'; |
|
757 | + } |
|
758 | + if($link) { |
|
759 | + $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); |
|
760 | + } |
|
721 | 761 | } |
722 | - if($s) |
|
723 | - $this->_out($s); |
|
762 | + if($s) { |
|
763 | + $this->_out($s); |
|
764 | + } |
|
724 | 765 | $this->lasth = $h; |
725 | 766 | if($ln>0) |
726 | 767 | { |
727 | 768 | // Go to next line |
728 | 769 | $this->y += $h; |
729 | - if($ln==1) |
|
730 | - $this->x = $this->lMargin; |
|
770 | + if($ln==1) { |
|
771 | + $this->x = $this->lMargin; |
|
772 | + } |
|
773 | + } else { |
|
774 | + $this->x += $w; |
|
775 | + } |
|
731 | 776 | } |
732 | - else |
|
733 | - $this->x += $w; |
|
734 | -} |
|
735 | 777 | |
736 | 778 | /** |
737 | 779 | * @param integer $w |
@@ -741,13 +783,15 @@ discard block |
||
741 | 783 | { |
742 | 784 | // Output text with automatic or explicit line breaks |
743 | 785 | $cw = &$this->CurrentFont['cw']; |
744 | - if($w==0) |
|
745 | - $w = $this->w-$this->rMargin-$this->x; |
|
786 | + if($w==0) { |
|
787 | + $w = $this->w-$this->rMargin-$this->x; |
|
788 | + } |
|
746 | 789 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
747 | 790 | $s = str_replace("\r",'',$txt); |
748 | 791 | $nb = strlen($s); |
749 | - if($nb>0 && $s[$nb-1]=="\n") |
|
750 | - $nb--; |
|
792 | + if($nb>0 && $s[$nb-1]=="\n") { |
|
793 | + $nb--; |
|
794 | + } |
|
751 | 795 | $b = 0; |
752 | 796 | if($border) |
753 | 797 | { |
@@ -756,14 +800,15 @@ discard block |
||
756 | 800 | $border = 'LTRB'; |
757 | 801 | $b = 'LRT'; |
758 | 802 | $b2 = 'LR'; |
759 | - } |
|
760 | - else |
|
803 | + } else |
|
761 | 804 | { |
762 | 805 | $b2 = ''; |
763 | - if (strpos($border, 'L') !== false) |
|
764 | - $b2 .= 'L'; |
|
765 | - if (strpos($border, 'R') !== false) |
|
766 | - $b2 .= 'R'; |
|
806 | + if (strpos($border, 'L') !== false) { |
|
807 | + $b2 .= 'L'; |
|
808 | + } |
|
809 | + if (strpos($border, 'R') !== false) { |
|
810 | + $b2 .= 'R'; |
|
811 | + } |
|
767 | 812 | $b = (strpos($border, 'T') !== false) ? $b2.'T' : $b2; |
768 | 813 | } |
769 | 814 | } |
@@ -792,8 +837,9 @@ discard block |
||
792 | 837 | $l = 0; |
793 | 838 | $ns = 0; |
794 | 839 | $nl++; |
795 | - if ($border && $nl == 2) |
|
796 | - $b = $b2; |
|
840 | + if ($border && $nl == 2) { |
|
841 | + $b = $b2; |
|
842 | + } |
|
797 | 843 | continue; |
798 | 844 | } |
799 | 845 | if ($c == ' ') |
@@ -808,16 +854,16 @@ discard block |
||
808 | 854 | // Automatic line break |
809 | 855 | if ($sep == -1) |
810 | 856 | { |
811 | - if ($i == $j) |
|
812 | - $i++; |
|
857 | + if ($i == $j) { |
|
858 | + $i++; |
|
859 | + } |
|
813 | 860 | if ($this->ws > 0) |
814 | 861 | { |
815 | 862 | $this->ws = 0; |
816 | 863 | $this->_out('0 Tw'); |
817 | 864 | } |
818 | 865 | $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); |
819 | - } |
|
820 | - else |
|
866 | + } else |
|
821 | 867 | { |
822 | 868 | if ($align == 'J') |
823 | 869 | { |
@@ -832,11 +878,12 @@ discard block |
||
832 | 878 | $l = 0; |
833 | 879 | $ns = 0; |
834 | 880 | $nl++; |
835 | - if ($border && $nl == 2) |
|
836 | - $b = $b2; |
|
837 | - } |
|
838 | - else |
|
839 | - $i++; |
|
881 | + if ($border && $nl == 2) { |
|
882 | + $b = $b2; |
|
883 | + } |
|
884 | + } else { |
|
885 | + $i++; |
|
886 | + } |
|
840 | 887 | } |
841 | 888 | // Last chunk |
842 | 889 | if ($this->ws > 0) |
@@ -844,8 +891,9 @@ discard block |
||
844 | 891 | $this->ws = 0; |
845 | 892 | $this->_out('0 Tw'); |
846 | 893 | } |
847 | - if ($border && strpos($border, 'B') !== false) |
|
848 | - $b .= 'B'; |
|
894 | + if ($border && strpos($border, 'B') !== false) { |
|
895 | + $b .= 'B'; |
|
896 | + } |
|
849 | 897 | $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); |
850 | 898 | $this->x = $this->lMargin; |
851 | 899 | } |
@@ -884,8 +932,9 @@ discard block |
||
884 | 932 | $nl++; |
885 | 933 | continue; |
886 | 934 | } |
887 | - if ($c == ' ') |
|
888 | - $sep = $i; |
|
935 | + if ($c == ' ') { |
|
936 | + $sep = $i; |
|
937 | + } |
|
889 | 938 | $l += $cw[$c]; |
890 | 939 | if ($l > $wmax) |
891 | 940 | { |
@@ -903,11 +952,11 @@ discard block |
||
903 | 952 | $nl++; |
904 | 953 | continue; |
905 | 954 | } |
906 | - if ($i == $j) |
|
907 | - $i++; |
|
955 | + if ($i == $j) { |
|
956 | + $i++; |
|
957 | + } |
|
908 | 958 | $this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', 0, $link); |
909 | - } |
|
910 | - else |
|
959 | + } else |
|
911 | 960 | { |
912 | 961 | $this->Cell($w, $h, substr($s, $j, $sep - $j), 0, 2, '', 0, $link); |
913 | 962 | $i = $sep + 1; |
@@ -922,24 +971,26 @@ discard block |
||
922 | 971 | $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
923 | 972 | } |
924 | 973 | $nl++; |
925 | - } |
|
926 | - else |
|
927 | - $i++; |
|
974 | + } else { |
|
975 | + $i++; |
|
976 | + } |
|
928 | 977 | } |
929 | 978 | // Last chunk |
930 | - if ($i != $j) |
|
931 | - $this->Cell($l / 1000 * $this->FontSize, $h, substr($s, $j), 0, 0, '', 0, $link); |
|
932 | -} |
|
979 | + if ($i != $j) { |
|
980 | + $this->Cell($l / 1000 * $this->FontSize, $h, substr($s, $j), 0, 0, '', 0, $link); |
|
981 | + } |
|
982 | + } |
|
933 | 983 | |
934 | 984 | function Ln($h = null) |
935 | 985 | { |
936 | 986 | // Line feed; default value is last cell height |
937 | 987 | $this->x = $this->lMargin; |
938 | - if ($h === null) |
|
939 | - $this->y += $this->lasth; |
|
940 | - else |
|
941 | - $this->y += $h; |
|
942 | -} |
|
988 | + if ($h === null) { |
|
989 | + $this->y += $this->lasth; |
|
990 | + } else { |
|
991 | + $this->y += $h; |
|
992 | + } |
|
993 | + } |
|
943 | 994 | |
944 | 995 | function Image($file, $x = null, $y = null, $w = 0, $h = 0, $type = '', $link = '') |
945 | 996 | { |
@@ -950,22 +1001,25 @@ discard block |
||
950 | 1001 | if ($type == '') |
951 | 1002 | { |
952 | 1003 | $pos = strrpos($file, '.'); |
953 | - if ( ! $pos) |
|
954 | - $this->Error('Image file has no extension and no type was specified: '.$file); |
|
1004 | + if ( ! $pos) { |
|
1005 | + $this->Error('Image file has no extension and no type was specified: '.$file); |
|
1006 | + } |
|
955 | 1007 | $type = substr($file, $pos + 1); |
956 | 1008 | } |
957 | 1009 | $type = strtolower($type); |
958 | - if ($type == 'jpeg') |
|
959 | - $type = 'jpg'; |
|
1010 | + if ($type == 'jpeg') { |
|
1011 | + $type = 'jpg'; |
|
1012 | + } |
|
960 | 1013 | $mtd = '_parse'.$type; |
961 | - if ( ! method_exists($this, $mtd)) |
|
962 | - $this->Error('Unsupported image type: '.$type); |
|
1014 | + if ( ! method_exists($this, $mtd)) { |
|
1015 | + $this->Error('Unsupported image type: '.$type); |
|
1016 | + } |
|
963 | 1017 | $info = $this->$mtd($file); |
964 | 1018 | $info['i'] = count($this->images) + 1; |
965 | 1019 | $this->images[$file] = $info; |
966 | - } |
|
967 | - else |
|
968 | - $info = $this->images[$file]; |
|
1020 | + } else { |
|
1021 | + $info = $this->images[$file]; |
|
1022 | + } |
|
969 | 1023 | |
970 | 1024 | // Automatic width and height calculation if needed |
971 | 1025 | if ($w == 0 && $h == 0) |
@@ -974,14 +1028,18 @@ discard block |
||
974 | 1028 | $w = -96; |
975 | 1029 | $h = -96; |
976 | 1030 | } |
977 | - if ($w < 0) |
|
978 | - $w = -$info['w'] * 72 / $w / $this->k; |
|
979 | - if ($h < 0) |
|
980 | - $h = -$info['h'] * 72 / $h / $this->k; |
|
981 | - if ($w == 0) |
|
982 | - $w = $h * $info['w'] / $info['h']; |
|
983 | - if ($h == 0) |
|
984 | - $h = $w * $info['h'] / $info['w']; |
|
1031 | + if ($w < 0) { |
|
1032 | + $w = -$info['w'] * 72 / $w / $this->k; |
|
1033 | + } |
|
1034 | + if ($h < 0) { |
|
1035 | + $h = -$info['h'] * 72 / $h / $this->k; |
|
1036 | + } |
|
1037 | + if ($w == 0) { |
|
1038 | + $w = $h * $info['w'] / $info['h']; |
|
1039 | + } |
|
1040 | + if ($h == 0) { |
|
1041 | + $h = $w * $info['h'] / $info['w']; |
|
1042 | + } |
|
985 | 1043 | |
986 | 1044 | // Flowing mode |
987 | 1045 | if ($y === null) |
@@ -997,12 +1055,14 @@ discard block |
||
997 | 1055 | $this->y += $h; |
998 | 1056 | } |
999 | 1057 | |
1000 | - if ($x === null) |
|
1001 | - $x = $this->x; |
|
1058 | + if ($x === null) { |
|
1059 | + $x = $this->x; |
|
1060 | + } |
|
1002 | 1061 | $this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q', $w * $this->k, $h * $this->k, $x * $this->k, ($this->h - ($y + $h)) * $this->k, $info['i'])); |
1003 | - if ($link) |
|
1004 | - $this->Link($x, $y, $w, $h, $link); |
|
1005 | -} |
|
1062 | + if ($link) { |
|
1063 | + $this->Link($x, $y, $w, $h, $link); |
|
1064 | + } |
|
1065 | + } |
|
1006 | 1066 | |
1007 | 1067 | function GetX() |
1008 | 1068 | { |
@@ -1013,11 +1073,12 @@ discard block |
||
1013 | 1073 | function SetX($x) |
1014 | 1074 | { |
1015 | 1075 | // Set x position |
1016 | - if ($x >= 0) |
|
1017 | - $this->x = $x; |
|
1018 | - else |
|
1019 | - $this->x = $this->w + $x; |
|
1020 | -} |
|
1076 | + if ($x >= 0) { |
|
1077 | + $this->x = $x; |
|
1078 | + } else { |
|
1079 | + $this->x = $this->w + $x; |
|
1080 | + } |
|
1081 | + } |
|
1021 | 1082 | |
1022 | 1083 | function GetY() |
1023 | 1084 | { |
@@ -1029,11 +1090,12 @@ discard block |
||
1029 | 1090 | { |
1030 | 1091 | // Set y position and reset x |
1031 | 1092 | $this->x = $this->lMargin; |
1032 | - if ($y >= 0) |
|
1033 | - $this->y = $y; |
|
1034 | - else |
|
1035 | - $this->y = $this->h + $y; |
|
1036 | -} |
|
1093 | + if ($y >= 0) { |
|
1094 | + $this->y = $y; |
|
1095 | + } else { |
|
1096 | + $this->y = $this->h + $y; |
|
1097 | + } |
|
1098 | + } |
|
1037 | 1099 | |
1038 | 1100 | /** |
1039 | 1101 | * @param integer $x |
@@ -1048,8 +1110,9 @@ discard block |
||
1048 | 1110 | function Output($name = '', $dest = '') |
1049 | 1111 | { |
1050 | 1112 | // Output PDF to some destination |
1051 | - if ($this->state < 3) |
|
1052 | - $this->Close(); |
|
1113 | + if ($this->state < 3) { |
|
1114 | + $this->Close(); |
|
1115 | + } |
|
1053 | 1116 | $dest = strtoupper($dest); |
1054 | 1117 | if ($dest == '') |
1055 | 1118 | { |
@@ -1089,8 +1152,9 @@ discard block |
||
1089 | 1152 | case 'F': |
1090 | 1153 | // Save to local file |
1091 | 1154 | $f = fopen($name, 'wb'); |
1092 | - if ( ! $f) |
|
1093 | - $this->Error('Unable to create output file: '.$name); |
|
1155 | + if ( ! $f) { |
|
1156 | + $this->Error('Unable to create output file: '.$name); |
|
1157 | + } |
|
1094 | 1158 | fwrite($f, $this->buffer, strlen($this->buffer)); |
1095 | 1159 | fclose($f); |
1096 | 1160 | break; |
@@ -1111,22 +1175,26 @@ discard block |
||
1111 | 1175 | function _dochecks() |
1112 | 1176 | { |
1113 | 1177 | // Check availability of %F |
1114 | - if (sprintf('%.1F', 1.0) != '1.0') |
|
1115 | - $this->Error('This version of PHP is not supported'); |
|
1178 | + if (sprintf('%.1F', 1.0) != '1.0') { |
|
1179 | + $this->Error('This version of PHP is not supported'); |
|
1180 | + } |
|
1116 | 1181 | // Check mbstring overloading |
1117 | - if (ini_get('mbstring.func_overload') & 2) |
|
1118 | - $this->Error('mbstring overloading must be disabled'); |
|
1182 | + if (ini_get('mbstring.func_overload') & 2) { |
|
1183 | + $this->Error('mbstring overloading must be disabled'); |
|
1184 | + } |
|
1119 | 1185 | // Ensure runtime magic quotes are disabled |
1120 | - if (get_magic_quotes_runtime()) |
|
1121 | - @set_magic_quotes_runtime(0); |
|
1122 | -} |
|
1186 | + if (get_magic_quotes_runtime()) { |
|
1187 | + @set_magic_quotes_runtime(0); |
|
1188 | + } |
|
1189 | + } |
|
1123 | 1190 | |
1124 | 1191 | function _checkoutput() |
1125 | 1192 | { |
1126 | 1193 | if (PHP_SAPI != 'cli') |
1127 | 1194 | { |
1128 | - if (headers_sent($file, $line)) |
|
1129 | - $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)"); |
|
1195 | + if (headers_sent($file, $line)) { |
|
1196 | + $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)"); |
|
1197 | + } |
|
1130 | 1198 | } |
1131 | 1199 | if (ob_get_length()) |
1132 | 1200 | { |
@@ -1146,17 +1214,18 @@ discard block |
||
1146 | 1214 | if (is_string($size)) |
1147 | 1215 | { |
1148 | 1216 | $size = strtolower($size); |
1149 | - if ( ! isset($this->StdPageSizes[$size])) |
|
1150 | - $this->Error('Unknown page size: '.$size); |
|
1217 | + if ( ! isset($this->StdPageSizes[$size])) { |
|
1218 | + $this->Error('Unknown page size: '.$size); |
|
1219 | + } |
|
1151 | 1220 | $a = $this->StdPageSizes[$size]; |
1152 | 1221 | return array($a[0] / $this->k, $a[1] / $this->k); |
1153 | - } |
|
1154 | - else |
|
1222 | + } else |
|
1155 | 1223 | { |
1156 | - if ($size[0] > $size[1]) |
|
1157 | - return array($size[1], $size[0]); |
|
1158 | - else |
|
1159 | - return $size; |
|
1224 | + if ($size[0] > $size[1]) { |
|
1225 | + return array($size[1], $size[0]); |
|
1226 | + } else { |
|
1227 | + return $size; |
|
1228 | + } |
|
1160 | 1229 | } |
1161 | 1230 | } |
1162 | 1231 | |
@@ -1173,14 +1242,16 @@ discard block |
||
1173 | 1242 | $this->y = $this->tMargin; |
1174 | 1243 | $this->FontFamily = ''; |
1175 | 1244 | // Check page size and orientation |
1176 | - if ($orientation == '') |
|
1177 | - $orientation = $this->DefOrientation; |
|
1178 | - else |
|
1179 | - $orientation = strtoupper($orientation[0]); |
|
1180 | - if ($size == '') |
|
1181 | - $size = $this->DefPageSize; |
|
1182 | - else |
|
1183 | - $size = $this->_getpagesize($size); |
|
1245 | + if ($orientation == '') { |
|
1246 | + $orientation = $this->DefOrientation; |
|
1247 | + } else { |
|
1248 | + $orientation = strtoupper($orientation[0]); |
|
1249 | + } |
|
1250 | + if ($size == '') { |
|
1251 | + $size = $this->DefPageSize; |
|
1252 | + } else { |
|
1253 | + $size = $this->_getpagesize($size); |
|
1254 | + } |
|
1184 | 1255 | if ($orientation != $this->CurOrientation || $size[0] != $this->CurPageSize[0] || $size[1] != $this->CurPageSize[1]) |
1185 | 1256 | { |
1186 | 1257 | // New size or orientation |
@@ -1199,9 +1270,10 @@ discard block |
||
1199 | 1270 | $this->CurOrientation = $orientation; |
1200 | 1271 | $this->CurPageSize = $size; |
1201 | 1272 | } |
1202 | - if ($orientation != $this->DefOrientation || $size[0] != $this->DefPageSize[0] || $size[1] != $this->DefPageSize[1]) |
|
1203 | - $this->PageSizes[$this->page] = array($this->wPt, $this->hPt); |
|
1204 | -} |
|
1273 | + if ($orientation != $this->DefOrientation || $size[0] != $this->DefPageSize[0] || $size[1] != $this->DefPageSize[1]) { |
|
1274 | + $this->PageSizes[$this->page] = array($this->wPt, $this->hPt); |
|
1275 | + } |
|
1276 | + } |
|
1205 | 1277 | |
1206 | 1278 | function _endpage() |
1207 | 1279 | { |
@@ -1216,8 +1288,9 @@ discard block |
||
1216 | 1288 | // Load a font definition file from the font directory |
1217 | 1289 | include($this->fontpath.$font); |
1218 | 1290 | $a = get_defined_vars(); |
1219 | - if ( ! isset($a['name'])) |
|
1220 | - $this->Error('Could not include font definition file'); |
|
1291 | + if ( ! isset($a['name'])) { |
|
1292 | + $this->Error('Could not include font definition file'); |
|
1293 | + } |
|
1221 | 1294 | return $a; |
1222 | 1295 | } |
1223 | 1296 | |
@@ -1253,15 +1326,13 @@ discard block |
||
1253 | 1326 | $c3 = ord($s[$i++]); |
1254 | 1327 | $res .= chr((($c1 & 0x0F) << 4) + (($c2 & 0x3C) >> 2)); |
1255 | 1328 | $res .= chr((($c2 & 0x03) << 6) + ($c3 & 0x3F)); |
1256 | - } |
|
1257 | - elseif ($c1 >= 192) |
|
1329 | + } elseif ($c1 >= 192) |
|
1258 | 1330 | { |
1259 | 1331 | // 2-byte character |
1260 | 1332 | $c2 = ord($s[$i++]); |
1261 | 1333 | $res .= chr(($c1 & 0x1C) >> 2); |
1262 | 1334 | $res .= chr((($c1 & 0x03) << 6) + ($c2 & 0x3F)); |
1263 | - } |
|
1264 | - else |
|
1335 | + } else |
|
1265 | 1336 | { |
1266 | 1337 | // Single-byte character |
1267 | 1338 | $res .= "\0".chr($c1); |
@@ -1283,16 +1354,19 @@ discard block |
||
1283 | 1354 | { |
1284 | 1355 | // Extract info from a JPEG file |
1285 | 1356 | $a = getimagesize($file); |
1286 | - if ( ! $a) |
|
1287 | - $this->Error('Missing or incorrect image file: '.$file); |
|
1288 | - if ($a[2] != 2) |
|
1289 | - $this->Error('Not a JPEG file: '.$file); |
|
1290 | - if ( ! isset($a['channels']) || $a['channels'] == 3) |
|
1291 | - $colspace = 'DeviceRGB'; |
|
1292 | - elseif ($a['channels'] == 4) |
|
1293 | - $colspace = 'DeviceCMYK'; |
|
1294 | - else |
|
1295 | - $colspace = 'DeviceGray'; |
|
1357 | + if ( ! $a) { |
|
1358 | + $this->Error('Missing or incorrect image file: '.$file); |
|
1359 | + } |
|
1360 | + if ($a[2] != 2) { |
|
1361 | + $this->Error('Not a JPEG file: '.$file); |
|
1362 | + } |
|
1363 | + if ( ! isset($a['channels']) || $a['channels'] == 3) { |
|
1364 | + $colspace = 'DeviceRGB'; |
|
1365 | + } elseif ($a['channels'] == 4) { |
|
1366 | + $colspace = 'DeviceCMYK'; |
|
1367 | + } else { |
|
1368 | + $colspace = 'DeviceGray'; |
|
1369 | + } |
|
1296 | 1370 | $bpc = isset($a['bits']) ? $a['bits'] : 8; |
1297 | 1371 | $data = file_get_contents($file); |
1298 | 1372 | return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data); |
@@ -1305,8 +1379,9 @@ discard block |
||
1305 | 1379 | { |
1306 | 1380 | // Extract info from a PNG file |
1307 | 1381 | $f = fopen($file, 'rb'); |
1308 | - if ( ! $f) |
|
1309 | - $this->Error('Can\'t open image file: '.$file); |
|
1382 | + if ( ! $f) { |
|
1383 | + $this->Error('Can\'t open image file: '.$file); |
|
1384 | + } |
|
1310 | 1385 | $info = $this->_parsepngstream($f, $file); |
1311 | 1386 | fclose($f); |
1312 | 1387 | return $info; |
@@ -1315,33 +1390,40 @@ discard block |
||
1315 | 1390 | function _parsepngstream($f, $file) |
1316 | 1391 | { |
1317 | 1392 | // Check signature |
1318 | - if ($this->_readstream($f, 8) != chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) |
|
1319 | - $this->Error('Not a PNG file: '.$file); |
|
1393 | + if ($this->_readstream($f, 8) != chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { |
|
1394 | + $this->Error('Not a PNG file: '.$file); |
|
1395 | + } |
|
1320 | 1396 | |
1321 | 1397 | // Read header chunk |
1322 | 1398 | $this->_readstream($f, 4); |
1323 | - if ($this->_readstream($f, 4) != 'IHDR') |
|
1324 | - $this->Error('Incorrect PNG file: '.$file); |
|
1399 | + if ($this->_readstream($f, 4) != 'IHDR') { |
|
1400 | + $this->Error('Incorrect PNG file: '.$file); |
|
1401 | + } |
|
1325 | 1402 | $w = $this->_readint($f); |
1326 | 1403 | $h = $this->_readint($f); |
1327 | 1404 | $bpc = ord($this->_readstream($f, 1)); |
1328 | - if ($bpc > 8) |
|
1329 | - $this->Error('16-bit depth not supported: '.$file); |
|
1405 | + if ($bpc > 8) { |
|
1406 | + $this->Error('16-bit depth not supported: '.$file); |
|
1407 | + } |
|
1330 | 1408 | $ct = ord($this->_readstream($f, 1)); |
1331 | - if ($ct == 0 || $ct == 4) |
|
1332 | - $colspace = 'DeviceGray'; |
|
1333 | - elseif ($ct == 2 || $ct == 6) |
|
1334 | - $colspace = 'DeviceRGB'; |
|
1335 | - elseif ($ct == 3) |
|
1336 | - $colspace = 'Indexed'; |
|
1337 | - else |
|
1338 | - $this->Error('Unknown color type: '.$file); |
|
1339 | - if (ord($this->_readstream($f, 1)) != 0) |
|
1340 | - $this->Error('Unknown compression method: '.$file); |
|
1341 | - if (ord($this->_readstream($f, 1)) != 0) |
|
1342 | - $this->Error('Unknown filter method: '.$file); |
|
1343 | - if (ord($this->_readstream($f, 1)) != 0) |
|
1344 | - $this->Error('Interlacing not supported: '.$file); |
|
1409 | + if ($ct == 0 || $ct == 4) { |
|
1410 | + $colspace = 'DeviceGray'; |
|
1411 | + } elseif ($ct == 2 || $ct == 6) { |
|
1412 | + $colspace = 'DeviceRGB'; |
|
1413 | + } elseif ($ct == 3) { |
|
1414 | + $colspace = 'Indexed'; |
|
1415 | + } else { |
|
1416 | + $this->Error('Unknown color type: '.$file); |
|
1417 | + } |
|
1418 | + if (ord($this->_readstream($f, 1)) != 0) { |
|
1419 | + $this->Error('Unknown compression method: '.$file); |
|
1420 | + } |
|
1421 | + if (ord($this->_readstream($f, 1)) != 0) { |
|
1422 | + $this->Error('Unknown filter method: '.$file); |
|
1423 | + } |
|
1424 | + if (ord($this->_readstream($f, 1)) != 0) { |
|
1425 | + $this->Error('Interlacing not supported: '.$file); |
|
1426 | + } |
|
1345 | 1427 | $this->_readstream($f, 4); |
1346 | 1428 | $dp = '/Predictor 15 /Colors '.($colspace == 'DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w; |
1347 | 1429 | |
@@ -1358,44 +1440,45 @@ discard block |
||
1358 | 1440 | // Read palette |
1359 | 1441 | $pal = $this->_readstream($f, $n); |
1360 | 1442 | $this->_readstream($f, 4); |
1361 | - } |
|
1362 | - elseif ($type == 'tRNS') |
|
1443 | + } elseif ($type == 'tRNS') |
|
1363 | 1444 | { |
1364 | 1445 | // Read transparency info |
1365 | 1446 | $t = $this->_readstream($f, $n); |
1366 | - if ($ct == 0) |
|
1367 | - $trns = array(ord(substr($t, 1, 1))); |
|
1368 | - elseif ($ct == 2) |
|
1369 | - $trns = array(ord(substr($t, 1, 1)), ord(substr($t, 3, 1)), ord(substr($t, 5, 1))); |
|
1370 | - else |
|
1447 | + if ($ct == 0) { |
|
1448 | + $trns = array(ord(substr($t, 1, 1))); |
|
1449 | + } elseif ($ct == 2) { |
|
1450 | + $trns = array(ord(substr($t, 1, 1)), ord(substr($t, 3, 1)), ord(substr($t, 5, 1))); |
|
1451 | + } else |
|
1371 | 1452 | { |
1372 | 1453 | $pos = strpos($t, chr(0)); |
1373 | - if ($pos !== false) |
|
1374 | - $trns = array($pos); |
|
1454 | + if ($pos !== false) { |
|
1455 | + $trns = array($pos); |
|
1456 | + } |
|
1375 | 1457 | } |
1376 | 1458 | $this->_readstream($f, 4); |
1377 | - } |
|
1378 | - elseif ($type == 'IDAT') |
|
1459 | + } elseif ($type == 'IDAT') |
|
1379 | 1460 | { |
1380 | 1461 | // Read image data block |
1381 | 1462 | $data .= $this->_readstream($f, $n); |
1382 | 1463 | $this->_readstream($f, 4); |
1383 | - } |
|
1384 | - elseif ($type == 'IEND') |
|
1385 | - break; |
|
1386 | - else |
|
1387 | - $this->_readstream($f, $n + 4); |
|
1464 | + } elseif ($type == 'IEND') { |
|
1465 | + break; |
|
1466 | + } else { |
|
1467 | + $this->_readstream($f, $n + 4); |
|
1468 | + } |
|
1388 | 1469 | } |
1389 | 1470 | while ($n); |
1390 | 1471 | |
1391 | - if ($colspace == 'Indexed' && empty($pal)) |
|
1392 | - $this->Error('Missing palette in '.$file); |
|
1472 | + if ($colspace == 'Indexed' && empty($pal)) { |
|
1473 | + $this->Error('Missing palette in '.$file); |
|
1474 | + } |
|
1393 | 1475 | $info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns); |
1394 | 1476 | if ($ct >= 4) |
1395 | 1477 | { |
1396 | 1478 | // Extract alpha channel |
1397 | - if ( ! function_exists('gzuncompress')) |
|
1398 | - $this->Error('Zlib not available, can\'t handle alpha channel: '.$file); |
|
1479 | + if ( ! function_exists('gzuncompress')) { |
|
1480 | + $this->Error('Zlib not available, can\'t handle alpha channel: '.$file); |
|
1481 | + } |
|
1399 | 1482 | $data = gzuncompress($data); |
1400 | 1483 | $color = ''; |
1401 | 1484 | $alpha = ''; |
@@ -1429,8 +1512,9 @@ discard block |
||
1429 | 1512 | unset($data); |
1430 | 1513 | $data = gzcompress($color); |
1431 | 1514 | $info['smask'] = gzcompress($alpha); |
1432 | - if ($this->PDFVersion < '1.4') |
|
1433 | - $this->PDFVersion = '1.4'; |
|
1515 | + if ($this->PDFVersion < '1.4') { |
|
1516 | + $this->PDFVersion = '1.4'; |
|
1517 | + } |
|
1434 | 1518 | } |
1435 | 1519 | $info['data'] = $data; |
1436 | 1520 | return $info; |
@@ -1443,13 +1527,15 @@ discard block |
||
1443 | 1527 | while ($n > 0 && ! feof($f)) |
1444 | 1528 | { |
1445 | 1529 | $s = fread($f, $n); |
1446 | - if ($s === false) |
|
1447 | - $this->Error('Error while reading stream'); |
|
1530 | + if ($s === false) { |
|
1531 | + $this->Error('Error while reading stream'); |
|
1532 | + } |
|
1448 | 1533 | $n -= strlen($s); |
1449 | 1534 | $res .= $s; |
1450 | 1535 | } |
1451 | - if ($n > 0) |
|
1452 | - $this->Error('Unexpected end of stream'); |
|
1536 | + if ($n > 0) { |
|
1537 | + $this->Error('Unexpected end of stream'); |
|
1538 | + } |
|
1453 | 1539 | return $res; |
1454 | 1540 | } |
1455 | 1541 | |
@@ -1463,13 +1549,16 @@ discard block |
||
1463 | 1549 | function _parsegif($file) |
1464 | 1550 | { |
1465 | 1551 | // Extract info from a GIF file (via PNG conversion) |
1466 | - if ( ! function_exists('imagepng')) |
|
1467 | - $this->Error('GD extension is required for GIF support'); |
|
1468 | - if ( ! function_exists('imagecreatefromgif')) |
|
1469 | - $this->Error('GD has no GIF read support'); |
|
1552 | + if ( ! function_exists('imagepng')) { |
|
1553 | + $this->Error('GD extension is required for GIF support'); |
|
1554 | + } |
|
1555 | + if ( ! function_exists('imagecreatefromgif')) { |
|
1556 | + $this->Error('GD has no GIF read support'); |
|
1557 | + } |
|
1470 | 1558 | $im = imagecreatefromgif($file); |
1471 | - if ( ! $im) |
|
1472 | - $this->Error('Missing or incorrect image file: '.$file); |
|
1559 | + if ( ! $im) { |
|
1560 | + $this->Error('Missing or incorrect image file: '.$file); |
|
1561 | + } |
|
1473 | 1562 | imageinterlace($im, 0); |
1474 | 1563 | $f = @fopen('php://temp', 'rb+'); |
1475 | 1564 | if ($f) |
@@ -1483,15 +1572,16 @@ discard block |
||
1483 | 1572 | rewind($f); |
1484 | 1573 | $info = $this->_parsepngstream($f, $file); |
1485 | 1574 | fclose($f); |
1486 | - } |
|
1487 | - else |
|
1575 | + } else |
|
1488 | 1576 | { |
1489 | 1577 | // Use temporary file |
1490 | 1578 | $tmp = tempnam('.', 'gif'); |
1491 | - if ( ! $tmp) |
|
1492 | - $this->Error('Unable to create a temporary file'); |
|
1493 | - if ( ! imagepng($im, $tmp)) |
|
1494 | - $this->Error('Error while saving to temporary file'); |
|
1579 | + if ( ! $tmp) { |
|
1580 | + $this->Error('Unable to create a temporary file'); |
|
1581 | + } |
|
1582 | + if ( ! imagepng($im, $tmp)) { |
|
1583 | + $this->Error('Error while saving to temporary file'); |
|
1584 | + } |
|
1495 | 1585 | imagedestroy($im); |
1496 | 1586 | $info = $this->_parsepng($tmp); |
1497 | 1587 | unlink($tmp); |
@@ -1517,11 +1607,12 @@ discard block |
||
1517 | 1607 | function _out($s) |
1518 | 1608 | { |
1519 | 1609 | // Add a line to the document |
1520 | - if ($this->state == 2) |
|
1521 | - $this->pages[$this->page] .= $s."\n"; |
|
1522 | - else |
|
1523 | - $this->buffer .= $s."\n"; |
|
1524 | -} |
|
1610 | + if ($this->state == 2) { |
|
1611 | + $this->pages[$this->page] .= $s."\n"; |
|
1612 | + } else { |
|
1613 | + $this->buffer .= $s."\n"; |
|
1614 | + } |
|
1615 | + } |
|
1525 | 1616 | |
1526 | 1617 | function _putpages() |
1527 | 1618 | { |
@@ -1529,15 +1620,15 @@ discard block |
||
1529 | 1620 | if ( ! empty($this->AliasNbPages)) |
1530 | 1621 | { |
1531 | 1622 | // Replace number of pages |
1532 | - for ($n = 1; $n <= $nb; $n++) |
|
1533 | - $this->pages[$n] = str_replace($this->AliasNbPages, $nb, $this->pages[$n]); |
|
1623 | + for ($n = 1; $n <= $nb; $n++) { |
|
1624 | + $this->pages[$n] = str_replace($this->AliasNbPages, $nb, $this->pages[$n]); |
|
1625 | + } |
|
1534 | 1626 | } |
1535 | 1627 | if ($this->DefOrientation == 'P') |
1536 | 1628 | { |
1537 | 1629 | $wPt = $this->DefPageSize[0] * $this->k; |
1538 | 1630 | $hPt = $this->DefPageSize[1] * $this->k; |
1539 | - } |
|
1540 | - else |
|
1631 | + } else |
|
1541 | 1632 | { |
1542 | 1633 | $wPt = $this->DefPageSize[1] * $this->k; |
1543 | 1634 | $hPt = $this->DefPageSize[0] * $this->k; |
@@ -1549,8 +1640,9 @@ discard block |
||
1549 | 1640 | $this->_newobj(); |
1550 | 1641 | $this->_out('<</Type /Page'); |
1551 | 1642 | $this->_out('/Parent 1 0 R'); |
1552 | - if (isset($this->PageSizes[$n])) |
|
1553 | - $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $this->PageSizes[$n][0], $this->PageSizes[$n][1])); |
|
1643 | + if (isset($this->PageSizes[$n])) { |
|
1644 | + $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $this->PageSizes[$n][0], $this->PageSizes[$n][1])); |
|
1645 | + } |
|
1554 | 1646 | $this->_out('/Resources 2 0 R'); |
1555 | 1647 | if (isset($this->PageLinks[$n])) |
1556 | 1648 | { |
@@ -1560,9 +1652,9 @@ discard block |
||
1560 | 1652 | { |
1561 | 1653 | $rect = sprintf('%.2F %.2F %.2F %.2F', $pl[0], $pl[1], $pl[0] + $pl[2], $pl[1] - $pl[3]); |
1562 | 1654 | $annots .= '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] '; |
1563 | - if (is_string($pl[4])) |
|
1564 | - $annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
1565 | - else |
|
1655 | + if (is_string($pl[4])) { |
|
1656 | + $annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
1657 | + } else |
|
1566 | 1658 | { |
1567 | 1659 | $l = $this->links[$pl[4]]; |
1568 | 1660 | $h = isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt; |
@@ -1571,8 +1663,9 @@ discard block |
||
1571 | 1663 | } |
1572 | 1664 | $this->_out($annots.']'); |
1573 | 1665 | } |
1574 | - if ($this->PDFVersion > '1.3') |
|
1575 | - $this->_out('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>'); |
|
1666 | + if ($this->PDFVersion > '1.3') { |
|
1667 | + $this->_out('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>'); |
|
1668 | + } |
|
1576 | 1669 | $this->_out('/Contents '.($this->n + 1).' 0 R>>'); |
1577 | 1670 | $this->_out('endobj'); |
1578 | 1671 | // Page content |
@@ -1587,8 +1680,9 @@ discard block |
||
1587 | 1680 | $this->_out('1 0 obj'); |
1588 | 1681 | $this->_out('<</Type /Pages'); |
1589 | 1682 | $kids = '/Kids ['; |
1590 | - for ($i = 0; $i < $nb; $i++) |
|
1591 | - $kids .= (3 + 2 * $i).' 0 R '; |
|
1683 | + for ($i = 0; $i < $nb; $i++) { |
|
1684 | + $kids .= (3 + 2 * $i).' 0 R '; |
|
1685 | + } |
|
1592 | 1686 | $this->_out($kids.']'); |
1593 | 1687 | $this->_out('/Count '.$nb); |
1594 | 1688 | $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $wPt, $hPt)); |
@@ -1612,17 +1706,21 @@ discard block |
||
1612 | 1706 | $this->_newobj(); |
1613 | 1707 | $this->FontFiles[$file]['n'] = $this->n; |
1614 | 1708 | $font = file_get_contents($this->fontpath.$file, true); |
1615 | - if ( ! $font) |
|
1616 | - $this->Error('Font file not found: '.$file); |
|
1709 | + if ( ! $font) { |
|
1710 | + $this->Error('Font file not found: '.$file); |
|
1711 | + } |
|
1617 | 1712 | $compressed = (substr($file, -2) == '.z'); |
1618 | - if ( ! $compressed && isset($info['length2'])) |
|
1619 | - $font = substr($font, 6, $info['length1']).substr($font, 6 + $info['length1'] + 6, $info['length2']); |
|
1713 | + if ( ! $compressed && isset($info['length2'])) { |
|
1714 | + $font = substr($font, 6, $info['length1']).substr($font, 6 + $info['length1'] + 6, $info['length2']); |
|
1715 | + } |
|
1620 | 1716 | $this->_out('<</Length '.strlen($font)); |
1621 | - if ($compressed) |
|
1622 | - $this->_out('/Filter /FlateDecode'); |
|
1717 | + if ($compressed) { |
|
1718 | + $this->_out('/Filter /FlateDecode'); |
|
1719 | + } |
|
1623 | 1720 | $this->_out('/Length1 '.$info['length1']); |
1624 | - if (isset($info['length2'])) |
|
1625 | - $this->_out('/Length2 '.$info['length2'].' /Length3 0'); |
|
1721 | + if (isset($info['length2'])) { |
|
1722 | + $this->_out('/Length2 '.$info['length2'].' /Length3 0'); |
|
1723 | + } |
|
1626 | 1724 | $this->_out('>>'); |
1627 | 1725 | $this->_putstream($font); |
1628 | 1726 | $this->_out('endobj'); |
@@ -1640,12 +1738,12 @@ discard block |
||
1640 | 1738 | $this->_out('<</Type /Font'); |
1641 | 1739 | $this->_out('/BaseFont /'.$name); |
1642 | 1740 | $this->_out('/Subtype /Type1'); |
1643 | - if ($name != 'Symbol' && $name != 'ZapfDingbats') |
|
1644 | - $this->_out('/Encoding /WinAnsiEncoding'); |
|
1741 | + if ($name != 'Symbol' && $name != 'ZapfDingbats') { |
|
1742 | + $this->_out('/Encoding /WinAnsiEncoding'); |
|
1743 | + } |
|
1645 | 1744 | $this->_out('>>'); |
1646 | 1745 | $this->_out('endobj'); |
1647 | - } |
|
1648 | - elseif ($type == 'Type1' || $type == 'TrueType') |
|
1746 | + } elseif ($type == 'Type1' || $type == 'TrueType') |
|
1649 | 1747 | { |
1650 | 1748 | // Additional Type1 or TrueType/OpenType font |
1651 | 1749 | $this->_newobj(); |
@@ -1655,36 +1753,40 @@ discard block |
||
1655 | 1753 | $this->_out('/FirstChar 32 /LastChar 255'); |
1656 | 1754 | $this->_out('/Widths '.($this->n + 1).' 0 R'); |
1657 | 1755 | $this->_out('/FontDescriptor '.($this->n + 2).' 0 R'); |
1658 | - if (isset($font['diffn'])) |
|
1659 | - $this->_out('/Encoding '.($nf + $font['diffn']).' 0 R'); |
|
1660 | - else |
|
1661 | - $this->_out('/Encoding /WinAnsiEncoding'); |
|
1756 | + if (isset($font['diffn'])) { |
|
1757 | + $this->_out('/Encoding '.($nf + $font['diffn']).' 0 R'); |
|
1758 | + } else { |
|
1759 | + $this->_out('/Encoding /WinAnsiEncoding'); |
|
1760 | + } |
|
1662 | 1761 | $this->_out('>>'); |
1663 | 1762 | $this->_out('endobj'); |
1664 | 1763 | // Widths |
1665 | 1764 | $this->_newobj(); |
1666 | 1765 | $cw = &$font['cw']; |
1667 | 1766 | $s = '['; |
1668 | - for ($i = 32; $i <= 255; $i++) |
|
1669 | - $s .= $cw[chr($i)].' '; |
|
1767 | + for ($i = 32; $i <= 255; $i++) { |
|
1768 | + $s .= $cw[chr($i)].' '; |
|
1769 | + } |
|
1670 | 1770 | $this->_out($s.']'); |
1671 | 1771 | $this->_out('endobj'); |
1672 | 1772 | // Descriptor |
1673 | 1773 | $this->_newobj(); |
1674 | 1774 | $s = '<</Type /FontDescriptor /FontName /'.$name; |
1675 | - foreach ($font['desc'] as $k=>$v) |
|
1676 | - $s .= ' /'.$k.' '.$v; |
|
1677 | - if ( ! empty($font['file'])) |
|
1678 | - $s .= ' /FontFile'.($type == 'Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R'; |
|
1775 | + foreach ($font['desc'] as $k=>$v) { |
|
1776 | + $s .= ' /'.$k.' '.$v; |
|
1777 | + } |
|
1778 | + if ( ! empty($font['file'])) { |
|
1779 | + $s .= ' /FontFile'.($type == 'Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R'; |
|
1780 | + } |
|
1679 | 1781 | $this->_out($s.'>>'); |
1680 | 1782 | $this->_out('endobj'); |
1681 | - } |
|
1682 | - else |
|
1783 | + } else |
|
1683 | 1784 | { |
1684 | 1785 | // Allow for additional types |
1685 | 1786 | $mtd = '_put'.strtolower($type); |
1686 | - if ( ! method_exists($this, $mtd)) |
|
1687 | - $this->Error('Unsupported font type: '.$type); |
|
1787 | + if ( ! method_exists($this, $mtd)) { |
|
1788 | + $this->Error('Unsupported font type: '.$type); |
|
1789 | + } |
|
1688 | 1790 | $this->$mtd($font); |
1689 | 1791 | } |
1690 | 1792 | } |
@@ -1708,28 +1810,33 @@ discard block |
||
1708 | 1810 | $this->_out('/Subtype /Image'); |
1709 | 1811 | $this->_out('/Width '.$info['w']); |
1710 | 1812 | $this->_out('/Height '.$info['h']); |
1711 | - if ($info['cs'] == 'Indexed') |
|
1712 | - $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal']) / 3 - 1).' '.($this->n + 1).' 0 R]'); |
|
1713 | - else |
|
1813 | + if ($info['cs'] == 'Indexed') { |
|
1814 | + $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal']) / 3 - 1).' '.($this->n + 1).' 0 R]'); |
|
1815 | + } else |
|
1714 | 1816 | { |
1715 | 1817 | $this->_out('/ColorSpace /'.$info['cs']); |
1716 | - if ($info['cs'] == 'DeviceCMYK') |
|
1717 | - $this->_out('/Decode [1 0 1 0 1 0 1 0]'); |
|
1818 | + if ($info['cs'] == 'DeviceCMYK') { |
|
1819 | + $this->_out('/Decode [1 0 1 0 1 0 1 0]'); |
|
1820 | + } |
|
1718 | 1821 | } |
1719 | 1822 | $this->_out('/BitsPerComponent '.$info['bpc']); |
1720 | - if (isset($info['f'])) |
|
1721 | - $this->_out('/Filter /'.$info['f']); |
|
1722 | - if (isset($info['dp'])) |
|
1723 | - $this->_out('/DecodeParms <<'.$info['dp'].'>>'); |
|
1823 | + if (isset($info['f'])) { |
|
1824 | + $this->_out('/Filter /'.$info['f']); |
|
1825 | + } |
|
1826 | + if (isset($info['dp'])) { |
|
1827 | + $this->_out('/DecodeParms <<'.$info['dp'].'>>'); |
|
1828 | + } |
|
1724 | 1829 | if (isset($info['trns']) && is_array($info['trns'])) |
1725 | 1830 | { |
1726 | 1831 | $trns = ''; |
1727 | - for ($i = 0; $i < count($info['trns']); $i++) |
|
1728 | - $trns .= $info['trns'][$i].' '.$info['trns'][$i].' '; |
|
1832 | + for ($i = 0; $i < count($info['trns']); $i++) { |
|
1833 | + $trns .= $info['trns'][$i].' '.$info['trns'][$i].' '; |
|
1834 | + } |
|
1729 | 1835 | $this->_out('/Mask ['.$trns.']'); |
1730 | 1836 | } |
1731 | - if (isset($info['smask'])) |
|
1732 | - $this->_out('/SMask '.($this->n + 1).' 0 R'); |
|
1837 | + if (isset($info['smask'])) { |
|
1838 | + $this->_out('/SMask '.($this->n + 1).' 0 R'); |
|
1839 | + } |
|
1733 | 1840 | $this->_out('/Length '.strlen($info['data']).'>>'); |
1734 | 1841 | $this->_putstream($info['data']); |
1735 | 1842 | $this->_out('endobj'); |
@@ -1754,16 +1861,18 @@ discard block |
||
1754 | 1861 | |
1755 | 1862 | function _putxobjectdict() |
1756 | 1863 | { |
1757 | - foreach ($this->images as $image) |
|
1758 | - $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); |
|
1759 | -} |
|
1864 | + foreach ($this->images as $image) { |
|
1865 | + $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); |
|
1866 | + } |
|
1867 | + } |
|
1760 | 1868 | |
1761 | 1869 | function _putresourcedict() |
1762 | 1870 | { |
1763 | 1871 | $this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); |
1764 | 1872 | $this->_out('/Font <<'); |
1765 | - foreach ($this->fonts as $font) |
|
1766 | - $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); |
|
1873 | + foreach ($this->fonts as $font) { |
|
1874 | + $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); |
|
1875 | + } |
|
1767 | 1876 | $this->_out('>>'); |
1768 | 1877 | $this->_out('/XObject <<'); |
1769 | 1878 | $this->_putxobjectdict(); |
@@ -1786,16 +1895,21 @@ discard block |
||
1786 | 1895 | function _putinfo() |
1787 | 1896 | { |
1788 | 1897 | $this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION)); |
1789 | - if ( ! empty($this->title)) |
|
1790 | - $this->_out('/Title '.$this->_textstring($this->title)); |
|
1791 | - if ( ! empty($this->subject)) |
|
1792 | - $this->_out('/Subject '.$this->_textstring($this->subject)); |
|
1793 | - if ( ! empty($this->author)) |
|
1794 | - $this->_out('/Author '.$this->_textstring($this->author)); |
|
1795 | - if ( ! empty($this->keywords)) |
|
1796 | - $this->_out('/Keywords '.$this->_textstring($this->keywords)); |
|
1797 | - if ( ! empty($this->creator)) |
|
1798 | - $this->_out('/Creator '.$this->_textstring($this->creator)); |
|
1898 | + if ( ! empty($this->title)) { |
|
1899 | + $this->_out('/Title '.$this->_textstring($this->title)); |
|
1900 | + } |
|
1901 | + if ( ! empty($this->subject)) { |
|
1902 | + $this->_out('/Subject '.$this->_textstring($this->subject)); |
|
1903 | + } |
|
1904 | + if ( ! empty($this->author)) { |
|
1905 | + $this->_out('/Author '.$this->_textstring($this->author)); |
|
1906 | + } |
|
1907 | + if ( ! empty($this->keywords)) { |
|
1908 | + $this->_out('/Keywords '.$this->_textstring($this->keywords)); |
|
1909 | + } |
|
1910 | + if ( ! empty($this->creator)) { |
|
1911 | + $this->_out('/Creator '.$this->_textstring($this->creator)); |
|
1912 | + } |
|
1799 | 1913 | $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis'))); |
1800 | 1914 | } |
1801 | 1915 | |
@@ -1803,21 +1917,23 @@ discard block |
||
1803 | 1917 | { |
1804 | 1918 | $this->_out('/Type /Catalog'); |
1805 | 1919 | $this->_out('/Pages 1 0 R'); |
1806 | - if ($this->ZoomMode == 'fullpage') |
|
1807 | - $this->_out('/OpenAction [3 0 R /Fit]'); |
|
1808 | - elseif ($this->ZoomMode == 'fullwidth') |
|
1809 | - $this->_out('/OpenAction [3 0 R /FitH null]'); |
|
1810 | - elseif ($this->ZoomMode == 'real') |
|
1811 | - $this->_out('/OpenAction [3 0 R /XYZ null null 1]'); |
|
1812 | - elseif ( ! is_string($this->ZoomMode)) |
|
1813 | - $this->_out('/OpenAction [3 0 R /XYZ null null '.sprintf('%.2F', $this->ZoomMode / 100).']'); |
|
1814 | - if ($this->LayoutMode == 'single') |
|
1815 | - $this->_out('/PageLayout /SinglePage'); |
|
1816 | - elseif ($this->LayoutMode == 'continuous') |
|
1817 | - $this->_out('/PageLayout /OneColumn'); |
|
1818 | - elseif ($this->LayoutMode == 'two') |
|
1819 | - $this->_out('/PageLayout /TwoColumnLeft'); |
|
1820 | -} |
|
1920 | + if ($this->ZoomMode == 'fullpage') { |
|
1921 | + $this->_out('/OpenAction [3 0 R /Fit]'); |
|
1922 | + } elseif ($this->ZoomMode == 'fullwidth') { |
|
1923 | + $this->_out('/OpenAction [3 0 R /FitH null]'); |
|
1924 | + } elseif ($this->ZoomMode == 'real') { |
|
1925 | + $this->_out('/OpenAction [3 0 R /XYZ null null 1]'); |
|
1926 | + } elseif ( ! is_string($this->ZoomMode)) { |
|
1927 | + $this->_out('/OpenAction [3 0 R /XYZ null null '.sprintf('%.2F', $this->ZoomMode / 100).']'); |
|
1928 | + } |
|
1929 | + if ($this->LayoutMode == 'single') { |
|
1930 | + $this->_out('/PageLayout /SinglePage'); |
|
1931 | + } elseif ($this->LayoutMode == 'continuous') { |
|
1932 | + $this->_out('/PageLayout /OneColumn'); |
|
1933 | + } elseif ($this->LayoutMode == 'two') { |
|
1934 | + $this->_out('/PageLayout /TwoColumnLeft'); |
|
1935 | + } |
|
1936 | + } |
|
1821 | 1937 | |
1822 | 1938 | function _putheader() |
1823 | 1939 | { |
@@ -1853,8 +1969,9 @@ discard block |
||
1853 | 1969 | $this->_out('xref'); |
1854 | 1970 | $this->_out('0 '.($this->n + 1)); |
1855 | 1971 | $this->_out('0000000000 65535 f '); |
1856 | - for ($i = 1; $i <= $this->n; $i++) |
|
1857 | - $this->_out(sprintf('%010d 00000 n ', $this->offsets[$i])); |
|
1972 | + for ($i = 1; $i <= $this->n; $i++) { |
|
1973 | + $this->_out(sprintf('%010d 00000 n ', $this->offsets[$i])); |
|
1974 | + } |
|
1858 | 1975 | // Trailer |
1859 | 1976 | $this->_out('trailer'); |
1860 | 1977 | $this->_out('<<'); |
@@ -461,6 +461,7 @@ |
||
461 | 461 | * @param string the file path |
462 | 462 | * @param string the permissions |
463 | 463 | * @param integer $perm |
464 | + * @param string $path |
|
464 | 465 | * @return bool |
465 | 466 | */ |
466 | 467 | function chmod($path, $perm) |
@@ -227,6 +227,7 @@ |
||
227 | 227 | * |
228 | 228 | * @access private |
229 | 229 | * @return string |
230 | + * @param integer $b |
|
230 | 231 | */ |
231 | 232 | function _zero_fill($a, $b) |
232 | 233 | { |
@@ -381,6 +381,9 @@ |
||
381 | 381 | return $this->sendPayload($msg); |
382 | 382 | } |
383 | 383 | |
384 | + /** |
|
385 | + * @param XML_RPC_Message $msg |
|
386 | + */ |
|
384 | 387 | function sendPayload($msg) |
385 | 388 | { |
386 | 389 | $fp = @fsockopen($this->server, $this->port, $this->errno, $this->errstr, $this->timeout); |
@@ -1234,11 +1234,11 @@ |
||
1234 | 1234 | /** |
1235 | 1235 | * @param integer $val |
1236 | 1236 | */ |
1237 | - function addScalar($val, $type='string') |
|
1237 | + function addScalar($val, $type = 'string') |
|
1238 | 1238 | { |
1239 | 1239 | $typeof = $this->xmlrpcTypes[$type]; |
1240 | 1240 | |
1241 | - if ($this->mytype==1) |
|
1241 | + if ($this->mytype == 1) |
|
1242 | 1242 | { |
1243 | 1243 | echo '<strong>XML_RPC_Values</strong>: scalar can have only one value<br />'; |
1244 | 1244 | return 0; |
@@ -443,14 +443,12 @@ discard block |
||
443 | 443 | // error |
444 | 444 | $this->errno = $code; |
445 | 445 | $this->errstr = htmlentities($fstr); |
446 | - } |
|
447 | - else if ( ! is_object($val)) |
|
446 | + } else if ( ! is_object($val)) |
|
448 | 447 | { |
449 | 448 | // programmer error, not an object |
450 | 449 | error_log("Invalid type '".gettype($val)."' (value: $val) passed to XML_RPC_Response. Defaulting to empty value."); |
451 | 450 | $this->val = new XML_RPC_Values(); |
452 | - } |
|
453 | - else |
|
451 | + } else |
|
454 | 452 | { |
455 | 453 | $this->val = $val; |
456 | 454 | } |
@@ -979,50 +977,42 @@ discard block |
||
979 | 977 | if ($name == 'STRING') |
980 | 978 | { |
981 | 979 | $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac']; |
982 | - } |
|
983 | - elseif ($name == 'DATETIME.ISO8601') |
|
980 | + } elseif ($name == 'DATETIME.ISO8601') |
|
984 | 981 | { |
985 | 982 | $this->xh[$the_parser]['vt'] = $this->xmlrpcDateTime; |
986 | 983 | $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac']; |
987 | - } |
|
988 | - elseif ($name == 'BASE64') |
|
984 | + } elseif ($name == 'BASE64') |
|
989 | 985 | { |
990 | 986 | $this->xh[$the_parser]['value'] = base64_decode($this->xh[$the_parser]['ac']); |
991 | - } |
|
992 | - elseif ($name == 'BOOLEAN') |
|
987 | + } elseif ($name == 'BOOLEAN') |
|
993 | 988 | { |
994 | 989 | // Translated BOOLEAN values to TRUE AND FALSE |
995 | 990 | if ($this->xh[$the_parser]['ac'] == '1') |
996 | 991 | { |
997 | 992 | $this->xh[$the_parser]['value'] = TRUE; |
998 | - } |
|
999 | - else |
|
993 | + } else |
|
1000 | 994 | { |
1001 | 995 | $this->xh[$the_parser]['value'] = FALSE; |
1002 | 996 | } |
1003 | - } |
|
1004 | - elseif ($name == 'DOUBLE') |
|
997 | + } elseif ($name == 'DOUBLE') |
|
1005 | 998 | { |
1006 | 999 | // we have a DOUBLE |
1007 | 1000 | // we must check that only 0123456789-.<space> are characters here |
1008 | 1001 | if ( ! preg_match('/^[+-]?[eE0-9\t \.]+$/', $this->xh[$the_parser]['ac'])) |
1009 | 1002 | { |
1010 | 1003 | $this->xh[$the_parser]['value'] = 'ERROR_NON_NUMERIC_FOUND'; |
1011 | - } |
|
1012 | - else |
|
1004 | + } else |
|
1013 | 1005 | { |
1014 | 1006 | $this->xh[$the_parser]['value'] = (double)$this->xh[$the_parser]['ac']; |
1015 | 1007 | } |
1016 | - } |
|
1017 | - else |
|
1008 | + } else |
|
1018 | 1009 | { |
1019 | 1010 | // we have an I4/INT |
1020 | 1011 | // we must check that only 0123456789-<space> are characters here |
1021 | 1012 | if ( ! preg_match('/^[+-]?[0-9\t ]+$/', $this->xh[$the_parser]['ac'])) |
1022 | 1013 | { |
1023 | 1014 | $this->xh[$the_parser]['value'] = 'ERROR_NON_NUMERIC_FOUND'; |
1024 | - } |
|
1025 | - else |
|
1015 | + } else |
|
1026 | 1016 | { |
1027 | 1017 | $this->xh[$the_parser]['value'] = (int)$this->xh[$the_parser]['ac']; |
1028 | 1018 | } |
@@ -1219,12 +1209,10 @@ discard block |
||
1219 | 1209 | if ($this->xmlrpcTypes[$type] == 1) |
1220 | 1210 | { |
1221 | 1211 | $this->addScalar($val, $type); |
1222 | - } |
|
1223 | - elseif ($this->xmlrpcTypes[$type] == 2) |
|
1212 | + } elseif ($this->xmlrpcTypes[$type] == 2) |
|
1224 | 1213 | { |
1225 | 1214 | $this->addArray($val); |
1226 | - } |
|
1227 | - elseif ($this->xmlrpcTypes[$type] == 3) |
|
1215 | + } elseif ($this->xmlrpcTypes[$type] == 3) |
|
1228 | 1216 | { |
1229 | 1217 | $this->addStruct($val); |
1230 | 1218 | } |
@@ -22,133 +22,133 @@ |
||
22 | 22 | ############################################################################### |
23 | 23 | |
24 | 24 | class Astpp_common extends CI_Model { |
25 | - // ------------------------------------------------------------------------ |
|
26 | - /** |
|
27 | - * initialises the class inheriting the methods of the class Model |
|
28 | - * |
|
29 | - * @return Usermodel |
|
30 | - */ |
|
31 | - function Astpp_common() { |
|
32 | - parent::__construct(); |
|
33 | - } |
|
34 | - /** |
|
35 | - * -------Here we write code for model astpp_common_model functions list_applyable_charges------ |
|
36 | - * Purpose: build array for applyable charge dropdown list. |
|
37 | - * @param |
|
38 | - * @return return array of applyable chargelist. |
|
39 | - */ |
|
40 | - function list_applyable_charges($accountid = '') { |
|
41 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
42 | - $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0; |
|
25 | + // ------------------------------------------------------------------------ |
|
26 | + /** |
|
27 | + * initialises the class inheriting the methods of the class Model |
|
28 | + * |
|
29 | + * @return Usermodel |
|
30 | + */ |
|
31 | + function Astpp_common() { |
|
32 | + parent::__construct(); |
|
33 | + } |
|
34 | + /** |
|
35 | + * -------Here we write code for model astpp_common_model functions list_applyable_charges------ |
|
36 | + * Purpose: build array for applyable charge dropdown list. |
|
37 | + * @param |
|
38 | + * @return return array of applyable chargelist. |
|
39 | + */ |
|
40 | + function list_applyable_charges($accountid = '') { |
|
41 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
42 | + $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0; |
|
43 | 43 | $q = " SELECT * FROM `charges` where reseller_id =$reseller_id and id NOT IN(select charge_id from charge_to_account where accountid =$accountid) AND pricelist_id = '0'"; |
44 | - $item_arr = array(); |
|
45 | - $query = $this->db->query($q); |
|
46 | - if ($query->num_rows() > 0) { |
|
47 | - foreach ($query->result_array() as $row) { |
|
48 | - if ($row['charge'] > 0) { |
|
49 | - $row['charge'] = $this->common_model->calculate_currency($row['charge']); |
|
50 | - } |
|
51 | - $item_arr[$row['id']] = $row['description'].' - '.$row['charge']; |
|
52 | - } |
|
53 | - } |
|
54 | - return $item_arr; |
|
55 | - } |
|
56 | - function quote($inp) { |
|
57 | - return "'".$this->db->escape_str($inp)."'"; |
|
58 | - } |
|
44 | + $item_arr = array(); |
|
45 | + $query = $this->db->query($q); |
|
46 | + if ($query->num_rows() > 0) { |
|
47 | + foreach ($query->result_array() as $row) { |
|
48 | + if ($row['charge'] > 0) { |
|
49 | + $row['charge'] = $this->common_model->calculate_currency($row['charge']); |
|
50 | + } |
|
51 | + $item_arr[$row['id']] = $row['description'].' - '.$row['charge']; |
|
52 | + } |
|
53 | + } |
|
54 | + return $item_arr; |
|
55 | + } |
|
56 | + function quote($inp) { |
|
57 | + return "'".$this->db->escape_str($inp)."'"; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param string $q |
|
62 | - * @param string $colname |
|
63 | - */ |
|
64 | - function db_get_item($q, $colname) { |
|
65 | - $item_arr = array(); |
|
66 | - $query = $this->db->query($q); |
|
67 | - if ($query->num_rows() > 0) { |
|
68 | - $row = $query->row_array(); |
|
69 | - return $row[$colname]; |
|
70 | - } |
|
71 | - return ''; |
|
72 | - } |
|
73 | - // Return the balance for a specific ASTPP account. |
|
74 | - function accountbalance($account) { |
|
75 | - $debit = 0; |
|
76 | - $q = "SELECT SUM(debit) as val1 FROM cdrs WHERE accountid=".$this->quote($account)." AND status NOT IN (1, 2)"; |
|
77 | - $query = $this->db->query($q); |
|
78 | - if ($query->num_rows() > 0) { |
|
79 | - $row = $query->row_array(); |
|
80 | - $debit = $row['val1']; |
|
81 | - } |
|
82 | - $credit = 0; |
|
83 | - $q = "SELECT SUM(credit) as val1 FROM cdrs WHERE accountid= ".$this->quote($account)." AND status NOT IN (1, 2)"; |
|
84 | - $query = $this->db->query($q); |
|
85 | - if ($query->num_rows() > 0) { |
|
86 | - $row = $query->row_array(); |
|
87 | - $credit = $row['val1']; |
|
88 | - } |
|
89 | - $posted_balance = 0; |
|
90 | - $q = "SELECT * FROM accounts WHERE id = ".$this->quote($account); |
|
91 | - $query = $this->db->query($q); |
|
92 | - if ($query->num_rows() > 0) { |
|
93 | - $row = $query->row_array(); |
|
94 | - $posted_balance = $row['balance']; |
|
95 | - } |
|
96 | - $balance = ($debit - $credit + $posted_balance); |
|
97 | - return $balance; |
|
98 | - } |
|
99 | - function accounts_total_balance($reseller) { |
|
100 | - $debit = 0; |
|
101 | - $credit = 0; |
|
102 | - if ($reseller == "") { |
|
103 | - $q = "SELECT SUM(debit) as val1 FROM cdrs WHERE status NOT IN (1, 2)"; |
|
104 | - $debit = $this->db_get_item($q, 'val1'); |
|
60 | + /** |
|
61 | + * @param string $q |
|
62 | + * @param string $colname |
|
63 | + */ |
|
64 | + function db_get_item($q, $colname) { |
|
65 | + $item_arr = array(); |
|
66 | + $query = $this->db->query($q); |
|
67 | + if ($query->num_rows() > 0) { |
|
68 | + $row = $query->row_array(); |
|
69 | + return $row[$colname]; |
|
70 | + } |
|
71 | + return ''; |
|
72 | + } |
|
73 | + // Return the balance for a specific ASTPP account. |
|
74 | + function accountbalance($account) { |
|
75 | + $debit = 0; |
|
76 | + $q = "SELECT SUM(debit) as val1 FROM cdrs WHERE accountid=".$this->quote($account)." AND status NOT IN (1, 2)"; |
|
77 | + $query = $this->db->query($q); |
|
78 | + if ($query->num_rows() > 0) { |
|
79 | + $row = $query->row_array(); |
|
80 | + $debit = $row['val1']; |
|
81 | + } |
|
82 | + $credit = 0; |
|
83 | + $q = "SELECT SUM(credit) as val1 FROM cdrs WHERE accountid= ".$this->quote($account)." AND status NOT IN (1, 2)"; |
|
84 | + $query = $this->db->query($q); |
|
85 | + if ($query->num_rows() > 0) { |
|
86 | + $row = $query->row_array(); |
|
87 | + $credit = $row['val1']; |
|
88 | + } |
|
89 | + $posted_balance = 0; |
|
90 | + $q = "SELECT * FROM accounts WHERE id = ".$this->quote($account); |
|
91 | + $query = $this->db->query($q); |
|
92 | + if ($query->num_rows() > 0) { |
|
93 | + $row = $query->row_array(); |
|
94 | + $posted_balance = $row['balance']; |
|
95 | + } |
|
96 | + $balance = ($debit - $credit + $posted_balance); |
|
97 | + return $balance; |
|
98 | + } |
|
99 | + function accounts_total_balance($reseller) { |
|
100 | + $debit = 0; |
|
101 | + $credit = 0; |
|
102 | + if ($reseller == "") { |
|
103 | + $q = "SELECT SUM(debit) as val1 FROM cdrs WHERE status NOT IN (1, 2)"; |
|
104 | + $debit = $this->db_get_item($q, 'val1'); |
|
105 | 105 | |
106 | - $q = "SELECT SUM(credit) as val1 FROM cdrs WHERE status NOT IN (1, 2)"; |
|
107 | - $credit = $this->db_get_item($q, 'val1'); |
|
106 | + $q = "SELECT SUM(credit) as val1 FROM cdrs WHERE status NOT IN (1, 2)"; |
|
107 | + $credit = $this->db_get_item($q, 'val1'); |
|
108 | 108 | |
109 | - $tmp = "SELECT SUM(balance) as val1 FROM accounts WHERE reseller_id = ''"; |
|
110 | - } else { |
|
111 | - $tmp = "SELECT SUM(balance) as val1 FROM accounts WHERE reseller_id = ".$this->quote($reseller); |
|
112 | - } |
|
113 | - $posted_balance = $this->db_get_item($tmp, "val1"); |
|
109 | + $tmp = "SELECT SUM(balance) as val1 FROM accounts WHERE reseller_id = ''"; |
|
110 | + } else { |
|
111 | + $tmp = "SELECT SUM(balance) as val1 FROM accounts WHERE reseller_id = ".$this->quote($reseller); |
|
112 | + } |
|
113 | + $posted_balance = $this->db_get_item($tmp, "val1"); |
|
114 | 114 | |
115 | - $balance = ($debit - $credit + $posted_balance); |
|
116 | - return $balance; |
|
117 | - } |
|
118 | - function count_dids($test) { |
|
119 | - $tmp = "SELECT COUNT(*) as val1 FROM dids ".$test; |
|
120 | - return $this->db_get_item($tmp, 'val1'); |
|
121 | - } |
|
115 | + $balance = ($debit - $credit + $posted_balance); |
|
116 | + return $balance; |
|
117 | + } |
|
118 | + function count_dids($test) { |
|
119 | + $tmp = "SELECT COUNT(*) as val1 FROM dids ".$test; |
|
120 | + return $this->db_get_item($tmp, 'val1'); |
|
121 | + } |
|
122 | 122 | |
123 | - function count_callingcards($where, $field = 'COUNT(*)') { |
|
124 | - $tmp = "SELECT $field as val FROM callingcards ".$where; |
|
125 | - return $this->db_get_item($tmp, 'val'); |
|
126 | - } |
|
123 | + function count_callingcards($where, $field = 'COUNT(*)') { |
|
124 | + $tmp = "SELECT $field as val FROM callingcards ".$where; |
|
125 | + return $this->db_get_item($tmp, 'val'); |
|
126 | + } |
|
127 | 127 | |
128 | - function count_accounts($test) { |
|
129 | - $tmp = "SELECT COUNT(*) as val1 FROM accounts ".$test; |
|
130 | - return $this->db_get_item($tmp, 'val1'); |
|
131 | - } |
|
128 | + function count_accounts($test) { |
|
129 | + $tmp = "SELECT COUNT(*) as val1 FROM accounts ".$test; |
|
130 | + return $this->db_get_item($tmp, 'val1'); |
|
131 | + } |
|
132 | 132 | |
133 | - function count_rategroup($test) { |
|
133 | + function count_rategroup($test) { |
|
134 | 134 | $tmp = "SELECT COUNT(*) as val1 FROM pricelists ".$test; |
135 | - return $this->db_get_item($tmp, 'val1'); |
|
136 | - } |
|
135 | + return $this->db_get_item($tmp, 'val1'); |
|
136 | + } |
|
137 | 137 | |
138 | - function count_termination($test = '') { |
|
138 | + function count_termination($test = '') { |
|
139 | 139 | $tmp = "SELECT COUNT(*) as val1 FROM outbound_routes ".$test; |
140 | - return $this->db_get_item($tmp, 'val1'); |
|
141 | - } |
|
140 | + return $this->db_get_item($tmp, 'val1'); |
|
141 | + } |
|
142 | 142 | |
143 | - function count_trunk($test = '') { |
|
143 | + function count_trunk($test = '') { |
|
144 | 144 | $tmp = "SELECT COUNT(*) as val1 FROM trunks ".$test; |
145 | - return $this->db_get_item($tmp, 'val1'); |
|
146 | - } |
|
145 | + return $this->db_get_item($tmp, 'val1'); |
|
146 | + } |
|
147 | 147 | |
148 | - function count_origination($test = '') { |
|
148 | + function count_origination($test = '') { |
|
149 | 149 | $tmp = "SELECT COUNT(*) as val1 FROM routes ".$test; |
150 | - return $this->db_get_item($tmp, 'val1'); |
|
151 | - } |
|
150 | + return $this->db_get_item($tmp, 'val1'); |
|
151 | + } |
|
152 | 152 | |
153 | 153 | } |
154 | 154 | ?> |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $amount_operator = $taxes_search['amount_operator']; |
126 | 126 | |
127 | - if (!empty($taxes_search['amount'])) { |
|
127 | + if ( ! empty($taxes_search['amount'])) { |
|
128 | 128 | switch ($amount_operator) { |
129 | 129 | case "1": |
130 | 130 | $this->db->where('taxes_amount ', $taxes_search['amount']); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | $rate_operator = $taxes_search['rate_operator']; |
151 | 151 | |
152 | - if (!empty($taxes_search['rate'])) { |
|
152 | + if ( ! empty($taxes_search['rate'])) { |
|
153 | 153 | switch ($rate_operator) { |
154 | 154 | case "1": |
155 | 155 | $this->db->where('taxes_rate ', $taxes_search['rate']); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | $description_operator = $taxes_search['description_operator']; |
176 | - if (!empty($taxes_search['description'])) { |
|
176 | + if ( ! empty($taxes_search['description'])) { |
|
177 | 177 | switch ($description_operator) { |
178 | 178 | case "1": |
179 | 179 | $this->db->like('taxes_description', $taxes_search['description']); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | |
203 | 203 | $amount_operator = $taxes_search['amount_operator']; |
204 | 204 | |
205 | - if (!empty($taxes_search['amount'])) { |
|
205 | + if ( ! empty($taxes_search['amount'])) { |
|
206 | 206 | switch ($amount_operator) { |
207 | 207 | case "1": |
208 | 208 | $this->db->where('taxes_amount =', $taxes_search['amount']); |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | |
228 | 228 | $rate_operator = $taxes_search['rate_operator']; |
229 | 229 | |
230 | - if (!empty($taxes_search['rate'])) { |
|
230 | + if ( ! empty($taxes_search['rate'])) { |
|
231 | 231 | switch ($rate_operator) { |
232 | 232 | case "1": |
233 | 233 | $this->db->where('taxes_rate == ', $taxes_search['rate']); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | } |
252 | 252 | |
253 | 253 | $description_operator = $taxes_search['description_operator']; |
254 | - if (!empty($taxes_search['description'])) { |
|
254 | + if ( ! empty($taxes_search['description'])) { |
|
255 | 255 | switch ($description_operator) { |
256 | 256 | case "1": |
257 | 257 | $this->db->like('taxes_description', $taxes_search['description']); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | $template_name_operator = $templatesearch['template_name_operator']; |
300 | 300 | |
301 | 301 | |
302 | - if (!empty($templatesearch['template_name'])) { |
|
302 | + if ( ! empty($templatesearch['template_name'])) { |
|
303 | 303 | switch ($template_name_operator) { |
304 | 304 | case "1": |
305 | 305 | $this->db->like('name', $templatesearch['template_name']); |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | } |
318 | 318 | |
319 | 319 | $template_subject = $templatesearch['subject_operator']; |
320 | - if (!empty($templatesearch['subject'])) { |
|
320 | + if ( ! empty($templatesearch['subject'])) { |
|
321 | 321 | switch ($template_subject) { |
322 | 322 | case "1": |
323 | 323 | $this->db->like('subject', $templatesearch['subject']); |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | } |
335 | 335 | } |
336 | 336 | $template_op = $templatesearch['template_operator']; |
337 | - if (!empty($templatesearch['template_desc'])) { |
|
337 | + if ( ! empty($templatesearch['template_desc'])) { |
|
338 | 338 | |
339 | 339 | switch ($template_op) { |
340 | 340 | case "1": |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | } |
354 | 354 | |
355 | 355 | |
356 | - if (!empty($templatesearch['accountid'])) { |
|
356 | + if ( ! empty($templatesearch['accountid'])) { |
|
357 | 357 | $this->db->like('accountid', $templatesearch['accountid']); |
358 | 358 | } |
359 | 359 | } |
@@ -395,19 +395,19 @@ discard block |
||
395 | 395 | if ($this->session->userdata('advance_search') == 1) { |
396 | 396 | $configuration_search = $this->session->userdata('configuration_search'); |
397 | 397 | |
398 | - if (!empty($configuration_search['reseller'])) { |
|
398 | + if ( ! empty($configuration_search['reseller'])) { |
|
399 | 399 | $this->db->where('reseller ', $configuration_search['reseller']); |
400 | 400 | } |
401 | - if (!empty($configuration_search['brand'])) { |
|
401 | + if ( ! empty($configuration_search['brand'])) { |
|
402 | 402 | $this->db->where('brand', $configuration_search['brand']); |
403 | 403 | } |
404 | - if (!empty($configuration_search['group_title'])) { |
|
404 | + if ( ! empty($configuration_search['group_title'])) { |
|
405 | 405 | $this->db->where('group_title', $configuration_search['group_title']); |
406 | 406 | } |
407 | 407 | |
408 | 408 | $name_operator = $configuration_search['name_operator']; |
409 | 409 | |
410 | - if (!empty($configuration_search['name'])) { |
|
410 | + if ( ! empty($configuration_search['name'])) { |
|
411 | 411 | switch ($name_operator) { |
412 | 412 | case "1": |
413 | 413 | $this->db->like('name', $configuration_search['name']); |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | |
427 | 427 | $value_operator = $configuration_search['value_operator']; |
428 | 428 | |
429 | - if (!empty($configuration_search['value'])) { |
|
429 | + if ( ! empty($configuration_search['value'])) { |
|
430 | 430 | switch ($value_operator) { |
431 | 431 | case "1": |
432 | 432 | $this->db->like('value', $configuration_search['value']); |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | |
446 | 446 | $comment_operator = $configuration_search['comment_operator']; |
447 | 447 | |
448 | - if (!empty($configuration_search['comment'])) { |
|
448 | + if ( ! empty($configuration_search['comment'])) { |
|
449 | 449 | switch ($comment_operator) { |
450 | 450 | case "1": |
451 | 451 | $this->db->like('comment', $configuration_search['comment']); |
@@ -51,10 +51,11 @@ discard block |
||
51 | 51 | $this->db->where("id", $id); |
52 | 52 | $query = $this->db->get("system"); |
53 | 53 | |
54 | - if ($query->num_rows() > 0) |
|
55 | - return $query->row_array(); |
|
56 | - else |
|
57 | - return false; |
|
54 | + if ($query->num_rows() > 0) { |
|
55 | + return $query->row_array(); |
|
56 | + } else { |
|
57 | + return false; |
|
58 | + } |
|
58 | 59 | } |
59 | 60 | |
60 | 61 | function remove_config($data) { |
@@ -89,10 +90,11 @@ discard block |
||
89 | 90 | $this->db->where("taxes_id", $id); |
90 | 91 | $query = $this->db->get("taxes"); |
91 | 92 | |
92 | - if ($query->num_rows() > 0) |
|
93 | - return $query->row_array(); |
|
94 | - else |
|
95 | - return false; |
|
93 | + if ($query->num_rows() > 0) { |
|
94 | + return $query->row_array(); |
|
95 | + } else { |
|
96 | + return false; |
|
97 | + } |
|
96 | 98 | } |
97 | 99 | |
98 | 100 | function remove_tax($data) { |
@@ -373,10 +375,11 @@ discard block |
||
373 | 375 | function get_template_by_id_all($id) { |
374 | 376 | $this->db->where('id', $id); |
375 | 377 | $query = $this->db->get('templates'); |
376 | - if ($query->num_rows() > 0) |
|
377 | - return $query->row_array(); |
|
378 | - else |
|
379 | - return false; |
|
378 | + if ($query->num_rows() > 0) { |
|
379 | + return $query->row_array(); |
|
380 | + } else { |
|
381 | + return false; |
|
382 | + } |
|
380 | 383 | } |
381 | 384 | |
382 | 385 | function edit_template($edit_id, $data) { |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $this->db->select($select); |
87 | 87 | $this->db->from($tableName); |
88 | 88 | $this->db->where($where); |
89 | - $this->db->order_by($order_by,$order_type); |
|
89 | + $this->db->order_by($order_by, $order_type); |
|
90 | 90 | $query = $this->db->get(); |
91 | 91 | return $query; |
92 | 92 | } |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | |
137 | 137 | if ($paging_limit) |
138 | 138 | $this->db->limit($paging_limit, $start_limit); |
139 | - if (!empty($groupby)) |
|
139 | + if ( ! empty($groupby)) |
|
140 | 140 | $this->db->group_by($groupby); |
141 | - if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
|
142 | - $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
|
143 | - }else{ |
|
144 | - if($order_by) |
|
141 | + if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined') { |
|
142 | + $this->db->order_by($_GET['sortname'], ($_GET['sortorder'] == 'undefined') ? 'desc' : $_GET['sortorder']); |
|
143 | + } else { |
|
144 | + if ($order_by) |
|
145 | 145 | $this->db->order_by($order_by, $order_type); |
146 | 146 | } |
147 | 147 | $query = $this->db->get(); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $this->db->order_by($order_by, $order_type); |
163 | 163 | if ($paging_limit) |
164 | 164 | $this->db->limit($paging_limit, $start_limit); |
165 | - if (!empty($groupby)) |
|
165 | + if ( ! empty($groupby)) |
|
166 | 166 | $this->db->groupby($groupby); |
167 | 167 | $query = $this->db->get(); |
168 | 168 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | if ($where != "") { |
193 | 193 | $this->db->where($where); |
194 | 194 | } |
195 | - if (!empty($where_in)) { |
|
195 | + if ( ! empty($where_in)) { |
|
196 | 196 | $this->db->where_in($key, $where_in); |
197 | 197 | } |
198 | 198 | $this->db->from($table); |
@@ -244,18 +244,18 @@ discard block |
||
244 | 244 | * ******************************************************** */ |
245 | 245 | |
246 | 246 | function getJionQuery($table, $feild, $where = "", $jionTable, $jionCondition, $type = 'inner', $start = '', $end = '', $order_type = '', $order_by = '', $group_by = '') { |
247 | - $start = (int) $start; |
|
248 | - $end = (int) $end; |
|
247 | + $start = (int)$start; |
|
248 | + $end = (int)$end; |
|
249 | 249 | $this->db->select($feild); |
250 | 250 | $this->db->from($table); |
251 | 251 | $this->db->join($jionTable, $jionCondition, $type); |
252 | 252 | if ($where != "") { |
253 | 253 | $this->db->where($where); |
254 | 254 | } |
255 | - if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
|
256 | - $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
|
257 | - }else{ |
|
258 | - if($order_by) |
|
255 | + if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined') { |
|
256 | + $this->db->order_by($_GET['sortname'], ($_GET['sortorder'] == 'undefined') ? 'desc' : $_GET['sortorder']); |
|
257 | + } else { |
|
258 | + if ($order_by) |
|
259 | 259 | $this->db->order_by($order_by, $order_type); |
260 | 260 | } |
261 | 261 | |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | } |
270 | 270 | |
271 | 271 | function getJionQueryCount($table, $feild, $where = "", $jionTable, $jionCondition, $type = 'inner', $start = '', $end = '', $order_type = '', $order_by = '', $group_by = '') { |
272 | - $start = (int) $start; |
|
273 | - $end = (int) $end; |
|
272 | + $start = (int)$start; |
|
273 | + $end = (int)$end; |
|
274 | 274 | $this->db->select($feild); |
275 | 275 | $this->db->from($table); |
276 | 276 | $this->db->join($jionTable, $jionCondition, $type); |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | } |
293 | 293 | |
294 | 294 | function getAllJionQuery($table, $feild, $where = "", $jionTable, $jionCondition, $type, $start = '', $end = '', $order_type = '', $order_by = '', $group_by = '') { |
295 | - $start = (int) $start; |
|
296 | - $end = (int) $end; |
|
295 | + $start = (int)$start; |
|
296 | + $end = (int)$end; |
|
297 | 297 | $this->db->select($feild); |
298 | 298 | $this->db->from($table); |
299 | 299 | $jion_table_count = count($jionTable); |
@@ -304,10 +304,10 @@ discard block |
||
304 | 304 | if ($where != "") { |
305 | 305 | $this->db->where($where); |
306 | 306 | } |
307 | - if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
|
308 | - $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
|
309 | - }else{ |
|
310 | - if($order_by) |
|
307 | + if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined') { |
|
308 | + $this->db->order_by($_GET['sortname'], ($_GET['sortorder'] == 'undefined') ? 'desc' : $_GET['sortorder']); |
|
309 | + } else { |
|
310 | + if ($order_by) |
|
311 | 311 | $this->db->order_by($order_by, $order_type); |
312 | 312 | } |
313 | 313 | |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | $string = ''; |
407 | 407 | if ($query->num_rows() > 0) { |
408 | 408 | foreach ($query->result() as $rows) { |
409 | - $string .= $rows->$select . ','; |
|
409 | + $string .= $rows->$select.','; |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | return substr($string, '', -1); |
@@ -429,13 +429,13 @@ discard block |
||
429 | 429 | } else { |
430 | 430 | $cnt_str = " $select_params[1],' (',$select_params[2],')' "; |
431 | 431 | } |
432 | - $select = $select_params[0] . ", concat($cnt_str) as $select_params[1] "; |
|
432 | + $select = $select_params[0].", concat($cnt_str) as $select_params[1] "; |
|
433 | 433 | $logintype = $this->session->userdata('logintype'); |
434 | 434 | if (($logintype == 1 || $logintype == 5) && $id_where == 'where_arr') { |
435 | 435 | $account_data = $this->session->userdata("accountinfo"); |
436 | 436 | $id_value['reseller_id'] = $account_data['id']; |
437 | 437 | } |
438 | - if(isset($id_value['type']) && $id_value['type'] == '0,3'){ |
|
438 | + if (isset($id_value['type']) && $id_value['type'] == '0,3') { |
|
439 | 439 | $twhere = "type IN (".$id_value["type"].")"; |
440 | 440 | $this->db->where($twhere); |
441 | 441 | unset($id_value['type']); |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | } else { |
489 | 489 | $cnt_str = " $select_params[1],' (',$select_params[2],')' "; |
490 | 490 | } |
491 | - $select = $select_params[0] . ", concat($cnt_str) as $select_params[1] "; |
|
491 | + $select = $select_params[0].", concat($cnt_str) as $select_params[1] "; |
|
492 | 492 | $where = $id_value; |
493 | 493 | $drp_array = $this->getSelect($select, $table, $id_value); |
494 | 494 | $drp_array = $drp_array->result(); |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | function build_dropdown($select, $table, $id_where = '', $id_value = '') { |
504 | 504 | $select_params = explode(',', $select); |
505 | 505 | $where = ''; |
506 | - if(isset($id_value["type"]) && $id_value["type"] == "GLOBAL"){ |
|
506 | + if (isset($id_value["type"]) && $id_value["type"] == "GLOBAL") { |
|
507 | 507 | $where = "type IN ('0','3')"; |
508 | 508 | $this->db->where($where); |
509 | 509 | unset($id_value["type"]); |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | $this->db->group_by($id_value); |
514 | 514 | } else if ($id_where == "where_arr") { |
515 | 515 | $logintype = $this->session->userdata('logintype'); |
516 | - if (($logintype == 1 || $logintype == 5) && $id_where == 'where_arr' && $this->db->field_exists('reseller_id',$table)) { |
|
516 | + if (($logintype == 1 || $logintype == 5) && $id_where == 'where_arr' && $this->db->field_exists('reseller_id', $table)) { |
|
517 | 517 | $id_value['reseller_id'] = $this->session->userdata["accountinfo"]['id']; |
518 | 518 | } |
519 | 519 | $where = $id_value; |
@@ -538,8 +538,8 @@ discard block |
||
538 | 538 | } |
539 | 539 | function build_dropdown_deleted($select, $table, $id_where = '', $id_value = '') { |
540 | 540 | $select_params = explode(',', $select); |
541 | - if(isset($id_value["type"]) ){ |
|
542 | - $where = $id_value["type"] == "GLOBAL" ? "type IN ('0','3')": "type IN (".$id_value["type"].")"; |
|
541 | + if (isset($id_value["type"])) { |
|
542 | + $where = $id_value["type"] == "GLOBAL" ? "type IN ('0','3')" : "type IN (".$id_value["type"].")"; |
|
543 | 543 | $this->db->where($where); |
544 | 544 | unset($id_value["type"]); |
545 | 545 | } |
@@ -569,21 +569,21 @@ discard block |
||
569 | 569 | |
570 | 570 | $drp_array = $drp_array->result(); |
571 | 571 | |
572 | - $name=explode("as",$select); |
|
573 | - if(isset($name[3])){ |
|
574 | - $name=trim($name[3]); |
|
575 | - }else{ |
|
576 | - $name=trim($name[1]); |
|
572 | + $name = explode("as", $select); |
|
573 | + if (isset($name[3])) { |
|
574 | + $name = trim($name[3]); |
|
575 | + } else { |
|
576 | + $name = trim($name[1]); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | $drp_list = array(); |
580 | - $dele =array(); |
|
580 | + $dele = array(); |
|
581 | 581 | foreach ($drp_array as $drp_value) { |
582 | - $dele=explode("^",$drp_value->$name); |
|
583 | - if(isset($dele[1])) |
|
582 | + $dele = explode("^", $drp_value->$name); |
|
583 | + if (isset($dele[1])) |
|
584 | 584 | { |
585 | - $drp_list['Deleted'][$drp_value->$select_params[0]] = str_replace("^","",$drp_value->$name); |
|
586 | - }else{ |
|
585 | + $drp_list['Deleted'][$drp_value->$select_params[0]] = str_replace("^", "", $drp_value->$name); |
|
586 | + } else { |
|
587 | 587 | $drp_list['Active'][$drp_value->$select_params[0]] = $drp_value->$name; |
588 | 588 | } |
589 | 589 | } |
@@ -599,32 +599,32 @@ discard block |
||
599 | 599 | /* ASTPP 3.0 |
600 | 600 | Display Records in |
601 | 601 | */ |
602 | - unset($account_search['search_in'],$account_search['time']); |
|
603 | - if (!empty($account_search)) { |
|
602 | + unset($account_search['search_in'], $account_search['time']); |
|
603 | + if ( ! empty($account_search)) { |
|
604 | 604 | foreach ($account_search as $key => $value) { |
605 | 605 | if ($value != "") { |
606 | 606 | if (is_array($value)) { |
607 | - if (array_key_exists($key . "-integer", $value)) { |
|
608 | - $this->get_interger_array($key, $value[$key . "-integer"], $value[$key]); |
|
607 | + if (array_key_exists($key."-integer", $value)) { |
|
608 | + $this->get_interger_array($key, $value[$key."-integer"], $value[$key]); |
|
609 | 609 | } |
610 | - if (array_key_exists($key . "-string", $value)) { |
|
611 | - $this->get_string_array($key, $value[$key . "-string"], $value[$key]); |
|
610 | + if (array_key_exists($key."-string", $value)) { |
|
611 | + $this->get_string_array($key, $value[$key."-string"], $value[$key]); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | /** |
615 | 615 | ASTPP 3.0 |
616 | 616 | first used,creation,expiry search date picker |
617 | 617 | **/ |
618 | - if ($key == 'callstart'|| |
|
619 | - $key == 'date'|| |
|
620 | - $key =='payment_date' || |
|
621 | - $key == 'first_used' || |
|
622 | - $key == 'creation' || |
|
623 | - $key =='from_date'|| |
|
624 | - $key =='invoice_date' || |
|
625 | - $key =='expiry' || |
|
626 | - $key =='created_date' || |
|
627 | - $key=='to_date') { |
|
618 | + if ($key == 'callstart' || |
|
619 | + $key == 'date' || |
|
620 | + $key == 'payment_date' || |
|
621 | + $key == 'first_used' || |
|
622 | + $key == 'creation' || |
|
623 | + $key == 'from_date' || |
|
624 | + $key == 'invoice_date' || |
|
625 | + $key == 'expiry' || |
|
626 | + $key == 'created_date' || |
|
627 | + $key == 'to_date') { |
|
628 | 628 | /***********************************************/ |
629 | 629 | $this->get_date_array($key, $value); |
630 | 630 | } |
@@ -641,16 +641,16 @@ discard block |
||
641 | 641 | |
642 | 642 | function get_date_array($field, $value) { |
643 | 643 | if ($value != '') { |
644 | - if (!empty($value[0])) { |
|
645 | - if($field == 'invoice_date'){ |
|
646 | - $this->db->where($field . ' >= ', gmdate("Y-m-d", strtotime($value['0']))." 00:00:01"); |
|
647 | - $this->db->where($field . ' <= ', gmdate("Y-m-d", strtotime($value['0']))." 23:59:59"); |
|
648 | - }else{ |
|
649 | - $this->db->where($field . ' >= ', gmdate('Y-m-d H:i:s',strtotime($value[0]))); |
|
644 | + if ( ! empty($value[0])) { |
|
645 | + if ($field == 'invoice_date') { |
|
646 | + $this->db->where($field.' >= ', gmdate("Y-m-d", strtotime($value['0']))." 00:00:01"); |
|
647 | + $this->db->where($field.' <= ', gmdate("Y-m-d", strtotime($value['0']))." 23:59:59"); |
|
648 | + } else { |
|
649 | + $this->db->where($field.' >= ', gmdate('Y-m-d H:i:s', strtotime($value[0]))); |
|
650 | 650 | } |
651 | 651 | } |
652 | - if (!empty($value[1])) { |
|
653 | - $this->db->where($field . ' <= ', gmdate('Y-m-d H:i:s',strtotime($value[1]))); |
|
652 | + if ( ! empty($value[1])) { |
|
653 | + $this->db->where($field.' <= ', gmdate('Y-m-d H:i:s', strtotime($value[1]))); |
|
654 | 654 | } |
655 | 655 | } |
656 | 656 | } |
@@ -662,19 +662,19 @@ discard block |
||
662 | 662 | $this->db->where($field, $search_array); |
663 | 663 | break; |
664 | 664 | case "2": |
665 | - $this->db->where($field . ' <>', $search_array); |
|
665 | + $this->db->where($field.' <>', $search_array); |
|
666 | 666 | break; |
667 | 667 | case "3": |
668 | - $this->db->where($field . ' > ', $search_array); |
|
668 | + $this->db->where($field.' > ', $search_array); |
|
669 | 669 | break; |
670 | 670 | case "4": |
671 | - $this->db->where($field . ' < ', $search_array); |
|
671 | + $this->db->where($field.' < ', $search_array); |
|
672 | 672 | break; |
673 | 673 | case "5": |
674 | - $this->db->where($field . ' >= ', $search_array); |
|
674 | + $this->db->where($field.' >= ', $search_array); |
|
675 | 675 | break; |
676 | 676 | case "6": |
677 | - $this->db->where($field . ' <= ', $search_array); |
|
677 | + $this->db->where($field.' <= ', $search_array); |
|
678 | 678 | break; |
679 | 679 | } |
680 | 680 | } |
@@ -684,35 +684,35 @@ discard block |
||
684 | 684 | if ($search_array != '') { |
685 | 685 | switch ($value) { |
686 | 686 | case "1": |
687 | - $str1 = $field . " LIKE '%$search_array%'"; |
|
687 | + $str1 = $field." LIKE '%$search_array%'"; |
|
688 | 688 | $this->db->where($str1); |
689 | 689 | break; |
690 | 690 | case "2": |
691 | - $str1 = $field . " NOT LIKE '%$search_array%'"; |
|
691 | + $str1 = $field." NOT LIKE '%$search_array%'"; |
|
692 | 692 | $this->db->where($str1); |
693 | 693 | break; |
694 | 694 | case "3": |
695 | 695 | $this->db->where($field, $search_array); |
696 | 696 | break; |
697 | 697 | case "4": |
698 | - $this->db->where($field . ' <>', $search_array); |
|
698 | + $this->db->where($field.' <>', $search_array); |
|
699 | 699 | break; |
700 | 700 | case "5": |
701 | - if($field == "pattern"){ |
|
702 | - $str1 = $field . " LIKE '^".$search_array."%'"; |
|
701 | + if ($field == "pattern") { |
|
702 | + $str1 = $field." LIKE '^".$search_array."%'"; |
|
703 | 703 | $this->db->where($str1); |
704 | - } else{ |
|
705 | - $str1 = $field . " LIKE '".$search_array."%'"; |
|
704 | + } else { |
|
705 | + $str1 = $field." LIKE '".$search_array."%'"; |
|
706 | 706 | $this->db->where($str1); |
707 | 707 | } |
708 | 708 | |
709 | 709 | break; |
710 | 710 | case "6": |
711 | - if($field == "pattern"){ |
|
712 | - $str1 = $field . " LIKE '%".$search_array.".*'"; |
|
711 | + if ($field == "pattern") { |
|
712 | + $str1 = $field." LIKE '%".$search_array.".*'"; |
|
713 | 713 | $this->db->where($str1); |
714 | - } else{ |
|
715 | - $str1 = $field . " LIKE '%".$search_array."'"; |
|
714 | + } else { |
|
715 | + $str1 = $field." LIKE '%".$search_array."'"; |
|
716 | 716 | $this->db->where($str1); |
717 | 717 | } |
718 | 718 | |
@@ -722,46 +722,46 @@ discard block |
||
722 | 722 | } |
723 | 723 | function build_search_string($accounts_list_search) { |
724 | 724 | $where = null; |
725 | - $search=$this->session->userdata($accounts_list_search); |
|
725 | + $search = $this->session->userdata($accounts_list_search); |
|
726 | 726 | if ($this->session->userdata('advance_search') == 1) { |
727 | 727 | $account_search = $this->session->userdata($accounts_list_search); |
728 | 728 | unset($account_search["ajax_search"]); |
729 | 729 | unset($account_search["advance_search"]); |
730 | - if (!empty($account_search)) { |
|
730 | + if ( ! empty($account_search)) { |
|
731 | 731 | foreach ($account_search as $key => $value) { |
732 | 732 | if ($value != "") { |
733 | 733 | if (is_array($value)) { |
734 | - if (array_key_exists($key . "-integer", $value)) { |
|
735 | - $string=null; |
|
736 | - $string =$this->build_interger_where($key, $value[$key . "-integer"], $value[$key]); |
|
737 | - if($string) |
|
738 | - $where.= "$string AND "; |
|
734 | + if (array_key_exists($key."-integer", $value)) { |
|
735 | + $string = null; |
|
736 | + $string = $this->build_interger_where($key, $value[$key."-integer"], $value[$key]); |
|
737 | + if ($string) |
|
738 | + $where .= "$string AND "; |
|
739 | 739 | } |
740 | - if (array_key_exists($key . "-string", $value)) { |
|
741 | - $string=null; |
|
742 | - $string=$this->build_string_where($key, $value[$key . "-string"], $value[$key]); |
|
743 | - if($string) |
|
744 | - $where.= "$string AND "; |
|
740 | + if (array_key_exists($key."-string", $value)) { |
|
741 | + $string = null; |
|
742 | + $string = $this->build_string_where($key, $value[$key."-string"], $value[$key]); |
|
743 | + if ($string) |
|
744 | + $where .= "$string AND "; |
|
745 | 745 | } |
746 | - if ($key == 'callstart'|| $key == 'date'||$key== 'log_time') { |
|
747 | - $string=null; |
|
748 | - $string=$this->build_date_where($key, $value); |
|
749 | - if($string) |
|
750 | - $where.= "$string AND "; |
|
746 | + if ($key == 'callstart' || $key == 'date' || $key == 'log_time') { |
|
747 | + $string = null; |
|
748 | + $string = $this->build_date_where($key, $value); |
|
749 | + if ($string) |
|
750 | + $where .= "$string AND "; |
|
751 | 751 | } |
752 | 752 | } else { |
753 | - $where.="$key = '$value'AND "; |
|
753 | + $where .= "$key = '$value'AND "; |
|
754 | 754 | } |
755 | 755 | } |
756 | 756 | } |
757 | 757 | } |
758 | 758 | } |
759 | - $where =rtrim($where ," AND "); |
|
759 | + $where = rtrim($where, " AND "); |
|
760 | 760 | return $where; |
761 | 761 | } |
762 | 762 | // This function using by reports module don't delete it |
763 | - function build_string_where($field, $value, $search_array){ |
|
764 | - $where=null; |
|
763 | + function build_string_where($field, $value, $search_array) { |
|
764 | + $where = null; |
|
765 | 765 | if ($search_array != '') { |
766 | 766 | switch ($value) { |
767 | 767 | case "1": |
@@ -777,17 +777,17 @@ discard block |
||
777 | 777 | $where = "$field <> '$search_array'"; |
778 | 778 | break; |
779 | 779 | case "5": |
780 | - if($field == "pattern"){ |
|
781 | - $where = $field . " LIKE '^".$search_array."%'"; |
|
782 | - }else{ |
|
783 | - $where = $field . " LIKE '".$search_array."%'"; |
|
780 | + if ($field == "pattern") { |
|
781 | + $where = $field." LIKE '^".$search_array."%'"; |
|
782 | + } else { |
|
783 | + $where = $field." LIKE '".$search_array."%'"; |
|
784 | 784 | } |
785 | 785 | break; |
786 | 786 | case "6": |
787 | - if($field == "pattern"){ |
|
788 | - $str1 = $field . " LIKE '%".$search_array.".*'"; |
|
789 | - }else{ |
|
790 | - $str1 = $field . " LIKE '%".$search_array."'"; |
|
787 | + if ($field == "pattern") { |
|
788 | + $str1 = $field." LIKE '%".$search_array.".*'"; |
|
789 | + } else { |
|
790 | + $str1 = $field." LIKE '%".$search_array."'"; |
|
791 | 791 | } |
792 | 792 | break; |
793 | 793 | } |
@@ -796,9 +796,9 @@ discard block |
||
796 | 796 | } |
797 | 797 | |
798 | 798 | function build_interger_where($field, $value, $search_array) { |
799 | - $where=null; |
|
799 | + $where = null; |
|
800 | 800 | if ($search_array != '') { |
801 | - if(is_numeric($search_array)) |
|
801 | + if (is_numeric($search_array)) |
|
802 | 802 | { |
803 | 803 | switch ($value) { |
804 | 804 | case "1": |
@@ -824,29 +824,29 @@ discard block |
||
824 | 824 | else |
825 | 825 | { |
826 | 826 | $this->db->where("$field IS NULL"); |
827 | - $where= "$field IS NULL"; |
|
827 | + $where = "$field IS NULL"; |
|
828 | 828 | } |
829 | 829 | } |
830 | 830 | return $where; |
831 | 831 | } |
832 | 832 | function build_date_where($field, $value) { |
833 | - $where =null; |
|
833 | + $where = null; |
|
834 | 834 | if ($value != '') { |
835 | - if (!empty($value[0])) { |
|
836 | - $string=null; |
|
837 | - $string="$field >= '$value[0]'"; |
|
838 | - if($string) |
|
839 | - $where.=$string." AND "; |
|
835 | + if ( ! empty($value[0])) { |
|
836 | + $string = null; |
|
837 | + $string = "$field >= '$value[0]'"; |
|
838 | + if ($string) |
|
839 | + $where .= $string." AND "; |
|
840 | 840 | } |
841 | - if (!empty($value[1])) { |
|
842 | - $string=null; |
|
843 | - $string="$field <= '$value[1]'"; |
|
844 | - if($string) |
|
845 | - $where.=$string." AND "; |
|
841 | + if ( ! empty($value[1])) { |
|
842 | + $string = null; |
|
843 | + $string = "$field <= '$value[1]'"; |
|
844 | + if ($string) |
|
845 | + $where .= $string." AND "; |
|
846 | 846 | } |
847 | 847 | } |
848 | - if($where){ |
|
849 | - $where =rtrim($where," AND "); |
|
848 | + if ($where) { |
|
849 | + $where = rtrim($where, " AND "); |
|
850 | 850 | } |
851 | 851 | return $where; |
852 | 852 | } |
@@ -858,10 +858,10 @@ discard block |
||
858 | 858 | |
859 | 859 | function update_balance($amount, $accountid, $payment_type) { |
860 | 860 | if ($payment_type == "debit") { |
861 | - $query = 'UPDATE `accounts` SET `balance` = (balance - ' . $amount . ') WHERE `id` = ' . $accountid; |
|
861 | + $query = 'UPDATE `accounts` SET `balance` = (balance - '.$amount.') WHERE `id` = '.$accountid; |
|
862 | 862 | return $this->db->query($query); |
863 | 863 | } else { |
864 | - $query = 'UPDATE `accounts` SET `balance` = (balance + ' . $amount . ') WHERE `id` = ' . $accountid; |
|
864 | + $query = 'UPDATE `accounts` SET `balance` = (balance + '.$amount.') WHERE `id` = '.$accountid; |
|
865 | 865 | return $this->db->query($query); |
866 | 866 | } |
867 | 867 | } |
@@ -875,30 +875,30 @@ discard block |
||
875 | 875 | // $this->db->where($field, $search_array); |
876 | 876 | break; |
877 | 877 | case "2": |
878 | - if($update_fields[$key] != ''){ |
|
878 | + if ($update_fields[$key] != '') { |
|
879 | 879 | $updateflg = true; |
880 | - $this->db->set($key,$update_fields[$key]); |
|
880 | + $this->db->set($key, $update_fields[$key]); |
|
881 | 881 | } |
882 | 882 | break; |
883 | 883 | case "3": |
884 | - $this->db->set($key, $key . "+" . $update_fields[$key], FALSE); |
|
884 | + $this->db->set($key, $key."+".$update_fields[$key], FALSE); |
|
885 | 885 | $updateflg = true; |
886 | 886 | break; |
887 | 887 | case "4": |
888 | - $this->db->set($key, $key . "-" . $update_fields[$key], FALSE); |
|
888 | + $this->db->set($key, $key."-".$update_fields[$key], FALSE); |
|
889 | 889 | $updateflg = true; |
890 | 890 | break; |
891 | 891 | } |
892 | 892 | } else { |
893 | - if ($update_fields != ""){ |
|
894 | - $this->db->set($key,$update_fields); |
|
893 | + if ($update_fields != "") { |
|
894 | + $this->db->set($key, $update_fields); |
|
895 | 895 | $updateflg = true; |
896 | 896 | } |
897 | 897 | } |
898 | 898 | } |
899 | 899 | return $updateflg; |
900 | 900 | } |
901 | - function build_search_opensips($opensips_db_obj,$accounts_list_search) { |
|
901 | + function build_search_opensips($opensips_db_obj, $accounts_list_search) { |
|
902 | 902 | if ($this->session->userdata('advance_search') == 1) { |
903 | 903 | $account_search = $this->session->userdata($accounts_list_search); |
904 | 904 | unset($account_search["ajax_search"]); |
@@ -906,11 +906,11 @@ discard block |
||
906 | 906 | foreach ($account_search as $key => $value) { |
907 | 907 | if ($value != "") { |
908 | 908 | if (is_array($value)) { |
909 | - if (array_key_exists($key . "-integer", $value)) { |
|
910 | - $this->get_opensips_interger_array($opensips_db_obj,$key, $value[$key . "-integer"], $value[$key]); |
|
909 | + if (array_key_exists($key."-integer", $value)) { |
|
910 | + $this->get_opensips_interger_array($opensips_db_obj, $key, $value[$key."-integer"], $value[$key]); |
|
911 | 911 | } |
912 | - if (array_key_exists($key . "-string", $value)) { |
|
913 | - $this->get_opensips_string_array($opensips_db_obj,$key, $value[$key . "-string"], $value[$key]); |
|
912 | + if (array_key_exists($key."-string", $value)) { |
|
913 | + $this->get_opensips_string_array($opensips_db_obj, $key, $value[$key."-string"], $value[$key]); |
|
914 | 914 | } |
915 | 915 | } else { |
916 | 916 | $opensips_db_obj->where($key, $value); |
@@ -920,32 +920,32 @@ discard block |
||
920 | 920 | } |
921 | 921 | } |
922 | 922 | |
923 | - function get_opensips_interger_array($opensips_db_obj,$field, $value, $search_array) { |
|
923 | + function get_opensips_interger_array($opensips_db_obj, $field, $value, $search_array) { |
|
924 | 924 | if ($search_array != '') { |
925 | 925 | switch ($value) { |
926 | 926 | case "1": |
927 | 927 | $opensips_db_obj->where($field, $search_array); |
928 | 928 | break; |
929 | 929 | case "2": |
930 | - $opensips_db_obj->where($field . ' <>', $search_array); |
|
930 | + $opensips_db_obj->where($field.' <>', $search_array); |
|
931 | 931 | break; |
932 | 932 | case "3": |
933 | - $opensips_db_obj->where($field . ' > ', $search_array); |
|
933 | + $opensips_db_obj->where($field.' > ', $search_array); |
|
934 | 934 | break; |
935 | 935 | case "4": |
936 | - $opensips_db_obj->where($field . ' < ', $search_array); |
|
936 | + $opensips_db_obj->where($field.' < ', $search_array); |
|
937 | 937 | break; |
938 | 938 | case "5": |
939 | - $opensips_db_obj->where($field . ' >= ', $search_array); |
|
939 | + $opensips_db_obj->where($field.' >= ', $search_array); |
|
940 | 940 | break; |
941 | 941 | case "6": |
942 | - $opensips_db_obj->where($field . ' <= ', $search_array); |
|
942 | + $opensips_db_obj->where($field.' <= ', $search_array); |
|
943 | 943 | break; |
944 | 944 | } |
945 | 945 | } |
946 | 946 | } |
947 | 947 | |
948 | - function get_opensips_string_array($opensips_db_obj,$field, $value, $search_array) { |
|
948 | + function get_opensips_string_array($opensips_db_obj, $field, $value, $search_array) { |
|
949 | 949 | if ($search_array != '') { |
950 | 950 | switch ($value) { |
951 | 951 | case "1": |
@@ -958,14 +958,14 @@ discard block |
||
958 | 958 | $opensips_db_obj->where($field, $search_array); |
959 | 959 | break; |
960 | 960 | case "4": |
961 | - $opensips_db_obj->where($field . ' <>', $search_array); |
|
961 | + $opensips_db_obj->where($field.' <>', $search_array); |
|
962 | 962 | break; |
963 | 963 | case "5": |
964 | - $str1 = $field . " LIKE '".$search_array."%'"; |
|
964 | + $str1 = $field." LIKE '".$search_array."%'"; |
|
965 | 965 | $opensips_db_obj->where($str1); |
966 | 966 | break; |
967 | 967 | case "6": |
968 | - $str1 = $field . " LIKE '%".$search_array."'"; |
|
968 | + $str1 = $field." LIKE '%".$search_array."'"; |
|
969 | 969 | $opensips_db_obj->where($str1); |
970 | 970 | break; |
971 | 971 | } |
@@ -980,7 +980,7 @@ discard block |
||
980 | 980 | } else { |
981 | 981 | $cnt_str = " $select_params[1],' (',$select_params[2],')' "; |
982 | 982 | } |
983 | - $select = $select_params[0] . ", concat($cnt_str) as $select_params[1] ,".$select_params[4] ; |
|
983 | + $select = $select_params[0].", concat($cnt_str) as $select_params[1] ,".$select_params[4]; |
|
984 | 984 | $logintype = $this->session->userdata('logintype'); |
985 | 985 | if (($logintype == 1 || $logintype == 5) && $id_where == 'where_arr') { |
986 | 986 | $account_data = $this->session->userdata("accountinfo"); |
@@ -991,12 +991,12 @@ discard block |
||
991 | 991 | $drp_array = $drp_array->result(); |
992 | 992 | $drp_list = array(); |
993 | 993 | foreach ($drp_array as $drp_value) { |
994 | - if($drp_value->type == 3) |
|
994 | + if ($drp_value->type == 3) |
|
995 | 995 | { |
996 | 996 | $drp_list['Provider'][$drp_value->id] = $drp_value->first_name; |
997 | - }elseif($drp_value->type == 1){ |
|
997 | + }elseif ($drp_value->type == 1) { |
|
998 | 998 | $drp_list['Reseller'][$drp_value->id] = $drp_value->first_name; |
999 | - }else{ |
|
999 | + } else { |
|
1000 | 1000 | $drp_list['Customer'][$drp_value->id] = $drp_value->first_name; |
1001 | 1001 | } |
1002 | 1002 | } |
@@ -48,10 +48,11 @@ discard block |
||
48 | 48 | function save($tableName, $arr, $val = 'false') { |
49 | 49 | $str = $this->db->insert_string($tableName, $arr); |
50 | 50 | $rs = $this->db->query($str); |
51 | - if ($val == true) |
|
52 | - return $this->db->insert_id(); |
|
53 | - else |
|
54 | - return $rs; |
|
51 | + if ($val == true) { |
|
52 | + return $this->db->insert_id(); |
|
53 | + } else { |
|
54 | + return $rs; |
|
55 | + } |
|
55 | 56 | } |
56 | 57 | |
57 | 58 | /* * ******************************************************** |
@@ -134,15 +135,18 @@ discard block |
||
134 | 135 | $this->db->where($where); |
135 | 136 | } |
136 | 137 | |
137 | - if ($paging_limit) |
|
138 | - $this->db->limit($paging_limit, $start_limit); |
|
139 | - if (!empty($groupby)) |
|
140 | - $this->db->group_by($groupby); |
|
138 | + if ($paging_limit) { |
|
139 | + $this->db->limit($paging_limit, $start_limit); |
|
140 | + } |
|
141 | + if (!empty($groupby)) { |
|
142 | + $this->db->group_by($groupby); |
|
143 | + } |
|
141 | 144 | if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
142 | 145 | $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
143 | - }else{ |
|
144 | - if($order_by) |
|
145 | - $this->db->order_by($order_by, $order_type); |
|
146 | + } else{ |
|
147 | + if($order_by) { |
|
148 | + $this->db->order_by($order_by, $order_type); |
|
149 | + } |
|
146 | 150 | } |
147 | 151 | $query = $this->db->get(); |
148 | 152 | return $query; |
@@ -160,10 +164,12 @@ discard block |
||
160 | 164 | } |
161 | 165 | $this->db->where_in($key, $where_in); |
162 | 166 | $this->db->order_by($order_by, $order_type); |
163 | - if ($paging_limit) |
|
164 | - $this->db->limit($paging_limit, $start_limit); |
|
165 | - if (!empty($groupby)) |
|
166 | - $this->db->groupby($groupby); |
|
167 | + if ($paging_limit) { |
|
168 | + $this->db->limit($paging_limit, $start_limit); |
|
169 | + } |
|
170 | + if (!empty($groupby)) { |
|
171 | + $this->db->groupby($groupby); |
|
172 | + } |
|
167 | 173 | $query = $this->db->get(); |
168 | 174 | |
169 | 175 | return $query; |
@@ -254,9 +260,10 @@ discard block |
||
254 | 260 | } |
255 | 261 | if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
256 | 262 | $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
257 | - }else{ |
|
258 | - if($order_by) |
|
259 | - $this->db->order_by($order_by, $order_type); |
|
263 | + } else{ |
|
264 | + if($order_by) { |
|
265 | + $this->db->order_by($order_by, $order_type); |
|
266 | + } |
|
260 | 267 | } |
261 | 268 | |
262 | 269 | if ($group_by != '') { |
@@ -306,9 +313,10 @@ discard block |
||
306 | 313 | } |
307 | 314 | if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
308 | 315 | $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
309 | - }else{ |
|
310 | - if($order_by) |
|
311 | - $this->db->order_by($order_by, $order_type); |
|
316 | + } else{ |
|
317 | + if($order_by) { |
|
318 | + $this->db->order_by($order_by, $order_type); |
|
319 | + } |
|
312 | 320 | } |
313 | 321 | |
314 | 322 | if ($group_by != '') { |
@@ -572,7 +580,7 @@ discard block |
||
572 | 580 | $name=explode("as",$select); |
573 | 581 | if(isset($name[3])){ |
574 | 582 | $name=trim($name[3]); |
575 | - }else{ |
|
583 | + } else{ |
|
576 | 584 | $name=trim($name[1]); |
577 | 585 | } |
578 | 586 | |
@@ -583,7 +591,7 @@ discard block |
||
583 | 591 | if(isset($dele[1])) |
584 | 592 | { |
585 | 593 | $drp_list['Deleted'][$drp_value->$select_params[0]] = str_replace("^","",$drp_value->$name); |
586 | - }else{ |
|
594 | + } else{ |
|
587 | 595 | $drp_list['Active'][$drp_value->$select_params[0]] = $drp_value->$name; |
588 | 596 | } |
589 | 597 | } |
@@ -645,7 +653,7 @@ discard block |
||
645 | 653 | if($field == 'invoice_date'){ |
646 | 654 | $this->db->where($field . ' >= ', gmdate("Y-m-d", strtotime($value['0']))." 00:00:01"); |
647 | 655 | $this->db->where($field . ' <= ', gmdate("Y-m-d", strtotime($value['0']))." 23:59:59"); |
648 | - }else{ |
|
656 | + } else{ |
|
649 | 657 | $this->db->where($field . ' >= ', gmdate('Y-m-d H:i:s',strtotime($value[0]))); |
650 | 658 | } |
651 | 659 | } |
@@ -734,20 +742,23 @@ discard block |
||
734 | 742 | if (array_key_exists($key . "-integer", $value)) { |
735 | 743 | $string=null; |
736 | 744 | $string =$this->build_interger_where($key, $value[$key . "-integer"], $value[$key]); |
737 | - if($string) |
|
738 | - $where.= "$string AND "; |
|
745 | + if($string) { |
|
746 | + $where.= "$string AND "; |
|
747 | + } |
|
739 | 748 | } |
740 | 749 | if (array_key_exists($key . "-string", $value)) { |
741 | 750 | $string=null; |
742 | 751 | $string=$this->build_string_where($key, $value[$key . "-string"], $value[$key]); |
743 | - if($string) |
|
744 | - $where.= "$string AND "; |
|
752 | + if($string) { |
|
753 | + $where.= "$string AND "; |
|
754 | + } |
|
745 | 755 | } |
746 | 756 | if ($key == 'callstart'|| $key == 'date'||$key== 'log_time') { |
747 | 757 | $string=null; |
748 | 758 | $string=$this->build_date_where($key, $value); |
749 | - if($string) |
|
750 | - $where.= "$string AND "; |
|
759 | + if($string) { |
|
760 | + $where.= "$string AND "; |
|
761 | + } |
|
751 | 762 | } |
752 | 763 | } else { |
753 | 764 | $where.="$key = '$value'AND "; |
@@ -779,14 +790,14 @@ discard block |
||
779 | 790 | case "5": |
780 | 791 | if($field == "pattern"){ |
781 | 792 | $where = $field . " LIKE '^".$search_array."%'"; |
782 | - }else{ |
|
793 | + } else{ |
|
783 | 794 | $where = $field . " LIKE '".$search_array."%'"; |
784 | 795 | } |
785 | 796 | break; |
786 | 797 | case "6": |
787 | 798 | if($field == "pattern"){ |
788 | 799 | $str1 = $field . " LIKE '%".$search_array.".*'"; |
789 | - }else{ |
|
800 | + } else{ |
|
790 | 801 | $str1 = $field . " LIKE '%".$search_array."'"; |
791 | 802 | } |
792 | 803 | break; |
@@ -820,8 +831,7 @@ discard block |
||
820 | 831 | $where = "$field <= '$search_array'"; |
821 | 832 | break; |
822 | 833 | } |
823 | - } |
|
824 | - else |
|
834 | + } else |
|
825 | 835 | { |
826 | 836 | $this->db->where("$field IS NULL"); |
827 | 837 | $where= "$field IS NULL"; |
@@ -835,14 +845,16 @@ discard block |
||
835 | 845 | if (!empty($value[0])) { |
836 | 846 | $string=null; |
837 | 847 | $string="$field >= '$value[0]'"; |
838 | - if($string) |
|
839 | - $where.=$string." AND "; |
|
848 | + if($string) { |
|
849 | + $where.=$string." AND "; |
|
850 | + } |
|
840 | 851 | } |
841 | 852 | if (!empty($value[1])) { |
842 | 853 | $string=null; |
843 | 854 | $string="$field <= '$value[1]'"; |
844 | - if($string) |
|
845 | - $where.=$string." AND "; |
|
855 | + if($string) { |
|
856 | + $where.=$string." AND "; |
|
857 | + } |
|
846 | 858 | } |
847 | 859 | } |
848 | 860 | if($where){ |
@@ -994,9 +1006,9 @@ discard block |
||
994 | 1006 | if($drp_value->type == 3) |
995 | 1007 | { |
996 | 1008 | $drp_list['Provider'][$drp_value->id] = $drp_value->first_name; |
997 | - }elseif($drp_value->type == 1){ |
|
1009 | + } elseif($drp_value->type == 1){ |
|
998 | 1010 | $drp_list['Reseller'][$drp_value->id] = $drp_value->first_name; |
999 | - }else{ |
|
1011 | + } else{ |
|
1000 | 1012 | $drp_list['Customer'][$drp_value->id] = $drp_value->first_name; |
1001 | 1013 | } |
1002 | 1014 | } |
@@ -23,33 +23,33 @@ |
||
23 | 23 | |
24 | 24 | class Auth_model extends CI_Model { |
25 | 25 | |
26 | - function Auth_model() { |
|
27 | - parent::__construct(); |
|
28 | - } |
|
29 | - /** |
|
30 | - * -------Here we write code for model auth_model functions verify_login------ |
|
31 | - * Purpose: Validate Login Name and Password. |
|
32 | - * @param $username,$password. |
|
33 | - * @return integer login user name and password is valid then return true else return false. |
|
34 | - */ |
|
35 | - function verify_login($username, $password) { |
|
36 | - $q = "SELECT COUNT(*) as cnt FROM accounts WHERE (number = '".$this->db->escape_str($username)."'"; |
|
26 | + function Auth_model() { |
|
27 | + parent::__construct(); |
|
28 | + } |
|
29 | + /** |
|
30 | + * -------Here we write code for model auth_model functions verify_login------ |
|
31 | + * Purpose: Validate Login Name and Password. |
|
32 | + * @param $username,$password. |
|
33 | + * @return integer login user name and password is valid then return true else return false. |
|
34 | + */ |
|
35 | + function verify_login($username, $password) { |
|
36 | + $q = "SELECT COUNT(*) as cnt FROM accounts WHERE (number = '".$this->db->escape_str($username)."'"; |
|
37 | 37 | $q .= " OR email = '".$this->db->escape_str($username)."')"; |
38 | - $q .= " AND password = '".$this->db->escape_str($password)."'"; |
|
39 | - $q .= " AND status = 0 AND type IN (1,2,3,4,5,0,-1) AND deleted = 0"; |
|
40 | - $query = $this->db->query($q); |
|
41 | - if ($query->num_rows() > 0) { |
|
42 | - $row = $query->row(); |
|
43 | - if ($row->cnt > 0) { |
|
44 | - $this->session->set_userdata('user_name', $username); |
|
45 | - return 1; |
|
46 | - } else { |
|
47 | - return 0; |
|
48 | - } |
|
49 | - } |
|
38 | + $q .= " AND password = '".$this->db->escape_str($password)."'"; |
|
39 | + $q .= " AND status = 0 AND type IN (1,2,3,4,5,0,-1) AND deleted = 0"; |
|
40 | + $query = $this->db->query($q); |
|
41 | + if ($query->num_rows() > 0) { |
|
42 | + $row = $query->row(); |
|
43 | + if ($row->cnt > 0) { |
|
44 | + $this->session->set_userdata('user_name', $username); |
|
45 | + return 1; |
|
46 | + } else { |
|
47 | + return 0; |
|
48 | + } |
|
49 | + } |
|
50 | 50 | |
51 | - return 0; |
|
52 | - } |
|
51 | + return 0; |
|
52 | + } |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | //end class |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | $config = array(); |
57 | 57 | $result = $query->result_array(); |
58 | 58 | foreach ($result as $row) { |
59 | - if($row['name'] == 'decimal_points' || $row['name'] == 'starting_digit' || $row['name'] == 'card_length' || $row['name'] == 'pin_length'){ |
|
60 | - $row['name'] = str_replace("_","",$row['name']); |
|
59 | + if ($row['name'] == 'decimal_points' || $row['name'] == 'starting_digit' || $row['name'] == 'card_length' || $row['name'] == 'pin_length') { |
|
60 | + $row['name'] = str_replace("_", "", $row['name']); |
|
61 | 61 | } |
62 | 62 | $config[$row['name']] = $row['value']; |
63 | 63 | } |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | return $currencylist; |
88 | 88 | } |
89 | 89 | |
90 | - function get_admin_info(){ |
|
91 | - $result=$this->db->get_where('accounts',array('type'=>'-1')); |
|
92 | - $result=$result->result_array(); |
|
90 | + function get_admin_info() { |
|
91 | + $result = $this->db->get_where('accounts', array('type'=>'-1')); |
|
92 | + $result = $result->result_array(); |
|
93 | 93 | self::$global_config['admin_info'] = $result[0]; |
94 | 94 | return $result[0]; |
95 | 95 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * Changes for invoices |
98 | 98 | */ |
99 | 99 | function generate_receipt($accountid, $amount, $accountinfo, $last_invoice_ID, $invoice_prefix, $due_date) { |
100 | - $amount = str_replace( ',', '', $amount ); |
|
100 | + $amount = str_replace(',', '', $amount); |
|
101 | 101 | $invoice_data = array("accountid" => $accountid, |
102 | 102 | "invoice_prefix" => $invoice_prefix, |
103 | 103 | "invoiceid" => $last_invoice_ID, |
@@ -123,16 +123,16 @@ discard block |
||
123 | 123 | $to_currency1 = $this->session->userdata['accountinfo']['currency_id']; |
124 | 124 | $to_currency = $this->common->get_field_name('currency', 'currency', $to_currency1); |
125 | 125 | } |
126 | - $from_cur_rate = (self::$global_config['currency_list'][$from_currency] > 0)?self::$global_config['currency_list'][$from_currency]:1; |
|
127 | - $to_cur_rate = (self::$global_config['currency_list'][$to_currency])?self::$global_config['currency_list'][$to_currency]:1; |
|
128 | - $amount = str_replace( ',', '', $amount ); |
|
126 | + $from_cur_rate = (self::$global_config['currency_list'][$from_currency] > 0) ? self::$global_config['currency_list'][$from_currency] : 1; |
|
127 | + $to_cur_rate = (self::$global_config['currency_list'][$to_currency]) ? self::$global_config['currency_list'][$to_currency] : 1; |
|
128 | + $amount = str_replace(',', '', $amount); |
|
129 | 129 | $cal_amount = ($amount * $to_cur_rate) / $from_cur_rate; |
130 | 130 | if ($format_currency) |
131 | 131 | $cal_amount = $this->format_currency($cal_amount); |
132 | - if ($append_currency){ |
|
133 | - $cal_amount = $cal_amount . " " . $to_currency; |
|
132 | + if ($append_currency) { |
|
133 | + $cal_amount = $cal_amount." ".$to_currency; |
|
134 | 134 | } |
135 | - $cal_amount = str_replace( ',', '', $cal_amount ); |
|
135 | + $cal_amount = str_replace(',', '', $cal_amount); |
|
136 | 136 | return $cal_amount; |
137 | 137 | } |
138 | 138 | function calculate_currency_customer($amount = 0, $from_currency = '', $to_currency = '', $format_currency = true, $append_currency = true) { |
@@ -142,35 +142,35 @@ discard block |
||
142 | 142 | $to_currency1 = $this->session->userdata['accountinfo']['currency_id']; |
143 | 143 | $to_currency = $this->common->get_field_name('currency', 'currency', $to_currency1); |
144 | 144 | } |
145 | - $from_cur_rate = (self::$global_config['currency_list'][$from_currency] > 0)?self::$global_config['currency_list'][$from_currency]:1; |
|
146 | - $to_cur_rate = (self::$global_config['currency_list'][$to_currency])?self::$global_config['currency_list'][$to_currency]:1; |
|
147 | - $amount = str_replace( ',', '', $amount ); |
|
145 | + $from_cur_rate = (self::$global_config['currency_list'][$from_currency] > 0) ? self::$global_config['currency_list'][$from_currency] : 1; |
|
146 | + $to_cur_rate = (self::$global_config['currency_list'][$to_currency]) ? self::$global_config['currency_list'][$to_currency] : 1; |
|
147 | + $amount = str_replace(',', '', $amount); |
|
148 | 148 | $cal_amount = ($amount * $to_cur_rate) / $from_cur_rate; |
149 | 149 | if ($format_currency) |
150 | 150 | $cal_amount = $this->format_currency($cal_amount); |
151 | 151 | if ($append_currency) |
152 | - $cal_amount = $cal_amount ; |
|
153 | - $cal_amount = str_replace( ',', '', $cal_amount ); |
|
152 | + $cal_amount = $cal_amount; |
|
153 | + $cal_amount = str_replace(',', '', $cal_amount); |
|
154 | 154 | return $cal_amount; |
155 | 155 | } |
156 | 156 | |
157 | 157 | function add_calculate_currency($amount = 0, $from_currency = '', $to_currency = '', $format_currency = true, $append_currency = true) { |
158 | - $amount = str_replace( ',', '', $amount ); |
|
158 | + $amount = str_replace(',', '', $amount); |
|
159 | 159 | if ($from_currency == '') { |
160 | 160 | $from_currency1 = $this->session->userdata['accountinfo']['currency_id']; |
161 | 161 | $from_currency = $this->common->get_field_name('currency', 'currency', $from_currency1); |
162 | 162 | } |
163 | 163 | $to_currency = ($to_currency == '') ? self::$global_config['system_config']['base_currency'] : $to_currency; |
164 | - if(self::$global_config['currency_list'][$from_currency] > 0){ |
|
164 | + if (self::$global_config['currency_list'][$from_currency] > 0) { |
|
165 | 165 | $cal_amount = ($amount * self::$global_config['currency_list'][$to_currency]) / self::$global_config['currency_list'][$from_currency]; |
166 | - }else{ |
|
167 | - $cal_amount=$amount; |
|
166 | + } else { |
|
167 | + $cal_amount = $amount; |
|
168 | 168 | } |
169 | 169 | if ($format_currency) |
170 | 170 | $cal_amount = $this->format_currency($cal_amount); |
171 | 171 | if ($append_currency) |
172 | - $cal_amount = $cal_amount . " " . $to_currency; |
|
173 | - $cal_amount = str_replace( ',', '', $cal_amount ); |
|
172 | + $cal_amount = $cal_amount." ".$to_currency; |
|
173 | + $cal_amount = str_replace(',', '', $cal_amount); |
|
174 | 174 | return $cal_amount; |
175 | 175 | } |
176 | 176 | |
@@ -181,26 +181,26 @@ discard block |
||
181 | 181 | } |
182 | 182 | $from_currency = ($from_currency == '') ? self::$global_config['system_config']['base_currency'] : $from_currency; |
183 | 183 | |
184 | - $from_cur_rate = (self::$global_config['currency_list'][$from_currency] > 0)?self::$global_config['currency_list'][$from_currency]:1; |
|
185 | - $to_cur_rate = (self::$global_config['currency_list'][$to_currency])?self::$global_config['currency_list'][$to_currency]:1; |
|
186 | - $amount = str_replace( ',', '', $amount ); |
|
184 | + $from_cur_rate = (self::$global_config['currency_list'][$from_currency] > 0) ? self::$global_config['currency_list'][$from_currency] : 1; |
|
185 | + $to_cur_rate = (self::$global_config['currency_list'][$to_currency]) ? self::$global_config['currency_list'][$to_currency] : 1; |
|
186 | + $amount = str_replace(',', '', $amount); |
|
187 | 187 | $cal_amount = ($amount * $to_cur_rate) / $from_cur_rate; |
188 | 188 | if ($format_currency) |
189 | 189 | $cal_amount = $this->format_currency($cal_amount); |
190 | 190 | if ($append_currency) |
191 | - $cal_amount = $cal_amount . " " . $to_currency; |
|
192 | - $cal_amount = str_replace( ',', '', $cal_amount ); |
|
191 | + $cal_amount = $cal_amount." ".$to_currency; |
|
192 | + $cal_amount = str_replace(',', '', $cal_amount); |
|
193 | 193 | return $cal_amount; |
194 | 194 | } |
195 | 195 | |
196 | 196 | function format_currency($amount) { |
197 | - $amount = str_replace( ',', '', $amount ); |
|
198 | - return number_format($amount,Common_model::$global_config['system_config']['decimalpoints']); |
|
197 | + $amount = str_replace(',', '', $amount); |
|
198 | + return number_format($amount, Common_model::$global_config['system_config']['decimalpoints']); |
|
199 | 199 | // return $amount; |
200 | 200 | } |
201 | 201 | |
202 | 202 | function money_format($format, $number) { |
203 | - $regex = '/%((?:[\^!\-]|\+|\(|\=.)*)([0-9]+)?' . |
|
203 | + $regex = '/%((?:[\^!\-]|\+|\(|\=.)*)([0-9]+)?'. |
|
204 | 204 | '(?:#([0-9]+))?(?:\.([0-9]+))?([in%])/'; |
205 | 205 | if (setlocale(LC_MONETARY, 0) == 'C') { |
206 | 206 | setlocale(LC_MONETARY, ''); |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | 'nosimbol' => preg_match('/\!/', $fmatch[1]) > 0, |
219 | 219 | 'isleft' => preg_match('/\-/', $fmatch[1]) > 0 |
220 | 220 | ); |
221 | - $width = trim($fmatch[2]) ? (int) $fmatch[2] : 0; |
|
222 | - $left = trim($fmatch[3]) ? (int) $fmatch[3] : 0; |
|
223 | - $right = trim($fmatch[4]) ? (int) $fmatch[4] : $locale['int_frac_digits']; |
|
221 | + $width = trim($fmatch[2]) ? (int)$fmatch[2] : 0; |
|
222 | + $left = trim($fmatch[3]) ? (int)$fmatch[3] : 0; |
|
223 | + $right = trim($fmatch[4]) ? (int)$fmatch[4] : $locale['int_frac_digits']; |
|
224 | 224 | $conversion = $fmatch[5]; |
225 | 225 | |
226 | 226 | $positive = true; |
@@ -252,9 +252,9 @@ discard block |
||
252 | 252 | $suffix = ')'; |
253 | 253 | break; |
254 | 254 | } |
255 | - if (!$flags['nosimbol']) { |
|
256 | - $currency = $cprefix . |
|
257 | - ($conversion == 'i' ? $locale['int_curr_symbol'] : $locale['currency_symbol']) . |
|
255 | + if ( ! $flags['nosimbol']) { |
|
256 | + $currency = $cprefix. |
|
257 | + ($conversion == 'i' ? $locale['int_curr_symbol'] : $locale['currency_symbol']). |
|
258 | 258 | $csuffix; |
259 | 259 | } else { |
260 | 260 | $currency = ''; |
@@ -266,13 +266,13 @@ discard block |
||
266 | 266 | |
267 | 267 | $n = strlen($prefix) + strlen($currency) + strlen($value[0]); |
268 | 268 | if ($left > 0 && $left > $n) { |
269 | - $value[0] = str_repeat($flags['fillchar'], $left - $n) . $value[0]; |
|
269 | + $value[0] = str_repeat($flags['fillchar'], $left - $n).$value[0]; |
|
270 | 270 | } |
271 | 271 | $value = implode($locale['mon_decimal_point'], $value); |
272 | 272 | if ($locale["{$letter}_cs_precedes"]) { |
273 | - $value = $prefix . $currency . $space . $value . $suffix; |
|
273 | + $value = $prefix.$currency.$space.$value.$suffix; |
|
274 | 274 | } else { |
275 | - $value = $prefix . $value . $space . $currency . $suffix; |
|
275 | + $value = $prefix.$value.$space.$currency.$suffix; |
|
276 | 276 | } |
277 | 277 | if ($width > 0) { |
278 | 278 | $value = str_pad($value, $width, $flags['fillchar'], $flags['isleft'] ? |
@@ -311,14 +311,14 @@ discard block |
||
311 | 311 | /* ASTPP 3.0 |
312 | 312 | * Using for Payment Functionality from Admin/Reseller Login |
313 | 313 | */ |
314 | - function get_parent_info($accountid){ |
|
315 | - $this->db->where('id',$accountid); |
|
314 | + function get_parent_info($accountid) { |
|
315 | + $this->db->where('id', $accountid); |
|
316 | 316 | $this->db->select('reseller_id,type'); |
317 | - $account_result=$this->db->get('accounts'); |
|
318 | - $account_result=(array)$account_result->first_row(); |
|
319 | - if(isset($account_result['reseller_id']) && $account_result['reseller_id']> 0){ |
|
317 | + $account_result = $this->db->get('accounts'); |
|
318 | + $account_result = (array)$account_result->first_row(); |
|
319 | + if (isset($account_result['reseller_id']) && $account_result['reseller_id'] > 0) { |
|
320 | 320 | return $account_result['reseller_id']; |
321 | - }else{ |
|
321 | + } else { |
|
322 | 322 | return '0'; |
323 | 323 | } |
324 | 324 | |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | $query = $query->result_array(); |
342 | 342 | $sub_total = $query["0"]["total"]; |
343 | 343 | } |
344 | - $tax_total = (($sub_total * ( $tax_value['taxes_rate'] / 100 )) + $tax_value['taxes_amount'] ); |
|
344 | + $tax_total = (($sub_total * ($tax_value['taxes_rate'] / 100)) + $tax_value['taxes_amount']); |
|
345 | 345 | $tax_total = round($tax_total, self::$global_config['system_config']['decimalpoints']); |
346 | 346 | $tax_array = array("accountid" => $account['id'], "reseller_id" => $account['reseller_id'], "invoiceid" => $invoiceid, "item_id" => "0", "description" => $tax_value['taxes_description'], "debit" => $tax_total, "credit" => "", "item_type" => "TAX", "created_date" => $start_date); |
347 | 347 | $this->db->insert("invoice_details", $tax_array); |
@@ -127,8 +127,9 @@ discard block |
||
127 | 127 | $to_cur_rate = (self::$global_config['currency_list'][$to_currency])?self::$global_config['currency_list'][$to_currency]:1; |
128 | 128 | $amount = str_replace( ',', '', $amount ); |
129 | 129 | $cal_amount = ($amount * $to_cur_rate) / $from_cur_rate; |
130 | - if ($format_currency) |
|
131 | - $cal_amount = $this->format_currency($cal_amount); |
|
130 | + if ($format_currency) { |
|
131 | + $cal_amount = $this->format_currency($cal_amount); |
|
132 | + } |
|
132 | 133 | if ($append_currency){ |
133 | 134 | $cal_amount = $cal_amount . " " . $to_currency; |
134 | 135 | } |
@@ -146,10 +147,12 @@ discard block |
||
146 | 147 | $to_cur_rate = (self::$global_config['currency_list'][$to_currency])?self::$global_config['currency_list'][$to_currency]:1; |
147 | 148 | $amount = str_replace( ',', '', $amount ); |
148 | 149 | $cal_amount = ($amount * $to_cur_rate) / $from_cur_rate; |
149 | - if ($format_currency) |
|
150 | - $cal_amount = $this->format_currency($cal_amount); |
|
151 | - if ($append_currency) |
|
152 | - $cal_amount = $cal_amount ; |
|
150 | + if ($format_currency) { |
|
151 | + $cal_amount = $this->format_currency($cal_amount); |
|
152 | + } |
|
153 | + if ($append_currency) { |
|
154 | + $cal_amount = $cal_amount ; |
|
155 | + } |
|
153 | 156 | $cal_amount = str_replace( ',', '', $cal_amount ); |
154 | 157 | return $cal_amount; |
155 | 158 | } |
@@ -163,13 +166,15 @@ discard block |
||
163 | 166 | $to_currency = ($to_currency == '') ? self::$global_config['system_config']['base_currency'] : $to_currency; |
164 | 167 | if(self::$global_config['currency_list'][$from_currency] > 0){ |
165 | 168 | $cal_amount = ($amount * self::$global_config['currency_list'][$to_currency]) / self::$global_config['currency_list'][$from_currency]; |
166 | - }else{ |
|
169 | + } else{ |
|
167 | 170 | $cal_amount=$amount; |
168 | 171 | } |
169 | - if ($format_currency) |
|
170 | - $cal_amount = $this->format_currency($cal_amount); |
|
171 | - if ($append_currency) |
|
172 | - $cal_amount = $cal_amount . " " . $to_currency; |
|
172 | + if ($format_currency) { |
|
173 | + $cal_amount = $this->format_currency($cal_amount); |
|
174 | + } |
|
175 | + if ($append_currency) { |
|
176 | + $cal_amount = $cal_amount . " " . $to_currency; |
|
177 | + } |
|
173 | 178 | $cal_amount = str_replace( ',', '', $cal_amount ); |
174 | 179 | return $cal_amount; |
175 | 180 | } |
@@ -185,10 +190,12 @@ discard block |
||
185 | 190 | $to_cur_rate = (self::$global_config['currency_list'][$to_currency])?self::$global_config['currency_list'][$to_currency]:1; |
186 | 191 | $amount = str_replace( ',', '', $amount ); |
187 | 192 | $cal_amount = ($amount * $to_cur_rate) / $from_cur_rate; |
188 | - if ($format_currency) |
|
189 | - $cal_amount = $this->format_currency($cal_amount); |
|
190 | - if ($append_currency) |
|
191 | - $cal_amount = $cal_amount . " " . $to_currency; |
|
193 | + if ($format_currency) { |
|
194 | + $cal_amount = $this->format_currency($cal_amount); |
|
195 | + } |
|
196 | + if ($append_currency) { |
|
197 | + $cal_amount = $cal_amount . " " . $to_currency; |
|
198 | + } |
|
192 | 199 | $cal_amount = str_replace( ',', '', $cal_amount ); |
193 | 200 | return $cal_amount; |
194 | 201 | } |
@@ -318,7 +325,7 @@ discard block |
||
318 | 325 | $account_result=(array)$account_result->first_row(); |
319 | 326 | if(isset($account_result['reseller_id']) && $account_result['reseller_id']> 0){ |
320 | 327 | return $account_result['reseller_id']; |
321 | - }else{ |
|
328 | + } else{ |
|
322 | 329 | return '0'; |
323 | 330 | } |
324 | 331 |