<!-- Main Content -->



<div class="page-wrapper">



    <div class="container-fluid pt-25">



    	<div class="row">



    		<div class="col-md-12">



    			<div class="alert alert-success alert-dismissible" role="alert" <?php if($this->session->flashdata('message')==''){ ?> style="display:none" <?php } ?> >



          			<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>



          			<?php echo $this->session->flashdata('message'); ?>



        		</div>



    		</div>



    	</div>



		<!-- Row -->



		<div class="row">



			<div class="col-sm-12">



				<div class="panel panel-default card-view">



					<div class="panel-heading">



						<div class="col-md-4">

							<h6 class="panel-title txt-dark">All Projects</h6>

						</div>

						<div class="col-md-8">

						</div>



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



					</div>



					<div class="panel-wrapper collapse in">



						<div class="panel-body">



							<div class="table-wrap">



								<div class="table-responsive">



									<table id="datable_1-1" class="table table-hover table-bordered display  pb-30" >



										<thead align="center">



                                            <tr><td colspan="2"><?php echo (isset($h1)?$h1:""); ?></td>



                                                <td colspan="3">



                                                    <div class="col-md-4">&nbsp;</div>



                                                    <div class="col-md-8">



                                                        <select id="admin_length" class="pull-right form-control">



                                                            <option value="10" <?php echo ($this->perPage==10)?'selected':""; ?>>10</option>



                                                            <option value="20" <?php echo ($this->perPage==20)?'selected':""; ?>>20</option>



                                                            <option value="50" <?php echo ($this->perPage==50)?'selected':""; ?>>50</option>



                                                            <option value="100" <?php echo ($this->perPage==100)?'selected':""; ?>>100</option>



                                                            <option value="250" <?php echo ($this->perPage==250)?'selected':""; ?>>250</option>



                                                            <option value="500" <?php echo ($this->perPage==500)?'selected':""; ?>>500</option>

                                                            <option value="1000" <?php echo ($this->perPage==1000)?'selected':""; ?>>1000</option>



                                                        </select>



                                                    </div>



                                                </td>



                                            </tr>



                                            <tr>

                                            	<td colspan="5" style="color: red;"><?php echo (isset($h2)?$h2:""); ?></td>

                                            </tr>



                                        </thead>



										<!-- <thead>



							                <tr>



							                  <th>SR.No.</th>



							                  <th>Image</th>



							                  <th>Category</th>

							                  <th>Featured</th>



							                  <th>Action</th>



							                </tr>



							            </thead> -->







							            <tbody>

							            	<tr>

				            					<td class="tbody" colspan="5">

									                <?php if(!empty($gallery)){ foreach ($gallery as $key => $value): ?>

									                	<div id="<?php echo "gallery_project_".$value['id']; ?>" class="panel panel-default orderby mb-10" data-order="<?php echo $value['id']; ?>">

							                				<div class="panel-body pa-0">

									                			<table class="table mb-0">

													                <tr>

													                  <td style="width:10%;"><?php echo $key+1; ?></td>

													                  <td style="width:15%;">

													                  	<?php if($value['feat_image']!=''){ ?>

												                            <img src="<?php echo base_url($value['feat_image']); ?>" alt="image" style="width:100px;">

											                            <?php } ?>

													                  </td>
													                  <td style="width:30%">
													                  	<p><strong><?php echo $value['title']; ?></strong></p>
													                  	<!-- <p><?php //echo $value['completed_date']; ?></p> -->
													                  	<?php $catname = $this->common->getsData('gallery_category',array('id'=>$value['category'])); ?>
													                  	<p><?php echo (isset($catname['category']))?$catname['category']:''; ?></p>
													                  </td>
													                  <td style="width:20%;">
													                  	<a href="<?php echo base_url(A.'/all-gallery?pid='.$value['projectid']); ?>" target="_blank">View Gallery</a>
													                  </td>

													                  <td style="width:20%;">Featured <input type="checkbox" name="isFeatured" class="isFeatured" value="1" data-id="<?php echo $value['id']; ?>" <?php echo ($value['isFeatured']==1)?'checked':""; ?> /></td> 

													                  <td style="width:10%;">

													                    <a href="<?php echo base_url(A."/edit-gallery/".$value['projectid']); ?>" class="text-inverse pr-10" data-value=""><i class="fa fa-pencil-square fa-lg"></i></a>

													                    <a href="javascript:void(0)" class="text-inverse gallery_delete" data-table="gallery_project" data-value="<?php echo "gallery_projectid_".$value['id']; ?>" data-image='' data-id="<?php echo $value['id']; ?>"><i class="fa fa-trash-o fa-lg"></i></a>

													                  </td>

													                </tr>

													            </table>

													        </div>

													    </div>

							                		<?php endforeach; } ?>

							                	</td>

							                </tr>

							            </tbody>



									</table>



								</div>



							</div>



						</div>



						<div class="panel-footer clearfix">



                            <div class="row">



                                <div class="col-md-12">



                                    <div class="text-center"><?php echo (isset($links))?$links:""; ?></div>



                                </div>



                            </div>



                        </div>



					</div>



				</div>	



			</div>



		</div>



		<!-- /Row -->



	</div>



<script type="text/javascript">



	var site_url = "<?php echo base_url(); ?>";



	var urlLink = "<?php echo A; ?>";







	$(".gallery_delete").on("click",function(){



		var table = $(this).attr('data-table');



	    var id = $(this).attr('data-id');



	    var pimage = $(this).attr('data-image');



	    var ok = confirm("Are you sure you want to delete? Deleted records are not retrievable.");



	    if (ok) {



	        $.ajax({



	            url: site_url+urlLink+'/ajaxDelete',



	            type:'POST',



	            data:'id='+id+'&pimage='+pimage+'&table='+table,



	            success: function(data){



	                location.reload();



	            },



	        });



	    }



	});







	$('.isFeatured').change(function(){



	    var td = this.checked ? '1' : '0';



	    var pid = $(this).attr('data-id');



	    



	    $.ajax({



	        url: site_url+urlLink+"/setFeaturedGalleryProject",



	        type: "POST",



	        data: "id="+pid+"&isFeatured="+td,



	        success: function(data){  



	        	alert('Status Update');

	        	// location.reload();



	        }



	    });



	});



</script>

<script type="text/javascript">

    var path = "<?php echo base_url(A); ?>";

    $("#admin_length").on("change",function(){

        var length = $(this).val();

        $.ajax({

            url: path+"/AdminSearchLength",

            type:"POST",

            data:"length="+length,

            success: function(result){

                if(result==1){

                    window.location.reload();

                }

            }

        });

    });

    $("#category").on("change",function(){

        var cid = $(this).val();

        $.ajax({

            url: path+"/getSubCatByCategory",

            type:"POST",

            data:"cid="+cid,

            success: function(result){

                $('#subcategory').html(result.html);

            }

        });

    });

</script>

<script>

	$(function() {

      $('.tbody').sortable({

        delay: 150,

        stop: function() {

          var div = [];

          $('.orderby').each(function() {

            var id = $(this).attr('data-order');

            if(id!='undefined'){

              div.push(id);

            }

          });

            var site_url = '<?php echo base_url(); ?>';

            $.ajax({

              url: site_url+urlLink+"/updateGalleryProjectOrder",

              type: "POST",

              dataType:"json",

              data: "div="+div,

              success: function(result){

                

              }

            });

        }

      });

  	});

</script>