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

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$myyear = $_SESSION[$myyear];
mysqli_select_db($conn, $zdb);

$maindb = 'invmain';
$trandb = 'invtran';

$zroot = $_SESSION["zdbroot"];
$formname = 'SALE SUMMARY PAPERWISE';

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


    $medium = $_POST["medium"];
    $section = $_POST["section"];
    $session = $_POST["session"];
    $exam = $_POST["exam"];


    $medmcond = "";
    $sessncond = '';
    $sectcond = '';
    $examcond = '';

    if (!empty($exam)) {
        $examcond = " AND a.examcode = $exam ";
    }

    if (!empty($medium)) {
        $medmcond = " AND a.medmcode = '$medium' ";
    }

    if (!empty($session)) {
        $sessncond = " AND a.`session` = '$session' ";
    }

    if (!empty($section)) {
        $sectcond = " AND a.section = '$section' ";
    }

    $comp = mysqli_query($conn, "SELECT * FROM $zroot.`company`") or die(mysqli_error($conn));
    $zcomp = mysqli_fetch_assoc($comp);


    include("includes/linkshead.php");
    ?>
    <link href="MyStyle/rep_format.css" rel="stylesheet">
    <style>

        body{
            font-size: 12px;

        }
        .mtable{
            border:1px solid black;
            boder-collapse:collapse;
        }
        .mtd{
            border:1px solid black;
            border-left-style:none;
            border-right-style:none;
            text-align:right;
        }

        td,th,.t4{
            padding:0px;
            font-size:12px;
            font-size:12px;
        }

        .padd{
            padding:7px;
        }

        .border{
            border-top-style:solid;
            border-right-style:none;
            border-left-style:none;
            border-bottom-style:solid;
            border-width:2px;
        }
        .border2{
            border-top-style:solid;
            border-right-style:none;
            border-left-style:none;
            border-bottom-style:solid;
            border-width:2px;
        }

        .right{
            text-align:right;
        }

        table{
            width:100%;
        }
        hr { 
            border-style: inset;
            border-width: 2px;
        } 

    </style>
    </head>
    <body>    
        <div class="page">
            <div class="col-lg-11"></div>
            <div class="col-lg-1">
                <a  class="btn btn-primary goback"  onclick="window.close()">Go Back</a>
            </div>

            <div class="subpage" style="margin-top:5px;width:100%;">
                <div class="row">
                    <?php
                    echo "<h2 class='text-center'>$zcomp[compname]</h2>";
                    echo "<h4 class='text-center'>$zcomp[add1] $zcomp[add1] </h4>";
                    echo "<h4 class='text-center'>$zcomp[add3]</h4>";
                    ?>
                </div>


                <table style="width:100%">
                    <tr>
                        <td style="width:50%"><h4><b>SALES SUMMARY - PAPER WISE</b></h4></td>
                        <td style="width:50%"></td>
                    </tr>
                </table>
                <br>
                <?php
//                $fmain = mysqli_fetch_array($qmain)
                ?>

                <table>
                    <tr class="border">
                        <td style="width:5%;" class="padd"><b>Sr.</b></td>
                        <td style="width:10%;" class="padd"><b>Medium</b></td>
                        <td style="width:7%;" class="padd"><b>First</b></td>
                        <td style="width:7%;" class="padd"><b>Second</b></td>
                        <td style="width:7%;" class="padd"><b>Third</b></td>
                        <td style="width:7%;" class="padd"><b>Fourth</b></td>
                        <td style="width:7%;" class="padd"><b>Fifth</b></td>
                        <td style="width:8%;" class="padd"><b>Sixth</b></td>
                        <td style="width:8%;" class="padd"><b>Seventh</b></td>
                        <td style="width:8%;" class="padd"><b>Eight</b></td>
                        <td style="width:8%;" class="padd"><b>Ninth</b></td>
                        <td style="width:8%;" class="padd"><b>Tenth</b></td>
                        <td style="width:10%;" class="padd mtd"><b>Total</b></td>
                    </tr>

                    <?php
                    $totfpack = 0;
                    $gpack = mysqli_query($conn, "SELECT a.*,b.vouchno,SUM(b.pq1) as p1,SUM(b.pq2) as p2,SUM(b.pq3) as p3,SUM(b.pq4) as p4,
                            SUM(b.pq5) as p5,SUM(b.pq6) as p6,SUM(b.pq7) as p7,SUM(b.pq8) as p8,SUM(b.pq9) as p9,
                            SUM(b.pq10) as p10 FROM `invmain` a,`invtran` b WHERE a.vouchno = b.vouchno $medmcond $examcond $sessncond $sectcond
                             group by a.medmcode order by a.medmcode ") or die(mysqli_error($conn));
//                    $gpack = mysqli_query($conn, "SELECT * FROM `invmain`  WHERE vouchno = '' $medmcond $examcond $sessncond $sectcond ") or die(mysqli_error($conn));

                    $ctr = 0;

                    while ($fpack = mysqli_fetch_array($gpack)) {

                        $getmedm = mysqli_query($conn, "SELECT * FROM `medium` where  `code` = '$fpack[medmcode]' group by '$fpack[medmcode]' 
                                order by '$fpack[medmcode]' ") or die(mysqli_error($conn));
                        $shmedm = mysqli_fetch_array($getmedm);

                        $gmedm = mysqli_query($conn, "SELECT `code`,`name` FROM `medium` WHERE `code` = '$fpack[medmcode]' ")or die(mysqli_error($conn));
                        $fmedm = mysqli_fetch_array($gmedm);

//                        $gtran = mysqli_query($conn, "SELECT vouchno,SUM(pq1) as p1,SUM(pq2) as p2,SUM(pq3) as p3,SUM(pq4) as p4,
//                              SUM(pq5) as p5,SUM(pq6) as p6,SUM(pq7) as p7,SUM(pq8) as p8,SUM(pq9) as p9,
//                              SUM(pq10) as p10 FROM `invtran` WHERE vouchno = $fpack[vouchno]") or die(mysqli_error($conn));
//                        while ($tran = mysqli_fetch_array($gtran)) {

                        $totfpack = $fpack[p1] + $fpack[p2] + $fpack[p3] + $fpack[p4] + $fpack[p5] +
                                $fpack[p6] + $fpack[p7] + $fpack[p8] + $fpack[p9] + $fpack[p10];



                        if ($fpack[p1] < 3) {
                            $fpack[p1] = 0;
                        }
                        if ($fpack[p2] < 3) {
                            $fpack[p2] = 0;
                        }
                        if ($fpack[p3] < 3) {
                            $fpack[p3] = 0;
                        }
                        if ($fpack[p4] < 3) {
                            $fpack[p4] = 0;
                        }
                        if ($fpack[p5] < 3) {
                            $fpack[p5] = 0;
                        }
                        if ($fpack[p6] < 3) {
                            $fpack[p6] = 0;
                        }
                        if ($fpack[p7] < 3) {
                            $fpack[p7] = 0;
                        }
                        if ($fpack[p8] < 3) {
                            $fpack[p8] = 0;
                        }
                        if ($fpack[p9] < 3) {
                            $fpack[p9] = 0;
                        }
                        if ($fpack[p10] < 3) {
                            $fpack[p10] = 0;
                        }


                        $ctr++;
                        echo "<tr>";
                        echo "<td class='padd center'>$ctr</td>";
                        echo "<td class='padd center'>$fmedm[name]</td>";
                        echo "<td class='padd right'>$fpack[p1]</td>";
                        echo "<td class='padd right'>$fpack[p2]</td>";
                        echo "<td class='padd right'>$fpack[p3]</td>";
                        echo "<td class='padd right'>$fpack[p4]</td>";
                        echo "<td class='padd right'>$fpack[p5]</td>";
                        echo "<td class='padd right'>$fpack[p6]</td>";
                        echo "<td class='padd right'>$fpack[p7]</td>";
                        echo "<td class='padd right'>$fpack[p8]</td>";
                        echo "<td class='padd right'>$fpack[p9]</td>";
                        echo "<td class='padd right'>$fpack[p10]</td>";
                        echo "<td class='padd right'>$totfpack</td>";
                        echo "</tr>";

                        $totfirst = $totfirst + $fpack[p1];
                        $totsecond = $totsecond + $fpack[p2];
                        $totthird = $totthird + $fpack[p3];
                        $totfourth = $totfourth + $fpack[p4];
                        $totfifth = $totfifth + $fpack[p5];
                        $totsixth = $totsixth + $fpack[p6];
                        $totseventh = $totseventh + $fpack[p7];
                        $toteight = $toteight + $fpack[p8];
                        $totninth = $totninth + $fpack[p9];
                        $tottenth = $tottenth + $fpack[p10];
                        $total = $totfirst + $totsecond + $totthird + $totfourth + $totfifth +
                                $totsixth + $totseventh + $toteight + $totninth + $tottenth;
                    }


                    echo "<tr>";
                    echo "<td class='padd border2'></td>";
                    echo "<td style='text-align:right'  class='padd border2'><b>Total</b></td>";
                    echo "<td  class='padd border2 right'><b>$totfirst</b></td>";
                    echo "<td  class='padd border2 right'><b>$totsecond</b></td>";
                    echo "<td  class='padd border2 right'><b>$totthird</b></td>";
                    echo "<td  class='padd border2 right'><b>$totfourth</b></td>";
                    echo "<td  class='padd border2 right'><b>$totfifth</b></td>";
                    echo "<td  class='padd border2 right'><b>$totsixth</b></td>";
                    echo "<td  class='padd border2 right'><b>$totseventh </b></td>";
                    echo "<td  class='padd border2 right'><b>$toteight</b></td>";
                    echo "<td  class='padd border2 right'><b>$totninth</b></td>";
                    echo "<td  class='padd border2 right'><b>$tottenth</b></td>";
                    echo "<td  class='padd border2 right'><b>$total</b></td>";
                    echo "</tr>";
                    ?>
                </table>
                <?php
                ?>
            </div>
        </div>
        <?php include('includes/linksfoot.php'); ?>
    </body>
    </html>
    <?php
}
if (isset($_POST["excel"])) {

    $medium = $_POST["medium"];
    $section = $_POST["section"];
    $session = $_POST["session"];
    $exam = $_POST["exam"];
    $dtype = 1;

    $medmcond = "";
    $sessncond = '';
    $sectcond = '';
    $examcond = '';

    if (!empty($exam)) {
        $examcond = " AND a.examcode = $exam ";
    }

    if (!empty($medium)) {
        $medmcond = " AND a.medmcode = '$medium' ";
    }

    if (!empty($session)) {
        $sessncond = " AND a.`session` = '$session' ";
    }

    if (!empty($section)) {
        $sectcond = " AND a.section = '$section' ";
    }

    $comp = mysqli_query($conn, "SELECT * FROM $zroot.`company`") or die(mysqli_error($conn));
    $zcomp = mysqli_fetch_assoc($comp);

    $contents.="Sr., Medium, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eight, Ninth, Tenth, Total \n";


    $totfpack = 0;
    $gpack = mysqli_query($conn, "SELECT a.*,b.vouchno,SUM(b.pq1) as p1,SUM(b.pq2) as p2,SUM(b.pq3) as p3,SUM(b.pq4) as p4,
                            SUM(b.pq5) as p5,SUM(b.pq6) as p6,SUM(b.pq7) as p7,SUM(b.pq8) as p8,SUM(b.pq9) as p9,
                            SUM(b.pq10) as p10 FROM `invmain` a,`invtran` b WHERE a.vouchno = b.vouchno $medmcond $examcond $sessncond $sectcond
                             group by a.medmcode order by a.medmcode ") or die(mysqli_error($conn));
//                    $gpack = mysqli_query($conn, "SELECT * FROM `invmain`  WHERE vouchno = '' $medmcond $examcond $sessncond $sectcond ") or die(mysqli_error($conn));

    $ctr = 0;

    while ($fpack = mysqli_fetch_array($gpack)) {

        $getmedm = mysqli_query($conn, "SELECT * FROM `medium` where  `code` = '$fpack[medmcode]' group by '$fpack[medmcode]' 
                                order by '$fpack[medmcode]' ") or die(mysqli_error($conn));
        $shmedm = mysqli_fetch_array($getmedm);

        $gmedm = mysqli_query($conn, "SELECT `code`,`name` FROM `medium` WHERE `code` = '$fpack[medmcode]' ")or die(mysqli_error($conn));
        $fmedm = mysqli_fetch_array($gmedm);

//                        while ($tran = mysqli_fetch_array($gtran)) {

        $totfpack = $fpack[p1] + $fpack[p2] + $fpack[p3] + $fpack[p4] + $fpack[p5] +
                $fpack[p6] + $fpack[p7] + $fpack[p8] + $fpack[p9] + $fpack[p10];



        if ($fpack[p1] < 3) {
            $fpack[p1] = 0;
        }
        if ($fpack[p2] < 3) {
            $fpack[p2] = 0;
        }
        if ($fpack[p3] < 3) {
            $fpack[p3] = 0;
        }
        if ($fpack[p4] < 3) {
            $fpack[p4] = 0;
        }
        if ($fpack[p5] < 3) {
            $fpack[p5] = 0;
        }
        if ($fpack[p6] < 3) {
            $fpack[p6] = 0;
        }
        if ($fpack[p7] < 3) {
            $fpack[p7] = 0;
        }
        if ($fpack[p8] < 3) {
            $fpack[p8] = 0;
        }
        if ($fpack[p9] < 3) {
            $fpack[p9] = 0;
        }
        if ($fpack[p10] < 3) {
            $fpack[p10] = 0;
        }


        $ctr++;
        $contents.= $ctr . ",";
        $contents.= $fmedm[name] . ",";
        $contents.= $fpack[p1] . ",";
        $contents.= $fpack[p2] . ",";
        $contents.= $fpack[p3] . ",";
        $contents.= $fpack[p4] . ",";
        $contents.= $fpack[p5] . ",";
        $contents.= $fpack[p6] . ",";
        $contents.= $fpack[p7] . ",";
        $contents.= $fpack[p8] . ",";
        $contents.= $fpack[p9] . ",";
        $contents.= $fpack[p10] . ",";
        $contents.= $totfpack . "\n";

        $totfirst = $totfirst + $fpack[p1];
        $totsecond = $totsecond + $fpack[p2];
        $totthird = $totthird + $fpack[p3];
        $totfourth = $totfourth + $fpack[p4];
        $totfifth = $totfifth + $fpack[p5];
        $totsixth = $totsixth + $fpack[p6];
        $totseventh = $totseventh + $fpack[p7];
        $toteight = $toteight + $fpack[p8];
        $totninth = $totninth + $fpack[p9];
        $tottenth = $tottenth + $fpack[p10];
        $total = $totfirst + $totsecond + $totthird + $totfourth + $totfifth +
                $totsixth + $totseventh + $toteight + $totninth + $tottenth;
    }

    $contents.= " " . ",";
    $contents.= "Total" . ",";
    $contents.= $totfirst . ",";
    $contents.= $totsecond . ",";
    $contents.= $totthird . ",";
    $contents.= $totfourth . ",";
    $contents.= $totfifth . ",";
    $contents.= $totsixth . ",";
    $contents.= $totseventh . ",";
    $contents.= $toteight . ",";
    $contents.= $totninth . ",";
    $contents.= $tottenth . ",";
    $contents.= $total . "\n";

    $contents = strip_tags($contents);


    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"])) {


    $medium = $_POST["medium"];
    $section = $_POST["section"];
    $session = $_POST["session"];
    $exam = $_POST["exam"];


    $medmcond = "";
    $sessncond = '';
    $sectcond = '';
    $examcond = '';

    if (!empty($exam)) {
        $examcond = " AND a.examcode = $exam ";
    }

    if (!empty($medium)) {
        $medmcond = " AND a.medmcode = '$medium' ";
    }

    if (!empty($session)) {
        $sessncond = " AND a.`session` = '$session' ";
    }

    if (!empty($section)) {
        $sectcond = " AND a.section = '$section' ";
    }

    $comp = mysqli_query($conn, "SELECT * FROM $zroot.`company`") or die(mysqli_error($conn));
    $zcomp = mysqli_fetch_assoc($comp);

    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();
    $pdf->SetFont('Arial', 'I', 10);
    $pdf->Cell(278, 7, "$zcomp[compname]", 1, 0, 'C');
    $pdf->Ln();
    $pdf->Cell(278, 7, "$zcomp[add1]" . "$zcomp[add2]", 1, 0, 'C');
    $pdf->Ln();
    $pdf->Cell(278, 7, "$zcomp[add3]", 1, 0, 'C');
    $pdf->Ln();

    $pdf->SetFont('Arial', 'I', 10);
    $pdf->SetTextColor(255, 255, 255);
    $pdf->SetFillColor(96, 130, 191);
    $pdf->Cell(278, 7, "SALES SUMMARY - PAPER WISE", 1, 0, '', 1);
    $pdf->SetFont('Arial', '', 1, 0);

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

    $pdf->SetFont('Arial', 'I', 10);
    $pdf->SetTextColor(255, 255, 255);
    $pdf->SetFillColor(96, 130, 191);
    $pdf->Cell(8, 7, "Sr.", 1, 0, '', 1);
    $pdf->Cell(30, 7, "Medium", 1, 0, '', 1);
    $pdf->Cell(21, 7, "First", 1, 0, '', 1);
    $pdf->Cell(21, 7, "Second", 1, 0, '', 1, 0, 'R');
    $pdf->Cell(21, 7, "Third", 1, 0, '', 1, 0, 'R');
    $pdf->Cell(21, 7, "Fourth", 1, 0, '', 1, 0, 'R');
    $pdf->Cell(21, 7, "Fifth", 1, 0, '', 1, 0, 'R');
    $pdf->Cell(21, 7, "Sixth", 1, 0, '', 1, 0, 'R');
    $pdf->Cell(21, 7, "Seventh", 1, 0, '', 1, 0, 'R');
    $pdf->Cell(21, 7, "Eight", 1, 0, '', 1, 0, 'R');
    $pdf->Cell(21, 7, "Ninth", 1, 0, '', 1, 0, 'R');
    $pdf->Cell(21, 7, "Tenth", 1, 0, '', 1, 0, 'R');
    $pdf->Cell(30, 7, "Total", 1, 0, '', 1, 0, 'R');
    $pdf->SetFont('Arial', '', 1, 0);

    $pdf->SetTextColor(0, 0, 0);
    $pdf->Ln();
    $totfpack = 0;
    $gpack = mysqli_query($conn, "SELECT a.*,b.vouchno,SUM(b.pq1) as p1,SUM(b.pq2) as p2,SUM(b.pq3) as p3,SUM(b.pq4) as p4,
                            SUM(b.pq5) as p5,SUM(b.pq6) as p6,SUM(b.pq7) as p7,SUM(b.pq8) as p8,SUM(b.pq9) as p9,
                            SUM(b.pq10) as p10 FROM `invmain` a,`invtran` b WHERE a.vouchno = b.vouchno $medmcond $examcond $sessncond $sectcond
                             group by a.medmcode order by a.medmcode ") or die(mysqli_error($conn));
//                    $gpack = mysqli_query($conn, "SELECT * FROM `invmain`  WHERE vouchno = '' $medmcond $examcond $sessncond $sectcond ") or die(mysqli_error($conn));

    $ctr = 0;

    while ($fpack = mysqli_fetch_array($gpack)) {

        $getmedm = mysqli_query($conn, "SELECT * FROM `medium` where  `code` = '$fpack[medmcode]' group by '$fpack[medmcode]' 
                                order by '$fpack[medmcode]' ") or die(mysqli_error($conn));
        $shmedm = mysqli_fetch_array($getmedm);

        $gmedm = mysqli_query($conn, "SELECT `code`,`name` FROM `medium` WHERE `code` = '$fpack[medmcode]' ")or die(mysqli_error($conn));
        $fmedm = mysqli_fetch_array($gmedm);

//                        $gtran = mysqli_query($conn, "SELECT vouchno,SUM(pq1) as p1,SUM(pq2) as p2,SUM(pq3) as p3,SUM(pq4) as p4,
//                              SUM(pq5) as p5,SUM(pq6) as p6,SUM(pq7) as p7,SUM(pq8) as p8,SUM(pq9) as p9,
//                              SUM(pq10) as p10 FROM `invtran` WHERE vouchno = $fpack[vouchno]") or die(mysqli_error($conn));
//                        while ($tran = mysqli_fetch_array($gtran)) {

        $totfpack = $fpack[p1] + $fpack[p2] + $fpack[p3] + $fpack[p4] + $fpack[p5] +
                $fpack[p6] + $fpack[p7] + $fpack[p8] + $fpack[p9] + $fpack[p10];



        if ($fpack[p1] < 3) {
            $fpack[p1] = 0;
        }
        if ($fpack[p2] < 3) {
            $fpack[p2] = 0;
        }
        if ($fpack[p3] < 3) {
            $fpack[p3] = 0;
        }
        if ($fpack[p4] < 3) {
            $fpack[p4] = 0;
        }
        if ($fpack[p5] < 3) {
            $fpack[p5] = 0;
        }
        if ($fpack[p6] < 3) {
            $fpack[p6] = 0;
        }
        if ($fpack[p7] < 3) {
            $fpack[p7] = 0;
        }
        if ($fpack[p8] < 3) {
            $fpack[p8] = 0;
        }
        if ($fpack[p9] < 3) {
            $fpack[p9] = 0;
        }
        if ($fpack[p10] < 3) {
            $fpack[p10] = 0;
        }
        $ctr++;
        $pdf->SetFont('Arial', '', 8);
        $pdf->Cell(8, 7, "$ctr", 1);
        $pdf->Cell(30, 7, "$fmedm[name]", 1);
        $pdf->Cell(21, 7, "$fpack[p1]", 1);
        $pdf->Cell(21, 7, "$fpack[p2]", 1);
        $pdf->Cell(21, 7, "$fpack[p3]", 1);
        $pdf->Cell(21, 7, "$fpack[p4]", 1);
        $pdf->Cell(21, 7, "$fpack[p5]", 1);
        $pdf->Cell(21, 7, "$fpack[p6]", 1);
        $pdf->Cell(21, 7, "$fpack[p7]", 1);
        $pdf->Cell(21, 7, "$fpack[p8]", 1);
        $pdf->Cell(21, 7, "$fpack[p9]", 1);
        $pdf->Cell(21, 7, "$fpack[p10]", 1);
        $pdf->Cell(30, 7, "$totfpack", 1);
        $pdf->Ln();

        $totfirst = $totfirst + $fpack[p1];
        $totsecond = $totsecond + $fpack[p2];
        $totthird = $totthird + $fpack[p3];
        $totfourth = $totfourth + $fpack[p4];
        $totfifth = $totfifth + $fpack[p5];
        $totsixth = $totsixth + $fpack[p6];
        $totseventh = $totseventh + $fpack[p7];
        $toteight = $toteight + $fpack[p8];
        $totninth = $totninth + $fpack[p9];
        $tottenth = $tottenth + $fpack[p10];
        $total = $totfirst + $totsecond + $totthird + $totfourth + $totfifth +
                $totsixth + $totseventh + $toteight + $totninth + $tottenth;
    }


    $pdf->SetFont('Arial', 'I', 10);
    $pdf->SetTextColor(255, 255, 255);
    $pdf->SetFillColor(255, 0, 0);
    $pdf->Cell(8, 7, " ", 1, 0, '', 1);
    $pdf->Cell(30, 7, "Total", 1, 0, '', 1);
    $pdf->Cell(21, 7, "$totfirst", 1, 0, '', 1);
    $pdf->Cell(21, 7, "$totsecond", 1, 0, '', 1);
    $pdf->Cell(21, 7, "$totthird", 1, 0, '', 1);
    $pdf->Cell(21, 7, "$totfourth", 1, 0, '', 1);
    $pdf->Cell(21, 7, "$totfifth", 1, 0, '', 1);
    $pdf->Cell(21, 7, "$totsixth", 1, 0, '', 1);
    $pdf->Cell(21, 7, "$totseventh", 1, 0, '', 1);
    $pdf->Cell(21, 7, "$toteigth", 1, 0, '', 1);
    $pdf->Cell(21, 7, "$totninth", 1, 0, '', 1);
    $pdf->Cell(21, 7, "$tottenth", 1, 0, '', 1);
    $pdf->Cell(30, 7, "$total", 1, 0, '', 1);
    $pdf->SetFont('Arial', '', 1, 0, '', 1, 0);

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

    $pdf->Output("Sale Summary PaperWise.pdf", "D");
}
?>