<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" />
<style type="text/css">
    select{width:370px !important}
</style>
<div id="addMagezine">
<div class="modal-dialog" style="width: 850px !important;">
<div class="modal-content">
<!-- Modal heading -->
<div class="modal-header">
    <a class="btn pull-right fa fa-arrow-left" href="<?php echo base_url(); ?>index.php/subscriber/preview/?user_id=<?php echo $strSubscriberId; ?>"> <button type="button" class="btn btn-primary">Pay Later</button></a>
    <h4 class="modal-title" align="center">Make Payment <?php echo ucwords($arrResultSet['name']); ?></h4>

</div>
<!-- // Modal heading END -->
<!-- Modal body -->
<div class="modal-body">
    <div class="innerAll">
        <div class="innerLR">
            <form class="form-horizontal" role="form" id = "edit_magezine" method = "post" enctype="multipart/form-data" action="<?php echo base_url();?>index.php/subscriber/proceed_payment">
                <?php $this->load->view('admin/flashdata_admin'); ?>
                <div class="form-group mmar">
                    <p> Please review below subscription details and proceed to payment, </p>
                    <p> Subscriber  -  <span class="username_display"><?php echo ucwords($strName); ?></span> </p>

                </div>
                <table class="table table-white table-vertical-center margin-none table-striped footable">
                    <tr>
                        <th>Sr.No</th>
                        <th>Magazine Id</th>
                        <th>Number Of years</th>
                        <th>Number Of Copies</th>
                        <th>Start Issue</th>
                        <th>End Issue</th>
                        <th>Subscribed On</th>
                        <th>Amount</th>
                    </tr>                                                       
                    <?php                      
                    $intCount = 1;
                    $strCurrency = "";
                    foreach($transaction_details as $transaction) {?>
                        <tr>
                            <td>
                                <p><?php echo $intCount ?></p>
                            </td>
                            <td>
                                <p><?php echo $transaction['magazine_code'] ?></p>
                            </td>
                            <td>
                                <p><?php echo $transaction['period']; ?></p>
                            </td>
                            <td>
                                <p><?php echo $transaction['totalNCopies']; ?></p>
                            </td>
                            <td>     
                                <p><?php echo $transaction['start_issue'] ?></p>
                            </td>
                            <td>
                                <p><?php echo $transaction['end_issue'] ?></p>
                            </td>
                            <td>
                                <p><?php echo date("d M Y", strtotime($transaction['subscribed_on'])) ?></p>
                            </td>
                            <td>
                                <p>
                                    <?php
                                        $strTotalAmountToPay = $strTotalAmountToPay +  $transaction['amount'];
                                        $strCurrency = $transaction['currency'];
                                        echo number_format($transaction['amount'], 2)." ".$transaction['currency'];
                                    ?>
                                </p>
                            </td>
                        </tr>
                    <?php $intCount++;  } ?>
                </table>
                <hr>
                <div class="form-group mmar" style="text-align: right;margin-top: 25px !important;">
                    <p>Total Amount: <?php echo number_format($strTotalAmountToPay, 2)." ".$transaction['currency']; ?></p>
                </div>
                <hr>
                <div class="form-group mmar">
                    <label  class="col-sm-3 control-label text-right">Comment : </label>
                    <div class="col-sm-9">
                        <textarea class="form-control " id="message_desc" name="message_desc"></textarea>
                    </div>
                </div>
                <div class="form-group mmar" style="margin-top: 30px !important;">
                    <label  class="col-sm-3 control-label text-right">Payment made by : </label>
                    <div class="col-sm-9">
                        <select class="cust_select col-md-12 validate[required] text-input" id = "subscriber_type" name = "payment_type" style="color: black">
                            <option value = "">--Select--</option>
                            <?php
                            foreach ($arrPaymentMethods as $key => $paymentMethod) {
                                echo '<option value = "'.$paymentMethod['id'].'">'.$paymentMethod['dispay_text'].'</option>';
                            }
                            ?>
                           <!--  <option value = "1">Cash</option>
                            <option value = "2">Cheque</option>
                            <option value = "3">Credit Card</option>
                            <option value = "4">Online Transfer</option>
                            <option value = "5">Club Membership</option>
                            <option value = "6">Complementary</option>
                            <option value = "7">Replacement</option>
                            <option value = "8">Invoice</option>
                            <option value = "9">NETS</option>
                            <option value = "10">Paynow</option> -->
                        </select>
                    </div>

                </div>
                
                <div class="form-group mmar" style="margin-top: 30px !important;">
                    <label  class="col-sm-3 control-label text-right date">Payment Date : </label>
                    <div class="col-sm-9">
                        <input type="text" name="payment_date" class="form-control date" data-date-format="d-M-yyyy" readonly="readonly" />
                    </div>
                </div>

                <div class="form-group mmar" style="margin-top: 30px !important;">
                    <label  class="col-sm-3 control-label text-right">Reference No : </label>
                    <div class="col-sm-9">
                        <input type="text" name="reference_no" class="form-control" />
                    </div>
                </div>

                <!-- <div class="form-group mmar" style="margin-top: 30px !important;">
                    <label  class="col-sm-3 control-label text-right">Voucher : </label>
                    <div class="col-sm-9">
                        <input type="text" name="voucher" class="form-control" />
                    </div>
                </div> -->

                <div class="form-group mmar" style="margin-top: 30px !important;">
                    <label  class="col-sm-3 control-label text-right">Discount Rate : </label>
                    <div class="col-sm-9">
                        <input type="text" name="discount_rate" class="form-control" />
                    </div>
                </div>

                <hr>
                <!--<div id="cash_payment" class="form-group mmar">
                    <label  class="col-sm-3 control-label text-center">Agent: </label>
                    <div class="col-sm-9">
                        <select class="cust_select col-md-12 marl-n validate[required] text-input" id = "cname" name = "cname">
                            <option value = "">--Select--</option>
                            <?php foreach($agent_details as $campaign) { ?>
                                <option value = "<?php echo $campaign['id']; ?>"><?php echo ucfirst($campaign['first_name']." ".$campaign['last_name']); ?></option>
                            <?php } ?>
                            <option value = "other">Other</option>
                        </select>
                    </div>
                </div>
                <div id="other_info" class="form-group mmar">
                    <label  class="col-sm-3 control-label text-center">Details: </label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control validate[required] text-input" value="" name= "other_details"  style="width:360px !important" />
                    </div>
                </div> -->
                     
                <!-- <div id="paynow_con" style="display: none;">      
                    <div class="form-group text-center">
                       <img src="<?php //echo base_url();?>assets/images/qr_code_new.jpeg" />
                       <div style="font-weight: bold;font-size: 16px;color:red;">Your Purchase Code is :
                           <?php 
                           // echo '<input type="hidden" name="purchase_code" value="'.base64_decode($this->input->get('transaction_id')).'" />';
                           // echo base64_decode($this->input->get('transaction_id'));
                           ?>
                       </div>
                       <div>
                           Please Scan the QR Code on your PayNow App and enter the Purchase Code
                       </div>
                    </div>
                </div> -->
                                    

                <div id="cheque_payment">
                    <div class="form-group mmar">
                        <label  class="col-sm-3 control-label text-center">Cheque Date: </label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control date " value="" name= "cheque_date"  style="width:360px !important" readonly/>
                        </div>
                    </div>
                    <div class="form-group mmar">
                        <label  class="col-sm-3 control-label text-center">Cheque Number: </label>
                        <div class="col-sm-9">
                            <input type = "text" class="form-control validate[required,custom[onlyLetterNumber]] text-input"  style="width:360px !important" name="cheque_num" >
                        </div>
                    </div>
                    <div class="form-group mmar">
                        <label  class="col-sm-3 control-label text-center">Bank Name: </label>
                        <div class="col-sm-9">
                            <input type = "text" class="form-control text-input"  style="width:360px !important" name="bank_num">
                        </div>
                    </div>
                </div>




                <div id="credit_payment">
                    <div class="form-group mmar">
                        <label  class="col-sm-3 control-label text-center">Name on credit card: </label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control validate[required] text-input" value="" name= "cc_name"  style="width:360px !important" />
                        </div>
                    </div>
                    <div class="form-group mmar">
                        <label  class="col-sm-3 control-label text-center">Credit card Number: </label>
                        <div class="col-sm-9">
                            <!--<input type="text" class="form-control validate[required,creditCard] text-input" value="" /> -->
                            <input type="text" class="form-control" name= "cc_number1" value="" maxlength="4" min="1000" size="30" style="width: 90px !important;float: left">
                            <input type="text" class="form-control" name= "cc_number2" value="" maxlength="4" min="1000" size="30" style="width: 90px !important;float: left;margin-left: 5px">
                            <input type="text" class="form-control" name= "cc_number3" value="" maxlength="4" min="1000" size="30" style="width: 90px !important;float: left;margin-left: 5px">
                            <input type="text" class="form-control" name= "cc_number4" value="" maxlength="4" min="1000" size="30" style="width: 90px !important;float: left;margin-left: 5px">
                            <!-- validate[required,custom[integer]] text-input -->
                        </div>
                    </div>
                    <div class="form-group mmar">
                        <label  class="col-sm-3 control-label text-center">Expiry Date: </label>
                        <div class="col-sm-9">
                            <select name="credit_card_exp_month" id="credit_card_exp_month" class="cust_select col-md-2 marl-n" style="width: 180px !important;float: left;margin-right: 15px">
                                        <option value="">-- Select Month --</option>
                                    <?php for($intMonth = 1; $intMonth < 13; $intMonth++) {?>
                                        <option value="<?php echo $intMonth?>"><?php echo $intMonth; ?></option>
                                    <? } ?>
                            </select>
                            <input type = "text" class="form-control"  style="width:180px !important;" name="credit_card_exp_year" id="credit_card_exp_year" placeholder="Enter Year" maxlength="4">
                        </div>
                    </div>
                    <div class="form-group mmar">
                        <label  class="col-sm-3 control-label text-center">Issued Bank Name: </label>
                        <div class="col-sm-9">
                            <input type = "text" class="form-control"  style="width:360px !important" name="issue_bank_num">
                        </div>
                    </div>
                    <!--<div class="form-group mmar">
                        <label  class="col-sm-3 control-label text-center">Card Type: </label>
                        <div class="col-sm-9">
                            <select name="credit_card_type" id="credit_card_type" class="cust_select col-md-2 marl-n" style="width: 180px !important;float: left;margin-right: 15px">
                                <option value="">-- Select Month --</option>
                                <option value="visa">Visa</option>
                                <option value="mastercard">MasterCard</option>
                            </select>
                            <input type = "text" class="form-control"  style="width:180px !important;" name="credit_card_exp_year" id="credit_card_exp_year" placeholder="Enter Year" maxlength="4">
                        </div>
                    </div> -->
                </div>

                <div id="online_payment">
                    <div class="form-group mmar">
                        <label  class="col-sm-3 control-label text-center">Bank name: </label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control " value="" name= "bank_name"  style="width:360px !important" />
                        </div>
                    </div>
                    <div class="form-group mmar">
                        <label  class="col-sm-3 control-label text-center">Online Transaction Id: </label>
                        <div class="col-sm-9">
                            <input type = "text" class="form-control validate[required] text-input"  style="width:360px !important" name="transaction_id">
                        </div>
                    </div>
                    <div class="form-group mmar">
                        <label  class="col-sm-3 control-label text-center">Transaction Date: </label>
                        <div class="col-sm-9">
                            <input type = "text" class="form-control date validate[required] text-input"  style="width:360px !important" name="transaction_date" readonly>
                        </div>
                    </div>
                </div>

<div id="NETS_payment" style="display: none;">
                     
                    <div class="form-group mmar">
                        <label  class="col-sm-3 control-label text-center">Transaction Id: </label>
                        <div class="col-sm-9">
                            <input type = "text" class="form-control validate[required] text-input"  style="width:360px !important" name="NETS_transaction_id">
                        </div>
                    </div>
                    <div class="form-group mmar">
                        <label  class="col-sm-3 control-label text-center">Transaction Date: </label>
                        <div class="col-sm-9">
                            <input type = "text" class="form-control date validate[required] text-input"  style="width:360px !important" name="NETS_transaction_date" readonly>
                        </div>
                    </div>
                </div>

                <div id="cash_payment" class="form-group mmar">
                    <label  class="col-sm-3 control-label text-center">Agent: </label>
                    <div class="col-sm-9">
                        <select class="cust_select col-md-12 marl-n validate[required] text-input" id = "cname" name = "cname">
                            <option value = "">--Select--</option>
                            <?php foreach($agent_details as $campaign) { ?>
                                <option value = "<?php echo $campaign['id']; ?>"><?php echo ucfirst($campaign['first_name']." ".$campaign['last_name']); ?></option>
                            <?php } ?>
                            <option value = "other">Other</option>
                        </select>
                    </div>
                </div>
                <div id="other_info" class="form-group mmar">
                    <label  class="col-sm-3 control-label text-center">Details: </label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control validate[required] text-input" value="" name= "other_details"  style="width:360px !important" />
                    </div>
                </div>

                <input type="hidden" name="encSubscriberId" value="<?php echo $strSubscriberId; ?>" >
                <input type="hidden" name="en_Transaction_id" id="ensubscription_id" value="<?php echo $strTransactionId; ?>" >
                <input type="hidden" name="currency" value="<?php echo $strCurrency; ?>" >
                <div class="form-group">
                    <div class="col-sm-offset-4 col-sm-8">
                        <button type="submit" class="btn btn-primary" id ="btnSubmit">Submit</button>
                        <a class="btn" href="<?php echo base_url(); ?>index.php/subscriber/preview/?user_id=<?php echo $strSubscriberId; ?>"> <button type="button" class="btn btn-primary">Pay Later</button></a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>


<!-- // Modal body END -->
</div>
</div>
</div>
<script src="<?php echo base_url();?>assets/js/main.js" type="text/javascript"></script>
<script src="<?php echo base_url();?>assets/js/custom.js" type="text/javascript"></script>
<script src="<?php echo base_url();?>assets/plugins/forms_elements_multiselect/js/jquery.multi-select.js?v=v2.0.0-rc1&sv=v0.0.1.2"></script>
<script src="<?php echo base_url();?>assets/plugins/forms_elements_bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_bootstrap-select/bootstrap-select.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_bootstrap-select/bootstrap-select.init.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_fuelux-radio/fuelux-radio.init.js"></script>
<script src="<?php echo base_url();?>assets/components/forms_elements_multiselect/multiselect.init.js?v=v2.0.0-rc1&sv=v0.0.1.2"></script>
<script src="<?php echo base_url();?>assets/js/jquery.validationEngine-en.js" type="text/javascript"></script>
<script src="<?php echo base_url();?>assets/js/jquery.validationEngine.js" type="text/javascript"></script>

<script>
    $(document).ready(function() {

        $("#cash_payment").hide();
        $("#cheque_payment").hide();
        $("#credit_payment").hide();
        $("#online_payment").hide();
        $("#other_info").hide();

        $("#subscriber_type").change(function(){
            $("#cash_payment").hide();
            $("#cheque_payment").hide();
            $("#credit_payment").hide();
            $("#online_payment").hide();
            $("#other_info").hide();
            $("#paynow_con").hide();

            var val = $("#subscriber_type").val();
            if (val == 1) {
                $("#cash_payment").show();
            } else if(val == 2) {
                $("#cheque_payment").show();
                $("#cash_payment").show();
            } else if(val == 3) {
                $("#credit_payment").show();
                $("#cash_payment").show();
            } else if(val ==4) {
                $("#online_payment").show();
                $("#cash_payment").show();
            } else if(val ==5) {
                $("#cash_payment").show();
            } else if(val ==6) {
                $("#cash_payment").show();
            } else if(val ==7) {
                $("#cash_payment").show();
            } else if(val == 8) {
                $("#cash_payment").show();
            } else if(val == 9) {
                $("#NETS_payment").show();
                $("#cash_payment").show();
            }else if(val == 10) {
                //$("#paynow_con").show();
                $("#cash_payment").show();
            }else if(val == 11) {
                //$("#paynow_con").show();
                $("#cash_payment").show();
            }
        });

        $("#cname").change(function(){
            $("#other_info").hide();

            var val = $("#cname").val();
            if (val == 'other') {
                $("#other_info").show();
            }
        });

        $("#edit_magezine1").validationEngine();
        $("#edit_magezine").validationEngine();
        $('.date').datepicker();


        $("#magazine_code").focus(function(){
            var nameValue = $("#sub_email").val();
            if (nameValue == "") {
                $('#sub_email').focus();
            }
        });
        // $("#sub_email").autocomplete({
        //     source:'<?php echo base_url()?>index.php/subscriber/get_subscriber/',
        //     minLength:1
        // });

        // $("#magazine_code").autocomplete({
        //     //source:'<?php echo base_url()?>index.php/magazine/get_all_magazines/?name='+ name_Value,
        //     //minLength:1
        //     source: function(request, response) {
        //         $.getJSON("<?php echo base_url()?>index.php/magazine/get_all_magazines", { var_name: $("#sub_email").val(), term : $("#magazine_code").val()},
        //             response);
        //     },
        //     minLength: 1
        // });



    });
</script>

