Bug #2127: Rapport : erreur quand un rapport est demandé

This commit is contained in:
sparkyx 2022-01-22 09:49:46 +01:00
parent 55f9dd9a73
commit ff25c4bdb7
3 changed files with 89 additions and 10 deletions

View file

@ -63,13 +63,13 @@ class Acc_Report
* from a report
* \param $p_start start periode
* \param $p_end end periode
* \param $p_type_date type of the date : periode or calendar
* \param $p_type_date type of the date : periode (or 0) or calendar (or 1)
*/
function get_row($p_start,$p_end,$p_type_date)
{
if (DEBUGNOALYSS > 1) {
tracedebug("impress.debug.log",__FILE__."71.get_row({$p_start},{$p_end},{$p_type_date})");
}
if (DEBUGNOALYSS > 1) {
tracedebug("impress.debug.log",__FILE__."71.get_row({$p_start},{$p_end},{$p_type_date})");
}
$Res=$this->form_definition->cn->exec_sql("select fo_id ,
fo_fr_id,
fo_pos,
@ -87,13 +87,15 @@ class Acc_Report
}
$col=array();
$a_type_date=["periode"=>0,"calendar"=>1];
if (array_key_exists($p_type_date, $a_type_date) )
{
$type_date=$a_type_date[$p_type_date];
if ( $p_type_date == '0' || $p_type_date=="periode") {
$type_date=0;
} elseif ($p_type_date == '1' || $p_type_date=="calendar") {
$type_date=1;
} else {
throw new Exception("acr93 invalid type_date [ {$p_type_date} ] ");
throw new Exception("ACR93:invalid type_date [ {$p_type_date} ] ");
}
for ($i=0;$i<$Max;$i++)
{
$l_line=Database::fetch_array($Res,$i);

View file

@ -280,7 +280,7 @@ $date_to=new IDate('to_date');
$date_to->id='to_date';
echo td(_("Calendrier depuis :"));
echo td($date_from->input('to_date'));
echo td($date_from->input('from_date'));
echo td(_("jusque"));
echo td($date_to->input('to_date'));
echo '</tr>';

View file

@ -0,0 +1,77 @@
<?php
/*
* * Copyright (C) 2022 Dany De Bontridder <dany@alchimerys.be>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Author : Dany De Bontridder danydb@noalyss.eu
*
*/
/**
* @file
* @brief
*/
use PHPUnit\Framework\TestCase;
/**
* @backupGlobals enabled
* @coversDefaultClass \Acc_Report
*/
require 'global.php';
class Acc_ReportTest extends TestCase
{
/**
* @var Fiche
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test method is executed.
*/
protected function setUp():void
{
include 'global.php';
}
public function test_getRowExistingForm()
{
global $g_connection;
$report=new Acc_Report($g_connection,3000000);
$aResult=$report->get_row(132,144,0);
$aResultDate=$report->get_row('01.01.2020','31.12.2020',1);
$this->assertEquals($aResult,$aResultDate,"Acc_Report::get_row gives different results ");
$this->assertFalse(empty($aResult),"Acc_Report::get_row retrieves a empty array");
}
public function test_getRowNotExistingForm()
{
global $g_connection;
$report=new Acc_Report($g_connection,1);
$aResult=$report->get_row(132,144,0);
$aResultDate=$report->get_row('01.01.2020','31.12.2020',1);
$this->assertEquals($aResult,$aResultDate,"Acc_Report::get_row gives different results ");
$this->assertTrue(empty($aResult),"Acc_Report::get_row retrieves a empty array");
}
}