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

$zdb = $_SESSION["zdbyear_" . $dbname];
$formname = "Salary Register";
mysqli_select_db($conn, $zdb);

$cond = "";
$ccond = "";
$cocond = "";
$rtit = "";
if (!empty($_POST["cmbemp"])) {
    $party = trim($_POST["cmbemp"]);
    $ccond = "AND `accode`='$party'";
    $rtit = "Single Employee";
}

$year = $_POST["year"];

if (!empty($_POST["cmbdept"])) {
    $sup = trim($_POST["cmbdept"]);
    $cocond = "AND deptcode='$sup'";
    $getdept = mysqli_query($conn, "SELECT * FROM `dept` WHERE code='$_POST[cmbdept]'") or die(mysqli_error($conn));
    $dept = mysqli_fetch_array($getdept);
    $rtit = "<b>Department Wise : " . $dept["name"] . "</b>";
}



$monno = $_POST["month"];
// browse($monno);
// browse($year);
$get = mysqli_query($conn, "SELECT *  FROM `payproc` WHERE monthno='$monno' and yearno = '$year' $ccond $cocond ORDER BY empname") or die(mysqli_error($conn));

$get2 = mysqli_query($conn, "SELECT *, SUM(salary)as totsalary, SUM(basic)as totbasic, SUM(convey)as totconvey, SUM(trav)as tottrav,
                        SUM(otamt)as tototamt, SUM(miscamt)as totmiscamt, SUM(monsalary)as totmonsal, SUM(loan)as totloan,sum(sunsal) as sunsal,
                        SUM(advance)as totadvance, SUM(miscdedn)as totmiscdedn, SUM(total_ded)as totdedn, SUM(net_Sal)as totnet FROM `payproc`
                        WHERE monthno='$monno' and yearno = '$year'  $ccond $cond $cocond ORDER BY empname") or die(mysqli_error($conn));

$getno = mysqli_num_rows($get);

if (isset($_POST["view"])) {

    include("includes/linkshead.php");
    ?>

    <style>
        @media print
        {    
            .no-print, .no-print *
            {
                display: none !important;
            }
        }
        .th1{
            background-color: #037D95;            
            /*background-color: #00AAFC;*/           
        }
        .th2{
            background-color: #88D8BF;            
        }

    </style>
    </head>



    </head>
    <body>
        <div class="container" style="width:90%">
            <?php require("includes/head_rep.php"); ?>
            <div class="row1">
                <table style="width:100%;background: white;" class="table table-condensed table-hover table-striped table-bordered">
                    <thead class="mySearchTr">
                        <tr id="font">
                            <th style="text-align:left;width:5%"><b>Sr.</b></th>
                            <th style="text-align:left;width:15%"><b>Employee Name</b></th>
                            <!-- <th style="text-align:right;width:5%" ><b>Basic</b></th>
                            <th style="text-align:right;width:5%" ><b>Sunday</b></th>
                            <th style="text-align:right;width:5%" ><b>DA</b></th>
                            <th style="text-align:right;width:5%" ><b>HRA</b></th>
                            <th style="text-align:right;width:5%" ><b>TA</b></th>
                            <th style="text-align:right;width:5%" width="4"><b>OA</b></th> -->
                            <th style="text-align:right;width:6%" ><b>Monthly Salary</b></th>
                            <!-- <th style="text-align:right;width:6%" ><b>Prov. Fund</b></th>
                            <th style="text-align:right;width:5%" ><b>Prof. Tax</b></th> -->
                            <th style="text-align:right;width:5%" ><b>Loan</b></th>
                            <th style="text-align:right;width:5%" ><b>Advance</b></th>
                            <!-- <th style="text-align:right;width:5%" ><b>Food</b></th>
                            <th style="text-align:right;width:5%" ><b>ESIC</b></th> -->
                            <th style="text-align:right;width:8%" ><b>Total Deduction</b></th>
                            <th style="text-align:right;width:7%" ><b>Net Salary</b></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $ctr = 0;
                        $totbasic = $totfood = $totsunsal = $totda = $tothra = $totta = $totoa = $totsal = $totpfund = $totproftax = $totloan = $totadv = $totesic = $totded = $totnetsal = 0;

                        while ($row = mysqli_fetch_assoc($get)) {
//                        mysqli_select_db($conn, $zdb);
                            $getname = mysqli_query($conn, "SELECT * FROM `accmast` WHERE accode=$row[accode] ORDER BY accode") or die(mysqli_error($conn));
                            $party = mysqli_fetch_array($getname);
                            $ctr++;
                            echo "<tr>";
                            echo "<th style='color:#5D5F63; text-align:left;'   width='5'>$ctr</th>";
                            echo "<th style='color:#5D5F63; text-align:left;'   width='80'>$party[name]</th>";
                            // echo "<th style='color:#5D5F63; text-align:right;'  width='6'>$row[basic]</th>";
                            // echo "<th style='color:#5D5F63; text-align:right;'  width='6'>$row[sunsal]</th>";
                            // echo "<th style='color:#5D5F63; text-align:right;'  width='6'>$row[da]</th>";
                            // echo "<th style='color:#5D5F63; text-align:right;'  width='6'>$row[hra]</th>";
                            // echo "<th style='color:#5D5F63; text-align:right;'  width='6'>$row[ta]</th>";
                            // echo "<th style='color:#5D5F63; text-align:right;'  width='4'>$row[oa]</th>";
                            echo "<th style='color:#5D5F63; text-align:right;'  width='6'>$row[salary]</th>";
                            // echo "<th style='color:#5D5F63; text-align:right;'  width='6'>$row[provfund]</th>";
                            // echo "<th style='color:#5D5F63; text-align:right;'  width='6'>$row[proftax]</th>";
                            echo "<th style='color:#5D5F63; text-align:right;'  width='6'>$row[loan]</th>";
                            echo "<th style='color:#5D5F63; text-align:right;'  width='6'>$row[advance]</th>";
                            // echo "<th style='color:#5D5F63; text-align:right;'  width='6'>$row[food]</th>";
                            // echo "<th style='color:#5D5F63; text-align:right;'  width='6'>$row[esic]</th>";
                            echo "<th style='color:#5D5F63; text-align:right;'  width='6'>$row[total_ded]</th>";
                            echo "<th style='color:#5D5F63; text-align:right;'  width='6'>$row[net_sal]</th>";
                            echo "</tr>";

                            $totbasic = $totbasic + $row['basic'];
                            $totsunsal = $totsunsal + $row['sunsal'];
                            $totda = $totda + $row['da'];
                            $tothra = $tothra + $row['hra'];
                            $totta = $totta + $row['ta'];
                            $totoa = $totoa + $row['oa'];
                            $totsal = $totsal + $row['salary'];
                            $totpfund = $totpfund + $row['provfund'];
                            $totproftax = $totproftax + $row['proftax'];
                            $totloan = $totloan + $row['loan'];
                            $totadv = $totadv + $row['advance'];
                            $totesic = $totesic + $row['esic'];
                            $totded = $totded + $row['total_ded'];
                            $totfood = $totfood + $row['food'];
                            $totnetsal = $totnetsal + $row['net_sal'];
                        }
                        
                        $row2 = mysqli_fetch_array($get2);
                        echo "<tr>";
                        echo "<th style='text-align:right;'></th>";
                        echo "<th style='text-align:right;  color:red'  valign='top' scope='col' width='80'>Total</th>";
                        // echo "<th style='text-align:right; color:red'>$totbasic</th>";
                        // echo "<th style='text-align:right; color:red'>$totsunsal</th>";
                        // echo "<th style='text-align:right; color:red'>$totda</th>";
                        // echo "<th style='text-align:right; color:red'>$tothra</th>";
                        // echo "<th style='text-align:right; color:red'>$totta</th>";
                        // echo "<th style='text-align:right; color:red'>$totoa</th>";
                        echo "<th style='text-align:right; color:red'>$totsal</th>";
                        // echo "<th style='text-align:right; color:red'>$totpfund</th>";
                        // echo "<th style='text-align:right; color:red'>$totproftax</th>";
                        echo "<th style='text-align:right; color:red'>$totloan</th>";
                        echo "<th style='text-align:right; color:red'>$totadv</th>";
                        // echo "<th style='text-align:right; color:red'>$totfood</th>";
                        // echo "<th style='text-align:right; color:red'>$totesic</th>";
                        echo "<th style='text-align:right; color:red'>$totded</th>";
                        echo "<th style='text-align:right; color:red'>$totnetsal</th>";
                        echo "</tr>";
                        ?>


                    </tbody>
                </table>
            </div>
    </body>
    </html>

    <?php
}
if (isset($_POST["excel"])) {
    $contents .= "Sr.,Employee Name,Basic,Sunday,DA,HRA,TA,OA,Toatl Salary,Prov. Fund,Prof. Tax,Loan,Advance,Food,ESIC,Total Deduction,Net Salary\n";
   
                        $ctr = 0;
                        $totbasic = $totfood = $totsunsal = $totda = $tothra = $totta = $totoa = $totsal = $totpfund = $totproftax = $totloan = $totadv = $totesic = $totded = $totnetsal = 0;

                        while ($row = mysqli_fetch_assoc($get)) {
//                        mysqli_select_db($conn, $zdb);
                            $getname = mysqli_query($conn, "SELECT * FROM `accmast` WHERE accode=$row[accode] ORDER BY accode") or die(mysqli_error($conn));
                            $party = mysqli_fetch_array($getname);
                            $ctr++;
                            $contents .= "$ctr" . ",";
                            $contents .= "$party[name]" . ",";
                            $contents .= "$row[basic]" . ",";
                            $contents .= "$row[sunsal]" . ",";
                            $contents .= "$row[da]" . ",";
                            $contents .= "$row[hra]" . ",";
                            $contents .= "$row[ta]" . ",";
                            $contents .= "$row[oa]" . ",";
                            $contents .= "$row[salary]" . ",";
                            $contents .= "$row[provfund]" . ",";
                            $contents .= "$row[proftax]" . ",";
                            $contents .= "$row[loan]" . ",";
                            $contents .= "$row[advance]" . ",";
                            $contents .= "$row[food]" . ",";
                            $contents .= "$row[esic]" . ",";
                            $contents .= "$row[total_ded]" . ",";
                            $contents .= "$row[net_sal]" . "\n";

                            $totbasic = $totbasic + $row['basic'];
                            $totsunsal = $totda + $row['sunsal'];
                            $totda = $totda + $row['da'];
                            $tothra = $tothra + $row['hra'];
                            $totta = $totta + $row['ta'];
                            $totoa = $totoa + $row['oa'];
                            $totsal = $totsal + $row['salary'];
                            $totpfund = $totpfund + $row['provfund'];
                            $totproftax = $totproftax + $row['proftax'];
                            $totloan = $totloan + $row['loan'];
                            $totadv = $totadv + $row['advance'];
                            $totesic = $totesic + $row['esic'];
                            $totded = $totded + $row['total_ded'];
                            $totfood = $totfood + $row['food'];
                            $totnetsal = $totnetsal + $row['net_sal'];
                        }
//                        echo "
//                        <tr>
//                          <td colspan='15'>
//                              <hr style='border-top: 1px solid #039;'/>
//                          </td>
//                       </tr>";
                        $row2 = mysqli_fetch_array($get2);

                        $contents .= "" . ",";
                        $contents .= "Total" . ",";
                        $contents .= "$totbasic" . ",";
                        $contents .= "$totsunsal" . ",";
                        $contents .= "$totda" . ",";
                        $contents .= "$tothra" . ",";
                        $contents .= "$totta" . ",";
                        $contents .= "$totoa" . ",";
                        $contents .= "$totsal" . ",";
                        $contents .= "$totpfund" . ",";
                        $contents .= "$totproftax" . ",";
                        $contents .= "$totloan" . ",";
                        $contents .= "$totadv" . ",";
                        $contents .= "$totfood" . ",";
                        $contents .= "$totesic" . ",";
                        $contents .= "$totded" . ",";
                        $contents .= "$totnetsal" . "\n";


    if ($_POST["dtype"] == 1) {
        header("Content-Disposition: attachment; filename=$formname" . "_Summary" . date('d-m-Y') . ".csv");
        print $contents;
    } else {
        header("Content-Disposition: attachment; filename=$formname" . "_Detail" . date('d-m-Y') . ".csv");
        print $contents;
    }
}
//if (isset($_POST["subpdf"])) {
//
//    $cond = "";
//    $ccond = "";
//    $cocond = "";
//    $rtit = "";
//
//
//    if (!empty($_POST["cmbemp"])) {
//        $party = trim($_POST["cmbemp"]);
//        $ccond = "AND `accode`='$party'";
//        $rtit = "Single Employee";
//    }
//
//
//
//
//    if (!empty($_POST["cmbdept"])) {
//        $sup = trim($_POST["cmbdept"]);
//        $cocond = "AND dept='$sup'";
//        $getdept = mysqli_query($conn, "SELECT * FROM `dept` WHERE code='$_POST[cmbdept]'") or die(mysqli_error($conn));
//        $dept = mysqli_fetch_array($getdept);
//        $rtit = "<b>Department Wise : " . $dept["name"] . "</b>";
//    }
//
//
//
//    $monno = $_POST["month"];
//
//    $get = mysqli_query($conn, "SELECT *  FROM `payproc` WHERE monthno='$monno' $ccond $cond $cocond ORDER BY accode") or die(mysqli_error($conn));
//
//    $get2 = mysqli_query($conn, "SELECT *, SUM(salary)as totsalary, SUM(basic)as totbasic, SUM(convey)as totconvey, SUM(trav)as tottrav,
//                        SUM(otamt)as tototamt, SUM(miscamt)as totmiscamt, SUM(monsalary)as totmonsal, SUM(loan)as totloan,
//                        SUM(advance)as totadvance, SUM(miscdedn)as totmiscdedn, SUM(total_ded)as totdedn, SUM(net_Sal)as totnet FROM `payproc` WHERE monthno='$monno' $ccond $cond $cocond ORDER BY accode") or die(mysqli_error($conn));
//
//
//
//    $getno = mysqli_num_rows($get);
//    require("MyScript/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');
//        }
//
//    }
//
//    $pdf = new pdf('L', 'mm', 'A4');
//
//    $pdf->AliasNbPages();
//
//    $pdf->AddPage();
////    include(include/head_rep_pdf2.php"");
//    $pdf->SetFont('Arial', '', 18);
//    $pdf->Cell(100, 7, "$comp[compname]", 0, 'L');
//    $pdf->Ln();
//    $pdf->SetFont('Arial', '', 9);
////    $pdf->Cell(100, 7, "OCEAN HOUSE, RAJENDRA GURU NAGAR, NEAR NEW NERAL POLICE STATION NERAL DIST-RAIGAD", 0, 'L');
//    $address = str_replace('       ', ' ', $comp[add1] . $comp[add2] . $comp[add3]);
//    $pdf->Cell(100, 7, $address, 0, 'L');
//    $pdf->Ln();
//    $pdf->SetFont('Arial', 'I', 10);
//    $pdf->SetTextColor(000, 000, 000);
//    $pdf->SetFillColor(249, 244, 245);
//
//    $pdf->Cell(200, 7, "Print - " . $formname, 0, 'L');
//    $pdf->Cell(0, 7, "Report Date - " . Date("d-m-y"), 0, 'L');
//    $pdf->Ln();
//    $pdf->SetFont('Arial', '', 10);
//    $pdf->SetTextColor(000, 000, 000);
//    $pdf->Cell(50, 10, 'From Date-' . $fdate, 0);
//    $pdf->SetFont('Arial', '', 10);
//    $pdf->SetTextColor(000, 000, 000);
//    $pdf->Cell(50, 10, 'To Date-' . $tdate, 0);
//    $pdf->Ln();
//    $pdf->SetFont('Arial', '', 10);
//    $pdf->SetTextColor(255, 255, 255);
//    $pdf->SetFillColor(3, 125, 149);
//    $pdf->Cell(30, 7, "Employee Name", 1, 0, '', 1);
//    $pdf->Cell(25, 7, "Salary", 1, 0, '', 1);
//    $pdf->Cell(25, 7, "Basic", 1, 0, '', 1);
//    $pdf->Cell(18, 7, "Convey", 1, 0, '', 1);
//    $pdf->Cell(18, 7, "Travel", 1, 0, '', 1);
//    $pdf->Cell(18, 7, "O.T", 1, 0, '', 1);
//    $pdf->Cell(18, 7, "Bonus", 1, 0, '', 1);
//    $pdf->Cell(20, 7, "Gross", 1, 0, '', 1);
//    $pdf->Cell(20, 7, "Loan", 1, 0, '', 1);
//    $pdf->Cell(20, 7, "Advance", 1, 0, '', 1);
//    $pdf->Cell(21, 7, "Others", 1, 0, '', 1);
//    $pdf->Cell(26, 7, "Total Dedn", 1, 0, '', 1);
//    $pdf->Cell(27, 7, "Net Salary", 1, 0, '', 1);
//    $pdf->SetFont('Arial', '', 1, 0);
//
//    $pdf->SetTextColor(0, 0, 0);
//    $pdf->Ln();
//
//    $ctr = 0;
//    while ($row = mysqli_fetch_assoc($get)) {
//        mysqli_select_db($conn, $zdb);
//        $getname = mysqli_query($conn, "SELECT * FROM `accmast` WHERE accode=$row[accode] ORDER BY accode") or die(mysqli_error($conn));
//        $party = mysqli_fetch_array($getname);
//
//        $pdf->SetFont('Arial', '', 10);
//        $pdf->Cell(30, 7, "$party[name]", 1);
//        $pdf->Cell(25, 7, "$row[salary]", 1);
//        $pdf->Cell(25, 7, "$row[basic]", 1);
//        $pdf->Cell(18, 7, "$row[convey]", 1);
//        $pdf->Cell(18, 7, "$row[trav]", 1);
//        $pdf->Cell(18, 7, "$row[otamt]", 1);
//        $pdf->Cell(18, 7, "$row[miscamt]", 1);
//        $pdf->Cell(20, 7, "$row[monsalary]", 1);
//        $pdf->Cell(20, 7, "$row[loan]", 1);
//        $pdf->Cell(20, 7, "$row[advance]", 1);
//        $pdf->Cell(21, 7, "$row[miscdedn]", 1);
//        $pdf->Cell(26, 7, "$row[total_ded]", 1);
//        $pdf->Cell(27, 7, "$row[net_sal]", 1);
//        $pdf->Ln();
//        $ctr++;
//    }
//
//
//
//    $row2 = mysqli_fetch_array($get2);
//    $pdf->SetFont('Arial', '', 10);
//    $pdf->Cell(30, 7, "Total", 1);
//    $pdf->Cell(25, 7, "$row2[totsalary]", 1);
//    $pdf->Cell(25, 7, "$row2[totbasic]", 1);
//    $pdf->Cell(18, 7, "$row2[totconvey]", 1);
//    $pdf->Cell(18, 7, "$row2[tottrav]", 1);
//    $pdf->Cell(18, 7, "$row2[tototamt]", 1);
//    $pdf->Cell(18, 7, "$row2[totmiscamt]", 1);
//    $pdf->Cell(20, 7, "$row2[totmonsal]", 1);
//    $pdf->Cell(20, 7, "$row2[totloan]", 1);
//    $pdf->Cell(20, 7, "$row2[totadvance]", 1);
//    $pdf->Cell(21, 7, "$row2[totmiscdedn]", 1);
//    $pdf->Cell(26, 7, "$row2[totdedn]", 1);
//    $pdf->Cell(27, 7, "$row2[totnet]", 1);
//
//    $pdf->Ln();
//    $ctr++;
//
//
//
//
//    $pdf->Output("Salary Register.pdf", "D");
//}
//


if (isset($_POST["subpdf"])) {

    $cond = "";
    $ccond = "";
    $cocond = "";
    $rtit = "";


    if (!empty($_POST["cmbemp"])) {
        $party = trim($_POST["cmbemp"]);
        $ccond = "AND `accode`='$party'";
        $rtit = "Single Employee";
    }




    if (!empty($_POST["cmbdept"])) {
        $sup = trim($_POST["cmbdept"]);
        $cocond = "AND dept='$sup'";
        $getdept = mysqli_query($conn, "SELECT * FROM `dept` WHERE code='$_POST[cmbdept]'") or die(mysqli_error($conn));
        $dept = mysqli_fetch_array($getdept);
        $rtit = "<b>Department Wise : " . $dept["name"] . "</b>";
    }



    $monno = $_POST["month"];

    $get = mysqli_query($conn, "SELECT *  FROM `payproc` WHERE monthno='$monno' $ccond $cond $cocond ORDER BY accode") or die(mysqli_error($conn));

    $get2 = mysqli_query($conn, "SELECT *, SUM(salary)as totsalary, SUM(basic)as totbasic, SUM(convey)as totconvey, SUM(trav)as tottrav,
                        SUM(otamt)as tototamt, SUM(miscamt)as totmiscamt, SUM(monsalary)as totmonsal, SUM(loan)as totloan,
                        SUM(advance)as totadvance, SUM(miscdedn)as totmiscdedn, SUM(total_ded)as totdedn, SUM(net_Sal)as totnet FROM `payproc` WHERE monthno='$monno' $ccond $cond $cocond ORDER BY accode") or die(mysqli_error($conn));



    $getno = mysqli_num_rows($get);
    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');
        }

    }

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

    $pdf->AliasNbPages();

    $pdf->AddPage();
//    include(include/head_rep_pdf2.php"");
    $pdf->SetFont('Arial', '', 18);
    $pdf->Cell(100, 7, "$comp[compname]", 0, 'L');
    $pdf->Ln();
    $pdf->SetFont('Arial', '', 9);
    $pdf->Cell(100, 7, "OCEAN HOUSE, RAJENDRA GURU NAGAR, NEAR NEW NERAL POLICE STATION NERAL DIST-RAIGAD", 0, 'L');
    $address = str_replace('       ', ' ', $comp[add1] . $comp[add2] . $comp[add3]);
    $pdf->Cell(100, 7, $address, 0, 'L');
    $pdf->Ln();
    $pdf->SetFont('Arial', 'I', 10);
    $pdf->SetTextColor(000, 000, 000);
    $pdf->SetFillColor(249, 244, 245);

    $pdf->Cell(200, 7, "Print - " . $formname, 0, 'L');
    $pdf->Cell(0, 7, "Report Date - " . Date("d-m-y"), 0, 'L');
    $pdf->Ln();
    $pdf->SetFont('Arial', '', 10);
    $pdf->SetTextColor(000, 000, 000);
    $pdf->Cell(50, 10, 'From Date-' . $fdate, 0);
    $pdf->SetFont('Arial', '', 10);
    $pdf->SetTextColor(000, 000, 000);
    $pdf->Cell(50, 10, 'To Date-' . $tdate, 0);
    $pdf->Ln();
    $pdf->SetFont('Arial', '', 8);
    $pdf->SetTextColor(255, 255, 255);
    $pdf->SetFillColor(3, 125, 149);
    $pdf->Cell(55, 7, "Employee Name", 1, 0, '', 1);
    $pdf->Cell(20, 7, "Salary", 1, 0, 'R', 1);
    $pdf->Cell(20, 7, "Basic", 1, 0, 'R', 1);
    $pdf->Cell(18, 7, "Convey", 1, 0, 'R', 1);
    $pdf->Cell(18, 7, "Travel", 1, 0, 'R', 1);
    $pdf->Cell(18, 7, "O.T", 1, 0, 'R', 1);
    $pdf->Cell(18, 7, "Bonus", 1, 0, 'R', 1);
    $pdf->Cell(18, 7, "Gross", 1, 0, 'R', 1);
    $pdf->Cell(20, 7, "Loan", 1, 0, 'R', 1);
    $pdf->Cell(20, 7, "Advance", 1, 0, 'R', 1);
    $pdf->Cell(18, 7, "Others", 1, 0, 'R', 1);
    $pdf->Cell(20, 7, "Total Dedn", 1, 0, 'R', 1);
    $pdf->Cell(20, 7, "Net Salary", 1, 0, 'R', 1);
    $pdf->SetFont('Arial', '', 1, 0);

    $pdf->SetTextColor(0, 0, 0);
    $pdf->Ln();

    $ctr = 0;
    while ($row = mysqli_fetch_assoc($get)) {
        mysqli_select_db($conn, $zdb);
        $getname = mysqli_query($conn, "SELECT * FROM `accmast` WHERE accode=$row[accode] ORDER BY accode") or die(mysqli_error($conn));
        $party = mysqli_fetch_array($getname);

        $pdf->SetFont('Arial', '', 8);
        $pdf->Cell(55, 7, "$party[name]", 1);
        $pdf->Cell(20, 7, "$row[salary]", 1, 0, 'R');
        $pdf->Cell(20, 7, "$row[basic]", 1, 0, 'R');
        $pdf->Cell(18, 7, "$row[convey]", 1, 0, 'R');
        $pdf->Cell(18, 7, "$row[trav]", 1, 0, 'R');
        $pdf->Cell(18, 7, "$row[otamt]", 1, 0, 'R');
        $pdf->Cell(18, 7, "$row[miscamt]", 1, 0, 'R');
        $pdf->Cell(18, 7, "$row[monsalary]", 1, 0, 'R');
        $pdf->Cell(20, 7, "$row[loan]", 1, 0, 'R');
        $pdf->Cell(20, 7, "$row[advance]", 1, 0, 'R');
        $pdf->Cell(18, 7, "$row[miscdedn]", 1, 0, 'R');
        $pdf->Cell(20, 7, "$row[total_ded]", 1, 0, 'R');
        $pdf->Cell(20, 7, "$row[net_sal]", 1, 0, 'R');
        $pdf->Ln();
        $ctr++;
    }



    $row2 = mysqli_fetch_array($get2);
    $pdf->SetFont('Arial', '', 8);
    $pdf->Cell(55, 7, "Total", 1, 0, 'R');
    $pdf->Cell(20, 7, "$row2[totsalary]", 1, 0, 'R');
    $pdf->Cell(20, 7, "$row2[totbasic]", 1, 0, 'R');
    $pdf->Cell(18, 7, "$row2[totconvey]", 1, 0, 'R');
    $pdf->Cell(18, 7, "$row2[tottrav]", 1, 0, 'R');
    $pdf->Cell(18, 7, "$row2[tototamt]", 1, 0, 'R');
    $pdf->Cell(18, 7, "$row2[totmiscamt]", 1, 0, 'R');
    $pdf->Cell(18, 7, "$row2[totmonsal]", 1, 0, 'R');
    $pdf->Cell(20, 7, "$row2[totloan]", 1, 0, 'R');
    $pdf->Cell(20, 7, "$row2[totadvance]", 1, 0, 'R');
    $pdf->Cell(18, 7, "$row2[totmiscdedn]", 1, 0, 'R');
    $pdf->Cell(20, 7, "$row2[totdedn]", 1, 0, 'R');
    $pdf->Cell(20, 7, "$row2[totnet]", 1, 0, 'R');

    $pdf->Ln();
    $ctr++;

    $pdf->Output("Salary Register.pdf", "D");
}