KoolReport's Forum

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

Get user-entered parameters #1989

Open Gabriela Matheus opened this topic on on Mar 23, 2021 - 2 comments

Gabriela Matheus commented on Mar 23, 2021

sorry if that topic already exists, but I didn’t succeed with any of the examples I found. I need to get the date parameters entered by the user in the report.view.php input and pass in the report.php query. I managed to pass a fixed parameter, but I have doubts on how to bring this parameter from the view to the query in report.php. Sorry if that sounds easy, but I don't know.

My report.view.php


<h2 id="texto">Relatório de Vendas</h2>

<form action="VendasIndex.php" method="post">
<label for="DataDe">Data De:</label>
<input type="date" name="DataDe" id="">

<label for="DataAte">Data Até:</label>
<input type="date" name="DataAte" id="">

<input type="button" value="Pesquisar">
</form>



<?php
    \koolreport\widgets\koolphp\Table::create(array(
   
    "dataSource"=>$this->dataStore('resultDados'),
    )); 
?>

my report.php

 protected function setup()
    {
       
        $this->src("conexao")
        ->query("Select v.CODIGO_VENDA as NUM_VENDA , v.CODIGO_CLIENTE ,c.NOME,v.NUM_PECAS,v.VALOR,v.DESCONTO,v.TOTAL -isnull(z.ValorNaoDevido,0) TOTAL,v.TIPO_VENDA,v.STATUS_VENDA,Case when f.CREDIARIO = 'CREDIÁRIO' then 'Sim' else 'Não' end as CREDIARIO, isnull(s.Integrado, 'Não') as Integrado 
        from VENDAS v 
         inner join CLIENTE c 
        on v.CODIGO_CLIENTE = c.CODIGO 
        and v.LOJA = c.LOJA 
         left join(Select CODIGO_VENDA, LOJA,'CREDIÁRIO' as CREDIARIO from FORMA_PAGAMENTO_VENDA where TIPO_FORMA_PGTO = 'CREDIÁRIO' group by CODIGO_VENDA,LOJA) as f 
        on v.CODIGO_VENDA = f.CODIGO_VENDA 
        and v.LOJA = f.LOJA 
        left join(SELECT codigoVenda, 'Sim' Integrado 
        FROM    MovimentoSAT 
        WHERE   CodigoRetornoEEEEE = 6000 
        GROUP BY codigoVenda) as S on v.CODIGO_VENDA = S.codigoVenda 
       left join( Select f.CODIGO_VENDA,f.LOJA, SUM(f.VALOR) as ValorNaoDevido 
       from VENDAS v  inner  join FORMA_PAGAMENTO_VENDA f on v.CODIGO_VENDA = f.CODIGO_VENDA 
       where TIPO_FORMA_PGTO in ('CREDITO', 'BRINDE', 'VALEPRESENTE') 
       and v.STATUS_VENDA = 'Finalizado' 
       group by f.CODIGO_VENDA,f.LOJA) as z on v.CODIGO_VENDA = z.CODIGO_VENDA and v.LOJA = z.LOJA where 1=1 and DATA>=:DATA ")
        ->params(array(
            ":DATA"=>$this->params["DATA"]
        ))
        ->pipe($this->dataStore("resultDados"));


    }

my index.php

<?php

require_once "./vendor/autoload.php";
require_once "VendasReport.php";



$report = new ReportVendas(array(
    "DATA"=>'2021-01-01'
));
$report->run()->render();


?>

Thank your for attention!

KoolReport commented on Mar 24, 2021

You do:

$report = new ReportVendas(array(
    "DATA"=>$_POST ["Your data key"]
));
$report->run()->render();

By this way you can catch value from post and enter it into report parameters.

Or better you can consider our Inputs package, the value posted from inputs package will be bind to the report parameters. This is not a must, just more convenient.

Gabriela Matheus commented on Mar 24, 2021

Am I right to put the inputs in report.view.php?

When I open the screen, instead of the title, this-> dataStore ('result') appears, and then the table data, what can it be?

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
None yet

None