<?php

error_reporting(0);

    include ("sidebar.php");

    include ("header.php");

    require_once('database.php');

    $order_information=$_GET['id_orderid'];

    $query="SELECT * FROM order_items WHERE order_id='$order_information'";

    $rec=db::getRecord($query);

 

//$splittedstring=explode(",", $rec['product_code']);

//foreach ($splittedstring as $key => $value) {

////echo "splittedstring[".$key."] = ".$value."<br>";

////    echo $value."<br>";

//    echo stripslashes($value);

    $code=json_decode( $rec['product_code'],true);

    $k=json_decode( $rec['product_qty'],true);

// Loop through the associative array

//foreach($k as $key=>$value){

//    echo  $value . "<br>";

//}

?>

  

      <div class="content" >

        <div class="content">

          <div class="container-fluid" style="margin-top:-40px">

            <div class="row">

              <div class="col-md-12">

                <div class="card" style="min-height:550px;">

                    

                <div class="card-header card-header-info" style="background-color:#1FC1D5"   >

                  <h4 class="card-title "  style="color:white">Order</h4>

                </div>

                    <div class="table-responsive">          

  <table class="table table-hover">

    <thead>

      <tr>

        <th>Product_Name</th>

        <th>product_Quantity</th>

        <th>Unit Price</th>

        <th>Total_Price</th>

      </tr>

    </thead>

    <tbody>

        <?php

        foreach($code as $index => $value) {

            $str_arr = explode (",", $value); 

            $size=sizeof($str_arr);

            for($i=0; $i<$size;$i++){

               $product_code=$str_arr[$i];

            

            

            $query="SELECT product_name,product_price FROM products WHERE product_code='$product_code'";

            $r=db::getRecord($query);

        ?>

      <tr>

        <td><?php   echo $r['product_name'];  ?></td>

        <td><?php   echo $k[$index];?></td>

        <td>€<?php   echo $r['product_price'];  ?></td>

        <td>€<?php

            $subtotal = ($k[$index] * $r['product_price']);

            echo sprintf("%01.2f",$subtotal);

            ?></td>

          </tr>

       <?php

            $total =$total + $subtotal;

        }

        }

        ?>

    </tbody>

  </table>

  </div>

                    <div class="row">

              <div class="col-md-8">

                  <h4 style="padding-left:10px">Note:</h4>

                  <p style="padding-left:10px">

                   <?php $query="SELECT special_note,order_type FROM order_information WHERE order_id='$order_information'";

                     $rec=db::getRecord($query);

                     echo $rec['special_note'];

                   ?>   

                  </p>

              </div>

                  <div class="col-md-4 text-center">

                      <h5><strong>Sub-Total:</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;€ <?php echo sprintf("%01.2f",$total); ?></h5>

                         <h5><strong>Discount:</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;€ <?php

                         $a=$total*0.1;

                         $f=2.50;

                         if($rec['order_type'] == 'pickup'){
                          $f=0;
                         }

                         echo sprintf("%01.2f",$a); ?></h5>

                         <h5><strong>Delivery Fee:</strong>€ <?php echo sprintf("%01.2f",$f); ?></h5>

                         <h5><strong>Grand Total:</strong>&nbsp;€ <?php

                         $b=$total-$a+$f;

                         echo sprintf("%01.2f",$b); ?></h5>

                        

                        </div>

              </div>

                      

                   

                          </div>

                          </div>

                          </div>

                        </div>

           

              

                      </div>

                    </div>

                  



<?php

    include ("footer.php");

?>

