KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Ajuda (help) with CloudExport error #2294

Closed inforsi opened this topic on on Aug 23, 2021 - 3 comments

inforsi commented on Aug 23, 2021

Boas, estou a usar o cloudexport e já consigo exportar para pdf, acontece que neste relatorio tenho um filtro de data inicio, fim e cliente. acontece que quando faço exportar para pdf ele da o seguinte erro:

(Well, I'm using cloudexport and I can already export to pdf, it turns out that in this report I have a start, end and client date filter. it happens that when I export to pdf it gives the following error:)

Notice: Undefined index: inicio in C:\xampp72\htdocs\systema\customRelatorioFaturaIVA\export.php on line 9

Notice: Undefined index: fim in C:\xampp72\htdocs\systema\customRelatorioFaturaIVA\export.php on line 10

Notice: Undefined index: cliente in C:\xampp72\htdocs\systema\customRelatorioFaturaIVA\export.php on line 11

Notice: Undefined index: table in C:\xampp72\htdocs\systema\customRelatorioFaturaIVA\export.php on line 12

Fatal error: Uncaught Exception: Query Error >> [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' "/", .doc_serie_fk) AS sid, .clienteEmpresa, .nomeClienteEmpresa, cast(.tot...' at line 1] >> SELECT CONCAT(.serieFatura, "/", .doc_serie_fk) AS sid, .clienteEmpresa, .nomeClienteEmpresa, cast(.totalCIVA AS DECIMAL(10,2)), cast(.totalSIVA AS DECIMAL(65,4)) as totalSIVA, cast(SUM(.totalCIVA-.totalSIVA) as DECIMAL(65,4)) as totalIVA, stock.id as stid, stock.descricao, stock.quantidade, stock.preco as PrecoPeloQualFoiVendido, cadastroartigos.taxaIVA, (cadastroartigos.taxaIVA / 100) + 1 as taxIVAFormatada, ((stock.preco / ((cadastroartigos.taxaIVA / 100) + 1))(cadastroartigos.taxaIVA/100)) as incidencia, cast(((stock.preco / ((cadastroartigos.taxaIVA / 100) + 1))(cadastroartigos.taxaIVA/100))*stock.quantidade AS DECIMAL(1 in C:\xampp72\htdocs\systema\vendor\koolreport\core\src\datasources\PdoDataSource.php on line 432 alguem sabe como resolver?

INDEX.PHP

<?php 
  require_once('functions.php'); 
  add();
?>

<?php include(HEADER_TEMPLATE); ?>

<?php

require_once "MyReport.php";
$report = new MyReport(array(
  "inicio"=>$_REQUEST['inicio'],
  "fim"=>$_REQUEST['fim'],
  "cliente"=>$_REQUEST['cliente'],
  "table"=>$_REQUEST['table'],
  "title"=>"Relatório de IVA Venda"
));
@$report->run()->render();					
                

Sebastian Morales commented on Aug 24, 2021

Pls wrap your whole report in a <form> tag and use an export button instead of an <a> export link. Make sure that when you click the export button you have data in $_REQUEST variable. Rgds,

inforsi commented on Aug 24, 2021

O problema é quando tento exportar ele da esse erro.

export.php
<?php
require_once "MyReport.php";
$report = new MyReport;
$report->run()
->cloudExport("MyReportPDF")
->chromeHeadlessio("........")
->pdf()
->toBrowser("Relatorio_Iva.pdf");
/**
 * Follow the instruction here to get token key
 * https://www.koolreport.com/docs/cloudexport/chromeheadlessio/#get-token-key 
 */

$secretToken = 'my_cloud_export_secret_token';
$type=isset($_GET['type']) ? $_GET['type'] : 'PDF';
$settings = [
	// 'useLocalTempFolder' => true,
	"pageWaiting" => "networkidle2", //load, domcontentloaded, networkidle0, networkidle2
];
if ($type === 'cloudJPG') {
    $report->cloudExport("MyReportPDF")
    ->chromeHeadlessio($secretToken)
	->settings($settings)
    ->jpg(array(
        // "format"=>"A4",
         "fullPage" => true
    ))
    ->toBrowser("MyReport.jpg")
    ;
} else if ($type === 'cloudPDF') {
    $pdfOptions = [
        "format"=>"A4",
        'landscape'=>false,
        // 'displayHeaderFooter' => true,
        // 'headerTemplate' => '
            // <div id="header-template" 
                // style="font-size:10px !important; color:#808080; padding-left:10px">
                // <span>Footer command: </span>
                // <span class="date"></span>
                // <span class="title"></span>
                // <span class="url"></span>
                // <span class="pageNumber"></span>
                // <span class="totalPages"></span>
            // </div>
        // ',
        // 'footerTemplate' => '
            // <div id="footer-template" 
                // style="font-size:10px !important; color:#808080; padding-left:10px">
                // <span>Footer command: </span>
                // <span class="date"></span>
                // <span class="title"></span>
                // <span class="url"></span>
                // <span class="pageNumber"></span>
                // <span class="totalPages"></span>
            // </div>
        // ',
        // 'margin' => [
            // 'top'    => '100px',
            // 'bottom' => '200px',
            // 'right'  => '30px',
            // 'left'   => '30px'
        // ],
        // "noRepeatTableHeader" => true,
        "noRepeatTableFooter" => true,
    ];
    $report->cloudExport("MyReportPDF")
    ->chromeHeadlessio($secretToken)
    ->settings($settings)
    ->pdf($pdfOptions)
    ->toBrowser("MyReport.pdf")
    ;
} 

como posso fazer para no exportar ter essas variáveis ?

Sebastian Morales commented on Aug 25, 2021

Something like this:

//MyReport.view.php
<form method="post">
    //Put your repor here including text input. select, checkbox, radio, etc
    ...
    <button formaction="export.php>Export</button>
</form>

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

CloudExport