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

  {
 ;

  $hnm=$_POST['hiD'];

  $ownID=$_POST['owniD'];
   
  $post=$_POST["post"];
  


    if ($post=="UPLOAD"){

      ///////////////////  
 
 
     $sname=$_POST['sname'];
      $tname=$_POST['tname'];

      $fn = $_FILES["imagefile"]["name"];
      $tmp_name=$_FILES["imagefile"]["tmp_name"];
 
    if($tmp_name!="" && $fn!="")
     {


      ini_set('upload_max_filesize', '2M');
      ini_set('post_max_size', '2M');
      ini_set('max_input_time', 300);
      ini_set('max_execution_time', 300); 
 
      $type=$_FILES["imagefile"]["type"];

      $size=$_FILES["imagefile"]["size"];

      $error=$_FILES["imagefile"]["error"];


      $ext = pathinfo($fn, PATHINFO_EXTENSION);

     $allowedtype=array('png','jpg','jpeg','gif','jpeg','JPG','JPEG','GIF','PNG');
 

    if($con->vImageType($ext,$allowedtype) && $con->vImageError($error)  && $con->vImageSize($size) && $con->vImageAdvExist($fn) && $con->vImageSelectF($fn))
      {
   ///   
    /////////////
    ////////////////////
    /////////////////
 
   if($con->vAname($sname) && $con->vTname($tname))
      { 

        ?>

  <center>
     
      <div>
       
       <sup>
       <?php 
    
        echo $con->addAdPostAndImg($sname,$hnm,$fn,$tmp_name,$tname); 
        ?>
       </sup>
     </div>
  </center> 


<?php 

      }
   else
      { 
            ?> 
            <center>
                <div>
                 <sup>
                  <?php 
                  echo $con->eSname($sname)."<p/>";
                  echo $con->eTname($tname)."<p/>";  
    
                ?>
                 </sup>
                 </div>
            </center> 

            <?php
 
            
      }
 
    //////////////////
    /////////////////
    /////////////
      }

      ///

      else{

        ?>

    <center>
       <div>
       <sup>
       <?php
        echo $con->eImageType($ext,$allowedtype)."<p/>";
        echo $con->eImageSize($size)."<p/>";
        echo $con->eImageError($error)."<p/>";
        echo $con-> eImageAdvExist($fn)."<p/>" ;
        echo $con->eImageSelectF($fn)
        ?>
        </sup>
        </div>
     </center>
        <?php
      }
      }
      ///

   

  else
  {
    //////////////
    ///////////////
     /////////////////
 
   if($con->vAname($sname) && $con->vTname($tname))
      {  
        ?>

  <center>
     
      <div>
       
       <sup>
       <?php 
    
        echo $con->addAdPostOnly($sname,$hnm,$tname); 
        ?>
       </sup>
     </div>
  </center> 


<?php 

      }
   else
      {  
            ?>
 
            <center>
                <div>
                 <sup>
                  <?php 
                  echo $con->eSname($sname)."<p/>";
                  echo $con->eTname($tname)."<p/>"; 
    
                ?>
                 </sup>
                 </div>
            </center> 

            <?php
  
      }

    /////////////////
    ///////////


  }

      ///////////////////////
       //////////////////////
   
    }

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

         $HD=$con->getMyOperationHotel($ownID,$hnm);
    
        if($HD->rowCount()>0)
        {
          $ro=$HD->fetch();

        }
      
    }
     
  }
?> 
 
  
 
   <!--NEW USER REGISTRATION FORM, DISPLAYED BY DEFAULTS IN PAGE LOAD-->

















 

<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"> Post advertisement  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="addAdvertisementFormStaff.php"   method="post"   autocomplete="on" enctype="multipart/form-data"> 
   <input class="hi" type="text" name="owniD"  value="<?php echo $ownID;?>">


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


          <tr>

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

                   <label id="mini_label">Post Title:-<sup>*</sup></label>

              </td>
          </tr>
          <tr> 
              <td valign="top">
              
                <input type="text" name="tname" id="tname" class="prof_info"><br/>
                  <sup id="tn"></sup>
              </td>
          </tr>
          <tr>
              <td valign="top" id="hf"> 

                   <label id="mini_label">Advertisement content:-<sup>*</sup></label>

              </td>
          </tr>
          <tr>
              <td valign="top" height="60px">
              
                   <textarea type="text" name="sname" id="sname"></textarea><br/>
                   <sup id="ln"></sup>
         
              </td>

          </tr>

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

              <label id="mini_label">Choose image (if any,optional):<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>
 





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

    reader.onload = function (e) {
        // get loaded data and render thumbnail.
        document.getElementById("image").src = e.target.result;
    };

    // read the image file as a data URL.
    reader.readAsDataURL(this.files[0]);
}
 
$(document).ready(function(){
  
$("#upload_form").on('submit',function(e){ 
var sname =document.getElementById('sname').value;
$.trim(sname); 

var tname =document.getElementById('sname').value;
$.trim(tname);   

var vN =/[\sA-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(sname=="")
{
   e.preventDefault();

   document.getElementById('ln').innerHTML="Post content required!..";
 } 
 else
 {

   

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

           
  }
 
    j=0, i=0;
                
if(tname=="")
{
   e.preventDefault();

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

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

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





