<?php

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

$formname = 'CHALLAN / BILL';
$maindb = 'invmain';
$trandb = 'invtran';
$file = 'chal_pdf.php';
$source = "";
$zcomp = $_SESSION["comp_" . $dbname];

$zdb = $_SESSION["zdbyear_" . $dbname];
$zroot = $_SESSION["zdir"];
mysqli_select_db($conn, $zdb);

$mht = 'height:20px;';
$admin = $_SESSION["admin_" . $dbname];
$vouchno = $_REQUEST["vouchno"];

$result = mysqli_query($conn, "SELECT *, DATE_FORMAT(`vouchdt`, '%d-%m-%Y') as mydt FROM `$maindb` WHERE vouchno='$vouchno' ") or die(mysqli_error($conn));
$get = mysqli_fetch_array($result);
// if ($get['type'] == 'H') {
//     $type = "Hours";
// } else {
//     $type = "Lumsum";
// }

// $imgpath = $get['imgpath'];
// $getparty = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` WHERE `accode`= '$get[accode]'") or die(mysqli_error($conn));
// $lparty = mysqli_fetch_array($getparty);

// $getanch = mysqli_query($conn, "SELECT `name` FROM `port` WHERE `code`= '$get[anchor]'") or die(mysqli_error($conn));
// $fanch = mysqli_fetch_array($getanch);

// $getlaunch = mysqli_query($conn, "SELECT `name` FROM `launch` WHERE `code`= '$get[launch]'") or die(mysqli_error($conn));
// $flaunch = mysqli_fetch_array($getlaunch);


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

// mysqli_select_db($conn, $zdb);
// $gcust = mysqli_query($conn, "SELECT accode,name,gstno,add1,add2,add3,state,statecode,city,pin   FROM `accmast` WHERE `accode`='$getmdata[party]'") or die(mysqli_error($conn));
// $cust = mysqli_fetch_array($gcust);

require("library/fpdf/fpdf.php");

class pdf extends fpdf
{

    function Footer()
    {
        $this->SetY(-15);
        $this->SetFont('Arial', 'I', 8);

    }
}

//browse('udar');

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

$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetTitle('FAVOURITE');
$pdf->SetTextColor(0, 0, 0);

$pdf->SetFont('Arial', '', 9);
$pdf->SetTextColor(0, 0, 0);
$h = 7;

// $img = "Images/celllogo.png";
// $pdf->Image("$img", 171, 10, 7, 7, 'png');

$pdf->SetFont('Arial', 'B', 10);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFillColor(0, 0, 0);
$pdf->Cell(195, $h, "9821028139", 0, 0,'R');
$pdf->ln();

$pdf->SetFont('Arial', 'B', 10);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFillColor(0, 0, 0);
$pdf->Cell(195, $h, "9821575339", 0, 0,'R');
$pdf->ln();

$pdf->SetFont('Arial', 'B', 10);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFillColor(0, 0, 0);
$pdf->Cell(195, $h, "9820131712", 0, 0,'R');
$pdf->ln(5);

// $img = "images/FLS.jpg";
// $pdf->Image($img, 11, 18, 23, 23, 'jpg');

$pdf->SetFont('Arial', 'B', 32);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFillColor(0, 0, 0);
$pdf->Cell(190, $h, "Favourite Launch Services",0, 0,'C');
$pdf->ln(10);

$pdf->Line(3, 39, 205, 39);

$pdf->SetFont('Arial', 'B', 12);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFillColor(0, 0, 0);
$pdf->Cell(193, $h, "L a u n c h e s,  T u g' s  O w n e r s  &  O p e r a t o r s", 0, 0,'C');
$pdf->ln();

$pdf->Line(3, 46, 205, 46);

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(-9, $h, "", 0, 0);
$pdf->Cell(34, $h, "Operating Office : ", 0, 0);

$pdf->SetFont('Arial', '', 10);
$pdf->Cell(117, $h, "Mole Station, Inside Green Gate (BPS), Ballard Pier, MUMBAI - 4000038.", 0, 0);

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(15, $h, "Phone : ", 0, 0);

$pdf->SetFont('Arial', '', 10);
$pdf->Cell(15, $h, "2264 4827/ 9321577732", 0, 0);
$pdf->ln(5);

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(25, $h, "Head Office : ", 0, 0);

$pdf->SetFont('Arial', '', 10);
$pdf->Cell(34, $h, "122/124, Kokan Manzil,  5th Floor, Room No, 72, D'Lima Street, 
                    Dockyard Road, MUMBAI 400010", 0, 0);
$pdf->ln(5);
$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(40, $h, "", 0, 0);
$pdf->Cell(15, $h, "Phone : ", 0, 0);

$pdf->SetFont('Arial', '', 10);
$pdf->Cell(5, $h, "022-23754211 : favouritelaunch@yahoo.com", 0, 0);
$pdf->ln(12);

$pdf->SetFont('Arial', 'B', 11);
$pdf->SetFillColor(220, 220, 220);
$pdf->Cell(195, $h, "INVOICE OF SUPPLY", 'TLRB', 0, 'C', 1);
$pdf->SetFillColor(253, 254, 254);
$pdf->ln();

$pdf->SetFillColor(255, 255, 255);
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(195, $h, "OUR GSTIN No. 27AACFF93993D1Z9", 'TLRB', 0, 'C', 1);
$pdf->SetFillColor(253, 254, 254);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(97.5, $h, "Invoice No: 1256", 1, 0, 1);
$pdf->Cell(97.5, $h, "To,", 1, 0, 1);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(97.5, $h, "Invoice Date: 11/12/2024", 1, 0, 1);
$pdf->Cell(97.5, $h, "Name: ISS SHIPPING INDIA PVT LTD", 1, 0, 1);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(97.5, $h, "Vessal Name: VEGA COROLINE", 1, 0, 1);
$pdf->Cell(97.5, $h, "GSTIN No: 27AAACS6213Q1Z0", 1, 0, 1);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(97.5, $h, "JOB No: INBOM-00629A", 1, 0, 1);
$pdf->Cell(97.5, $h, "Address: 1st Floor, Unit no 101, Reliable Plaza,", 'TR', 0, 1);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(97.5, $h, "Reverse Charge: NO", 1, 0, 1);
$pdf->Cell(97.5, $h, "Thane Belapur Road, Near Reliable Tech park,", 'R', 0, 1);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(97.5, $h, "State code: 27", 1, 0, 1);
$pdf->SetFont('Arial', 'B', 10);
$pdf->Cell(97.5, $h, "PLOT NO K-10 AIROLI INDUSTRIAL AREA, Navi Mumbai", 'RB', 0, 1);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(97.5, $h, "State: MAHARASHTRA", 'TLR', 0, 1);
$pdf->Cell(97.5, $h, "Contact No: Mr. Kiran More- +91 8928586086", 1, 0, 1);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(97.5, $h, "", 'LRB', 0, 1);
$pdf->Cell(97.5, $h, "Email: mumbaivinv1@iss-shipping.com", 1, 0, 1);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->SetFillColor(220, 220, 220);
$pdf->Cell(25, $h, "Sr .No", 'TLR', 0, 'C', 1);
$pdf->Cell(85, $h, "Description of Service", 'TLRB', 0, 'C', 1);
$pdf->Cell(85, $h, "Amount", 'TLRB', 0, 'C', 1);
$pdf->SetFillColor(253, 254, 254);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->SetFillColor(220, 220, 220);
$pdf->Cell(25, $h, "", 'LRB', 0, 'C', 1);
$pdf->Cell(42.5, $h, "Date", 'TLRB', 0, 'C', 1);
$pdf->Cell(42.5, $h, "No.", 'TLRB', 0, 'C', 1);
$pdf->Cell(42.5, $h, "Rs", 'TLRB', 0, 'R', 1);
$pdf->Cell(42.5, $h, "P.", 'TLRB', 0, 'L', 1);
$pdf->SetFillColor(253, 254, 254);
$pdf->ln();

$data = [
    ["07/12/2024", "4909", "10125", "00"],
    ["06/12/2024", "4907", "6750", "00"],
    ["06/12/2024", "4908", "6750", "00"],
    ["07/12/2024", "4910", "9563", "00"],
    ["07/12/2024", "4911", "16488", "00"]
];

for ($sr = 0; $sr < count(value: $data); $sr++) {
    $pdf->SetFont('Arial', 'B', 11);
    
    $pdf->Cell(25,   $h, ($sr + 1) . ".", 'TLRB', 0, 'C', 1);
    $pdf->Cell(42.5, $h, $data[$sr][0], 'TLRB', 0, 'C', 1);
    $pdf->Cell(42.5, $h, $data[$sr][1], 'TLRB', 0, 'C', 1);
    $pdf->Cell(42.5, $h, $data[$sr][2], 'TLRB', 0, 'R', 1);
    $pdf->Cell(42.5, $h, $data[$sr][3], 'TLRB', 0, 'L', 1);
    $pdf->ln();
}

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(25, $h, "", 'TLRB', 0, 'C', 1);
$pdf->Cell(85, $h, "TOTAL", 'TLRB', 0, 'R', 1);
$pdf->Cell(42.5, $h, "49676", 'TLRB', 0, 'R', 1);
$pdf->Cell(42.5, $h, "00", 'TLRB', 0, 'L', 1);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->Cell(25, $h, "", 'TLRB', 0, 1);
$pdf->Cell(85, $h, "GST", 'TLRB', 0, 'R', 1);
$pdf->Cell(85, $h, "EXEMPTED Under SAC CODE 996522", 'TLRB', 0, 'C', 1);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->SetFillColor(220, 220, 220);
$pdf->Cell(48.75, $h, "", 'TLRB', 0, 1);
$pdf->Cell(61.2, $h, "GRAND TOTAL", 'TLRB', 0, 'R', 1);
$pdf->Cell(42.525, $h, "49676", 'TLRB', 0, 'R', 1);
$pdf->Cell(42.525, $h, "00", 'TLRB', 0, 'L', 1);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->SetFillColor(253, 254, 254);
$pdf->Cell(110, 10, "Bank Details :-", 'LR', 0, 1);
$pdf->Cell(85, 10, "For FAVOURITE LAUNCH SERVICES", 'LR  ', 0, 1);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->SetFillColor(253, 254, 254);
$pdf->Cell(110,5 , "Bank Name           : BANK OF INDIA", 'LR', 0, 1);
$pdf->Cell(85, 5, "", 'LR  ', 0, 1);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->SetFillColor(253, 254, 254);
$pdf->Cell(110,5, "Bank A/C No.        : 000320110000735", 'LR', 0, 1);
$pdf->Cell(85, 5, "", 'LR  ', 0, 1);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->SetFillColor(253, 254, 254);
$pdf->Cell(110,5, "Bank IFSC Code   : BKID0000003", 'LR', 0, 1);
$pdf->Cell(85, 5, "", 'LR  ', 0, 1);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 11);
$pdf->SetFillColor(253, 254, 254);
$pdf->Cell(110, 5, "Branch Name        : Ballard Estate, Mumbai-38", 'LRB', 0, 1);
$pdf->Cell(85,  5, "", 'LRB  ', 0, 1);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 9);
$pdf->Cell(195, $h, "NOTE:", 'TLR', 0, 1);
$pdf->ln();

$pdf->SetFont('Arial', 'B', 9);
$pdf->Cell(10,  5, "1)", 'L', 0, "R");
$pdf->Cell(3,  5, "", 0, 0, "R");
$pdf->Cell(182, 5, "THIS IS AN ORIGINALINVOICE COPY FOR THE SERVICES RENDERED.", "R", 0,  "L");
$pdf->ln();

// $pdf->Line(21, 249, 128, 249);

$pdf->SetFont('Arial', 'B', 9);
$pdf->Cell(10,  5, "2)", 'LB', 0, "R");
$pdf->Cell(3,  5, "", "B", 0, "R");
$pdf->Cell(182, 5, 'PAYMENT SHOULD BE DONE AGAINST "INVOICE OF SUPPLY" ONLY.','RB', 0, 0);
$pdf->ln();

$y_aqui = $pdf->Gety();
$y_aqui2 = $pdf->Gety();

ob_end_clean();
$pdf->Output("$formname - $lparty[name]-" . $getmdata['vouchno'] . ".pdf", "I");
