<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="layout-app">
    <div class="container"><div class="row row-app">
            <div class="col-md-12">
                <div class="col-separator col-separator-first col-unscrollable bg-none">
                    <div class="col-table">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="widget">
                                    <?php $this->load->view('admin/flashdata_admin'); ?>
                                    <div class="widget-head">
                                        <a href="<?php echo base_url(); ?>index.php/promotion/add_promotion" data-toggle="modal" class="btn btn-inverse pull-right mar"><i class="fa fa-fw fa-plus"></i>Add New</a>
                                        <h4 class="heading">Campaign Codes</h4>

                                    </div>
                                    <div class="clearfix"></div>

                                    <div class="widget-body">
                                        <div>
                                            <form action="" method="GET" >
                                                <div class="col-md-12 selectBox">
                                                    <div class="col-sm-3 bot-mar">
                                                        <label>Enter Campaign Code/Name</label>
                                                        <input type="text" class="form-control" name = "camp_code" value = "<?php echo $strCampCode; ?>" placeholder="Campaign Code/Name" style="background-color: #A9A9A9;color: white"/>
                                                    </div>

                                                    <div class="col-sm-2 bot-mar">
                                                        <label>&nbsp;</label>
                                                        <div>
                                                            <button type="submit" class="btn btn-primary">Search</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </form>
                                            <div class="clearfix"></div>
                                        </div>
                                    </div>
                                    <table class="table table-white table-vertical-center margin-none table-striped footable">
                                        <thead>
                                        <tr>
                                            <th data-class="highlight" class="text-left">Campaign Name</th>
                                            <th  class="text-left">Campaign Code</th>
                                            <th  class="text-left">Description</th>
                                            <th  class="text-left">Magazines Details</th>
                                            <th  class="text-left">Transactions Details</th>
                                            <th  class="text-left">Copy Campaign</th>
                                            <th class="text-left">Edit</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <?php  if(count($details) > 0) {
                                            foreach ($details as $arrPromo){
                                                ?>
                                                <?php $strDecodedId = base64_encode($arrPromo['id']); ?>
                                                <tr>
                                                    <td class="text-left" ><?php echo $arrPromo['name']; ?></td>
                                                    <td class="text-left" ><?php echo $arrPromo['campeign_code']; ?></td>
                                                    <td class="text-left" ><?php echo $arrPromo['description']; ?></td>
                                                    <td class="text-left">
                                                        <a href="<?php echo base_url(); ?>index.php/promotion/fnGenerateMagazineReport/?id=<?php echo $strDecodedId; ?>">
                                                            <i class="fa fa-2x fa-file-excel-o" title="Details of Magazine using Campaign"></i>
                                                        </a>
                                                    </td>
                                                    <td class="text-left">
                                                        <a href="<?php echo base_url(); ?>index.php/promotion/fnGenerateTransactionReport/?id=<?php echo $strDecodedId; ?>">
                                                            <i class="fa fa-2x fa-file-excel-o" title="Details of Transaction using Campaign"></i>
                                                        </a>
                                                    </td>
                                                    <td class="text-left">
                                                        <a href="<?php echo base_url(); ?>index.php/promotion/fnCopyCampaign/?id=<?php echo $strDecodedId; ?>">
                                                            <i class="fa fa-2x fa-files-o"></i>
                                                        </a>
                                                    </td>

                                                    <td class="text-left"><a href="<?php echo base_url(); ?>index.php/promotion/edit_promotion?promotion_id=<?php echo $strDecodedId;?>"><i class="fa fa-pencil"></i></a></td>
                                                </tr>
                                            <?php }
                                        } else {?>
                                            <tr>
                                                <td class="text-center" colspan = "6">No Campaign found</td>
                                            </tr>
                                        <?php } ?>
                                        </tbody>
                                    </table>
                                    <div class="text-center innerAll border-top pagination">
                                        <?php echo $cust_Pagination; ?>
                                    </div>
                                </div>
                                <!-- // END TRENDS -->
                            </div>


                        </div>

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

        </div>
    </div>
</div>
<div class="modal fade" id="editPromo" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content" id="edit_promo">

        </div>
    </div>
</div>
<script src="<?php echo base_url(); ?>assets/library/jquery/jquery.min.js"></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 src="<?php echo base_url(); ?>assets/js/subscriber.js"></script>
<script type="application/javascript">
    function add_promotion()
    {
        $.ajax({
            url:"<?php echo base_url(); ?>index.php/promotion/add_promotion",
            'type' : 'GET',
            success:function(result){
                $("#tran_preview").html(result);
                //alert(result);
            }
        });
    }

    function edit_promotion(intPromotionId)
    {
        $.ajax({
            url:"<?php echo base_url(); ?>index.php/promotion/edit_promotion",
            'data' : {
                'promotion_id' :intPromotionId
            },
            'type' : 'GET',
            success:function(result){
                $("#edit_promo").html(result);
            }
        });
    }
</script>