<?php
ob_start();
session_start();
date_default_timezone_set('asia/Kuala_Lumpur');
include "../db/connection.php";
//include "../db/connection_prdcln.php";
include "send-email.php";
ini_set('display_errors',0);
//if(isset($_SESSION) && $_SESSION['logged']!=1){
  //header("Location:http://ytyportal.ytygroup.my/formsyty/Authenticate/login.php");
  //die;
//}
//*********************************SUPPORT EMAIL START BY DEEP RANA*****************/
$querySE= "SELECT YTY_FN_EMPGRV_REPLY AS SUPPORT_EMAIL FROM DUAL"; 
$supportEmailDetails = oci_parse($dbcon,$querySE);
oci_execute($supportEmailDetails);
$rowSupt=oci_fetch_array($supportEmailDetails);
//echo"<pre>";print_r($rowSupt);die;
//*********************************SUPPORT EMAIL END BY DEEP RANA*****************/

if(isset($_POST['emp_name']) && isset($_POST['emp_id']))
{
  if($_POST['emp_id_1']=="" || $_POST['emp_name']=="" || $_POST['emp_id']=="")
  { 
    echo '<script>';
    echo 'alert("EmployeeID & Employee name should not be left blank.");';
    echo '</script>';
    echo '<script>';
    echo 'window.location.href ="https://ytygroup.app/formsyty/yty-grievance-form.php";';
    echo '</script>';
  }
  if(isset($_POST['g-recaptcha-response'])){
    $captcha=$_POST['g-recaptcha-response'];
  }
  if(!$captcha){
    echo "<script>alert('Captcha can not be left blank.');</script>";
    echo '<script>';
    echo 'window.location.href ="https://ytygroup.app/formsyty/yty-grievance-form.php";';
    echo '</script>';
  }
  //echo"<pre>";print_r($_POST);die;
  $query= "SELECT YTY_FN_EMP_GRV_SRNO('".$_POST['emp_id_1']."') as MAX_ID FROM DUAL"; 
  $tableDetails = oci_parse($dbcon, $query);
  oci_execute($tableDetails);
  $row=oci_fetch_array($tableDetails);
  $applicationNo=$row['MAX_ID'];
  //************* Get application no code end here by deep rana*/
  $insertFlag=0;
  $emp_id = $_POST['emp_id'];
  $emp_name = $_POST['emp_name'];
  $date_form_submitted = date('d-M-Y',strtotime($_POST['date_form_submitted']));
  $postion = $_POST['postion'];
  $employee_sign = $_POST['employee_sign'];
  $date = date('d-M-Y',strtotime($_POST['date']));
  //*********************************/
  $event_location = $_POST['event_location'];
  $event_location_Date = $_POST['event_location_Date'];
  $witness ='NA';
  if($_POST['witness'])
    $witness = $_POST['witness'];

  $event_account = $_POST['event_account'];
  $violation = $_POST['violation'];
 //*********************************/
 list($default,$eng,$selected)=explode("/",$_COOKIE['googtrans']);
 $from_language ='en';
 if($selected)
  $from_language =$selected;

 $to_language ='en';

   //echo"<pre>";print_r($_COOKIE);die;
 $event_location1= $event_location;
 $witness1= $witness;
 $event_account1= $event_account;
 $violation1= $violation;
 if($from_language!=$to_language)
 { 
   $returnLangEl=googleTranslatorCoverter($event_location,$from_language,$to_language);
   if (!empty($returnLangEl)) {
    $event_location1= $returnLangEl;
   }

   $returnLangWt=googleTranslatorCoverter($witness,$from_language,$to_language);
   if (!empty($returnLangWt)) {
    $witness1= $returnLangWt;
   }
   
   $returnLangEa=googleTranslatorCoverter($event_account,$from_language,$to_language);
   if (!empty($returnLangEa)) {
    $event_account1= $returnLangEa;
   }

   $returnLangVl=googleTranslatorCoverter($violation,$from_language,$to_language);
   if (!empty($returnLangVl)) {
    $violation1= $returnLangVl;
   }
 }
  //*********************************/
  $team_handled = $_POST['team_handled'];
  $emp_sign_1 = $_POST['emp_sign_1'];
  $date_1 = date('d-M-Y');
  $received_sign = $_POST['received_sign'];
  $date_2 = $_POST['date_2'];
  $email_id = $_POST['email_id'];
  $mobile =($_POST['mobile']) ? "60".$_POST['mobile'] : "";
  $grievance_status ='0';
  $sought_status="N";
  $currentUser = $_SESSION['EMP_ID'];
  if($_POST['sought_check']=='on')
  {
    $sought_status="Y";
  }
  $fileName="";
  $i=0;
  $fno=1;
  $filesNames="";
  for($i=0;$i<count($_FILES['attachment']['name']);$i++)
  {
    $fileNamses=$_FILES['attachment']['name'][$i];
    $tmpName=$_FILES['attachment']['tmp_name'][$i];
    if($fileNamses!='')
    {
    $ext = pathinfo($fileNamses, PATHINFO_EXTENSION);
    $fileName=$applicationNo."_".$fno.".".$ext;
    $filesNames=$filesNames.",".$fileName;
    move_uploaded_file($tmpName,"upload/".$fileName);
    }
    $fno++;
  }
   $filesNames=ltrim($filesNames,",");
    $insert_query = "INSERT INTO EMPLOYEE_GRIEVANCE (EMP_ID,EMPLOYEE_NAME ,SUBMISSION_DATE,POSITION,EMP_SIGNATURE_1,SIGN_DATE_1,GRIEVANCE_DETAILS,WITNESS_NAME,ACCOUNT_OF_EVENT,VIOLATIONS,CORRECTIVE_ACTION,STATUS_OF_GRIEVANCE,HANDLED_BY,EMP_SIGNATURE_2,SIGN_DATE_2,APPLICATION_ID,EMPLOYEE_EMAIL,EMPLOYEE_MOB,GRIEVANCE_DETAILS_HR,WITNESS_NAME_HR,ACCOUNT_OF_EVENT_HR,VIOLATIONS_HR,EMP_GRV_LANGUAGE,HR_LANGUAGE,OPEN_FOR_OTHERS,GRIEVANCE_ATTACHMENT,CREATED_BY,CREATED_DATE) VALUES ('$emp_id','$emp_name','$date_form_submitted','$postion ','$employee_sign','$date','".str_replace("'","''",$event_location)."','".str_replace("'","''",$witness)."','".str_replace("'","''",$event_account)."','".str_replace("'","''",$violation)."','$received_sign','$grievance_status','$team_handled','$emp_sign_1','$date_1','$applicationNo','$email_id','$mobile','".str_replace("'","''",$event_location1)."','".str_replace("'","''",$witness1)."','".str_replace("'","''",$event_account1)."','".str_replace("'","''",$violation1)."','$from_language','$to_language','$sought_status','$filesNames','$currentUser',sysdate)";
    $executeQuery1= oci_parse($dbcon,$insert_query);
    if(oci_execute($executeQuery1))
    {
      $query1= "SELECT  YTY_FN_EMP_GRV_PASS_VERIF('".$applicationNo."') PASSCODE FROM DUAL"; 
      $tableDetails1= oci_parse($dbcon, $query1);
      oci_execute($tableDetails1);
      $row1=oci_fetch_array($tableDetails1);
      $passCode=$row1['PASSCODE'];
      //****************************CODE TO SEND SMS BY DEEP RANA*********************************/
      if($mobile!="")
      { 
        $encode=base64_encode($applicationNo."_".$from_language);
        $replaceLink='https://ytygroup.app/formsyty/yty-grievance-serarch-form.php?empDet='.$encode;
        $querySmsTemplate= "SELECT SMS_TEMPLATE FROM XXYTY_SMS_TEMPLATE T WHERE T.PORTAL_TYPE = '1005' AND T.FROM_TYPE = 'ENTRYFORM'"; 
        $tableDetailsSMS= oci_parse($dbcon, $querySmsTemplate);
        oci_execute($tableDetailsSMS);
        $row2=oci_fetch_array($tableDetailsSMS);
        $sms_template=$row2['SMS_TEMPLATE'];
        $searchArr=array('APPLICATION_ID','PASSCODE','LINK');
        $replaceArr=array($applicationNo,$passCode,$replaceLink);
        $mergeSMS=MsgTextFormat($searchArr,$replaceArr,$sms_template);
        //echo"<pre>";print_r($mergeSMS);die;
        $returnSms=gw_send_sms($mobile,$mergeSMS);
      }
      $encode=base64_encode($applicationNo."_".$from_language);
      //****************************CODE TO SEND EMAIL BY DEEP RANA*********************************/
      $html='<!doctype html>
      <html>
      <head>
        <title></title>
        <style type="text/css">
          table {border-collapse:separate;}
          .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td {line-height: 100%}
          .ExternalClass {width: 100%;}
      
          .wrapper {
            width:100%;
            background-color: #fff;
          }
      
          .container {
            width:800px !important;
          }
      
          .content {
            background-color: #fff;
            border: 1px solid #D6D6D6;
            -webkit-box-shadow: 0px 0px 7px 1px rgba(0,0,0,0.75);
            -moz-box-shadow: 0px 0px 7px 1px rgba(0,0,0,0.75);
            box-shadow: 0px 0px 7px 1px rgba(0,0,0,0.55);
          }
      
          .mbody {
            color: #000;
            font-family: Verdana;
            font-style: normal;
            font-size: 10.5pt;
          }
      
          .note {
            font-size: 7.5pt;
            font-family: Verdana;
            color: #000;
            text-align: justify;
          }
        </style>
      </head>
      <body>
      <table cellpadding="0" cellspacing="0" align="center" border="0" width="100%" style="height:100%!important; margin:0; padding:0; width:100%!important; text-align:center">
      <tr>
        <td style="height:20px; display:block;"></td>
      </tr>
      <tr>
        <td style="width:20px; display:block;"></td>
        <td align="center">
          <table class="content" border="0" cellspacing="0" cellpadding="0" width="800" style="border-collapse: collapse; border:1px solid #7f7f7f;">
          <tr>
            <td>
              <img src="http://dl.ytygroup.com.my/CommonLogo/MailHeader.jpg" width="952" height="106" style="display:block;"/>
            </td>
          </tr>
          <tr>
            <td style="height:10px; display:block;"></td>
          </tr>
          <tr>
            <td>
              <table class="mbody" style="width:100%;">
              <tr>
                <td style="width:20px; display:block;"></td>
                <td style="line-height: 1.3em;">
                  <p>Thank you for submitting.</p>
                  <p><b>Application no.:</b>'.$applicationNo.'</p>
                  <p><b>Passcode:</b>'.$passCode.'</p>
                  <br/><p><a href="https://ytygroup.app/formsyty/yty-grievance-serarch-form.php?empDet='.$encode.'">See More Detail</a></p>
                  <br/><p>Sincerely,<br /><b>YTY Workflow</b></p> 
                  <p style="font-size:11px;">Note: This message is auto-generated so please do not respond to this email.</p></td>
                <td style="width:20px; display:block;"></td>
              </tr>
              </table>
            </td>
          </tr>
          <tr>
            <td style="height:10px; display:block;"></td>
          </tr>
          <tr>
            <td>
              <img src="http://dl.ytygroup.com.my/CommonLogo/MailFooter.jpg" style="display:block;"/>
            </td>
          </tr>
          </table>
        </td>
        <td style="width:20px; display:block;"></td>
      </tr>
      <tr>
        <td style="height:20px; display:block;"></td>
      </tr>
      </table>
      </body>
      </html>';
      $htmlHr='<!doctype html>
      <html>
      <head>
        <title></title>
        <style type="text/css">
          table {border-collapse:separate;}
          .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td {line-height: 100%}
          .ExternalClass {width: 100%;}
      
          .wrapper {
            width:100%;
            background-color: #fff;
          }
      
          .container {
            width:800px !important;
          }
      
          .content {
            background-color: #fff;
            border: 1px solid #D6D6D6;
            -webkit-box-shadow: 0px 0px 7px 1px rgba(0,0,0,0.75);
            -moz-box-shadow: 0px 0px 7px 1px rgba(0,0,0,0.75);
            box-shadow: 0px 0px 7px 1px rgba(0,0,0,0.55);
          }
      
          .mbody {
            color: #000;
            font-family: Verdana;
            font-style: normal;
            font-size: 10.5pt;
          }
      
          .note {
            font-size: 7.5pt;
            font-family: Verdana;
            color: #000;
            text-align: justify;
          }
        </style>
      </head>
      <body>
      <table cellpadding="0" cellspacing="0" align="center" border="0" width="100%" style="height:100%!important; margin:0; padding:0; width:100%!important; text-align:center">
      <tr>
        <td style="height:20px; display:block;"></td>
      </tr>
      <tr>
        <td style="width:20px; display:block;"></td>
        <td align="center">
          <table class="content" border="0" cellspacing="0" cellpadding="0" width="800" style="border-collapse: collapse; border:1px solid #7f7f7f;">
          <tr>
            <td>
              <img src="http://dl.ytygroup.com.my/CommonLogo/MailHeader.jpg" width="952" height="106" style="display:block;"/>
            </td>
          </tr>
          <tr>
            <td style="height:10px; display:block;"></td>
          </tr>
          <tr>
            <td>
              <table class="mbody" style="width:100%;">
              <tr>
                <td style="width:20px; display:block;"></td>
                <td style="line-height: 1.3em;">
                  <p>New Grievance entry has been received.</p>
                  <p><b>Application no. is :</b>'.$applicationNo.'</p>
                  <p><b>Employee ID :</b>'.substr($emp_id,3).'</p>
                  <p><b>Employee Name :</b>'.$emp_name.'</p>
                  <br/><p>Sincerely,<br /><b>YTY Workflow</b></p> 
                  <p style="font-size:11px;">Note: This message is auto-generated so please do not respond to this email.</p></td>
                <td style="width:20px; display:block;"></td>
              </tr>
              </table>
            </td>
          </tr>
          <tr>
            <td style="height:10px; display:block;"></td>
          </tr>
          <tr>
            <td>
              <img src="http://dl.ytygroup.com.my/CommonLogo/MailFooter.jpg" style="display:block;"/>
            </td>
          </tr>
          </table>
        </td>
        <td style="width:20px; display:block;"></td>
      </tr>
      <tr>
        <td style="height:20px; display:block;"></td>
      </tr>
      </table>
      </body>
      </html>';
      //echo"<pre>";print_r($email_id);
      if($email_id){ 
        $mailSubject="GRIEVANCE SYSTEM-APPLICATION RECEIVED/APPLICATION ID:".$applicationNo;
        $mailSubjectHr="GRIEVANCE SYSTEM-NEW GRIEVANCE CASE RECEIVED/APPLICATION ID:".$applicationNo;
        sendEmail($email_id,$mailSubject,$html,'');
        sendEmail($rowSupt['SUPPORT_EMAIL'],$mailSubjectHr,$htmlHr,'');
      }
      $insertFlag=1;
    }           
    if($insertFlag==1)
    {
      header("location:yty-grievance-print_form.php?appId=".$applicationNo."&passcode=".$passCode); 
      die;    
    }
    else
    {
        header("location:yty-grievance-form.php?msg=Data Not Inserted.");
        die;      
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <title>EMPLOYEE GRIEVANCE AND REDRESSAL</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="css/mystyle.css">
  <link rel="shortcut icon" href="favicon.png" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <script src="https://www.google.com/recaptcha/api.js" async defer></script>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="https://code.jquery.com/ui/1.8.23/themes/base/jquery-ui.css">
  <script src="https://code.jquery.com/jquery-1.8.2.js"></script>
  <script src="https://code.jquery.com/ui/1.8.23/jquery-ui.js"></script>
  <link rel="stylesheet" href="https://jqueryui.com/resources/demos/style.css">
  <script type="text/javascript" src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
  <script type="text/javascript">
  function googleTranslateElementInit() {
    new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
  }
  </script>
  <script type="text/javascript">
  function googleTranslateElementInit() {
    new google.translate.TranslateElement({pageLanguage: 'en' , includedLanguages : 'en,hi,ms,bn,my,vi,ta,ne'}, 'google_translate_element');
  }
  
  </script>
</head>
<body onload="Captcha();">
<style>
 .goog-logo-link{display: none !important;}
.goog-te-gadget{height: 28px !important;  overflow: hidden;}
body{ top: 0 !important;}
.goog-te-banner-frame{display: none !important;}
</style>
<header id="myHeader">
  <div class="container-fluid">
   <div class="col-md-8 col-sm-7 col-xs-12 pull-left">
     <img src="medi-logo1.png" alt="YTY"><span>EMPLOYEE GRIEVANCE AND REDRESSAL</span>
   </div>
   
   <div class="col-md-4 col-sm-5 col-xs-12 pull-right">
    <div class="row">
        <div class="col-md-6 col-sm-6 col-xs-6" style="padding:0"> 
         <div class="modal-content">    
         <div id="google_translate_element">
           <button><i class="fa fa-language"></i></button> 
          </div>
        </div>
       </div>  
       
       <div class="col-md-5 col-sm-4 col-xs-4" style="padding:0; padding-right:3px;"> 
        <div class="lng-icon"><button><a href="yty-grievance-serarch-form.php">GRIEVANCE STATUS</a></button></div>
       </div>
       <div class="col-md-1 col-sm-2 col-xs-2" style="padding:0"> 
        <div class="lng-icon"><a href="upload/YTY_Grievance_User_Manual.pdf" target="_blank" title="Manual Help" style="color: #fff;"><button title="Manual Help"><i class="fa fa-info" title="Manual Help" aria-hidden="true" style="font-size: 18px;"></i></button></a></div>
       </div>      
    </div>        
   </div>
  </div>
</header>

 <div class="container-fluid mydesignform">
 
   <div class="row">  
     <div class="divtitle">
       <h1>EMPLOYEE GRIEVANCE FORM<span>(Employees are strongly encouraged to have informal discussions before filling the  grievance form)</span></h1>
     </div>  
     <div class="col-sm-12 col-xs-12">
                    <?php
          if($_REQUEST['msg'])
          {
            ?>
                        <div class="alert alert-success" id="success-alert">
                          <button type="button" class="close" data-dismiss="alert">x</button>
                          <strong><?php echo $_REQUEST['msg'];?>.</strong>
                          <span style="display: block;color: #ef0000;font-size: 12px;font-weight: 600;"><strong>Note : </strong> Grievances filed &nbsp;will be&nbsp; maintained&nbsp; with confidentiality and no employee shall be subjected to retaliation for initiating or participating in the grievance filing procedure.</span>
                        </div>  
          <?php
          }
          ?>
          </div>
   </div>
   
   <div class="row">
      <form action="" method="post" id="formSubmit" enctype="multipart/form-data">
      <div class="section1bg">
      <!--heading Start-->  
      <div class="col-lg-12 col-12 formheading">EMPLOYEE'S INFORMATION</div>
      <!--heading End-->     
       <!--Form Column Start-->
      <div class="col-lg-6 col-md-6 col-sm-6 col-6 autodropdownlist">
        <div class="form-group">
         <label for="email">EMPLOYEE ID<span>*</span></label>
         <input type="text" autocomplete="off" style="text-transform: uppercase;" class="form-control" maxlength="6" max="6" name="emp_id_1" required id="emp_id_1"   onkeyup="return wating(this.value)">
         <input type="hidden"  class="form-control" name="emp_id" required id="emp_id">
        </div>
        <span id="empList"></span>
      </div>
      <!--Form Column End-->
   
      <!--Form Column Start-->
      <div class="col-lg-6 col-md-6 col-sm-6 col-6">
        <div class="form-group">
         <label for="email">EMPLOYEE NAME<span>*</span></label>
         <input type="text" class="form-control" name="emp_name" id="emp_name" readonly placeholder="" required>
        </div>
      </div>      
      <!--Form Column End-->
      <!--Form Column Start-->
      <div class="col-lg-6 col-md-6 col-sm-6 col-6">
        <div class="form-group">
         <label for="email">DATE FORM SUBMITTED<span>*</span></label>
         <input class="form-control" readonly name="date_form_submitted" value="<?php echo date('d-M-Y')?>" id="" required type="text"  autocomplete="off"/>
         <input type="hidden" class="form-control" name="postion" id="postion" readonly required>
         <input type="hidden" class="form-control" readonly name="employee_sign" id="employee_sign">
         <input class="form-control" name="date" type="hidden" value="<?php echo date('d-M-Y')?>" readonly autocomplete="off"/>
        </div>
      </div>
      <!--Form Column End--> 
       <!--Form Column Start-->
       <div class="col-lg-6 col-md-6 col-sm-6 col-6">
        <div class="form-group">
         <label for="email">Email</label>
         <input type="email" class="form-control" onblur="return ValidateEmail(this.value)"  name="email_id" id="email_id" >
        </div>
      </div>
      <!--Form Column End-->
      <!--Form Column Start-->
      <div class="col-lg-6 col-md-6 col-sm-6 col-6">
        <div class="form-group">
         <label for="email">Mobile <span>*</span></label>
         <input type="tel" name="code" class="form-control smallinputleft" readonly value="+60" required="required" style="width: 62px;position: absolute;">
          <input class="form-control" name="mobile" onblur="return valid_phone_num(this.value)" onkeypress='return isNumberKey(event)' id="mobile"minlength="9" maxlength="10" autocomplete="off" type="text"   autocomplete="off" style="padding-left: 70px"/>
          <span id="error_msg"></span>
        </div>
      </div>
      <!--Form Column Start-->
      <div class="col-lg-6 col-md-12">
        <div class="form-group" style="margin-top:14px">
            <span><input type="checkbox" style="width: 20px;margin: 0;height: 20px;margin-top: 13px;position: relative;top: 4px;" name="sought_check" checked /></span>
         <label for="email">Open to be contacted if further information is sought.</label>
     
        </div>
      </div>
       <!--Form Column End--> 
      <!--Form Column End-->  
     </div>
     <div class="section1bg">
      <!--heading Start-->  
      <div class="col-lg-12 col-12 formheading">DETAILS OF EVENT LEADING TO GRIEVANCE</div>
      <!--heading End-->      
      <!--Form Column Start-->
      <div class="col-lg-6 col-md-4 col-sm-4 col-6">
        <div class="form-group">
         <label for="email">DATE, TIME, AND LOCATION OF EVENT <span>*</span></label>
         <textarea class="form-control"  name="event_location" id="event_location" maxlength="3875" placeholder="Location of event. If you cannot remember the exact date, please enter the approximate date." required></textarea>
        </div>
      </div>
      <!--Form Column End--> 
      <!--Form Column Start-->
      <div class="col-lg-6 col-md-4 col-sm-4 col-6">
        <div class="form-group">
         <label for="email">WITNESSES <strong>if applicable</strong></label>
         <textarea class="form-control"  name="witness" placeholder="Witnesses" maxlength="3875" required></textarea>
        </div>
      </div>
      <!--Form Column End--> 
      <!--Form Column Start-->
      <div class="col-lg-6 col-md-6 col-sm-6 col-6">
        <div class="form-group">
         <label for="email">ACCOUNT OF EVENT <span>*</span></label>
         <textarea type="text" class="form-control" name="event_account" id="event_account" maxlength="3875" placeholder="Provide a detailed account of the occurrence. 
Include the names of any additional persons involved." required></textarea>
        </div>
      </div>
      <!--Form Column End--> 
      <!--Form Column Start-->
      <div class="col-lg-6 col-md-6 col-sm-6 col-6">
        <div class="form-group">
         <label for="email">VIOLATIONS <span>*</span></label>
         <textarea type="text" class="form-control" name="violation" id="violation" maxlength="3875" placeholder="Provide a list of any policies, procedures, or guidelines you believe have been violated in the event described." required></textarea>
        </div>
      </div>
       <!--Form Column End-->
    
       <!--Form Column Start-->
       <div class="col-lg-6 col-md-12 col-sm-12 col-6">
       <label for="email">Captcha Verify</label>
       <div class="row">
       <div class="col-lg-6 col-md-12 col-sm-12 col-6">
        <div class="form-group">  
        <div class="g-recaptcha" data-sitekey="6LeIK10aAAAAAOM4c7ilmla7hc32k86IduputXr3"></div></td>
        <!--<input type="text"  class="form-control" id="mainCaptcha" readonly style="border:none;font-weight: bold;background-color: #c1c1c1;"/> 
        <input type="button" id="refresh" value="Refresh" onclick="Captcha();" style="height: auto;background: none;border: none;background-color: rgb(240 248 255 / 0%) !important;box-shadow: none;text-align: left;font-weight: 600;padding-left: 3px;color: #0d62ab;"  class="form-control"/>-->
        </div>
        </div>
        <div class="col-lg-6 col-md-12 col-sm-12 col-6">
        <div class="form-group">
         <!--<input type="text" id="txtInput"  onpaste="return false;" autocomplete="off" class="form-control" placeholder="Enter left captcha here."/><span id="error_captcha" style="font-size: 13px;position: relative;top: 4px;left: 3px;color: #ff0029;font-weight: 600;"></span>-->    
       </div>
        
        </div>
     
        
        </div>       
      </div>
      <!--Form Column Start-->
      <div class="col-lg-6 col-md-6 col-sm-6 col-6">
        <div class="form-group">
         <label for="email">Attachment</label> <span>*file format: JPG, PNG, PDF</span>
          <input class="form-control" type="file" name="attachment[]" multiple accept=".png,.jpg,.pdf"  id="attachment"  />
        </div>
      </div>
      <!--Form Column Start--> 
      <!--Form Column Start-->
      <div class="col-lg-12 col-md-12 col-sm-12 col-6">
        <div class="form-group">
         <button type="submit" class="formbutton" onclick="return submitForm();" id="btnLogin">Submit Form</button>
         <label id='internet-connection-error' style='color: #F44336;'></label>
        </div>
      </div>      
      <!--Form Column End-->   
   
     </div>
      <div class="section1bg" style="display:none;">
      <!--heading Start-->  
      <div class="col-lg-12 col-12 formheading">CORRECTIVE ACTION</div>
      <!--heading End-->     
      <!--Form Column Start-->
      <div class="col-lg-12 col-md-4 col-sm-4 col-6">
        <div class="form-group">
         <label for="email">HANDLED BY GRIEVANCE ADMINISTRATOR </label>
         <textarea type="text" disabled class="form-control"  name="team_handled" placeholder="Handled by Grievance Administrator"><?php echo $rowDetailsArr['HANDLED_BY'];?></textarea>
        </div>
      </div>      
      <!--Form Column End-->
      <div class="col-lg-6 col-md-6 col-sm-6 col-6">
        <div class="form-group">
         <label for="email">RECEIVED BY:  [GRIEVANCE ADMINISTRATOR] NAME AND SIGNATURE</label>
         <input type="text" class="form-control" disabled  name="received_sign" placeholder="">
        </div>
      </div>      
      <!--Form Column End--> 
       <!--Form Column Start-->
      <div class="col-lg-6 col-md-6 col-sm-6 col-6">
        <div class="form-group">
         <label for="email">DATE</label>
          <input class="form-control" name="date_2" disabled  placeholder="DD-MM-YYYY" type="text" autocomplete="off"/>
          <div class="input-group-addon dateicon">
              <span class="glyphicon glyphicon-th"></span>
          </div>
        </div>
      </div>
      <!--Form Column End--> 
        <!--Form Column Start-->
      <div class="col-lg-6 col-md-12 col-sm-12 col-6">
        <div class="form-group">
         <label for="email">
         <strong class="indicatorbg" style="margin-left:0;">Open &nbsp; <strong class="open" style="margin-right:0;"></strong></strong>
         </label>        
        </div>
      </div>      
      <!--Form Column End-->      
     
     </div>
     <div class="section1bg" style="display:none;">
      <!--heading Start-->  
      <div class="col-lg-12 col-12 formheading">ADMINISTRATIVE SECTION</div>
      <!--heading End-->     
      <!--Form Column Start-->
      <div class="col-lg-12 col-md-4 col-sm-4 col-6">
        <div class="form-group">
         <label for="email">COMMENT</label>
         <textarea type="text" class="form-control"  name="comment" disabled placeholder=""></textarea>
        </div>
      </div> 
      <!--heading End-->          
      <!--Form Column Start-->
       <div class="col-lg-6 col-md-12 col-sm-12 col-6 autodropdownlist">
        <div class="form-group">
         <label for="email">ASSIGN TO<span>*</span></label>
         <input type="text" class="form-control"  disabled name="emp_id" required id="emp_id" autocomplete="off" onkeyup="return wating(this.value)" onchange="return getEmployeeDetails(document.getElementById('txtUserid').value)">
         <input type="hidden" class="form-control"  name="assign_emp_id" required id="assign_emp_id">
        </div>
        <span id="empList"></span>
      </div>
      <!--Form Column End-->
       <!--Form Column Start-->
      <div class="col-lg-6 col-md-12 col-sm-12 col-6">
      <div class="form-group">
         <label for="email">CATEGORY</label>
          <select name="priority" id="priority" class="form-control" disabled>
            <option>--Category--</option>
          </select>
        </div>
      </div> 
      <!--heading End-->
       <!--Form Column Start-->
       <div class="col-lg-12 col-md-12 col-sm-12 col-6">
        <div class="form-group">
         <label for="email">STATUS OF GRIEVANCE 
         <strong class="indicatorbg">Open <strong class="open"></strong> Close <strong class="close"></strong></strong>
         </label><br>
         <label class="switch">
         <input type="checkbox" name="grievance_status"  disabled><div class="status_slider round"></div></label>       
        </div>
      </div>      
      <!--Form Column End-->       
     
     </div>
      </form>
     </div>  
  </div>
  <script>
  $(function() {
  $( "#datepicker" ).datepicker({dateFormat: 'dd-M-yy'});
  });
</script>
  <script>
  function wating(val)
  {
      document.getElementById('empList').innerHTML="";
      console.log(val);
      if(val.length < 6)
      {
        return false;
      }
      document.getElementById("empList").innerHTML='Loading please wait...';
      document.getElementById('btnLogin').disabled=true;
      $.ajax({
        url: "search_employee_by_id.php?term="+val+"&type=1",
        type: 'get',
        dataType: 'json',
        success:function(response) {
          if(response!="")
          {
            //alert(response[1]);
            if(response[1]==1){
              $("#emp_id_1").val(response[0][0].EMP_ID);
              $("#emp_id").val(response[0][0].EMP_MAIN_ID);
              $("#emp_name").val(response[0][0].EMPLOYEE_NAME);
              $("#postion").val(response[0][0].DEPARTMENT);
              $("#employee_sign").val(response[0][0].EMPLOYEE_NAME);
              $("#email_id").val(response[0][0].EMAIL_ID);
              document.getElementById("emp_name").focus();
              document.getElementById('btnLogin').disabled=false;
              document.getElementById("empList").innerHTML='';
              return false;
            }
            else{
              $("#emp_id").val('');
              $("#emp_name").val('');
              $("#postion").val('');
              $("#employee_sign").val('');
              $("#email_id").val('');
              document.getElementById("emp_name").focus();
              document.getElementById('empList').innerHTML=response[0];
              document.getElementById('btnLogin').disabled=false;
              getEmployeeDetails(val);
              return false;
            }           
          }
        }
        }); 
    //else
      //document.getElementById("loading").innerHTML='';
  }
  function fillTextData(data)
  {
    var dataArr=data.split("_");
    $("#emp_id_1").val(dataArr[1]);
    $("#emp_id").val(dataArr[0]);
    $("#emp_name").val(dataArr[2]);
    $("#postion").val(dataArr[3]);
    $("#employee_sign").val(dataArr[2]);
    $("#email_id").val(dataArr[4]);
    document.getElementById("empList").innerHTML='';
  }
  function getEmployeeDetails(value)
  {

    if(Number(document.getElementById("emp_id_1").value))
      val=document.getElementById("emp_id_1").value;
    else
      val=value;
      
    if(val.length < 6)
    {
      alert('Invalid Employee ID.');
      $("#emp_id_1").val('');
      return false;
    }
    if(val!=""){
      $.ajax({
        url: "search_employee_by_id.php?term="+val+"&type=1",
        type: 'get',
        dataType: 'json',
        success:function(response) {
          if(response[1]==0)
          {
            alert('Invalid Employee ID.');
            $("#emp_id").val('');
            $("#emp_id_1").val('');
          }
        }
        }); 
    }
  }
  function isNumberKey(evt){
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;
    return true;
}
function ValidateEmail(email)
{
    const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    if(re.test(String(email).toLowerCase()))
    {
        return true;
    }
    else{
      alert("You have entered an invalid email address!");
      document.getElementById('email_id').value="";
      return false;
    }
}
function valid_phone_num(txtMobile)
{
  $('#error_msg').html('');
  if(txtMobile)
    var txtMobile="60"+txtMobile;

  const mob = /^(\+?6?01)[0|1|2|3|5||4|6|7|8|9]\-*[0-9]{7,8}$/;
  if(txtMobile!="")
  { 
    if (mob.test(txtMobile) == false) {
        $('#error_msg').html('<i class="fa fa-exclamation-triangle" aria-hidden="true" style="color: red;font-weight: bold;"> Please enter valid mobile number.');
        document.getElementById('mobile').value="";
        return false;
    }
    return true;
  }
}
$("#mobile").keyup(function(){
    var value = $(this).val();
    value = value.replace(/^(0*)/,"");
    $(this).val(value);
});
function submitForm()
  {
    document.getElementById('internet-connection-error').innerHTML = '';
    if($("#mobile").val().length == 0){
      alert("Phone is required")
      $('#mobile').css("border","2px solid red").focus()
      return false
    }
    
    if(document.getElementById("emp_id_1").value==''){ 
      $('#emp_id_1').attr('required',true);
      alert('EmloyeeID should not left blank.');
      document.getElementById('emp_id_1').style.border='2px solid red';
      document.getElementById('emp_id_1').focus();
      return false;
    }
    if(document.getElementById("emp_name").value==''){ 
      $('#emp_name').attr('required',true);
      alert('Emloyee name should not left blank.');
      document.getElementById('emp_name').style.border='2px solid red';
      document.getElementById('emp_name').focus();
      return false;
    }

    if(document.getElementById("emp_id_1").value.length < 6)
    {
      alert('Invalid Employee ID.');
      $("#emp_id_1").val('');
      return false;
    }
    if(document.getElementById("event_location").value=='')
    {
      alert('Location of event should not left blank.');
      document.getElementById('event_location').style.border='2px solid red';
      document.getElementById('event_location').focus();
      return false;
    }
    if(document.getElementById("event_account").value=='')
    {
      alert('Account of event should not left blank.');
      document.getElementById('event_account').style.border='2px solid red';
      document.getElementById('event_account').focus();
      return false;
    }
    if(document.getElementById("violation").value=='')
    {
      alert('Violation should not left blank.');
      document.getElementById('violation').style.border='2px solid red';
      document.getElementById('violation').focus();
      return false;
    }
    var googleResponse = jQuery('#g-recaptcha-response').val();
      if (!googleResponse) {
      	alert('Please check the captcha.');
      	return false;
      }
    /*if(!ValidCaptcha()){
         $('#error_captcha').html('Invalid Captcha !');
         $('#txtInput').focus();
         return false;
    }*/
    document.getElementById("btnLogin").style.color='#000 ';
    var online = isOnline();
    if (online==true){
      document.getElementById('btnLogin').innerHTML ="Processing please wait..."; 
      $('#btnLogin').attr('disabled',true);
      document.getElementById('formSubmit').submit();
      return true;
    }
    document.getElementById('internet-connection-error').innerHTML = 'No internet connection. Please check your internet connection and try again.';
     return false;
  }
  function isOnline() { 
    return (navigator.onLine) 
}
</script>
<script type="text/javascript">
     function Captcha(){
         var alpha = new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
         var i;
         for (i=0;i<6;i++){
           var a = alpha[Math.floor(Math.random() * alpha.length)];
           var b = alpha[Math.floor(Math.random() * alpha.length)];
           var c = alpha[Math.floor(Math.random() * alpha.length)];
           var d = alpha[Math.floor(Math.random() * alpha.length)];
           var e = alpha[Math.floor(Math.random() * alpha.length)];
           var f = alpha[Math.floor(Math.random() * alpha.length)];
           //var g = alpha[Math.floor(Math.random() * alpha.length)];
          }
        var code = a + ' ' + b + ' ' + ' ' + c + ' ' + d + ' ' + e + ' '+ f ;
        document.getElementById("txtInput").value ='';
        $('#error_captcha').html('');
        document.getElementById("mainCaptcha").value = code
      }
      function ValidCaptcha(){
          var string1 = removeSpaces(document.getElementById('mainCaptcha').value);
          var string2 = removeSpaces(document.getElementById('txtInput').value);
          if (string1 == string2){
            return true;
          }
          else{        
            return false;
          }
      }
      function omitMessage()
      {
         $('#error_captcha').html('');
      }
      function removeSpaces(string){
        return string.split(' ').join('');
      }
      function checktextcount(textVal,countMsg,id)
      {
        $("#"+countMsg).text("Characters : " + (textVal.length));
      }
     
 </script>
</body>
</html>
