<link rel="stylesheet" href="<?php echo base_url();?>assets/css/cust_paginition.css" type="text/css" />
<script src="<?php echo base_url(); ?>assets/library/jquery/jquery.min.js"></script> 
<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="#addMagazine" class="btn btn-inverse pull-right mar" data-toggle="modal" onclick="return add_promotion()"><i class="fa fa-fw fa-plus"></i>Add New</a>
												<h4 class="heading">Magazine</h4>

											</div>
                                            <div class="widget-body">
                                                <form action="" method="GET" >
                                                    <div class="col-md-12 selectBox">
                                                        <div class="col-xs-4 col-md-2 bot-mar">
                                                            <label class="col-xs-12">Currency</label>
                                                            <select class="cust_select col-xs-12" name = "sel_currency">
                                                                <option value = "">--All--</option>
                                                                <?php foreach ($all_currencies as $currency) {?>
                                                                    <option value = "<?php echo $currency['id']?>"
                                                                        <?php if($arrGetData['sel_currency'] == $currency['id']) {?> selected
                                                                        <?php } ?>><?php echo $currency['name']?></option>
                                                                <?php } ?>

                                                            </select>
                                                        </div>
                                                        <div class="col-xs-4 col-md-2 bot-mar">
                                                            <label class="col-xs-12">Category</label>
                                                            <select class="cust_select col-xs-12" name = "sel_category">
                                                                <option value = "">--All--</option>
                                                                <?php foreach ($all_categories as $categories) {?>
                                                                    <option value = "<?php echo $categories['id']?>"
                                                                        <?php if($arrGetData['sel_category'] == $categories['id']) {?> selected
                                                                        <?php } ?>><?php echo $categories['name']?></option>
                                                                <?php } ?>
                                                            </select>
                                                        </div>

                                                        <div class="col-xs-4 col-md-2 bot-mar">
                                                            <label class="col-xs-12">Language</label>
                                                            <select class="cust_select col-xs-12" name = "sel_language">
                                                                <option value = "">--All--</option>
                                                                <?php foreach ($all_languages as $languages) {?>
                                                                    <option value = "<?php echo $languages['id']?>"
                                                                        <?php if($arrGetData['sel_language'] == $languages['id']) {?> selected
                                                                        <?php } ?>><?php echo $languages['name']?></option>
                                                                <?php } ?>
                                                            </select>
                                                        </div>

                                                        <div class="col-xs-4 col-md-2 bot-mar">
                                                            <label class="col-xs-12">Status</label>
                                                            <select class="cust_select col-xs-12" name = "sel_status">
                                                                <option value = "">--All--</option>
                                                                <option value="live"
                                                                    <?php if($arrGetData['sel_status'] == 'live') {?> selected
                                                                    <?php } ?>
                                                                    >Live</option>
                                                                <option value="suspended"
                                                                    <?php if($arrGetData['sel_status'] == 'suspended') {?> selected
                                                                    <?php } ?>
                                                                    >Suspended</option>
                                                                <option value="closed"
                                                                    <?php if($arrGetData['sel_status'] == 'closed') {?> selected
                                                                    <?php } ?>
                                                                    >Closed</option>
                                                            </select>
                                                        </div>

                                                        <div class="col-xs-4 col-md-2 bot-mar">
                                                            <label class="col-xs-12">&nbsp;</label>
                                                            <div>
                                                                <button type="submit" class="btn btn-primary">Search</button>
                                                            </div>
                                                        </div>
                                                </form>
                                                <div class="clearfix"></div>
                                            </div>
                                            <div class="widget-body">
												<table class="table table-white table-vertical-center margin-none table-striped footable">
													<thead>
														<tr>

															<th data-class="highlight" class="text-left">Magazine ID</th>
															<th  class="text-left">Magazine Title</th>
															<th data-hide="phone" class="text-left">Category</th>
															<th data-hide="phone" class="text-left">Language</th>
															<th data-hide="phone" class="text-left">Currency</th>

															<th class="text-left">Status</th>
															<th class="text-left">Edit</th>
														</tr>
													</thead>
													<tbody>
													<?php
                                                    if(count($details) > 0) {
														foreach ($details as $arrmagezine){ ?>
															<tr>
																	<td class="text-left" ><a href="<?php echo base_url();?>index.php/magazine/preview?magezine_id=<?php echo base64_encode($arrmagezine['id']);?>" data-toggle="modal"><?php echo $arrmagezine['magezine_id'];?></a></td>
																	<td class="text-left" ><?php echo ($arrmagezine['name']) ? ucfirst($arrmagezine['name']) : ucfirst($arrmagezine['magezine_id']); ?></td>
																	<td class="text-left"><?php echo ucfirst($arrmagezine['category_name']);?></td>
																	<td class="text-left"><?php echo ucfirst($arrmagezine['language_name']);?></td>
																	<td class="text-left"><?php echo ucwords($arrmagezine['currency_name']);?></td>
		
																	<td class="text-left"><?php echo $arrmagezine['status'];?></td>
                                                                    <?php $intEncodedId =  base64_encode($arrmagezine['id']);?>
																	<td class="text-left">
                                                                        <?php if ((int) $arrmagezine['id'] > 0) {?>
                                                                        <a href="#editMagazine" data-toggle="modal" onclick="return edit_promotion('<?php echo $intEncodedId; ?>')">
                                                                            <i class="fa fa-pencil"></i>
                                                                        </a>
                                                                        <?php } else {?>
                                                                            <a href="#editMagazine">
                                                                                <i class="fa fa-pencil"></i>
                                                                            </a>
                                                                        <?php } ?>
                                                                    </td>

															</tr>
													<?php }?>
														</tbody>
													</table>
                                                <div class="text-center innerAll border-top pagination">
                                                    <?php echo $pagination; ?>
                                                </div>
													<?php } else { ?>
														<tr>
															<td class="text-center" colspan = "7" align = "center">Sorry, No Magazine found</td>
														</tr>
														</tbody>
													</table>
													<?php }?>
													
												
											</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="addMagazine" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content" id="tran_preview">

        </div>
    </div>
</div>
<div class="modal fade" id="editMagazine" 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/js/subscriber.js"></script>
<script type="application/javascript">
    function add_promotion()
    {
        var system_base_url = $("#system_base_url").val();
        var html = "<div align='center'><img src='"+system_base_url+"assets/images/loader.gif'/></div>";
        $("#tran_preview").html(html);
        $.ajax({
            url:system_base_url + "index.php/magazine/add_magezine",
            'type' : 'GET',
            success:function(result){
                $("#tran_preview").html(result);
                //alert(result);
            }
        });
    }

    function edit_promotion(intPromotionId)
    {
        var system_base_url = $("#system_base_url").val();
        var html = "<div align='center'><img src='"+system_base_url+"assets/images/loader.gif'/></div>";
        $("#edit_promo").html(html);
        $.ajax({
            url:system_base_url + "index.php/magazine/edit_magezine",
            'data' : {
                'magezine_id' :intPromotionId
            },
            'type' : 'GET',
            success:function(result){
                $("#edit_promo").html(result);
            }
        });
    }
</script>