<?php
/**
 * Created by PhpStorm.
 * User: neosoft
 * Date: 27/10/14
 * Time: 11:16 AM
 */
?>
<link rel="stylesheet" href="<?php echo base_url();?>assets/js/validationEngine.jquery.css" type="text/css" />
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/cust_paginition.css" type="text/css" />
<div id="addMagezine">
    <div class="modal-dialog">
        <div class="modal-content">
            <!-- Modal heading -->
            <!-- // Modal heading END -->
            <!-- Modal body -->
            <div class="modal-body">

                <div class="innerAll">
                    <div class="innerLR">

                        <div id="print_div">
                            <div class="modal-header">
                                <div style="float: left;margin-top: -24px;">
                                    <img src="<?php echo base_url(); ?>assets/images/logo/sub-logo.jpg" />
                                </div>
                                <div>
                                    <h4 class="modal-title" align="center">Receipt Voucher</h4>
                                </div>
                            </div>
                            <div style="clear: both"></div>
                            <div>
                                <table class="table table-white table-vertical-center margin-none table-striped footable">
                                    <tr>
                                        <td class="text-left">Subscriber Name:</td>
                                        <td class="text-left"><?php echo ucwords($arrData[0]['subscriber_name']); ?></td>
                                    </tr>
                                    <tr>
                                        <td class="text-left">Transaction Id:</td>
                                        <td class="text-left"><?php echo ucwords($arrData[0]['transaction_id']); ?></td>
                                    </tr>
                                    <tr>
                                        <td class="text-left">Transaction Date:</td>
                                        <td class="text-left"><?php echo ucwords($arrData[0]['transaction_date']); ?></td>
                                    </tr>
                                    <tr>
                                        <td class="text-left">Payment Method</td>
                                        <td class="text-left"><?php echo ucwords($payment_method[$arrData[0]['mode_of_payment']]); ?></td>
                                    </tr>
                                </table>
                            </div>
                            <div style="clear: both"></div>
                            <hr>
                            <br>
                            <div class="modal-header">
                                <h5 class="modal-title" align="center">Transaction details</h5>
                            </div>

                            <div>
                                <table class="table table-white table-vertical-center margin-none table-striped footable">
                                    <tr>
                                        <th data-class="highlight" class="text-center">Magazine Code</th>
                                        <th data-class="highlight" class="text-center">Subscribed On</th>
                                        <th data-class="highlight" class="text-center">Start Issue</th>
                                        <th data-class="highlight" class="text-center">End Issue</th>
                                        <th data-class="highlight" class="text-center">Total Issues</th>
                                        <th data-class="highlight" class="text-center">Amount</th>
                                    </tr>
                                    <?php
                                    $intTotalAmount = 0;
                                    foreach($arrData as $details) {?>
                                        <tr>
                                            <td  class="text-center"><?php echo $details['magazine_code']; ?></td>
                                            <td  class="text-center"><?php echo date("Y-m-d", strtotime($details['subscribed_on'])); ?></td>
                                            <td  class="text-center"><?php echo $details['start_issue']; ?></td>
                                            <td  class="text-center"><?php echo $details['end_issue']; ?></td>
                                            <td  class="text-center"><?php echo $details['no_of_issue']; ?></td>
                                            <td  class="text-center"><?php echo $details['amount']; ?></td>
                                        </tr>
                                        <?php $intTotalAmount = $intTotalAmount + $details['amount']; } ?>
                                    </table>
                            </div>
                            <br>
                            <hr>
                            <div class="modal-header">
                                <h5 class="" align="right">Total Amount : <?php echo $intTotalAmount." ".$arrData['name']; ?></h5>
                            </div>
                        </div>
                        <hr>
                        <br><h5 class="" align="right"><small>Thank you for choosing Subscription Management System<small></small></h5>
                        <div align="center" id="this_msg">

                        </div>

                        <div class="form-group">
                            <div class="col-sm-offset-4 col-sm-9" align="center">
                                <?php
                                $strRedirectUrl = base_url()."index.php/subscriber/fnGenrateReceiptPdf/?id=".$intTransactionId."&view=subscriber/receipt_pdf"; ?>
                                <a href="<?php echo $strRedirectUrl; ?>"><button type="button" class="btn btn-primary" id ="btnSubmit">Download PDF</button></a>
                                <button type="button" class="btn btn-primary" onClick="printDiv()">Print</button>
                                <button type="button" class="btn btn-primary" onClick="fnSendEmail()">Send subscriber Email</button>
                                <input type="hidden" name="vl" id = "vl" value="<?php echo $arrData;?>" >
                                <input type="hidden" id="base_url" value="<?php echo base_url(); ?>" />
                                <input type="hidden" id="transaction_id" value="<?php echo $intTransactionId; ?>" />
                                <a class="btn" href="<?php echo base_url(); ?>index.php/subscriber/finalise_payment"> <button type="button" class="btn btn-primary">Back</button></a>
                            </div>
                        </div>
                        <br>
                    </div>
                </div>

            </div>
        </div>
    </div>


    <script src="<?php echo base_url();?>assets/js/main.js" type="text/javascript"></script>
    <script>
        function printDiv() {

            w = window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=850,height=750');
            w.document.write($('#print_div').html());
            w.print();
            w.close();
        }


        function fnSendEmail() {
            var system_base_url = $('#base_url').val();
            var transaction_id = $('#transaction_id').val();
            $('#this_msg').empty();
            $.ajax({
                url: system_base_url+"index.php/subscriber/SendEmailForReceipt",
                'type' : 'POST',
                async:false,
                'data' : {
                    'transaction_id' :transaction_id
                },
                success: function(data){
                    alert(data);
                    //$('#this_msg').html(data).show();
                    //$('#this_msg').fadeOut(6000);

                }
            });
        }


    </script>

