<?php
/*require_once("head2Alt.php");

if(isset($_POST["post"])){
   if (isset($_POST["hiD"])) {
       $ownID=$_POST["hiD"];	 
       require_once("buda_connect.php");

       $con=new connect_class();

       $HD=$con->getHotelAddImage($ownID);
       if($HD->rowCount()<=0)
          {

          echo "Page time out".$ownID;
          }
       else
          {
  	      $rN=$HD->fetch();*/


          ?>
 <center>
<section><sup>
<?php
   echo $con->eImageType($ext,$allowedtype)."<p/>";
   echo $con->eImageSize($size)."<p/>";
   echo $con->eImageError($error)."<p/>";
   echo $con-> eImageExist($fn)."<p/>" ;
   echo $con-> eTitle($tit)."<p/>" ;
   echo $con->eImageSelectF($fn)."<p/>" ;
   echo $con->eRoomID($roomid);
?>
</sup>
</section>
 </center>







<fieldset style="border-color:silver; border:0;padding-bottom:95%; width:100%; ">

<center>Before you upload an image please verify you image here:-</center>

    <div style="width:70%; margin-left:1%;" id="app">
     <div style="height:80px;" class="card bg-light mb-4" @change="change" @dragover="dragover" @drop="drop">  
          <div class="p-5 text-center">Drop image here or <input type="file" id="file" accept="image/jpeg,image/jpg,image/jpe,image/png,image/gif,image/webp,image/bmp,image/tiff" ref="input" onclick="var q=0; document.getElementById('inputQuality').value=q;"></div>
       
      <div class="row">
        <div class="col-lg-4 mb-4">
          <div class="card">
            <div class="card-body">
              <h3 class="card-title">Options</h3>
              <hr>
              <fieldset class="form-group">
                <div class="form-check form-check-inline">
                  <input type="checkbox" name="checkOrientation" class="form-check-input" id="inputCheckOrientation" v-model="options.checkOrientation">
                  <label class="form-check-label" for="inputCheckOrientation">checkOrientation</label>
                </div>
              </fieldset>
            
              <div class="form-group row">
                <label for="inputQuality" class="col-sm-5 col-form-label">quality</label>
                <div class="col-sm-7">
                  <input type ="text" class="form-control" name="quality" id="inputQuality"v-model.number="options.quality">
                  
                  </select>
                </div>
              </div>
              <div class="form-group row">
                <label for="inputMimeType" class="col-sm-5 col-form-label">mimeType</label>
                <div class="col-sm-7">
                  <input type="text" name="mimeType" class="form-control" id="inputMimeType" placeholder="auto" v-model.number="options.mimeType">
                </div>
              </div>
              <div class="form-group row mb-0">
                <label for="inputConvertSize" class="col-sm-5 col-form-label">convertSize</label>
                <div class="col-sm-7">
                  <input type="number" name="convertSize" class="form-control" id="inputConvertSize" placeholder="5000000" v-model.number="options.convertSize">
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="col-lg-8 mb-4">
          <div class="card mb-4">
            <div class="card-body">
              The image you selected is not compatible, download the equivalent compatible copy.  
              <hr>
              <div class="row">
                <div class="col-md-4 d-flex">
                  <div class="w-100 text-center" v-if="inputURL">
                    <img class="mw-100" :src="inputURL" :alt="input.name">
                  </div>
                  <div v-else class="w-100 bg-light"></div>
                </div>
                <div class="col-md-8">
                  <dl class="row"> 
                    <dt class="col-sm-5">name:</dt>
                    <dd class="col-sm-7">{{ input.name || 'N/A' }}</dd>
                    <dt class="col-sm-5">type:</dt>
                    <dd class="col-sm-7">{{ input.type || 'N/A' }}</dd>
                    <dt class="col-sm-5">size:</dt>
                    <dd class="col-sm-7">{{ input.size | prettySize }}</dd>
                  </dl>
                </div>
              </div>
            </div>
          </div>
          <div class="card">
            <div class="card-body">
               Plealse  download the compatible version below:- 
              <hr>
              <div class="row">
                <div class="col-md-4 d-flex justify-content-center">
                  <div class="w-100 text-center" v-if="outputURL">
                    <img class="mw-100" :src="outputURL" :alt="output.name">
                    <div class="mt-2">
                      <a class="btn btn-sm btn-blocks btn-outline-primary mt-2" :download="output.name" :href="outputURL" title="Download the compressed image" sysle="color:blue;" >Download</a>
                    </div>
                  </div>
                  <div v-else class="w-100 bg-light"></div>
                </div>
                <div class="col-md-8">
                  <dl class="row"> 
                    <dt class="col-sm-5">name:</dt>
                    <dd class="col-sm-7">{{ output.name || 'N/A' }}</dd>
                    <dt class="col-sm-5">type:</dt>
                    <dd class="col-sm-7">{{ output.type || 'N/A' }}</dd>
                    <dt class="col-sm-5">size:</dt>
                    <dd class="col-sm-7">{{ output.size | prettySize }}
                      <span v-if="output.size">({{ ((1 - (output.size / input.size)) * 100).toFixed(2) }}% off)</span>
                    </dd>
                  </dl>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    </div>
<!--TAIL-->


  <table style="width:25%; margin-left:72%;" border="0" class="himgf" >
        
          <tr>
               <td colspan="2">

               <label id="reg_form_tile_label"> Upload room images here:- </label>

               </td></tr>
               <tr></tr>

               <td height="120px">
               	 <div id="deta" ><img style="width:100%;" id="image">  </div> 
               </td>
          </tr>
          
        <form  name="upload_form" id="upload_form" action="roomImageUploadProStaff.php"   method="post"   autocomplete="on" enctype="multipart/form-data">

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

          <tr>

              <td valign="top" id="hf"> 

                   <label id="mini_label">Image name(Title):<sup>*</sup></label>

              </td>
</tr>
<tr> 
              <td valign="top">
              
              <input type="text" name="title" id="title"  class="prof_info"/>
              <sup id="nf"></sup>
              </td>
          </tr>
  <tr>
              <td valign="top" id="hf"> 

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

              </td>
      </tr>
  <tr>
              <td valign="top" height="60px">
              
                     <select name="roomid" id="roomid">
                     <option  value="">Select</option>
                     <?php
                     $rM=$con->getHotelRoom($hnm);
                     if($rM->rowCount()){
                      $rr=$rM->fetchAll();
                      foreach ($rr as $key => $rid) {

                        echo '<option value="'.$rid['room_no'].'">'.$rid['rname'].'</option>';
                      }

                     }
                     ?>
                     </select>

                      <sup id="r"></sup>
              </td>

          </tr>

          <tr>
              <td valign="top" id="hf"> 

              <label id="mini_label">Choose image:<sup>*</sup></label>

              </td>
       </tr>
       <tr> 
              <td valign="top">

              <input type="file" class="prof_info" name="imagefile" id="imagefile"  onchange="readURL(this);"/>
              <sup id="mg"></sup>;
              </td>
        </tr>

           <tr> 

               <td >

                 <center>

                 <input type = "submit" value="UPLOAD" name="post"  id="submit"  />

                 </center>
               </td>
            </tr>

           </form> 


 
  </table> 
 
</fieldset>
 














 
 <?php
/* }
 }
 else{
 	echo "Page load time out";
 }
 
}
else{
	echo "Oops page not found!";
}
*/
?>

<script>

   document.getElementById("imagefile").onchange = function () {
    var reader = new FileReader();

    reader.onload = function (e) { 
        document.getElementById("image").src = e.target.result;
    };
     reader.readAsDataURL(this.files[0]);
}
 
$(document).ready(function() {
	
	
  $(" #upload_form").on('submit',(function(e){
	var floc= document.getElementById('imagefile').value
	var tit = document.getElementById('title').value;
	var hid = document.getElementById('hotelid').value; 
  var roomid = document.getElementById('roomid').value;
	var nV =/[a-z\s]/i;
  var j=0,k=0, g=0,i=0;
  var vN =/[\(A-Za-z0-9)]/g;
 if (floc=="") 
    {
	 e.preventDefault();
    document.getElementById('mg').innerHTML="Image file is required!..";
    }
    else
    {

    document.getElementById('mg').innerHTML="";
    }
                                                         //TITLE VALIDATION
 if(tit=="")
{
 e.preventDefault();

document.getElementById('nf').innerHTML="Title is required!..";
 } 
 else
 {

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

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

       
        document.getElementById('nf').innerHTML="Typed title with error!.."; 


              }
         else{

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

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


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

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

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

           }
        }
      
       if(j>0){
       e.preventDefault();
 
        document.getElementById('r').innerHTML="Invalid room id!.."; 
              }
         else{
       

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

              }
   }
 
    j=0, i=0;
 
 
	})); 
	 
}); 
</script>
</html>