<? global $vis_language;
	$calls_array = $call_details[0]->call;
	//echo '<pre>';print_r($calls_array); echo '</pre>';
	if($calls_array->direction == 'outbound'){
		$to = $calls_array->raw_digits;
		$from = $calls_array->number->digits;
	}else if($calls_array->direction == 'inbound'){
		 $from = $calls_array->raw_digits;
		 $to = $calls_array->number->digits;
	}
	if(isset($calls_array->contact)){
		$contact_name = $calls_array->contact->first_name.' '.$calls_array->contact->last_name;
	}
	$staff = 'Name: '.$calls_array->user->name.'<br/>Email: '.$calls_array->user->email;
	$voiceemail = $calls_array->voicemail;
	$recording_url	= $calls_array->recording;
	
?>
<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 $vis_language['TXTCALLDETAILS'];?></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="#/voip/aircall_call/<? echo $vis_language['TXTAIRCALL'];?>"><? echo $vis_language['TXTAIRCALL'];?></a></li>
      <li><? echo $vis_language['TXTCALLDETAILS'];?></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><? echo $vis_language['TXTCALLDETAILS'];?></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 id="created_session_link">
        <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTFROM'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><? echo $from;?></div>
        </div>
        <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTTO'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><? echo $to; ?></div>
        </div>
		<?php if(isset($calls_array->contact)){ ?>
		<div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTCONTACT'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><? echo $contact_name; ?></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($calls_array->started_at); ?></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($calls_array->ended_at); ?></div>
        </div>
         <div class="row m-b-sm"> <span class="col-xs-3 text-right "><? echo $vis_language['TXTDURATION'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><? echo $calls_array->duration.' '.$vis_language['TXTSECONDS'];?></div>
        </div>  
	  
        
        <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTDIRECTION'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><? echo $calls_array->direction;?></div>
        </div>
		<div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTSTAFF'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><? echo $staff;?></div>
        </div>
        <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTSTATUS'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><? echo $calls_array->status; ?></div>
        </div>
       <?php if($recording_url !=''){ ?>
        <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTRECORDING'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><audio src="<?php echo $recording_url; ?>" controls preload="auto" autobuffer ></audio></div>
        </div>
		<?php }  ?>
		<?php if($voiceemail !=''){ ?>
        <div class="row m-b-sm"> <span class="col-xs-3 text-right"><? echo $vis_language['TXTVOICEMAIL'];?> :</span>
          <div class=" col-xs-9 text-lt text-muted"><audio src="<?php echo $voiceemail; ?>" controls preload="auto" autobuffer ></audio></div>
        </div>
		<?php }  ?>
        </div>
        <div class="row m-b-sm"> </div>
       <div class="row m-b-sm"> <span class="col-xs-3 text-right"></span>
          <div class=" col-xs-9 text-lt text-muted"> <!--<button type="button" class="btn btn-primary" onclick="SelectText('created_session_link')"><?// echo $vis_language['TXTCOPYTOCLIPBOARD']; ?></button> -->
		  <?php if(isset($operation['vis_domain_id'])){ ?>
		  <a href="javascript:void(0);" class="btn btn-primary" data-toggle="ajaxModal" data-modal-arguments="vis_module=ticket&vis_operation=new_ticket_step_one&vis_static_area=vis_open_new_dialog&vis_chat_type=aircall&vis_email_id=<? echo str_replace(' ','',$calls_array->raw_digits) ?>&vis_domain_id=<? echo $operation['vis_domain_id']; ?>&vis_aircall_domain_id=<? echo $operation['vis_domain_id']; ?>&vis_chat_id=<? echo $call_id; ?>" onclick="" ><? echo $vis_language['TXTCONVERTTOTICKET']; ?></a>
		  <?php } ?>
		  </div>
        </div>
      </div>

      <div class="col-md-6"></div>
    </div>
  </section>
</section>
<script>
function SelectText(element) {
    var doc = document
        , text = doc.getElementById(element)
        , range, selection
    ;
    if (doc.body.createTextRange) {
        range = document.body.createTextRange();
        range.moveToElementText(text);
        range.select();
    } else if (window.getSelection) {
        selection = window.getSelection();
        range = document.createRange();
        range.selectNodeContents(text);
        selection.removeAllRanges();
        selection.addRange(range);
    }
}

</script>
