<?php

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

//$formname = 'Annexure 2 ';
$maindb = 'visamain';
$trandb = 'visatran';
$file = 'undertaking_pdf.php';
$formname = "Undertaking";
//$keyfld = "vouchno";
//$source = "CP";
$zdb = $_SESSION["zdbyear_" . $dbname];
$zroot = $_SESSION["zdir"];
mysqli_select_db($conn, $zdb);
$mht = 'height:20px;';

$admin = $_SESSION["admin_" . $dbname];
$myvouch = $_REQUEST["myvouch"];
$ppno = $_REQUEST["passport"];

$mainqry = mysqli_query($conn, "SELECT a.*, b.ladd1, b.sector, b.sponsor, b.sponsor2, b.visano, b.hijridate, b.purpvisit, DATE_FORMAT(a.vouchdt,  '%d-%m-%Y') AS mydt 
                                       FROM `$trandb` a, `$maindb` b 
                                       WHERE a.myvouch = '$myvouch' and a.passport = '$ppno' and a.myvouch = b.myvouch") or die(mysqli_error($conn));
$fetdata = mysqli_fetch_array($mainqry);

$nation = 'INDIAN';
$paxname = $fetdata['paxname'];

//$getcomp = mysqli_query($conn, "SELECT * FROM $zroot.`company` WHERE `code`= '1'")or die(mysqli_error($conn));
//$comp = mysqli_fetch_array($getcomp);
//$gettran = mysqli_query($conn, 
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->Ln(70);
$pdf->SetFont('Arial', '', 14);
$pdf->SetTextColor(0, 0, 0);
$pdf->Cell(10, 6, "", 0, 0, 'L');
$pdf->SetFont('Arial', 'B', 14);
$pdf->Cell(180, 6, "(UNDERTAKING)", 0, 0, 'C');

$pdf->Ln(20);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(30, 6, "", 0, 0, 'L');
$pdf->Cell(07, 6, "I,", 0, 0, 'L');
$pdf->Cell(90, 6, $paxname, 0, 0, 'L');
$pdf->Cell(27, 6, "Nationality  :", 0, 0, 'L');
$pdf->Cell(15, 6, $nation, 0, 0, 'L');

$pdf->Ln(10);
//$pdf->SetFont('Arial', '', 10);
$pdf->Cell(30, 6, "", 0, 0, 'L');
$pdf->Cell(40, 6, "Passport No. :", 0, 0, 'L');
$pdf->Cell(58, 6, $ppno, 0, 0, 'L');
$pdf->Cell(42, 6, "undertake   hereby", 0, 0, 'R');
$pdf->Ln(10);
$pdf->Cell(30, 6, "", 0, 0, 'L');
$pdf->Cell(170, 6, "that  I  am  aware  of  all  travel  and  entry   procedures   to  Saudi  Arabia", 0, 0, 'L');
$pdf->Ln(10);
$pdf->Cell(30, 6, "", 0, 0, 'L');
$pdf->Cell(170, 6, "related   to  Covid - 19   pandemic  including   the   mandatory   quarantine", 0, 0, 'L');
$pdf->Ln(10);
$pdf->Cell(30, 6, "", 0, 0, 'L');
$pdf->Cell(170, 6, "period   ( 14 days )    in     the    country     from     where    the    entry    to", 0, 0, 'L');
$pdf->Ln(10);
$pdf->Cell(30, 6, "", 0, 0, 'L');
$pdf->Cell(170, 6, "Kingdom   is   permitted.   Still   I   would   like   to   get   a   visa   and   will", 0, 0, 'L');
$pdf->Ln(10);
$pdf->Cell(30, 6, "", 0, 0, 'L');
$pdf->Cell(170, 6, "not   demand    any   claim   from   the   consulate   in   case   I   could  not", 0, 0, 'L');
$pdf->Ln(10);
$pdf->Cell(30, 6, "", 0, 0, 'L');
$pdf->Cell(170, 6, "manage    entry   to    Saudi  Arabia    during   the   visa    validity    period.", 0, 0, 'L');

$pdf->Ln(20);
$pdf->Cell(30, 6, "", 0, 0, 'L');
$pdf->Cell(170, 6, "Name:", 0, 0, 'L');
$pdf->Ln(20);
$pdf->Cell(30, 6, "", 0, 0, 'L');
$pdf->Cell(170, 6, "Signature:", 0, 0, 'L');


//$pdf->Cell(70, 6, "Sub. Dn. $getmdata[subdivsn]", 0, 0, 'L');
//$pdf->Cell(45, 6, "Circle $getmdata[circ]", 0, 0, 'L');
//
//$pdf->Ln(10);
//$pdf->Cell(90, 6, "1. Name of Scheme", 0, 0, 'L');
//$pdf->MultiCell(100, 6, "$getmdata[schemename]", '0', 'L', false);
//
//$pdf->Ln();
//$pdf->Cell(90, 6, "2. Name of Work", 0, 0, 'L');
//$pdf->MultiCell(100, 6, "$getmdata[workname]", '0', 'L', false);
//$pdf->Ln();
//$pdf->Cell(90, 6, "   & Estimate Sanction No.", 0, 0, 'L');
//$pdf->MultiCell(100, 6, "$getmdata[estsacnno]", '0', 'L', false);
//
//$pdf->Ln();
//$pdf->Cell(90, 6, "3. Amount of Sanctioned Estimate", 0, 0, 'L');
//$pdf->Cell(90, 6, "$getmdata[estsacnamt]", 0, 0, 'L');
//
//$pdf->Ln(10);
//$pdf->Cell(90, 6, "4. Actual Expenditure Estimate", 0, 0, 'L');
//$pdf->Cell(90, 6, "$getmdata[actlexpest]", 0, 0, 'L');
//
//$pdf->Ln();
//$pdf->Cell(200, 6, "    (Details Enclosed)", 0, 0, 'L');
//
//$pdf->Ln(10);
//$pdf->Cell(90, 6, "5. Savings (3 - 4)", 0, 0, 'L');
//$pdf->Cell(100, 6, "$getmdata[savings]", 0,  0, 'L');
//
//$pdf->Ln(10);
//$pdf->Cell(90, 6, "6. % of Savings (5 x 3  100)", 0, 0, 'L');
//$pdf->Cell(100, 6, "$getmdata[percsave]", 0,  0, 'L');
//
//$pdf->Ln(10);
//$pdf->Cell(90, 6, "7. Excess if any(4 - 3)", 0, 0, 'L');
//$pdf->Cell(100, 6, "$getmdata[excamt]", 0,  0, 'L');
//
//$pdf->Ln(10);
//$pdf->Cell(90, 6, "8. % of the Excess over Estimate", 0, 0, 'L');
//$pdf->Cell(100, 6, "$getmdata[excperc]", 0,  0, 'L');
//
//$pdf->Ln();
//$pdf->Cell(90, 6, "    (7/3 x 100)", 0, 0, 'L');
//$pdf->Cell(90, 6, "", 0, 0, 'L');
//
//$pdf->Ln(10);
//$pdf->Cell(90, 6, "9. Date of work Started", 0, 0, 'L');
//$pdf->Cell(100, 6, "$getmdata[startdate]", 0, 0, 'L');
//
//$pdf->Ln(10);
//$pdf->Cell(90, 6, "10. Date of work Completed", 0, 0, 'L');
//$pdf->Cell(100, 6, "$getmdata[compltdt]", 0, 0, 'L');
//
//$pdf->Ln(10);
//$pdf->Cell(90, 6, "11. Date of Assets commissioned put inuse", 0, 0, 'L');
//$pdf->Cell(100, 6, "$getmdata[assetdt]", 0, 0, 'L');
//
//$pdf->Ln(10);
//$pdf->Cell(90, 6, "12. Justification of excess savings", 0, 0, 'L');
//$pdf->Cell(100, 6, "$getmdata[excsave]", 0, 0, 'L');
//
//$pdf->Ln(10);
//$pdf->Cell(90, 6, "Prepared by", 0, 0, 'L');
//$pdf->Cell(90, 6, "", 0, 0, 'L');
//
//$pdf->Ln(10);
//$pdf->Cell(90, 6, "Checked by", 0, 0, 'L');
//$pdf->Cell(90, 6, "", 0, 0, 'L');
//
//$pdf->Ln(10);
//$pdf->Cell(90, 6, "Addl. Ex. Engr. Sub. Dn", 0, 0, 'L');
//$pdf->Cell(90, 6, "", 0, 0, 'L');
//
//$pdf->Ln(10);
//$pdf->Cell(90, 6, "Asset Card Prepared", 0, 0, 'L');
//$pdf->Cell(90, 6, "", 0, 0, 'L');
//
//$pdf->Ln(10);
//$pdf->Cell(90, 6, "Divisional Accountant (C.)", 0, 0, 'L');
//$pdf->Cell(90, 6, "", 0, 0, 'L');
//
//$pdf->Ln();
//$pdf->Cell(90, 6, "C.C.O. & M. Dn. Panvel (R.)", 0, 0, 'L');
//$pdf->Cell(90, 6, "", 0, 0, 'L');
//
//$pdf->Ln();




//$gettran = mysqli_query($conn, "SELECT * FROM `$trandb` WHERE `vouchno`='$getmdata[vouchno]' ORDER BY `srno`")or die(mysqli_error($conn));
//$ctab = 0;
//$ctn = 0;
//while ($tran = mysqli_fetch_array($gettran)) {
//    $ctn++;
//
//    $pdf->SetFont('Arial', '', 9);
//    $pdf->Cell(8, 6, "$tran[srno]", "LTR", 0, 'C');
////    $stlen1 = substr($tran[name], 0, 50);
////    $stlen2 = substr($tran[name], 50, 135);
//    $pdf->Cell(24, 6, "$tran[shopno]", "LTR", 0, 'C');
////    $pdf->Cell(89, 6, "$stlen1", "LTR", 0, 'L');
//    $pdf->Cell(30, 6, "$tran[cat]", "LTR", 0, 'C');
//    $pdf->Cell(24, 6, "$tran[type]", "LTR", 0, 'C');
//    $pdf->Cell(15, 6, "$tran[ph]", "LTR", 0, 'C');
//    $pdf->Cell(24, 6, "$tran[loadunit]", "LTR", 0, 'C');
////    $pdf->Cell(22, 6, "$tran[mobile]","LTR", 0, 'C');
//    $pdf->Cell(22, 6, "$tran[carparea]", "LTR", 0, 'C');
//    $pdf->Cell(22, 6, "$tran[totloadunit]", "LTR", 0, 'C');
//    $ctab++;
//    $pdf->Ln();
//    if ($ctab == 40) {
//        $pdf->Cell(183, 6, "", "T", 1, 'C');
////        continue;
////        break;
//    }
//    $ttotload = $ttotload + $tran['totloadunit'];
//    $tcarparea = $tcarparea + $tran['carparea'];
//}
//$pdf->SetFont('Arial', '', 10);
//$pdf->Cell(62, 6, "Total Connections", 1, 0, 'R');
//$pdf->Cell(24, 6, "$ctn", 1, 0, 'C');
//$pdf->Cell(39, 6, "Total Load", 1, 0, 'R');
//$pdf->Cell(22, 6, "$tcarparea", 1, 0, 'C');
//$pdf->Cell(22, 6, "$ttotload", 1, 0, 'C');
//    $pdf->Ln();
//    $pdf->Ln();
//    $pdf->Ln();
//    $pdf->Ln();
//

ob_end_clean();
$pdf->Output("Annexure I Normal-" . $getmdata['vouchno'] . ".pdf", "I");
?>
         
