File "images.php"

Full Path: /home/ichhrkpd/public_html/idcm_old/application/views/images.php
File size: 6.22 KB
MIME-type: text/html
Charset: utf-8

 <?php 
	require_once('add_edit_image.php');
	 $sl =1;
	 $img_data = isset($img_data) ? $img_data : array();
	 
	 $msg = isset($msg)?$msg:'';
	 $msg_type = isset($msg_type)?$msg_type:'';
	 $this->session->UnsetFlashData();
 ?>
 

 
       <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            Images
          </h1>
          
        </section>
 
        <section class="content">
          <div class="row">
          <?php //GPrint($rtype_data);?>
            <div class="col-xs-12">
              <div class="box">
                <div class="box-header">
                  
                  <button class="btn btn-primary btn-xs pull-right" type="button"
            		data-img_id="N"
            		data-edit= "N"
            		data-toggle="modal" 
            		data-target="#add_edit_image" >
                    <i class="fa fa-plus"></i> Add Images
               	</button>
                </div><!-- /.box-header -->
                <div class="box-body"><div class="table-responsive">
                  <table id="example" class="table table-bordered table-hover">
                    <thead>
						<tr>
							<th>sl#</th>
							<th>Type</th>
							<th>Status</th>
							<th>Image</th>
							<th>Image Link</th>
							<th>Action</th>
						</tr>
                    </thead>
                    <tbody>
                    
                    
                    <?php foreach ($img_data as $id){
                        $image_link=base_url()."img/Image_not_available.png";
                        $image_link_short=base_url()."img/Image_not_available.png";
                        
                        $down_file_name = $id->img_id.'.jpg';
        				if($id->img_type == 'G'){
        				    $physical_link = BASEPATH."../img/gallery/$down_file_name";
        				}elseif($id->img_type == 'S'){
        				    $physical_link = BASEPATH."../img/slide/$down_file_name";
        				}else{
        				    $physical_link = BASEPATH."../img/others/$down_file_name";
        				}
        				
        				$image_found = 'N';
        				
        				if(file_exists($physical_link)){
        				    $image_found = 'Y';
        				}
                        
                    	$type = '';
                    	if($id->img_type == 'G'){
                    		$type = "<span class='badge bg-green'>Gallery</span>";
                    		$image_link_short=base_url()."img/gallery/$id->img_id".'.jpg';
                    		if($image_found == 'Y'){
                    		   $image_link=base_url()."img/gallery/".$id->img_id.".jpg?v=".filemtime(BASEPATH."../img/gallery/".$id->img_id.".jpg"); 
                    		}
                    		
                    	}elseif($id->img_type == 'S'){
                    		$type = "<span class='badge bg-yellow'>Slide</span>";
                    		$image_link_short=base_url()."img/slide/$id->img_id".'.jpg';
                    		if($image_found == 'Y'){
                    		   $image_link=base_url()."img/slide/".$id->img_id.".jpg?v=".filemtime(BASEPATH."../img/slide/".$id->img_id.".jpg"); 
                    		}
                    	}elseif($id->img_type == 'O'){
                    		$type = "<span class='badge bg-aqua'>Others</span>";
                    		$image_link_short=base_url()."img/others/$id->img_id".'.jpg';
                    		if($image_found == 'Y'){
                    		    $image_link=base_url()."img/others/".$id->img_id.".jpg?v=".filemtime(BASEPATH."../img/others/".$id->img_id.".jpg");
                    		}
                    	}else{
                    	    $type = "<span class='badge bg-red'>Unknown</span>";
                    	}
                    	
                    	if($image_found == 'N'){
                    	    $image_link=base_url()."img/Image_not_available.png";
                            $image_link_short=base_url()."img/Image_not_available.png";
                    	}
                    	
                    	$status = '';
                    	if($id->status == 'A'){
                    		$status = "<span class='badge bg-green'>Active</span>";
                    	}else{
                    		$status = "<span class='badge bg-red'>Inactive</span>";
                    	}
                    	
                    	?>  
                      <tr>
                      	<td><?php echo $sl; ?></td>
                      	<td><?php echo $type;?></td>
                        <td><?php echo $status;?></td>
                        <td><img width="100" src="<?php echo $image_link;?>" class="" alt="User Image"></td>
                        <td><?php echo $image_link_short; ?></td>
						<td nowrap>
							<button class="btn-xs btn-success" type="button"
			            		data-img_id="<?php echo $id->img_id; ?>"
			            		data-edit= "Y"
			            		data-toggle="modal" 
			            		data-target="#add_edit_image" >
			                    <i class="fa fa-edit"></i> Edit
			               	</button>
				        </td>
                      </tr>
                    <?php $sl++;}?>  
                    </tbody>
                  </table></div>
                </div><!-- /.box-body -->
              </div><!-- /.box -->

             
            </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
      </div>  
     
<script src="<?php echo base_url();?>lib/bootstrap/js/jquery.dataTables.min.js"></script>
        <script src="<?php echo base_url();?>lib/bootstrap/js/dataTables.bootstrap.min.js"></script>        
<script>
	$(document).ready(function() {
		$('#example').dataTable({
	        /* Disable initial sort */
	        "aaSorting": []
	    });
	    
		var toast_msg = '<?php echo $msg;?>';
		var msg_type = '<?php echo $msg_type;?>';
		if(toast_msg !== null && toast_msg !== '') {
            var shortCutFunction = msg_type;
            toastr.options = {
                positionClass: 'toast-bottom-right'
            };
            var $toast = toastr[shortCutFunction](toast_msg);
	    }	    
	    
	} );

	
</script>