<style>
    <?php include(public_path().'/css/style.css');?>
    <?php include(public_path().'/css/font-awesome.css');?>
</style>
<style>
body {
    background-color: white !important;
}
</style>
<?php
    $invoice_date = "";
    $invoice_number ="";
    $qr_string ="";
    $invoice_date = $invoice->invoice_date;
    if($invoice_date)
    {
        $invoice_month = date('m',strtotime($invoice_date));
        $invoice_year = date('Y',strtotime($invoice_date));
        $invoice_no = $invoice->invoice_no;
        $org_code = $invoice->organisation->short_code;
        if($invoice_month<4)
            $invoice_year--;

        $nextyear = $invoice_year+1;

        $invoice_number = $org_code.'/'.$invoice_no.'/'.$invoice_year.'-'.$nextyear;
    }

    if($invoice->status==1)
        $invoice_status = 'Paid';
    else if($invoice->status==0)
        $invoice_status = 'Pending';
    else
        $invoice_status = 'Cancelled';

    //get adults and child count from tickets
    foreach($invoice->tickets as $ticket)
    {
        $adultCount = $ticket->noof_adult;
        $childCount = $ticket->noof_child;
    }

    $totalCount = $adultCount+$childCount;

    if($invoice_date)
    {
        $secretkey='KSSTM'.$invoice_number.$invoice_date;
        $secretmd5 = md5($secretkey);
    
        $qr_string=$invoice_number.'~'.$invoice_date.'~'.'Adult:'.$adultCount.'~'.'Child:'.$childCount.'~'.$invoice_status.'~'.'Secret:'.$secretmd5;
    }
    
?>
<div class="table-responsive">
    <table class="table table-clear">
        <tr>
            <td colspan="2"><img class="logo-abbr mr-2" width="80" src="<?php echo e(public_path('images/logo_ksstm.png')); ?>" alt=""></td><td colspan="2" align="right"><img src="data:image/png;base64, <?php echo base64_encode(QrCode::format('png')->size(80)->generate($qr_string)); ?> "></td>
        </tr>
        <tr>
            <td colspan="4"><div class=""> Invoice #: <strong><?php echo e($invoice_number); ?></strong><span class="float-right">
                                    <strong>Status:</strong> <?php echo e($invoice_status); ?></span> </div>
            </td>
        </tr>
        <tr><td>Show Date:</td><td><strong><?php echo e(date('d-m-Y', strtotime($invoice->show_date))); ?></strong></td><td>Visitor Name:</td><td><strong><?php echo e($invoice->publicuser->name); ?></strong></td></tr>
        <tr><td>Centre:</td><td colspan="3"><strong><?php echo e($invoice->organisation->organisation_name); ?>,&nbsp;<?php echo e($invoice->organisation->city); ?></strong></td></tr>
        <tr><td>Adults#:</td><td><strong><?php echo e($adultCount); ?></strong></td><td>Child#:</td><td><strong><?php echo e($childCount); ?></strong></td></tr>
        <tr><td colspan="4" align="center"><span> <strong class="d-block" style="border:orange; border-width:2px; border-style:solid; text-align: center;"><p style="margin:5px !important;">Total Permit:&nbsp;<?php echo e($totalCount); ?></p></strong>
                                                    </span></td></tr>
        <tr><td colspan="4"><small class="text-muted">*Ticket subjected to verification at Counters</small></td></tr>
    </table>
    <table class="table table-striped">
        <thead>
            <tr>
                <th class="center">#</th>
                <th>Ticket#</th>
                <th>Facility</th>
                <th class="right">Show Time</th>
                <th class="right">Amount</th>
            </tr>
        </thead>
        <tbody>
            <?php $j=0; ?>
            <?php $__currentLoopData = $invoice->tickets; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ticket): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <?php $j++; ?>
            <tr>
                <td class="center"><?php echo e($j); ?></td>
                <td class="left strong"><?php echo e($org_code); ?>/<?php echo e($ticket->facility->short_code); ?>/<?php echo e($ticket->ticket_no); ?>/<?php echo e($invoice_year); ?>-<?php echo e($nextyear); ?></td>
                <td class="left"><?php echo e($ticket->facility->facility_name); ?></td>
                <td class="right"><?php echo e($ticket->showtime->from_time); ?>&nbsp;-&nbsp;<?php echo e($ticket->showtime->to_time); ?>

                    <p>
                        <?php
                            if($ticket->facility->fixedseatflag)
                            {
                                echo "Seat(s) : ";
                                for($i=1; $i<=$totalrows; $i++)
                                {
                                    $printseatstring='';
                                    $firstseat='';
                                    $prevrowname='';
                                    $colcount=0;
                                    ?>
                                    <?php $__currentLoopData = $seat_name_row[$i]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $rowseatname): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php
                                        $colcount++;
                                            if(in_array($rowseatname, $seatname_ticket))
                                            {
                                                if(!$firstseat)
                                                {
                                                    $firstseat = $rowseatname;
                                                    $printseatstring = $firstseat;
                                                }


                                                 $prevrowname = $rowseatname;

                                                 if($colcount==sizeof($seat_name_row[$i]) && $firstseat!=$rowseatname)
                                                 {
                                                    $printseatstring .= '-'.$rowseatname;
                                                 }
                                            }
                                            else
                                            {
                                                if($prevrowname)
                                                    $printseatstring .= '-'.$prevrowname;

                                                $prevrowname = '';
                                                $firstseat ='';
                                                if($printseatstring)
                                                    echo $printseatstring.", ";

                                                $printseatstring = '';
                                            }

                                        ?>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <?php
                                    if($printseatstring)
                                        echo $printseatstring."<br>";
                                }
                            }
                        ?>                                
                    </p>
                </td>
                <td class="right">Rs.&nbsp;<?php echo e($ticket->amount); ?></td>
            </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            
        </tbody>
    </table>
    <table class="table table-clear">
        <tbody>
            
            <tr>
                <td class="left"><strong>Total</strong></td>
                <td class="right"><strong>Rs.&nbsp;<?php echo e($invoice->amount); ?>/-</strong><br>
                    </td>
            </tr>
        </tbody>
    </table>

</div>

		<?php /**PATH /var/www/html/ksstmprod/resources/views/tickets/invoicepdf.blade.php ENDPATH**/ ?>