
<?php
require('../headers.php');
 if (isset($_POST['dealid']) && isset($_POST['owniD'])) {
 //$post=$_POST['post'];	 
 $dealid=$_POST['dealid'];  
 $ownID=$_POST['owniD'];


 ////////////////// UPDATE PRICE///////////// 
 /*if ($post=="Save price") 
 {
   $itemcost=$_POST['itemcost'];
   if ($xcon->vcost($itemcost))
      {
         $r = $xcon->updateDealPrice($dealid,$itemcost,$ownID);
            
             if ($r->rowCount()>0) 
                    {
                     echo "Update successfully!..";
                     }
                     else
                     {
                      echo "No update made!..";
                     }
      }
   else{
        echo $xcon->ecost($itemcost);
       }
 }


////////////////UPDATE STATUS////////

 if ($post=="Terminate") 
 { 
   
         $r = $xcon->updateDealStatus($dealid,$ownID);
            
             if ($r->rowCount()>0) 
                    {
                     echo "Termination successfully!..";
                     }
                     else
                     {
                      echo "No termination made!..";
                     }
      
 }
 ///////////UPDATE STATUS ENDS////////////

 ////////////////UPDATE STATUS////////

 if ($post=="Upgrade") 
 { 
   
         $r = $xcon->upgradeDealStatus($dealid,$ownID);
            
             if ($r->rowCount()>0) 
                    {
                     echo "Upgrade successfully!..";
                     }
                     else
                     {
                      echo "No upgrade made!..";
                     }
      
 }*/
 ///////////UPDATE STATUS ENDS////////////
?>
<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="hexaNdealOut.php" method="post">
               <!--<input class="hi" type="hidden" name="owniD"  value="<?php// echo $ownID;?>">-->

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

           
                  <form action="hexaNdealOut.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  id="item" type="submit" value="Need Posts" name="post">

                   </form> 
        </li>
         <li style="padding-right:3%;">

           
                  <form action="../home.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  id="item" type="submit" value="Have what?" name="post">

                   </form> 
        </li>

        <li style="padding-right:3%;">

           
                  <form action="../home.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  id="item" type="submit" value="Need what?" name="post">

                   </form> 
        </li>
      </ul>
<!--
	   <li style="padding-right:3%;">
		  <form id="order" action="myDealPostDetail.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="myDealPostDetail.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>

<!------CODE FOR EDITING PRICE
	///////////////////////////--- 
if ($post=="Edit price") {
	 
 
?>

<fieldset id="new_deal_image_form">
	Edit price here..
	<form id="orderP" action="myDealPostDetail.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;?>">

   
<sup id="cv">*</sup>
                      <input class="prof_info" type="text" name="itemcost" id="itemcost" value="">


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

                 </form>
</fieldset>-->
<script>
 /*
$(document).ready(function(){
 
$("#orderP").on('submit',function(e){

  ///e.preventDefault();
var itemcost =document.getElementById('itemcost').value;
$.trim(itemcost);  
 
var nC =/[0-9]/i;
 
var j=0,k=0, g=0,i=0;
                      //////IMAGE VALIDATION
 
                                                         //ITEM NAME VALIDATION
 
if(itemcost==""){
 e.preventDefault();

document.getElementById('cv').innerHTML="Price required!..";
 
 
              }
 else{

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

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

        document.getElementById('cv').innerHTML="Price typed with error!.."; 
              }
         else{

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

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

<?php
 
 
 $getS=$xcon->getMyDealDetail($dealid,$ownID);
 if ($getS->rowCount()>0) {
  $DD=$getS->fetch();
  $dealid =$DD['dealid'];
?>
<!------CODE FOR EDITING PRICE
	///////////////////////////--->
<table border="0" width="100%" >
 
<tr>
	<td colspan="2" height="40px" >
		

	  <label id="main_lab"><?php echo $DD['title'];?></label>

	</td>
 </tr>
 <tr>

	  

     <td width="40%"   align="justify" height="auto" >
		     <b>DEAL:  <?php echo $DD['title'];?> summmary</b>
     </td>


	<td   height="40px" width="60%">


		<b> <?php echo $DD['title'];?> images<br/>
	</td>
   </tr>
   <tr>
      
		 
	
	 <td align="justify" width="40%" >

					 <img src="<?php echo $DD['profileimage'];?>" id="picd" >
		<p/> 
             

  	 
			<ul id="lipad">

				<li id="pad"> 
                     <b>Deal id</b><hr><?php echo $DD['dealid'];?></hr> 
				</li>
			    <li id="pad"> 
                     <b>Category</b><hr>

                     <?php echo $DD['category'];?></hr>

                </li>
				<li id="pad">
                     <b> value</b><hr>

                      <?php echo $DD['currency'].":". $DD['cvalue'];?></hr> 
				</li>
				<li id="pad"> 
                      <b>Owner name</b><hr> <?php echo $DD['cperson'];?></hr> 
				</li>
				<li id="pad"> 
                      <b>Contact person:</b><hr> <?php echo $DD['cphone'];?></hr> 
				</li>



				<li id="pad"> 
                      <b>Date posted</b><hr><?php echo $DD['posteddate'];?></hr>
				</li>

				<li id="pad"> 
                      <b>Expire on</b><hr> <?php echo $DD['addeadline'];?> </hr>
				</li>
				<li id="pad"> 
                      <b>Status</b><hr><!-- <?php
                     
                      
                       //if ($DD['status']=="Expired")
                        {
                          /////////////////UPGRADE STATUS//////////////
                          /////////////////////////////////////////////
                        ?>
                    <form id="order" action="DealPostDetail.php" method="post">

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


                     <?php //echo $DD['status'];?>:<input class="hi" type="hidden" name="dealid"  value="<?php// echo $dealid;?>">

   


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

                 </form>-->
                 <?php
                        //}
                        //else
                        //{ 
                          echo $DD['status'];

                       // }

                     /////////////////UPGRADE END/////////////
                        /////////////////////////////////
                      ?> </hr>
				</li>



				 
			</ul>
			<p><ul>
				<li id="pad">
					 <b>Deal description</b><hr>

                       <?php echo $DD['description'];?> </hr>
     
				</li>
				<li>
					<b> Deal location address</b><hr>

                        <?php echo $DD['locationaddress'];?></hr> 
     
				</li>
			   </ul>
			
		</td>

		<td valign="top" width="50%" align="justify">
		<?php 
	    $itD=$xcon->getMyDealImage($dealid);
        if ($itD->rowCount()>0)
         {
   	        $itmD=$itD->fetchAll();
			?>
			<ul style="padding-top:0%">
			<?php
        foreach ($itmD as $key =>$D)
         {
	  

	     ?>
				<li style="padding-top:0%; text-align:top; padding-left:0%;">
				<b><?php echo $D['title']; ?><br/>
				<img src="<?php echo $D['directory'];?>" id="itemimage"><p/>
                <i><small>Posted:<?php echo $D['posteddate']; ?></small></i>

                
				</li>
		<?php
		 }
   	    
          }
        else
          {
             ?>
				<li> 
				No more images!..
				</li>
		<?php
		 
          } 
		?>
		</ul>
		</td>

	</tr>
 
</table>
</center>
<?php
}
}
 else{
	 echo "No deal post available!..";
   }
}
 else
{
 	 echo "Some thing went wrong while processi the page!..";
}

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