<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');

$formname = 'DELIVERY CHALLAN';
$maindb = 'salemain';
//$trandb = 'saletran';
$file = 'deliverychal_pdf.php';
$source = "";
$zcomp = $_SESSION["comp_" . $dbname];

$zdb = $_SESSION["zdbyear_" . $dbname];
$zroot = $_SESSION["zdir"];
mysqli_select_db($conn, $zdb);
$prbal = $_POST['prbal'];
$mht = 'height:20px;';
$admin = $_SESSION["admin_" . $dbname];
$vouchno = $_REQUEST["vouchno"];
$input = $_POST["input"];

$mainqry = mysqli_query($conn, "SELECT *, DATE_FORMAT(`vouchdt`, '%d-%m-%Y') AS vouchdt FROM `$maindb` WHERE `vouchno`='$vouchno'  ORDER BY `vouchno`") or die(mysqli_error($conn));
$getmdata = mysqli_fetch_array($mainqry);

$tranqry = mysqli_query($conn, "SELECT DATE_FORMAT(`delvdate`, '%d-%m-%Y') AS mydelvdt FROM `saletran` WHERE `vouchno`='$vouchno' AND delchal = '$input' order by srno")or die(mysqli_error($conn));
$tranfet = mysqli_fetch_array($tranqry);
if ($tranfet['mydelvdt'] == "00-00-0000") {
    $delvdate = $getmdata['vouchdt'];
}  else {
    $delvdate = $tranfet['mydelvdt'];
}

$cmpname = mysqli_query($conn, "SELECT * From $zroot.`company` where code ='$zcomp'")or die(mysqli_error($conn));
$getcmpname = mysqli_fetch_array($cmpname);

$logo = $getcmpname['logoimg'];

$getparty = mysqli_query($conn, "SELECT `accode`,`name`, `add1`, `add2`, `add3`, `city`, `pin`,`mobile` FROM `accmast` WHERE `accode`= '$getmdata[party]'") or die(mysqli_error($conn));
$lparty = mysqli_fetch_array($getparty);

$getsale = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` WHERE `accode`= '$getmdata[salesman]'") or die(mysqli_error($conn));
$lsale = mysqli_fetch_array($getsale);
$getarchitect = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` WHERE `accode`= '$getmdata[architect]'") or die(mysqli_error($conn));
$larchitect = mysqli_fetch_array($getarchitect);


// $ad1 = substr($lparty['address'],0,50) ;
// $ad2 = substr($lparty['address'],51,50) ;
// $ad3 = substr($lparty['address'],101,50) ;
//echo($ad1);
//echo($ad2);
//echo($ad3);
//die();
//if($getmdata['clientno']){
//    
//$clientno =  " ( " . $getmdata['clientno'] . " )";
//}
//if($lparty['name']){
//    
//$clientno =  " ( " . $lparty['name'] . " )";
//}
//if (isset($_POST["subpdf"])) {
//browse('idar');
//ini_set("session.auto_start", 0);
require("library/fpdf/fpdf.php");

class pdf extends fpdf {

    function Footer() {

//Position at 1.5 cm from bottom
        $this->SetY(-15);

//Arial italic 8
        $this->SetFont('Arial', 'I', 8);
//Page number
        $this->Cell(0, 10, 'Page ' . $this->PageNo() . '/{nb}', 0, 0, 'C');
    }

}

//browse('udar');

$pdf = new pdf('P', 'mm', 'A4');

$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 16);
$pdf->SetTextColor(0, 0, 0);
//$pdf->Rect(5, 5, 200, 120, 'D');
$pdf->Image('images/logo/halogo.jpg', 10, 1, 40, 44, 'JPG');
$ht = 5;
$pdf->SetFont('Arial', 'B', 16);
$pdf->Cell(45, $ht, "", 0, 0, 'C');
$pdf->Cell(145, $ht, "$getcmpname[compname]", 0, 0, 'L');
$pdf->Ln(10);

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(45, $ht, "", 0, 0, 'C');
$pdf->Cell(145, $ht, "$getcmpname[hoadd1] $getcmpname[hoadd2] $getcmpname[hoadd3] $getcmpname[hocity] - $getcmpname[hopin]", 0, 0, 'L');
$pdf->Ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(45, $ht, "", 0, 0, 'C');
$pdf->Cell(145, $ht, "+$getcmpname[htel] / $getcmpname[homob]", 0, 0, 'L');
$pdf->Ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(45, $ht, "", 0, 0, 'C');
$pdf->Cell(145, $ht, "$getcmpname[email]", 0, 0, 'L');
$pdf->Ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(45, $ht, "", 0, 0, 'C');
$pdf->Cell(145, $ht, "GSTNO - $getcmpname[gstno]", 0, 0, 'L');
$pdf->Ln(10);

$pdf->SetFillColor(207, 145, 69);
$pdf->Cell(190, 1, "", 0, 0, 'C', true);
$pdf->Ln();
$pdf->SetFillColor(255, 255, 255);

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(190, 7, "$formname", 0, 0, 'C');
$pdf->Ln(10);
$ht = 5;
//$pdf->Ln();
$pdf->SetFont('Arial', '', 9);
$pdf->SetTextColor(0, 0, 0);
$pdf->Cell(40, $ht, "M/S. (BILL TO)", 0, 0);

$pdf->SetFont('Arial', 'B', 10);
$pdf->SetTextColor(0, 0, 0);

if ($getmdata['ntprint'] == "") {
    $pdf->Cell(90, $ht, ": $lparty[name]", 0, 0);
} else {
    $pdf->Cell(90, $ht, ": $getmdata[ntprint]", 0, 0);
}
$pdf->SetFont('Arial', '', 9);
$pdf->Cell(32, $ht, "NO. ", 0, 0, "L");
$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(20, $ht, ": $getmdata[vouchno]", 0, 0, "L");
$pdf->Ln();

$pdf->SetFont('Arial', '', 9);
$pdf->SetTextColor(0, 0, 0);
$pdf->Cell(40, $ht, "ADDRESS (SHIP TO)", 0, 0);

$pdf->SetFont('Arial', 'B', 10);
$pdf->SetTextColor(0, 0, 0);
$pdf->Cell(90, $ht, ": $getmdata[add1]", 0, 0);
$pdf->SetFont('Arial', '', 9);
$pdf->Cell(32, $ht, "DATE ", 0, 0, "L");
$pdf->SetFont('Arial', 'B', 10);
$pdf->Cell(50, $ht, ": $delvdate", 0, 0, "L");
$pdf->Ln();

$pdf->SetFont('Arial', '', 9);
$pdf->SetTextColor(0, 0, 0);
$pdf->Cell(40, $ht, "", 0, 0);

$stradd2 = iconv('UTF-8', 'windows-1252', $getmdata['add2']);
$stradd3 = iconv('UTF-8', 'windows-1252', $getmdata['add3']);
$stradd4 = iconv('UTF-8', 'windows-1252', $getmdata['add4']);

if ($getmdata['add2'] != "") {
    $pdf->SetFont('Arial', 'B', 10);
    $pdf->SetTextColor(0, 0, 0);
    $pdf->Cell(90, $ht,"  $stradd2", 0, 0);
    $pdf->Ln();
} else {
    $pdf->SetFont('Arial', 'B', 9);
    $pdf->SetTextColor(0, 0, 0);
    $pdf->Cell(90, $ht, "", 0, 0);
    $pdf->Ln();
}
if ($getmdata['add3'] != '') {
    $pdf->SetFont('Arial', 'B', 10);
    $pdf->SetTextColor(0, 0, 0);
    $pdf->Cell(40, $ht, "", 0, 0);
    $pdf->Cell(150, $ht, "  $stradd3 $stradd4", 0, 0, "L");
    $pdf->Ln();
}

if ($getmdata['mobile'] != "") {
    $pdf->SetFont('Arial', '', 9);
    $pdf->SetTextColor(0, 0, 0);
    $pdf->Cell(40, $ht, "MOBILE ", 0, 0, "L");

    $pdf->SetFont('Arial', 'B', 10);
    $pdf->SetTextColor(0, 0, 0);
    $pdf->Cell(50, $ht, ": $getmdata[mobile]", 0, 0, "L");
    $pdf->Ln();
}


if ($lparty['city'] != '' || $lparty['pin']) {
    $pdf->SetFont('Arial', '', 9);
    $pdf->SetTextColor(0, 0, 0);
    $pdf->Cell(40, 2, "", 0, 0);

    $pdf->SetFont('Arial', 'B', 10);
    $pdf->SetTextColor(0, 0, 0);
    $pdf->Cell(150, 2, "  $lparty[city] $lparty[pin]", 0, 0);
    $pdf->Ln(6);
}

$pdf->SetFont('Arial', '', 12);
$pdf->SetTextColor(0, 0, 0);
mysqli_select_db($conn, $zdb);
$gcust = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `accode`='$getmdata[party]'") or die(mysqli_error($conn));
$cust = mysqli_fetch_array($gcust);

$pdf->SetDrawColor(206, 169, 98);
$pdf->SetFont('Arial', '', 9);
$pdf->SetDrawColor(0, 0, 0);

$pdf->SetFont('Arial', 'B', 10);
$pdf->Cell(130, $ht, "", 0, 0);
$pdf->SetFont('Arial', '', 9);
$pdf->SetTextColor(0, 0, 0);
$pdf->Cell(32, $ht, "SALES EXECUTIVE ", 0, 0, 'L');
$pdf->SetFont('Arial', 'B', 11);
$pdf->SetTextColor(0, 0, 0);
$pdf->Cell(35, $ht, ": $lsale[name]", 0, 0, "L");
$pdf->Ln(6);

$pdf->SetFont('Arial', 'B', 10);
$pdf->SetFillColor(143, 65, 49);
$cl = 6;
$pdf->SetTextColor(207, 145, 69);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('Arial', 'B', 10);
$pdf->Cell(15, $cl, 'SR. NO.', 1, 0, 'C', 1);
$pdf->Cell(14, $cl, 'QTY.', 1, 0, 'C', 1);
$pdf->Cell(17, $cl, 'UNIT', 1, 0, 'C', 1);
$pdf->Cell(98, $cl, 'DESCRIPTION', 1, 0, 'C', 1);
$pdf->Cell(25, $cl, 'SIZE', 1, 0, 'C', 1);
$pdf->Cell(24, $cl, 'SQ.FT.', 1, 0, 'C', 1);
$pdf->Ln();
$pdf->SetFont('Arial', '', 10);
$pdf->SetFillColor(255, 255, 255);
$pdf->SetTextColor(0, 0, 0);
$ctr = 1;
$ctab = 0;
$totqty = 0;
$gettran = mysqli_query($conn, "SELECT * FROM `saletran` WHERE `vouchno`='$vouchno' AND delchal = '$input' order by srno")or die(mysqli_error($conn));
while ($row = mysqli_fetch_array($gettran)) {
    if ($row['qty'] > 0) {
        $qty = $row['qty'];
    } else {
        $qty = "";
    }
    if ($row['rate'] > 0) {
        $rate = $row['rate'];
    } else {
        $rate = "";
    }
    if ($row['amount'] > 0) {
        $amount = $row['amount'];
    } else {
        $amount = "";
    }

    $unit = $row['unit'];
    $itemname = $row['itemname'];
    $size = $row['size'];
    $sqft = $row['sqft'];
//    $gstperc = $row['gstperc'];

    $pdf->Cell(15, $cl, "$ctr", 1, 0, 'C', 1);
    $pdf->SetFont('Arial', '', 9);
    $pdf->Cell(14, $cl, "$qty", 1, 0, 'C', 1);
    $pdf->SetFont('Arial', '', 10);
    $pdf->Cell(17, $cl, "$unit", 1, 0, 'C', 1);
    $pdf->Cell(98, $cl, "$itemname", 1, 0, 'C', 1);
    $pdf->Cell(25, $cl, "$size", 1, 0, 'C', 1);
    $pdf->Cell(24, $cl, "$sqft", 1, 0, 'C', 1);
    $pdf->Ln();
//    $pdf->Cell(25, $cl, "$rate", 1, 0, 'C', 1);
//    $pdf->Cell(25, $cl, "$amount", 1, 0, 'C', 1);
//    $pdf->Cell(20, $cl, "$gstperc", 1, 0, 'C', 1);

    $ctr++;
    $ctab = $ctab + 1;
    $totqty = $row['qty'] + $totqty;
    $totamt = $row['amount'] + $totamt;
    $totalsqft = $row['sqft'] + $totalsqft;
    $totsqft = number_format($totalsqft, 2);
}
if ($ctab < 12) {
    for ($i = $ctab; $i <= 12; $i++) {
        $ctab = $ctab + 1;
        $pdf->Cell(15, $cl, "", 1, 0, 'C', 1);
        $pdf->Cell(14, $cl, "", 1, 0, 'C', 1);
        $pdf->Cell(17, $cl, "", 1, 0, 'C', 1);
        $pdf->Cell(98, $cl, "", 1, 0, 'C', 1);
        $pdf->Cell(25, $cl, "", 1, 0, 'C', 1);
        $pdf->Cell(24, $cl, "", 1, 0, 'C', 1);
        $pdf->Ln();
    }
}
$tnetamt = number_format($totamt, 2);
$pdf->Cell(15, $cl, "", 'TLB', 0, 'L', 1);
$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(14, $cl, "$totqty", 'TLB', 0, 'R', 1);
$pdf->Cell(17, $cl, "", 'TLB', 0, 'R', 1);
$pdf->Cell(98, $cl, "", 'TLB', 0, 'R', 1);
$pdf->Cell(25, $cl, "", 'TLB', 0, 'R', 1);
$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(24, $cl, "$totsqft", '1', 0, 'R', 1);

$pdf->Ln();

$cl1 = 6;

$pdf->SetFont('Arial', 'B', 9);
$pdf->Cell(29, $cl1, "REMARKS", 1, 0, 'L', 1);
$pdf->Cell(164, $cl1, "$getmdata[rem1]", 1, 0, 'L', 1);
$pdf->Ln();
$pdf->Cell(29, $cl1, "", 1, 0, 'L', 1);
$pdf->Cell(164, $cl1, "$getmdata[rem2]", 1, 0, 'L', 1);
$pdf->Ln();
//$pdf->Ln();

$y_aqui = $pdf->Gety();
$pdf->Rect(10, $y_aqui, 193, 48, 'D');

// $pdf->SetFont('Arial', 'B', 10);
// $pdf->Cell(70, 7, "", 0, 0, 'C');
// $pdf->Cell(50, 7, "GSTIN : $getcmpname[gstno]", 0, 0, 'C');
// $pdf->Ln(6);

$pdf->SetTextColor(0, 0, 0);
$pdf->SetFillColor(143, 65, 49);
$cl = 7;

$pdf->SetFont('Arial', 'B', 8);
$pdf->Cell(193, 5, 'NOTES', 1, 0, 'L', 1);
$pdf->Ln();
$pdf->SetFillColor(255, 255, 255);
$pdf->SetFont('Arial', 'B', 6);
$pdf->Cell(193, $cl, '1. GOODS ONCE SOLD WILL NOT BE TAKEN BACK OR REPLACE.', 0, 0, 'L', 0);
$pdf->Ln(3);
$pdf->SetFont('Arial', 'B', 6);
$pdf->Cell(193, $cl, '2. OUR RESPONSIBILITY CEASES ON DELIVERY OF GOOODS.', 0, 0, 'L', 0);
$pdf->Ln(3);
$pdf->SetFont('Arial', 'B', 6);
$pdf->Cell(193, $cl, '3. GOODS DESCRIBED & THAT ALL DESCRIPTION ARE TRUE AND CORRECT.', 0, 0, 'L', 0);
$pdf->Ln(3);
$pdf->SetFont('Arial', 'B', 6);
$pdf->Cell(193, $cl, "4. GOODS ARE DISPATCHED AT OWNER'S RISK.", 0, 0, 'L', 0);
$pdf->Ln(8);
// $pdf->SetFont('Arial', 'B', 6);
// $pdf->Cell(193, $cl, '5. GOODS WILL BE DISPATCHED WITHIN 7 WORKING DAYS FROM THE DATE OF ORDER PLACED', 0, 0, 'L', 0);
// $pdf->Ln(3);
// $pdf->SetFont('Arial', 'B', 6);
// $pdf->Cell(193, $cl, "6. CHEQUE WILL BE IN THE NAME OF $getcmpname[pname] .", 0, 0, 'L', 0);
// $pdf->Ln(3);
// $pdf->SetFont('Arial', 'B', 6);
// $pdf->Cell(193, $cl, '7. THIS QUOTATION IS VALID FOR 7 DAYS.', 0, 0, 'L', 0);
// $pdf->Ln(3);
// $pdf->SetFont('Arial', 'B', 6);
// $pdf->Cell(193, $cl, '8. GOODS ONCE SOLD WILL NOT BE TAKEN BACK OR REPLACE.', 0, 0, 'L', 0);
// $pdf->Ln(3);
// $pdf->SetFont('Arial', 'B', 6);
// $pdf->Cell(193, $cl, '9. OUR RESPONSIBILITY CEASES ON DELIVERY OF GOODS.', 0, 0, 'L', 0);
// $pdf->Ln(3);
// $pdf->SetFont('Arial', 'B', 6);
// $pdf->Cell(193, $cl, "10.GOODS ARE DISPATCHED AT OWNER'S RISK", 0, 0, 'L', 0);
// $pdf->Ln(3);
// $pdf->SetFont('Arial', 'B', 6);
// $pdf->Cell(155., $cl, '11.SUBJECT TO MUMBAI JURISDICATION ONLY.', 0, 0, 'L', 0);
$pdf->Cell(150, $cl, "", 0, 0, 'R', 0);
$pdf->Cell(30, $cl, "RECEIVER'S SIGNATURE", 'T', 0, 'R', 0);
$pdf->Ln(9);

$y_aqui2 = $pdf->Gety();

//$pdf->Rect(10,$y_aqui2,100,20,'D');
//$pdf->SetTextColor(0, 0, 0);
//$pdf->SetFillColor(206, 169, 98);
//$pdf->SetFont('Arial', 'B', 8);
//$pdf->Cell(100, 5, 'BANK DETAILS', 1, 0, 'C', 1);
//$pdf->Ln();
//
// $pdf->SetFillColor(255, 255, 255);
if ($prbal == 1) {
    if ($getmdata["totbal"] != 0) {
        $pdf->SetTextColor(238, 75, 43);
        $pdf->SetFont('Arial', 'B', 11);
        $pdf->Cell(100, $cl, "BALANCE PENDING : $getmdata[totbal]", 0, 0, 'L', 0);
        $pdf->Ln(3);
    } else {
        $pdf->SetTextColor(0, 0, 0);
        $pdf->SetFont('Arial', 'B', 11);
        $pdf->Cell(100, $cl, "PAYMENT RECEIVED", 0, 0, 'L', 0);
        $pdf->Ln(3);
    }
}
$y_aqui2 = $pdf->Gety();

$nitco   = "images/nitco.jpg";
$kajaria = "images/kajaria.jpg";
$qutone  = "images/qutone.jpg";
$rak     = "images/rak.jpg";
$somany  = "images/somany.jpg";
$johnson = "images/johnson.jpg";
$kerakoll  = "images/kerakoll.jpg";
$agl  = "images/agl.jpg";
$kalinga  = "images/kalinga.jpg";
$lioli  = "images/lioli.jpg";
$nirali  = "images/nirali.jpg";
$orientbell  = "images/orientbell.jpg";
$simpolo  = "images/simpolo.jpg";
$sunheart  = "images/sunheart.jpeg";
$nexion  = "images/nexion.jpg";
$ispira  = "images/ispira.jpg";

$cellwd = 23.75;
$imgwd = 20;
$imght = 14;
$imght2 = 12;
$pdf->ln(20);
if (file_exists($nitco)) {
   $pdf->Cell($cellwd, $pdf->Image($nitco, $pdf->GetX(), $pdf->GetY() ,$imgwd, $imght),  '');
} else {
   $pdf->Cell($cellwd, $cl, "", 0, 0, 'C', 1);
}
if (file_exists($kajaria)) {
   $pdf->Cell($cellwd, $pdf->Image($kajaria, $pdf->GetX(), $pdf->GetY(),$imgwd, $imght),  '');
} else {
   $pdf->Cell($cellwd, $cl, "", 0, 0, 'C', 1);
}
if (file_exists($rak)) {
    $pdf->Cell($cellwd, $pdf->Image($rak, $pdf->GetX(), $pdf->GetY(),$imgwd, $imght),  '');
} else {
    $pdf->Cell($cellwd, $cl, "", 0, 0, 'C', 1);
}
if (file_exists($qutone)) {
   $pdf->Cell($cellwd, $pdf->Image($qutone, $pdf->GetX(), $pdf->GetY(),$imgwd, $imght),  '');
} else {
   $pdf->Cell($cellwd, $cl, "", 0, 0, 'C', 1);
}
if (file_exists($johnson)) {
    $pdf->Cell($cellwd, $pdf->Image($johnson, $pdf->GetX(), $pdf->GetY(),$imgwd, $imght),  '');
} else {
    $pdf->Cell($cellwd, $cl, "", 0, 0, 'C', 1);
}
if (file_exists($somany)) {
   $pdf->Cell($cellwd, $pdf->Image($somany, $pdf->GetX(), $pdf->GetY(),$imgwd, $imght),  '');
} else {
   $pdf->Cell($cellwd, $cl, "", 0, 0, 'C', 1);
}
if (file_exists($kerakoll)) {
   $pdf->Cell($cellwd, $pdf->Image($kerakoll, $pdf->GetX(), $pdf->GetY(),$imgwd, $imght),  '');
} else {
   $pdf->Cell($cellwd, $cl, "", 0, 0, 'C', 1);
}
if (file_exists($ispira)) {
    $pdf->Cell($cellwd, $pdf->Image($ispira, $pdf->GetX(), $pdf->GetY(),$imgwd, $imght),  '');
 } else {
    $pdf->Cell($cellwd, $cl, "", 0, 0, 'C', 1);
 }

$pdf->ln($imght+1);


if (file_exists($kalinga)) {
   $pdf->Cell($cellwd, $pdf->Image($kalinga, $pdf->GetX(), $pdf->GetY(),$imgwd, $imght),  '');
} else {
   $pdf->Cell($cellwd, $cl, "", 0, 0, 'C', 1);
}
if (file_exists($lioli)) {
   $pdf->Cell($cellwd, $pdf->Image($lioli, $pdf->GetX(), $pdf->GetY(),$imgwd, $imght),  '');
} else {
   $pdf->Cell($cellwd, $cl, "", 0, 0, 'C', 1);
}
if (file_exists($nirali)) {
   $pdf->Cell($cellwd, $pdf->Image($nirali, $pdf->GetX(), $pdf->GetY(),$imgwd, $imght),  '');
} else {
   $pdf->Cell($cellwd, $cl, "", 0, 0, 'C', 1);
}
if (file_exists($orientbell)) {
   $pdf->Cell($cellwd, $pdf->Image($orientbell, $pdf->GetX(), $pdf->GetY(),$imgwd, $imght),  '');
} else {
   $pdf->Cell($cellwd, $cl, "", 0, 0, 'C', 1);
}
if (file_exists($simpolo)) {
   $pdf->Cell($cellwd, $pdf->Image($simpolo, $pdf->GetX(), $pdf->GetY(),$imgwd, $imght),  '');
} else {
   $pdf->Cell($cellwd, $cl, "", 0, 0, 'C', 1);
}
if (file_exists($sunheart)) {
   $pdf->Cell($cellwd, $pdf->Image($sunheart, $pdf->GetX(), $pdf->GetY(),$imgwd, $imght),  '');
} else {
   $pdf->Cell($cellwd, $cl, "", 0, 0, 'C', 1);
}
if (file_exists($nexion)) {
   $pdf->Cell($cellwd, $pdf->Image($nexion, $pdf->GetX(), $pdf->GetY(),$imgwd, $imght2),  '');
} else {
   $pdf->Cell($cellwd, $cl, "", 0, 0, 'C', 1);
}
if (file_exists($agl)) {
    $pdf->Cell($cellwd, $pdf->Image($agl, $pdf->GetX(), $pdf->GetY(),$imgwd, $imght),  '');
 } else {
    $pdf->Cell($cellwd, $cl, "", 0, 0, 'C', 1);
 }
//$pdf->Cell(100, $cl, "ACCOUNT NAME : $getcmpname[acname]", 0, 0, 'L', 0);
//$pdf->Ln(3);
//$pdf->Cell(100, $cl, "ACCOUNT No. : $getcmpname[acno]", 0, 0, 'L', 0);
//$pdf->Ln(3);
//$pdf->Cell(100, $cl, "BRANCH : $getcmpname[branchname]", 0, 0, 'L', 0);
//$pdf->Ln();
//$pdf->Ln(20);
//$pdf->SetFont('Arial', '', 12);
//$pdf->Cell(130, 7, "____________________", 0, 0, 'L');
//$pdf->Cell(30, 7, "____________________", 0, 0, 'L');
//$pdf->Ln();
//$pdf->SetFont('Arial', '', 12);
//$pdf->Cell(125, 7, '   Authorised Signatory ', 0, 0, 'L');
//$pdf->Cell(30, 7, 'Received By/Account Holder ', 0, 0, 'L');
//$pdf->Line(10, 30, 200, 30);
//$pdf->Ln(5);
//ob_end_flush(); 
ob_end_clean();
//$pdf Output('filename.pdf','F'); 
$pdf->Output("$formname - $lparty[name]-" . $getmdata['vouchno'] . ".pdf", "I");
////}
?>