<?php

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

$formname = 'Sale';
$maindb = 'saleamt';
$file = 'saleamt_pdf.php';
// $formname = "Bank Payment";

$source = "CP";
$zdb = $_SESSION["zdbyear_" . $dbname];
$zroot = $_SESSION["zdir"];
mysqli_select_db($conn, $zdb);
$mht = 'height:20px;';

$admin = $_SESSION["admin_" . $dbname];
$vouchno = $_REQUEST["vouchno"];

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

$getcomp = mysqli_query($conn, "SELECT * FROM $zroot.`company` WHERE `code`= '1'")or die(mysqli_error($conn));
$comp = mysqli_fetch_array($getcomp);

$getparty = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `accode` = '$getmdata[party]'");
$party = mysqli_fetch_array($getparty);

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', '', 14);
// $pdf->SetTextColor(0, 0, 0);
// $pdf->SetFont('Arial', 'B', 14);
// $pdf->Cell(190, 6, "M/S STERLING POWERTECH", 0, 0, 'C');
// $pdf->Ln(5);
// $pdf->SetFont('Arial', 'B', 8);
// $pdf->Cell(190, 6, "Regd.office;1203,12th Floor,The Corporate Park,Plot no- 14&15, Sector-18, Vashi Navi Mumbai-400705", 0, 0, 'C');
// $pdf->Ln(4);
// $pdf->Cell(190, 6,"Tel.(022)49706497,Email-id;info@msterling.com ", 0, 0, 'C');
// $pdf->SetTextColor(0, 0, 0);
$pdf->Ln(15);

$pdf->Rect(7, 15, 195, 85, 'D');

$f = 14;
$l = 10;

$pdf->SetFont('Arial', 'B', 16);
$pdf->Cell(193, 6,"$comp[name]", 0, 0, 'C');
$pdf->Ln(15);

$pdf->SetFont('Arial', 'B', $f);
$pdf->Cell(10, 6,"Voucher No :", 0, 0);
$pdf->SetFont('Arial', '', $f);
$pdf->Cell(50, 6,"$getmdata[vouchno]", 0, 0,'C');
$pdf->SetFont('Arial', 'B', $f);
$pdf->Cell(100, 6,"Date :", 0, 0,'R');
$pdf->SetFont('Arial', '', $f);
$pdf->Cell(30, 6,"$getmdata[vouchdt]", 0, 0, 'R');
$pdf->Ln($l);

$pdf->SetFont('Arial', 'B', $f);
$pdf->Cell(10, 6,"Party :", 0, 0);
$pdf->SetFont('Arial', '', $f);
$pdf->Cell(95, 6,"$party[name]", 0, 0, 'R');
$pdf->Ln($l);

$pdf->SetFont('Arial', 'B', $f);
$pdf->Cell(15, 6,"Invoice No :", 0, 0);
$pdf->SetFont('Arial', '', $f);
$pdf->Cell(30, 6,"$getmdata[recpno]", 0, 0, 'R');
$pdf->Ln($l);

$pdf->SetFont('Arial', 'B', $f);
$pdf->Cell(16, 6,"Amount :", 0, 0);
$pdf->SetFont('Arial', '', $f);
$pdf->Cell(30, 6,"$getmdata[amount]", 0, 0, 'R');
$pdf->Ln($l);

$pdf->SetFont('Arial', 'B', $f);
$pdf->Cell(41, 6,"Remark :", 0, 0);
$pdf->SetFont('Arial', '', $f);
$pdf->Cell(30, 6,"$getmdata[remark1]", 0, 0, 'R');
$pdf->Cell(50, 6,"$getmdata[remark2]", 0, 0, 'R');
$pdf->Ln();



ob_end_clean();
$pdf->Output("Bank Payment-".$getmdata['vouchno'].".pdf", "I");
//}
?>
         
