<link rel="stylesheet" href="<?php echo base_url();?>assets/js/validationEngine.jquery.css" type="text/css" />
<div class="" id="addPromotion">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header" align = "left">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h3 class="modal-title">Add new magazine details</h3>
            </div>
            <div class="modal-body">
                <div class="innerAll">
                    <div class="innerLR">
                        <form class="form-horizontal" role="form" id = "addCampaign_promo1" action = "<?php echo base_url(); ?>index.php/promotion/add_promotion" method = "post">
                            <?php $this->load->view('admin/flashdata_admin'); ?>
                            <?php if(count($magezine) > 0) {?>
                                <div id="magazine_list">
                                    <div class="form-group mmar">
                                        <label  class="col-sm-3 control-label text-center">Select Magazine: </label>
                                        <div class="col-sm-9">
                                            <select class="marl-n validate[required] cust_select" name = "magazine" id="addCampaignmagazine" style="margin-left: 3px" required="required">
                                                <option value="">-- Select --</option>
                                                <?php foreach($magezine as $objMagezine) {?>
                                                    <option value="<?php echo $objMagezine['id'] ?>"><?php echo $objMagezine['magezine_id']; ?></option>
                                                <?php } ?>
                                            </select>
                                        </div>
                                    </div>
                                    <!-- <div class="form-group mmar">
                                        <label  class="col-sm-3 control-label text-center">Number of years subscription: </label>
                                        <div class="col-sm-9">
                                            <input type="text" value="<?php echo $strNOOfYears;?>" class="form-control" name = "number_of_year" id = "number_of_year" readonly/>
                                        </div>
                                    </div> -->
                                    <div class="form-group mmar">
                                        <label  class="col-sm-3 control-label text-center">No. Of years: </label>
                                        <div class="col-sm-9">
                                            <select name="number_of_year" id="addCampaignnumber_of_year" class="form-control validate[required]">
                                                <option value="">---Select Year---</option>
                                                <?php for($intCounter=1; $intCounter <= 12; $intCounter++) {?>
                                                    <option value="<?php echo $intCounter; ?>"><?php echo $intCounter; ?></option>
                                                <?php } ?>
                                            </select>

                                        </div>
                                    </div>
                                    <div class="form-group mmar" style="margin-top: 10px">
                                        <label  class="col-sm-3 control-label text-center">Amount: </label>
                                        <div class="col-sm-9">
                                            <input type="text" value="" class="form-control validate[required,min[1]] text-input" name = "amount" id = "addCampaigncamp_amount" required="required"/>
                                        </div>
                                    </div>
                                    <div class="form-group mmar">
                                        <label  class="col-sm-3 control-label text-center" for="myDate">Subscription Start Date: </label>
                                        <div class="col-sm-9">
                                            <input type="text" value="" class="form-control date" data-date-format="d-M-yyyy" name = "start_date" id = "addCampaigndate1" readonly required="required"/>
                                        </div>
                                    </div>
                                    <div class="form-group mmar">
                                        <label  class="col-sm-3 control-label text-center" for="myDate">Subscription   End Date: </label>
                                        <div class="col-sm-9">
                                            <input type="text" value="" class="form-control date" data-date-format="d-M-yyyy" name = "end_date" id = "addCampaigndate2" readonly required="required"/>
                                        </div>
                                    </div>
                                    <div class="form-group mmar">
                                        <label  class="col-sm-3 control-label text-center">Start Issue Number: </label>
                                        <div class="col-sm-9">
                                            <!-- <input type="text" value="" class="form-control validate[required,custom[integer],max[999], min[1]] text-input" name = "start_issue" id = "addCampaignissue1" required="required"/> -->
                                            <input type="text" value="" class="form-control validate[required] text-input" name = "start_issue" id = "addCampaignissue1" required="required"/>
                                        </div>
                                    </div>
                                    <div class="form-group mmar">
                                        <label  class="col-sm-3 control-label text-center">End Issue Number: </label>
                                        <div class="col-sm-9">
                                            <input type="text" value="" class="form-control validate[required] text-input" name = "end_issue" id = "addCampaignissue2" required="required"/>
                                        </div>
                                    </div>
                                    <div class="form-group mmar">
                                        <label  class="col-sm-3 control-label text-left">Total Issue: </label>
                                        <div class="col-sm-9">
                                            <input class="form-control validate[required,custom[integer],min[1]] text-input" type="text" id="edit_no_issues" name="no_issues" value=""/>
                                        </div>
                                    </div>
                                    <!-- <a href="javascript:void(0)" id="add_new_Magazine"><i class="fa fa-fw fa-plus"></i></a> -->
                                </div>
                                <div id="promo_issue_error" class="formErrorContent" align="center"></div><br>
                                <div id="year_error" class="formErrorContent" align="center"></div>
                                <input type="hidden" value="add_new" id="purpose" />
                                <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="">
                                        <button type="submit" class="btn btn-primary" id="btnSubmit">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>
                            <?php } else {?>
                                Sorry No Magazines found !!!!!!
                            <?php } ?>
                        </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/promotion.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/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() {
        $("#addCampaign_promo1").validationEngine();
        /*$("#add_promo1").submit(function(){

         });*/

        $("#magazine").change(function(){
            var system_base_url = $("#system_base_url").val();
            var strMagazineId = $("#magazine").val();
            var NumberOfYear =  $("#number_of_year").val();
            if (strMagazineId != "") {
                $.ajax({
                    url:system_base_url+"index.php/promotion/fnGetMagazineAmount",
                    'type' : 'GET',
                    async:false,
                    'data' : {
                        'strMagazineId' :strMagazineId,
                        'NumberOfYear' : NumberOfYear
                    },
                    success:function(result){
                        $("#camp_amount").val(result);

                    }
                });
            }
        });
$(document).on('blur','#addCampaigncamp_amount',function(){
            var pkg_values = $(this).val();
            if(pkg_values != ''){
                var chk2 = strpos(pkg_values,'.');
                if(chk2 == -1){
                    $(this).val(pkg_values+'.00');
                }
            }
        });

   function strpos(str,test) {
            var str = str;
            var n = str.indexOf(test);
            return n;
        }

    });
</script>
