Completed
Pull Request — v3.0 (#140)
by Samir
21:15
created
web_interface/astpp/system/libraries/Fpdf.php 1 patch
Spacing   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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';
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/pdf.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -11,25 +11,25 @@  discard block
 block discarded – undo
11 11
   
12 12
   
13 13
 	$this->page++;
14
-	if(!isset($this->pages[$this->page])) // solves the problem of overwriting a page if it already exists
14
+	if ( ! isset($this->pages[$this->page])) // solves the problem of overwriting a page if it already exists
15 15
 		$this->pages[$this->page] = '';
16
-	$this->state  =2;
16
+	$this->state = 2;
17 17
 	$this->x = $this->lMargin;
18 18
 	$this->y = $this->tMargin;
19 19
 	$this->FontFamily = '';
20 20
 	// Check page size and orientation
21
-	if($orientation=='')
21
+	if ($orientation == '')
22 22
 		$orientation = $this->DefOrientation;
23 23
 	else
24 24
 		$orientation = strtoupper($orientation[0]);
25
-	if($size=='')
25
+	if ($size == '')
26 26
 		$size = $this->DefPageSize;
27 27
 	else
28 28
 		$size = $this->_getpagesize($size);
29
-	if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1])
29
+	if ($orientation != $this->CurOrientation || $size[0] != $this->CurPageSize[0] || $size[1] != $this->CurPageSize[1])
30 30
 	{
31 31
 		// New size or orientation
32
-		if($orientation=='P')
32
+		if ($orientation == 'P')
33 33
 		{
34 34
 			$this->w = $size[0];
35 35
 			$this->h = $size[1];
@@ -39,28 +39,28 @@  discard block
 block discarded – undo
39 39
 			$this->w = $size[1];
40 40
 			$this->h = $size[0];
41 41
 		}
42
-		$this->wPt = $this->w*$this->k;
43
-		$this->hPt = $this->h*$this->k;
44
-		$this->PageBreakTrigger = $this->h-$this->bMargin;
42
+		$this->wPt = $this->w * $this->k;
43
+		$this->hPt = $this->h * $this->k;
44
+		$this->PageBreakTrigger = $this->h - $this->bMargin;
45 45
 		$this->CurOrientation = $orientation;
46 46
 		$this->CurPageSize = $size;
47 47
 	}
48
-	if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1])
48
+	if ($orientation != $this->DefOrientation || $size[0] != $this->DefPageSize[0] || $size[1] != $this->DefPageSize[1])
49 49
 		$this->PageSizes[$this->page] = array($this->wPt, $this->hPt);
50 50
 }
51 51
 
52 52
 function Footer() {
53 53
 	// Check if Footer for this page already exists (do the same for Header())
54
-	if(!isset($this->footerset[$this->page])) {
54
+	if ( ! isset($this->footerset[$this->page])) {
55 55
 		$this->SetY(-15);
56 56
 		// Page number
57
-		$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
57
+		$this->Cell(0, 10, 'Page '.$this->PageNo().'/{nb}', 0, 0, 'C');
58 58
 		// set footerset
59 59
 		$this->footerset[$this->page] = true;
60 60
 	}
61 61
 }
62 62
 
63
-function morepagestable($datas, $lineheight=8) {
63
+function morepagestable($datas, $lineheight = 8) {
64 64
 	// some things to set and 'remember'
65 65
 	$l = $this->lMargin;
66 66
 	$startheight = $h = $this->GetY();
@@ -68,32 +68,32 @@  discard block
 block discarded – undo
68 68
 
69 69
 	// calculate the whole width
70 70
 	$fullwidth = 0;
71
-	foreach($this->tablewidths AS $width) {
71
+	foreach ($this->tablewidths AS $width) {
72 72
 		$fullwidth += $width;
73 73
 	}
74 74
 
75 75
 	// Now let's start to write the table
76
-	foreach($datas AS $row => $data) {
76
+	foreach ($datas AS $row => $data) {
77 77
 		$this->page = $currpage;
78 78
 		// write the horizontal borders
79 79
 	 
80 80
 		// write the content and remember the height of the highest col
81
-		foreach($data AS $col => $txt) {
81
+		foreach ($data AS $col => $txt) {
82 82
 			$this->page = $currpage;
83
-			$this->SetXY($l,$h);
83
+			$this->SetXY($l, $h);
84 84
 
85
-		if($col == 5)
86
-		  $this->MultiCell($this->tablewidths[$col],$lineheight,$txt,0,"R");
85
+		if ($col == 5)
86
+		  $this->MultiCell($this->tablewidths[$col], $lineheight, $txt, 0, "R");
87 87
 			else
88
-		  $this->MultiCell($this->tablewidths[$col],$lineheight,$txt);
88
+		  $this->MultiCell($this->tablewidths[$col], $lineheight, $txt);
89 89
 			$l += $this->tablewidths[$col];
90 90
 
91
-			if(!isset($tmpheight[$row.'-'.$this->page]))
91
+			if ( ! isset($tmpheight[$row.'-'.$this->page]))
92 92
 				$tmpheight[$row.'-'.$this->page] = 0;
93
-			if($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
93
+			if ($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
94 94
 				$tmpheight[$row.'-'.$this->page] = $this->GetY();
95 95
 			}
96
-			if($this->page > $maxpage)
96
+			if ($this->page > $maxpage)
97 97
 				$maxpage = $this->page;
98 98
 		}
99 99
 
@@ -107,17 +107,17 @@  discard block
 block discarded – undo
107 107
 	// draw the borders
108 108
 	// we start adding a horizontal line on the last page
109 109
 	$this->page = $maxpage;
110
-	$this->Line($l,$h,$fullwidth+$l,$h);
110
+	$this->Line($l, $h, $fullwidth + $l, $h);
111 111
 	// now we start at the top of the document and walk down
112
-	for($i = $startpage; $i <= $maxpage; $i++) {
112
+	for ($i = $startpage; $i <= $maxpage; $i++) {
113 113
 		$this->page = $i;
114 114
 		$l = $this->lMargin;
115 115
 		$t  = ($i == $startpage) ? $startheight : $this->tMargin;
116
-		$lh = ($i == $maxpage)   ? $h : $this->h-$this->bMargin;
117
-		$this->Line($l,$t,$l,$lh);
118
-		foreach($this->tablewidths AS $width) {
116
+		$lh = ($i == $maxpage) ? $h : $this->h - $this->bMargin;
117
+		$this->Line($l, $t, $l, $lh);
118
+		foreach ($this->tablewidths AS $width) {
119 119
 			$l += $width;
120
-			$this->Line($l,$t,$l,$lh);
120
+			$this->Line($l, $t, $l, $lh);
121 121
 		}
122 122
 	}
123 123
 	// set it to the last page, if not it'll cause some problems
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
 
128 128
 
129
-function table_total($datas, $lineheight=8) {
129
+function table_total($datas, $lineheight = 8) {
130 130
 	// some things to set and 'remember'
131 131
 	$l = $this->lMargin;
132 132
 	$startheight = $h = $this->GetY();
@@ -134,37 +134,37 @@  discard block
 block discarded – undo
134 134
 
135 135
 	// calculate the whole width
136 136
 	$fullwidth = 0;
137
-	foreach($this->tablewidths AS $width) {
137
+	foreach ($this->tablewidths AS $width) {
138 138
 		$fullwidth += $width;
139 139
 	}
140 140
 
141 141
 	// Now let's start to write the table
142
-	foreach($datas AS $row => $data) {
142
+	foreach ($datas AS $row => $data) {
143 143
 		$this->page = $currpage;
144 144
 		// write the horizontal borders
145
-	if($data != "")
146
-		$this->Line(100,$h,200,$h);
145
+	if ($data != "")
146
+		$this->Line(100, $h, 200, $h);
147 147
 		// write the content and remember the height of the highest col
148
-		foreach($data AS $col => $txt) {
148
+		foreach ($data AS $col => $txt) {
149 149
 			$this->page = $currpage;
150
-			$this->SetXY($l,$h);
150
+			$this->SetXY($l, $h);
151 151
             
152
-			if($col == 3)
152
+			if ($col == 3)
153 153
 		  $this->SetFont('Arial', 'B', 8);
154 154
 		else
155 155
 		  $this->SetFont('Arial', '', 8);
156
-		if($col == 5)
157
-		  $this->MultiCell($this->tablewidths[$col],$lineheight,$txt,0,"R");
156
+		if ($col == 5)
157
+		  $this->MultiCell($this->tablewidths[$col], $lineheight, $txt, 0, "R");
158 158
 			else
159
-		  $this->MultiCell($this->tablewidths[$col],$lineheight,$txt);
159
+		  $this->MultiCell($this->tablewidths[$col], $lineheight, $txt);
160 160
 			$l += $this->tablewidths[$col];
161 161
 
162
-			if(!isset($tmpheight[$row.'-'.$this->page]))
162
+			if ( ! isset($tmpheight[$row.'-'.$this->page]))
163 163
 				$tmpheight[$row.'-'.$this->page] = 0;
164
-			if($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
164
+			if ($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
165 165
 				$tmpheight[$row.'-'.$this->page] = $this->GetY();
166 166
 			}
167
-			if($this->page > $maxpage)
167
+			if ($this->page > $maxpage)
168 168
 				$maxpage = $this->page;
169 169
 		}
170 170
 
@@ -179,21 +179,21 @@  discard block
 block discarded – undo
179 179
 	// we start adding a horizontal line on the last page
180 180
 	$this->page = $maxpage;
181 181
     
182
-	$this->Line(100,$h,200,$h);
182
+	$this->Line(100, $h, 200, $h);
183 183
 
184 184
 	// now we start at the top of the document and walk down
185
-	for($i = $startpage; $i <= $maxpage; $i++) {
185
+	for ($i = $startpage; $i <= $maxpage; $i++) {
186 186
 		$this->page = $i;
187 187
 		$l = $this->lMargin;
188 188
 		$t  = ($i == $startpage) ? $startheight : $this->tMargin;
189
-		$lh = ($i == $maxpage)   ? $h : $this->h-$this->bMargin;
189
+		$lh = ($i == $maxpage) ? $h : $this->h - $this->bMargin;
190 190
 
191
-		foreach($this->tablewidths AS $width) {
191
+		foreach ($this->tablewidths AS $width) {
192 192
 		$l += $width;
193
-		if($width != '30')
193
+		if ($width != '30')
194 194
 		{
195
-		  $this->Line(100,$t,100,$lh);
196
-		  $this->Line($l,$t,$l,$lh);
195
+		  $this->Line(100, $t, 100, $lh);
196
+		  $this->Line($l, $t, $l, $lh);
197 197
 		}
198 198
 		}
199 199
 	}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 }
203 203
 
204 204
 
205
-function export_pdf($datas, $lineheight=8) {
205
+function export_pdf($datas, $lineheight = 8) {
206 206
 	// some things to set and 'remember'
207 207
 	$l = $this->lMargin;
208 208
 	$startheight = $h = $this->GetY();
@@ -210,32 +210,32 @@  discard block
 block discarded – undo
210 210
 
211 211
 	// calculate the whole width
212 212
 	$fullwidth = 0;
213
-	foreach($this->tablewidths AS $width) {
213
+	foreach ($this->tablewidths AS $width) {
214 214
 		$fullwidth += $width;
215 215
 	}
216 216
 
217 217
 	// Now let's start to write the table
218
-	foreach($datas AS $row => $data) {
218
+	foreach ($datas AS $row => $data) {
219 219
 		$this->page = $currpage;
220 220
 		// write the horizontal borders
221
-	 $this->Line($l,$h,$fullwidth+$l,$h); 
221
+	 $this->Line($l, $h, $fullwidth + $l, $h); 
222 222
 		// write the content and remember the height of the highest col
223
-		foreach($data AS $col => $txt) {
223
+		foreach ($data AS $col => $txt) {
224 224
 			$this->page = $currpage;
225
-			$this->SetXY($l,$h);
225
+			$this->SetXY($l, $h);
226 226
 
227
-		if($col == 5)
228
-		  $this->MultiCell($this->tablewidths[$col],$lineheight,$txt,0,"R");
227
+		if ($col == 5)
228
+		  $this->MultiCell($this->tablewidths[$col], $lineheight, $txt, 0, "R");
229 229
 			else
230
-		  $this->MultiCell($this->tablewidths[$col],$lineheight,$txt);
230
+		  $this->MultiCell($this->tablewidths[$col], $lineheight, $txt);
231 231
 			$l += $this->tablewidths[$col];
232 232
 
233
-			if(!isset($tmpheight[$row.'-'.$this->page]))
233
+			if ( ! isset($tmpheight[$row.'-'.$this->page]))
234 234
 				$tmpheight[$row.'-'.$this->page] = 0;
235
-			if($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
235
+			if ($tmpheight[$row.'-'.$this->page] < $this->GetY()) {
236 236
 				$tmpheight[$row.'-'.$this->page] = $this->GetY();
237 237
 			}
238
-			if($this->page > $maxpage)
238
+			if ($this->page > $maxpage)
239 239
 				$maxpage = $this->page;
240 240
 		}
241 241
 
@@ -249,17 +249,17 @@  discard block
 block discarded – undo
249 249
 	// draw the borders
250 250
 	// we start adding a horizontal line on the last page
251 251
 	$this->page = $maxpage;
252
-	$this->Line($l,$h,$fullwidth+$l,$h);
252
+	$this->Line($l, $h, $fullwidth + $l, $h);
253 253
 	// now we start at the top of the document and walk down
254
-	for($i = $startpage; $i <= $maxpage; $i++) {
254
+	for ($i = $startpage; $i <= $maxpage; $i++) {
255 255
 		$this->page = $i;
256 256
 		$l = $this->lMargin;
257 257
 		$t  = ($i == $startpage) ? $startheight : $this->tMargin;
258
-		$lh = ($i == $maxpage)   ? $h : $this->h-$this->bMargin;
259
-		$this->Line($l,$t,$l,$lh);
260
-		foreach($this->tablewidths AS $width) {
258
+		$lh = ($i == $maxpage) ? $h : $this->h - $this->bMargin;
259
+		$this->Line($l, $t, $l, $lh);
260
+		foreach ($this->tablewidths AS $width) {
261 261
 			$l += $width;
262
-			$this->Line($l,$t,$l,$lh);
262
+			$this->Line($l, $t, $l, $lh);
263 263
 		}
264 264
 	}
265 265
 	// set it to the last page, if not it'll cause some problems
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Calendar.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@
 block discarded – undo
101 101
 	{
102 102
 		// Set and validate the supplied month/year
103 103
 		if ($year == '') {
104
-					$year  = date("Y", $this->local_time);
104
+					$year = date("Y", $this->local_time);
105 105
 		}
106 106
 
107 107
 		if ($month == '') {
Please login to merge, or discard this patch.
web_interface/astpp/system/libraries/Xmlrpc.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1234,11 +1234,11 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
web_interface/astpp/system/database/DB_active_rec.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2132,7 +2132,7 @@
 block discarded – undo
2132 2132
 	 */
2133 2133
 		 function _insert_on_duplicate_update_batch($table, $keys, $values)
2134 2134
 		 {
2135
-				  foreach($keys as $key)
2135
+				  foreach ($keys as $key)
2136 2136
 				  $update_fields[] = $key.'=VALUES('.$key.')';
2137 2137
            
2138 2138
 				  return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values)." ON DUPLICATE KEY UPDATE ".implode(', ', $update_fields);
Please login to merge, or discard this patch.
web_interface/astpp/system/helpers/template_inheritance_helper.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
 That's it for now. If you have questions, ideas or problems, please write me at daniel AT dornhardt.com.
238 238
 */
239
-	if (! defined('TI_VIEWS_DIR') ) {
239
+	if ( ! defined('TI_VIEWS_DIR')) {
240 240
 		if (defined('APPPATH')) {
241 241
 			define('TI_VIEWS_DIR', APPPATH.'views/');
242 242
 		} else {
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 			$GLOBALS['CI']->load->view($GLOBALS['TI_CURRENT_BASE_TEMPLATE']);
286 286
 		}
287 287
 		else {
288
-			include realpath( TI_VIEWS_DIR . $GLOBALS['TI_CURRENT_BASE_TEMPLATE']);
288
+			include realpath(TI_VIEWS_DIR.$GLOBALS['TI_CURRENT_BASE_TEMPLATE']);
289 289
 		}
290 290
 	}
291 291
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 */
372 372
 	function block_rendering_neccessary() {
373 373
 		// check if no child did override this block
374
-		if (!array_key_exists($GLOBALS['TI_CURRENT_BLOCKNAME'], $GLOBALS['TI_EXTENDED_BASE_TEMPLATE_DATA'] )) {
374
+		if ( ! array_key_exists($GLOBALS['TI_CURRENT_BLOCKNAME'], $GLOBALS['TI_EXTENDED_BASE_TEMPLATE_DATA'])) {
375 375
 			return true;
376 376
 		}
377 377
 		// check if there is an extension marker in the child blocks data. If so, the
Please login to merge, or discard this patch.
web_interface/astpp/system/helpers/form_helper.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 		return $form;
81 81
 	}
82 82
 }
83
-if(!function_exists('form_breadcrumb')){
84
-	function form_breadcrumb($info=''){
85
-	 $form=false;
86
-	 if(!empty($info))
87
- 	$form.="<div class='breadcrumb'>
83
+if ( ! function_exists('form_breadcrumb')) {
84
+	function form_breadcrumb($info = '') {
85
+	 $form = false;
86
+	 if ( ! empty($info))
87
+ 	$form .= "<div class='breadcrumb'>
88 88
 	        <a href='".$info['url']."'>".$info['name']."</a>
89 89
 		</div>";
90 90
 	return $form;
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
                    		</span>
213 213
                    </div>
214 214
                </div>';
215
-		}else{
215
+		} else {
216 216
 			return "<div class='col-md-5 no-padding'><image "._parse_form_attributes($data, $defaults).$extra." /></div>";
217 217
 		}	
218 218
 		
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	{
227 227
 				//  echo '<pre>'; print_r($data); exit;
228 228
 			//$data["class"] = "col-md-5 form-control";
229
-			$data['value']='Delete';
229
+			$data['value'] = 'Delete';
230 230
 		$defaults = array('type' => 'button', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => 'Delete');
231 231
 
232 232
 		return "<div class='col-md-5 no-padding'><input "._parse_form_attributes($data, $defaults).$extra." /></div>";
@@ -377,21 +377,21 @@  discard block
 block discarded – undo
377 377
 
378 378
 		if ($extra != '') $extra = ' '.$extra;
379 379
 		$multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : '';
380
-				if(is_array($name)){
381
-					 $str=null;
382
-					 foreach($name as $key=>$value){
383
-					  if($key !='class' && $key!='disabled')
384
-					  $str.=$key."='$value' ";
380
+				if (is_array($name)) {
381
+					 $str = null;
382
+					 foreach ($name as $key=>$value) {
383
+					  if ($key != 'class' && $key != 'disabled')
384
+					  $str .= $key."='$value' ";
385 385
 					 }
386
-					 if(isset($name['disabled']) && $name['disabled']== 'disabled'){
387
-					  $str.='disabled = "disabled"';
386
+					 if (isset($name['disabled']) && $name['disabled'] == 'disabled') {
387
+					  $str .= 'disabled = "disabled"';
388 388
 					 }
389 389
 							   $form = '<select '.$str." class='col-md-5 form-control selectpicker ".$name['class'].$extra."' data-live-search='true'>\n";
390
-				}else{
391
-					if(!empty($extra)){
392
-						$form = '<select  name="'.$name.'"' .$multiple." class='col-md-5 form-control selectpicker ".$extra."' data-live-search='true'>\n";
393
-					}else{
394
-						$form = '<select  name="'.$name.'"' .$multiple." class='col-md-5 form-control selectpicker' data-live-search='true'>\n";
390
+				} else {
391
+					if ( ! empty($extra)) {
392
+						$form = '<select  name="'.$name.'"'.$multiple." class='col-md-5 form-control selectpicker ".$extra."' data-live-search='true'>\n";
393
+					} else {
394
+						$form = '<select  name="'.$name.'"'.$multiple." class='col-md-5 form-control selectpicker' data-live-search='true'>\n";
395 395
 					}
396 396
 				}
397 397
 //                if($extra != '' ){
@@ -418,12 +418,12 @@  discard block
 block discarded – undo
418 418
 			{
419 419
 				$sel = (in_array($key, $selected)) ? ' selected="selected"' : '';
420 420
 
421
-				$form .= '<option value="'.$key.'"'.$sel.'>'.(string) $val."</option>\n";
421
+				$form .= '<option value="'.$key.'"'.$sel.'>'.(string)$val."</option>\n";
422 422
 			}
423 423
 		}
424
-				if(isset($name['option_value']) && isset($name['option_text'])){
425
-		  $sel= isset($name['value']) && $name['value']==$name['option_value']?'selected ="selected"':'';
426
-		  $form .= '<option value="'.$name['option_value'].'"'.$sel.'>'.(string) $name['option_text']."</option>\n";
424
+				if (isset($name['option_value']) && isset($name['option_text'])) {
425
+		  $sel = isset($name['value']) && $name['value'] == $name['option_value'] ? 'selected ="selected"' : '';
426
+		  $form .= '<option value="'.$name['option_value'].'"'.$sel.'>'.(string)$name['option_text']."</option>\n";
427 427
 				}
428 428
 		$form .= '</select>';
429 429
 //echo $form; exit;
@@ -449,21 +449,21 @@  discard block
 block discarded – undo
449 449
 			}
450 450
 		}
451 451
 		if ($extra != '') $extra = ' '.$extra;
452
-				$class= isset($name['class']) && !empty($name['class']) ? "col-md-5 form-control selectpicker $name[class]" :"col-md-5 form-control selectpicker";
452
+				$class = isset($name['class']) && ! empty($name['class']) ? "col-md-5 form-control selectpicker $name[class]" : "col-md-5 form-control selectpicker";
453 453
 		$multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : '';
454
-		if(is_array($name) && !isset($name["id"])){
454
+		if (is_array($name) && ! isset($name["id"])) {
455 455
 					$form = '<select name="'.$name['name'].'"'." class='$class' data-live-search='true'>\n";
456
-				}else if(is_array($name) && isset($name["id"])){
456
+				} else if (is_array($name) && isset($name["id"])) {
457 457
 					$form = '<select name="'.$name['name'].'" id="'.$name['id'].'"'."class='$class' data-live-search='true'>\n";
458 458
 				}
459
-				else{
460
-					$form = '<select name="'.$name.'"' .$multiple." class='$class' data-live-search='true'>\n";
459
+				else {
460
+					$form = '<select name="'.$name.'"'.$multiple." class='$class' data-live-search='true'>\n";
461 461
 				}   
462 462
 
463 463
 		$form .= '<option value=""> --Select-- </option>';
464 464
 		foreach ($options as $key => $val)
465 465
 		{
466
-			$key = (string) $key;
466
+			$key = (string)$key;
467 467
 
468 468
 			if (is_array($val) && ! empty($val))
469 469
 			{
@@ -481,12 +481,12 @@  discard block
 block discarded – undo
481 481
 			{
482 482
 				$sel = (in_array($key, $selected)) ? ' selected="selected"' : '';
483 483
 
484
-				$form .= '<option value="'.$key.'"'.$sel.'>'.(string) $val."</option>\n";
484
+				$form .= '<option value="'.$key.'"'.$sel.'>'.(string)$val."</option>\n";
485 485
 			}
486 486
 		}
487
-				if(isset($name['option_value']) && isset($name['option_text'])){
488
-		  $sel= isset($name['value']) && $name['value']==$name['option_value']?'selected ="selected"':'';
489
-		  $form .= '<option value="'.$name['option_value'].'"'.$sel.'>'.(string) $name['option_text']."</option>\n";
487
+				if (isset($name['option_value']) && isset($name['option_text'])) {
488
+		  $sel = isset($name['value']) && $name['value'] == $name['option_value'] ? 'selected ="selected"' : '';
489
+		  $form .= '<option value="'.$name['option_value'].'"'.$sel.'>'.(string)$name['option_text']."</option>\n";
490 490
 				}
491 491
 		$form .= '</select>';
492 492
 
@@ -517,35 +517,35 @@  discard block
 block discarded – undo
517 517
 		/*
518 518
 		  ASTPP  3.0  For Search Display In
519 519
 		*/
520
-		if ($extra != '' && !is_array($extra)) $extra = ' '.$extra;
520
+		if ($extra != '' && ! is_array($extra)) $extra = ' '.$extra;
521 521
 			/**********************************************************/
522 522
 
523
-		$class= isset($name['class']) && !empty($name['class']) ? "col-md-5 form-control selectpicker $name[class]" :"col-md-5 form-control selectpicker";
523
+		$class = isset($name['class']) && ! empty($name['class']) ? "col-md-5 form-control selectpicker $name[class]" : "col-md-5 form-control selectpicker";
524 524
 
525 525
 		$multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : '';
526 526
 				/*
527 527
 		  ASTPP  3.0  For Search Display In
528 528
 		*/
529
-				if(empty($extra)){
529
+				if (empty($extra)) {
530 530
 				/*********************************/
531
-		if(is_array($name) && !isset($name["id"])){
531
+		if (is_array($name) && ! isset($name["id"])) {
532 532
 					$form = '<select name="'.$name['name'].'"'." class='col-md-5 form-control $class' style='margin-left:5px;' data-live-search='true'>\n";
533
-				}else if(is_array($name) && isset($name["id"])){
533
+				} else if (is_array($name) && isset($name["id"])) {
534 534
 					$form = '<select name="'.$name['name'].'" id="'.$name['id'].'"'."class='col-md-5 form-control $class' style='margin-left:5px;' data-live-search='true'>\n";
535
-				}else{
536
-					$form = '<select name="'.$name.'"' .$multiple." class='col-md-5 form-control $class' style='margin-left:5px;' data-live-search='true'>\n";
535
+				} else {
536
+					$form = '<select name="'.$name.'"'.$multiple." class='col-md-5 form-control $class' style='margin-left:5px;' data-live-search='true'>\n";
537 537
 				}   
538 538
  /*
539 539
 		  ASTPP  3.0  For Search Display In
540 540
 		*/
541
-				}else{
541
+				} else {
542 542
 
543 543
 					$form = '<select name="'.$name['name'].'" id="'.$name['id'].'"'."class='".$extra['class']." $class' style='".$extra['style']."' data-live-search='true'>\n";
544 544
 				 }
545 545
 		//$form .= '<option value=""> --Select-- </option>';
546 546
 		foreach ($options as $key => $val)
547 547
 		{
548
-			$key = (string) $key;
548
+			$key = (string)$key;
549 549
 
550 550
 			if (is_array($val) && ! empty($val))
551 551
 			{
@@ -685,13 +685,13 @@  discard block
 block discarded – undo
685 685
 		{
686 686
 			unset($defaults['checked']);
687 687
 		}
688
-		$class=NULL;
688
+		$class = NULL;
689 689
 
690 690
 //echo "<pre>".$value; print_r($extra); exit;
691
-		if(isset($extra[$value]) && !empty($extra) && $extra[$value] == '0'){
692
-		$class='onoffswitch-inner';
693
-		}else{
694
-		$class='onoffswitch-inner';
691
+		if (isset($extra[$value]) && ! empty($extra) && $extra[$value] == '0') {
692
+		$class = 'onoffswitch-inner';
693
+		} else {
694
+		$class = 'onoffswitch-inner';
695 695
  		}
696 696
 /*            if(isset($extra) && $extra != ''){
697 697
 	      if(isset($extra[0])){
Please login to merge, or discard this patch.
freeswitch/fs/lib/astpp.cdr.php 1 patch
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 
47 47
 	if ($dataVariable['billsec'] == 0 && $dataVariable['hangup_cause'] == 'NORMAL_CLEARING')
48 48
 	{
49
-		$hangup_cause = isset($dataVariable['last_bridge_hangup_cause'])?$dataVariable['last_bridge_hangup_cause']:$dataVariable['hangup_cause'];
50
-	}else{
49
+		$hangup_cause = isset($dataVariable['last_bridge_hangup_cause']) ? $dataVariable['last_bridge_hangup_cause'] : $dataVariable['hangup_cause'];
50
+	} else {
51 51
 		$hangup_cause = $dataVariable['hangup_cause'];
52 52
 	}   
53 53
 
54 54
 	if ($dataVariable['error_cdr'] == '1')
55 55
 	{
56 56
 		//Get actual hangup cause 
57
-		$hangup_cause= (isset($dataVariable['error_cdr'])) ? $dataVariable['last_bridge_hangup_cause'] : (isset($dataVariable['last_bridge_hangup_cause'])?$dataVariable['last_bridge_hangup_cause']:$dataVariable['hangup_cause']); 
57
+		$hangup_cause = (isset($dataVariable['error_cdr'])) ? $dataVariable['last_bridge_hangup_cause'] : (isset($dataVariable['last_bridge_hangup_cause']) ? $dataVariable['last_bridge_hangup_cause'] : $dataVariable['hangup_cause']); 
58 58
 	}
59 59
 
60 60
 	/*#### PATCH FOR ONE WAY AUDIO ####*/
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 	/*#### ************* END *************####*/
66 66
 
67 67
 	//Don't thing this will be useful anytime. Need to remove it after testing. 
68
-	if($hangup_cause == "NONE")
68
+	if ($hangup_cause == "NONE")
69 69
 	{
70 70
 		$hangup_cause = $dataVariable['current_application_data'];
71 71
 	}
72 72
 
73 73
 	$dataVariable['hangup_cause'] = $hangup_cause;
74 74
 
75
-	if ( ($dataVariable['hangup_cause'] != 'NORMAL_CLEARING') && ($dataVariable['hangup_cause'] != 'ALLOTTED_TIMEOUT')) {
75
+	if (($dataVariable['hangup_cause'] != 'NORMAL_CLEARING') && ($dataVariable['hangup_cause'] != 'ALLOTTED_TIMEOUT')) {
76 76
 	  	$dataVariable['billsec'] = 0;
77 77
 	}
78 78
 
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 	$actual_calltype = $dataVariable['calltype'];
87 87
 	
88 88
 	//Normalize origination and termination rates array 		   
89
-	if(isset($dataVariable['origination_rates']))
89
+	if (isset($dataVariable['origination_rates']))
90 90
 	   $origination_rate = normalize_origination_rate($dataVariable['origination_rates']);
91
-	if(isset($dataVariable['termination_rates']))
91
+	if (isset($dataVariable['termination_rates']))
92 92
 	   $termination_rate = normalize_rate($dataVariable['termination_rates']);
93 93
 
94 94
 	//If receiver account id found then explicitly set call direction and call type 
95
-	if(isset($dataVariable['receiver_accid']))
95
+	if (isset($dataVariable['receiver_accid']))
96 96
 	{
97 97
 		$dataVariable['call_direction'] = "outbound";
98 98
 		$dataVariable['calltype'] = "STANDARD";
@@ -101,23 +101,23 @@  discard block
 block discarded – undo
101 101
 	//Check if cusotmer have any package seconds left to use
102 102
 	if ($actual_duration > 0)			
103 103
 	{
104
-			$package_array = package_calculation( $dataVariable['effective_destination_number'],$origination_rate[$accountid]['RATEGROUP'],$actual_duration,$dataVariable['call_direction'],$accountid,$db,$logger);
105
-			if(!empty($package_array))
104
+			$package_array = package_calculation($dataVariable['effective_destination_number'], $origination_rate[$accountid]['RATEGROUP'], $actual_duration, $dataVariable['call_direction'], $accountid, $db, $logger);
105
+			if ( ! empty($package_array))
106 106
 			{
107 107
 				$dataVariable['calltype'] = "FREE";
108
-				$dataVariable['package_id']= $package_array['package_id'];
108
+				$dataVariable['package_id'] = $package_array['package_id'];
109 109
 			}
110 110
 	}
111 111
 	
112 112
 	//Calculate debit of customer call 			
113
-	$debit = calc_cost($dataVariable,$origination_rate[$accountid],$logger,$decimal_points);
113
+	$debit = calc_cost($dataVariable, $origination_rate[$accountid], $logger, $decimal_points);
114 114
 
115 115
 	//Calculate cost for customer call for provider
116
-	$provider_cost = calc_cost($dataVariable,$termination_rate,$logger,$decimal_points);
116
+	$provider_cost = calc_cost($dataVariable, $termination_rate, $logger, $decimal_points);
117 117
 
118 118
 	//Calculate parent cost if customer have any parent 
119
-	$parent_cost = ($parentid > 0) ? calc_cost($dataVariable,$origination_rate[$parentid],$logger,$decimal_points) : $provider_cost;
120
-	$logger->log("Debit :".$debit ." Cost : ".$cost ." Provider Cost : ".$parent_cost);
119
+	$parent_cost = ($parentid > 0) ? calc_cost($dataVariable, $origination_rate[$parentid], $logger, $decimal_points) : $provider_cost;
120
+	$logger->log("Debit :".$debit." Cost : ".$cost." Provider Cost : ".$parent_cost);
121 121
     
122 122
 	//Initialize final cost variable to use for billing
123 123
 	$cost = ($parent_cost > 0) ? $parent_cost : $provider_cost;    
@@ -125,33 +125,33 @@  discard block
 block discarded – undo
125 125
 	//Outbound call entry for all type of calls 
126 126
 	$logger->log("*********************** OUTBOUND CALL ENTRY START *************");
127 127
 
128
-	$cdr_string = get_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost,$logger);
128
+	$cdr_string = get_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost, $logger);
129 129
 
130 130
 	$query = "INSERT INTO cdrs (uniqueid,accountid,type,callerid,callednum,billseconds,trunk_id,trunkip,callerip,disposition,callstart,debit,cost,provider_id,pricelist_id,package_id,pattern,notes,rate_cost,reseller_id,reseller_code,reseller_code_destination,reseller_cost,provider_code,provider_code_destination,provider_cost,provider_call_cost,call_direction,calltype,profile_start_stamp,answer_stamp,bridge_stamp,progress_stamp,progress_media_stamp,end_stamp,billmsec,answermsec,waitmsec,progress_mediamsec,flow_billmsec)  values ($cdr_string)";
131 131
 	$logger->log($query);
132 132
 	$db->run($query);
133 133
 	
134 134
 	//Update customer balance
135
-	if($debit > 0 && $dataVariable['calltype'] != "FREE")
135
+	if ($debit > 0 && $dataVariable['calltype'] != "FREE")
136 136
 	{
137 137
 		update_balance($accountid, $debit, 0, $logger, $db);
138 138
 	}
139 139
 
140 140
 	//Update parent or provider balance
141
-	if($parent_cost > 0){
141
+	if ($parent_cost > 0) {
142 142
 		update_balance($termination_rate['PROVIDER'], ($parent_cost * -1), 3, $logger, $db);
143 143
 	}
144 144
 
145 145
 	//Resellers CDR entry
146 146
 	$flag_parent = false;
147
-	insert_parent_data($dataVariable,$actual_calltype,$parentid,$origination_rate,$actual_duration,$provider_cost,$flag_parent,$logger,$db,$decimal_points);
147
+	insert_parent_data($dataVariable, $actual_calltype, $parentid, $origination_rate, $actual_duration, $provider_cost, $flag_parent, $logger, $db, $decimal_points);
148 148
 
149 149
 	$logger->log("*********************** OUTBOUND CALL ENTRY END *************");
150 150
 
151 151
    
152 152
 	//************ ADDING EXTRA ENTRY For local/DID Inbound call ****************************
153
-	$receiver_parentid=0;
154
-	if(isset($dataVariable['receiver_accid']) && $dataVariable['receiver_accid'] != "")
153
+	$receiver_parentid = 0;
154
+	if (isset($dataVariable['receiver_accid']) && $dataVariable['receiver_accid'] != "")
155 155
 	{
156 156
 		$logger->log("*********************** EXTRA ENTRY SECTION FOR BILLING START *************");            
157 157
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		$dataVariable['calltype'] = "DID";
161 161
 
162 162
 		//Override variables if call for DID PSTN
163
-		if(isset($dataVariable['caller_did_account_id']))
163
+		if (isset($dataVariable['caller_did_account_id']))
164 164
 		{
165 165
 			$dataVariable['receiver_accid'] = $dataVariable['caller_did_account_id'];
166 166
 			$dataVariable['call_direction'] = "outbound";
@@ -171,17 +171,17 @@  discard block
 block discarded – undo
171 171
         
172 172
 
173 173
 		//Get call receiver account information 
174
-		$receiver_carddata = get_accounts($dataVariable['receiver_accid'],$logger,$db);
174
+		$receiver_carddata = get_accounts($dataVariable['receiver_accid'], $logger, $db);
175 175
 		$receiver_parentid = $receiver_carddata['reseller_id'];
176 176
 
177 177
 		//For additional cdr entry of receiver
178
-		insert_extra_receiver_entry($dataVariable,$origination_rate,$termination_rate,$account_type,$actual_duration,$provider_cost,$receiver_parentid,$flag_parent,$dataVariable['receiver_accid'],$logger,$db,$decimal_points);
178
+		insert_extra_receiver_entry($dataVariable, $origination_rate, $termination_rate, $account_type, $actual_duration, $provider_cost, $receiver_parentid, $flag_parent, $dataVariable['receiver_accid'], $logger, $db, $decimal_points);
179 179
 
180 180
 		$flag_parent = true;
181 181
 		$dataVariable['uuid'] = $dataVariable['uuid'].$dataVariable['calltype']."_".$receiver_parentid;
182 182
 
183 183
 		//Insert parent reseller cdr
184
-		insert_parent_data($dataVariable,$actual_calltype,$receiver_parentid,$origination_rate,$actual_duration,$provider_cost,$flag_parent,$logger,$db,$decimal_points);
184
+		insert_parent_data($dataVariable, $actual_calltype, $receiver_parentid, $origination_rate, $actual_duration, $provider_cost, $flag_parent, $logger, $db, $decimal_points);
185 185
 		$logger->log("*********************** EXTRA ENTRY SECTION FOR BILLING END *************");            
186 186
 	}
187 187
 	//*****************************************************************************************
@@ -193,16 +193,16 @@  discard block
 block discarded – undo
193 193
  * @param string $provider_cost
194 194
  * @param boolean $flag_parent
195 195
  */
196
-function insert_parent_data($dataVariable,$actual_calltype,$parentid,$origination_rate,$actual_duration,$provider_cost,$flag_parent,$logger,$db,$decimal_points)
196
+function insert_parent_data($dataVariable, $actual_calltype, $parentid, $origination_rate, $actual_duration, $provider_cost, $flag_parent, $logger, $db, $decimal_points)
197 197
 {
198
-	while($parentid > 0 )
198
+	while ($parentid > 0)
199 199
 	{
200 200
 		$logger->log("*************** IN PARENT DATA SECTION ********");
201 201
 		$dataVariable['calltype'] = $actual_calltype;
202
-		$carddata = get_accounts($parentid,$logger,$db);
202
+		$carddata = get_accounts($parentid, $logger, $db);
203 203
 		$accountid = $carddata['id'];
204 204
 
205
-		$debit = calc_cost($dataVariable,$origination_rate[$accountid],$logger,$decimal_points);
205
+		$debit = calc_cost($dataVariable, $origination_rate[$accountid], $logger, $decimal_points);
206 206
 
207 207
 		//If receiver account id found then explicitly set call direction and call type
208 208
 		/*if(isset($dataVariable['receiver_accid']))
@@ -212,31 +212,31 @@  discard block
 block discarded – undo
212 212
         }*/
213 213
 
214 214
 		//Check if reseller have any package seconds left to use        
215
-		if ($actual_duration > 0)		{
216
-			$package_array = package_calculation( $dataVariable['effective_destination_number'],$origination_rate[$accountid]['RATEGROUP'],$actual_duration,$dataVariable['call_direction'],$accountid,$db,$logger);
217
-			if(!empty($package_array))
215
+		if ($actual_duration > 0) {
216
+			$package_array = package_calculation($dataVariable['effective_destination_number'], $origination_rate[$accountid]['RATEGROUP'], $actual_duration, $dataVariable['call_direction'], $accountid, $db, $logger);
217
+			if ( ! empty($package_array))
218 218
 			{
219 219
 				$dataVariable['calltype'] = "FREE";
220
-				$dataVariable['package_id']= $package_array['package_id'];
220
+				$dataVariable['package_id'] = $package_array['package_id'];
221 221
 			}
222 222
 		}	
223 223
 
224 224
 		//Get parent id for cost calculation 
225 225
 		$parentid = $carddata['reseller_id'];
226
-		$parent_cost = ($parentid > 0) ? calc_cost($dataVariable,$origination_rate[$parentid],$logger,$decimal_points) : $provider_cost;
226
+		$parent_cost = ($parentid > 0) ? calc_cost($dataVariable, $origination_rate[$parentid], $logger, $decimal_points) : $provider_cost;
227 227
 		$cost = ($parent_cost > 0) ? $parent_cost : $provider_cost;
228 228
 	
229
-		if(isset($dataVariable['receiver_accid']) && $dataVariable['receiver_accid'] != "" && $flag_parent == true)
229
+		if (isset($dataVariable['receiver_accid']) && $dataVariable['receiver_accid'] != "" && $flag_parent == true)
230 230
 		{
231 231
 			$logger->log("********* IN RESELLER FOR RECEIVER ENTRY START ******");
232 232
 			$flag_parent = true;
233
-			insert_extra_receiver_entry($dataVariable,$origination_rate,$termination_rate,$account_type,$actual_duration,$provider_cost,$parentid,$flag_parent,$accountid,$logger,$db,$decimal_points);
233
+			insert_extra_receiver_entry($dataVariable, $origination_rate, $termination_rate, $account_type, $actual_duration, $provider_cost, $parentid, $flag_parent, $accountid, $logger, $db, $decimal_points);
234 234
 			$logger->log("********* IN RESELLER FOR RECEIVER ENTRY END ******");
235 235
 			return true;	
236 236
 
237
-		} else{
237
+		} else {
238 238
 
239
-			$cdr_string = get_reseller_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost);	
239
+			$cdr_string = get_reseller_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost);	
240 240
 
241 241
  			$query = "INSERT INTO reseller_cdrs (uniqueid,accountid,callerid,callednum,billseconds,disposition,callstart,debit,cost,pricelist_id,package_id,pattern,notes,rate_cost,
242 242
 		reseller_id,reseller_code,reseller_code_destination,reseller_cost,call_direction,calltype) values ($cdr_string)";
@@ -257,38 +257,38 @@  discard block
 block discarded – undo
257 257
 /**
258 258
  * @param boolean $flag_parent
259 259
  */
260
-function insert_extra_receiver_entry($dataVariable,$origination_rate,$termination_rate,$account_type,$actual_duration,$provider_cost,$parentid,$flag_parent,$accountid,$logger,$db,$decimal_points)
260
+function insert_extra_receiver_entry($dataVariable, $origination_rate, $termination_rate, $account_type, $actual_duration, $provider_cost, $parentid, $flag_parent, $accountid, $logger, $db, $decimal_points)
261 261
 {
262 262
 		$localVariable = $dataVariable;
263 263
 		$localVariable['call_direction'] = "inbound";
264 264
 		$localVariable['uuid'] = $localVariable['uuid'].$dataVariable['calltype']."_".$accountid;
265 265
 		
266
-		if($dataVariable['calltype'] == "LOCAL")
266
+		if ($dataVariable['calltype'] == "LOCAL")
267 267
 		{
268 268
 			$origination_rate[$accountid]['CODE'] = $dataVariable['effective_destination_number'];
269 269
 			$origination_rate[$accountid]['DESTINATION'] = $dataVariable['calltype'];
270
-			if($flag_parent == false){
271
-				$cdr_string = get_cdr_string($localVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,0,0,$logger);
272
-			} else{
273
-				$cdr_string = get_reseller_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost);
270
+			if ($flag_parent == false) {
271
+				$cdr_string = get_cdr_string($localVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, 0, 0, $logger);
272
+			} else {
273
+				$cdr_string = get_reseller_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost);
274 274
 			}
275
-		} else{
275
+		} else {
276 276
 
277 277
 			$origination_rate_did = normalize_origination_rate($dataVariable['origination_rates_did']);
278
-			$debit = calc_cost($dataVariable,$origination_rate_did[$accountid],$logger,$decimal_points);
278
+			$debit = calc_cost($dataVariable, $origination_rate_did[$accountid], $logger, $decimal_points);
279 279
 
280
-			if($flag_parent == false){
280
+			if ($flag_parent == false) {
281 281
 				
282
-				$cdr_string = get_cdr_string($localVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate_did,$provider_cost,$parentid,$debit,0,$logger);
283
-			} else{
284
-				$cdr_string = get_reseller_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost);
282
+				$cdr_string = get_cdr_string($localVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate_did, $provider_cost, $parentid, $debit, 0, $logger);
283
+			} else {
284
+				$cdr_string = get_reseller_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost);
285 285
 			}
286 286
 		}
287 287
 	  
288
-		if($flag_parent == false)
288
+		if ($flag_parent == false)
289 289
 		{
290 290
 			$query = "INSERT INTO cdrs(uniqueid,accountid,type,callerid,callednum,billseconds,trunk_id,trunkip,callerip,disposition,callstart,debit,cost,provider_id,pricelist_id,package_id,pattern,notes,rate_cost,reseller_id,reseller_code,reseller_code_destination,reseller_cost,provider_code,provider_code_destination,provider_cost,provider_call_cost,call_direction,calltype,profile_start_stamp,answer_stamp,bridge_stamp,progress_stamp,progress_media_stamp,end_stamp,billmsec,answermsec,waitmsec,progress_mediamsec,flow_billmsec) values ($cdr_string)";
291
-		} else{
291
+		} else {
292 292
 			$query = "INSERT INTO reseller_cdrs (uniqueid,accountid,callerid,callednum,billseconds,disposition,callstart,debit,cost,pricelist_id,package_id,pattern,notes,rate_cost,
293 293
 	reseller_id,reseller_code,reseller_code_destination,reseller_cost,call_direction,calltype) values ($cdr_string)";
294 294
 		}
@@ -304,22 +304,22 @@  discard block
 block discarded – undo
304 304
 }
305 305
 
306 306
 //Generate CDR string for insert query for customer.
307
-function get_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost,$logger)
307
+function get_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost, $logger)
308 308
 {
309 309
 
310
-		$dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER')?"DID":$dataVariable['calltype'];
310
+		$dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER') ? "DID" : $dataVariable['calltype'];
311 311
 
312
-		return  $cdr_string = "'".($dataVariable['uuid'])."','".$accountid."','".$account_type."','".(urldecode($dataVariable['caller_id']))."','".($dataVariable['effective_destination_number'])."','".$actual_duration."',".(($termination_rate['TRUNK']) ? $termination_rate['TRUNK'] : '0').",".(($dataVariable['sip_via_host']) ? "'".$dataVariable['sip_via_host']."'" : '').",".(($dataVariable['sip_contact_host']) ? "'".$dataVariable['sip_contact_host']."'" : '').",'".($dataVariable['hangup_cause'])."','".urldecode($dataVariable['callstart'])."','".$debit."','".$cost."',".(($termination_rate['PROVIDER']) ? $termination_rate['PROVIDER'] : '0').",'".$origination_rate[$accountid]['RATEGROUP']."','".$dataVariable['package_id']."','".($origination_rate[$accountid]['CODE'])."',".(($origination_rate[$accountid]['DESTINATION']) ? "'".htmlentities($origination_rate[$accountid]['DESTINATION'],ENT_COMPAT, 'UTF-8')."'" : "'".''."'").",".(($origination_rate[$accountid]['COST']) ? "'".$origination_rate[$accountid]['COST']."'" : "'".'0'."'").",
313
-'".$parentid."',".(($origination_rate[$parentid]['CODE'] ) ? "'".$origination_rate[$parentid]['CODE']."'" : "'".'0'."'").",".(($origination_rate[$parentid]['DESTINATION']) ?  "'".$origination_rate[$parentid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$parentid]['COST']) ?  "'".$origination_rate[$parentid]['COST']."'" :  '0').",".(($termination_rate['CODE']) ? "'".$termination_rate['CODE']."'" : "'".''."'" ).",
312
+		return  $cdr_string = "'".($dataVariable['uuid'])."','".$accountid."','".$account_type."','".(urldecode($dataVariable['caller_id']))."','".($dataVariable['effective_destination_number'])."','".$actual_duration."',".(($termination_rate['TRUNK']) ? $termination_rate['TRUNK'] : '0').",".(($dataVariable['sip_via_host']) ? "'".$dataVariable['sip_via_host']."'" : '').",".(($dataVariable['sip_contact_host']) ? "'".$dataVariable['sip_contact_host']."'" : '').",'".($dataVariable['hangup_cause'])."','".urldecode($dataVariable['callstart'])."','".$debit."','".$cost."',".(($termination_rate['PROVIDER']) ? $termination_rate['PROVIDER'] : '0').",'".$origination_rate[$accountid]['RATEGROUP']."','".$dataVariable['package_id']."','".($origination_rate[$accountid]['CODE'])."',".(($origination_rate[$accountid]['DESTINATION']) ? "'".htmlentities($origination_rate[$accountid]['DESTINATION'], ENT_COMPAT, 'UTF-8')."'" : "'".''."'").",".(($origination_rate[$accountid]['COST']) ? "'".$origination_rate[$accountid]['COST']."'" : "'".'0'."'").",
313
+'".$parentid."',".(($origination_rate[$parentid]['CODE']) ? "'".$origination_rate[$parentid]['CODE']."'" : "'".'0'."'").",".(($origination_rate[$parentid]['DESTINATION']) ? "'".$origination_rate[$parentid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$parentid]['COST']) ? "'".$origination_rate[$parentid]['COST']."'" : '0').",".(($termination_rate['CODE']) ? "'".$termination_rate['CODE']."'" : "'".''."'").",
314 314
 ".(($termination_rate['DESTINATION']) ? "'".$termination_rate['DESTINATION']."'" : "'".''."'").",".(($termination_rate['COST']) ? "'".$termination_rate['COST']."'" : '0').",'".$provider_cost."',".(($dataVariable['call_direction']) ? "'".$dataVariable['call_direction']."'" : "'internal'").",'".($dataVariable['calltype'])."','".convert_to_gmt(urldecode($dataVariable['profile_start_stamp']))."','".convert_to_gmt(urldecode($dataVariable['answer_stamp']))."','".convert_to_gmt(urldecode($dataVariable['bridge_stamp']))."','".convert_to_gmt(urldecode(@$dataVariable['progress_stamp']))."','".convert_to_gmt(urldecode(@$dataVariable['progress_media_stamp']))."','".convert_to_gmt(urldecode($dataVariable['end_stamp']))."',".$dataVariable['billmsec'].",'".$dataVariable['answermsec']."','".$dataVariable['waitmsec']."','".$dataVariable['progress_mediamsec']."','".$dataVariable['flow_billmsec']."'";
315 315
 
316 316
 }
317 317
 
318 318
 //Generate CDR string for insert query for reseller
319
-function get_reseller_cdr_string($dataVariable,$accountid,$account_type,$actual_duration,$termination_rate,$origination_rate,$provider_cost,$parentid,$debit,$cost)
319
+function get_reseller_cdr_string($dataVariable, $accountid, $account_type, $actual_duration, $termination_rate, $origination_rate, $provider_cost, $parentid, $debit, $cost)
320 320
 {
321
-        $dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER')?"DID":$dataVariable['calltype'];
322
-	return $cdr_string = "'".($dataVariable['uuid'])."','".$accountid."','".(urldecode($dataVariable['caller_id']))."','".($dataVariable['effective_destination_number'])."','".$actual_duration."','".($dataVariable['hangup_cause'])."','".convert_to_gmt(urldecode($dataVariable['callstart']))."','".$debit."','".$cost."','".$origination_rate[$accountid]['RATEGROUP']."','".$dataVariable['package_id']."','".($origination_rate[$accountid]['CODE'])."',".(($origination_rate[$accountid]['DESTINATION']) ? "'".$origination_rate[$accountid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$accountid]['COST']) ? "'".$origination_rate[$accountid]['COST']."'" : "'".'0'."'").",'".$parentid."',".(($origination_rate[$parentid]['CODE'] ) ? "'".$origination_rate[$parentid]['CODE']."'" : "'".'0'."'").",".(($origination_rate[$parentid]['DESTINATION']) ?  "'".$origination_rate[$parentid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$parentid]['COST']) ?  "'".$origination_rate[$parentid]['COST']."'" :  '0').",".(($dataVariable['call_direction']) ? "'".$dataVariable['call_direction']."'" : "'internal'").",'".($dataVariable['calltype'])."'";
321
+        $dataVariable['calltype'] = ($dataVariable['calltype'] == 'DID-LOCAL' || $dataVariable['calltype'] == 'SIP-DID' || $dataVariable['calltype'] == 'OTHER') ? "DID" : $dataVariable['calltype'];
322
+	return $cdr_string = "'".($dataVariable['uuid'])."','".$accountid."','".(urldecode($dataVariable['caller_id']))."','".($dataVariable['effective_destination_number'])."','".$actual_duration."','".($dataVariable['hangup_cause'])."','".convert_to_gmt(urldecode($dataVariable['callstart']))."','".$debit."','".$cost."','".$origination_rate[$accountid]['RATEGROUP']."','".$dataVariable['package_id']."','".($origination_rate[$accountid]['CODE'])."',".(($origination_rate[$accountid]['DESTINATION']) ? "'".$origination_rate[$accountid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$accountid]['COST']) ? "'".$origination_rate[$accountid]['COST']."'" : "'".'0'."'").",'".$parentid."',".(($origination_rate[$parentid]['CODE']) ? "'".$origination_rate[$parentid]['CODE']."'" : "'".'0'."'").",".(($origination_rate[$parentid]['DESTINATION']) ? "'".$origination_rate[$parentid]['DESTINATION']."'" : "'".''."'").",".(($origination_rate[$parentid]['COST']) ? "'".$origination_rate[$parentid]['COST']."'" : '0').",".(($dataVariable['call_direction']) ? "'".$dataVariable['call_direction']."'" : "'internal'").",'".($dataVariable['calltype'])."'";
323 323
 }
324 324
 
325 325
 //Update user balance
@@ -328,8 +328,8 @@  discard block
 block discarded – undo
328 328
  */
329 329
 function update_balance($user_id, $amount, $entity_id, $logger, $db) {
330 330
     $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+';
331
-    $query = "UPDATE accounts SET balance=balance-" . $amount . " WHERE id=" . $user_id;
332
-    $logger->log("Balance update : " . $query);
331
+    $query = "UPDATE accounts SET balance=balance-".$amount." WHERE id=".$user_id;
332
+    $logger->log("Balance update : ".$query);
333 333
     $db->run($query);
334 334
 }
335 335
 
@@ -388,46 +388,46 @@  discard block
 block discarded – undo
388 388
     
389 389
 			if ($billseconds > 0)
390 390
 			{
391
-				$call_cost += (ceil($billseconds/$rates['INC'])*$rates['INC'])*($rates['COST']/60);
391
+				$call_cost += (ceil($billseconds / $rates['INC']) * $rates['INC']) * ($rates['COST'] / 60);
392 392
 			}
393 393
 	}
394
-	$call_cost = number_format($call_cost,$decimal_points);
394
+	$call_cost = number_format($call_cost, $decimal_points);
395 395
 	$logger->log("Return cost ".$call_cost);
396 396
 	return $call_cost;
397 397
 }
398 398
 
399 399
 // get intial package information
400
-function package_calculation($destination_number,$pricelist_id,$duration,$call_direction,$accountid,$db,$logger)
400
+function package_calculation($destination_number, $pricelist_id, $duration, $call_direction, $accountid, $db, $logger)
401 401
 {
402 402
 	$package_array = array();
403
-	$custom_destination = number_loop($destination_number,"patterns",$db);
403
+	$custom_destination = number_loop($destination_number, "patterns", $db);
404 404
 
405 405
 	$query = "SELECT * FROM packages  as P inner join package_patterns as PKGPTR on P.id = PKGPTR.package_id WHERE ".$custom_destination." AND status = 0 AND pricelist_id = ".$pricelist_id." ORDER BY LENGTH(PKGPTR.patterns) DESC LIMIT 1";
406 406
 
407 407
 	$package_info = $db->run($query);
408
-	if($package_info){
408
+	if ($package_info) {
409 409
 		$package_info = $package_info[0];
410 410
 
411
-		if( ($package_info['applicable_for'] == "0" && $call_direction == "outbound") || ($package_info['applicable_for'] == "1" && $call_direction == "inbound") || ($package_info['applicable_for'] == "2") ) {
411
+		if (($package_info['applicable_for'] == "0" && $call_direction == "outbound") || ($package_info['applicable_for'] == "1" && $call_direction == "inbound") || ($package_info['applicable_for'] == "2")) {
412 412
 	
413
-			$counter_info =  get_counters($accountid,$package_info['package_id'],$db,$logger);
413
+			$counter_info = get_counters($accountid, $package_info['package_id'], $db, $logger);
414 414
 
415
-			if(!$counter_info) {
415
+			if ( ! $counter_info) {
416 416
 				$Insert_Query = "INSERT INTO counters (package_id,accountid) VALUES (".$package_info['package_id'].",".$accountid.")";		
417
-				$logger->log("Insert Counters  : " . $Insert_query);
417
+				$logger->log("Insert Counters  : ".$Insert_query);
418 418
 				$db->run($Insert_Query);
419
-				$counter_info =  get_counters($accountid,$package_info['package_id'],$db,$logger);
419
+				$counter_info = get_counters($accountid, $package_info['package_id'], $db, $logger);
420 420
 				
421 421
 			}	
422 422
 			//print_r($counter_info);
423
-			if ( $package_info['includedseconds'] > ($counter_info['seconds'] )) {
423
+			if ($package_info['includedseconds'] > ($counter_info['seconds'])) {
424 424
 				$availableseconds = $package_info['includedseconds'] - $counter_info['seconds'];
425 425
 				$freeseconds = ($availableseconds >= $duration) ? $duration : $availableseconds;
426 426
 				$duration = ($availableseconds >= $duration) ? $duration : $availableseconds;
427
-				$update_query = "UPDATE counters SET seconds = ".($counter_info['seconds'] + $freeseconds ). " WHERE id = ". $counter_info['id'];
428
-				$logger->log("Update Counters  : " . $update_query);
427
+				$update_query = "UPDATE counters SET seconds = ".($counter_info['seconds'] + $freeseconds)." WHERE id = ".$counter_info['id'];
428
+				$logger->log("Update Counters  : ".$update_query);
429 429
 				$db->run($update_query);
430
-				$package_array['package_id']= $package_info['package_id'];
430
+				$package_array['package_id'] = $package_info['package_id'];
431 431
 				$package_array['calltype'] = "FREE";
432 432
 			}						
433 433
 		} 
@@ -436,21 +436,21 @@  discard block
 block discarded – undo
436 436
 } 
437 437
 
438 438
 // Getting used package minutes in counter table
439
-function get_counters($accountid,$package_id,$db,$logger)
439
+function get_counters($accountid, $package_id, $db, $logger)
440 440
 {
441 441
 	$query_counter = "SELECT id,seconds FROM counters  WHERE  accountid = ".$accountid." AND package_id = ".$package_id." AND status=1 LIMIT 1";
442 442
 	$counter = $db->run($query_counter);
443
-	$logger->log("GET Counters  : " . $query_counter);
444
-	if($counter)
443
+	$logger->log("GET Counters  : ".$query_counter);
444
+	if ($counter)
445 445
 		return $counter[0];	
446 446
 	else
447 447
 		return "";
448 448
 }
449 449
 
450 450
 //Get user info
451
-function get_accounts($parent_id,$logger, $db) {
452
-	$query = "SELECT * FROM accounts WHERE id=" . $parent_id;
453
-	$logger->log("GET configuration  : " . $query);
451
+function get_accounts($parent_id, $logger, $db) {
452
+	$query = "SELECT * FROM accounts WHERE id=".$parent_id;
453
+	$logger->log("GET configuration  : ".$query);
454 454
 	$res_user = $db->run($query);
455 455
 	return $res_user[0];
456 456
 }
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 {
461 461
 	$query = "SELECT name,value FROM system WHERE name='decimal_points' and group_title = 'global'";
462 462
 	$config = $db->run($query);
463
-	$logger->log("GET configuration  : " . $query);
463
+	$logger->log("GET configuration  : ".$query);
464 464
 	return $config[0];
465 465
 }
466 466
 
@@ -468,16 +468,16 @@  discard block
 block discarded – undo
468 468
 /**
469 469
  * @param string $field
470 470
  */
471
-function number_loop($destination,$field,$db)
471
+function number_loop($destination, $field, $db)
472 472
 {
473
-	$max_len_prefix  = strlen($destination);
473
+	$max_len_prefix = strlen($destination);
474 474
 	$number_prefix = '(';
475
-	while ($max_len_prefix  > 0)
475
+	while ($max_len_prefix > 0)
476 476
 	{
477
-		$number_prefix .= "$field='^".substr($destination,0,$max_len_prefix).".*' OR ";
477
+		$number_prefix .= "$field='^".substr($destination, 0, $max_len_prefix).".*' OR ";
478 478
 		$max_len_prefix--;
479 479
 	}
480
-	$number_prefix .= "$field='^defaultprefix.*')";//echo $number_prefix;exit;
480
+	$number_prefix .= "$field='^defaultprefix.*')"; //echo $number_prefix;exit;
481 481
 	return $number_prefix;
482 482
 }
483 483
 
@@ -487,6 +487,6 @@  discard block
 block discarded – undo
487 487
  */
488 488
 function convert_to_gmt($date)
489 489
 {
490
-	return gmdate('Y-m-d H:i:s', strtotime($date) );
490
+	return gmdate('Y-m-d H:i:s', strtotime($date));
491 491
 }
492 492
 ?>
Please login to merge, or discard this patch.
freeswitch/fs/lib/astpp.xml.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 }
37 37
 
38 38
 //Build acl xml
39
-function load_acl($logger, $db,$config) {
39
+function load_acl($logger, $db, $config) {
40 40
 	$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
41 41
 	$xml .= "<document type=\"freeswitch/xml\">\n";
42 42
 	$xml .= "   <section name=\"Configuration\" description=\"Configuration\">\n";
@@ -46,29 +46,29 @@  discard block
 block discarded – undo
46 46
 	
47 47
 	//For customer and provider ips
48 48
 	$query = "SELECT ip FROM ip_map,accounts WHERE ip_map.accountid=accounts.id AND accounts.status=0 AND deleted=0";
49
-	$logger->log("ACL Query : " . $query);
49
+	$logger->log("ACL Query : ".$query);
50 50
 	$res_acl = $db->run($query);
51 51
 	$logger->log($res_acl);
52 52
 
53 53
 	foreach ($res_acl as $res_acl_key => $res_acl_value) {
54
-		$xml .= "       <node type=\"allow\" cidr=\"" . $res_acl_value['ip'] . "\"/>\n";
54
+		$xml .= "       <node type=\"allow\" cidr=\"".$res_acl_value['ip']."\"/>\n";
55 55
 	}
56 56
 
57 57
 	//For gateways
58 58
 	$query = "SELECT * FROM gateways WHERE status=0";
59
-	$logger->log("Sofia Gateway Query : " . $query);
59
+	$logger->log("Sofia Gateway Query : ".$query);
60 60
 	$sp_gw = $db->run($query);
61 61
 	$logger->log($sp_gw);
62 62
 
63 63
 	foreach ($sp_gw as $sp_gw_key => $sp_gw_value) {
64 64
 
65
-			$sp_gw_settings  = json_decode($sp_gw_value['gateway_data'], true);
65
+			$sp_gw_settings = json_decode($sp_gw_value['gateway_data'], true);
66 66
 			foreach ($sp_gw_settings as $sp_gw_settings_key => $sp_gw_settings_value) {
67 67
 				if ($sp_gw_settings_value != "" && $sp_gw_settings_key == "proxy")
68 68
 				{
69
-					$tmp_ip_arr = explode(":",$sp_gw_settings_value);
70
-					if (!filter_var($tmp_ip_arr[0], FILTER_VALIDATE_IP) === false) {
71
-						$xml .= "   <node type=\"allow\" cidr=\"" . $tmp_ip_arr[0] . "/32\"/>\n";
69
+					$tmp_ip_arr = explode(":", $sp_gw_settings_value);
70
+					if ( ! filter_var($tmp_ip_arr[0], FILTER_VALIDATE_IP) === false) {
71
+						$xml .= "   <node type=\"allow\" cidr=\"".$tmp_ip_arr[0]."/32\"/>\n";
72 72
 					}
73 73
 				}
74 74
 	   	}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 
79 79
 	//For opensips
80
-	if($config['opensips'] == '0')
80
+	if ($config['opensips'] == '0')
81 81
 	{
82 82
 		$xml .= "<node type=\"allow\" cidr=\"".$config['opensips_domain']."/32\"/>\n";     
83 83
 	}
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	$xml .= "       </list>\n";
86 86
 
87 87
 	//For loopback 
88
-	if($config['opensips'] == '0')
88
+	if ($config['opensips'] == '0')
89 89
 	{
90 90
 		$xml .= "<list name=\"loopback.auto\" default=\"allow\">\n";
91 91
 			$xml .= "<node type=\"allow\" cidr=\"".$config['opensips_domain']."/32\"/>\n";
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 
95 95
 	//For event handing
96 96
 	$xml .= "<list name=\"event\" default=\"deny\">\n";
97
-		$xml .= ($config['opensips'] == "0")?"<node type=\"allow\" cidr=\"".$config['opensips_domain']."/32\"/>\n":"\n";
97
+		$xml .= ($config['opensips'] == "0") ? "<node type=\"allow\" cidr=\"".$config['opensips_domain']."/32\"/>\n" : "\n";
98 98
 		$xml .= "<node type=\"allow\" cidr=\"127.0.0.0/8\"/>\n";
99 99
 	$xml .= "</list>\n";
100 100
 	$xml .= "           </network-lists>\n";
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	$xml .= "   <profiles>\n";
115 115
 
116 116
 	$query = "SELECT * FROM sip_profiles WHERE status=0";
117
-	$logger->log("Sofia Query : " . $query);
117
+	$logger->log("Sofia Query : ".$query);
118 118
 	$res_sp = $db->run($query);
119 119
 	//$logger->log($res_sp);
120 120
 
@@ -122,40 +122,40 @@  discard block
 block discarded – undo
122 122
 
123 123
 		$settings = json_decode($sp_value['profile_data'], true);
124 124
 		//$logger->log(print_r($settings,true));
125
-		$xml .= "   <profile name=\"" . $sp_value['name'] . "\">\n";
125
+		$xml .= "   <profile name=\"".$sp_value['name']."\">\n";
126 126
 
127 127
 		$xml .= "   <domains>\n";
128
-			$xml .= "       <domain name=\"" . $sp_value['sip_ip'] . "\" alias=\"true\" parse=\"true\"/>\n";
128
+			$xml .= "       <domain name=\"".$sp_value['sip_ip']."\" alias=\"true\" parse=\"true\"/>\n";
129 129
 		$xml .= "   </domains>\n";
130 130
 		/*$xml .= "   <aliases>\n";
131 131
             $xml .= "       <alias name=\"" . $sp_value['sip_ip'] . "\"/>\n";
132 132
         $xml .= "   </aliases>\n";*/
133 133
 
134 134
 	$xml .= "   <settings>\n";
135
-	$xml .= "       <param name=\"sip-ip\" value=\"" . $sp_value['sip_ip'] . "\"/>\n";
136
-	$xml .= "       <param name=\"sip-port\" value=\"" . $sp_value['sip_port'] . "\"/>\n";    
137
-	foreach($settings as $set_key => $set_val)
135
+	$xml .= "       <param name=\"sip-ip\" value=\"".$sp_value['sip_ip']."\"/>\n";
136
+	$xml .= "       <param name=\"sip-port\" value=\"".$sp_value['sip_port']."\"/>\n";    
137
+	foreach ($settings as $set_key => $set_val)
138 138
 	{
139
-			$xml .= "       <param name=\"" . $set_key . "\" value=\"" . $set_val . "\"/>\n";
139
+			$xml .= "       <param name=\"".$set_key."\" value=\"".$set_val."\"/>\n";
140 140
 	}
141 141
 		$xml .= "   </settings>\n";
142 142
 	
143 143
 
144 144
 		//Gateway block start 
145 145
 		$xml .= "   <gateways>\n";
146
-		$query = "SELECT * FROM gateways WHERE sip_profile_id=" . $sp_value['id'] . " AND status=0";
147
-		$logger->log("Sofia Gateway Query : " . $query);
146
+		$query = "SELECT * FROM gateways WHERE sip_profile_id=".$sp_value['id']." AND status=0";
147
+		$logger->log("Sofia Gateway Query : ".$query);
148 148
 		$sp_gw = $db->run($query);
149 149
 		$logger->log($sp_gw);
150 150
 		foreach ($sp_gw as $sp_gw_key => $sp_gw_value) {
151
-			$xml .= "       <gateway name=\"" . $sp_gw_value['name'] . "\">\n";
151
+			$xml .= "       <gateway name=\"".$sp_gw_value['name']."\">\n";
152 152
 
153 153
 
154 154
 
155
-		$sp_gw_settings  = json_decode($sp_gw_value['gateway_data'], true);
155
+		$sp_gw_settings = json_decode($sp_gw_value['gateway_data'], true);
156 156
 			foreach ($sp_gw_settings as $sp_gw_settings_key => $sp_gw_settings_value) {
157 157
 				if ($sp_gw_settings_value != "")
158
-					$xml .= "           <param name=\"" . $sp_gw_settings_key . "\" value=\"" . $sp_gw_settings_value . "\"/>\n";
158
+					$xml .= "           <param name=\"".$sp_gw_settings_key."\" value=\"".$sp_gw_settings_value."\"/>\n";
159 159
 			}
160 160
 			$xml .= "       </gateway>\n";
161 161
 		}
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 function load_directory($logger, $db) {
178 178
 	$xml = "";
179 179
 
180
-	$query = "SELECT username,dir_params,dir_vars,number as accountcode,accountid FROM sip_devices,accounts WHERE accounts.status=0 AND accounts.deleted=0 AND accounts.id=sip_devices.accountid AND username='" . $_REQUEST['user']."' limit 1";
180
+	$query = "SELECT username,dir_params,dir_vars,number as accountcode,accountid FROM sip_devices,accounts WHERE accounts.status=0 AND accounts.deleted=0 AND accounts.id=sip_devices.accountid AND username='".$_REQUEST['user']."' limit 1";
181 181
 	
182
-	$logger->log("Directory Query : " . $query);
182
+	$logger->log("Directory Query : ".$query);
183 183
 	$res_dir = $db->run($query);
184 184
 	$logger->log($res_dir);
185 185
 
@@ -187,21 +187,21 @@  discard block
 block discarded – undo
187 187
 		$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
188 188
 		$xml .= "<document type=\"freeswitch/xml\">\n";
189 189
 		$xml .= "   <section name=\"Directory\" description=\"Directory\">\n";
190
-		$xml .= "       <domain name=\"" . $_REQUEST['domain'] . "\" alias=\"true\">\n";
191
-		$xml .= "           <user id=\"" . $_REQUEST['user'] . "\">\n";
190
+		$xml .= "       <domain name=\"".$_REQUEST['domain']."\" alias=\"true\">\n";
191
+		$xml .= "           <user id=\"".$_REQUEST['user']."\">\n";
192 192
 
193 193
 	$params = json_decode($res_dir_value['dir_params'], true);
194 194
 
195 195
 	$vars   = json_decode($res_dir_value['dir_vars'], true);
196 196
 	$param_xml = $var_xml = "";
197
-	foreach($params as $parms_key => $res_dir_params)
197
+	foreach ($params as $parms_key => $res_dir_params)
198 198
 	{	
199
-						$param_xml .= "<param name=\"" . $parms_key . "\" value=\"" . $res_dir_params . "\"/>\n";
199
+						$param_xml .= "<param name=\"".$parms_key."\" value=\"".$res_dir_params."\"/>\n";
200 200
 	}
201 201
 
202
-	foreach($vars as $var_key => $res_dir_vars)
202
+	foreach ($vars as $var_key => $res_dir_vars)
203 203
 	{	
204
-						$var_xml .= "<variable name=\"" . $var_key . "\" value=\"" . $res_dir_vars . "\"/>\n";
204
+						$var_xml .= "<variable name=\"".$var_key."\" value=\"".$res_dir_vars."\"/>\n";
205 205
 	}		
206 206
 
207 207
 
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 		$xml .= "               <variables>\n";
215 215
 		$xml .= $var_xml;
216 216
 		$xml .= "<variable name=\"sipcall\" value=\"true\"/>\n";
217
-		$xml .= "<variable name=\"accountcode\" value=\"" . $res_dir_value['accountcode'] . "\"/>\n";
218
-		$xml .= "<variable name=\"domain_name\" value=\"" . $_REQUEST['domain'] . "\"/>\n";
217
+		$xml .= "<variable name=\"accountcode\" value=\"".$res_dir_value['accountcode']."\"/>\n";
218
+		$xml .= "<variable name=\"domain_name\" value=\"".$_REQUEST['domain']."\"/>\n";
219 219
 		$xml .= "               </variables>\n";
220 220
 
221 221
 		$xml .= "           </user>\n";
Please login to merge, or discard this patch.