 <?php 
   require_once("../head2Alts.php");
   if(isset($_POST['post']) || isset($_POST['submit']))
 {

if(isset($_POST['owniD']) && isset($_POST['dealid']))
  { 
 $owniD=$_POST['owniD'];

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

   $dealid= $_POST['dealid'];
   $itemname=""; 
   $post=$_POST['post'];

   if($post=="Submit"){

   ini_set('upload_max_filesize', '2M');
   ini_set('post_max_size', '2M');
   ini_set('max_input_time', 300);
   ini_set('max_execution_time', 300);
  
    $fn = $_FILES["imagefile"]["name"]; 
    $type=$_FILES["imagefile"]["type"];
    $size=$_FILES["imagefile"]["size"];
    $error=$_FILES["imagefile"]["error"];
    $tmp_name=$_FILES["imagefile"]["tmp_name"];
    $ext = pathinfo($fn, PATHINFO_EXTENSION);
    $allowedtype=array('png','jpg','jpeg','gif','jpeg','JPG','JPEG','GIF','PNG');

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

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


   $itemname=$_POST['itemname']; 

if($xcon->vImageType($ext,$allowedtype) && $xcon->vImageError($error) && $xcon->vImageSize($size) && $xcon->vImageExist($fn) && $xcon->vImageSelectF($fn) ){

   if($xcon->vitemname($itemname))
      {
        ?>
         <center>
         <div>
        
        <?php 
        
           $ro= $xcon->uploadImage($fn,$itemname,$tmp_name,$dealid);
           if ($ro->rowCount()>0) {
              
           $itemname=""; 
           echo "Post successful!..";
            }
            else
            {
              echo "Data not saved!..";
            }
         //}else{
          //echo "Submission error!..";
          // $u=$r->ErrorInfo();
          // print_r($u);//"Error occurred while saving data!..";
            //  }
        ?> 
       </div>
       </center> 

        <?php
    
      }
      else{

        //////////////
        ?>
         <center>
         <div>
         <sup>
             <?php 
              echo  $xcon->eitemname($itemname)."<p/>"; 
           
             ?>
       </sup>
       </div>
       </center> 

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

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

        <?php
        }

}
 
 

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

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


<center>
  <label id="main_lab" >
         HEXA<font size="6">N</font>DEAL </label><br/>
<fieldset id="nav_field">
    <ul><li style="padding-right:3%;">

  <form action="hexaNdeal.php" method="post">
          <input class="hi" type="hidden" name="owniD"  value="<?php echo $ownID;?>">

               <input  class="pos" type="submit" value="My Deal Posts" name="post"  >
         </form>
        </li>
        <li style="padding-right:3%;">

           
                  <form action="myDealPostDetail.php" method="post">

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


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

 

                     <input   class="pos" type="submit" value="Deal preview" name="post">

                   </form> 
        </li>
        <li style="padding-right:3%;">
        <form id="order" action="shopPaymentPage.php" method="post">

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


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

   


                      <input  class="pos" type="submit" value="Edit price" name="post">  

                 </form>
        </li>
        <li style="padding-right:3%;">
        <form id="order" action="addMoreDealImages.php" method="post">

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


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

   


                      <input class="pos" type="submit" value="Add image" name="post">  

                 </form>
         </li>
         <li style="padding-right:3%;">
         <form id="order" action="shopPaymentPage.php" method="post">

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


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

   


                      <input class="pos" type="submit" value="Terminate" name="post">  

                 </form>
         </li>
        </ul>
      </fieldset>
      
      </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--> 
      
      
      
      
      
      
      
      
      

  <fieldset id="new_deal_image_form"  style="width:25%; margin-left:72%;" border="0" >
<label id="reg_form_tile_label">Add image post here.. </label></p/>
 
<form name="new_user_registration" id="new_user_registration" action="addMoreDealImages.php" method="POST" autocomplete="on" enctype="multipart/form-data">

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

   <input class="hi" type="hidden" name="owniD"  value="<?php echo $ownID;?>">
    <input class="hi" type="hidden" name="dealid"  value="<?php echo $dealid;?>">
  <tr>
  <td id="reg_form_table_cell">
     <label id="mini_label">Deal title:<sup>*</sup></label><br>
         <input type="text" name="itemname" id="itemname" class="prof_info" value="<?php echo $itemname;?>"  /><br/>
         <sup id="si"></sup>
         
  </td>
   
</tr>
  <tr>
   <td height="120px" width="100%">
    
                 <div id="deta" ><img id="dealmoreimage">  </div>
  </td>
</tr>

  
 <tr>
   

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

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

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

</tr>

</table>
 
</form>
</fieldset>  
</fieldset>
  <?php
 }
 else
 {
  echo "UNRECOGNISED USER!";
 }
    }
    else{
    echo "ERROR OCCURED!";
  }
 
  ?>
<script>

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

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

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

// e.preventDefault();
var itemname =document.getElementById('itemname').value;
$.trim(itemname);  
 
var floc= document.getElementById('imagefile').value
 
 
var nR =/[\sA-Za-z0-9]/i;
 
var j=0,k=0, g=0,i=0;
                      //////IMAGE VALIDATION

if (floc=="") 
    {
   e.preventDefault();
    document.getElementById('mg').innerHTML="Image file is required!..";
    }
    else
    {

    document.getElementById('mg').innerHTML="";
    }

                                                         //ITEM NAME VALIDATION
if(itemname=="")
{
e.preventDefault();

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

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

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

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


              }
         else{

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

              }
   }
 
    j=0, i=0;

 
                                                                            ///ROOM ID  
}
);
}
);  
    
 
</script>

 <?php
        require_once('../footerIns.php');
        ?>



