<?php

require('../head2Alts.php');
if (isset($_POST['owniD']) && isset($_POST['orderid'])) {
	
$ownID =$_POST['owniD'];
$orderid=$_POST['orderid'];
 
      $Ord=$gcon->getMyItemOrderDetail($ownID,$orderid); 
$post=$_POST['post'];
     if($post="Send") 
     {
       
     }
                 ////

 

	//////////////////////////////////////////////RANGE DATE////////////////////
	///////////////////////////////////////////////////////////////////////////

?>
<center> <table width="95%" border="0">

	

<?php
if ($Ord->rowCount()>0){
	$Od=$Ord->fetch();
 ?>
   
 <?php 
$itemid=$Od['itemid'];
$shopid=$Od['shopid'];
$code=$Od['paymentcode'];
$sn=$gcon->getShopName($shopid)->fetch();
$in=$gcon->getItemName($itemid)->fetch();
$pc=$gcon->getAmountPaid($code)->fetch();
$iQ=$gcon->getMyOrderMessage($orderid,$ownID);
$post=$_POST['post'];
     if($post=="Send") 
     {
       $customerid=$_POST['owniD'];
       $itemid=$_POST['itemid'];
       $shopid=$_POST['shopid'];
       $orderid=$_POST['orderid'];
       $message=$_POST['message'];
       if ($gcon->vmessage($message))
       {
        ?>
        <center>
          <b>
          <?php
          print_r($gcon->OrederInquire($shopid,$itemid,$orderid,$customerid,$message));
          ?>
          </b>
        </center>
        <?php
       }
     }
 ?>
	<tr>
  <td  colspan="2" >
    


    <label id="main_title">The datail information about the order item:-</label>
     <?php
        require_once('shopNavLinkOtherIn.php');
        ?>
  
</tr>
<tr >
   

  <td colspan="2">
    <b> Item  Description</b><p/>
                  <?php
                     echo $in['description'];
                   ?>


  </td>
</tr>
<tr>
<td colspan="2">
  <ul>
		<li id="padli"> 
    <label id="inner_top">ORDER ID</label><p/>
            <i><?php
                echo $Od['orderid'];
             ?></i>
		</li>

		<li id="padli"> 
    <label id="inner_top">SHOP NAME</label><p/>
              <i><?php
                echo $sn['shopname'];
                ?></i>
		</li>

		<li id="padli">
    <label id="inner_top">ITEM ID</label><p/>
                   <i><?php
                     echo $Od['itemid'];
                   ?></i>
		</li>

		<li id="padli"> 
    <label id="inner_top">ITEM NAME</label><p/>
                   <i><?php
                     echo $in['itemname'];
                   ?></i>  
		</li>

		<li id="padli"> 
    <label id="inner_top">PAYMENT CODE</label><p/>
              <i><?php
                 echo $Od['paymentcode'];
               ?></i>
		</li>
		<li id="padli">
    <label id="inner_top">QUANTITY</label><p/>
		        <i><?php
                echo $Od['quantity'];
                ?></i>
       </li>
		<li id="padli">
    <label id="inner_top">DATE ORDERED</label><p/>
             <i><?php
                   echo $Od['dateordered'];
                  ?></i>

		</li>
		<li id="padli"> 
    <label id="inner_top">PROCESSING STATUS</label><p/>
                  <i><?php
                   echo $Od['processingstatus'];
                  ?></i>
		</li>

		<li id="padli"> 
    <label id="inner_top">PRICE/ITEM</label><p/>
                  <i><?php
                     echo $Od['tcost']/$Od['quantity'];
                   ?></i>
		</li>

		<li id="padli"> 
    <label id="inner_top">TOTAL PAID</label><p/>
                  <i><?php
                     echo $Od['tcost'];
                   ?></i>
		</li>
    </ul>
    </td>
	</tr>
  <tr>
    <td colspan="2">
<b>Leave message here(if any):</b>
    <sup id="rd">
    <?php 
     if ($post=="Send")
     {
     echo $gcon->emessage($message);  
     } 
     ?>
       
     </sup>
     <form id="ordermessage" action="myOrderDetail.php" method="post">

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

                     <input class="hi" type="text" name="orderid"  value="<?php echo $Od['orderid'];?>">


                     <input class="hi" type="text" name="itemid"  value="<?php echo $in['itemid'];?>">

                     <input class="hi" type="text" name="shopid"  value="<?php echo $sn['shopid'];?>">

 
                     <input type="text" class="message"  name="message" id="message"> 

                     <input  type="submit" value="Send" name="post">

                 </form> 
                 <p/>
                 
                 <?php
             if($iQ->rowCount()>0){
              $Q=$iQ->fetchAll();
             foreach ($Q as $key => $q){
 

                 ?>
                   
                   <small>
                          <i>
                              Posted on: <?php echo $q['inquiredate'];  ?><br>
                          </i>
                    </small>
                     <?php echo $q['message'];?><br>
                     
                     <i>Reply status:</i><?php echo $q['replystatus'];  ?><p/>
                      <?php
                     if ($q['replystatus']!="In process")
                         {
                          $inquireid=$q['inquiredate'];
                          $r= $gcon->getMyOrderMessageReply($orderid,$ownID,$inquireid);
                          if($r->rowCount()>0){
                          $R=$r->fetchAll();
                          foreach ($R as $key => $rm){
                            ?>
                            <blockquote>
                              <?php
                                 echo "<i> Posted on:".$rm['replydate']."</i><br/>".$rm['reply'];   
                              ?>
                            </blockquote>
                            <?php
                          }
                        }
                         }
                      
                   }
                 }
                   ?>
                  
    </td>
  </tr>

<?php 
}
else
{
	?>
	<tr>
		<td>
			You don't have any order now!..
		</td>
	</tr>
	<?php
}
?>
</table></center>
<?php
}
else{
	echo "NETWORK PROBLEM WHILE TRYING TO LOAD!..";
}
?>
<script>

  
 
$(document).ready(function(){
 
$("#ordermessage").on('submit',function(e){

// e.preventDefault();
 

var message =document.getElementById('message').value;
$.trim(message);
  
                      //////IMAGE VALIDATION
  
 

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

document.getElementById('rd').innerHTML="Message required!..";
 }
  
    else{
       

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

               
   }
 
    j=0, i=0;
      
 
                                                                            ///ROOM ID VALIDATION
  
  
}
);
}
);  
    
 
</script>
<?php
 require_once('../footerIns.php');
?>