<?  global $vis_language; ?>
<? if($checkExists == 2): ?>
	<script> $("#vis_submit_msg_div").show(); $("#vis_submit_msg_div").html('<? echo $vis_language['MSGSUCCOPRT']; ?>'); </script> 
<? elseif($checkExists != -1): ?>
	<script> $("#vis_submit_err_div").show().html('<? echo $vis_language['MSGALREADYSUBMIT']; ?>'); </script> 	
<? else: 

 if(isset($operation['servay_error_msg'])){ ?>
         <script> $("#vis_submit_err_div").show().html('<? echo $vis_language['MSGINFOMISS']; ?>'); </script> 	 
      <?  }
?>  
  <section class="container m-t-md">
   <div class="row">
      <div class="col-md-12">
        <section class="panel shadow-none">
            <div class="panel-body no-padder">
                <form class="form-horizontal" id="vis_form_client_survey" name="vis_form_client_survey" method="post" role="form">
                    <div class="col-md-12">
                      <div class="wrapper">
                        <? if($custom_field_var == ''): ?>
							<? echo $vis_language['MSGSURVEYERR']; ?>
						<? else: ?>
							<? echo $custom_field_var; ?>
						<? endif; ?>
                          <div class="form-group">
                      </div>
                    </div>
                    <div class="col-lg-offset-2 col-lg-8 m-b-lg">
                          <button type="submit" class="btn btn-primary" onclick="return check_customdata();"><?= $vis_language['TXTSUBMIT']; ?></button>
                          <input type="hidden" name="vis_operation" value="add_client_survey" /><input type="hidden" name="vis_module" value="client" /><input type="hidden" name="vis_email" value="<? echo $user_email; ?>" /><input type="hidden" name="vis_survey" value="<? echo $survey_id; ?>" />
                    </div>
                    </div>
                </form>    
                </div>
			  </div>                 
			 </section>
			<!-- / .panel -->
		</div>
	</div>
</section>
<? endif; ?>   
<script>
var d = new Date();
var curr_time = d.getHours()+":"+d.getMinutes();
var curr_date= '<? echo date("M-d, Y")?> '+curr_time+'';
$('.start').datetimepicker({ format: "<?php echo VIS_DATETIMEPICKER_FORMAT;?>",defaultDate: curr_date});

function check_customdata()
{
	
		var val =  $('#vis_form_client_survey').find('input[name!=vis_operation][name!=vis_module]').serialize();
		var textareaval='';
         $('[id^="field"]' ).each(function(){
		if($(this).is("textarea")){
				 textareaval=textareaval+'&'+this.id+'='+$(this).val();
			}
            });
	
		 var returns=true;
   	 $.ajax({
             url: 'index.php',
             dataType: 'json',
			 async:false,
             data: val+textareaval+'&vis_module=ticket&vis_operation=check_customdata&location=4',
             type: "POST",
			 async:false,
             success: function(data) {
			if(data.res==0)
				 {
					 $("#vis_submit_err_div").show();
					 $("#vis_submit_err_div").html(data.msg); window.scrollTo(0,0);
				 setTimeout(function(){$("#vis_submit_err_div").hide();},10000);
//					  $("#vis_global_msg_div").html(data.msg);

returns=false;
				 }
				 else
				 {
					 returns=true;
				 }
				 
			             }
         });
return returns;
}
</script>
