<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 class="" id="addPromo">
    <div class="modal-dialog" style="width:1150px">
        <div class="modal-content">
            <!-- Modal heading -->
            <div class="modal-header" align = "left">
                <!-- <a class="btn  pull-right mar" href="<?php //echo base_url(); ?>index.php/promotion/promotion_list"> vin</a> -->
                <a href="<?php echo base_url();?>index.php/subscriber/fnSubscribeCampaign/?subscriber_id=<?php echo $strGivenSubId; ?>&tr_id=<?php echo $this->input->get('tr_id');?>" class=" pull-right mar" onclick="return fnCheckSelectedContent();"><button class="btn btn-info" type="button">Subscribe Campaign</button></a>
                <h4 class="modal-title" align="center">Subscribe Magazines for <span class="username_display"><?php echo $strUserName; ?></span></h4>
            </div>
            <!-- // Modal heading END -->
            <!-- Modal body -->
            <div class="modal-body">
                <div class="innerAll">
                    <div class="innerLR">
                        <form class="form-horizontal" role="form" id = "add_promo" action = "<?php echo base_url(); ?>index.php/subscriber/subscribe_magazine" method = "post">
                            <?php $this->load->view('admin/flashdata_admin'); ?>
                            <input type="hidden" value="<?php echo $this->input->get('tr_id');?>" name="tr_id"/>
                            <div class="form-group mmar">
                                <label  class="col-sm-8 control-label text-center" for="myDate" style="margin-left: 18%"><small>Please click on Add Magazine link and select magazines to subscribe</small> </label>
                            </div>
                            <div class="form-group mmar">
                                <div class="col-sm-17">
                                    <table class="table table-white table-vertical-center margin-none table-striped footable" id="list_new_magazines">
                                        <thead>
                                        <tr>
                                            <th  class="text-center">Magazine Code</th>
                                            <th  class="text-center">No Of year</th>
                                            <th  class="text-center">Amount</th>
                                            <th  class="text-center">Start Date</th>
                                            <th  class="text-center">End Date</th>
                                            <th  class="text-center">Start Issue</th>
                                            <th  class="text-center">End Issue</th>
                                            <th  class="text-center">Total Issues</th>
                                            <th  class="text-center">Action</th>

                                        </tr>
                                        </thead>
                                        <tbody>
                                        </tbody>
                                    </table>
                                </div>
                            </div>

                            <hr>
                            <div id="newMagazineList">

                            </div>
                            <div class="form-group mmar" id="attach_mag_list">


                            </div>
                            <br>

                            <div id="promo_issue_block" class="formErrorContent" align="center"></div>

                            <a href="#nnn" id="add_new_Magazine" data-toggle="modal" onclick="return add_new_promotion();"><i class="fa fa-fw fa-plus"></i>Add Magazines</a>
                            <input type="hidden" id="num_mag" value="0" />
                            <br><br>
                            <div class="form-group">
                                <div class="col-sm-offset-4 col-sm-8">
                                    <input type="hidden" id="system_base_url" value="<?php echo base_url();?>">
                                    <input type="hidden" id="previous_id" value="">
                                    <input type="hidden" name="subscriber_id" id="subscriber_id" value="<?php echo $strGivenSubId;?>">
                                    <button type="submit" class="btn btn-primary" id="sub1">Submit</button>
                                    <a class="btn" href="<?php echo base_url(); ?>index.php/promotion/promotion_list"> <button type="button" class="btn btn-primary">Cancel</button></a>
                                </div>
                            </div>

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

            <!-- // Modal body END -->
        </div>
    </div>

    <input type="hidden" id="system_base_url" value="<?php echo base_url();?>" />
    <div class="modal fade" id="nnn" data-backdrop="static">
        <div class="modal-dialog">
            <div class="modal-content" id="tran_preview2">

            </div>
        </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/promotion.js" type="text/javascript"></script>
<script src="<?php echo base_url();?>assets/js/new_calender.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/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() {
        $("#add_promo").validationEngine();

    });

    function add_new_promotion()
    {
        /**var arrMagazines = new Array();
         $("input[name^='magezine_code[]']").each(function(index, element){
            arrMagazines.push($(element).val());
        });*/
        //var strIds = arrMagazines.join();
        var system_base_url = $("#system_base_url").val();
        var html = "<div align='center'><img src='"+system_base_url+"assets/images/loader.gif'/></div>";
        $("#tran_preview2").html(html);
        $.ajax({
            url:system_base_url+"index.php/promotion/add_new_magazine",
            'data' : {
                //'prev_ids' :strIds,
                //'no_of_years': NumberOfYears
            },
            'type' : 'GET',
            success:function(result){
                $("#tran_preview2").html(result);
            }
        });
    }

    function fnCheckSelectedContent()
    {
        var intCountOfMagazines = $(":input[name='magezine_code[]']").length;
        if (intCountOfMagazines > 0) {
            alert("All the selected magazine details will be lost if you proceed !!!");
            return false;
        }
        var flag = confirm("Are you sure to proceed other way ?");
        return flag;
    }

</script>

