<? global $vis_language; ?>
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title"><? echo$vis_language['TXTLINKPROBLEM']; ?></h4>
        </div>
        <div class="modal-body">
            <div class="row">
                <div class="col-sm-12">
                <form method="post" role="form" class="form-horizontal" name="vis_ticket_form_<?= $operation['vis_changes_id'];?>" id="vis_ticket_form_<?= $operation['vis_changes_id'];?>">
				<div class="form-group">
                  
                   <div class="col-sm-12 text-center">
                   <input type="text" id="search_language_variables" onkeyup="vis_apply_filter();" placeholder="<?= $vis_language['TXTSEARCHPROBLEM'];?>" class="form-control">
                   </div>
				   
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <div id="cmdb_problems"></div>                        
                    </div>
                </div>
				<input type="hidden" name="vis_changes_id" id="vis_changes_id" value="<?= $operation['vis_changes_id'];?>">
				<input type="hidden" name="vis_attached_id" id="vis_attached_id" value="<?= $operation['attached_id'];?>">
              </form>
              </div>
            </div>
        </div>
        <div class="modal-footer">
			<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':'changes', 'vis_operation':'attach_problem', 'vis_attach_problem':'success', 'vis_form':'vis_ticket_form_<?= $operation['vis_changes_id'];?>', 'ci_for':'<?= $operation['ci_for'];?>'});"><? echo $vis_language['TXTATTACH']; ?></a>
        </div>
    </div>
</div>
<script type="text/javascript">
	$('.selectpicker').selectpicker(); 
	function vis_apply_filter(){
		var filter = $("#search_language_variables").val();
		var data = {'vis_filter':''+filter+'', 'attached_id':'<?= $operation['attached_id'];?>', 'vis_domain_id':'<?= $operation['vis_domain_id'];?>'};
		if(filter.length <= 2){
			$("#cmdb_problems").html('<div style="text-align:center;"><?= $vis_language['TXTGLOBALSEARCHERROR'];?></div>');
			return false;
		}else {
			$.ajax({
				url: 'index.php?vis_module=changes&vis_operation=get_problem_list',
				data: data,
				type: "POST",
				dataType: "json",
				success: function(data){
					//alert(data);
					$("#cmdb_problems").html(data.list);
				},
				error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
			});    
		}
	}	
</script>
