<? 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 $message_info['vis_form_title']; ?></h4>
		</div>
		<div class="modal-body">
			<div class="row">				
				<div class="col-sm-12">
					<form class="form-horizontal" role="form" name="vis_sla_form" id="vis_sla_form" method="post">
						<div class="form-group">
							<label for="vis_amount" class="col-sm-3 control-label"><?= $vis_language['TXTSLA'] ?></label>
							<div class="col-sm-9">
								<select name="vis_sla" id="vis_sla" class="form-control input-sm selectpicker" <? if(count($sla_details)>10) echo 'data-live-search="true"';?> onchange="if(this.value!=0) $('#vis_custom_duetime').hide(); else $('#vis_custom_duetime').show();"><option value="0"><?= $vis_language['TXTCUSTDUETIME'] ?></option><option value="9999"><?php echo $vis_language['TXTNONE']; ?></option><?
								for($i=0;$i<count($sla_details); $i++) echo '<option value="'.$sla_details[$i]['sla_id'].'">'.$sla_details[$i]['sla_name'].'</option>'; ?></select>
								
							</div>
						</div>
                                                   
						<div id="vis_custom_duetime">
                                                    <div class="form-group">
                                                     <label class="col-sm-3 control-label"><? echo $vis_language['TXTDATE']; ?></label>
                                                        <div class="col-md-2">
								  <input type="checkbox" name="vis_response_datepicker" id="vis_response_datepicker" checked="checked" onchange="return vis_check_responsetime_datepicker();" value="1">                                                 
							</div>
                                                    </div> 
							<div class="form-group">
							   <label class="col-sm-3 control-label"><? echo $vis_language['TXTDUETIME']; ?></label>                                                          
                                                           <div class="col-sm-4" id="response_date_picker" name="response_date_picker">
                                                                <span class="input-group-addon no-padder no-borders from_date">
                                                                    <input id="response_from_date" name="response_from_date" class="form-control input-sm start" type="text" >
                                                                </span>                                                               
                                                           </div>
                                                           <div id="vis_response_datetime_details" name="vis_response_datetime_details" style="display:none;">
                                                                <div class="col-md-2">
                                                                       <input class="form-control input-sm" type="text" name="vis_due_time_days" id="vis_due_time_days" placeholder="<? echo $vis_language['TXTDAYS']; ?>">
                                                                </div>
                                                                <div class="col-md-2">
                                                                       <input class="form-control input-sm" type="text" name="vis_due_time_hrs" id="vis_due_time_hrs" placeholder="<? echo $vis_language['TXTHOURS']; ?>" >
                                                                </div>
                                                                <div class="col-md-2">
                                                                       <input class="form-control input-sm" type="text" name="vis_due_time_mins" id="vis_due_time_mins" placeholder="<? echo $vis_language['TXTMINUTES']; ?>">
                                                                </div>
                                                           </div>
							</div>
							<div class="form-group">
							   <label class="col-sm-3 control-label"><? echo $vis_language['TXTRESOLUTIONTIME']; ?></label>                                                           
                                                           <div class="col-sm-4" id="resolution_date_picker" name="resolution_date_picker">
                                                                <span class="input-group-addon no-padder no-borders from_date">
                                                                    <input id="resolution_from_date" name="resolution_from_date" class="form-control input-sm start" type="text" >
                                                                </span>
                                                           </div>
                                                           <div id="vis_resolution_datetime_details" name="vis_resolution_datetime_details" style="display:none;">
                                                                <div class="col-md-2">
                                                                       <input class="form-control input-sm" type="text" name="vis_resolution_days" id="vis_overduemin" placeholder="<? echo $vis_language['TXTDAYS']; ?>">
                                                                </div>
                                                                <div class="col-md-2">
                                                                       <input class="form-control input-sm" type="text" name="vis_resolution_hrs" id="vis_resolution_hrs" placeholder="<? echo $vis_language['TXTHOURS']; ?>">
                                                                </div>
                                                                <div class="col-md-2">
                                                                       <input class="form-control input-sm" type="text" name="vis_resolution_mins" id="vis_resolution_mins" placeholder="<? echo $vis_language['TXTMINUTES']; ?>">
                                                                </div>
                                                           </div>
							</div>
							 <div class="form-group">
							   <label class="col-sm-3 control-label"><? echo $vis_language['TXTSCHEDULE']; ?></label>
							   <div class="col-sm-9">
								  <select  name="vis_schedule" class="form-control input-sm selectpicker" <? if(count($schedule_details)>10) echo 'data-live-search="true"';?>><?
									 for($i=0;$i<count($schedule_details); $i++){ echo '<option value="'.$schedule_details[$i]['schedule_id'].'">'.$schedule_details[$i]['schedule_name'].'</option>'; } ?>
								  </select>
							   </div>
							</div>
						</div>
						<input type="hidden" name="vis_ticket_id" value="<? echo $operation['vis_ticket_id']; ?>" />
						<input type="hidden" name="vis_client_id" value="<? echo $message_info['client_id']; ?>" />
					</form>
				</div>
			</div>
		</div>
		<div class="modal-footer">		
			<a class="btn btn-default" data-dismiss="modal"><? echo $vis_language['TXTCANCEL']; ?></a>	
			<?if(isset($operation['vis_inbox'])){?>
			<a class="btn btn-primary" onclick="$(this).visExecution('submit_form',{'vis_module':'<? echo $message_info['vis_module']; ?>', 'vis_sla_id':$('#vis_sla').val(), 'vis_due_time':$('#vis_due_time').val(), 'vis_resolve_time':$('#vis_resolve_time').val(), 'vis_operation':'<? echo $message_info['vis_opeartion']; ?>', 'vis_form':'<?= isset($operation['vis_form'])?$operation['vis_form']:'vis_ticket_form'; ?>','vis_inbox':1});"><?= $vis_language['TXTUPDATE']; ?></a>
			<? } else {?>
			<a class="btn btn-primary" onclick="$(this).visExecution('submit_form',{'vis_module':'<? echo $message_info['vis_module']; ?>', 'vis_sla_id':$('#vis_sla').val(), 'vis_due_time':$('#vis_due_time').val(), 'vis_resolve_time':$('#vis_resolve_time').val(), 'vis_operation':'<? echo $message_info['vis_opeartion']; ?>', 'vis_form':'<?= isset($operation['vis_form'])?$operation['vis_form']:'vis_ticket_form'; ?>'});"><?= $vis_language['TXTUPDATE']; ?></a><? }?>
		</div>
	</div>
</div>
<script>
    function vis_check_responsetime_datepicker() {
        if ($("#vis_response_datepicker:checked").length == 0){ 
             $("#response_date_picker").hide(); 
              $("#resolution_date_picker").hide(); 
             $("#vis_response_datetime_details").show();
             $("#vis_resolution_datetime_details").show(); 
        }
        else {
            $("#vis_response_datetime_details").hide(); 
            $("#vis_resolution_datetime_details").hide(); 
            $("#response_date_picker").show(); 
             $("#resolution_date_picker").show(); 
        }
    }   
	$(".selectpicker").selectpicker(); 
        $('.start').datetimepicker({
               format: "<?php echo VIS_DATETIMEPICKER_FORMAT;?>"
               }); 
</script>
