





<?php $__env->startSection('content'); ?>


<style>



</style>
<?php
    $invoice_date = $invoice->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;

    $secretkey='KSSTM'.$invoice_number.$invoice_date;
    $secretmd5 = md5($secretkey);

    $qr_string=$invoice_number.'~'.$invoice_date.'~'.'Adult:'.$adultCount.'~'.'Child:'.$childCount.'~'.$invoice_status.'~'.'Secret:'.$secretmd5;

    $invoice_secret = md5($invoice->id);

?>
<div class="container-fluid">
    <div class="row">
        <div class="col-lg-12">
            <span class="float-right"><a href="<?php echo e(url('user/invoiceprint/')); ?>/<?php echo e($invoice->id); ?>/<?php echo e($invoice_secret); ?>" target="_blank"><button class="btn btn-xs btn-primary">Print Reservation Slip</button></a></span>
        </div>
    </div>
    <div class="row">
                    <div class="col-lg-12">

                        <div class="card mt-3">
                            <div class="card-header"> <div>Invoice #: <strong><?php echo e($invoice_number); ?></strong><br><small><?php echo e(date('d-m-Y', strtotime($invoice_date))); ?></small></div> <span class="float-right">
                                    <strong>Status:</strong> <?php echo e($invoice_status); ?></span> </div>
                            <div class="card-body">
                                <div class="row">
                                    <div class="col-xl-6 col-sm-6 mb-8">
                                        
                                        <div class="col-sm-12 row"><div class="col-sm-4"> Show Date:&nbsp;</div><div class="col-sm-8"><strong><?php echo e(date('d-m-Y', strtotime($invoice->show_date))); ?></strong> </div></div>
                                        <div class="col-sm-12 row"><div class="col-sm-4"> Visitor:&nbsp;</div><div class="col-sm-8"><strong><?php echo e(auth('publicuser')->user()->name); ?></strong> </div></div>
                                        <div class="col-sm-12 row"><div class="col-sm-4"> Centre:&nbsp;</div><div class="col-sm-8"><strong><?php echo e($invoice->organisation->organisation_name); ?>,&nbsp;<?php echo e($invoice->organisation->city); ?></strong> </div></div>
                                        <div class="col-sm-12 row"><div class="col-sm-4"> Adults#:&nbsp;</div><div class="col-sm-8"><strong><?php echo e($adultCount); ?></strong> </div></div>
                                        <div class="col-sm-12 row"><div class="col-sm-4"> Child#:&nbsp;</div><div class="col-sm-8"><strong><?php echo e($childCount); ?></strong> </div></div>
                                    </div>
                                    
                                    <div class="col-xl-6 col-lg-6 col-md-12 col-sm-12 mb-4 d-flex justify-content-lg-end justify-content-md-center justify-content-xs-start">
                                        <div class="row align-items-center">
                                            <div class="col-sm-9"> 
                                                <div class="brand-logo mb-3">
                                                    <img class="logo-abbr mr-2" width="80" src="<?php echo e(asset('images/logo_ksstm.png')); ?>" alt="">
                                                    <img class="logo-compact" width="110" src="<?php echo e(asset('images/logo_text_ksstm.png')); ?>" alt="">
                                                </div>
                                                <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><br>
                                                <small class="text-muted">*Ticket subjected to verification at Counters</small>
                                            </div>
                                            <div class="col-sm-3 mt-3"> <?php echo QrCode::size(80)->generate($qr_string); ?> </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="table-responsive">
                                    <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"><i class='fa fa-rupee'></i>&nbsp;<?php echo e($ticket->amount); ?></td>
                                            </tr>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            
                                        </tbody>
                                    </table>
                                </div>
                                <div class="row">
                                    <div class="col-lg-4 col-sm-5"> </div>
                                    <div class="col-lg-4 col-sm-5 ml-auto">
                                        <table class="table table-clear">
                                            <tbody>
                                                
                                                <tr>
                                                    <td class="left"><strong>Total</strong></td>
                                                    <td class="right"><strong><i class='fa fa-rupee'></i>&nbsp;<?php echo e($invoice->amount); ?></strong><br>
                                                        </td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
</div>






<script>

</script>

<?php $__env->stopSection(); ?>			
<?php echo $__env->make('layout.public', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/ksstmorg/resources/views/tickets/invoice.blade.php ENDPATH**/ ?>