Uname : Linux V-ShopU01 4.18.0-348.20.1.el8_5.x86_64 #1 SMP Thu Mar 10 20:59:28 UTC 2022 x86_64
Server : Apache/2.4.37 (rocky) OpenSSL/1.1.1k
Whoami : apache
Safe Mode : OFF
DOCUMENT ROOT : /var/www/html/site_shopudiet
Disable Function :
Path : /var/www/html/site_shopudiet/admin/

Server IP : 65.20.74.164 Client IP : 18.224.57.16
Current File : /var/www/html/site_shopudiet/admin/invoice_test.php
<?php
require('fpdf/fpdf.php');

session_start();
include 'dbconnect.php';
$did = $_REQUEST['id'];
$home_id= base64_decode($did);
$order_id = 'FC00'.$home_id;

$sq = "select * from confirm_order WHERE id='$home_id'";
$res = mysqli_query($conn, $sq);
$r = mysqli_fetch_array($res);
$total = $r['total'];
$username = $r['username'];
$address = $r['address'];
$phone = $r['phone'];
$postcode = $r['postcode'];
$squery = "select purchased_products.*,product.product_name, product.id as prduct_id from purchased_products INNER JOIN product ON product.id=purchased_products.product_id WHERE confirm_id='$home_id'";
$result = mysqli_query($conn, $squery);
$num=mysqli_num_rows($result);
$date = date('y-m-d');
$image1 = "../images/logo.png";
while( $row = mysqli_fetch_array($result))
{
   
    $no = $row['no_of_item'];
    $gst = $row['gst'];
    $sing = $gst*$no;
    $gst_total = $gst_total+$sing;
    $grand=$grand+$row['total'];
    $product[]=$row['product_name'];
    $product_id[]=$row['prduct_id'];
    $product_no[]=$row['no_of_item'];
    
}
  $purch = mysqli_query($conn,"SELECT SUM(total) as grand FROM `purchased_products` WHERE confirm_id='$home_id'");
  while($purch_prds = mysqli_fetch_array($purch)) {
      $grand = $purch_prds['grand'];
  }
  $gran1=$grand;
  $pdf = new FPDF();
          $pdf->AddPage();
          $pdf->SetFont('Times', 'B',10 ); 
          $pdf->Cell( 40, 40, $pdf->Image($image1), 0,0,0 );

          $pdf->SetFont('Times', 'B',10 );
          $pdf->Cell(135,5 , 'Agroroot Collection LLP', 0, 0, 'R');
          $pdf->Ln();
          $pdf->SetFont('Times', '',9 );
          $pdf->Cell(175,5, 'Mukattu, ochanthuruth', 0, 0, 'R');
          $pdf->Ln();
          $pdf->Cell(175,5, 'Kochi', 0, 0, 'R');
          $pdf->Ln();
          $pdf->Cell(175,5, 'PIN-682508', 0, 0, 'R');
          $pdf->Ln();
            
           
          $pdf->Ln();
          $pdf->SetFont('Times', 'B', 9);
          $pdf->Cell(10, 5, 'Bill To', 0, 0, 'L');
          $pdf->Cell(160, 5, 'Invoice :', 0, 0, 'R');
          $pdf->Ln();
          $pdf->Cell(10, 5, $username, 0, 0, 'L');
          $pdf->Cell(160, 5, 'FC00'.$home_id, 0, 0, 'R');
          $pdf->Ln();
          $pdf->MultiCell(50, 6, $address, 0, 'L');
          $pdf->Cell(160, 5, 'PH NO : '.$phone, 0, 0, 'L');
          $pdf->Ln();
          $pdf->Ln();
          $pdf->Cell(10, 5, 'PIN : '.$postcode, 0, 0, 'L');
          $pdf->Cell(160, 5, 'Date', 0, 0, 'R');


          $pdf->Ln();
          $pdf->Cell(10, 5, 'GSTNO : 32ABRFA6518R1ZS', 0, 0, 'L');
          $pdf->Cell(160, 5, date('d-m-Y',strtotime($date)), 0, 0, 'R');
          $pdf->Cell(160, 5, '$time', 0, 0, 'R');




          $pdf->Ln();
          $pdf->Ln();



          $pdf->SetFont('Times', 'B', 10);
          $pdf->Cell(20,12,'Items',1);
          $pdf->Cell(46,12,'Description',1);
          $pdf->Cell(50,12,'Manufacture Name',1);
          $pdf->Cell(20,12,'Quantity',1);
          $pdf->Cell(20,12,'Price',1);
          $pdf->Cell(20,12,'Amount',1);
          $pdf->SetFont('Times', '', 8); 
            $pdf->Ln();
            for($i=0;$i<$num;$i++){
           $sqls="select * from product where id='".$product_id[$i]."' AND product_name='".$product[$i]."'";
                                                    $result_pins=mysqli_query($conn,$sqls);
                                                    $row=mysqli_fetch_array($result_pins);
                                        $bid = $row['brand_id']; 
                                        if($bid > 0) {
                                        $sq = mysqli_query($conn,"SELECT * FROM brand WHERE id='$bid'");
                                        while($res = mysqli_fetch_array($sq))
                                          {
                                              $mnc=$res['brand_name'];
                                          }
                                        } else { $mnc = ''; }
                                                    $wg=$row['weight'];
                                                   
          $pdf->Cell(20,12,$row['prdct_code'],1);
          $pdf->Cell(46,12,$product[$i].' ('.$wg.') ',1);
          $pdf->Cell(50,12,$mnc,1);
          $pdf->Cell(20,12,$product_no[$i],1);
           $cart="select * from purchased_products where product_id='".$product_id[$i]."' order by id desc";
                                                    $result_cart=mysqli_query($conn,$cart);
                                                    $row_cart=mysqli_fetch_array($result_cart);
                                                   
                                                $price=$row_cart['price'];
                                                $tot = $price*$product_no[$i];
            $sql="select * from product where product_name='".$product[$i]."'";
                                                    $result_pin=mysqli_query($conn,$sql);
                                                    $row=mysqli_fetch_array($result_pin);
                                                    
                                                    $gs = $row['gst'];
                                                    $gst = $gs*$product_no[$i];


          if (mysqli_num_rows($result_pin)==0) {
            $sql="select * from packages where product_name='".$product[$i]."'";
                                                    $result_pin=mysqli_query($conn,$sql);
                                                    $row=mysqli_fetch_array($result_pin);
                                                $price=$row_cart['price'];
                                                $tot = $price*$product_no[$i];
          $pdf->Cell(20,12,$price,1);
          }
          else{
            $pdf->Cell(20,12,$price,1);
          }
          $pdf->Cell(20,12,$tot,1);

          $pdf->Ln();


          }
          $pdf->Cell(66,12,'Delivery Charge',1);
          $pdf->Cell(110,12,'30',1);
          $pdf->Ln();
          $pdf->Ln();
          $pdf->SetFont('Times', 'B', 10);
          $pdf->Cell(10, 5, 'Total Amount', 0, 0, 'L');

          $taxRate=$gst_total;
          $tax=$grand*$taxRate/100;

          $pdf->Cell(160, 5, 'Rs.'.$total, 0, 0, 'R');

          $pdf->Ln();



          $pdf->Ln();



          $pdf->SetFont('Times', 'B', 10);
          $pdf->Cell(20,12,'Items',1);
          $pdf->Cell(46,12,'Tax rate(CGST & SGST)',1);
          $pdf->Cell(40,12,'Tax Amount',1);
          $pdf->SetFont('Times', '', 8); 
          $pdf->Ln();
          $tgst = 0;
          for($i=0;$i<$num;$i++){
           $sqls="select * from product where product_name='".$product[$i]."'";
                                                    $result_pins=mysqli_query($conn,$sqls);
                                                    $row=mysqli_fetch_array($result_pins);
                                        $bid = $row['brand_id']; 
                                        if($bid > 0)
                                        {
                                        $sq = mysqli_query($conn,"SELECT * FROM brand WHERE id='$bid'");
                                        while($res = mysqli_fetch_array($sq))
                                          {
                                              $mnc=$res['brand_name'];
                                          }
                                        } else { $mnc = ''; }
                                                    $wg=$row['weight'];

           $cart="select * from purchased_products where product_id='".$product_id[$i]."'";
                                                    $result_cart=mysqli_query($conn,$cart);
                                                    $row_cart=mysqli_fetch_array($result_cart);
                                                    $price=$row_cart['price'];
                                                    $tot = $row_cart['total'];
            $sql="select * from product where product_name='".$product[$i]."'";
                                                    $result_pin=mysqli_query($conn,$sql);
                                                    $row=mysqli_fetch_array($result_pin);
                                                    $code = $row['prdct_code'];
                                                    $gs = $row['gst'];
                                                    $gst = $gs*$product_no[$i];
          if (mysqli_num_rows($result_pin)==0) {
            $sql="select * from packages where product_name='".$product[$i]."'";
                                                    $result_pin=mysqli_query($conn,$sql);
                                                    $row=mysqli_fetch_array($result_pin);
                                                    $price=$row_cart['price'];
                                                    $tot_gst = $row['gst_price'];
          $taxs = $tot_gst*$product_no[$i];
          $gs = 'pkg';
          $code='#PKG';
          }
          else {
            
          $taxRates=$gst;
          $taxs=$price*$taxRates/100;
          $totals=$grand+$taxs; // 315

              
          }
          $pdf->Cell(20,12,$code,1);
          $pdf->Cell(46,12,$gs.'%',1);
          $pdf->Cell(40,12,$taxs,1);
          $pdf->Ln();

          $tgst = $tgst+$taxs;
          }
          $pdf->Cell(66,12,'Total tax amount',1);
          $pdf->Cell(40,12,$tgst,1);
          $pdf->Ln();
          if(isset($_SESSION['discount_rate'])) 
          {
              $tot_amount = $grand;
              $final_amount = round($tot_amount-$_SESSION['discount_rate']);
              $pdf->Ln();
              $pdf->SetFont('Times', 'B', 10);
              $pdf->Cell(10, 5, 'Coupon Discount :', 0, 0, 'L');
              $pdf->Cell(160, 5, 'Rs.'.$_SESSION['discount_rate'].'/-', 0, 0, 'R');
          }
          else {
              $result = $grand;
              $amtot = $result;
              $final_amount = round($amtot);
          }
          $pdf->Ln();
          $pdf->Ln();
          $pdf->SetFont('Times', 'B', 14);
          $pdf->Cell(10, 5, 'Grand Total', 0, 0, 'L');

          $pdf->Cell(160, 5, 'Rs.'.$total.'/-', 0, 0, 'R');
$pdf->Output();







// $separator = md5(time());


// $eol = PHP_EOL;



// $filename = $username."orders.pdf";


// $pdf->Output($filename,'I');







    
mysqli_close($conn);

?>