<? global $vis_language;

	function vis_show_subcategories($details,$call,$flag,$selectid) {
		if($flag=='ci')
			$id='item_id';
		elseif($flag=='location')
			$id='location_id';
			
		$selected='';	
		for($i=0;$i<count($details);$i++) { 
				if($selectid!='')
					$selected = ($selectid==$details[$i][$id])?'selected="selected"':'';
				
				$options .='<option value="'.$details[$i][$id].'" '.$selected.'>'.$details[$i]['name'].'</option>';
				if(isset($details[$i]['subcat']) && $details[$i]['subcat']!=NULL) { 
					$options .= vis_show_subcategories($details[$i]['subcat'],'sub_cat',$flag,$selectid); 
				}
			}
		return $options;
	}
	
?>
 <section  class="container m-t-md">
   <!-- Announcements -->
   <div class="row">
   <div class="col-md-12">
   <section class="panel shadow-none">
      <header class="vis_login_head">
		<? if(isset($operation['message']) && $operation['message']!='' && $operation['message']!='domain') { ?> <script> $("#vis_submit_msg_div").show(); $("#vis_submit_msg_div").html('<? echo $operation['message']; ?>'); </script><? }else { ?> <div id="vis_submit_msg_div" class="alert text-center alert-success" style="display:none"></div>  <? } ?>
	 
	</header>			
      <div class="panel-heading b-b">
         <h4 class="panel-title1">
            <div class="col-sm-6 no-padder">
			 <input type="hidden" name="vis_assets_id" value="<? echo $assets_details['assets_id']; ?>" />
			  <span> <? echo $vis_language['TXTNAME']; ?>   :   </span>
			  <span class="vh-yellow m-l-xs"> <? echo $assets_details['name']; ?> </span> 
               </div>
            <div class="text-right"> 
			
			<?$is_expired ='--';
			if($assets_details['ci_type_id']==2 || $assets_details['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;padding: 3px 3px;  font-size: 10px;" class="btn btn-xs l-h-1x text-xs">'.$vis_language['TXTITILEXPIRED'].'</span>';
				}
			}?>
			 <span > <? echo  $vis_language['TXTSTATUS']; ?> :  <?= $is_expired; ?></span>
			 </div>
         </h4>
      </div>
 
    
                       <section class="row m-b m-l-none m-r-none b-t b-light">
    <div class="col-md-6">
    <div class="wrapper">
        <div class="row m-b-sm">
             <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTNAME']?> :</span>
            <div class=" col-xs-9 text-lt text-muted h5"><? echo $assets_details['name']; ?></div>
        </div>
        <div class="row m-b-sm">
              <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTCITYPE']?> :</span>
            <div class=" col-xs-9 text-lt text-muted"><?
                      for($i=0;$i<count($citype_details);$i++) {
                          echo $assets_details['ci_type_id']==$citype_details[$i]['item_id'] ? $citype_details[$i]['name'] : '';
                      } ?>
            </div>
        </div>
        <div class="row m-b-sm">
            <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTIMPACT']?> :</span>
            <div class=" col-xs-9 text-lt text-muted"><?
			for($i=0;$i<count($impact_details);$i++) {
					  echo $assets_details['impact_id']==$impact_details[$i]['impact_id']? $impact_details[$i]['name']:'';
			}
			?>
            </div>
        </div>
        <div class="row m-b-sm">
            <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTMANAGEDBY']?> :</span>
            <div class=" col-xs-9 text-lt text-muted">
			<? echo $staff[0]['first_name'].' '.$staff[0]['last_name'];?>
            </div>
        </div>
         <? if($assets_details['ci_property_type']==1 ||$assets_details['ci_property_type']==2){

			    if($assets_details['installation_path']!=''){ ?>
                  <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTCOST']?>:</span>
                      <div class=" col-xs-9 text-lt text-muted">
                      <? echo $assets_details['installation_path'].' '.$assets_domain[0]['currency']; ?>
                      </div>
                  </div>
             <? }
			 if($assets_details['installation_date']!=''){ ?>
                  <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTITILACQUISITIONDATE']?> :</span>
                      <div class=" col-xs-9 text-lt text-muted">
                      <? echo date(VIS_EDITDATETIMEPICKER_FORMAT,$assets_details['installation_date']);
					  //format_datetime($assets_details['installation_date']); ?>
                      </div>
                  </div>
             <? }
              if($assets_details['installation_path']!='' && $assets_details['depreciation_type']!=0 && $assets_details['salvage']!=''){
				  if($depreciation_details[0]['finance_type_id']==1){
					  $aquisition_date = date("m",$assets_details['installation_date']);
					  $available_month=12-$aquisition_date+1;
					  $expence = ($assets_details['installation_path']-$assets_details['salvage'])/$depreciation_details[0]['useful_life'];
					  $month_expence = $expence/12;
					  $final_expense=$month_expence*$available_month;
					  $book_value = $assets_details['installation_path']-$final_expense;?>
					  <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTITILBOOKVALUE']?> :</span>
                      <div class=" col-xs-9 text-lt text-muted">
                      <? echo round($book_value,2).' '.$assets_domain[0]['currency'];?>
                      </div>
                  </div>
			   <? }
			      if($depreciation_details[0]['finance_type_id']==2){
					  $aquisition_date = date("m",$assets_details['installation_date']);
					  $available_month=12-$aquisition_date+1;
					  $percent = (1/$depreciation_details[0]['useful_life'])*100;
					  $expence = ($percent/100)*$assets_details['installation_path'];
					  $month_expence = $expence/12;
					  $final_expense=$month_expence*$available_month;
					  $book_value = $assets_details['installation_path']-$final_expense;?>
					  <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTITILBOOKVALUE']?> :</span>
                      <div class=" col-xs-9 text-lt text-muted">
                      <? echo round($book_value,2).' '.$assets_domain[0]['currency'];?>
                      </div>
                  </div>
			   <? }
			      if($depreciation_details[0]['finance_type_id']==3){
					  $aquisition_date = date("m",$assets_details['installation_date']);
					  $available_month=12-$aquisition_date+1;
					  $percent = (1/$depreciation_details[0]['useful_life'])*100;
					  $expence = (($percent*2)/100)*$assets_details['installation_path'];
					  $month_expence = $expence/12;
					  $final_expense=$month_expence*$available_month;
					  $book_value = $assets_details['installation_path']-$final_expense;?>
					  <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTITILBOOKVALUE']?> :</span>
                      <div class=" col-xs-9 text-lt text-muted">
                      <? echo round($book_value,2).' '.$assets_domain[0]['currency'];?>
                      </div>
                  </div>
			   <? }
			      if($depreciation_details[0]['finance_type_id']==4){
					  $aquisition_date = date("m",$assets_details['installation_date']);
					  $available_month=12-$aquisition_date+1;
					  $sofyd = $depreciation_details[0]['useful_life']*($depreciation_details[0]['useful_life']+1)/2;
					  $depreciable_base = $assets_details['installation_path']-$assets_details['salvage'];
					  $expence=($depreciation_details[0]['useful_life']/$sofyd)*($available_month/12)*$depreciable_base;
					  $book_value = $assets_details['installation_path']-$expence;
			   ?> <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTITILBOOKVALUE']?> :</span>
                      <div class=" col-xs-9 text-lt text-muted">
                      <? echo round($book_value,2).' '.$assets_domain[0]['currency'];?>
                      </div>
                  </div>
			   <? }
			  }?>
			   
			 
			 
			 
			 
			   <? if($assets_details['salvage']!=''){ ?>
                  <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTITILSALVAGE']?> :</span>
                      <div class=" col-xs-9 text-lt text-muted">
                      <? echo $assets_details['salvage'].' '.$assets_domain[0]['currency']; ?>
                      </div>
                  </div>
             <? }
			    if($assets_details['depreciation_type']!=0){ ?>
                  <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTITILDEPRECIATIONTYPE']?> :</span>
                      <div class=" col-xs-9 text-lt text-muted">
                      <? echo $depreciation_details[0]['name']; ?>
                      </div>
                  </div>
             <? }
			 if($depreciation_details[0]['useful_life']!=0){ ?>
                  <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTUSEFULLIFE']?> :</span>
                      <div class=" col-xs-9 text-lt text-muted">
                      <? echo $depreciation_details[0]['useful_life']; ?>
                      </div>
                  </div>
             <? }?>
			
			 <? if($assets_details['asset_tag']!=''){ ?>
                  <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTASSETSTAG']?> :</span>
                      <div class=" col-xs-9 text-lt text-muted">
                      <? echo $assets_details['asset_tag'].' '.$assets_domain[0]['asset_tag']; ?>
                      </div>
                  </div>
             <? }?>
			
					
            <? }?>
			 <? $descriptions= str_replace('<p><br></p>', '', $assets_details['description']);
			if($descriptions!=''){?>
			 <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTDESCRIPTION']?> :</span>
                      <div class=" col-xs-9 text-lt text-muted">
                      <? echo $assets_details['description']; ?>
                      </div>
              </div>
			<? }?>

			 
    </div>
    </div>
    <div class="col-md-6">
        <div class="wrapper">
          <div class="row m-b-sm">
               <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTDEPARTMENT']?> :</span>
              <div class=" col-xs-9 text-lt text-muted">
              <? echo $assets_department[0]['domain_name'].' :: '.$assets_department[0]['department_name'];?>
              </div>
          </div>
          <div class="row m-b-sm">
               <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTLOCATION']?> :</span>
              <div class=" col-xs-9 text-lt text-muted"><?
			   for($i=0;$i<count($location_details);$i++) {
			   	echo $assets_details['location_id']==$location_details[$i]['location_id']? $location_details[$i]['name']:'';
			   }?>
              </div>
          </div>
          <div class="row m-b-sm">
               <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTASSIGNEDON']?> :</span>
              <div class=" col-xs-9 text-lt text-muted">
              <?=format_datetime($assets_details['assigned_on']);?>
              </div>
          </div>
          <div class="row m-b-sm">
               <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTUSEDBY']?> :</span>
              <div class=" col-xs-9 text-lt text-muted">
              <? echo $assets_details['usedby']; ?>
              </div>
          </div>
             <? if($assets_details['ci_property_type']==1 ||$assets_details['ci_property_type']==2){?>
			   <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTCIPRODUCT']?> :</span>
                      <div class=" col-xs-9 text-lt text-muted">  
				 <? 	  for($i=0;$i<count($product_details);$i++) {
					  echo $assets_details['ci_type_id']==$product_details[$i]['product_id']? $product_details[$i]['name']:'';?>
							
							  <?}?>
                    </div>
               </div>
          
		  <? if($assets_details['warranty_year']!=''){ ?>
                  <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTWARRANTYTEAR']?> :</span>
                      <div class=" col-xs-9 text-lt text-muted">
                      <? echo $assets_details['warranty_year'].' '.$assets_domain[0]['warranty_year']; ?>
                      </div>
                  </div>
             <? }?>
			 <? if($assets_details['warranty_month']!=''){ ?>
                  <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTWARRANTYMONTH']?>:</span>
                      <div class=" col-xs-9 text-lt text-muted">
                      <? echo $assets_details['warranty_month'].' '.$assets_domain[0]['warranty_month']; ?>
                      </div>
                  </div>
             <? }?>
			 
			 
			  <? if($assets_details['licence_key']!=''){ ?>
                  <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTITILLICENSEKEY']?> :</span>
                      <div class=" col-xs-9 text-lt text-muted">
					    <? echo $assets_details['licence_key'].' '.$assets_domain[0]['licence_key']; ?>
                    
                      </div>
                  </div>
             <? }?>
			 
			  <? if($assets_details['installation_path']!=''){ ?>
                  <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTITILINSTALLATIONPATH']?> :</span>
                      <div class=" col-xs-9 text-lt text-muted">
                      <? echo $assets_details['installation_path'].' '.$assets_domain[0]['installation_path']; ?>
                      </div>
                  </div>
             <? }?> 
			 	 <? if($assets_details['installation_date']!=''){ ?>
                  <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTITILINSTALLATIONDATE']?> :</span>
                      <div class=" col-xs-9 text-lt text-muted">
					   <? echo format_datetime($assets_details['installation_date']); ?>
                      <? echo $assets_details['installation_date'].' '.$assets_domain[0]['installation_date']; ?>
                      </div>
                  </div>
             <? }?>
			  <? if($assets_details['expiry_date']!=''){ ?>
                  <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTITILLICENSEEXPDATE']?> :</span>
                      <div class=" col-xs-9 text-lt text-muted">
					   <? echo format_datetime($assets_details['expiry_date']); ?>
                      <? echo $assets_details['expiry_date'].' '.$assets_domain[0]['expiry_date']; ?>
                      </div>
                  </div>
             <? }?>
			  <? if($assets_details['last_audit_date']!=''){ ?>
                  <div class="row m-b-sm">
                       <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTITILLASTAUDITDATE']?>:</span>
                      <div class=" col-xs-9 text-lt text-muted">
					    <? echo format_datetime($assets_details['last_audit_date']); ?>
                    
                      </div>
                  </div>
             <? }?>
			 
			
			<!-- ////////////////assets_state /////////////////////////-->
			
			<? } ?>
        </div>
    </div>

</section>

</section>
 </div>
   </div>
</section>
<script type="text/javascript">
	$('.selectpicker').selectpicker();
</script>
<script>
	function set_active_tab(tab_id){
        var active = $("#tabs .active").attr("id");
        $("#"+active).removeClass("active");
        $("#"+tab_id).addClass("active").show();
        var parent_div = $("#vis_details_list").parent().parent();
        if($("#vis_child_client_form #tabs #contact.active").length
        || $("#vis_child_client_form #tabs #ticket.active").length
        || $("#vis_child_client_form #tabs #order.active").length || $("#vis_child_client_form #tabs #product.active").length || $("#vis_child_client_form #tabs #invoice.active").length || $("#vis_child_client_form #tabs #transaction.active").length)
            parent_div.addClass("p-l-none").addClass("p-r-none");
        else parent_div.removeClass("p-l-none").removeClass("p-r-none");
    }
</script>

