<? 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="padder">
    <section class="panel panel-default">
        <header class="panel-heading sub_header"><? echo $vis_language['TXTUPDATECI']; ?></header>
        <div class="panel-body">
            <form class="form-horizontal" role="form" id="vis_update_assets_form" name="vis_update_assets_form" method="post">
				<input type="hidden" name="vis_assets_id" value="<? echo $assets_details['assets_id']; ?>" />
				<div class="form-group">
					<label for="vis_firstname" class="col-sm-2 control-label"><? echo $vis_language['TXTNAME']; ?></label>
					<div class="col-sm-10">
						<input type="text" class="form-control input-sm" data-type="text" data-required="true" name="vis_name" id="vis_name" value="<? echo htmlentities($assets_details['name'], ENT_COMPAT, 'UTF-8');//$assets_details['name']; ?>">
					</div>
				</div>  
				<div class="form-group">
					<label for="vis_department" class="col-sm-2 control-label"><? echo $vis_language['TXTDEPARTMENT']; ?></label>
					<div class="col-sm-10">
						<select name="vis_department" id="vis_department" onchange="get_staffdata(this.value,'')" class="form-control input-sm selectpicker"<? if(count($department_details)>10) echo ' data-live-search="true"';?>>
						<option value="0"> <? echo $vis_language['TXTSELECT']; ?> </option>
						<? if($department_details!=-1)	for($i=0;$i<count($department_details); $i++){?>
							<option value="<? echo $department_details[$i]['domain_id'].':'.$department_details[$i]['department_id'];?>" 
							<? echo $department_details[$i]['department_id']==$assets_details['department_access'] ? 'selected="selected"' : '';?>> <? echo $department_details[$i]['domain_name'].' :: '.$department_details[$i]['department_name'];?></option>
						<? } ?>	
						</select>
					</div>
				</div>	
				<div class="form-group">
				   <label class="col-sm-2 control-label"><? echo $vis_language['TXTCITYPE']; ?></label>
				   <div class="col-sm-10" id="citype_list">
					<select class="form-control selectpicker" onchange="set_property(this.value,$('#vis_department').val());" name="vis_ci_type_id" id="vis_ci_type_id" data-live-search="true">
					 <option value=""> <? echo $vis_language['TXTSELECT']; ?> </option>
					  <? 
					  echo vis_show_subcategories($citype_details,'','ci',$assets_details['ci_type_id']); 
					  /*for($i=0;$i<count($citype_details);$i++) {
						  ?>
					  <option value="<? echo $citype_details[$i]['item_id']; ?>" <? echo $assets_details['ci_type_id']==$citype_details[$i]['item_id']? 'selected="selected"':''; ?> > <? echo $citype_details[$i]['name']; ?></option>
					  <? }*/ ?>
					</select>
				   </div>
				</div>
				<div class="form-group">
				   <label class="col-sm-2 control-label"><? echo $vis_language['TXTIMPACT']; ?></label>
				   <div class="col-sm-10" id="impact_list">
					<select class="form-control selectpicker" name="vis_impact_id" id="vis_impact_id" <? if(count($impact_details) > 10) echo 'data-live-search="true"' ?>>
					<option value=""> <? echo $vis_language['TXTSELECT']; ?> </option>
					  <?
					  for($i=0;$i<count($impact_details);$i++) {
						  ?>
					  <option value="<? echo $impact_details[$i]['impact_id']; ?>" <? echo $assets_details['impact_id']==$impact_details[$i]['impact_id']? 'selected="selected"':''; ?>> <? echo $impact_details[$i]['name']; ?></option>
					  <? } ?>
					</select>
				   </div>
				</div>
				<div class="form-group">
					<label for="vis_firstname" class="col-sm-2 control-label"><? echo $vis_language['TXTDESCRIPTION']; ?></label>
					<div class="col-sm-10">
						<textarea name="vis_description" id="vis_description" class="form-control" rows="10"><? echo $assets_details['description']; ?></textarea>
					</div>
				</div>
				<div id="assets_property">
				<?php
    	$vis_last_audit_date = ($operation['vis_last_audit_date']!='0' && $operation['vis_last_audit_date']!='')?date(VIS_EDITDATETIMEPICKER_FORMAT,$operation['vis_last_audit_date']):'';
    	$vis_expiry_date = ($operation['vis_last_audit_date']!='0' && $operation['vis_expiry_date']!='')?date(VIS_EDITDATETIMEPICKER_FORMAT,$operation['vis_expiry_date']): '';
    	$vis_installation_date = ($operation['vis_last_audit_date']!='0' &&  $operation['vis_installation_date']!='')?date(VIS_EDITDATETIMEPICKER_FORMAT,$operation['vis_installation_date']):'';	?>
		<? if($operation['vis_section']=='software'){?>
<div class="line b-b line-lg pull-in"></div>
<br/> 
<div class="form-group"><label class="col-sm-2 control-label"><strong><? echo $vis_language['TXTITILSOFTWAREPROPERTY']; ?></strong></label></div>

<div class="form-group">
    <label class="col-sm-2 control-label"><? echo $vis_language['TXTCIPRODUCT']; ?></label>
    <div class="col-sm-10">
        <select name="vis_product_id" id="vis_product_id" onchange="get_vendor(this.value);" class="form-control input-sm selectpicker"<? if(count($product_details)>10) echo ' data-live-search="true"';?>>
        <option value="0"> <? echo $vis_language['TXTSELECT']; ?> </option>
        <? if($product_details!=-1) 
            for($i=0;$i<count($product_details); $i++){
				if($operation['vis_product_id']==$product_details[$i]['product_id']) $chk='selected="selected"'; else $chk='';
				echo '<option '.$chk.' value="'.$product_details[$i]['product_id'].'">'.$product_details[$i]['name'].'</option>';
			}?>
        </select>
    </div>
</div>
<div id="vendor_list" class="form-group" style="display:none;">
</div>
<? if($operation['vis_vendor_id']!='' && $operation['vis_vendor_id']!=0){?>
<div class="form-group" id="vendor_edit">
	<label class="col-sm-2 control-label"><? echo $vis_language['TXTVENDOR']; ?></label>
    <div class="col-sm-10">
        <select name="vis_vendor_id" id="vis_vendor_id" onchange="get_vendor(this.value);" class="form-control input-sm selectpicker"<? if(count($vendor_details)>10) echo ' data-live-search="true"';?>>
        <? if($vendor_details!=-1) 
            for($v=0;$v<count($vendor_details); $v++){
				echo '<option value="'.$vendor_details[$v]['vendor_id'].'">'.$vendor_details[$v]['vendor_name'].'</option>';
			}?>
        </select>
    </div>
</div>
<? }?>
<div class="form-group">
    <label for="vis_firstname" class="col-sm-2 control-label"><? echo $vis_language['TXTITILWARRANTY']; ?></label>
    <div class="col-sm-5">
        <select name="vis_warranty_year" id="vis_warranty_year" class="form-control input-sm selectpicker" data-live-search="true">
        <? for($y=0;$y<11;$y++){
			if($operation['vis_warranty_year']==$y) $chk='selected="selected"'; else $chk='';
             echo '<option '.$chk.' value="'.$y.'"> '.$y.' '.$vis_language['TXTYEAR'].' </option>';
		   }
		?>	 
         
        </select> 
    </div>
    <div class="col-sm-5">
        <select name="vis_warranty_month" id="vis_warranty_month" class="form-control input-sm selectpicker" data-live-search="true">
        <? for($m=0;$m<12;$m++){
			if($operation['vis_warranty_month']==$m) $chk='selected="selected"'; else $chk='';
             echo '<option '.$chk.' value="'.$m.'"> '.$m.' '.$vis_language['TXTMONTH'].' </option>';
		   }
		?>	 
        </select> 
    </div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label m-t-xs"><?= $vis_language['TXTITILINSTALLATIONDATE'];?></label>
    <div class="col-sm-10">
     <span class="input-group-addon no-padder no-borders date">
        <input id="vis_installation_date" name="vis_installation_date" class="form-control input-sm" type="text" value="<?= $vis_installation_date;?>">
    </span>
    </div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label m-t-xs"><?= $vis_language['TXTITILLICENSEEXPDATE'];?></label>
    <div class="col-sm-10">
     <span class="input-group-addon no-padder no-borders date">
        <input id="vis_expiry_date" name="vis_expiry_date" class="form-control input-sm" type="text" value="<?= $vis_expiry_date;?>">
    </span>
    </div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label"><? echo $vis_language['TXTITILLICENSETYPE']; ?></label>
    <div class="col-sm-10">
        <select name="vis_assets_state" id="vis_assets_state" class="form-control input-sm selectpicker"<? if(count($license_type_details)>10) echo ' data-live-search="true"';?>>
         <option value=""> <? echo $vis_language['TXTSELECT']; ?> </option>
            <? if($license_type_details!=-1) 
            for($l=0;$l<count($license_type_details); $l++){
				if($operation['vis_assets_state']==$license_type_details[$l]['license_type_id']) $chk='selected="selected"'; else $chk='';
				echo '<option '.$chk.' value="'.$license_type_details[$l]['license_type_id'].'">'.$license_type_details[$l]['name'].'</option>';
			}?>
        </select>
    </div>
</div>
<div class="form-group">
   <label class="col-sm-2 control-label"><? echo $vis_language['TXTCOST']; ?></label>
   <div class="col-sm-10">
      <input class="form-control input-sm" type="text" name="vis_asset_tag" id="vis_asset_tag" value="<?= $operation['vis_asset_tag']?>">
   </div>
</div>
<div class="form-group">
   <label class="col-sm-2 control-label"><? echo $vis_language['TXTITILLICENSEKEY']; ?></label>
   <div class="col-sm-10">
      <input class="form-control input-sm" type="text" name="vis_licence_key" id="vis_licence_key" value="<?= $operation['vis_licence_key']?>">
   </div>
</div>
<div class="form-group">
   <label class="col-sm-2 control-label"><? echo $vis_language['TXTITILINSTALLATIONPATH']; ?></label>
   <div class="col-sm-10">
      <input class="form-control input-sm" type="text" name="vis_installation_path" id="vis_installation_path" value="<?= $operation['vis_installation_path']?>">
   </div>
</div>            
<div class="form-group">
    <label class="col-sm-2 control-label m-t-xs"><?= $vis_language['TXTITILLASTAUDITDATE'];?></label>
    <div class="col-sm-10">
     <span class="input-group-addon no-padder no-borders date">
	 
        <input id="vis_last_audit_date" name="vis_last_audit_date" class="form-control input-sm" type="text" value="<?=$vis_last_audit_date?>">
		
    </span>
    </div>
</div>
<input id="vis_ci_property_type" name="vis_ci_property_type" class="form-control input-sm" type="hidden" value="2" >
<? }elseif($operation['vis_section']=='hardware'){?>
<div class="line b-b line-lg pull-in"></div>
<br/> 
<div class="form-group"><label class="col-sm-2 control-label"><strong><? echo $vis_language['TXTITILHARDWAREPROPERTY']; ?></strong></label></div>

<div class="form-group">
    <label class="col-sm-2 control-label"><? echo $vis_language['TXTCIPRODUCT']; ?></label>
    <div class="col-sm-10">
        <select name="vis_product_id" id="vis_product_id" onchange="get_vendor(this.value);" class="form-control input-sm selectpicker"<? if(count($product_details)>10) echo ' data-live-search="true"';?>>
        <option value=""> <? echo $vis_language['TXTSELECT']; ?> </option>
        <? if($product_details!=-1) 
            for($i=0;$i<count($product_details); $i++){
				if($operation['vis_product_id']==$product_details[$i]['product_id']) $chk='selected="selected"'; else $chk='';
				echo '<option '.$chk.' value="'.$product_details[$i]['product_id'].'">'.$product_details[$i]['name'].'</option>';
			}?>
        </select>
    </div>
</div>
<div id="vendor_list" class="form-group" style="display:none;">
</div>
<? if($operation['vis_vendor_id']!='' && $operation['vis_vendor_id']!=0){?>
<div class="form-group" id="vendor_edit">
	<label class="col-sm-2 control-label"><? echo $vis_language['TXTVENDOR']; ?></label>
    <div class="col-sm-10">
        <select name="vis_vendor_id" id="vis_vendor_id" onchange="get_vendor(this.value);" class="form-control input-sm selectpicker"<? if(count($vendor_details)>10) echo ' data-live-search="true"';?>>
        <? if($vendor_details!=-1) 
            for($v=0;$v<count($vendor_details); $v++){
				echo '<option value="'.$vendor_details[$v]['vendor_id'].'">'.$vendor_details[$v]['vendor_name'].'</option>';
			}?>
        </select>
    </div>
</div>
<? }?>
<div class="form-group">
    <label for="vis_firstname" class="col-sm-2 control-label"><? echo $vis_language['TXTITILWARRANTY']; ?></label>
    <div class="col-sm-5">
        <select name="vis_warranty_year" id="vis_warranty_year" class="form-control input-sm selectpicker" data-live-search="true">
        <? for($y=0;$y<11;$y++){
			if($operation['vis_warranty_year']==$y) $chk='selected="selected"'; else $chk='';
             echo '<option '.$chk.' value="'.$y.'"> '.$y.' '.$vis_language['TXTYEAR'].' </option>';
		   }
		?>	 
         
        </select> 
    </div>
    <div class="col-sm-5">
        <select name="vis_warranty_month" id="vis_warranty_month" class="form-control input-sm selectpicker" data-live-search="true">
        <? for($m=0;$m<12;$m++){
			if($operation['vis_warranty_month']==$m) $chk='selected="selected"'; else $chk='';
             echo '<option '.$chk.' value="'.$m.'"> '.$m.' '.$vis_language['TXTMONTH'].' </option>';
		   }
		?>	 
        </select> 
    </div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label m-t-xs"><?= $vis_language['TXTITILACQUISITIONDATE'];?></label>
    <div class="col-sm-10">
     <span class="input-group-addon no-padder no-borders date">
        <input id="vis_installation_date" name="vis_installation_date" class="form-control input-sm" type="text" value="<?= $vis_installation_date;?>">
    </span>
    </div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label m-t-xs"><?= $vis_language['TXTITILWARRANTYEXPDATE'];?></label>
    <div class="col-sm-10">
     <span class="input-group-addon no-padder no-borders date">
        <input id="vis_expiry_date" name="vis_expiry_date" class="form-control input-sm" type="text" value="<?= $vis_expiry_date;?>">
    </span>
    </div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label"><? echo $vis_language['TXTASSETSTATE']; ?></label>
    <div class="col-sm-10">
        <select name="vis_assets_state" id="vis_assets_state" class="form-control input-sm selectpicker"<? if(count($asset_state_details)>10) echo ' data-live-search="true"';?>>
        <option value=""> <? echo $vis_language['TXTSELECT']; ?> </option>
        <? if($asset_state_details!=-1) 
            for($i=0;$i<count($asset_state_details); $i++){
				if($operation['vis_assets_state']==$asset_state_details[$i]['asset_id']) $chk='selected="selected"'; else $chk='';
				echo '<option '.$chk.' value="'.$asset_state_details[$i]['asset_id'].'">'.$asset_state_details[$i]['name'].'</option>'; 
			}?>
        </select>
    </div>
</div>
<div class="form-group">
   <label class="col-sm-2 control-label"><? echo $vis_language['TXTITILASSETTAG']; ?></label>
   <div class="col-sm-10">
      <input class="form-control input-sm" type="text" name="vis_asset_tag" id="vis_asset_tag" value="<?= $operation['vis_asset_tag']?>">
   </div>
</div>
<div class="form-group">
   <label class="col-sm-2 control-label"><? echo $vis_language['TXTITILSERIALNUMBER']; ?></label>
   <div class="col-sm-10">
      <input class="form-control input-sm" type="text" name="vis_licence_key" id="vis_licence_key" value="<?= $operation['vis_licence_key']?>" >
   </div>
</div>            
<div class="form-group">
    <label class="col-sm-2 control-label m-t-xs"><?= $vis_language['TXTITILLASTAUDITDATE'];?></label>
    <div class="col-sm-10">
     <span class="input-group-addon no-padder no-borders date">
      
		
		
          <input id="vis_last_audit_date" name="vis_last_audit_date" class="form-control input-sm" type="text" value="<?php echo $vis_last_audit_date;?>">
		
    </span>
    </div>
</div>
<div class="line b-b line-lg pull-in"></div>
<br/> 
<div class="form-group"><label class="col-sm-2 control-label"><strong><? echo $vis_language['TXTITILDEPRECIATIONDETAILS']; ?></strong></label></div>
<div class="form-group">
   <label class="col-sm-2 control-label"><? echo $vis_language['TXTCOST']; ?></label>
   <div class="col-sm-10">
      <input class="form-control input-sm" type="text" name="vis_installation_path" id="vis_installation_path" value="<?= $operation['vis_installation_path'];?>">
   </div>
</div>
<div class="form-group">
   <label class="col-sm-2 control-label"><? echo $vis_language['TXTITILSALVAGE']; ?></label>
   <div class="col-sm-10">
      <input class="form-control input-sm" type="text" name="vis_salvage" id="vis_salvage" value="<?= $operation['vis_salvage']?>">
   </div>
</div>
<div class="form-group">
	<label class="col-sm-2 control-label"><? echo $vis_language['TXTITILDEPRECIATIONTYPE']; ?></label>
    <div class="col-sm-10">
        <select name="vis_depreciation_type" id="vis_depreciation_type" class="form-control input-sm selectpicker"<? if(count($depreciation_details)>10) echo ' data-live-search="true"';?>>
        <? if($depreciation_details!=-1) 
            for($v=0;$v<count($depreciation_details); $v++){
				if($operation['vis_depreciation_type']==$depreciation_details[$v]['finance_id'])
				   $chk = 'selected="selected"';
				else
				   $chk = '';   
				echo '<option '.$chk.' value="'.$depreciation_details[$v]['finance_id'].'">'.$depreciation_details[$v]['name'].'</option>';
			}?>
        </select>
    </div>
</div>
<input id="vis_ci_property_type" name="vis_ci_property_type" class="form-control input-sm" type="hidden" value="1" >
<? }?>
<script type="application/javascript">
var d = new Date();
var curr_time = d.getHours()+":"+d.getMinutes();
var curr_date= '<? echo date("M-d, Y")?> '+curr_time+'';
$('.date').datetimepicker({ format: "<?php echo VIS_DATETIMEPICKER_FORMAT;?>"});

function get_vendor(vis_product_id){
		$('#vendor_edit').show();
		$('#vendor_list').show();
		$('#vendor_list').visExecution('load_operations', {'vis_module':'cmdb', 'vis_operation':'get_product_vendor','vis_product_id':''+vis_product_id+''});
}
</script>
				</div>
				<div id="custom_fields"><?php echo $customdata;?></div>
				
				<div class="line b-b line-lg pull-in"></div>
				<br/> 
				
				<div class="form-group"><label class="col-sm-2 control-label"><strong><? echo $vis_language['TXTASSIGNMENT']; ?></strong></label></div>
				<div class="form-group">
					<label for="vis_firstname" class="col-sm-2 control-label"><? echo $vis_language['TXTMANAGEDBY']; ?></label>
					<div class="col-sm-10" id="staff_list">
 						<select class="form-control input-sm selectpicker" name="vis_managed_by" id="vis_managed_by" disabled>
							<option value=""> <? echo $vis_language['TXTSELECT']; ?> </option>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label for="vis_firstname" class="col-sm-2 control-label"><? echo $vis_language['TXTUSEDBY']; ?></label>
					<div class="col-sm-10">		
					<input class="form-control input-sm" type="text" name="vis_usedby" id="vis_usedby"  placeholder="<?= $vis_language['TXTTYPETOSEARCHEXISTINGCLIENTSEMAILADDRESS']?>" data-resize="no" style="width:100%"/>
                                <script type="text/javascript">
                                    $(document).ready(function() {
                                        $("#vis_usedby").tokenInput(
                                            "index.php?vis_module=cmdb&vis_operation=get_staff_client_details",
                                            {
                                                theme: "facebook",
                                                searchDelay: 300,
                                                minChars: 3,
                                                queryParam: "vis_data",
                                                propertyToSearch: "email",
                                                tokenValue: "email",
                                                tokenLimit: 1,
                                                preventDuplicates: true,
                                                resultsFormatter: function(item) {
                                                    return "<li>" + "<div style='display: inline-block; padding-left: 10px;'><div class='full_name'>" + item.full_name + " < " + item.email + " ></div></div></li>";
                                                },
                                                tokenFormatter: function(item) {
													if(item.email!=''){
                                                    	return "<li><p>" + item.email + "</p></li>";
													}else{
														return '';
													}
                                                }
                                            }
                                        );
										$("div.token-input-dropdown-facebook").css('width', $(".token-input-list-facebook").width() + 2 + 'px');
                                        $("#token-input-vis_usedby").parent().css('width','100%');
								   
								   <? if($assets_details['usedby']!=''){ ?>
                                     	$("#vis_usedby").tokenInput("add", {email: "<?= $assets_details['usedby']; ?>"});
                                   <? }?>
                                    });
                                </script></div>
				</div>
				<div class="form-group">
				   <label class="col-sm-2 control-label"><? echo $vis_language['TXTLOCATION']; ?></label>
				   <div class="col-sm-10" id="location_list">
					<select class="form-control selectpicker" name="vis_location_id" id="vis_location_id" <? if(count($location_details) > 10) echo 'data-live-search="true"' ?>>
					<option value=""> <? echo $vis_language['TXTSELECT']; ?> </option>
					  <? echo vis_show_subcategories($location_details,'','location',$assets_details['location_id']); ?>
					</select>
				   </div>
				</div>				
				<div class="form-group">
					<label for="vis_firstname" class="col-sm-2 control-label"><? echo $vis_language['TXTASSIGNEDON']; ?></label>
					<div class="col-sm-10">
						<input type="text" class="form-control input-sm from_date" data-type="text" data-required="true" name="vis_assigned_on" id="vis_assigned_on" value="<?php if($assets_details['assigned_on']=='0') echo ''; else echo date('M-jS, Y G:i', ($assets_details['assigned_on']+VIS_TIMEZONE)); ?>">
					</div>
				</div>
				<div class="form-group">
					<label for="vis_firstname" class="col-sm-2 control-label"><? echo $vis_language['TXTATTACHFILE']; ?></label>
					<div class="col-sm-10">
						<input type="file" name="files[]" multiple="multiple" onchange="$(this).visExecution('upload_file', {'vis_static_area':'#vis_csv_attachments', 'vis_form':'vis_update_assets_form', 'vis_form_attachment_area':'#vis_attachments'})" class="filestyle" data-input="false" data-icon="true" data-classButton="btn btn-link link" data-iconName="vh-chat" data-buttonText="<?=$vis_language['TXTCHOOSEFILE']?>" data-badge="true"/>
						<input type="hidden" name="vis_location" value="<? echo VIS_DOMAIN; ?>" />
						<input type="hidden" name="vis_attachments" id="vis_attachments" value="<?=$assets_details['attachment_id']?>" />
						<div id="vis_csv_attachments">
						<?php
							if($assets_details['attachment_id']!=''){
								for($j=0;$j<count($assets_details['files']);$j++){
									 
									
						?>
						<a href="../attachment/<?php echo $assets_details['files'][$j]['content']; ?>" download>
							<div class="btn-group wrapper-xxs">
							
								<span class="btn btn-xs alert-success"><?php echo $assets_details['files'][$j]['file_name'];?></span>
								<button onclick="$(this).parent().remove(); $(this).visExecution('load_operations', {'vis_module':'ticket', 'vis_operation':'remove_attachment', 'vis_attachment_id':<?php echo $assets_details['files'][$j]['attachment_id'];?>});vis_remove_attachment(<?php echo $assets_details['files'][$j]['attachment_id'];?>,'vis_attachments');" data-dismiss="alert" type="button" class="btn btn-xs alert-success"><i class="vh vh-cross"></i></button>
							</div></a>
						<?php }}?>
						</div>
					</div>
				</div>
	        </form>
            <div class="b-2x b-t m-b-md"></div>
				<div class="col-sm col-sm-offset-2">
					<button type="button" class="btn btn-primary" onClick="file_read();"><? echo $vis_language['TXTUPDATE']; ?></button>
				</div> <br/>  
			</div>
    </section>
</section>
<script src="<?= VIS_PATH_SCRIPT; ?>file-input/bootstrap-filestyle.min.js"></script>
<? if (!defined('VIS_HTML_EDITOR') || VIS_HTML_EDITOR == 1) { ?>	<script src="<?= VIS_PATH_PLUGINS; ?>redactor/source.js"></script> <?}?>
<script>
<?php /*?>set_property('<?php echo $assets_details['ci_type_id'];?>');<?php */?>
<? if($assets_details['ci_property_type']!='' && $assets_details['ci_property_type']!=0){?>
   <?php /*?> set_property_edit(<? echo $assets_details['ci_type_id'];?>);<?php */?>
<? }?>	
	//get_cidata(<? //echo $assets_details['ci_type_id']; ?>);
	<? if($assets_details['department_access']!=''){ ?>
		get_staffdata('<? echo $assets_details['department_access']; ?>','<? echo $assets_details['staff_id']; ?>');
	<? }?>	
	check_expiry();
	
	<? if (!defined('VIS_HTML_EDITOR') || VIS_HTML_EDITOR == 1) { ?>
	$(function() {
            $('#vis_description').redactor({
				buttonSource: true,
				minHeight: 180, // pixels
                maxHeight: 180,
                imageUpload: false,
                imageUploadParam: 'files',
                deniedTags: ['html', 'head', 'link', 'body', 'meta', 'script','applet'],
                plugins: ['source']			
            });
			$(".redactor-toolbar").attr('z-index', '3 !important');
        });
    <?php }?>
	
	$(".selectpicker").selectpicker();
	$('.from_date').datetimepicker({format: "<?php echo VIS_DATETIMEPICKER_FORMAT;?>"});
	
	$("#vis_ci_type_id").change(function (){
		$("#custom_fields").html('');
		get_cidata(this.value);
	});
	
	$("#vis_department").change(function (){
		$("#staff_list").html('');
		get_staffdata(this.value);
	});
	
	function get_staffdata(id,staff_id){
		if(id!=''){
		var data = { 'vis_module':"<?=$operation['vis_module'];?>", vis_operation:"get_filterdata_list", vis_department_id:''+id+'', vis_staff_id:''+staff_id+'' };  
		//console.log(data);
			$.ajax({
			url: 'index.php',
			data: data,
			type: "POST",
			dataType: "json",
			success: function(data) {
				//console.log(data);
				//$("#citype_list").html('');
				$("#staff_list").html('');
				//$("#impact_list").html('');
				//$("#location_list").html('');
				if(data!=-1)
					//$("#citype_list").html(data.citype_list);
					$("#staff_list").html(data.staff_list);
					//$("#impact_list").html(data.impact_list);
					//$("#location_list").html(data.location_list);
					$(".selectpicker").selectpicker();
			},
			error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
		});
		}
	}
	
	function get_cidata(id){		
		var data = { vis_module:"<?=$operation['vis_module'];?>", vis_operation:"get_custom_fields", ci_type_id:id, assets_id:<? echo $assets_details['assets_id']; ?> };   
		$.ajax({
			url: 'index.php',
			data: data,
			type: "POST",
			dataType: "json",
			success: function(data) {
				//$("#custom_fields").html('');
				if(data!=-1)
				{
				
					$("#custom_fields").html(data);
					$('.date').datetimepicker({ format: "<?php echo VIS_DATETIMEPICKER_FORMAT;?>"});
				}
			},
			error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
		});
	}
	
	function check_expiry(){
		if ($('#vis_notify_expiry').is(":checked"))$('#notify_expiry').show();
		else $('#notify_expiry').hide();
	}
	
	function vis_remove_attachment(file_id, attach_location){
		var loc = '';
		loc = (attach_location != "" && typeof(attach_location) != "undefined") ? attach_location : "vis_image_attachments";
		$("#" + loc).val( $("#" + loc).val().replace(file_id + ',', '') );
	}
	
	$(document).ready(function () {
		$(":file").filestyle({input: false});
	});
	
	function toggle_dept_list(){
       if($('#vis_department_all').is(":checked")) $('#vis_dept_list_section').hide();
       else $('#vis_dept_list_section').show();
    }
<? if($assets_details['ci_property_type']!='' && $assets_details['ci_property_type']!=0){?>
	function set_property_edit(vis_config_id){
		//$("#custom_fields").html('');
		//get_cidata(vis_config_id);
		
		$('#assets_property').show();
		$('#assets_property').visExecution('load_operations', {'vis_module':'cmdb', 'vis_operation':'get_edit_assets_properties','vis_config_id':''+vis_config_id+'','vis_module_section':'edit','vis_product_id':'<?=$assets_details['product_id']?>','vis_vendor_id':'<?=$assets_details['vendor_id']?>','vis_warranty_year':'<?=$assets_details['warranty_year']?>','vis_warranty_month':'<?=$assets_details['warranty_month']?>','vis_installation_date':'<?=$assets_details['installation_date']?>','vis_expiry_date':'<?=$assets_details['expiry_date']?>','vis_assets_state':'<?=$assets_details['assets_state']?>','vis_asset_tag':'<?=$assets_details['asset_tag']?>','vis_licence_key':'<?=$assets_details['licence_key']?>','vis_installation_path':'<?=$assets_details['installation_path']?>','vis_last_audit_date':'<?=$assets_details['last_audit_date']?>','vis_depreciation_type':'<?=$assets_details['depreciation_type']?>','vis_salvage':'<?=$assets_details['salvage']?>','vis_property_type':'<?=$assets_details['ci_property_type']?>'});
	}
	
<? }?>
function set_property(vis_config_id,deptid){

		$("#custom_fields").html('');
		get_cidata(vis_config_id);
		$('#assets_property').show();
		$('#assets_property').visExecution('load_operations', {'vis_module':'cmdb', 'vis_operation':'get_assets_properties','vis_config_id':''+vis_config_id+'','vis_module_section':'add','vis_departmentid':deptid});
	}
    function file_read(){
	var textArray = Array.prototype.slice.call(document.querySelectorAll('.btn.btn-xs.alert-success')).map(function(span){
	return span.textContent;
	
	 });
	 
    $('#vis_update_assets_form').visExecution('submit_form',{'vis_module':'<?=$operation['vis_module'];?>', 'vis_operation':'update_ci','vis_attach_name':''+textArray+'', 'vis_form':'vis_update_assets_form'});
    }
$("#vis_department").change(function () {
		var data = { vis_module:"<?=$operation['vis_module'];?>", vis_operation:"get_filterdata_list", vis_department_id:this.value };
		$.ajax({
			url: 'index.php',
			data: data,
			type: "POST",
			dataType: "json",
			success: function(data) {
				$("#citype_list").html('');
				$("#staff_list").html('');
				$("#impact_list").html('');
				$("#location_list").html('');
				if(data!=-1)
					$("#citype_list").html(data.citype_list);
					$("#staff_list").html(data.staff_list);
					$("#impact_list").html(data.impact_list);
					$("#location_list").html(data.location_list);
					$(".selectpicker").selectpicker();
			},
			error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
		});
	});
		
</script>
</section>
