<?php


if (!function_exists('view_listv2')) {
	function view_listv2($settings,$array_cols,$excluded,$status100,$button_items,$sys_button_items,$special_button_items){
$auther=10;
   if (array_key_exists('table', $settings)) {
   $table=$settings['table'];
   }
   
   if (array_key_exists('id_table', $settings)) {
   $id_table=$settings['id_table'];
   }
   
   if (array_key_exists('col1', $settings)) {
   $table_col1=$settings['col1'];
   }
   
   if (array_key_exists('col2', $settings)) {
   $table_col2=$settings['col2'];
   }
   
   if (array_key_exists('col3', $settings)) {
   $table_col3=$settings['col3'];
   }

   if (array_key_exists('col4', $settings)) {
   $table_col4=$settings['col4'];
   }

   if (array_key_exists('col5', $settings)) {
   $table_col4=$settings['col5'];
   }

   if (array_key_exists('where_col', $settings)) {
   $where_col=$settings['where_col'];
   }
   
   
   if (array_key_exists('detail_view', $settings)) {
   $detailed_view=$settings['detail_view'];
   }
   
   if (array_key_exists('add_new_view', $settings)) {
   $add_new_view=$settings['add_new_view'];
   }
  
  if (array_key_exists('suffix', $settings)) {
   $suffix=$settings['suffix'];
   }
   
   if (array_key_exists('date1', $settings)) {
   $date1=$settings['date1'];
   }
   
   if (array_key_exists('date2', $settings)) {
   $date2=$settings['date2'];
   }
   
   if (array_key_exists('disabled', $settings)) {
   $disabled=$settings['disabled'];
   }
   
   if (array_key_exists('col1encoding', $settings)) {
   $table_col1_encoded=$settings['col1encoding'];
   }
  
  if (array_key_exists('col2encoding', $settings)) {
   $table_col2_encoded=$settings['col2encoding'];
   }
   
  if (array_key_exists('col3encoding', $settings)) {
   $table_col3_encoded=$settings['col3encoding'];
   }
  
  if (array_key_exists('col4encoding', $settings)) {
   $table_col4_encoded=$settings['col4encoding'];
   }
  
  if (array_key_exists('col5encoding', $settings)) {
   $table_col5_encoded=$settings['col5encoding'];
   }
   
   if (array_key_exists('legend', $settings)) {
   $legend=$settings['legend'];
   }
 
   if (array_key_exists('call', $settings)) {
   $call=$settings['call'];
   }
 
   if (array_key_exists('heading', $settings)) {
   $heading=$settings['heading'];
   }
   
   if (array_key_exists('badge', $settings)) {
   $badge=$settings['badge'];
   }
   if (array_key_exists('delete', $settings)) {
   $delete=$settings['delete'];
   }
   if (array_key_exists('ref_value', $settings)) {
   $ref_val=$settings['ref_value'];
   }
   if (array_key_exists('table_21_label', $settings)) {
   $table_21_label=$settings['table_21_label'];
   }
  if (array_key_exists('table_22_label', $settings)) {
   $table_22_label=$settings['table_22_label'];
   }
   if (array_key_exists('del_section_flag', $settings)) {
   $del_section_flag=$settings['del_section_flag'];
   }
   else{
	$del_section_flag="del_rec";   
   }
  
del_modal();  
   
   ?>
<script type="text/javascript">
  $(document).ready(function() {
	   $( '#searchable-container' ).searchable({
        searchField: '#search',
        selector: '.row',
        childSelector: '.col-md-12',
        show: function( elem ) {
            elem.slideDown(100);
        },
        hide: function( elem ) {
            elem.slideUp( 100 );
        }
    })


	  });
  </script>
  
   
   <!-- PAGE FUNCTION LIST STARTS (c) i2d Technologies Website Engine -->
   <!-- START PAGE CONTENT -->
     <script type="text/javascript">
$(document).ready(function() {
var nb = $('div.member-card').length.toString();
$('#counter').html(nb);
$('#search').bind("keyup change blur", function(e) {
var bn = $('div.member-card:visible').length.toString();
$('#counter').html(bn);
});
$(".btn_delete a").click(function() {
var deL_iD = $(this).attr('id');	
var rowElement = $(this).parent().parent().parent().parent();
$("#delmodal").modal('show');	
$("#yes_del").click(function() {
$.ajax({
        
        Type : 'POST',
		
		contentType : "application/json; charset=utf-8",
		 
		dataType: 'text',

		cache	: false,

		url		: "perl.txt",
		
		
	    data	: 'section_flag=<?php echo $del_section_flag; ?>&ref_id=' + deL_iD + '&tbl=<?php echo $table; ?>&id_col=<?php echo $id_table; ?>',

		success : function(response){
rowElement.fadeOut(500).remove();
var bn2 = $('div.member-card:visible').length.toString();
$('#counter').html(bn2);	
console.log(response);

				},
        error:function(exception){
		   
		console.log(exception);
		   
		   ;}

	
				
				
});// end ajax()

});

});
});
</script>

                <div id="page-right-content">

                    <div class="container">
                        
						<div class="row">
                            <div class="col-sm-12">
                                <h4 class="header-title m-t-0 m-b-20"><?php echo $heading." List :"; ?> <span id="counter" style="color:red; font-weight:bold;"></span> Item(s)</h4>
                            </div>
							<div class="col-md-4 pull-right">
							
                                    			<?php 
												if($auther!=0){
												if(isset($add_new_view) && !empty($add_new_view)){
												?>
												<br />
												<span class="pull-right"><a button type="button" class="btn btn-lg btn-success" href="<?php echo $add_new_view; ?>"><?php echo "Add New ".$heading; ?></button></a></span>
												<?php }
												} 
												?>
												<span id="counter2" style="color:red; font-weight:bold;"></span>
							</div>
                        </div> <!-- end row -->
<p>&nbsp;</p>

<?php
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////

	if(isset($legend) && !empty($legend)){
	$tdsettings=array(
	'table'=>$table,
	'id_col'=>$id_table,
	'ref_value'=>$ref_val,
	'where_col'=>$where_col,
	'fields_array'=>$array_cols,
	'where_value'=>$legend,
	'echo'=>'0',
	'status_vaue'=>'Active',
	'order'=>'DESC',
	'type'=>'1b');

	$tdload=db_fetch($tdsettings);
	
	}
	else{
	    
$db_settings=array(
'table'=>$table,
'ref_value'=>$ref_val,
'type'=>'2',
'echo'=>'0',
'order'=>'DESC');

$tdload=db_fetch($db_settings);
    
	    
	}
	
	$table_id=id_col;
	?>


                        <div class="row p-20" id="searchable-container">
									
									
									
									<?php

if(!empty($tdload)){
	foreach($tdload as $item){ 
									
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
//for ($x = 0; $x <= 5; $x++) {			
//////////////////////////////////////////////////////////////////////////
					  ?>
                <div class="row">
				<div class="col-md-12">
				            		<div class="text-left card-box">
                                    <?php if($button_items!=0 ){ ?>
									<div class="dropdown pull-right">
                                        <a href="#" class="dropdown-toggle card-drop" data-toggle="dropdown" aria-expanded="false">
                                            <h3 class="m-0 text-muted"><i class="mdi mdi-dots-horizontal"></i></h3>
                                        </a>
										
                                        <ul class="dropdown-menu" role="menu">
                                            <?php if(isset($button_items) && !empty($button_items)){ 
				foreach($button_items as $bitem=>$bval){ 
				if($button_items[$bitem]['active']=="1"){
				?>
											
											<?php 
											
				}
				}
											}
											?>
											<?php if(isset($button_items) && !empty($button_items)){ 
				foreach($button_items as $bitem=>$bval){ 
				if($button_items[$bitem]['active']==1){
				?>
											<li><a href="<?php echo $button_items[$bitem]['link'].$item[$table_id]; ?>"><i class="<?php echo $button_items[$bitem]['icon']; ?>"></i> <?php echo $button_items[$bitem]['label']; ?></a></li>
<?php } 
else{ 
?>
<li><i class="<?php echo $button_items[$bitem]['icon']; ?>"></i> <?php echo $button_items[$bitem]['label']; ?></li>
<br />
                                            <li style="border-bottom:1px solid rgba(153,153,153,.3); margin:-10px 0 4px 0";></li>
																						
											<?php					
					  
				  } 
}
				}
				  ?>
                               <?php
if(isset($special_button_items) && !empty($special_button_items)){ 
foreach($special_button_items as $special_bitem=>$special_bval){
if($special_button_items[$special_bitem]['active']==10){				
				 ?>
				 
<li><a href="<?php echo $special_button_items[$special_bitem]['link'].$table."/".$item[$table_id]."/"; ?>" id="<?php echo $item[$table_id]; ?>"><i class="<?php echo $special_button_items[$special_bitem]['icon']; ?>"></i> <?php echo $special_button_items[$special_bitem]['label']; ?></a></li>
  <?php } 
				  else{
					?>
<li><i class="<?php echo $special_button_items[$special_bitem]['icon']; ?>"></i> <?php echo $special_button_items[$special_bitem]['label']; ?></li>					
					<?php					
					  
				  } 
}
				}
				  ?><?php
if(isset($sys_button_items) && !empty($sys_button_items)){ 
foreach($sys_button_items as $sys_bitem=>$sys_bval){
if($sys_button_items[$sys_bitem]['active']==10){				
				 ?>
				 
<li class="btn_delete"><a href="<?php echo $sys_button_items[$sys_bitem]['link'].$table."/".$item[$table_id]."/"; ?>" onclick="return false;" id="<?php echo $item[$table_id]; ?>"><i class="<?php echo $sys_button_items[$sys_bitem]['icon']; ?>"></i> <?php echo $sys_button_items[$sys_bitem]['label']; ?></a></li>
  <?php } 
				  else{
					?>
<li><i class="<?php echo $sys_button_items[$sys_bitem]['icon']; ?>"></i> <?php echo $sys_button_items[$sys_bitem]['label']; ?></li>					
					<?php					
					  
				  } 
}
				}
				  ?>
				</ul>
                                    </div>
									<?php } ?>
                                    <div class="clearfix"></div>
                                    <div class="member-card">
                                        <span class="user-badge bg-warning"><?php echo $suffix.$item[$id_table]; ?></span>
                                        

                                        

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

                                            

<?php if(isset($item[photo1]) && !empty($item[photo1])) { ?>
			  <img class="img-circle img-thumbnail" style="max-width: 15%;" src="<?php echo product_images.$item[photo1]; ?>">
			  <?php } else {	?>
			 <!-- <img class="img-circle img-thumbnail" style="max-width: 25%;" src="<?php //echo photo_folder; ?>default.png"> -->
			  <?php } ?>
			  <?php if ($button_items==0){ ?>
			  <br />
			  <?php } ?>
<h4 class="m-b-5"><?php 
				  if($table_col1_encoded==1){echo ucwords(base64_decode($item[$table_col1]));}
				  else{echo ucwords($item[$table_col1]);} 
				  ?></h4>
                                            
<p class="text-muted"> <?php 
              
              if(isset($item[$table_col2]) && !empty($item[$table_col2]) && $item[$table_col2]!=="empty value!"){ 
			  ?>
 <?php			  
			  } 
			  
			  ?> 
			  
			   <?php 
			   if(isset($settings['remote1']) && !empty($settings['remote1'])){
$branch_name=db_ref($settings['table_21'],$settings['table_21_id_col'],$item[$settings['remote_col1']],$settings['table_21_find_col']);	
}
if(isset($settings['remote2']) && !empty($settings['remote2'])){
$dept_name=db_ref($settings['table_22'],$settings['table_22_id_col'],$item[$settings['remote_col2']],$settings['table_22_find_col']);	
}

			   
			   if(isset($table_col3) && !empty($table_col3)) { 
			   
			   
			   ?>
                  <small>
                    
                     <span>
					 Last Update : <?php 
                        echo $item[$table_col3]."<br />"; 
                       ?>
					   <?php
					   if(isset($settings['remote1']) && !empty($settings['remote1'])){
                        echo $table_21_label. " : ";?> 
						<span style="color:red;font-weight:bolder;"> <?php echo $branch_name; ?></span> 
					   <?php }
					   if(isset($settings['count_table']) && !empty($settings['count_table'])){
$count=stats2($settings['count_table'],$settings['count_ref'],$settings['count_table_col'],$item[$id_table]);
					   ?> <h3><?php echo $count." Item(s)";?></h3>
					   <?php }
						if(isset($settings['remote2']) && !empty($settings['remote2'])){
						?>
                        <?php echo $table_22_label;?> : <span style="color:red;"><?php echo $dept_name; 
                       ?>
					   </span>
					   <?php
						}
					   ?>
					   
                     </span>
                  </small>
                  <?php 
                  
                  
                  }?>
			  
			  
			  
			  </a> </span></p>
			  
			  
			  
			  
			  
			  

                                        </div>
    </div>

                                        <p class="text-muted font-13">
&nbsp;
                                        </p>

                                        
                                        
                                    

                                </div>

                            </div>
							</div>
<?php } 
	}
?>	
							
							
                            </div>
                            
							
							</div>
                            
							
							
 <!-- PAGE FUNCTION LIST ENDS (c) i2d Technologies Website Engine -->   
<?php   
}
}
//////////////////////////// HTML FUNCTION ENDS (c) i2d Technologies ///////////////////////////////////////




?>