<? global $vis_language; 
if($assets_details==-1){ 
	include(VIS_PATH_TEMPLATE.'no_record_yet.php'); 
	if(!isset($view_only)) {echo '<script> $("#view_action").hide(); $("#vis_assets_form .panel-footer").hide(); $("#vis_assets_list").hide(); $(".fullFrame").removeClass("b-t").addClass("m-t-lg m-b-lg"); </script>';}
 } else { ?>
<script> $("#view_action").show(); $("#vis_assets_form .panel-footer").show(); $("#vis_assets_list").show(); </script>
<table class="table table-hover b-t b-light m-b-none" data-ride="datatables">
   <thead class="table_head">
      <tr>
		<?php if(!isset($view_only)){?>
         <th>
            <div class="btn-group">
               <label class="checkbox m-n m-r-sm i-checks"  style="float: left;"><input type="checkbox"><i></i></label>		
            </div>
         </th>
		<?php }?>
         <th><? echo $vis_language['TXTNAME']; ?></th>
		 <th class="txt_nowrap"><? echo $vis_language['TXTCITYPE'];?></th>
		 <th class="txt_nowrap"><? echo $vis_language['TXTDEPARTMENT']; ?></th>
		 <th class="txt_nowrap"><? echo $vis_language['TXTLOCATION']; ?></th>
		 <th class="txt_nowrap"><? echo $vis_language['TXTMANAGEDBY']; ?></th>
         <th class="txt_nowrap"><? echo $vis_language['TXTUSEDBY']; ?></th>
		 <th class="txt_nowrap"><? echo $vis_language['TXTSTATUS']; ?></th>
         <th></th>
      </tr>
   </thead>
   <tbody>
      <?
	  	 for($i=0;$i<count($assets_details);$i++) {
			 
			 if($assets_details[$i]['staff_id']==''){
			 	$managed_by = '---';
			 }else{
			 	$managed_by = $assets_details[$i]['first_name'].' '.$assets_details[$i]['last_name'];
			 }
			 
			 echo "<tr>";
			 if(!isset($view_only)){
				echo '<td width="30"><label class="checkbox m-n i-checks"><input type="checkbox" name="vis_global_mass_chk_'.$i.'" id="vis_global_mass_chk_'.$i.'" value="'.$assets_details[$i]['assets_id'].'" /><i></i></label></td>';
			 }
			 
			 
			echo '<td><a href="#/cmdb/cmdb_assets_details/'.rawurlencode(str_replace('/', ' ', $assets_details[$i]['name']).'/'.$assets_details[$i]['assets_id']).'">'.$assets_details[$i]['name'].'</a></td>';
			echo '<td><a href="#/cmdb/cmdb_assets_details/'.rawurlencode(str_replace('/', ' ', $assets_details[$i]['name']).'/'.$assets_details[$i]['assets_id']).'">'.$assets_details[$i]['CNAME'].'</a></td>';
			echo '<td><a href="#/cmdb/cmdb_assets_details/'.rawurlencode(str_replace('/', ' ', $assets_details[$i]['name']).'/'.$assets_details[$i]['assets_id']).'">'.$assets_details[$i]['domain_name'].' : '.$assets_details[$i]['department_name'].'</a></td>';
			echo '<td><a href="#/cmdb/cmdb_assets_details/'.rawurlencode(str_replace('/', ' ', $assets_details[$i]['name']).'/'.$assets_details[$i]['assets_id']).'">'.$assets_details[$i]['LNAME'].'</a></td>';
			echo '<td><a href="#/cmdb/cmdb_assets_details/'.rawurlencode(str_replace('/', ' ', $assets_details[$i]['name']).'/'.$assets_details[$i]['assets_id']).'">'.$managed_by.'</a></td>';
			echo '<td><a href="#/cmdb/cmdb_assets_details/'.rawurlencode(str_replace('/', ' ', $assets_details[$i]['name']).'/'.$assets_details[$i]['assets_id']).'">'.$assets_details[$i]['usedby'].'</a></td>';
			
			$is_expired ='--';
			if($assets_details[$i]['ci_type_id']==2 || $assets_details[$i]['ci_type_id']==3){
				$total_month = ($assets_details[$i]['warranty_year']*12)+$assets_details[$i]['warranty_month'];
				$current_date = strtotime(date('Y-m-d h:i:s'));
				$expiry_date = strtotime(date('Y-m-d h:i:s', $assets_details[$i]['installation_date']) . $total_month.' month');
				if($expiry_date <= $current_date){
					$is_expired='<span style="background-color: #e33244; color: #fff; font-weight: normal" class="btn btn-xs l-h-1x text-xs">'.$vis_language['TXTITILEXPIRED'].'</span>';
				}
			}
			echo '<td>'.$is_expired.'</td>';
			if(!isset($view_only)){ ?>
			<td align="center"> <a class="text-muted" href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=<?php echo $operation['vis_module']; ?>&vis_operation=get_assets_delete&vis_assets_id=<? echo $assets_details[$i]['assets_id']; ?>&vis_static_area=vis_assets_delete_form" title="<? echo $vis_language['TXTDELETE']; ?>"><i class="vh vh-delete-round"></a></td>
			<?php }?></tr> 
	  <? } ?>
   </tbody>
</table><? } ?>
<script type="text/javascript">
   $(".selectpicker").selectpicker(); 
   $(document).ready(function() {	
   $('[data-ride="datatables"]').dataTable({		
          "bPaginate" : false,	
   		"sDom": 't', "bAutoWidth": false,
   		"aoColumns": [
   			<? if(!isset($view_only)){?>{ "bSortable": false },<?php }?>
   		  	null,
   		  	null,
   		  	null,
   		  	null,
			null,
			null,
			null
			<? if(!isset($view_only)){?>,	{ "bSortable": false }<?php }?>
   		]
   	});
   });
</script>
