<? if($operation['jira']=='createissue'){
	if(isset($jira_product) && count($jira_product)>0 && $jira_product!='' && $jira_product['status-code']!='404'){?>
<div id="link_div">
    <div class="col-sm-12 text-center"><a class="link" href="javascript:void(0);" onclick="get_jira_issue();"><?php echo $vis_language['TXTLINKISSUE']; ?></a> <?php echo $vis_language['TXTOR']; ?> <a class="link" href="javascript:void(0);" onclick="get_create_issue();"><?php echo $vis_language['TXTCREATEISSUE']; ?></a></div>  
</div>   
<div class="row m-b"></div>
<form method="post" role="form" class="form-horizontal" name="vis_jira_form" id="vis_jira_form">
      <div class="form-group">
      <label class="col-sm-2 control-label"><? echo $vis_language['TXTPROJECTS']; ?></label>
         <div class="col-sm-4">
         <select class="form-control selectpicker" data-size="auto" onChange="get_issue_type(this.value);" data-container="body" name="vis_jira_product" id="vis_jira_product" <? if(count($jira_product) > 10) echo 'data-live-search="true"' ?>>
              <!--<option value="0"><?=$vis_language['TXTSELECTPRODUCT']?></option>-->
              <?php 
              for($p=0;$p<count($jira_product);$p++){
                  echo '<option value="'.$jira_product[$p]['key'].'">'.$jira_product[$p]['name'].'</option>';
              }
              ?>
         </select>
         </div>
         <label class="col-sm-2 control-label"><? echo $vis_language['TXTISSUETYPE'];?></label>
         <div class="col-sm-4" id="issue_type">
         <select class="form-control selectpicker" data-size="auto" data-container="body" name="vis_issue_type" id="vis_issue_type" <? if(count($issue_type) > 10) echo 'data-live-search="true"' ?>>
              <!--<option value="0"><?=$vis_language['TXTSELECTPRODUCT']?></option>-->
              <?php 
              for($i=0;$i<count($issue_type['projects'][0]['issuetypes']);$i++){
                 if($issue_type['projects'][0]['issuetypes'][$i]['subtask']==''){ echo '<option value="'.$issue_type['projects'][0]['issuetypes'][$i]['name'].'">'.$issue_type['projects'][0]['issuetypes'][$i]['name'].'</option>'; }
              }
              ?>
         </select>
         </div>
         <div class="col-sm-3"></div>
      </div> 
         <div class="form-group">
              <label class="col-sm-2 control-label"><? echo $vis_language['TXTSUBJECT']; ?></label>
              <div class="col-sm-10">
                  <input type="text" class="form-control input-sm" name="vis_subject" id="vis_subject" value="<?=$ticket_details['subject'];?>" />
              </div>
         </div>
         <div class="line b-b line-lg pull-in"></div><br />
         <div class="form-group">
           <div class="col-sm-12 text-right">
			<a class="btn btn-default" data-dismiss="modal"><? echo $vis_language['TXTCANCEL']; ?></a>
            <a class="btn btn-primary" onclick="$(this).visExecution('submit_form',{'vis_module':'ticket', 'vis_operation':'create_jira_issue', 'vis_form':'vis_jira_form'});"><? echo $vis_language['TXTCREATE']; ?></a>
            </div>
         </div>
         <input type="hidden" name="vis_ticket_post" id="vis_ticket_post" value="<?=$post_details[0]['content'];?>" />  
         <input type="hidden" name="vis_ticketid" id="vis_ticketid" value="<?=$ticket_details['ticket_id'];?>" />  
         <input type="hidden" name="ticket_hash" id="ticket_hash" value="<?=$ticket_details['ticket_hash'];?>" />        
         <input type="hidden" name="vis_username" id="vis_username" value="<?=$username;?>" />
         <input type="hidden" name="vis_password" id="vis_password" value="<?=$password;?>" />
         <input type="hidden" name="vis_jira_url" id="vis_jira_url" value="<?=$api_integration[0]['billing_url'];?>" />
         <input type="hidden" name="vis_domain" id="vis_domain" value="<?=$operation['vis_domain'];?>" />
</form>           
<script>$('.selectpicker').selectpicker();
function get_issue_type(key){
	$('#issue_type').visExecution('load_operations',{'vis_module':'ticket', 'vis_operation':'get_jira_issue_type','vis_jira_hash':''+key+'','vis_jira_url':'<?=$api_integration[0]['billing_url']?>','vis_username':'<?=$username;?>','vis_password':'<?=$password;?>'});
}
</script>
<? }else include(VIS_PATH_TEMPLATE.'no_record_yet.php');
}?>
<? /*if($operation['jira']=='getissue'){
	if(isset($jira_issue) && count($jira_issue)>0 && $jira_issue!=''){?>
<table class="table table-hover b-t b-light m-b-none" data-ride="datatables">
   <thead class="table_head">
      <tr>
         <th><? echo 'Hash'; ?></th>
		 <th class="txt_nowrap"><? echo 'Subject';?></th>
         <th class="txt_nowrap"><? echo 'Issue type'; ?></th>
      </tr>
   </thead>
   <tbody>
<? for($i=0;$i<count($jira_issue['issues']);$i++){
	 echo '<tr><td>'.$jira_issue['issues'][$i]['key'].'</td>';
	 echo '<td>'.$jira_issue['issues'][$i]['fields']['summary'].'</td>';			 
     echo '<td>'.$jira_issue['issues'][$i]['fields']['issuetype']['name'].'</td>'; 
	 ?>     
     </tr>     
<? }?>
   </tbody>
</table>             
<script>
function get_issue_type(key){
	$('#issue_type').visExecution('load_operations',{'vis_module':'ticket', 'vis_operation':'get_jira_issue_type','vis_jira_hash':''+key+'','vis_jira_url':'<?=$api_integration[0]['billing_url']?>','vis_username':'<?=$username;?>','vis_password':'<?=$password;?>'});
}
</script>
<? }else include(VIS_PATH_TEMPLATE.'no_record_yet.php');
}*/?>
<? if($operation['jira']=='linkissue'){
	 if($jira_link_details!=-1){?>
<form method="post" role="form" class="form-horizontal" name="vis_jira_form" id="vis_jira_form">
      <div class="form-group">
         <div class="col-sm-6" id="link_button">
         <a class="link" target="_blank" href="<?=$api_integration[0]['billing_url'].'/browse/'.$jira_link_details[0]['issue_hash'];?>"><?= $vis_language['TXTVIEWISSUEINJIRA'];?></a>
         </div>
         <div class="col-sm-6 text-right" id="link_button">
         <a class="btn btn-primary" onclick="$('#vis_details_list').visExecution('load_operations',{'vis_module':'ticket', 'vis_operation':'unlink_jira_issue','vis_domain':'<?=$operation['vis_domain'];?>','vis_ticketid':'<?=$operation['vis_ticketid'];?>'});"><?= $vis_language['TXTUNLINKISSUE'];?></a>    
         </div>
      </div>          
</form>
<table class="table table-hover b-t b-light m-b-none">
   <thead class="table_head">
      <tr>
         <th><? echo 'Hash'; ?></th>
		 <th class="txt_nowrap"><?= $vis_language['TXTSUBJECT'];?></th>
         <th class="txt_nowrap"><?= $vis_language['TXTISSUETYPE'];?>;</th>
         <th class="txt_nowrap"><?= $vis_language['TXTISTATUS'];?></th>
      </tr>
   </thead>
   <tbody>
<?   echo '<tr><td>'.$jira_link_details[0]['issue_hash'].'</td>';
	 echo '<td>'.$jira_link_issue['object']['title'].'</td>';			 
     echo '<td>'.$jira_issue_details['issues'][0]['fields']['issuetype']['name'].'</td>';
	 echo '<td>'.$jira_issue_details['issues'][0]['fields']['status']['name'].'</td>'; 
	 ?>     
     </tr>     
   </tbody>
</table>
<? }else{?>
<div id="link_div">
    <div class="col-sm-12 text-center"><a class="link" href="javascript:void(0);" onclick="get_jira_issue();"><?php echo $vis_language['TXTLINKISSUE'];?></a> <?php echo $vis_language['TXTOR']; ?> <a class="link" href="javascript:void(0);" onclick="get_create_issue();"><?php echo $vis_language['TXTCREATEISSUE']; ?></a></div>  
</div>
<div class="row m-b"></div>
<form method="post" role="form" class="form-horizontal" name="vis_jira_form" id="vis_jira_form">
      <div class="form-group">
         <div class="col-sm-6">
         <input type="text" id="jira_issue_hash" placeholder="<?= $vis_language['TXTISSUEHASH'];?>" class="form-control">
         </div>
         <div class="col-sm-6" id="link_button">
         <a class="btn btn-primary" onclick="vis_link_issue();"><?php echo $vis_language['TXTLINKISSUE'];?></a>
         </div>
      </div>          
</form>
<div class="text-center" id="issue_id_error" style="display:none;"></div>
<script>
/*$('#disp_jira_issue').visExecution('load_operations',{'vis_module':'ticket', 'vis_operation':'get_jira_link_issue','vis_domain':'<?=$operation['vis_domain'];?>','vis_ticketid':'<?=$operation['vis_ticketid'];?>'});*/
function vis_link_issue(){
	var issue_hash=$('#jira_issue_hash').val();
	$('#vis_details_list').visExecution('load_operations',{'vis_module':'ticket', 'vis_operation':'link_jira_issue','vis_jira_hash':''+issue_hash+'','vis_domain':'<?=$operation['vis_domain'];?>','vis_ticketid':'<?=$operation['vis_ticketid'];?>'});
}
</script> 
<? }}?>
<!--<div id="vis_details_list"></div>-->
