<?php include('../../config/setup.php')?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title><?php 
            
            $leename=mysqli_query($config,"select Name,Name_status from lee_master");
            while($lee=mysqli_fetch_array($leename))
            {
                 $namestatus=$lee[1];
if($namestatus == 1)
{
    echo  $lee[0];
}else{
    echo "Need Name";

}

            }
            
            ?></title>
    <link rel="stylesheet" href="style.css" media="all" />
</head>

<body>
    <header class="clearfix">
        <div id="logo">
            <img src="<?php 
            
            $inro_logo=mysqli_query($config,"select Logo_Path,logo_status from lee_master");
            while($logo=mysqli_fetch_array($inro_logo))
            {
                 $logstatus=$logo[1];
if($logstatus == 1)
{
   // $ms=substr($logo[0],6);
				  echo  $logo[0];
				 
}else{
    echo "../photos/logo/no_logo.png";

}

            }
            
            ?>">
        </div>
        <div class="invoice_head" style="border-bottom-style: solid;margin-top: -20px;border-width: thin;
   
">

            <center>
                <h1 style="font-size: 46px;margin-right: 100px;    margin-bottom: -1%;"><?php 
            
            $leename=mysqli_query($config,"select Name,Name_status from lee_master");
            while($lee=mysqli_fetch_array($leename))
            {
                 $namestatus=$lee[1];
if($namestatus == 1)
{
    echo  $lee[0];
}else{
    echo "Need Name";

}

            }
            
            ?></h1>
            </center>




            <?php 
            
            $Addressmaster=mysqli_query($config,"select * from lee_master");
            while($am=mysqli_fetch_object($Addressmaster))
            {?>
            <div style="    text-align: center;
    font-size: 14px;
    color: black;
    font-weight: 700;
    margin-top: -11px;
    margin-bottom: 6px;
">
                <p style="margin-right: -2%;
    margin-bottom: -4%;
"> Address :
                    <?php echo $am->Address;?>,<?php echo $am->Location;?></p>
                <p style="margin-right: -5%;">Tel: <?php echo $am->Tel_No;?>,Ph <?php echo $am->Contact_Number;?> </p>

            </div>

            <?php } ?>






        </div>

        <div id="project">
          











            <?php 
            
        //     $toaddress=mysqli_query($config,"select * from order_checkout where order_customer_track_id='".$_GET['orderid']."'");
        //   $toam=mysqli_fetch_object($toaddress);
           
				
 $tocustomer=mysqli_query($config,"select * from customer_master where Customer_Id='".$_GET['customerid']."'");				
	$toc=mysqli_fetch_object($tocustomer);			
 					
				
				?>

            <div style="    border-right: 1px solid;">
            <h3 style="    padding-left: 10px;">Bill No : INVWT_ <?php
		
        $innum=mysqli_query($config,"select Order_id from order_master where order_customer_track_id='".$_GET['orderid']."' order by Order_id  DESC LIMIT 1");
         $inn=mysqli_fetch_object($innum);
         
      echo $inn->Order_id;
          
      
      ?></h3>
            <div style="    display: flex;">
                <h3 style="width: 20%;padding-left: 10px;color:black;margin-bottom: -1%;" > NAME : <span style="font-size: small;"></h3>
                        <p style="color: black;
    font-size: 16px;margin-bottom: -1%;"><?php echo $toc->Customer_Name; ?></p>
            </div>
              <div style="    display: flex;">  <h3 style="    width: 20%;    padding-left: 10px;">Address : <span style="font-size: small;"></h3>
                       <p style="color: black;
    font-size: 15px;"> <?php echo $toc->Customer_Address; ?>
                        <br> 
                        <?php echo $toc->Customer_Landmark; ?> ,<?php echo $toc->Customer_location;?>
                        <br><?php echo $toc->Customer_Area;?> <?php echo $toc->Customer_Pincode;?></span></p>

            </div>




            </div>



        </div>


        <div id="company" class="clearfix">
            <div>
                <h3 style="    padding-left: 10px;"> DATE :<span style="font-size: small;"> <?php   
		  
echo $newDate = date("d-m-Y");
		
		?></span> </h3>

                <?php 
            
            $Addressmaster=mysqli_query($config,"select * from lee_master");
         $am=mysqli_fetch_object($Addressmaster);
            ?>


                <h3 style=" padding-left: 10px;">TIME : <span style="font-size: small;"> <?php  date_default_timezone_set('Asia/Kolkata');
                                                             echo $paidon= date('H:i: a'); ?>
                    </span> <br>
                    <h3 style=" padding-left: 10px;">MOBILE NO :<span style="font-size: small;">
                            <?php echo $toc->Customer_Phone_No; ?></span>
                    </h3>



                    <?php  ?>







            </div>
        </div>

        <?php  ?>

    </header>





  <main>
      <table>
        <thead>
          <tr>
            <th class="service">S.No</th>
            <th class="desc">PRODUCT</th>
              <th>TYPE</th>
			 <th>RATE</th>
			   
              <th>QTY</th>
             
			<th>PRICE</th>
          
           
          

            <th>TOTAL</th>
          </tr>
        </thead>
        <tbody>
          
		  
		  <?php 
		  $p=1;
		     $orderproduct=mysqli_query($config,"select * from order_master where order_customer_track_id='".$_GET['orderid']."'");
            while($op=mysqli_fetch_object($orderproduct))
            {
		 
          $sub_cate_1=mysqli_query($config,"select * from product_price_master where Product_price_id='$op->Product_priceid'");
          $subcate__1=mysqli_fetch_object($sub_cate_1);


                $sub_cate_=mysqli_query($config,"select * from main_category where Main_Category_id='$subcate__1->Product_type'");
                $subcate__=mysqli_fetch_object($sub_cate_);
       
                $su_=mysqli_query($config,"select * from game_support_flatform where shop_id='$subcate__1->Product_length'");
                $su__=mysqli_fetch_object($su_);
                $gsu_=mysqli_query($config,"select * from game_rate where Game_rate_id='$subcate__1->p_weight'");
                $gsu__=mysqli_fetch_object($gsu_);
		  
		  ?>
		
		
		  
		  <tr>
            <td class="service"><?php echo $p;?></td>
            <td class="desc"><?php echo $op->Productname;?></td>
            	 <td style="text-align: center;"> <?php   echo  $gsu__->Game_Rateing ?></td>
			  <td style="text-align: center;">Rs.<?php
                      $pr_text=(($op->Order_product_price * $op->Product_tax) / ( 100 + $op->Product_tax ));
                 $product_price=number_format(($op->Order_product_price-$pr_text),2);
               echo number_format( (($op->Order_product_price * 100)/ (100+$op->Product_tax)),0);  
               
               ?></td>

			            <td style="text-align: center;"><?php echo $op->Ordered_quantity;?> </td>
			          

            <td style="text-align: center;">Rs.
			
			
			
			<?php
			 $product_price;
           $op->Ordered_quantity;
          echo  $tpro[]= ($op->Order_product_price * 	$op->Ordered_quantity);		
			
			$tqty[]=$op->Ordered_quantity;
			
			?>
			
			
			
			
			</td>
            <!-- <td style="text-align: center;"><?php 	echo $op->Product_tax;?>% (
        <?php echo number_format( (($op->Order_product_price - (($op->Order_product_price * 100)/ (100+$op->Product_tax))) * $op->Ordered_quantity),0);
        $ttax[]=(($op->Order_product_price - (($op->Order_product_price * 100)/ (100+$op->Product_tax))) * $op->Ordered_quantity);?>)
        </td> -->
            
		
			
			

		
			
			<td style="text-align: center;">Rs.<?php  

             $g_total[]=$op->Order_Price;
             echo number_format(($op->Order_Price) ,0);
			
			
			?></td>
          </tr>
           
         
		 
		 <?php $p++;} ?>
		 
		  <?php 
		 
		     $ordertotal=mysqli_query($config,"select * from order_master where order_customer_track_id='".$_GET['orderid']."'");
            $oot=mysqli_fetch_object($ordertotal);
            
		  
		  
		  
		  ?>
		

		 <tr>
            <td colspan="4">TOTAL</td>
            <td  style="text-align: center;"><?php echo  array_sum($tqty)  ?></td>
			
            <td  style="text-align: center;">Rs.<?php 
		
			
			echo  array_sum($tpro) ;

			


			?></td>
            <!-- <td  style="text-align: center;">Rs.<?php  $totax= array_sum($ttax);
             echo number_format($totax,2) ?></td> -->
         
          
          
                <td  style="text-align: center;">Rs.<?php $gr_total= array_sum($g_total);
             echo number_format($gr_total) ?></td>
          </tr>
		 
		 
         
          
          
          
          <tr>
		  
		  
          <td ></td>
            <td colspan="5" class="grand total">GRAND TOTAL</td>
			
		
        
        
			<?php 
            $pro_sqla="SELECT SUM(Grand_total) as total_amount FROM `order_master` INNER JOIN product_master on order_master.Order_product=product_master.Product_id WHERE order_customer_track_id='".$_GET['orderid']."'";
            $total=mysqli_query($config,$pro_sqla); 
            $total=mysqli_fetch_object($total);
        
            // if($oot->Promocode_status == 'Applied'  || $oot->Promocode_status == 'ProApplied')
			// { 	?>

<!-- <td>
    
    <?php
  
			
		
			
			 $ptotal=  $oot->Grand_total- $oot->Delivery_charge - $oot->Discount_Offer_prce;
			
			if( $ptotal <= 0)
			{ ?>
			
		<del style="margin-right: 15px;">Rs.	<?php	
													 $pro_sqla="SELECT SUM(Order_price) as total_amount FROM `order_master` INNER JOIN product_master on order_master.Order_product=product_master.Product_id WHERE  order_customer_track_id='".$_GET['orderid']."'";
													$total=mysqli_query($config,$pro_sqla); 
													$total=mysqli_fetch_object($total);
												
												 $total->total_amount;
                                              
                                                ?>
	
			
		
		
		<?php	}else{
			    
                $pro_sqla="SELECT SUM(Grand_total) as total_amount FROM `order_master` INNER JOIN product_master on order_master.Order_product=product_master.Product_id WHERE order_customer_track_id='".$_GET['orderid']."'";
                $total=mysqli_query($config,$pro_sqla); 
                $total=mysqli_fetch_object($total);
            
             $total->total_amount;
          
			    
			}
			 
    ?>
    
        </del>
    
    
    
    
    
    
    
</td> -->










	<?php //}else{?>


		 <td style="text-align: center;">Rs.<?php   
            echo  $grand_to[]=(($gr_total) ); ?></td>
		
			<?php //} ?>
		
		
		</tr>
		  
		  
		  <tr>
         <?php 
           $pro_sqla="SELECT * FROM `order_master`  WHERE order_customer_track_id='".$_GET['orderid']."'";
           $total=mysqli_query($config,$pro_sqla); 
           $total=mysqli_fetch_object($total); ?>
		  <td ></td>
            <td colspan="5" class="grand total">Delivery Charges</td>
            <td ><center>(+) Rs.<?php echo $total->Delivery_charge; ?></center></td>
          </tr>
		  
			<?php if($total->Discount_Offer_prce != 0){?>
                <tr>
       
		  <td ></td>
            <td colspan="5" class="grand total">Discount Amount</td>
            <td ><center>(-) Rs.<?php echo $total->Discount_Offer_prce; ?></center></td>
          </tr>
                <?php }?>

                <tr>
       
       <td ></td>
         <td colspan="5" class="grand total">Total Amount</td>
         <td ><center> Rs.<?php
         $pro_sqla="SELECT SUM(Order_Price) as total_amount,Discount_Offer_prce,Delivery_charge FROM `order_master` WHERE order_customer_track_id='".$_GET['orderid']."'";
         $total=mysqli_query($config,$pro_sqla); 
         $total=mysqli_fetch_object($total);
         
         echo $ttamount= (($total->total_amount + $total->Delivery_charge) - $total->Discount_Offer_prce) ?></center></td>
       </tr>
        </tbody>
      </table></hr>
     ;

 <?php 
		 
		     $ordertotal=mysqli_query($config,"select * from order_master where order_customer_track_id='".$_GET['orderid']."'");
           $oot=mysqli_fetch_object($ordertotal);
        
		  
		  
		  
		  ?>

      <div id="project1" style="    margin-top: -21px;">
	    <h3 style="    padding-left: 10px;">Paid by :<span> <?php echo $oot->Payment_Mode; ?></span> </h3>
  	 <h3 style=" padding-left: 10px;">Paid Status :  <?php 

		  $paist= $oot->Paid_status; 
		   if(is_NULL($paist))
		   {
			   echo "Not Paid";
		   }else{
			   
			    $a=$paist;
				if($a==1)
				{
					echo "Paid";
				}else{
					
					echo  $a;
				}
				
				
				
		   
            }
		   
		   ?>
         </h3>
         <h3 style=" padding-left: 10px;">Amount  :  <?php
$class_obj = new numbertowordconvertsconver();
$convert_number =array_sum($grand_to);
echo $class_obj->convert_number($ttamount)." Rupees";
?> </h3>
     <h3 style=" padding-left: 10px;">Toal Amount  :Rs. <span><?php echo $ttamount; ?> </span> </h3>
    
</div>

	
   <div id="" style="    margin-top: -21px;" class="clearfix">
         <div>

         

	


	</div>
      </div>  <div id="project2"  class="clearfix" style="    width: 793px;">
         <div>
		
        <!-- <h3 style=" padding-left: 10px;">Amount  :  <?php
$class_obj = new numbertowordconvertsconver();
$convert_number =array_sum($grand_to);
echo $class_obj->convert_number($convert_number)." Rupees";
?> </h3> -->
         

	</div>
      </div>

			<?php  ?>



	 


</br></br></br></br></br></br>



	 <div id="notices" style=" padding-left: 10px;">
        
		
		
		<div style=" margin-top: 33px;"><b>NOTICE:</b></div>
        <div class="notice">This is a computer generated receipt so no need a signature</div>
        <div class="notice">Terms and Condition as Displayed in Store at the time of Purchase</div>
		
	<h3 style="text-align: right;
    margin-right: 104px;
">Thank You for Purchase</h3>
		<center>	<button onclick="window.print()">Print this Invoice</button>  </center>
      </div>
	  
	  
	  
	  
	  
    </main>
   <!-- <footer>
      Invoice was created on a computer and is valid without the signature and seal.
    </footer>-->
	
	<?php
class numbertowordconvertsconver {
    function convert_number($number) 
    {
        if (($number < 0) || ($number > 999999999)) 
        {
            throw new Exception("Number is out of range");
        }
        $giga = floor($number / 1000000);
        // Millions (giga)
        $number -= $giga * 1000000;
        $kilo = floor($number / 1000);
        // Thousands (kilo)
        $number -= $kilo * 1000;
        $hecto = floor($number / 100);
        // Hundreds (hecto)
        $number -= $hecto * 100;
        $deca = floor($number / 10);
        // Tens (deca)
        $n = $number % 10;
        // Ones
        $result = "";
        if ($giga) 
        {
            $result .= $this->convert_number($giga) .  "Million";
        }
        if ($kilo) 
        {
            $result .= (empty($result) ? "" : " ") .$this->convert_number($kilo) . " Thousand";
        }
        if ($hecto) 
        {
            $result .= (empty($result) ? "" : " ") .$this->convert_number($hecto) . " Hundred";
        }
        $ones = array("", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eightteen", "Nineteen");
        $tens = array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eigthy", "Ninety");
        if ($deca || $n) {
            if (!empty($result)) 
            {
                $result .= " and ";
            }
            if ($deca < 2) 
            {
                $result .= $ones[$deca * 10 + $n];
            } else {
                $result .= $tens[$deca];
                if ($n) 
                {
                    $result .= "-" . $ones[$n];
                }
            }
        }
        if (empty($result)) 
        {
            $result = "zero";
        }
        return $result;
    }
}
?>
	
	
	
	
  </body>
</html>

><style>
    #project2 {
    float: left;
    width: 421px;
    border-style: solid;
    border-top: thin;
    border-left: thin;
    border-width: 0px;
    border-right: thin;
}
</style>
<style>
#project2 {
    float: left;
    width: 421px;
    border-style: solid;
    border-top: thin;
    border-left: thin;
    border-width: 0px;
    border-right: thin;
}

#company {
    float: right;
    text-align: left;
    /* border-style: solid; */
    border-top: thin;
    width: 237px;
    border-right: thin;
    border-width: thin;
    margin-top: -141px;
    border-bottom: thin;
}
</style>