[Vtigercrm-commits] [vtiger-commits] r4610 - in /vtigercrm/trunk/modules: Invoice/CreatePDF.php PurchaseOrder/CreatePDF.php Quotes/CreatePDF.php SalesOrder/CreateSOPDF.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Tue Mar 28 10:51:24 EST 2006


Author: saraj
Date: Tue Mar 28 08:51:16 2006
New Revision: 4610

Log:
common code moved to include/pdf/body.php and the include statement changed to include/fpdf/templates/body.php as body.php has been moved from pdf_templates/body.php

Modified:
    vtigercrm/trunk/modules/Invoice/CreatePDF.php
    vtigercrm/trunk/modules/PurchaseOrder/CreatePDF.php
    vtigercrm/trunk/modules/Quotes/CreatePDF.php
    vtigercrm/trunk/modules/SalesOrder/CreateSOPDF.php

Modified: vtigercrm/trunk/modules/Invoice/CreatePDF.php
==============================================================================
--- vtigercrm/trunk/modules/Invoice/CreatePDF.php (original)
+++ vtigercrm/trunk/modules/Invoice/CreatePDF.php Tue Mar 28 08:51:16 2006
@@ -1,5 +1,5 @@
 <?php
-require_once('include/fpdf/fpdf.php');
+require_once('include/fpdf/pdf.php');
 require_once('modules/Invoice/Invoice.php');
 require_once('include/database/PearDatabase.php');
 
@@ -20,412 +20,14 @@
 $account_name = getAccountName($focus->column_fields[account_id]);
 
 
-// Xavier Nicolay 2004
-// Version 1.01
-class PDF extends FPDF
-{
-// private variables
-var $columns;
-var $format;
-var $angle=0;
-
-// private functions
-function RoundedRect($x, $y, $w, $h, $r, $style = '')
-{
-	$k = $this->k;
-	$hp = $this->h;
-	if($style=='F')
-		$op='f';
-	elseif($style=='FD' or $style=='DF')
-		$op='B';
-	else
-		$op='S';
-	$MyArc = 4/3 * (sqrt(2) - 1);
-	$this->_out(sprintf('%.2f %.2f m',($x+$r)*$k,($hp-$y)*$k ));
-	$xc = $x+$w-$r ;
-	$yc = $y+$r;
-	$this->_out(sprintf('%.2f %.2f l', $xc*$k,($hp-$y)*$k ));
-
-	$this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc);
-	$xc = $x+$w-$r ;
-	$yc = $y+$h-$r;
-	$this->_out(sprintf('%.2f %.2f l',($x+$w)*$k,($hp-$yc)*$k));
-	$this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r);
-	$xc = $x+$r ;
-	$yc = $y+$h-$r;
-	$this->_out(sprintf('%.2f %.2f l',$xc*$k,($hp-($y+$h))*$k));
-	$this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc);
-	$xc = $x+$r ;
-	$yc = $y+$r;
-	$this->_out(sprintf('%.2f %.2f l',($x)*$k,($hp-$yc)*$k ));
-	$this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r);
-	$this->_out($op);
-}
-
-function _Arc($x1, $y1, $x2, $y2, $x3, $y3)
-{
-	$h = $this->h;
-	$this->_out(sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $x1*$this->k, ($h-$y1)*$this->k,
-						$x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k));
-}
-
-function Rotate($angle,$x=-1,$y=-1)
-{
-	if($x==-1)
-		$x=$this->x;
-	if($y==-1)
-		$y=$this->y;
-	if($this->angle!=0)
-		$this->_out('Q');
-	$this->angle=$angle;
-	if($angle!=0)
-	{
-		$angle*=M_PI/180;
-		$c=cos($angle);
-		$s=sin($angle);
-		$cx=$x*$this->k;
-		$cy=($this->h-$y)*$this->k;
-		$this->_out(sprintf('q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy));
-	}
-}
-
-function _endpage()
-{
-	if($this->angle!=0)
-	{
-		$this->angle=0;
-		$this->_out('Q');
-	}
-	parent::_endpage();
-}
-
-// public functions
-function sizeOfText( $text, $largeur )
-{
-	$index    = 0;
-	$nb_lines = 0;
-	$loop     = TRUE;
-	while ( $loop )
-	{
-		$pos = strpos($text, "\n");
-		if (!$pos)
-		{
-			$loop  = FALSE;
-			$line = $text;
-		}
-		else
-		{
-			$line  = substr( $text, $index, $pos);
-			$text = substr( $text, $pos+1 );
-		}
-		$length = floor( $this->GetStringWidth( $line ) );
-		$res = 1 + floor( $length / $largeur) ;
-		$nb_lines += $res;
-	}
-	return $nb_lines;
-}
-
-// addImage
-// Default will place vtiger in the top left corner
-function addImage( $logo_name, $location=array('10','10','0','0') ) {
-	if($logo_name)//error checking just in case, by OpenCRM
-	{
-		$x1 = $location[0];
-		$y1 = $location[1];
-		$stretchx = $location[2];
-		$stretchy = $location[3];
-		$this->Image('test/logo/'.$logo_name,$x1,$y1,$stretchx,$stretchy);
-	}
-}
-
-// Company
-function addCompany( $nom, $address, $location='' )
-{
-	$x1 = $location[0];
-	$y1 = $location[1];
-	//Positionnement en bas
-	$this->SetXY( $x1, $y1 );
-	$this->SetFont('Arial','B',12);
-	$length = $this->GetStringWidth( $nom );
-	$this->Cell( $length, 2, $nom);
-	$this->SetXY( $x1, $y1 + 4 );
-	$this->SetFont('Arial','',10);
-	$length = $this->GetStringWidth( $address );
-	//Coordonnées de la société
-	$lines = $this->sizeOfText( $address, $length) ;
-	$this->MultiCell($length, 4, $address);
-}
-
-// bubble blocks
-function title ($label, $total, $position)
-{
-	$r1  = $position[0];
-	$r2  = $r1 + 19 + $position[2] ;
-	$y1  = $position[1];
-	$y2  = $y1;
-	$mid = $y1 + ($y2 / 2);
-	$width=10;
-	$this->SetFillColor(192);
-	$this->RoundedRect($r1-16, $y1-1, 52, $y2+1, 2.5, 'DF');
-	$this->SetXY( $r1 + 4, $y1+1 );
-	$this->SetFont( "Helvetica", "B", 15);
-	$this->Cell($width,5, $label." ".$total, 0, 0, "C");
-}
-
-// text block, non-wrapped
-function addTextBlock( $title,$text,$positions )
-{
-	$r1  = $positions[0];
-	$y1  = $positions[1];
-	$this->SetXY( $r1, $y1);
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell( $positions[2], 4,$title);
-	$this->SetXY( $r1, $y1+4);
-	$this->SetFont( "Helvetica", "", 10);
-	$this->MultiCell( $positions[2], 4, $text);
-}
-
-function tableWrapper($position)
-{
-	$r1  = $position[0];
-	$r2  = $r1 + 19 + $position[2] ;
-	$y1  = $position[1];
-	if($position[3])
-		$y2  = $position[3];
-	else
-		$y2  = 17;
-
-	$mid = $y1 + (13 / 2);
-	$width=10;
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 4.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 3, $y1+3 );
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 + 9 );
-}
-
-function addBubble($page,$title,$position)
-{
-	$r1  = $position[0];
-	$r2  = $r1 + 19 + $position[2] ;
-	$y1  = $position[1];
-	if($position[3])
-		$y2  = 17*$position[3];
-	else
-		$y2  = 17;
-
-	$mid = $y1 + (19 / 2);
-	$width=10;
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 4.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 3, $y1+3 );
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell($width,5, $title, 0, 0, "C");
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 + 9 );
-	$this->SetFont( "Helvetica", "", 10);
-	$this->MultiCell($width,5,$page, 0,0, "C");
-}
-
-// bubble blocks
-function addBubbleBlock ($page, $title, $position)
-{
-	$r1  = $position[0];
-	$r2  = $r1 + 19 + $position[2] ;
-	$y1  = $position[1];
-	$y2  = 17;
-
-	$mid = $y1 + ($y2 / 2);
-	$width=10;
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 4.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1+3 );
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell($width,5, $title, 0, 0, "C");
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 + 9 );
-	$this->SetFont( "Helvetica", "", 10);
-	$this->Cell($width,5,$page, 0,0, "C");
-}
-
-// record blocks
-function addRecBlock( $data, $title, $postion )
-{
-	$lengthtitle = strlen($title);
-	$lengthdata = strlen($data);
-	$length=$lengthtitle;
-	$r1  = $postion[0];
-	$r2  = $r1 + 40 + $length;
-	$y1  = $postion[1];
-	$y2  = $y1+10;
-	$mid = $y1 + (($y2-$y1) / 2);
-
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $r1 + ($r2-$r1)/2 -5 , $y1+1 );
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell(10,4, $title, 0, 0, "C");
-	$this->SetXY( $r1 + ($r2-$r1)/2 -5 , $y1 + 5 );
-	$this->SetFont( "Helvetica", "", 10);
-	$this->Cell(10,4,$data, 0, 0, "C");
-}
-
-// description blocks
-function addDescBlock( $data, $title, $position )
-{
-	$lengthtitle = strlen($title);
-	$lengthdata= $position[3];
-
-	$length=$position[2];
-	$r1  = $position[0];
-	$r2  = $r1 + 40 + $length;
-	$y1  = $position[1];
-	$y2  = $y1+10;
-	$mid = $y1 + (($y2-$y1) / 2);
-
-	$this->RoundedRect($r1,$y1, ($length + 40), ($lengthdata/140*30), 2.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $position[0]+2 , $y1 + 1 );
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell(10,4, $title);
-	$this->SetXY( $position[0]+2 , $y1 + 6 );
-	$this->SetFont( "Helvetica", "", 10);
-	$this->MultiCell(($length+36),4,$data);
-}
-
-function drawLine($positions)
-{
-	$x=$positions[0];
-	$y=$positions[1];
-	$width=$positions[2];
-	$this->Line( $x, $y, $x+$width, $y);
-}
-
-// add columns to table
-function addCols( $tab ,$positions ,$bottom)
-{
-	global $columns;
-
-	$r1  = 10;
-	$r2  = $this->w - ($r1 * 2) ;
-	$y1  = 80;
-	$x1  = $positions[1];
-	$y2  = $bottom;
-	$this->SetXY( $r1, $y1 );
-	$this->SetFont( "Helvetica", "", 10);
-
-	$colX = $r1;
-	$columns = $tab;
-	while ( list( $lib, $pos ) = each ($tab) )
-	{
-		$this->SetXY( $colX, $y1+3 );
-		$this->Cell( $pos, 1, $lib, 0, 0, "C");
-		$colX += $pos;
-	switch($lib) {
-	  case 'Total':
-	  break;
-	  default:
-			$this->Line( $colX, $y1, $colX, $y1+$y2);
-	  break;
-	}
-	}
-}
-
-function addLineFormat( $tab )
-{
-	global $format, $columns;
-
-	while ( list( $lib, $pos ) = each ($columns) )
-	{
-		if ( isset( $tab["$lib"] ) )
-			$format[ $lib ] = $tab["$lib"];
-	}
-}
-
-function addProductLine( $line, $tab )
-{
-	global $columns, $format;
-
-	$ordonnee     = 10;
-	$maxSize      = $line;
-
-	reset( $columns );
-	while ( list( $lib, $pos ) = each ($columns) )
-	{
-		$longCell  = $pos -2;
-		$text    = $tab[ $lib ];
-		$length    = $this->GetStringWidth( $text );
-		$formText  = $format[ $lib ];
-		$this->SetXY( $ordonnee, $line);
-		$this->MultiCell( $longCell, 3 , $text, 3, $formText);
-		if ( $maxSize < ($this->GetY()  ) )
-			$maxSize = $this->GetY() ;
-		$ordonnee += $pos;
-	}
-	return ( $maxSize - $line );
-}
-
-function addTotalsRec($names, $totals, $positions)
-{
-	$this->SetFont( "Arial", "B", 8);
-	$r1  = $positions[0];
-	$r2  = $r1 + 90;
-	$y1  = $positions[1];
-	$y2  = $y1+10;
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D');
-	$this->Line( $r1, $y1+4, $r2, $y1+4);
-	$this->Line( $r1+27, $y1, $r1+27, $y2);  // avant Subtotal
-	$this->Line( $r1+43, $y1, $r1+43, $y2);  // avant Tax
-	$this->Line( $r1+66, $y1, $r1+66, $y2);  // avant Adjustment
-
-	$this->SetXY( $r1+2, $y1);
-	$this->Cell(10,4, $names[0]);
-	$this->SetX( $r1+29,$y1 );
-	$this->Cell(10,4, $names[1]);
-	$this->SetX( $r1+45 );
-	$this->Cell(10,4, $names[2]);
-	$this->SetX( $r1+66 );
-	$this->Cell(10,4, $names[3]);
-
-
-	$this->SetXY( $r1+2, $y1+5 );
-	$this->Cell( 10,4, $totals[0] );
-	$this->SetXY( $r1+29, $y1+5 );
-	$this->Cell( 10,4, $totals[1] );
-	$this->SetXY( $r1+44, $y1+5 );
-	$this->Cell( 10,4, $totals[2] );
-	$this->SetXY( $r1+66, $y1+5 );
-	$this->Cell( 10,4, $totals[3] );
-
-	$this->SetFont( "Arial", "B", 6);
-	$this->SetXY( $r1+90, $y2 - 8 );
-	$this->SetFont( "Helvetica", "", 10);
-}
-
-// add a watermark (temporary estimate, DUPLICATA...)
-// call this method first
-function watermark( $text, $positions, $rotate = array('45','50','180') )
-{
-	$this->SetFont('Arial','B',50);
-	$this->SetTextColor(230,230,230);
-	$this->Rotate($rotate[0],$rotate[1],$rotate[2]);
-	$this->Text($positions[0],$positions[1],$text);
-	$this->Rotate(0);
-	$this->SetTextColor(0,0,0);
-}
-
-}
-
-function StripLastZero($string)
-{
-	$count=strlen($string);
-	$ret=substr($string,0,($count-1));
-	return $ret;
-}
-
-
 // **************** BEGIN POPULATE DATA ********************
 
 
 // populate data
-$so_name = getSoName($focus->column_fields["salesorder_id"]);
+if($focus->column_fields["salesorder_id"] != '')
+	$so_name = getSoName($focus->column_fields["salesorder_id"]);
+else
+	$so_name = '';
 $po_name = $focus->column_fields["purchaseorder"];
 
 $valid_till = $focus->column_fields["duedate"];
@@ -444,7 +46,7 @@
 
 $conditions = $focus->column_fields["terms_conditions"];
 $description = $focus->column_fields["description"];
-$invoice_status = $focus->column_fields["invoicestatus"];
+$status = $focus->column_fields["invoicestatus"];
 
 // Company information
 $add_query = "select * from organizationdetails";
@@ -462,7 +64,6 @@
 		$org_phone = $adb->query_result($result,0,"phone");
 		$org_fax = $adb->query_result($result,0,"fax");
 		$org_website = $adb->query_result($result,0,"website");
-
 		$logo_name = $adb->query_result($result,0,"logoname");
 }
 
@@ -535,7 +136,7 @@
 
 	$pdf->AddPage();
 	include("pdf_templates/header.php");
-	include("pdf_templates/body.php");
+	include("include/fpdf/templates/body.php");
 	include("pdf_templates/footer.php");
 
 	$page_num++;

Modified: vtigercrm/trunk/modules/PurchaseOrder/CreatePDF.php
==============================================================================
--- vtigercrm/trunk/modules/PurchaseOrder/CreatePDF.php (original)
+++ vtigercrm/trunk/modules/PurchaseOrder/CreatePDF.php Tue Mar 28 08:51:16 2006
@@ -1,5 +1,5 @@
 <?php
-require('include/fpdf/fpdf.php');
+require('include/fpdf/pdf.php');
 require_once('modules/PurchaseOrder/PurchaseOrder.php');
 require_once('include/database/PearDatabase.php');
 
@@ -19,409 +19,6 @@
 $focus = new Order();
 $focus->retrieve_entity_info($_REQUEST['record'],"PurchaseOrder");
 $vendor_name = getVendorName($focus->column_fields[vendor_id]);
-
-// Xavier Nicolay 2004
-// Version 1.01
-class PDF extends FPDF
-{
-// private variables
-var $columns;
-var $format;
-var $angle=0;
-
-// private functions
-function RoundedRect($x, $y, $w, $h, $r, $style = '')
-{
-	$k = $this->k;
-	$hp = $this->h;
-	if($style=='F')
-		$op='f';
-	elseif($style=='FD' or $style=='DF')
-		$op='B';
-	else
-		$op='S';
-	$MyArc = 4/3 * (sqrt(2) - 1);
-	$this->_out(sprintf('%.2f %.2f m',($x+$r)*$k,($hp-$y)*$k ));
-	$xc = $x+$w-$r ;
-	$yc = $y+$r;
-	$this->_out(sprintf('%.2f %.2f l', $xc*$k,($hp-$y)*$k ));
-
-	$this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc);
-	$xc = $x+$w-$r ;
-	$yc = $y+$h-$r;
-	$this->_out(sprintf('%.2f %.2f l',($x+$w)*$k,($hp-$yc)*$k));
-	$this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r);
-	$xc = $x+$r ;
-	$yc = $y+$h-$r;
-	$this->_out(sprintf('%.2f %.2f l',$xc*$k,($hp-($y+$h))*$k));
-	$this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc);
-	$xc = $x+$r ;
-	$yc = $y+$r;
-	$this->_out(sprintf('%.2f %.2f l',($x)*$k,($hp-$yc)*$k ));
-	$this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r);
-	$this->_out($op);
-}
-
-function _Arc($x1, $y1, $x2, $y2, $x3, $y3)
-{
-	$h = $this->h;
-	$this->_out(sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $x1*$this->k, ($h-$y1)*$this->k,
-						$x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k));
-}
-
-function Rotate($angle,$x=-1,$y=-1)
-{
-	if($x==-1)
-		$x=$this->x;
-	if($y==-1)
-		$y=$this->y;
-	if($this->angle!=0)
-		$this->_out('Q');
-	$this->angle=$angle;
-	if($angle!=0)
-	{
-		$angle*=M_PI/180;
-		$c=cos($angle);
-		$s=sin($angle);
-		$cx=$x*$this->k;
-		$cy=($this->h-$y)*$this->k;
-		$this->_out(sprintf('q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy));
-	}
-}
-
-function _endpage()
-{
-	if($this->angle!=0)
-	{
-		$this->angle=0;
-		$this->_out('Q');
-	}
-	parent::_endpage();
-}
-
-// public functions
-function sizeOfText( $text, $largeur )
-{
-	$index    = 0;
-	$nb_lines = 0;
-	$loop     = TRUE;
-	while ( $loop )
-	{
-		$pos = strpos($text, "\n");
-		if (!$pos)
-		{
-			$loop  = FALSE;
-			$line = $text;
-		}
-		else
-		{
-			$line  = substr( $text, $index, $pos);
-			$text = substr( $text, $pos+1 );
-		}
-		$length = floor( $this->GetStringWidth( $line ) );
-		$res = 1 + floor( $length / $largeur) ;
-		$nb_lines += $res;
-	}
-	return $nb_lines;
-}
-
-// addImage
-// $logo_name = name of logo, no path needed.
-// $location = array ('x','y','width','height')
-// Default will place vtiger in the top left corner
-function addImage( $logo_name, $location=array('10','10','0','0') ) {
-	if($logo_name)//error checking just in case, by OpenCRM
-	{
-		$x1 = $location[0];
-		$y1 = $location[1];
-		$stretchx = $location[2];
-		$stretchy = $location[3];
-		$this->Image('test/logo/'.$logo_name,$x1,$y1,$stretchx,$stretchy);
-	}
-}
-
-// Company
-function addCompany( $nom, $address, $location='' )
-{
-	$x1 = $location[0];
-	$y1 = $location[1];
-	//Positionnement en bas
-	$this->SetXY( $x1, $y1 );
-	$this->SetFont('Arial','B',12);
-	$length = $this->GetStringWidth( $nom );
-	$this->Cell( $length, 2, $nom);
-	$this->SetXY( $x1, $y1 + 4 );
-	$this->SetFont('Arial','',10);
-	$length = $this->GetStringWidth( $address );
-	//Coordonnées de la société
-	$lines = $this->sizeOfText( $address, $length) ;
-	$this->MultiCell($length, 4, $address);
-}
-
-// bubble blocks
-function title ($label, $total, $position)
-{
-	$r1  = $position[0];
-	$r2  = $r1 + 19 + $position[2] ;
-	$y1  = $position[1];
-	$y2  = $y1;
-	$mid = $y1 + ($y2 / 2);
-	$width=10;
-	$this->SetFillColor(192);
-	$this->RoundedRect($r1-16, $y1-1, 52, $y2+1, 2.5, 'DF');
-	$this->SetXY( $r1 + 4, $y1+1 );
-	$this->SetFont( "Helvetica", "B", 15);
-	$this->Cell($width,5, $label." ".$total, 0, 0, "C");
-}
-
-// text block, non-wrapped
-function addTextBlock( $title,$text,$positions )
-{
-	$r1  = $positions[0];
-	$y1  = $positions[1];
-	$this->SetXY( $r1, $y1);
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell( $positions[2], 4,$title);
-	$this->SetXY( $r1, $y1+4);
-	$this->SetFont( "Helvetica", "", 10);
-	$this->MultiCell( $positions[2], 4, $text);
-}
-
-function tableWrapper($position)
-{
-	$r1  = $position[0];
-	$r2  = $r1 + 19 + $position[2] ;
-	$y1  = $position[1];
-	if($position[3])
-		$y2  = $position[3];
-	else
-		$y2  = 17;
-
-	$mid = $y1 + (13 / 2);
-	$width=10;
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 4.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 3, $y1+3 );
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 + 9 );
-}
-
-function addBubble($page,$title,$position)
-{
-	$r1  = $position[0];
-	$r2  = $r1 + 19 + $position[2] ;
-	$y1  = $position[1];
-	if($position[3])
-		$y2  = 17*$position[3];
-	else
-		$y2  = 17;
-
-	$mid = $y1 + (19 / 2);
-	$width=10;
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 4.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 3, $y1+3 );
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell($width,5, $title, 0, 0, "C");
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 + 9 );
-	$this->SetFont( "Helvetica", "", 10);
-	$this->MultiCell($width,5,$page, 0,0, "C");
-}
-
-// bubble blocks
-function addBubbleBlock ($page, $title, $position)
-{
-	$r1  = $position[0];
-	$r2  = $r1 + 19 + $position[2] ;
-	$y1  = $position[1];
-	$y2  = 17;
-
-	$mid = $y1 + ($y2 / 2);
-	$width=10;
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 4.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1+3 );
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell($width,5, $title, 0, 0, "C");
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 + 9 );
-	$this->SetFont( "Helvetica", "", 10);
-	$this->Cell($width,5,$page, 0,0, "C");
-}
-
-// record blocks
-function addRecBlock( $data, $title, $postion )
-{
-	$lengthtitle = strlen($title);
-	$lengthdata = strlen($data);
-	$length=$lengthtitle;
-	$r1  = $postion[0];
-	$r2  = $r1 + 40 + $length;
-	$y1  = $postion[1];
-	$y2  = $y1+10;
-	$mid = $y1 + (($y2-$y1) / 2);
-
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $r1 + ($r2-$r1)/2 -5 , $y1+1 );
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell(10,4, $title, 0, 0, "C");
-	$this->SetXY( $r1 + ($r2-$r1)/2 -5 , $y1 + 5 );
-	$this->SetFont( "Helvetica", "", 10);
-	$this->Cell(10,4,$data, 0, 0, "C");
-}
-
-// description blocks
-function addDescBlock( $data, $title, $position )
-{
-	$lengthtitle = strlen($title);
-	$lengthdata= $position[3];
-
-	$length=$position[2];
-	$r1  = $position[0];
-	$r2  = $r1 + 40 + $length;
-	$y1  = $position[1];
-	$y2  = $y1+10;
-	$mid = $y1 + (($y2-$y1) / 2);
-
-	$this->RoundedRect($r1,$y1, ($length + 40), ($lengthdata/140*30), 2.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $position[0]+2 , $y1 + 1 );
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell(10,4, $title);
-	$this->SetXY( $position[0]+2 , $y1 + 6 );
-	$this->SetFont( "Helvetica", "", 10);
-	$this->MultiCell(($length+36),4,$data);
-}
-
-function drawLine($positions)
-{
-	$x=$positions[0];
-	$y=$positions[1];
-	$width=$positions[2];
-	$this->Line( $x, $y, $x+$width, $y);
-}
-
-// add columns to table
-function addCols( $tab ,$positions ,$bottom)
-{
-	global $columns;
-
-	$r1  = 10;
-	$r2  = $this->w - ($r1 * 2) ;
-	$y1  = 80;
-	$x1  = $positions[1];
-	$y2  = $bottom;
-	$this->SetXY( $r1, $y1 );
-	$this->SetFont( "Helvetica", "", 10);
-
-	$colX = $r1;
-	$columns = $tab;
-	while ( list( $lib, $pos ) = each ($tab) )
-	{
-		$this->SetXY( $colX, $y1+3 );
-		$this->Cell( $pos, 1, $lib, 0, 0, "C");
-		$colX += $pos;
-	switch($lib) {
-	  case 'Total':
-	  break;
-	  default:
-			$this->Line( $colX, $y1, $colX, $y1+$y2);
-	  break;
-	}
-	}
-}
-
-function addLineFormat( $tab )
-{
-	global $format, $columns;
-
-	while ( list( $lib, $pos ) = each ($columns) )
-	{
-		if ( isset( $tab["$lib"] ) )
-			$format[ $lib ] = $tab["$lib"];
-	}
-}
-
-function addProductLine( $line, $tab )
-{
-	global $columns, $format;
-
-	$ordonnee     = 10;
-	$maxSize      = $line;
-
-	reset( $columns );
-	while ( list( $lib, $pos ) = each ($columns) )
-	{
-		$longCell  = $pos -2;
-		$text    = $tab[ $lib ];
-		$length    = $this->GetStringWidth( $text );
-		$formText  = $format[ $lib ];
-		$this->SetXY( $ordonnee, $line);
-		$this->MultiCell( $longCell, 3 , $text, 3, $formText);
-		if ( $maxSize < ($this->GetY()  ) )
-			$maxSize = $this->GetY() ;
-		$ordonnee += $pos;
-	}
-	return ( $maxSize - $line );
-}
-
-function addTotalsRec($names, $totals, $positions)
-{
-	$this->SetFont( "Arial", "B", 8);
-	$r1  = $positions[0];
-	$r2  = $r1 + 90;
-	$y1  = $positions[1];
-	$y2  = $y1+10;
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D');
-	$this->Line( $r1, $y1+4, $r2, $y1+4);
-	$this->Line( $r1+27, $y1, $r1+27, $y2);  // avant Subtotal
-	$this->Line( $r1+43, $y1, $r1+43, $y2);  // avant Tax
-	$this->Line( $r1+66, $y1, $r1+66, $y2);  // avant Adjustment
-
-	$this->SetXY( $r1+2, $y1);
-	$this->Cell(10,4, $names[0]);
-	$this->SetX( $r1+29,$y1 );
-	$this->Cell(10,4, $names[1]);
-	$this->SetX( $r1+45 );
-	$this->Cell(10,4, $names[2]);
-	$this->SetX( $r1+66 );
-	$this->Cell(10,4, $names[3]);
-
-
-	$this->SetXY( $r1+2, $y1+5 );
-	$this->Cell( 10,4, $totals[0] );
-	$this->SetXY( $r1+29, $y1+5 );
-	$this->Cell( 10,4, $totals[1] );
-	$this->SetXY( $r1+44, $y1+5 );
-	$this->Cell( 10,4, $totals[2] );
-	$this->SetXY( $r1+66, $y1+5 );
-	$this->Cell( 10,4, $totals[3] );
-
-	$this->SetFont( "Arial", "B", 6);
-	$this->SetXY( $r1+90, $y2 - 8 );
-	$this->SetFont( "Helvetica", "", 10);
-}
-
-// add a watermark (temporary estimate, DUPLICATA...)
-// call this method first
-function watermark( $text, $positions, $rotate = array('45','50','180') )
-{
-	$this->SetFont('Arial','B',50);
-	$this->SetTextColor(230,230,230);
-	$this->Rotate($rotate[0],$rotate[1],$rotate[2]);
-	$this->Text($positions[0],$positions[1],$text);
-	$this->Rotate(0);
-	$this->SetTextColor(0,0,0);
-}
-
-}
-
-function StripLastZero($string)
-{
-	$count=strlen($string);
-	$ret=substr($string,0,($count-1));
-	return $ret;
-}
-
 
 // **************** BEGIN POPULATE DATA ********************
 
@@ -537,7 +134,7 @@
 
 	$pdf->AddPage();
 	include("pdf_templates/header.php");
-	include("pdf_templates/body.php");
+	include("include/fpdf/templates/body.php");
 	include("pdf_templates/footer.php");
 
 	$page_num++;

Modified: vtigercrm/trunk/modules/Quotes/CreatePDF.php
==============================================================================
--- vtigercrm/trunk/modules/Quotes/CreatePDF.php (original)
+++ vtigercrm/trunk/modules/Quotes/CreatePDF.php Tue Mar 28 08:51:16 2006
@@ -1,5 +1,5 @@
 <?php
-require_once('include/fpdf/fpdf.php');
+require_once('include/fpdf/pdf.php');
 require_once('modules/Quotes/Quote.php');
 require_once('include/database/PearDatabase.php');
 
@@ -13,409 +13,6 @@
 $endpage="1";
 global $products_per_page;
 $products_per_page="6";
-
-// Xavier Nicolay 2004
-// Version 1.01
-
-class PDF extends FPDF
-{
-// private variables
-var $columns;
-var $format;
-var $angle=0;
-
-// private functions
-function RoundedRect($x, $y, $w, $h, $r, $style = '')
-{
-	$k = $this->k;
-	$hp = $this->h;
-	if($style=='F')
-		$op='f';
-	elseif($style=='FD' or $style=='DF')
-		$op='B';
-	else
-		$op='S';
-	$MyArc = 4/3 * (sqrt(2) - 1);
-	$this->_out(sprintf('%.2f %.2f m',($x+$r)*$k,($hp-$y)*$k ));
-	$xc = $x+$w-$r ;
-	$yc = $y+$r;
-	$this->_out(sprintf('%.2f %.2f l', $xc*$k,($hp-$y)*$k ));
-
-	$this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc);
-	$xc = $x+$w-$r ;
-	$yc = $y+$h-$r;
-	$this->_out(sprintf('%.2f %.2f l',($x+$w)*$k,($hp-$yc)*$k));
-	$this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r);
-	$xc = $x+$r ;
-	$yc = $y+$h-$r;
-	$this->_out(sprintf('%.2f %.2f l',$xc*$k,($hp-($y+$h))*$k));
-	$this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc);
-	$xc = $x+$r ;
-	$yc = $y+$r;
-	$this->_out(sprintf('%.2f %.2f l',($x)*$k,($hp-$yc)*$k ));
-	$this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r);
-	$this->_out($op);
-}
-
-function _Arc($x1, $y1, $x2, $y2, $x3, $y3)
-{
-	$h = $this->h;
-	$this->_out(sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $x1*$this->k, ($h-$y1)*$this->k,
-						$x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k));
-}
-
-function Rotate($angle,$x=-1,$y=-1)
-{
-	if($x==-1)
-		$x=$this->x;
-	if($y==-1)
-		$y=$this->y;
-	if($this->angle!=0)
-		$this->_out('Q');
-	$this->angle=$angle;
-	if($angle!=0)
-	{
-		$angle*=M_PI/180;
-		$c=cos($angle);
-		$s=sin($angle);
-		$cx=$x*$this->k;
-		$cy=($this->h-$y)*$this->k;
-		$this->_out(sprintf('q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy));
-	}
-}
-
-function _endpage()
-{
-	if($this->angle!=0)
-	{
-		$this->angle=0;
-		$this->_out('Q');
-	}
-	parent::_endpage();
-}
-
-// public functions
-function sizeOfText( $text, $largeur )
-{
-	$index    = 0;
-	$nb_lines = 0;
-	$loop     = TRUE;
-	while ( $loop )
-	{
-		$pos = strpos($text, "\n");
-		if (!$pos)
-		{
-			$loop  = FALSE;
-			$line = $text;
-		}
-		else
-		{
-			$line  = substr( $text, $index, $pos);
-			$text = substr( $text, $pos+1 );
-		}
-		$length = floor( $this->GetStringWidth( $line ) );
-		$res = 1 + floor( $length / $largeur) ;
-		$nb_lines += $res;
-	}
-	return $nb_lines;
-}
-
-// addImage
-// Default will place vtiger in the top left corner
-function addImage( $logo_name, $location=array('10','10','0','0') ) {
-	if($logo_name)//error checking just in case, by OpenCRM
-	{
-		$x1 = $location[0];
-		$y1 = $location[1];
-		$stretchx = $location[2];
-		$stretchy = $location[3];
-		$this->Image('test/logo/'.$logo_name,$x1,$y1,$stretchx,$stretchy);
-	}
-}
-
-// Company
-function addCompany( $nom, $address, $location='' )
-{
-	$x1 = $location[0];
-	$y1 = $location[1];
-	//Positionnement en bas
-	$this->SetXY( $x1, $y1 );
-	$this->SetFont('Arial','B',12);
-	$length = $this->GetStringWidth( $nom );
-	$this->Cell( $length, 2, $nom);
-	$this->SetXY( $x1, $y1 + 4 );
-	$this->SetFont('Arial','',10);
-	$length = $this->GetStringWidth( $address );
-	//Coordonnées de la société
-	$lines = $this->sizeOfText( $address, $length) ;
-	$this->MultiCell($length, 4, $address);
-}
-
-// bubble blocks
-function title ($label, $total, $position)
-{
-	$r1  = $position[0];
-	$r2  = $r1 + 19 + $position[2] ;
-	$y1  = $position[1];
-	$y2  = $y1;
-	$mid = $y1 + ($y2 / 2);
-	$width=10;
-	$this->SetFillColor(192);
-	$this->RoundedRect($r1-16, $y1-1, (strlen($label." ".$total)*8)+4, $y2+1, 4.5, 'DF');
-	$this->SetXY( $r1 + 4, $y1+1 );
-	$this->SetFont( "Helvetica", "B", 15);
-	$this->Cell($width,5, $label." ".$total, 0, 0, "C");
-}
-
-// text block, non-wrapped
-function addTextBlock( $title,$text,$positions )
-{
-	$r1  = $positions[0];
-	$y1  = $positions[1];
-	$this->SetXY( $r1, $y1);
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell( $positions[2], 4,$title);
-	$this->SetXY( $r1, $y1+4);
-	$this->SetFont( "Helvetica", "", 10);
-	$this->MultiCell( $positions[2], 4, $text);
-}
-
-function tableWrapper($position)
-{
-	$r1  = $position[0];
-	$r2  = $r1 + 19 + $position[2] ;
-	$y1  = $position[1];
-	if($position[3])
-		$y2  = $position[3];
-	else
-		$y2  = 17;
-
-	$mid = $y1 + (13 / 2);
-	$width=10;
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 4.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 3, $y1+3 );
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 + 9 );
-}
-
-function addBubble($page,$title,$position)
-{
-	$r1  = $position[0];
-	$r2  = $r1 + 19 + $position[2] ;
-	$y1  = $position[1];
-	if($position[3])
-		$y2  = 17*$position[3];
-	else
-		$y2  = 17;
-
-	$mid = $y1 + (19 / 2);
-	$width=10;
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 4.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 3, $y1+3 );
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell($width,5, $title, 0, 0, "C");
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 + 9 );
-	$this->SetFont( "Helvetica", "", 10);
-	$this->MultiCell($width,5,$page, 0,0, "C");
-}
-
-// bubble blocks
-function addBubbleBlock ($page, $title, $position)
-{
-	$r1  = $position[0];
-	$r2  = $r1 + 19 + $position[2] ;
-	$y1  = $position[1];
-	$y2  = 17;
-
-	$mid = $y1 + ($y2 / 2);
-	$width=10;
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 4.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1+3 );
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell($width,5, $title, 0, 0, "C");
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 + 9 );
-	$this->SetFont( "Helvetica", "", 10);
-	$this->Cell($width,5,$page, 0,0, "C");
-}
-
-// record blocks
-function addRecBlock( $data, $title, $postion )
-{
-	$lengthtitle = strlen($title);
-	$lengthdata = strlen($data);
-	$length=$lengthtitle;
-	$r1  = $postion[0];
-	$r2  = $r1 + 40 + $length;
-	$y1  = $postion[1];
-	$y2  = $y1+10;
-	$mid = $y1 + (($y2-$y1) / 2);
-
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $r1 + ($r2-$r1)/2 -5 , $y1+1 );
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell(10,4, $title, 0, 0, "C");
-	$this->SetXY( $r1 + ($r2-$r1)/2 -5 , $y1 + 5 );
-	$this->SetFont( "Helvetica", "", 10);
-	$this->Cell(10,4,$data, 0, 0, "C");
-}
-
-// description blocks
-function addDescBlock( $data, $title, $position )
-{
-	$lengthtitle = strlen($title);
-	$lengthdata= $position[3];
-
-	$length=$position[2];
-	$r1  = $position[0];
-	$r2  = $r1 + 40 + $length;
-	$y1  = $position[1];
-	$y2  = $y1+10;
-	$mid = $y1 + (($y2-$y1) / 2);
-
-	$this->RoundedRect($r1,$y1, ($length + 40), ($lengthdata/140*30), 2.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $position[0]+2 , $y1 + 1 );
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell(10,4, $title);
-	$this->SetXY( $position[0]+2 , $y1 + 6 );
-	$this->SetFont( "Helvetica", "", 10);
-	$this->MultiCell(($length+36),4,$data);
-}
-
-function drawLine($positions)
-{
-	$x=$positions[0];
-	$y=$positions[1];
-	$width=$positions[2];
-	$this->Line( $x, $y, $x+$width, $y);
-}
-
-// add columns to table
-function addCols( $tab ,$positions ,$bottom)
-{
-	global $columns;
-
-	$r1  = 10;
-	$r2  = $this->w - ($r1 * 2) ;
-	$y1  = 80;
-	$x1  = $positions[1];
-	$y2  = $bottom;
-	$this->SetXY( $r1, $y1 );
-	$this->SetFont( "Helvetica", "", 10);
-
-	$colX = $r1;
-	$columns = $tab;
-	while ( list( $lib, $pos ) = each ($tab) )
-	{
-		$this->SetXY( $colX, $y1+3 );
-		$this->Cell( $pos, 1, $lib, 0, 0, "C");
-		$colX += $pos;
-	switch($lib) {
-	  case 'Total':
-	  break;
-	  default:
-			$this->Line( $colX, $y1, $colX, $y1+$y2);
-	  break;
-	}
-	}
-}
-
-function addLineFormat( $tab )
-{
-	global $format, $columns;
-
-	while ( list( $lib, $pos ) = each ($columns) )
-	{
-		if ( isset( $tab["$lib"] ) )
-			$format[ $lib ] = $tab["$lib"];
-	}
-}
-
-// add a line to the invoice/estimate
-function addProductLine( $line, $tab )
-{
-	global $columns, $format;
-
-	$ordonnee     = 10;
-	$maxSize      = $line;
-
-	reset( $columns );
-	while ( list( $lib, $pos ) = each ($columns) )
-	{
-		$longCell  = $pos -2;
-		$text    = $tab[ $lib ];
-		$length    = $this->GetStringWidth( $text );
-		$formText  = $format[ $lib ];
-		$this->SetXY( $ordonnee, $line);
-		$this->MultiCell( $longCell, 3 , $text, 3, $formText);
-		if ( $maxSize < ($this->GetY()  ) )
-			$maxSize = $this->GetY() ;
-		$ordonnee += $pos;
-	}
-	return ( $maxSize - $line );
-}
-
-function addTotalsRec($names, $totals, $positions)
-{
-	$this->SetFont( "Arial", "B", 8);
-	$r1  = $positions[0];
-	$r2  = $r1 + 90;
-	$y1  = $positions[1];
-	$y2  = $y1+10;
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D');
-	$this->Line( $r1, $y1+4, $r2, $y1+4);
-	$this->Line( $r1+27, $y1, $r1+27, $y2);  // avant Subtotal
-	$this->Line( $r1+43, $y1, $r1+43, $y2);  // avant Tax
-	$this->Line( $r1+66, $y1, $r1+66, $y2);  // avant Adjustment
-
-	$this->SetXY( $r1+2, $y1);
-	$this->Cell(10,4, $names[0]);
-	$this->SetX( $r1+29,$y1 );
-	$this->Cell(10,4, $names[1]);
-	$this->SetX( $r1+45 );
-	$this->Cell(10,4, $names[2]);
-	$this->SetX( $r1+66 );
-	$this->Cell(10,4, $names[3]);
-
-
-	$this->SetXY( $r1+2, $y1+5 );
-	$this->Cell( 10,4, $totals[0] );
-	$this->SetXY( $r1+29, $y1+5 );
-	$this->Cell( 10,4, $totals[1] );
-	$this->SetXY( $r1+44, $y1+5 );
-	$this->Cell( 10,4, $totals[2] );
-	$this->SetXY( $r1+66, $y1+5 );
-	$this->Cell( 10,4, $totals[3] );
-
-	$this->SetFont( "Arial", "B", 6);
-	$this->SetXY( $r1+90, $y2 - 8 );
-	$this->SetFont( "Helvetica", "", 10);
-}
-
-// add a watermark (temporary estimate, DUPLICATA...)
-// call this method first
-function watermark( $text, $positions, $rotate = array('45','50','180') )
-{
-	$this->SetFont('Arial','B',50);
-	$this->SetTextColor(230,230,230);
-	$this->Rotate($rotate[0],$rotate[1],$rotate[2]);
-	$this->Text($positions[0],$positions[1],$text);
-	$this->Rotate(0);
-	$this->SetTextColor(0,0,0);
-}
-
-}
-
-function StripLastZero($string)
-{
-	$count=strlen($string);
-	$ret=substr($string,0,($count-1));
-	return $ret;
-}
-
 
 // **************** BEGIN POPULATE DATA ********************
 $focus = new Quote();
@@ -441,7 +38,7 @@
 
 $conditions = $focus->column_fields["terms_conditions"];
 $description = $focus->column_fields["description"];
-$quote_status = $focus->column_fields["quotestage"];
+$status = $focus->column_fields["quotestage"];
 
 // Company information
 $add_query = "select * from organizationdetails";
@@ -532,7 +129,7 @@
 
 	$pdf->AddPage();
 	include("pdf_templates/header.php");
-	include("pdf_templates/body.php");
+	include("include/fpdf/templates/body.php");
 	include("pdf_templates/footer.php");
 
 	$page_num++;

Modified: vtigercrm/trunk/modules/SalesOrder/CreateSOPDF.php
==============================================================================
--- vtigercrm/trunk/modules/SalesOrder/CreateSOPDF.php (original)
+++ vtigercrm/trunk/modules/SalesOrder/CreateSOPDF.php Tue Mar 28 08:51:16 2006
@@ -1,6 +1,6 @@
 <?php
-require('include/fpdf/fpdf.php');
-require_once('modules/Orders/SalesOrder.php');
+require('include/fpdf/pdf.php');
+require_once('modules/SalesOrder/SalesOrder.php');
 require_once('include/database/PearDatabase.php');
 
 global $adb,$app_strings,$products_per_page;
@@ -19,412 +19,13 @@
 $focus->retrieve_entity_info($_REQUEST['record'],"SalesOrder");
 $account_name = getAccountName($focus->column_fields[account_id]);
 
-// Xavier Nicolay 2004
-// Version 1.01
-class PDF extends FPDF
-{
-// private variables
-var $columns;
-var $format;
-var $angle=0;
-
-// private functions
-function RoundedRect($x, $y, $w, $h, $r, $style = '')
-{
-	$k = $this->k;
-	$hp = $this->h;
-	if($style=='F')
-		$op='f';
-	elseif($style=='FD' or $style=='DF')
-		$op='B';
-	else
-		$op='S';
-	$MyArc = 4/3 * (sqrt(2) - 1);
-	$this->_out(sprintf('%.2f %.2f m',($x+$r)*$k,($hp-$y)*$k ));
-	$xc = $x+$w-$r ;
-	$yc = $y+$r;
-	$this->_out(sprintf('%.2f %.2f l', $xc*$k,($hp-$y)*$k ));
-
-	$this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc);
-	$xc = $x+$w-$r ;
-	$yc = $y+$h-$r;
-	$this->_out(sprintf('%.2f %.2f l',($x+$w)*$k,($hp-$yc)*$k));
-	$this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r);
-	$xc = $x+$r ;
-	$yc = $y+$h-$r;
-	$this->_out(sprintf('%.2f %.2f l',$xc*$k,($hp-($y+$h))*$k));
-	$this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc);
-	$xc = $x+$r ;
-	$yc = $y+$r;
-	$this->_out(sprintf('%.2f %.2f l',($x)*$k,($hp-$yc)*$k ));
-	$this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r);
-	$this->_out($op);
-}
-
-function _Arc($x1, $y1, $x2, $y2, $x3, $y3)
-{
-	$h = $this->h;
-	$this->_out(sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $x1*$this->k, ($h-$y1)*$this->k,
-						$x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k));
-}
-
-function Rotate($angle,$x=-1,$y=-1)
-{
-	if($x==-1)
-		$x=$this->x;
-	if($y==-1)
-		$y=$this->y;
-	if($this->angle!=0)
-		$this->_out('Q');
-	$this->angle=$angle;
-	if($angle!=0)
-	{
-		$angle*=M_PI/180;
-		$c=cos($angle);
-		$s=sin($angle);
-		$cx=$x*$this->k;
-		$cy=($this->h-$y)*$this->k;
-		$this->_out(sprintf('q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy));
-	}
-}
-
-function _endpage()
-{
-	if($this->angle!=0)
-	{
-		$this->angle=0;
-		$this->_out('Q');
-	}
-	parent::_endpage();
-}
-
-// public functions
-function sizeOfText( $text, $largeur )
-{
-	$index    = 0;
-	$nb_lines = 0;
-	$loop     = TRUE;
-	while ( $loop )
-	{
-		$pos = strpos($text, "\n");
-		if (!$pos)
-		{
-			$loop  = FALSE;
-			$line = $text;
-		}
-		else
-		{
-			$line  = substr( $text, $index, $pos);
-			$text = substr( $text, $pos+1 );
-		}
-		$length = floor( $this->GetStringWidth( $line ) );
-		$res = 1 + floor( $length / $largeur) ;
-		$nb_lines += $res;
-	}
-	return $nb_lines;
-}
-
-// addImage
-// Default will place vtiger in the top left corner
-function addImage( $logo_name, $location=array('10','10','0','0') ) {
-	if($logo_name)//error checking just in case, by OpenCRM
-	{
-		$x1 = $location[0];
-		$y1 = $location[1];
-		$stretchx = $location[2];
-		$stretchy = $location[3];
-		$this->Image('test/logo/'.$logo_name,$x1,$y1,$stretchx,$stretchy);
-	}
-}
-
-// Company
-function addCompany( $nom, $address, $location='' )
-{
-	$x1 = $location[0];
-	$y1 = $location[1];
-	//Positionnement en bas
-	$this->SetXY( $x1, $y1 );
-	$this->SetFont('Arial','B',12);
-	$length = $this->GetStringWidth( $nom );
-	$this->Cell( $length, 2, $nom);
-	$this->SetXY( $x1, $y1 + 4 );
-	$this->SetFont('Arial','',10);
-	$length = $this->GetStringWidth( $address );
-	//Coordonnées de la société
-	$lines = $this->sizeOfText( $address, $length) ;
-	$this->MultiCell($length, 4, $address);
-}
-
-// bubble blocks
-function title ($label, $total, $position)
-{
-	$r1  = $position[0];
-	$r2  = $r1 + 19 + $position[2] ;
-	$y1  = $position[1];
-	$y2  = $y1;
-	$mid = $y1 + ($y2 / 2);
-	$width=10;
-	$this->SetFillColor(192);
-	$this->RoundedRect($r1-16, $y1-1, 52, $y2+1, 2.5, 'DF');
-	$this->SetXY( $r1 + 4, $y1+1 );
-	$this->SetFont( "Helvetica", "B", 15);
-	$this->Cell($width,5, $label." ".$total, 0, 0, "C");
-}
-
-// text block, non-wrapped
-function addTextBlock( $title,$text,$positions )
-{
-	$r1  = $positions[0];
-	$y1  = $positions[1];
-	$this->SetXY( $r1, $y1);
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell( $positions[2], 4,$title);
-	$this->SetXY( $r1, $y1+4);
-	$this->SetFont( "Helvetica", "", 10);
-	$this->MultiCell( $positions[2], 4, $text);
-}
-
-function tableWrapper($position)
-{
-	$r1  = $position[0];
-	$r2  = $r1 + 19 + $position[2] ;
-	$y1  = $position[1];
-	if($position[3])
-		$y2  = $position[3];
-	else
-		$y2  = 17;
-
-	$mid = $y1 + (13 / 2);
-	$width=10;
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 4.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 3, $y1+3 );
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 + 9 );
-}
-
-function addBubble($page,$title,$position)
-{
-	$r1  = $position[0];
-	$r2  = $r1 + 19 + $position[2] ;
-	$y1  = $position[1];
-	if($position[3])
-		$y2  = 17*$position[3];
-	else
-		$y2  = 17;
-
-	$mid = $y1 + (19 / 2);
-	$width=10;
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 4.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 3, $y1+3 );
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell($width,5, $title, 0, 0, "C");
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 + 9 );
-	$this->SetFont( "Helvetica", "", 10);
-	$this->MultiCell($width,5,$page, 0,0, "C");
-}
-
-// bubble blocks
-function addBubbleBlock ($page, $title, $position)
-{
-	$r1  = $position[0];
-	$r2  = $r1 + 19 + $position[2] ;
-	$y1  = $position[1];
-	$y2  = 17;
-
-	$mid = $y1 + ($y2 / 2);
-	$width=10;
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 4.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1+3 );
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell($width,5, $title, 0, 0, "C");
-	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 + 9 );
-	$this->SetFont( "Helvetica", "", 10);
-	$this->Cell($width,5,$page, 0,0, "C");
-}
-
-// record blocks
-function addRecBlock( $data, $title, $postion )
-{
-	$lengthtitle = strlen($title);
-	$lengthdata = strlen($data);
-	$length=$lengthtitle;
-	$r1  = $postion[0];
-	$r2  = $r1 + 40 + $length;
-	$y1  = $postion[1];
-	$y2  = $y1+10;
-	$mid = $y1 + (($y2-$y1) / 2);
-
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $r1 + ($r2-$r1)/2 -5 , $y1+1 );
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell(10,4, $title, 0, 0, "C");
-	$this->SetXY( $r1 + ($r2-$r1)/2 -5 , $y1 + 5 );
-	$this->SetFont( "Helvetica", "", 10);
-	$this->Cell(10,4,$data, 0, 0, "C");
-}
-
-// description blocks
-function addDescBlock( $data, $title, $position )
-{
-	$lengthtitle = strlen($title);
-	$lengthdata= $position[3];
-
-	$length=$position[2];
-	$r1  = $position[0];
-	$r2  = $r1 + 40 + $length;
-	$y1  = $position[1];
-	$y2  = $y1+10;
-	$mid = $y1 + (($y2-$y1) / 2);
-
-	$this->RoundedRect($r1,$y1, ($length + 40), ($lengthdata/140*30), 2.5, 'D');
-	$this->Line( $r1, $mid, $r2, $mid);
-	$this->SetXY( $position[0]+2 , $y1 + 1 );
-	$this->SetFont( "Helvetica", "B", 10);
-	$this->Cell(10,4, $title);
-	$this->SetXY( $position[0]+2 , $y1 + 6 );
-	$this->SetFont( "Helvetica", "", 10);
-	$this->MultiCell(($length+36),4,$data);
-}
-
-function drawLine($positions)
-{
-	$x=$positions[0];
-	$y=$positions[1];
-	$width=$positions[2];
-	$this->Line( $x, $y, $x+$width, $y);
-}
-
-// add columns to table
-function addCols( $tab ,$positions ,$bottom)
-{
-	global $columns;
-
-	$r1  = 10;
-	$r2  = $this->w - ($r1 * 2) ;
-	$y1  = 80;
-	$x1  = $positions[1];
-	$y2  = $bottom;
-	$this->SetXY( $r1, $y1 );
-	$this->SetFont( "Helvetica", "", 10);
-
-	$colX = $r1;
-	$columns = $tab;
-	while ( list( $lib, $pos ) = each ($tab) )
-	{
-		$this->SetXY( $colX, $y1+3 );
-		$this->Cell( $pos, 1, $lib, 0, 0, "C");
-		$colX += $pos;
-	switch($lib) {
-	  case 'Total':
-	  break;
-	  default:
-			$this->Line( $colX, $y1, $colX, $y1+$y2);
-	  break;
-	}
-	}
-}
-
-function addLineFormat( $tab )
-{
-	global $format, $columns;
-
-	while ( list( $lib, $pos ) = each ($columns) )
-	{
-		if ( isset( $tab["$lib"] ) )
-			$format[ $lib ] = $tab["$lib"];
-	}
-}
-
-function addProductLine( $line, $tab )
-{
-	global $columns, $format;
-
-	$ordonnee     = 10;
-	$maxSize      = $line;
-
-	reset( $columns );
-	while ( list( $lib, $pos ) = each ($columns) )
-	{
-		$longCell  = $pos -2;
-		$text    = $tab[ $lib ];
-		$length    = $this->GetStringWidth( $text );
-		$formText  = $format[ $lib ];
-		$this->SetXY( $ordonnee, $line);
-		$this->MultiCell( $longCell, 3 , $text, 3, $formText);
-		if ( $maxSize < ($this->GetY()  ) )
-			$maxSize = $this->GetY() ;
-		$ordonnee += $pos;
-	}
-	return ( $maxSize - $line );
-}
-
-function addTotalsRec($names, $totals, $positions)
-{
-	$this->SetFont( "Arial", "B", 8);
-	$r1  = $positions[0];
-	$r2  = $r1 + 90;
-	$y1  = $positions[1];
-	$y2  = $y1+10;
-	$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D');
-	$this->Line( $r1, $y1+4, $r2, $y1+4);
-	$this->Line( $r1+27, $y1, $r1+27, $y2);  // avant Subtotal
-	$this->Line( $r1+43, $y1, $r1+43, $y2);  // avant Tax
-	$this->Line( $r1+66, $y1, $r1+66, $y2);  // avant Adjustment
-
-	$this->SetXY( $r1+2, $y1);
-	$this->Cell(10,4, $names[0]);
-	$this->SetX( $r1+29,$y1 );
-	$this->Cell(10,4, $names[1]);
-	$this->SetX( $r1+45 );
-	$this->Cell(10,4, $names[2]);
-	$this->SetX( $r1+66 );
-	$this->Cell(10,4, $names[3]);
-
-
-	$this->SetXY( $r1+2, $y1+5 );
-	$this->Cell( 10,4, $totals[0] );
-	$this->SetXY( $r1+29, $y1+5 );
-	$this->Cell( 10,4, $totals[1] );
-	$this->SetXY( $r1+44, $y1+5 );
-	$this->Cell( 10,4, $totals[2] );
-	$this->SetXY( $r1+66, $y1+5 );
-	$this->Cell( 10,4, $totals[3] );
-
-	$this->SetFont( "Arial", "B", 6);
-	$this->SetXY( $r1+90, $y2 - 8 );
-	$this->SetFont( "Helvetica", "", 10);
-}
-
-// add a watermark (temporary estimate, DUPLICATA...)
-// call this method first
-function watermark( $text, $positions, $rotate = array('45','50','180') )
-{
-	$this->SetFont('Arial','B',50);
-	$this->SetTextColor(230,230,230);
-	$this->Rotate($rotate[0],$rotate[1],$rotate[2]);
-	$this->Text($positions[0],$positions[1],$text);
-	$this->Rotate(0);
-	$this->SetTextColor(0,0,0);
-}
-
-}
-
-function StripLastZero($string)
-{
-	$count=strlen($string);
-	$ret=substr($string,0,($count-1));
-	return $ret;
-}
-
 
 // **************** BEGIN POPULATE DATA ********************
-
-
 // populate data
-$quote_name = getQuoteName($focus->column_fields["quote_id"]);
+if($focus->column_fields["quote_id"] != '')
+	$quote_name = getQuoteName($focus->column_fields["quote_id"]);
+else
+	$quote_name = '';
 $po_name = $focus->column_fields["purchaseorder"];
 $subject = $focus->column_fields["subject"];
 
@@ -535,7 +136,7 @@
 
 	$pdf->AddPage();
 	include("pdf_templates/header.php");
-	include("pdf_templates/body.php");
+	include("include/fpdf/templates/body.php");
 	include("pdf_templates/footer.php");
 
 	$page_num++;





More information about the vtigercrm-commits mailing list