<? global $vis_language; ?>
<section id="breadcrumb" class="row m-b m-l-none m-r-none">
   <div class="col-sm-6">
      <h3 class="m-b-xs text-black"><? echo $operation['view_title'];?></h3>
      <ul class="breadcrumb bg-empty no-border m-b-xxs no-padder">
         <li><a class="link" href="#/home/quick_view/<? echo $vis_language['TXTHOME']; ?>"><? echo $vis_language['TXTHOME']; ?></a></li>
         <li><a class="link" href="#/cmdb/assets/<? echo $vis_language['TXTASSETS']; ?>" class="link"> <? echo $vis_language['TXTCMDB']; ?></a></li>
         <!--<li><a  class="link" href="#/cmdb/assets/<?php echo $vis_language['TXTASSETS'];?>/<? echo $operation['view_title']; ?>" class="link"><? echo $operation['view_title']; ?></a> </li>-->
         <li class="active"><? echo $vis_language['TXTASSETSDETAIL'];?></li>
      </ul>
   </div>
   <div class="col-sm-6 text-right text-left-xs m-t-lg">
	    <ul class="navSeprator m-n bred_rlink">
			<li><a class="btn btn-rounded btn-default btn-sm pull-right" href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=cmdb&vis_operation=attach_relationships&vis_static_area=vis_add_cmdb_dialog&vis_assets_id=<? echo $assets_details['assets_id']; ?>"><i class="vh vh-plus" style="font-size:10px;"></i> <?= $vis_language['TXTATTACH'];?></a></li>
		</ul>
   </div>
</section>
<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 h4"><? 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){

			    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>
			   <? }
			  }
             }?>
    </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){
			    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>
             <? }
			 } ?>
        </div>
    </div>
    <? $descriptions= str_replace('<p><br></p>', '', $assets_details['description']);
if($descriptions!=''){?>
    <div class="col-md-6">
            <span class="col-xs-3 text-right font-bold "><? echo $vis_language['TXTDESCRIPTION']; ?>:</span>
            <div class="col-md-9 text-lt text-muted">
            	<? echo $assets_details['description']; ?>
            </div>
    </div>
    <?php /*?><div class="col-md-9">
          <div class="m-b-sm">
          <div class=" col-xs-1 text-lt text-muted">&nbsp;</div>
            <div class=" col-xs-10 text-lt text-muted"><? echo $assets_details['description']; ?></div>
          </div>
    </div><?php */?>
    <? }?>
</section>
<section class="padder">
    <section class="panel panel-default">
		    <form class="form-horizontal" role="form" id="vis_child_client_form" name="vis_child_client_form" method="post">
        <header class="panel-heading text-right bg-light clearfix">
            <ul class="nav nav-tabs pull-left"  id="tabs">
			   <li  id="auditlog" class="active"><a data-toggle="tab" oncontextmenu="return false;" onclick="$('#vis_details_list').visExecution('load_operations',{'vis_module':'cmdb', 'vis_operation':'get_audit_log_list','vis_assets_id':'<? echo $assets_details['assets_id']; ?>'});set_active_tab('auditlog');" href="#vis_details_list" ><? echo $vis_language['TXTAUDITLOG']; ?></a></li>
                <li  id="relationships"><a data-toggle="tab" oncontextmenu="return false;" onclick="$('#vis_details_list').visExecution('load_operations',{'vis_module':'cmdb', 'vis_operation':'get_relationships_list','vis_assets_id':'<? echo $assets_details['assets_id']; ?>'});set_active_tab('relationships');" href="#vis_details_list" ><? echo $vis_language['TXTITILREATIONSHIPS']; ?></a></li>
                <li  id="edit"><a data-toggle="tab" oncontextmenu="return false;" onclick="$('#vis_details_list').visExecution('load_operations',{'vis_module':'cmdb', 'vis_operation':'cmdb_assets_edit','vis_assets_id':'<? echo $assets_details['assets_id']; ?>'});set_active_tab('edit');" href="#vis_details_list" ><? echo $vis_language['TXTEDITASSETS']; ?></a></li>
                <li  id="contract"><a data-toggle="tab" oncontextmenu="return false;" onclick="$('#vis_details_list').visExecution('load_operations',{'vis_module':'cmdb', 'vis_operation':'get_attach_contract_ci_list','vis_assets_id':'<? echo $assets_details['assets_id']; ?>'});set_active_tab('contract');" href="#vis_details_list" ><? echo $vis_language['TXTCONTRACT']; ?></a></li>
                <li  id="ticket"><a data-toggle="tab" oncontextmenu="return false;" onclick="$('#vis_details_list').visExecution('load_operations',{'vis_module':'cmdb', 'vis_operation':'get_attach_ticket_ci_list','vis_assets_id':'<? echo $assets_details['assets_id']; ?>'});set_active_tab('ticket');" href="#vis_details_list" ><? echo $vis_language['TXTTICKET']; ?></a></li>
                <li  id="changes"><a data-toggle="tab" oncontextmenu="return false;" onclick="$('#vis_details_list').visExecution('load_operations',{'vis_module':'cmdb', 'vis_operation':'get_attach_changes_list','vis_assets_id':'<? echo $assets_details['assets_id']; ?>'});set_active_tab('changes');" href="#vis_details_list" ><? echo $vis_language['TXTCHANGES']; ?></a></li>
                <li id="problems"><a data-toggle="tab" oncontextmenu="return false;" href="#vis_details_list" onclick="$('#vis_details_list').visExecution('load_operations',{'vis_module':'cmdb', 'vis_operation':'get_attach_problems_list','vis_assets_id':'<? echo $assets_details['assets_id']; ?>'});set_active_tab('problems');"><? echo $vis_language['TXTPROBLEMS']; ?></a></li>
            <? if($assets_details['installation_path']!='' && $assets_details['depreciation_type']!=0 && $assets_details['salvage']!=''){?>
                <li  id="schedule"><a data-toggle="tab" oncontextmenu="return false;" onclick="$('#vis_details_list').visExecution('load_operations',{'vis_module':'cmdb', 'vis_operation':'get_depreciation_schedule','vis_cost':'<?= $assets_details['installation_path'];?>','vis_salvage':'<?= $assets_details['salvage']; ?>','vis_depreciation_type':'<?= $depreciation_details[0]['finance_type_id']; ?>','vis_expence':'<?= $expence; ?>','vis_useful_life':'<?= $depreciation_details[0]['useful_life']; ?>','vis_aquisition_date':'<?= $assets_details['installation_date'];?>'});set_active_tab('schedule');" href="#vis_details_list" ><? echo $vis_language['TXTITILDEPRECIATIONSCHEDULE']; ?></a></li>
               
            <? }?>
             <li  id="release"><a data-toggle="tab" oncontextmenu="return false;" onclick="$('#vis_details_list').visExecution('load_operations',{'vis_module':'cmdb', 'vis_operation':'get_attach_release_list','vis_assets_id':'<? echo $assets_details['assets_id']; ?>'});set_active_tab('release');" href="#vis_details_list" ><? echo $vis_language['TXTRELEASE']; ?></a></li>
            
            </ul>
        </header>
        </form>
        <div class="panel-body">
			<div class="tab-content">
				<div id="vis_details_list" class="tab-pane active">
            		<script>$('#vis_details_list').visExecution('load_operations',{'vis_module':'cmdb', 'vis_operation':'get_audit_log_list','vis_assets_id':'<? echo $assets_details['assets_id']; ?>'});
				    </script>
				</div>
			</div>
		</div>
	</section>
</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>
