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

  {

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

        $hnm=$_POST['hiD'];
        $ownID=$_POST['owniD'];
        $roomid=$_POST['roomNo']; 
         $HD=$con->getMyOperationHotel($ownID,$hnm);
    
        if($HD->rowCount()>0)
        {
          $ro=$HD->fetch();

        }
        $HR=$con->getHotelRoomForEdit($hnm,$roomid);
      
        if($HR->rowCount()>0)
        {
          $rm=$HR->fetch();
          $rname=$rm["rname"];
          $rtype=$rm["rtype"];
          $rcost=$rm["rcost"];
          $roomid=$rm["room_no"];
         
        }
    }
  }
?> 
 
  
 
   <!--NEW USER REGISTRATION FORM, DISPLAYED BY DEFAULTS IN PAGE LOAD-->


<center><fieldset id="new_room_reg_form">
<label id="reg_form_tile_label"> New room here </label></p/>
<i>Please fill the form below to add room-</i>
<form name="new_user_registration" id="new_user_registration" action="editRoomProStaff.php" method="POST">

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

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


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

  
   <input type="text" name="roomid" id="roomid"   class="hi" value="<?php echo $roomid; ?>" />     
    
  
<tr>
  
  <td height="40px" valign="top">

        <label id="mini_label">Room Name:<sup>*</sup></label><br>

  </td> 


  <td id="reg_form_table_cell">
     
         <input type="text" name="rname" id="rname" class="prof_info" value="<?php echo $rname; ?>" /><br/>
         <sup id="ln"></sup>
         
  </td>

</tr>

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

        <label id="mini_label">Room type:<sup>*</sup></label><br>

  </td> 

  <td id="reg_form_table_cell">

    
         <input type="text" name="rtype" id="rtype" class="prof_info" value="<?php echo $rtype; ?>" /><br/>
         <sup id="rt"></sup>
  </td>

  </tr>

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

        <label id="mini_label">Room cost:<sup>*</sup></label><br>

  </td> 

  <td id="reg_form_table_cell">

    
         <input type="text" name="rcost" id="rcost" class="prof_info" value="<?php echo $rcost; ?>"  /><br/>
         <sup id="rc"></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 rname =document.getElementById('rname').value;
$.trim(rname);
var roomid =document.getElementById('roomid').value;
$.trim(roomid);
var rtype =document.getElementById('rtype').value;
$.trim(rtype);
var rcost =document.getElementById('rcost').value;
$.trim(rcost);
 


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;

                                                         //ROOM NAME VALIDATION
if(rname=="")
{
 e.preventDefault();

document.getElementById('ln').innerHTML="Room name is required!..";
 } 
 else
 {

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

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

       
        document.getElementById('ln').innerHTML="You typed room name with error!.."; 


              }
         else{

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

              }
   }
 
    j=0, i=0;
                                                                               ///ROOM TYPE VALIDATION
 

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

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

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

           }
        }
      
       if(j>0){
       e.preventDefault();
 
        document.getElementById('rt').innerHTML="Typed room type with error!.."; 
              }
         else{
       

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

              }
   }
 
    j=0, i=0;
               
 


                                                                            ///ROOM COST VALIDATION



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

document.getElementById('rc').innerHTML="Room cost is required!..";
 
 
              }
 else{

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

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

        document.getElementById('rc').innerHTML="Room cost typed with error!.."; 
              }
         else{

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

              }
   }
 
    j=0, i=0;
               


 
                                                                            ///ROOM ID VALIDATION
 

if(roomid==""){
// e.preventDefault();

document.getElementById('fn').innerHTML="Room id required!..";
 

 }
 else{

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

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

              }
   }
 
    j=0, i=0;

               
  
}
);
}
);  
    
 
</script>





