Jump to content
Changes to the Jaspersoft community edition download ×

passing parameter with php date value using JasperReports


Recommended Posts

for example

I have this code in php file that calls the jrxml which receives date parameters. but it generates empty result. the question is how and what type should be the parameters for the mysql query can resolve and return a result and thank you very much

******************************

<?php 

session_start(); 
    $fechadesde = $_POST['select1'];
    $fechahasta = $_POST['select2'];
    $empre = $_SESSION['empresa'] ;
 
ini_set('memory_limit','128M'); 
include_once("class/tcpdf/tcpdf.php");
include_once("class/PHPJasperXML.inc.php"); // La clase que interactua con el ireport 
include_once ("setting.php"); // nuestra clase donde esta nuestra conf de ingreso a la bd 
 
 $date1 = strtotime($fechadesde);
$ano1= date("Y", $date1); // Year (2003)
$mes1 =date("m", $date1); // Month (12)
$dia1 =date("d", $date1); // day (14)
//  $fec  = '2019-06-01';
$date2 = strtotime($fechahasta);
$ano2= date("Y", $date2); // Year (2003)
$mes2 =date("m", $date2); // Month (12)
$dia2 =date("d", $date2); // day (14)
 
//$condicion = " where (toma_exterior.idempresa = ".$empre." )";
$xml = simplexml_load_file("agrupado_estado_amp_exterior_x_fecha_imp.jrxml"); // Leemos nuestro reporte de ireport 
 
$PHPJasperXML = new PHPJasperXML(); // instanciamos el obj  ,"fecha"=>"2015-06-30"
$PHPJasperXML->debugsql=false; // Si deseas ver la setencia del sql del reporte lo pones en true 
//$PHPJasperXML->arrayParameter=array("desde"=> $fechadesde,"hasta"=> $fechahasta,"cual_empresa"=>(int) $empre);
$PHPJasperXML->arrayParameter=array("ano1"=>(int) $ano1,"mes1"=>(int) $mes1,"dia1"=> (int) $dia1,"ano2"=>(int) $ano2,"mes2"=>(int) $mes2,"dia2"=> (int) $dia2,"cual_empresa"=>(int) $empre);
$PHPJasperXML->xml_dismantle($xml); 
$PHPJasperXML->transferDBtoArray($server,$user,$pass,$db); // las opciones de conexion de base de datos 
$PHPJasperXML->outpage("I"); // I: muetsra en el browser D: descarga el pdf 
?>
***********************************************
code ".jrxml" for consul mysql thank you
*********************************************
SELECT
     SUM(toma_exterior.sn) AS sn,
     SUM(toma_exterior.rcc) AS rcc,
     SUM(toma_exterior.hcc) AS hcc,
     SUM(toma_exterior.ds) AS ds,
     SUM(toma_exterior.dt) AS dt,
     SUM(toma_exterior.acpds) AS acpds,
     SUM(toma_exterior.acpdt) AS acpdt,
     toma_exterior.`idtomaexterior`,
     toma_exterior.`fechacarga`,
     toma_exterior.`idempresa`,
     toma_exterior.`idexterior`,
     empresa.`nombre_empresa`
FROM
     `empresa` empresa INNER JOIN `toma_exterior` toma_exterior ON empresa.`idempresa` = toma_exterior.`idempresa`
WHERE
((year(toma_exterior.fechacarga)+month(toma_exterior.fechacarga)) >= ($P{ano1}+$P{mes1})) and ((year(toma_exterior.fechacarga)+month(toma_exterior.fechacarga)) <= ($P{ano2}+$P{mes2}))
 AND (toma_exterior.idempresa = $P{cual_empresa})
GROUP BY
     toma_exterior.fechacarga
ORDER BY
     toma_exterior.fechacarga ASC
**********************************************
 
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...