#php #fpdf
Вопрос:
У меня возникла проблема с FPDF. У меня возникла проблема. Устаревшие: Методы с тем же именем, что и их класс, не будут конструкторами в будущей версии PHP; FPDF имеет устаревший конструктор. Я работаю над квитанцией. На локальном хосте мой код работает нормально, но когда я загружаю код в свой домен, он показывает ошибку, подобную этой устаревшей: Методы с тем же именем, что и их класс, не будут конструкторами в будущей версии PHP; FPDF имеет устаревший конструктор
вот мой код
<?php
include('includes/database.php');
include('code.php');
require('fpdf17/fpdf.php');
if (isset($_GET['edit_id'])) {
session_start();
$_SESSION['order_id'] = $_GET['edit_id'];
session_commit();
//Add a custom size
$db = new PDO("mysql:host=localhost; dbname=name", "root", "");
class myPDF extends FPDF
{
function headerTable()
{
include('includes/database.php');
$reportSubtitle = "Ñ";
$reportSubtitle = iconv('UTF-8', 'windows-1252', $reportSubtitle);
$this->Image('headerlogo.png', 9.5, 5, 'C');
$order_id = $_SESSION['order_id'];
$cust = "SELECT * FROM orders WHERE order_id = '$order_id'";
$query_cust = mysqli_query($connection, $cust);
$rowc = mysqli_fetch_assoc($query_cust);
$_SESSION['cust_id'] = $rowc['customer_id'];
$this->SetFont('Arial', '', 6);
$this->SetY(9);
$this->Cell(0, 40, ' addres', 0, 2, 'C');
$this->Ln(-18);
$this->Cell(0, 0, ' STO NI' . $reportSubtitle . 'address', 0, 2, 'C');
$this->Ln(2);
$this->Cell(0, 0, ' CONTACT US ON: 092622222', 0, 2, 'C');
$this->Ln(2.4);
$this->Cell(0, 0, ' 0922222224', 0, 2, 'C');
$this->Ln(2.5);
$this->Cell(0, 0, ' _______________________________________________', 0, 2, 'C');
}
function viewTable($db)
{
include('includes/database.php');
date_default_timezone_set('Asia/Manila');
$timestampa = date("m/d/Y");
$time = date("h:i:s a");
$order_id = $_SESSION['order_id'];
$user_id = $_SESSION['user_id'];
$sql = "SELECT * FROM user WHERE user_id = '$user_id'";
$query = mysqli_query($connection, $sql);
$row = mysqli_fetch_assoc($query);
$cust_id = $_SESSION['cust_id'];
$sql_cust = "SELECT * FROM customer WHERE id = '$cust_id'";
$query_custs = mysqli_query($connection, $sql_cust);
$rowcc = mysqli_fetch_assoc($query_custs);
$query_tid = "SELECT COUNT(*) as countz FROM orders WHERE DELIVERY_STATUS = 'delivered'";
$query_run_tid = mysqli_query($connection, $query_tid);
$row_tid = mysqli_fetch_assoc($query_run_tid);
$se_order = "SELECT tid From orders WHERE order_id = '$order_id'";
$query_se = mysqli_query($connection, $se_order);
$row_se = mysqli_fetch_assoc($query_se);
$tid = $row_tid['countz'];
$se = $row_se['tid'];
if ($se == 0){
$se = $tid 1;
$up_tid = "UPDATE orders SET tid = '$se' WHERE order_id = '$order_id'";
$query_up = mysqli_query($connection, $up_tid);
}
$this->SetFont('Arial', '', 6);
$this->SetFont('Arial', '', 6);
$this->SetY(40);
$this->Cell(-100, 10, 'Sold To:' . ' ' . $rowcc['CUS_FIRSTNAME'] . ' ' . $rowcc['CUS_LASTNAME'], 0, 0, 'L');
$this->Ln(3);
$this->Cell(-100, 10, 'Date:' . ' ' . $timestampa . ' Time:' . ' ' . $time, 0, 0, 'L');
$this->Ln(3);
$this->Cell(-100, 10, 'Cashier: ' . 'Code ' . ' ' . $row['user_username'] . ' T-ID:' . $se, 0, 0, 'L');
$this->Ln(3);
$this->Cell(-100, 10, ' _______________________________________________', 0, 0, 'L');
$this->Ln(5);
$stmt = $db->query("SELECT order_item.*, orders.*, product.* FROM order_item LEFT OUTER JOIN orders ON (order_item.order_id = orders.order_id) LEFT OUTER JOIN product ON (order_item.product_id = product.PRODUCT_ID) WHERE orders.DRIDER_ID != 0 AND order_item.order_id ='$order_id'");
if ($stmt->rowCount() == 0) {
$this->Ln();
$this->SetFont('Times', '', 6);
$this->Cell(276, 5, 'Record not found', 0, 0, 'C');
}
$i = 0;
while ($data = $stmt->fetch(PDO::FETCH_OBJ)) {
$discount_minus = $data->discount_minus;
$sell = $data->PRODUCT_SELLING_PRICE;
$sell = number_format($sell, 2);
//compute total of each product purchase
$total_quantity = $data->total_qty;
$qty = $data->quantity;
$price = $data->PRODUCT_SELLING_PRICE;
$amount = $qty * $price;
$this->Cell(-100, 10, $data->quantity . ' ' . $data->PRODUCT_GENERIC_NAME . ' ' . $data->PRODUCT_DOSAGE . ' ' . $data->PRODUCT_FORM, 0, 0, 'L');
$this->Ln(3);
$this->Cell(-100, 10, '(' . $data->PRODUCT_BRANDNAME . ')' . ' ' . '@' . $sell, 0, 0, 'L');
$this->Ln(3);
$this->Cell(0, 2, $amount, 0, 0, 'R');
$this->Ln(3);
//compute total amount purchased
$sub = $amount;
if ($i == 0) {
$sub1 = $sub;
//get the minus discount
$discounted = $discount_minus;
if ($discount_minus == '') {
$discounted = 0;
}
}
if ($i >= 1) {
$sub1 = $sub1 $sub;
$sub1 = number_format($sub1, 2);
$discounted = $discount_minus $discounted;
$discounted = number_format($discounted, 2);
}
$i ;
}
$fee = 50;
$fee = number_format($fee, 2);
$change = 0.00;
$change = number_format($change, 2);
$all_total1 = $sub1 - $discounted;
$all_total1 = abs($all_total1);
$all_total1 = number_format($all_total1, 2);
$all_total = $all_total1 $fee;
$all_total = number_format($all_total, 2);
$this->Ln(2);
$this->Cell(0, 10, 'No of item(s): ' . $total_quantity, 0, 0, 'C');
$this->Ln(3);
$this->SetFont('Arial', '', 8);
$this->Cell(0, 10, 'SUB TOTAL:' . ' ' . $sub1, 0, 0, 'L');
$this->Ln(3);
$this->Cell(0, 10, 'DISCOUNT:' . ' ' . $discounted, 0, 0, 'L');
$this->Ln(3);
$this->Cell(0, 10, 'DELIVERY FEE:' . ' ' . $fee, 0, 0, 'L');
$this->Ln(3);
$this->Cell(0, 10, ' ==========', 0, 0, 'L');
$this->Ln(5);
$this->SetFont('Arial', 'B', 10);
$this->Cell(0, 10, 'AMOUNT DUE:' . ' ' . $all_total, 0, 0, 'L');
$this->Ln(4);
$this->SetFont('Arial', '', 8);
$this->Cell(0, 10, 'Cash Tendered:' . ' ' . $all_total, 0, 0, 'L');
$this->Ln(3);
$this->Cell(0, 10, ' ==========', 0, 0, 'L');
$this->Ln(5);
$this->SetFont('Arial', 'B', 10);
$this->Cell(0, 10, 'CHANGE' . ' ' . $change, 0, 0, 'L');
$this->Ln(6);
$this->Cell(0, 0, ' _______________________________________________', 0, 2, 'C');
$this->SetFont('Arial', 'B', 6);
$this->Cell(0, 10, 'Transaction # ' . $se, 0, 0, 'C');
$this->Ln(6);
$this->Cell(0, 0, ' _______________________________________________', 0, 2, 'C');
$this->Ln(-15);
$this->SetFont('Arial', '', 6);
$this->Cell(0, 40, ' This serves as Official Receipt', 0, 2, 'C');
$this->Ln(-18);
$this->Cell(0, 0, ' Thank you and Come Again!', 0, 2, 'C');
$this->Ln(2);
$this->Cell(0, 0, ' Like us on Facebook', 0, 2, 'C');
$this->Ln(5);
$this->Cell(0, 0, 'Customer Name: __________________', 0, 2, 'L');
$this->Ln(4);
$this->Cell(0, 0, 'ID #: __________________', 0, 2, 'L');
$this->Ln(4);
$this->Cell(0, 0, 'Signature: __________________', 0, 2, 'L');
$this->Ln(4);
}
function footer()
{
$this->SetY(-15);
$this->SetFont('Arial', '', 8);
$this->Cell(0, 10, 'Page' . $this->PageNo() . '/{nb}', 0, 0, 'C');
}
}
$pdf = new myPDF();
$pdf->SetMargins(1, 5, 1);
$pdf->AliasNbPages();
$pdf->AddPage('P', [200, 58], 0);
$pdf->headerTable();
$pdf->viewTable($db);
$pdf->Output();
}
вот код в строке 12 в FPDF
определите(«FPDF_VERSION»,»1.7″);
class FPDF
{
var $page; // current page number
var $n; // current object number
var $offsets; // array of object offsets
var $buffer; // buffer holding in-memory PDF
var $pages; // array containing pages
var $state; // current document state
var $compress; // compression flag
var $k; // scale factor (number of points in user unit)
var $DefOrientation; // default orientation
var $CurOrientation; // current orientation
var $StdPageSizes; // standard page sizes
var $DefPageSize; // default page size
var $CurPageSize; // current page size
var $PageSizes; // used for pages with non default sizes or orientations
var $wPt, $hPt; // dimensions of current page in points
var $w, $h; // dimensions of current page in user unit
var $lMargin; // left margin
var $tMargin; // top margin
var $rMargin; // right margin
var $bMargin; // page break margin
var $cMargin; // cell margin
var $x, $y; // current position in user unit
var $lasth; // height of last printed cell
var $LineWidth; // line width in user unit
var $fontpath; // path containing fonts
var $CoreFonts; // array of core font names
var $fonts; // array of used fonts
var $FontFiles; // array of font files
var $diffs; // array of encoding differences
var $FontFamily; // current font family
var $FontStyle; // current font style
var $underline; // underlining flag
var $CurrentFont; // current font info
var $FontSizePt; // current font size in points
var $FontSize; // current font size in user unit
var $DrawColor; // commands for drawing color
var $FillColor; // commands for filling color
var $TextColor; // commands for text color
var $ColorFlag; // indicates whether fill and text colors are different
var $ws; // word spacing
var $images; // array of used images
var $PageLinks; // array of links in pages
var $links; // array of internal links
var $AutoPageBreak; // automatic page breaking
var $PageBreakTrigger; // threshold used to trigger page breaks
var $InHeader; // flag set when processing header
var $InFooter; // flag set when processing footer
var $ZoomMode; // zoom display mode
var $LayoutMode; // layout display mode
var $title; // title
var $subject; // subject
var $author; // author
var $keywords; // keywords
var $creator; // creator
var $AliasNbPages; // alias for total number of pages
var $PDFVersion;
Комментарии:
1. Почему бы вам не перейти на последнюю версию?
2. @Оливье да, спасибо