<? 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['TXTITILLINKPROBLEM']; ?></h4>
        </div>
        <div class="modal-body">
            <div class="row">
                <div class="col-sm-12">
                <form method="post" role="form" class="form-horizontal" name="vis_problem_form" id="vis_problem_form">
				<div class="form-group">
                  <!-- <div class="col-sm-6">
                   <select class="form-control selectpicker" name="vis_configuration_item" id="vis_configuration_item" <? if(count($confi_item_details) > 10) echo 'data-live-search="true"' ?>>
						<option value="0"><? //=$vis_language['TXTITILSELECTCITYPE']?></option>
						<?php /*for($p=0;$p<count($confi_item_details);$p++){ 
							echo '<option value="'.$confi_item_details[$p]['item_id'].'">'.$confi_item_details[$p]['name'].'</option>';
						}*/?>
                      </select>
                   </div>-->
                   <div class="col-sm-12 text-center">
                   <input type="text" id="search_language_variables" onkeyup="vis_apply_filter(this.value);" placeholder="<?= $vis_language['TXTSEARCHPROBLEM'];?>" class="form-control">
                   </div>
				   <div class="col-sm-3"></div>
                </div>
                <div class="form-group" id="vis_show_amt_balance">
                    <div class="col-sm-12">
                        <div id="cmdb_problems"></div>                        
                    </div>
                </div>
				<input type="hidden" name="vis_ticket_id" id="vis_ticket_id" value="<?= $operation['vis_ticket_id'];?>">
                <input type="hidden" name="vis_dept_id" id="vis_dept_id" value="<?= $operation['vis_dept_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':'problem', 'vis_operation':'attach_cmdb_problem', 'vis_form':'vis_problem_form'});"><? echo $vis_language['TXTATTACH']; ?></a>
        </div>
    </div>
</div>
<script type="text/javascript">
	$('.selectpicker').selectpicker();
	function vis_apply_filter(){
		//alert('tejas');
		var filter = $("#search_language_variables").val();
		//var config_item = $("#vis_configuration_item").val();
		//alert(filter);
		var data = {'vis_filter_enable':'1', 'vis_filter':''+filter+'', 'vis_section':'ticket', 'vis_domain_id':'<?= $operation['vis_domain_id'];?>'};
		//alert(filter);
		if(filter!=''){
		  var len = filter.length;
		  if(len>2){
			$.ajax({
				url: 'index.php?vis_module=problem&vis_operation=get_problem_list',
				data: data,
				type: "POST",
				dataType: "json",
				success: function(data){
					if(data.vis_msg!=undefined)
					{
						$("#vis_global_msg_div").visInterface("load_global_message", data.vis_msg);
					}
					//alert(data);
					$("#cmdb_problems").html(data.list);
				},
				error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
			});
		  }else{
			  $("#cmdb_problems").html('<div style="text-align:center;"><?= $vis_language['TXTGLOBALSEARCHERROR'];?></div>');
		  }
		}
	}	
</script>
