 <?php 
   require_once("headHotelStaff.php");
   if(isset($_POST['post']))

  {

     if( isset($_POST['hiD']) && isset($_POST['owniD']))
     {

        $hnm=$_POST['hiD'];
        $ownID=$_POST['owniD'];  
     
      
    }
  }
?> 
 
  
 
   <!--NEW USER REGISTRATION FORM, DISPLAYED BY DEFAULTS IN PAGE LOAD-->
    <center>
  <label id="succ">
    <?php  
    
    echo $con->addRoute($start,$rlength,$routeId,$end,$ldistance,$via,$hnm);
     ?>
 </label>
</center> 
   
<center><fieldset id="new_sevice_reg_form">
<label id="reg_form_tile_label">Add new route here </label></p/>
<i>Please fill the form below to add route to this location-</i>
<form name="new_user_registration" id="new_user_registration" action="addAssServiceProStaff.php" method="POST">

<table border="0" id="reg_form_table">

   <input class="hi" type="hidden" name="owniD"  value="<?php echo $ownID;?>">


   <input class="hi" type="hidden" name="hiD"  value="<?php echo $hnm;?>">

        
    <tr>
  
  <td height="40px" width="35%" valign="top">

        <label id="mini_label">Route Id number:<sup>*</sup></label><br>

  </td> 


  <td id="reg_form_table_cell">
     
         <input type="text" name="routeId" id="routeId" class="prof_info"   /><br/>
         <sup id="si"></sup>
         
  </td>

</tr>
  
<tr>
  
  <td height="40px" width="35%" valign="top">

        <label id="mini_label">Startt from:<sup>*</sup></label><br>

  </td> 


  <td id="reg_form_table_cell">
     
         <input type="text" name="start" id="start" class="prof_info"   /><br/>
         <sup id="ln"></sup>
         
  </td>

</tr>
  <tr>
 
  <td height="40px"   valign="top">

        <label id="mini_label">Estamated route length:<sup>*</sup></label><br>

  </td> 

  <td id="reg_form_table_cell">

    
         <input type="text" name="rlength" id="rlength" class="prof_info"   /><br/>
         <sup id="rt"></sup>
  </td>

  </tr>


<tr>
 
  <td height="40px"   valign="top">

        <label id="mini_label">Via(passes through):<sup>*</sup></label><br>

  </td> 

  <td id="reg_form_table_cell">

    
         <input type="text" name="via" id="via" class="prof_info"   /><br/>
         <sup id="rv"></sup>
  </td>

  </tr>

  <tr>
 
  <td height="40px"   valign="top">

        <label id="mini_label">Route distanation:<sup>*</sup></label><br>

  </td> 

  <td id="reg_form_table_cell">

    
         <input type="text" name="end" id="end" class="prof_info"   /><br/>
         <sup id="rdn"></sup>
  </td>

  </tr>


  <tr>
 
  <td height="40px"   valign="top">

        <label id="mini_label">Location distance from destination:<sup>*</sup></label><br>

  </td> 

  <td id="reg_form_table_cell">

    
         <input type="text" name="lditance" id="ldistance" class="prof_info"   /><br/>
         <sup id="rd"></sup>
  </td>

  </tr>

   
<tr>

  <td colspan="2" align="center">
        <input type="submit"  name="submit" value="Submit" id="submit"/>
  </td>

</tr>

</table>
 
</form>
</fieldset> </center>
 
<script>
 
$(document).ready(function(){
  
$("#new_user_registration").on('submit',function(e){

var start =document.getElementById('start').value;
$.trim(start);  
var via =document.getElementById('via').value;
$.trim(via);  
 
var routeId =document.getElementById('routeId').value;
$.trim(routeId);

var rlength =document.getElementById('rlength').value;
$.trim(rlength);  
var end =document.getElementById('end').value;
$.trim(end);  
 
var ldistance=document.getElementById('ldistance').value;
$.trim(ldistance);
var vN =/[\(A-Za-z)]/g;
var nV =/[a-z\s]/i;
var nR =/[A-Za-z0-9]/i;
var nC =/[0-9]/i;
var j=0,k=0, g=0,i=0;

                                                         //ROUTE ID VALIDATION
if(routeId=="")
{
e.preventDefault();

document.getElementById('si').innerHTML="Route Id  required!..";
 } 
 else
 {

      for(i=0;i<routeId.length;i++)
       {
         if(!routeId[i].match(nR))
          {
             j++;

           }
        }
      
       if(j>0){
       e.preventDefault();

       
        document.getElementById('si').innerHTML="You typed route id with error!.."; 


              }
         else{

        document.getElementById('si').innerHTML="";

              }
   }
 
    j=0, i=0;


                                                         //ROUTE START VALIDATION
if(start=="")
{
e.preventDefault();

document.getElementById('ln').innerHTML="Route starting location  required!..";
 } 
 else
 {

      for(i=0;i<start.length;i++)
       {
         if(!start[i].match(nV))
          {
             j++;

           }
        }
      
       if(j>0){
        e.preventDefault();

       
        document.getElementById('ln').innerHTML="Starting location typed with error!.."; 


              }
         else{

        document.getElementById('ln').innerHTML="";

              }
   }
 
    j=0, i=0;
                                                                               ///ROUTE LENGTH VALIDATION
 

if(rlength==""){
 e.preventDefault();

document.getElementById('rt').innerHTML="Route length required!..";
 }
 else{

     for(i=0;i<rlength.length;i++)
       {
         if(!rlength[i].match(nR))
          {
             j++;

           }
        }
      
       if(j>0){
       e.preventDefault();
 
        document.getElementById('rt').innerHTML="Route length typed with error!.."; 
              }
         else{
       

        document.getElementById('rt').innerHTML="";

              }
   }
 
    j=0, i=0;
      
 
                                                                            ///VIA VALIDATION


if(via=="")
{
e.preventDefault();

document.getElementById('rv').innerHTML="Route direction  required!..";
 } 
 else
 {

      for(i=0;i<via.length;i++)
       {
         if(!via[i].match(nR))
          {
             j++;

           }
        }
      
       if(j>0){
       e.preventDefault();

       
        document.getElementById('rv').innerHTML=" typed with error!.."; 


              }
         else{

        document.getElementById('rv').innerHTML="";

              }
   }
 
    j=0, i=0;


                                                         //ROUTE DESTINATION VALIDATION
if(end=="")
{
e.preventDefault();

document.getElementById('rdn').innerHTML="Route destination  required!..";
 } 
 else
 {

      for(i=0;i<end.length;i++)
       {
         if(!end[i].match(nV))
          {
             j++;

           }
        }
      
       if(j>0){
        e.preventDefault();

       
        document.getElementById('rdn').innerHTML="Route destination typed with error!.."; 


              }
         else{

        document.getElementById('rdn').innerHTML="";

              }
   }
 
    j=0, i=0;
                                                                               ///DESTINATION DISTANCE FROM LOCATION VALIDATION
 

if(ldistance==""){
 e.preventDefault();

document.getElementById('rd').innerHTML="Distance from destination to location required!..";
 }
 else{

     for(i=0;i<ldistance.length;i++)
       {
         if(!ldistance[i].match(nR))
          {
             j++;

           }
        }
      
       if(j>0){
       e.preventDefault();
 
        document.getElementById('rd').innerHTML="Distance  typed with error!.."; 
              }
         else{
       

        document.getElementById('rd').innerHTML="";

              }
   }
 
    j=0, i=0;
      
 
                                                                            ///ROOM ID VALIDATION
  
  
}
);
}
);  
    
 
</script>





