Jump to content

Displaying html tags with styles stored in database in fpdf


mythri
 Share

Recommended Posts

I have stored html data in db table as text looks like this , styled through html WYSIWYG editor.

<ul>
    <li><span style="background-color:rgb(255, 255, 255); color:rgb(35, 64, 70); font-family:lucida grande,lucida sans unicode,helvetica,arial,verdana,sans-serif; font-size:13px">Static Website</span></li>
    <li><span style="background-color:rgb(255, 255, 255); color:rgb(35, 64, 70); font-family:lucida grande,lucida sans unicode,helvetica,arial,verdana,sans-serif; font-size:13px">Number of Pages-20</span></li></ul>

In general it is getting displayed properly like

$row['description'];

But in fpdf it is very haphazard, like this

 

post-168283-0-23172000-1500130000_thumb.png

 

I tried putting htmlspecialchars(), htmlentities(), mysqli_real_escape_string....

But its of no use.

my fpdf files are

invoice.php file is

class PDF_Invoice extends FPDF
{
// private variables
var $colonnes;
var $format;
var $angle=0;
var $B; 
var $I; 
var $U; 
var $HREF; 
function PDF($orientation='P',$unit='mm',$format='A4') 
{ 
//Call parent constructor 
$this->FPDF($orientation,$unit,$format); 
//Initialization 
$this->B=0; 
$this->I=0; 
$this->U=0; 
$this->HREF=''; 
} 

function WriteHTML($html, $bi)
{ 
//HTML parser 
$html=strip_tags($html,"<b><u><i><a><img><p><br><strong><em><font><tr><blockquote><hr><td><tr><table><sup>"); //remove all unsupported tags
    $html=str_replace("\n",'',$html);
    $html=str_replace(" ",'',$html); //replace carriage returns by spaces
    $html=str_replace("\t",'',$html); //replace carriage returns by spaces
 $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE); 
foreach($a as $i=>$e) 
{ 
if($i%2==0) 
{ 
//Text 
if($this->HREF) 
$this->PutLink($this->HREF,$e); 
else 
$this->Write(5,$e); 
} 
else 
{ 
//Tag 
if($e{0}=='/') 
$this->CloseTag(strtoupper(substr($e,1))); 
else 
{ 
//Extract attributes 
$a2=explode(' ',$e); 
$tag=strtoupper(array_shift($a2)); 
$attr=array(); 
foreach($a2 as $v) 
if(ereg('^([^=]*)=["\']?([^"\']*)["\']?$',$v,$a3)) 
$attr[strtoupper($a3[1])]=$a3[2]; 
$this->OpenTag($tag,$attr); 
} 
} 
} 
} 

function OpenTag($tag,$attr) 
{ 
//Opening tag 
if($tag=='B' or $tag=='I' or $tag=='U') 
$this->SetStyle($tag,true); 
if($tag=='A') 
$this->HREF=$attr['HREF']; 
if($tag=='BR') 
$this->Ln(10); 
} 

function CloseTag($tag) 
{ 
//Closing tag 
if($tag=='B' or $tag=='I' or $tag=='U') 
$this->SetStyle($tag,false); 
if($tag=='A') 
$this->HREF=''; 
} 

function SetStyle($tag,$enable) 
{ 
//Modify style and select corresponding font 
$this->$tag+=($enable ? 1 : -1); 
$style=''; 
foreach(array('B','I','U') as $s) 
if($this->$s>0) 
$style.=$s; 
$this->SetFont('',$style); 
} 

function PutLink($URL,$txt) 
{ 
//Put a hyperlink 
$this->SetTextColor(0,0,255); 
$this->SetStyle('U',true); 
$this->Write(5,$txt,$URL); 
$this->SetStyle('U',false); 
$this->SetTextColor(0); 
} 


// other functions

Pdf generating file

<?php
// (c) Xavier Nicolay
// Exemple de génération de devis/facture PDF
$id= $_GET['order_id'];
include('../connect.php');
include('../admin_auth.php');

require('quote_fp.php');

$pdf = new PDF_Invoice( 'P', 'mm', 'A4' );
$pdf->AddPage();
$cols=array( "HSN/SAC"    => 15,
             "Item Code"  => 15,
             "Description"     => 30,
             "Price"      => 15,
             "Qty" => 13,

              );
$pdf->addCols( $cols);
$cols=array( "HSN/SAC"    => "L",
             "Item Code"  => "L",
             "Description"     => "L",
             "Price"      => "L",
             "Qty" => "L",

            );
// php codes
// $query ="";
while($row = mysqli_fetch_array($query))
{
$line = array( "HSN/SAC"    => "".$row['hsn_sac']."",
               "Item Code"  => "".$row['item']."",             
               "Description"     => "".$row['description']."",
               "Price"      => "".$row['selling_price']."",
               "Qty"  => "".$row['quantity']."",
);
}

Can somebody guide me?

Link to comment
Share on other sites

You are using individual styling on every element of your html instead of css?  What a nightmare should you ever need to alter your style.

 

As for your question - What is wrong?  'haphazard' is not very meaningful.  Perhaps you could show us how you think it should look.   

Link to comment
Share on other sites

Huh?

 

All I see is inline styling all through your sample html.  What stylesheet are you talking about?

 

I don't know what your reference to $row and the png output are supposed to be telling me.

 

You do realize that I am not sitting at your screen so you really should be a bit more helpful in your description of your problem.

 

And stop posting these images.  We prefer real code and real output.

Link to comment
Share on other sites

PDF is not HTML. HTML is not PDF. They're two entirely different and unrelated languages/formats.

 

When you insert HTML markup into an PDF document, then you get the markup as raw text. The PDF viewer has no idea what else it should do with that.

 

If you want to translate the markup into something a PDF viewer can understand, then you need to actually do that. The crude WriteHTML() method (which you don't seem to be using anyway) won't help you with that, because it cannot handle lists. Chances are you'll have to parse the markup yourself and then find a way to generate a list with fpdf. Google can help you.

Link to comment
Share on other sites

Sorry,

 

End user will input the product description through HTML editor like this

<form name="users" method="post" action="item_submit.php" enctype="multipart/form-data" class="horizontal-form" onsubmit="return validate();">
	<div class="form-body">
	
	<div class="row">
	<div class="col-md-4">
	<div class="form-group has-error">
		<label class="control-label">Name </label><input type="text" class="form-control" name="name" id="firstname"  required/>
	</div>
 	</div>


	<div class="col-md-4">
	<div class="form-group">
		<label class="control-label"></label>
		<?php
		$sql5 = "SELECT * FROM uom ORDER BY uom_name";
		$query5 = mysqli_query($con, $sql5);
		?>

		<select name="uom" class="form-control">
         <option value="">Select UOM</option>
			<?php while ($rs5 = mysqli_fetch_array($query5)) { ?>
			<option value="<?php echo $rs5["uom_name"]; ?>"><?php echo $rs5["uom_name"]; ?></option>
			<?php } ?>
		</select>
</div>
</div>


    </div>
    <div class="row">
    <div class="col-md-10">
	<div class="form-group has-error">
		<label class="control-label">Desciption</label>
		 <textarea name="description" class="ckeditor form-control" id="wysiwg_val" cols="30" rows="6" required></textarea>
	</div>
	</div>
    </div>
<div class="row">
    
    
    <div class="col-md-4">
    <div class="form-group has-error">
    <label class="control-label">Purchase Price </label><input type="text" name="cost" id="firstname" required class="form-control" />
    </div>
    </div>
 
    <div class="col-md-4">
    <div class="form-group has-error">
        <label class="control-label">Selling Price </label><input type="text" name="selling_price" id="firstname" class="form-control" required/>
    </div>
    </div>
    
     <div class="col-md-4">
    <div class="form-group has-error">
        <label class="control-label">HSN/SAC # </label><input type="text" name="hsn_sac" required  class="form-control" />
    </div>
    </div>
    
   
    
    </div>
    
    
    <div class="row">
    <div class="col-md-4">
    <div class="form-group">
        <label class="control-label"></label>
        <?php
        $sql = "SELECT * FROM taxes";
        $query = mysqli_query($con, $sql);
        ?>

        <select name="tax" class="form-control">
<option value="">Select Tax</option>
            <?php while ($rs = mysqli_fetch_array($query )) { ?>
            <option value="<?php echo $rs["tax_id"]; ?>"><?php echo $rs["name"].' - '.$rs['rate']; ?>%</option>
            <?php } ?>
        </select>

    </div>
    </div>
    
   


<div class="col-md-4">
    <div class="form-group has-error">
        <label class="control-label"></label>
        <select name="type" class="form-control" required>
        <option value="">Select Type</option>
            <option value="Product">Product</option>
            <option value="Service">Service</option>
 
        </select>
    </div>
    </div>
    
    
    <div class="col-md-4">
    <div class="form-group has-error">
        <label class="control-label"></label>
        <select name="active" class="form-control" required>
        <option value="">Is Active?</option>
            <option value="Yes">Yes</option>
            <option value="No">No</option>
 
        </select>
    </div>
    </div>
    </div>
    <div class="row">
   
 <div class="col-md-4">
    <div class="form-group has-error"><br />

    <input type="submit" name="submit" id="save" value="ADD ITEM" class="btn blue" /></div>
    </div>
    </div>
    </div>
 
</form>


I am storing this value into my database table

$name = $_POST['name'];
$descr = mysqli_real_escape_string($con, $_POST['description']);
$uom = $_POST['uom'];
$cost = $_POST['cost'];
$selling = $_POST['selling_price'];
$tax = $_POST['tax'];
$active = $_POST['active'];
$lead_time = $_POST['lead_time'];
$istock = $_POST['initial_stock'];
$type = $_POST['type'];
$hsn = $_POST['hsn_sac'];


$uom = !empty($uom) ? "".$uom."" : "NULL";
$tax = !empty($tax) ? "".$tax."" : "NULL";
$istock = !empty($istock) ? "".$istock."" : "0";


$twoLet = 'ITM';
$query = mysqli_query($con, "SELECT item_id FROM items ORDER BY item_id DESC LIMIT 1"); 
$count = mysqli_num_rows($query);
if($count==0)
{
	$newRef=$twoLet."001";
}
else
{

$r1 = mysqli_fetch_array($query);
$newRef = $twoLet."00".($r1['item_id']+1);

}

$sql = mysqli_query($con, "insert into items (iid, name, description, uom, cost, selling_price, tax_id, active, type, hsn_sac) values ('".$newRef."', '".$name."', '".$descr."', '".$uom."', ".$cost.", ".$selling.", ".$tax.", '".$active."', '".$type."', '".$hsn."')") or die (mysqli_error($con)); 

Now when i make quotation and print it, the html tags are displaying as it is without styling.

 

Here is my complete quotation using fpdf

<?php
// (c) Xavier Nicolay
// Exemple de génération de devis/facture PDF
$id= $_GET['order_id'];
include('../connect.php');
include('../admin_auth.php');

require('quote_fp.php');

$pdf = new PDF_Invoice( 'P', 'mm', 'A4' );
$pdf->AddPage();
//$pdf->Header();
$com = mysqli_query($con, "SELECT * FROM companies");
$r1 = mysqli_fetch_array($com);
$cname = $r1['name'];
$cadd_1 = $r1['address_1'];
$cadd_2 = $r1['address_2'];
$cpin = $r1['pin'];
$ccity = $r1['city'];
$cstate = $r1['state'];
$cphone = $r1['phone'];
$cemail = $r1['email'];
$cpan = $r1['pan'];
$ccin = $r1['cin'];
$ctin = $r1['tin'];
$gst = $r1['vat'];
//echo $rw1;

$bnk = mysqli_query($con, "SELECT * FROM banks");
$bk = mysqli_fetch_array($bnk);

$bname = $bk['name'];
$bbranch = $bk['branch'];
$bacc_no = $bk['account_no'];
$ifsc = $bk['ifsc'];

$ven = mysqli_query($con, "SELECT so.company_id, so.reference, so.contact_person, so.billing_address, so.t_c, so.payment, so.validity, l.company AS vname, l.gst, stc.desc_text, spt.description, lc.firstname, lc.lastname FROM orders AS so INNER JOIN leads AS l ON so.company_id=l.id INNER JOIN lead_contact AS lc ON so.contact_person=lc.con_id INNER JOIN terms_conditions AS stc ON so.t_c=stc.name INNER JOIN payment_terms AS spt ON so.payment=spt.name WHERE so.sales_order_id='".$id."'") or die (mysqli_error($con));
$v1 = mysqli_fetch_array($ven);
$vname = $v1['vname'];
$payment = $v1['description'];
$terms = $v1['desc_text'];
$validity = $v1['validity'];
$reference = $v1['reference'];
$cid = $v1['company_id'];
$lgst = $v1['gst'];
$cperson = $_v1['firstname'].' '.$v1['lastname'];
$billing = $v1['billing_address'];


$bill = mysqli_query($con, "SELECT * FROM lead_address WHERE company_id=".$cid." AND address_name='".$billing."'") or die (mysqli_error($con));$b1 = mysqli_fetch_array($bill);


                
$sql ="SELECT sol.sales_order_id, sol.item, sol.uom, sol.quantity, sol.selling_price, sol.discount, sol.total, sol.tax_amount, sol.tax, i.name, i.hsn_sac, i.description, t.name AS tname, t.rate FROM before_order_line_items AS sol INNER JOIN items AS i ON sol.item=i.iid INNER JOIN taxes AS t ON sol.tax=t.tax_id WHERE sol.sales_order_id='".$_GET['order_id']."'";

//echo $sql;

$query = mysqli_query($con, $sql) or die (mysqli_error($con));            

$total_amt = 0;
$tax_amt = 0;
$frt_amt = 0;
$i=1;

//$pdf->addSociete( "".$cname."",
//                  "".$cadd_1."\n" .
//                  "".$cadd_2."\n".
//                  "".$cstate.", \n".
//                  "".$ccity.", ".$cpin."\n".
//                  "".$cphone.",  - ".$cemail."\n"  
//                  );
$pdf->fact_dev1( "Quotation" );                  
$pdf->fact_dev( "Quote No ", "".$_GET['order_id']."" );
//$pdf->temporaire( "Devis temporaire" );
$pdf->fact_dev5( "Date ", "".date('jS F Y')."" );
//$pdf->addDate( date('jS F Y'));
$pdf->fact_dev6( "Validity ", "".$validity." Days" );
//$pdf->addClient("".$validity." Days");
// 20mm from each edge
//$pdf->addPageNumber("1");
$pdf->addClientAdresse2("".$vname."\n".$b1['address_1']."\n".$b1['address_2']."\n".$b1['state']."\n".$b1['city']." - ".$b1['pin']."\n\nGST No.: - ".$lgst."");
$pdf->addClientAdresse1("".$cname."\n".$cadd_1."\n".$cadd_2."\n".$ccity." - ".$cpin."\nPhone: - ".$cphone."\nE-mail - ".$cemail."\n\nGSTIN No.: - ".$gst."");
//$pdf->addClientAdresse("".$vname."\n".$s1['address_1']."  ".$s1['address_2']."\n".$s1['state']."\n".$s1['city']." - ".$s1['pin']."\n\nGST No.: - ".$lgst."");
$pdf->addBankDetails("Name:  ".$bname."\nAcc. No:  ".$bacc_no."\nBranch:  ".$bbranch."\nIFSC Code:  ".$ifsc."\n");
$pdf->addBankHead("");
$pdf->addpayterms1("");
//$pdf->SetXY(34, 237.5);
$pdf->addpayterm2($payment);
//$pdf->MultiCell(20, 7, $payment, 0, 'L',0);
$pdf->addShipInst();
$pdf->addShipInst1($reference);
$cols=array( "HSN/SAC"    => 15,
             "Item Code"  => 15,
             "Description"     => 30,
             "Price"      => 15,
             "Qty" => 13,
             "Disc%"          => 10,
             "Taxable Amt"    => 20,
             "CGST%"          => 10,
             "Amt"          => 15,
             "SGST%"          => 10,
             "Amt "          => 15,
              "IGST%"          => 10,
             " Amt"          => 15,
              );
$pdf->addCols( $cols);
$cols=array( "HSN/SAC"    => "L",
             "Item Code"  => "L",
             "Description"     => "L",
             "Price"      => "L",
             "Qty" => "L",
             "Disc%"          => "L",
             "Taxable Amt"    => "L",
              "CGST%"          => "L",
               "Amt"          => "L",
                "SGST%"          => "L",
             "Amt "          => "L",
              "IGST%"          => "L",
             " Amt"          => "L"    ,    
            );
            $pdf->WriteHTML($_POST['text']);
$pdf->addLineFormat( $cols);
$pdf->addLineFormat($cols);

$y    = 123;
$tamt1 =0;
$iamt =0;
 $qty1 = 0;
while($row = mysqli_fetch_array($query))
{
if($row['tname']=='GST')
{
$tr1 = $row['rate']/2;
$trate = $tr1;
$tax_amount = ($row['total'] * ($trate/100));
$trate1 = 'NA';
$tax_amount1 = 00;
}
else
if($row['tname']=='IGST')
{
    $tr2 = $row['rate'];
    $trate1 = $tr2;
    $tax_amount1 = ($row['total'] * ($tr2/100));
    $trate = 'NA';
    $tax_amount = 00;
}

$total = $row['sub_total']+$row['tax_amount'];    
$line = array( "HSN/SAC"    => "".$row['hsn_sac']."",
               "Item Code"  => "".$row['item']."",             
               "Description"     => "".htmlspecialchars_decode($row['description'])."",
               "Price"      => "".$row['selling_price']."",
               "Qty"  => "".$row['quantity']."",
               "Disc%"          => "".$row['discount']."",
               "Taxable Amt"          => "".number_format(($row['total']),2)."",
               "CGST%"          => "".$trate."",
               "Amt"          => "".$tax_amount."",
               "SGST%"          => "".$trate."",
               "Amt "          => "".$tax_amount."",
               "IGST%"          => "".$trate1."",
               " Amt"          => "".$tax_amount1."",
               );
$size = $pdf->addLine( $y, $line );
$y   += $size + 10;


$total_amt += $row['total'];
 $tax_amt += $row['tax_amount'];
 $tamt1 += $tax_amount;
 $iamt += $tax_amount1;
 $qty1 += $row['quantity'];
}
$pdf->SetLineWidth(0.01);
//$pdf->Line(9,  247, 220-18, 247);
$pdf->Rect(9.1,222,192.6,10);
$pdf->addTotalText("Total");
//$pdf->Rect(9.1,247,192.6,10);
//$pdf->addReverseText("Amount of Tax subject to Reverse Charges");
$pdf->addRemarque($qty1);
$pdf->addTaxable((number_format($total_amt,2)));
$pdf->addSgst((number_format($tamt1,2)));
$pdf->addCgst((number_format($tamt1,2)));
$pdf->addIgst((number_format($iamt,2)));
$pdf->addTVAs($total_amt, $tax_amt);
$pdf->addCadreEurosFrancs($total_amt,$tax_amt);
//$pdf->Footer();

//$pdf->Output();
$pdf->AddPage();
//$pdf->SetAutoPageBreak(1,-185);
//$pdf->SetTopMargin(30);
//$pdf->SetY(-25);
//$y    = 354;
//$pdf->Write(0,(htmlentities($rw1)),0);
//$pdf->SetMargins(0, -10);
//$pdf->cMargin = 20;
$pdf->WriteHTML("<BR><BR>");
$pdf->WriteHTML($terms);
//$pdf->Output('Sales-Quote-'.$_GET['order_id'].' - '.date('m-d-Y').'.pdf',D);
$pdf->Output();
?>


quote_fp.php

<?php
require('../fpdf/fpdf.php');
//define('EURO', chr(128) );
//define('EURO_VAL', 6.55957 );
error_reporting(0);
//require('../fpdf/makefont/makefont.php');
//MakeFont('../fpdf/OpenSans-Regular.ttf','opensans-regular.afm');

//MakeFont('../fpdf/OpenSans-Regular.ttf','cp1252');//


// Xavier Nicolay 2004
// Version 1.02

//////////////////////////////////////
// Public functions                 //
//////////////////////////////////////
//  function sizeOfText( $texte, $larg )
//  function addSociete( $nom, $adresse )
//  function fact_dev( $libelle, $num )
//  function addDevis( $numdev )
//  function addFacture( $numfact )
//  function addDate( $date )
//  function addClient( $ref )
//  function addPageNumber( $page )
//  function addClientAdresse( $adresse )
//  function addReglement( $mode )
//  function addEcheance( $date )
//  function addNumTVA($tva)
//  function addReference($ref)
//  function addCols( $tab )
//  function addLineFormat( $tab )
//  function lineVert( $tab )
//  function addLine( $ligne, $tab )
//  function addRemarque($remarque)
//  function addCadreTVAs()
//  function addCadreEurosFrancs()
//  function addTVAs( $params, $tab_tva, $invoice )
//  function temporaire( $texte )

class PDF_Invoice extends FPDF
{
// private variables
var $colonnes;
var $format;
var $angle=0;
var $B; 
var $I; 
var $U; 
var $HREF; 
function PDF($orientation='P',$unit='mm',$format='A4') 
{ 
//Call parent constructor 
$this->FPDF($orientation,$unit,$format); 
//Initialization 
$this->B=0; 
$this->I=0; 
$this->U=0; 
$this->HREF=''; 
} 

function WriteHTML($html, $bi)
{ 
//HTML parser 
$html=strip_tags($html,"<b><u><i><a><img><p><br><strong><em><font><tr><blockquote><hr><td><tr><table><sup>"); //remove all unsupported tags
    $html=str_replace("\n",'',$html);
	$html=str_replace(" ",'',$html); //replace carriage returns by spaces
    $html=str_replace("\t",'',$html); //replace carriage returns by spaces
 $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE); 
foreach($a as $i=>$e) 
{ 
if($i%2==0) 
{ 
//Text 
if($this->HREF) 
$this->PutLink($this->HREF,$e); 
else 
$this->Write(5,$e); 
} 
else 
{ 
//Tag 
if($e{0}=='/') 
$this->CloseTag(strtoupper(substr($e,1))); 
else 
{ 
//Extract attributes 
$a2=explode(' ',$e); 
$tag=strtoupper(array_shift($a2)); 
$attr=array(); 
foreach($a2 as $v) 
if(ereg('^([^=]*)=["\']?([^"\']*)["\']?$',$v,$a3)) 
$attr[strtoupper($a3[1])]=$a3[2]; 
$this->OpenTag($tag,$attr); 
} 
} 
} 
} 

function OpenTag($tag,$attr) 
{ 
//Opening tag 
if($tag=='B' or $tag=='I' or $tag=='U') 
$this->SetStyle($tag,true); 
if($tag=='A') 
$this->HREF=$attr['HREF']; 
if($tag=='BR') 
$this->Ln(10); 
} 

function CloseTag($tag) 
{ 
//Closing tag 
if($tag=='B' or $tag=='I' or $tag=='U') 
$this->SetStyle($tag,false); 
if($tag=='A') 
$this->HREF=''; 
} 

function SetStyle($tag,$enable) 
{ 
//Modify style and select corresponding font 
$this->$tag+=($enable ? 1 : -1); 
$style=''; 
foreach(array('B','I','U') as $s) 
if($this->$s>0) 
$style.=$s; 
$this->SetFont('',$style); 
} 

function PutLink($URL,$txt) 
{ 
//Put a hyperlink 
$this->SetTextColor(0,0,255); 
$this->SetStyle('U',true); 
$this->Write(5,$txt,$URL); 
$this->SetStyle('U',false); 
$this->SetTextColor(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' || $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( $texte, $largeur )
{
	$index    = 0;
	$nb_lines = 0;
	$loop     = TRUE;
	while ( $loop )
	{
		$pos = strpos($texte, "\n");
		if (!$pos)
		{
			$loop  = FALSE;
			$ligne = $texte;
		}
		else
		{
			$ligne  = substr( $texte, $index, $pos);
			$texte = substr( $texte, $pos+1 );
		}
		$length = floor( $this->GetStringWidth( $ligne ) );
		$res = 1 + floor( $length / $largeur) ;
		$nb_lines += $res;
	}
	return $nb_lines;
}
function Header()
{
    //Logo
	
    $this->Image('../logo/logo.png',11,5,'',20);
    //Arial bold 15
    $this->SetFont('Arial','B',13);
    //Move to the right
    $this->Cell(70);
    //Title
    $this->Cell(30,1,'Quotation',0,0,'C');
    //Line break
    //$this->Ln(20);
	include('../connect.php');
	$ven = mysqli_query($con, "SELECT so.company_id, so.contact_person, so.billing_address, so.shipping_address, so.t_c, so.payment, so.validity, l.company AS vname, stc.desc_text, spt.description, lc.firstname, lc.lastname FROM orders AS so INNER JOIN leads AS l ON so.company_id=l.id INNER JOIN lead_contact AS lc ON so.contact_person=lc.con_id INNER JOIN terms_conditions AS stc ON so.t_c=stc.name INNER JOIN payment_terms AS spt ON so.payment=spt.name WHERE so.sales_order_id='".$_GET['order_id']."'");
$v1 = mysqli_fetch_array($ven);
$validity = $v1['validity'];
	$this->fact_dev("Quote No ", "".$_GET['order_id']."");
	$this->fact_dev5( "Date ", "".date('jS F Y')."" );
	$this->fact_dev6( "Validity ", "".$validity." Days" );
//$pdf->addDate( date('jS F Y'));
$r1  = $this->w - 81;
	$r2  = $r1 + 30;
	$y1  = 15;
	$y2  = $y1 ;
	$mid = $y1 + ($y2 / 1);
	
	//$this->Line( 8, $mid, 220-20, $mid);
//$this->Line(8, 45, 220-20, 45); 


}
function Footer()
{
	include('../connect.php');
   $com = mysqli_query($con, "SELECT * FROM companies");
$r1 = mysqli_fetch_array($com);
$cname = $r1['name'];
$cadd_1 = $r1['address_1'];
$cadd_2 = $r1['address_2'];
$cpin = $r1['pin'];
$ccity = $r1['city'];
$cstate = $r1['state'];
$cphone = $r1['phone'];
$cemail = $r1['email'];
$cpan = $r1['pan'];
$cstax = $r1['service_tax'];
$ccin = $r1['cin'];
$ctin = $r1['tin'];

    $this->setY(-20);
	
	$this->SetLineWidth(0.01);
	$this->Line( 8,  284.5, 220-20, 284.5); 
   $this->SetFont("", "", 6);
    $this->Cell(175,10,'Pvt Ltd Company - PAN: '.$cpan.', CIN: '.$ccin.' ',10,0,'C');
   // $this->Cell(-175,20,'SRVC TAX: '.$cstax.' - CIN: '.$ccin.'',10,0,'C');
   $this->Cell(-175, 20,'This document has been electronically generated and requires no physical signature or stamp.',10,0,'C');

	
}
// Company
function addSociete( $nom, $adresse )
{
	$x1 = 10;
	$y1 = 22;
	//Positionnement en bas
	
	//
	$this->SetXY( $x1, $y1 - 4 );
	
	$this->SetFont("", "", 10);
	$this->Cell(10,5, "FROM:", 0, 0, "L");
	$this->SetXY( $x1, $y1 );
	//$this->AddFont('OpenSans','','OpenSans-Regular.php');
	$this->SetFont('','',10);
	$length = $this->GetStringWidth($nom);
	$this->Cell( $length, 8, $nom);
	$this->SetXY( $x1, $y1 + 7 );
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont('','',;
	$length = $this->GetStringWidth( $adresse );
	//Coordonnées de la société
	$lignes = $this->sizeOfText( $adresse, $length) ;
	$this->MultiCell($length, 4, $adresse);
}

// Label and number of invoice/estimate
function fact_dev( $libelle, $num )
{
    $r1  = $this->w - 75.8;
    $r2  = $r1 + 68;
    $y1  = 6;
    $y2  = $y1 + 2;
    $mid = ($r1 + $r2 ) / 2;
    
    $texte  = $libelle . " : " . $num;    
    $szfont = 10;
    $loop   = 0;
    
    while ( $loop == 0 )
    {
		//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
       $this->SetFont( "", "B", $szfont );
       $sz = $this->GetStringWidth( $texte );
       if ( ($r1+$sz) > $r2 )
          $szfont --;
       else
          $loop ++;
    }

    $this->SetLineWidth(0.01);
    $this->SetFillColor(235,237,238);
    //$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 0, 'DF');
    $this->SetXY( $r1+1, $y1+2);
    $this->Cell($r2-$r1 -1,5, $texte, 0, 0, "C" );
}
function fact_dev5( $libelle, $num )
{
    $r1  = $this->w - 60;
    $r2  = $r1 + 68;
    $y1  = 15;
    $y2  = $y1 + 2;
    $mid = ($r1 + $r2 ) / 2;
    
    $texte  = $libelle . " : " . $num;    
    $szfont = 8;
    $loop   = 0;
    
    while ( $loop == 0 )
    {
		//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
       $this->SetFont("", "", $szfont );
       $sz = $this->GetStringWidth( $texte );
       if ( ($r1+$sz) > $r2 )
          $szfont --;
       else
          $loop ++;
    }

    $this->SetLineWidth(0.01);
   // $this->SetFillColor(235,237,238);
    //$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 0, 'DF');
    $this->SetXY( $r1+1, $y1+2);
    $this->Cell($r2-$r1 -1,5, $texte, 0, 0, "L" );
}
function fact_dev6( $libelle, $num )
{
    $r1  = $this->w - 60;
    $r2  = $r1 + 68;
    $y1  = 20;
    $y2  = $y1 + 2;
    $mid = ($r1 + $r2 ) / 2;
    
    $texte  = $libelle . " : " . $num;    
    $szfont = 8;
    $loop   = 0;
    
    while ( $loop == 0 )
    {
		//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
       $this->SetFont("", "", $szfont );
       $sz = $this->GetStringWidth( $texte );
       if ( ($r1+$sz) > $r2 )
          $szfont --;
       else
          $loop ++;
    }

    $this->SetLineWidth(0.01);
   // $this->SetFillColor(235,237,238);
    //$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 0, 'DF');
    $this->SetXY( $r1+1, $y1+2);
    $this->Cell($r2-$r1 -1,5, $texte, 0, 0, "L" );
}


function fact_dev1( $libelle, $num )
{
    $this->Cell(70);
    //Title
	$this->SetFont( "", "B", 14);
   $this->Cell(20,-60,'Quotation',0,0,'C');
    //Line break
    //$this->Ln(20);
}
// Estimate
function addDevis( $numdev )
{
	$string = sprintf("DEV%04d",$numdev);
	$this->fact_dev( "Devis", $string );
}

// Invoice
function addFacture( $numfact )
{
	$string = sprintf("FA%04d",$numfact);
	$this->fact_dev( "Facture", $string );
}

function addDate( $date )
{
	$r1  = $this->w - 81;
	$r2  = $r1 + 30;
	$y1  = 17;
	$y2  = $y1 ;
	$mid = $y1 + ($y2 / 1);
	$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 0.5, 'D');
	$this->Line( $r1, $mid, $r2, $mid);
	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1+3 );
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "B", ;
	$this->Cell(10,3, "DATE", 0, 0, "C");
	$this->SetXY( $r1 + ($r2-$r1)/2 - 3, $y1+8 );
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "", ;
	$this->Cell(8,4,$date, 0,0, "C");
}

function addClient( $ref )
{
	$r1  = $this->w - 39;
	$r2  = $r1 + 19;
	$y1  = 17;
	$y2  = $y1;
	$mid = $y1 + ($y2 / 2);
	$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 1.5, 'D');
	$this->Line( $r1, $mid, $r2, $mid);
	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1+3 );
	$this->SetFont( "", "B", 10);
	$this->Cell(10,5, "Validity", 0, 10, "C");
	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 + 9 );
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "", ;
	$this->Cell(10,5,$ref, 0,0, "C");
}

function addPageNumber( $page )
{
	$r1  = $this->w - 80;
	$r2  = $r1 + 19;
	$y1  = 17;
	$y2  = $y1;
	$mid = $y1 + ($y2 / 2);
	$this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 3.5, 'D');
	$this->Line( $r1, $mid, $r2, $mid);
	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1+3 );
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "B", 10);
	$this->Cell(10,5, "PAGE", 0, 0, "C");
	$this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 + 9 );
	$this->SetFont( "", "", 10);
	$this->Cell(10,5,$page, 0,0, "C");
}

// Client address
function addClientAdresse( $adresse )
{
	$r1     = $this->w - 80;
	$r2     = $r1 + 68;
	$y1     = 85;
	//$this->Rect(129,86,73,30);
	$this->SetXY( $r1-2, $y1 - 5 );
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "B", ;
	$this->Cell(10,5, "Sold To:", 0, 0, "L");
	$this->SetFont( "", "", ;
	$this->SetXY( $r1, $y1+2);
	$this->MultiCell(80, 4, $adresse);
}

function addClientAdresse1( $adresse )
{
	$r1     = $this->w - 200;
	$r2     = $r1 + 68;
	$y1     = 56;
	$this->Rect(10,57,87,36,'F');
	
	$this->SetXY( $r1-1, $y1 - 5 );
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "B", ;
	$this->Cell(10,5, "From:", 0, 0, "L");
	$this->SetFont( "", "", ;
	$this->SetXY( $r1, $y1+2);
	$this->MultiCell( 60, 4, $adresse);
}

function addClientAdresse2( $adresse )
{
	$r1     = $this->w - 94;
	$r2     = $r1 + 68;
	$y1     = 56;
	$this->Rect(115,57,87,36);
	$this->SetXY( $r1-2, $y1 - 5 );
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "B", ;
	$this->Cell(10,5, "Bill To:", 0, 0, "L");
	$this->SetFont( "", "", ;
	$this->SetXY( $r1, $y1+2);
	$this->MultiCell( 150, 4, $adresse);
}
function addBankDetails( $adresse )
{
	$r1     = $this->w - 412;
	$r2     = $r1 + 60;
	$y1     = 258;
	//$this->Rect(10,86,87,30);
	$this->SetXY( $r1, $y1 );
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	//$this->SetFont( "", "B", ;
	//$this->Cell(10,5, "Bank Details:", 0, 0, "L");
	$this->SetFont( "", "", ;
	$this->SetXY( $r1, $y1+2);
	$this->MultiCell( 150, 4, $adresse);
}
function addBankHead($ref)
{
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "B", ;
	$length = $this->GetStringWidth( "BankDetails");
	$r1  = 8;
	$r2  = $r1 + $length;
	$y1  = 255;
	$y2  = $y1+8;
	$this->SetXY( $r1 , $y1 );
	
	$this->Cell($length,4, "Payment Details: ");
	$this->SetFont( "", "", ;
	
	
	
	
}

// Mode of payment
function addReglement( $mode )
{
	$r1  = $this->w - 80;
	$r2  = $r1 + 68;
	$y1  = 80;
	
	$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->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "B", 10);
	$this->Cell(10,4, "Shipping Address", 0, 0, "C");
	$this->SetXY( $r1 + ($r2-$r1)/2 -5 , $y1 + 5 );
	$this->SetFont( "", "", 9);
	$this->Cell(10,5,$mode, 0,0, "C");
}

// Expiry date
function addEcheance( $date )
{
	$r1  = 80;
	$r2  = $r1 + 40;
	$y1  = 80;
	$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, "DATE D'ECHEANCE", 0, 0, "C");
	$this->SetXY( $r1 + ($r2-$r1)/2 - 5 , $y1 + 5 );
	$this->SetFont( "helvetica", "", 10);
	$this->Cell(10,5,$date, 0,0, "C");
}

// VAT number
function addNumTVA($tva)
{
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "B", 10);
	$r1  = $this->w - 80;
	$r2  = $r1 + 70;
	$y1  = 80;
	$y2  = $y1+10;
	$mid = $y1 + (($y2-$y1) / 2);
	$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 1.5, 'D');
	$this->Line( $r1, $mid, $r2, $mid);
	$this->SetXY( $r1 + 16 , $y1+1 );
	$this->Cell(40, 4, "To", '', '', "C");
	$this->SetFont( "", "", 10);
	$this->SetXY( $r1 + 16 , $y1+5 );
	$this->Cell(40, 5, $tva, '', '', "C");
}



function addShipInst($term)
{
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "B", ;
	$length = $this->GetStringWidth( "Reference : " . $term );
	$r1  = 151;
	$r2  = $r1 + $length;
	$y1  = 29;
	$y2  = $y1+8;
	$this->SetXY( $r1 , $y1 );
	$this->Cell($length,4, "Reference : ");
}
function addShipInst1($term)
{
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	
	$length = $this->GetStringWidth( "Reference : " . $term );
	$r1  = 166;
	$r2  = $r1 + $length;
	$y1  = 29;
	$y2  = $y1+8;
	$this->SetXY( $r1 , $y1 );
	$this->SetFont( "", "", ;
	$this->Cell($length,4, "  " .$term);
}

function addpayterms($ref)
{
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "", 9);
	$length = $this->GetStringWidth( "Payment Terms : " . $ref );
	$r1  = 10;
	$r2  = $r1 + $length;
	$y1  = 238;
	$y2  = $y1+8;
	$this->SetXY( $r1 , $y1 );
	
	$this->Cell($length,4, "" . $ref);
}
function addpayterms1($ref)
{
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "B", ;
	$length = $this->GetStringWidth( "Payment");
	$r1  = 8;
	$r2  = $r1 + $length;
	$y1  = 236;
	$y2  = $y1+8;
	$this->SetXY( $r1 , $y1 );
	
	$this->Cell($length,4, "Payment Terms: ");
	$this->SetFont( "", "", ;
	
	
	
}

function addpayterm2( $adresse )
{
	$r1     = $this->w - 202;
	$r2     = $r1 + 34;
	$y1     = 240;
	//$this->Rect(10,86,87,30);
	$this->SetXY( $r1, $y1 );
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	//$this->SetFont( "", "B", ;
	//$this->Cell(10,5, "Bank Details:", 0, 0, "L");
	$this->SetFont( "", "", ;
	$this->SetXY( $r1, $y1+2);
	$this->MultiCell( 75, 4, $adresse);
}

function addCols( $tab )
{
	global $colonnes;
	
	$r1  = 9;
	$r2  = $this->w - ($r1 * 1.9) ;
	$y1  = 106;
	$y2  = $this->h - 75 - $y1;
	$this->SetXY( $r1, $y1 );
	
	$this->Rect( $r1, $y1, $r2, $y2, "D");
	$this->Line( $r1, $y1+6, $r1+$r2, $y1+7);
	$colX = $r1;
	$colonnes = $tab;
	while ( list( $lib, $pos ) = each ($tab) )
	{
		$this->SetXY( $colX, $y1+2 );
		$this->SetFont( "", "B", 7);
		$this->Cell( $pos, 2, $lib, 0, 0, "C");
		$colX += $pos;
		$this->SetFont( "", "", 7);
		$this->Line( $colX, $y1, $colX, $y1+$y2);
	}
}


function addLineFormat( $tab )
{
	global $format, $colonnes;
	
	while ( list( $lib, $pos ) = each ($colonnes) )
	{
		if ( isset( $tab["$lib"] ) )
			$format[ $lib ] = $tab["$lib"];
	}
}

function lineVert( $tab )
{
	global $colonnes;

	reset( $colonnes );
	$maxSize=0;
	while ( list( $lib, $pos ) = each ($colonnes) )
	{
		$texte = $tab[ $lib ];
		$longCell  = $pos -2;
		$size = $this->sizeOfText( $texte, $longCell );
		if ($size > $maxSize)
			$maxSize = $size;
	}
	return $maxSize;
}

// add a line to the invoice/estimate
/*    $ligne = array( "REFERENCE"    => $prod["ref"],
                      "DESIGNATION"  => $libelle,
                      "QUANTITE"     => sprintf( "%.2F", $prod["qte"]) ,
                      "P.U. HT"      => sprintf( "%.2F", $prod["px_unit"]),
                      "MONTANT H.T." => sprintf ( "%.2F", $prod["qte"] * $prod["px_unit"]) ,
                      "TVA"          => $prod["tva"] );
*/
function addLine( $ligne, $tab )
{
	global $colonnes, $format;

	$ordonnee     = 10;
	$maxSize      = $ligne;

	reset( $colonnes );
	while ( list( $lib, $pos ) = each ($colonnes) )
	{
		$longCell  = $pos -2;
		$texte     = $tab[ $lib ];
		$length    = $this->GetStringWidth( $texte );
		$tailleTexte = $this->sizeOfText( $texte, $length );
		$formText  = $format[ $lib ];
		$this->SetXY( $ordonnee, $ligne-1);
		$this->MultiCell( $longCell, 4 , $texte, 0, $formText);
		if ( $maxSize < ($this->GetY()  ) )
			$maxSize = $this->GetY() ;
		$ordonnee += $pos;
	}
	return ( $maxSize - $ligne );
}

function addTotalText($remarque)
{
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "B", 10);
	$length = $this->GetStringWidth( "");
	$r1  = 10;
	$r2  = $r1 + $length;
	$y1  = $this->h - 60;
	$y2  = $y1+5;
	$this->SetXY( $r1 , $y1 );
	$this->Cell($length,-18, $remarque);
}
function addReverseText($remarque)
{
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "B", ;
	$length = $this->GetStringWidth( "" );
	$r1  = 10;
	$r2  = $r1 + $length;
	$y1  = $this->h - 45.5;
	$y2  = $y1+5;
	$this->SetXY( $r1 , $y1 );
	$this->Cell($length, 2, $remarque);
}
function addRemarque($remarque)
{
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "", 7);
	$length = $this->GetStringWidth( "Remarque : " . $remarque );
	$r1  = 87;
	$r2  = $r1 + $length;
	$y1  = $this->h - 60;
	$y2  = $y1+5;
	$this->SetXY( $r1 , $y1 );
	$this->Cell($length,-18, $remarque);
}
function addTaxable($remarque)
{
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "", 7);
	$length = $this->GetStringWidth( "Remarque : " . $remarque );
	$r1  = 109;
	$r2  = $r1 + $length;
	$y1  = $this->h - 60;
	$y2  = $y1+5;
	$this->SetXY( $r1 , $y1 );
	$this->Cell($length,-18, $remarque);
}
function addSgst($remarque)
{
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "", 7);
	$length = $this->GetStringWidth( "Remarque : " . $remarque );
	$r1  = 138;
	$r2  = $r1 + $length;
	$y1  = $this->h - 60;
	$y2  = $y1+5;
	$this->SetXY( $r1 , $y1 );
	$this->Cell($length,-18, $remarque);
}
function addCgst($remarque)
{
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "", 7);
	$length = $this->GetStringWidth( "Remarque : " . $remarque );
	$r1  = 163;
	$r2  = $r1 + $length;
	$y1  = $this->h - 60;
	$y2  = $y1+5;
	$this->SetXY( $r1 , $y1 );
	$this->Cell($length,-18, $remarque);
}
function addIgst($remarque)
{
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "", 7);
	$length = $this->GetStringWidth( "Remarque : " . $remarque );
	$r1  = 190;
	$r2  = $r1 + $length;
	$y1  = $this->h - 60;
	$y2  = $y1+5;
	$this->SetXY( $r1 , $y1 );
	$this->Cell($length,-18, $remarque);
}


function addCadreTVAs()
{
	//$this->AddFont('OpenSans-Regular','','OpenSans-Regular.php');
	$this->SetFont( "", "B", ;
	$r1  = 10;
	$r2  = $r1 + 120;
	$y1  = $this->h - 40;
	$y2  = $y1+20;
	$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 0.5, 'D');
	$this->Line( $r1, $y1+4, $r2, $y1+4);
	$this->Line( $r1+5,  $y1+4, $r1+5, $y2); // avant BASES HT
	$this->Line( $r1+27, $y1, $r1+27, $y2);  // avant REMISE
	$this->Line( $r1+43, $y1, $r1+43, $y2);  // avant MT TVA
	$this->Line( $r1+63, $y1, $r1+63, $y2);  // avant % TVA
	$this->Line( $r1+75, $y1, $r1+75, $y2);  // avant PORT
	$this->Line( $r1+91, $y1, $r1+91, $y2);  // avant TOTAUX
	$this->SetXY( $r1+9, $y1);
	$this->Cell(10,4, "BASES HT");
	$this->SetX( $r1+29 );
	$this->Cell(10,4, "REMISE");
	$this->SetX( $r1+48 );
	$this->Cell(10,4, "MT TVA");
	$this->SetX( $r1+63 );
	$this->Cell(10,4, "% TVA");
	$this->SetX( $r1+78 );
	$this->Cell(10,4, "PORT");
	$this->SetX( $r1+100 );
	$this->Cell(10,4, "TOTAUX");
	$this->SetFont( "helvetica", "B", 6);
	$this->SetXY( $r1+93, $y2 - 8 );
	$this->Cell(6,0, "H.T.   :");
	$this->SetXY( $r1+93, $y2 - 3 );
	$this->Cell(6,0, "T.V.A. :");
}

function addCadreEurosFrancs($stotal,$tax,$frt)
{
	$r1  = $this->w - 128;
	$r2  = $r1 + 120;
	$y1  = $this->h - 61;
	$y2  = $y1+12;
	$mid = $y1 + ($y2 / 1);
	$this->RoundedRect($r1+15, $y1, ($r2 - $r1)-15, ($y2-$y1), 'D');
	$this->Line( $r1+80,  $y1, $r1+80, $y2); // avant EUROS
	//$this->Line( 8, $mid, 220-20, $mid);
	//$this->Line( $r1+20, $y1+4, $r2, $y1+4); // Sous Euros & Francs
	//$this->Line( $r1+38,  $y1, $r1+38, $y2); // Entre Euros & Francs
	//$this->SetFont( "Arial", "B", ;
	//$this->SetXY( $r1+22, $y1 );
	//$this->Cell(15,4, "EUROS", 0, 0, "C");
	//$this->SetFont( "Arial", "", ;
	////$this->SetXY( $r1+42, $y1 );
	//$this->Cell(15,4, "FRANCS", 0, 0, "C");
	
	$this->SetFont( "", "B", ;
	//$this->SetXY( $r1, $y1+1 );
	//$this->Cell(30, 4, "Total Invoice (In Figure)", 0, 0, "R");
	//$this->SetXY( $r1, $y1+6 );
	//$this->Cell(30,4, "Tax", 0, 0, "R");
	$this->SetXY( $r1, $y1+2 );
	//$this->Cell(63,8, "", 0, 0, "R");
	$this->Cell(63,8, "Total Invoice Value (In Figure) ", 0, 0, "R");
}


function addQty($qty)
{
	$this->SetFont('helvetica','',;
	$y = 261;
	$this->SetXY(104,266.4);
	//$this->Cell(15,3, sprintf("%0.2F", $params), '', '', 'R' );
	//$this->SetXY(114,271.4);
	//$this->Cell(15,4, sprintf("%0.2F", $tab_tva), '', '', 'R' );
    $total = $qty;

	$re  = $this->w - 35;
	
	$this->SetFont( "helvetica", "", ;
	$this->SetXY( $re, $y1+1 );
	$this->Cell( 40,-6, sprintf("%0.2F", $params), '', '', 'R');
	
	
}
function addTVAs( $params, $tab_tva, $invoice )
{
	$this->SetFont('helvetica','',;
	
	
	$y = 261;
	


	$this->SetXY(104,266.4);
	//$this->Cell(15,3, sprintf("%0.2F", $params), '', '', 'R' );
	//$this->SetXY(114,271.4);
	//$this->Cell(15,4, sprintf("%0.2F", $tab_tva), '', '', 'R' );
$total = $params + $tab_tva + $invoice;

	$re  = $this->w - 35;
	$rf  = $this->w - 29;
	$y1  = $this->h - 65;
	$this->SetFont( "helvetica", "B", ;
	$this->SetXY( $re, $y1+1 );
	//$this->Cell( 20,-6, sprintf("%0.2F", $params), '', '', 'R');
	//$this->SetXY( $re, $y1+3 );
	//$this->Cell( 20,0, sprintf("%0.2F", $tab_tva), '', '', 'R');
	//$this->SetXY( $re, $y1+7 );
	$this->Cell(20,18, sprintf("%0.2F", $total), '', '', 'R');

}

// add a watermark (temporary estimate, DUPLICATA...)
// call this method first
function temporaire( $texte )
{
	$this->SetFont('helvetica','B',50);
	$this->SetTextColor(203,203,203);
	$this->Rotate(45,55,190);
	$this->Text(55,190,$texte);
	$this->Rotate(0);
	$this->SetTextColor(0,0,0);
}




}
?>

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.