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

if(isset($_POST['owniD']) && isset($_POST['posterid']) && isset($_POST['needid']))
  { 
 $owniD=$_POST['owniD'];
 $posterid=$_POST['posterid'];
 $needid=$_POST['needid'];
//////////////////
 $hs=$xcon->getOtherThisNeedDetail($needid,$posterid);
  if ($hs->rowCount()>0) {
  
   $hD=$hs->fetch();
 
 
 


  $needid=$hD['needid'];    
   ?>
  <table width="98%" border="0">
    <tr>
    <td colspan="2" align="center">
    
     
        <label id="main_lab" >
         HEXA<font size="6">N</font>DEAL </label>
    </td>
  </tr>
  <tr>
    <td align="left" >
      <ul style="padding-left:0%;">
      <li>
          <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>
        <form action="hexaNdeal.php" method="post">

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

                    <input  class="pos" type="submit" value="My Need Posts" name="post"  >
                 </form>
      </li>
    </ul>
    
    </td>
   
    <td align="right" width="50%">
    <ul>
      <li>
        <form action="dealPostForm.php" method="post">

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

                    <input  class="pos" type="submit" value="Have what?" name="post"  >
                 </form>
      </li>
      <li>
        <form action="needPostForm.php" method="post">

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

                    <input  class="pos" type="submit" value="Need what?" name="post"  >
                 </form>
      </li>
    </ul>
    
    </td>
  </tr>
 </table>
 
 
 
 
    
      
<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%; margin-top:1%;" border="0">
  <tr>
  <td  valign="top">
     
<?php
 
}
 ////////////// 

   $needid= $_POST['needid'];
   $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');

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

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

   $senderid=$_POST['owniD'];
   $receiverid=$posterid;
   $itemdescription=$_POST['itemname']; 
   $offerid=substr(Date("Ymdhis"),2);


   if($xcon->vitemdescription($itemdescription))
      {
        ?>
         <center>
         <div>
        
        <?php 
        ///////////////
        if($xcon->vImageType($ext,$allowedtype) && $xcon->vImageError($error) && $xcon->vImageSize($size) && $xcon->vImageExist($fn) && $xcon->vImageSelectF($fn) ){

        ////////////
           $ro= $xcon->postNeedOffering($offerid,$needid,$senderid,$receiverid,$itemdescription,$fn,$tmp_name);
          // print_r($ro);
           if ($ro->rowCount()>0) {
             echo "Post successfully!..";
           $itemname=""; 
            }
            else
            {
              echo "Data not saved!..";
            }
         //}else{
          //echo "Submission error!..";
          // $u=$r->ErrorInfo();
          // print_r($u);//"Error occurred while saving data!..";
            //  }
        ?> 
       </div>
       </center> 

        <?php
        }
    else{
///// ///////////////////
       ////////////
           $ro= $xcon->postNeedOffering0($itemdescription,$offerid,$needid,$senderid,$receiverid);
           if ($ro->rowCount()>0) {
              echo "Post successfully!..";
           $itemname=""; 
            }
            else
            {
              echo "Data not saved!..";
            }
         //}else{
          //echo "Submission error!..";
          // $u=$r->ErrorInfo();
          // print_r($u);//"Error occurred while saving data!..";
            //  }
       
      //////////////////
        }
      }
      else{

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

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

      }


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






















 
<fieldset style="width:98%;   " border="0">
<label id="reg_form_tile_label">Post what you offer here.. </label></p/>
 
<form name="new_user_registration" id="new_user_registration" action="dealOfferingPostForm.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="posterid"  value="<?php echo $posterid;?>">
    <input class="hi" type="hidden" name="needid"  value="<?php echo $needid;?>">
  <tr>
  <td id="reg_form_table_cell">
     <label id="mini_label">Offer description:<sup>*</sup></label><br>
        <textarea  name="itemname" id="itemname" ><?php echo $itemname;?></textarea><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>

  <section style="padding-left:5%;">
    <b> <?php echo $hD['title'] ?> </b><br>
     <small>(Post by:<i><?php echo $hD['cperson']."(".$hD['cphone'].")";?></i></small>
    <small>Posted:<i><?php echo $hD['posteddate']."(status:".$hD['status'].")";?></i></small>
    <small>Category:<i><?php echo $hD['category'];?></i></small>)<br/>
    <b> Description </b><br/>
     <?php echo $hD['description'] ?><br>     
     <small>Location:<i><?php echo $hD['region'].",".$hD['district'].",".$hD['street']."(Deadline:".$hD['deadline'].")";?></i></small>  
 
 </section> 

</td>
</tr>
</table>
 </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);  
 

  
                      //////IMAGE VALIDATION
 
      var floc= document.getElementById('imagefile').value;
  

                                                         //ITEM NAME VALIDATION
if(itemname=="")
    {
    e.preventDefault();
    document.getElementById('si').innerHTML="Deal title  required!..";
    } 
 else
    {
        document.getElementById('si').innerHTML="";

     }
 
   

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

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


