<? 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"><span><? echo $vis_language['TXTCONTRACT'];?></span></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/contract/Contract" onclick="$('#vis_workpanel_div').visExecution('load_module','<? echo $vis_language['TXTCONTRACT']; ?>',{'vis_module':'cmdb','vis_operation':'contract'});"><?echo $vis_language['TXTCONTRACT'];?></a></li>
	<li class="active"><?=$contract_details['name']?></li>
</ul>
</div>
</section>
<section class="padder">
  <section class="panel panel-default">
    <div class="wrapper-sm">
      <div class="btn-group">
        <div class="form-group">
          <h5><?=$contract_details['name']?></h5>
        </div>
      </div>
    <div class="line b-b line-lg pull-in"></div>
    </div>
    <div class="row m-t">
      <div class="col-md-6">

        <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTNAME'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><?=$contract_details['name']?></div>
        </div>
        <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTCONTRACTNUMBER'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><?=$contract_details['contract_number']?></a></div>
        </div>
        <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTCONTRACTTYPE'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted">
			<? 	for($j=0;$j<count($contract_type_details);$j++){
					echo ($contract_details['type']==$contract_type_details[$j]['contract_type_id']) ? $contract_type_details[$j]['name']:'';
				}?>
		  </div>
        </div>
        <div class="row m-b-sm"> <span class="col-xs-3 text-right "><? echo $vis_language['TXTPRODUCT'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted">
		  <? for($j=0;$j<count($ci_product_details);$j++){
				echo ($contract_details['product']==$ci_product_details[$j]['product_id'])?$ci_product_details[$j]['name']: '';
			}?></div>
        </div>
        <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTVENDOR'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><? echo $vendor_details[0]['name']; ?></div>
        </div>
         <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTLICENSECOUNT'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><?=$contract_details['license_count']?></div>
        </div>
         <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTLICENSETYPE'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><? for($j=0;$j<count($license_type_details);$j++){
				echo ($contract_details['license_type']==$license_type_details[$j]['license_type_id']) ? $license_type_details[$j]['name']:'';} ?>
		  </div>
        </div>
         <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTAPROVER'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted">
			<? foreach ($staff_list as $staff) {
				echo ($contract_details['approver']==$staff['staff_id']) ? $staff['first_name'].' '.$staff['last_name']: '';
			} ?>
		  </div>
        </div>
        <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTCOST'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><?=$contract_details['cost']?> <?php echo $domain[0]['currency']?></div>
        </div>
        <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTDESCRIPTION'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><? echo stripslashes($contract_details['description'])?></div>
        </div>
		<?php if($contract_details['attach_ci']!=''){?>
        <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTATTACHCI'];?> :</span>
            <div class=" col-xs-9 text-lt text-muted"><?php
				if(attached_ci!=-1){
					for($j=0;$j<count($attached_ci);$j++){ ?>
					<div class="btn-group wrapper-xxs">
						<span class="btn btn-xs alert-success"><?php echo $attached_ci[$j]['name'];?></span>
					</div>
				<?php }}?>
			</div>
        </div>
		<?php }?>
		<?php if($contract_details['files']!='' ){?>
        <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTATTACHMENT'];?> :</span>
            <div class=" col-xs-9 text-lt text-muted"><?php
					for($f=0;$f<count($contract_details['files']);$f++){ ?>
					<div class="btn-group wrapper-xxs">
						<span class="btn btn-xs alert-success">
						<?php echo '<a href="'.$domain[0]['domain_url'].'manage/?vis_module=export&vis_operation=get_attachment&vis_attachment='.$contract_details['files'][$f]['attachment_id'].'&'.VIS_STAFF_COOKIE.'='.$_COOKIE[VIS_STAFF_COOKIE].'">'.$contract_details['files'][$f]['file_name'].'</a>';?>
						</span>
					</div>
				<?php }?>
			</div>
        </div>
		<?php }?>
       <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTSTARTDATE'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><? echo format_datetime($contract_details['start_date']); ?></div>
        </div>
		<div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTENDDATE'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><? echo format_datetime($contract_details['end_date']); ?></div>
        </div><hr>
		<div class="row m-b-sm"> <span class="col-xs-3 text-right"></span>
          <div class=" col-xs-9 text-lt text-muted" id="btn_class"><?=$btn_class?></div>
        </div>

      </div>

      <div class="col-md-6"></div>
    </div>
  </section>
</section>
<script src="<?= VIS_PATH_SCRIPT; ?>file-input/bootstrap-filestyle.min.js"></script>
<script>
	<? if (!defined('VIS_HTML_EDITOR') || VIS_HTML_EDITOR == 1) { ?>
	$(function() {
            $('#vis_description').redactor({
				buttonSource: true,
				minHeight: 180, // pixels
                maxHeight: 180,
                imageUpload: false,
                imageUploadParam: 'files',
				paragraphize: false,
		        replaceDivs: false,
                linebreaks: true,
                deniedTags: ['html', 'head', 'link', 'body', 'meta', 'script','applet']
            });
			$(".redactor-toolbar").attr('z-index', '3 !important');
        });
    <?php }?>

	$(document).ready(function () {
		$(":file").filestyle({input: false});
	});

	function change_contract_status(contract_id, status){

		var data = {'contract_id':contract_id, 'status':status};
		$.ajax({
			url: 'index.php?vis_module=cmdb&vis_operation=change_contract_status',
			data: data,
			type: "POST",
			success: function(data) {
				$("#btn_class").html(data);
				$("#vis_global_msg_div").visInterface("load_global_message", "<?php echo $vis_language['MSGSUCCOPRT']?>");
				$("#vis_workpanel_div").visExecution("load_module","<?php echo $vis_language['TXTCONTRACT'];?>",{"vis_module":"<?php echo $operation['vis_module'];?>", "vis_operation":"contract"});
			},
			error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
		});
	}
</script>
</section>

