# HG changeset patch # User Michiel Broek # Date 1541705432 -3600 # Node ID 7af1d472475ae3f1051ab50e47ebafe9ac4da9a5 # Parent aad866b2bcea76fad839b0e6c54f001825c94b46 Inventory PDF now properly handles UTF8 encoding. diff -r aad866b2bcea -r 7af1d472475a www/inv_instock.php --- a/www/inv_instock.php Thu Nov 08 19:57:32 2018 +0100 +++ b/www/inv_instock.php Thu Nov 08 20:30:32 2018 +0100 @@ -5,6 +5,14 @@ define('EURO', chr(128) ); $link = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME); +if (! $link) { + die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); +} +if (! mysqli_set_charset($link, "utf8" )) { + echo "error"; + return 1; +} + setlocale ( LC_ALL, 'nl_NL.UTF-8'); class PDF_MySQL_Table extends FPDF @@ -86,8 +94,8 @@ $this->SetX($this->TableX); $ci=$this->ColorIndex; $this->SetFillColor($this->RowColors[$ci][0],$this->RowColors[$ci][1],$this->RowColors[$ci][2]); - $this->Cell(30,5,$row['supplier'],0,0,'L',true); - $this->Cell(90,5,$row['name'],0,0,'L',true); + $this->Cell(30,5,iconv('UTF-8','windows-1252',$row['supplier']),0,0,'L',true); + $this->Cell(90,5,iconv('UTF-8','windows-1252',$row['name']),0,0,'L',true); $this->Cell(30,5,sprintf("%10.3f kg",$row['inventory']),0,0,'R',true); $this->Cell(20,5,sprintf("%8.2f ",$row['cost']).EURO,0,0,'R',true); $this->Cell(20,5,sprintf("%8.2f ",$value).EURO,0,0,'R',true); @@ -134,9 +142,9 @@ $this->SetX($this->TableX); $ci=$this->ColorIndex; $this->SetFillColor($this->RowColors[$ci][0],$this->RowColors[$ci][1],$this->RowColors[$ci][2]); - $this->Cell(30,5,$row['origin'],0,0,'L',true); - $this->Cell(75,5,$row['name'],0,0,'L',true); - $this->Cell(15,5,$row['form'],0,0,'L',true); + $this->Cell(30,5,iconv('UTF-8','windows-1252',$row['origin']),0,0,'L',true); + $this->Cell(75,5,iconv('UTF-8','windows-1252',$row['name']),0,0,'L',true); + $this->Cell(15,5,iconv('UTF-8','windows-1252',$row['form']),0,0,'L',true); $this->Cell(30,5,sprintf("%10.1f gr",$stock),0,0,'R',true); $this->Cell(20,5,sprintf("%8.2f ",$row['cost']).EURO,0,0,'R',true); $this->Cell(20,5,sprintf("%8.2f ",$value).EURO,0,0,'R',true); @@ -184,9 +192,9 @@ $this->SetX($this->TableX); $ci=$this->ColorIndex; $this->SetFillColor($this->RowColors[$ci][0],$this->RowColors[$ci][1],$this->RowColors[$ci][2]); - $this->Cell(30,5,$row['laboratory'],0,0,'L',true); - $this->Cell(20,5,$row['product_id'],0,0,'L',true); - $this->Cell(70,5,$row['name'],0,0,'L',true); + $this->Cell(30,5,iconv('UTF-8','windows-1252',$row['laboratory']),0,0,'L',true); + $this->Cell(20,5,iconv('UTF-8','windows-1252',$row['product_id']),0,0,'L',true); + $this->Cell(70,5,iconv('UTF-8','windows-1252',$row['name']),0,0,'L',true); $this->Cell(30,5,sprintf("%10.1f ",$stock).$amount,0,0,'R',true); $this->Cell(20,5,sprintf("%8.2f ",$row['cost']).EURO,0,0,'R',true); $this->Cell(20,5,sprintf("%8.2f ",$value).EURO,0,0,'R',true); @@ -233,8 +241,8 @@ $this->SetX($this->TableX); $ci=$this->ColorIndex; $this->SetFillColor($this->RowColors[$ci][0],$this->RowColors[$ci][1],$this->RowColors[$ci][2]); - $this->Cell(30,5,$row['type'],0,0,'L',true); - $this->Cell(90,5,$row['name'],0,0,'L',true); + $this->Cell(30,5,iconv('UTF-8','windows-1252',$row['type']),0,0,'L',true); + $this->Cell(90,5,iconv('UTF-8','windows-1252',$row['name']),0,0,'L',true); $this->Cell(30,5,sprintf("%10.1f ",$stock).$amount,0,0,'R',true); $this->Cell(20,5,sprintf("%8.2f ",$row['cost']).EURO,0,0,'R',true); $this->Cell(20,5,sprintf("%8.2f ",$value).EURO,0,0,'R',true);