[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 14/46: Bug simple report : FROM 00.0000 was c
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 14/46: Bug simple report : FROM 00.0000 was computed from user preference instead of end period. Improve ergonomy |
Date: |
Tue, 13 Jul 2021 05:01:52 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 8ea668ed8629213e8af26b8a06c926a0d56dbff0
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Thu Jun 10 17:26:07 2021 +0200
Bug simple report : FROM 00.0000 was computed from user preference
instead of end period.
Improve ergonomy
Signed-off-by: sparkyx <danydb@noalyss.eu>
---
include/impress_rapport.inc.php | 24 ++++++++++-------
include/lib/impress.class.php | 38 ++++++++++++---------------
unit-test/include/class/impressTest.class.php | 11 ++++++--
3 files changed, 40 insertions(+), 33 deletions(-)
diff --git a/include/impress_rapport.inc.php b/include/impress_rapport.inc.php
index 6ed2dc8..30c55e5 100644
--- a/include/impress_rapport.inc.php
+++ b/include/impress_rapport.inc.php
@@ -84,7 +84,7 @@ if ( isset( $_GET['bt_html'] ) )
}
catch (Exception $ex)
{
- alert($ex->getMessage());;
+ alert($ex->getMessage());
}
@@ -101,7 +101,7 @@ if ( isset( $_GET['bt_html'] ) )
{
$t=($from_periode==$to_periode)?"":" ->
".getPeriodeName($cn,$to_periode,'p_end');
- echo '<h2 class="info">'.$form_id
+ echo '<h2 >'.$form_id
." ".$form_label
." - ".getPeriodeName($cn,$from_periode,'p_start')
." ".$t
@@ -109,7 +109,7 @@ if ( isset( $_GET['bt_html'] ) )
}
else
{
- echo '<h2 class="info">'.$form_id." ".$form_label.
+ echo '<h2 >'.$form_id." ".$form_label.
' Date :'.
$from_date.
" au ".
@@ -124,8 +124,10 @@ if ( isset( $_GET['bt_html'] ) )
printf( 'id="%s" onsubmit="download_document_form(\'%s\')">',$id,$id);
echo dossier::hidden().
- HtmlInput::submit('bt_other',"Autre Rapport").
-
$hid->input("type","rapport").$hid->input("ac",$access_code)."</form></TD>";
+ $hid->input("form_id",$form_id).
+ HtmlInput::submit('bt_other',"Autre Rapport").
+ $hid->input("type","rapport").
+ $hid->input("ac",$access_code)."</form></TD>";
echo '<TD><form method="GET" ACTION="export.php" ';
$id=uniqid("export_");
@@ -187,7 +189,7 @@ if ( isset( $_GET['bt_html'] ) )
$a=0;
foreach ( $array as $e)
{
- printf( '<h2 class="info">%s</h2> ',$periode_name[$a]);
+ printf( '<h2>%s</h2> ',$periode_name[$a]);
$a++;
ShowReportResult($e);
}
@@ -227,22 +229,24 @@ printf( ' onsubmit="waiting_box()">');
echo 'Choisissez un autre exercice :';
$ex=new Exercice($cn);
-$wex=$ex->select('exercice',$exercice,' onchange="submit(this)"');
+$wex=$ex->select('exercice',$exercice,
+ sprintf('
onchange="updatePeriode(\'%s\',\'exercice\',\'from_periode\',\'to_periode\',1)"',Dossier::id(),$exercice));
echo $wex->input();
echo dossier::hidden();
echo HtmlInput::get_to_hidden(array('ac','type'));
-echo '</form>';
+
echo '</fieldset>';
echo '<FORM METHOD="GET" onsubmit="waiting_box()">';
$hidden=new IHidden();
-echo $hidden->input("ac",$_GET['ac']);
+echo $hidden->input("ac",$access_code);
echo $hidden->input("type","rapport");
echo dossier::hidden();
echo '<TABLE><TR>';
$w=new ISelect();
+$w->selected=$http->request("form_id","string",0);
$w->table=1;
print td(_("Choisissez le rapport"));
print $w->input("form_id",$ret);
@@ -282,7 +286,7 @@ $date_to=new IDate('to_date');
$date_to->id='to_date';
echo td(_("Calendrier depuis :"));
-echo td($date_from->input('from_date'));
+echo td($date_from->input('to_date'));
echo td(_("jusque"));
echo td($date_to->input('to_date'));
echo '</tr>';
diff --git a/include/lib/impress.class.php b/include/lib/impress.class.php
index ea12d72..0969a42 100644
--- a/include/lib/impress.class.php
+++ b/include/lib/impress.class.php
@@ -314,27 +314,27 @@ class Impress
*/
static public function compute_periode($p_cn, $p_from,$p_end)
{
- global $g_user;
// There is a FROM clause
// then we must modify the cond for the periode
// Get the periode
- /* ! \note special value for the clause FROM=00.0000
+ /* ! \note special value for the clause FROM=00.0000, we take the
first day of the exercice of $p_end
*/
if ($p_from=='00.0000')
{
-
+ $current_exercice=$p_cn->get_value('select p_exercice from
parm_periode where p_id=$1',
+ [$p_end]);
+ if ( $current_exercice=="") {
+ throw new Execution(_('CP329'));
+ }
+ $first_day=$p_cn->get_value("select
to_char(min(p_start),'DD.MM.YYYY') as p_start from parm_periode where
p_exercice=$1",
+ [$current_exercice]);
+ $last_day=$p_cn->get_value("select to_char(p_end,'DD.MM.YYYY')
from parm_periode where p_id=$1",[$p_end]);
// retrieve the first month of this periode
- $user_periode=$g_user->get_periode();
- $oPeriode=new Periode($p_cn);
- $periode=$oPeriode->get_exercice($user_periode);
- list($first, $last)=$oPeriode->get_limit($periode);
- $ret=$first->get_date_limit();
- $end_date=$oPeriode->get_date_limit($p_end);
- if ($ret==null)
+ if (empty($first_day))
throw new Exception('Pas de limite à cette période', 1);
- $cond=sql_filter_per($p_cn, $ret['p_start'], $end_date['p_end'],
'date', 'j_tech_per');
+ $cond=sql_filter_per($p_cn, $first_day, $last_day, 'date',
'j_tech_per');
}
else
{
@@ -349,17 +349,13 @@ class Impress
/* if none periode is found
then we take the first periode of the year
*/
- $user_periode=$g_user->get_periode();
-
- $year=$oPeriode->get_exercice($user_periode);
- list($first, $last)=$oPeriode->get_limit($year);
- $ret=$first->get_date_limit();
- $end_date=$oPeriode->get_date_limit($p_end);
- if ($ret==null)
- {
+
+ $first_day=$p_cn->get_value("select
to_char(min(p_start),'DD.MM.YYYY') as p_start from parm_periode");
+ $last_day=$p_cn->get_value("select to_char(p_end,'DD.MM.YYYY')
from parm_periode where p_id=$1",[$p_end]);
+ // retrieve the first month of this periode
+ if (empty($first_day))
throw new Exception('Pas de limite à cette période', 1);
- }
- $cond=sql_filter_per($p_cn, $ret['p_start'],
$end_date['p_end'], 'date', 'j_tech_per');
+ $cond=sql_filter_per($p_cn, $first_day, $last_day, 'date',
'j_tech_per');
}
}
return $cond;
diff --git a/unit-test/include/class/impressTest.class.php
b/unit-test/include/class/impressTest.class.php
index 1c66045..c229350 100644
--- a/unit-test/include/class/impressTest.class.php
+++ b/unit-test/include/class/impressTest.class.php
@@ -180,15 +180,22 @@ class ImpressTest extends TestCase
function test_computePeriode()
{
global $g_connection,$g_parameter,$g_user;
- $g_user->set_periode(110);
+ $g_user->set_periode(98);
$this->assertEquals(trim("j_tech_per in (select p_id from parm_periode
where p_start >= to_date('01.01.2017','DD.MM.YYYY') and p_end <=
to_date('30.11.2017','DD.MM.YYYY'))"),trim(\Impress::compute_periode($g_connection,
"00.0000",115))
," SQL from 01.01.2017 to 01.11.2017");
+ $this->assertEquals(trim("j_tech_per in (select p_id from parm_periode
where p_start >= to_date('01.01.2020','DD.MM.YYYY') and p_end <=
to_date('30.09.2020','DD.MM.YYYY'))"),trim(\Impress::compute_periode($g_connection,
"00.0000",140))
+ ," SQL from 01.01.2020 to 01.11.2020");
+ $this->assertEquals(trim("j_tech_per in (select p_id from parm_periode
where p_start >= to_date('01.01.2019','DD.MM.YYYY') and p_end <=
to_date('30.09.2019','DD.MM.YYYY'))"),trim(\Impress::compute_periode($g_connection,
"00.0000",127))
+ ," SQL from 01.01.2019 to 30.09.2019");
$this->assertEquals(
trim("j_tech_per in (select p_id from parm_periode where
p_start >= to_date('01.02.2017','DD.MM.YYYY') and p_end <=
to_date('31.10.2017','DD.MM.YYYY'))"),
trim(\Impress::compute_periode($g_connection, "02.2017",114)),
" SQL from 01.02.2017 to 01.10.2017");
-
+ $this->assertEquals(
+ trim("j_tech_per in (select p_id from parm_periode where
p_start >= to_date('01.01.2017','DD.MM.YYYY') and p_end <=
to_date('31.10.2017','DD.MM.YYYY'))"),
+ trim(\Impress::compute_periode($g_connection, "02.2000",114)),
+ " From periode doesn't exist, we start from the first period
found SQL from 01.02.2017 to 01.10.2017");
}
/**
* @covers Impress::parse_formula
- [Noalyss-commit] [noalyss] 32/46: Code Cleaning #0002022: Utilisation d'un autoloader, (continued)
- [Noalyss-commit] [noalyss] 32/46: Code Cleaning #0002022: Utilisation d'un autoloader, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 35/46: Update Translation, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 36/46: get the output with transform2pdf in case it fails, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 41/46: Cosmetic #0002033: Alignement totaux + Trésorerie -> Financier/banque, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 42/46: Typo , debug information, jQuery available, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 43/46: check that g_user exists and not the g_theme, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 46/46: Merge branch 'master' of gitlab.noalyss.eu:noalyss/noalyss, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 45/46: Cosmetic : unwanted char in operation detail, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 37/46: Manage_Table show header even if table empty, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 13/46: Forecast : protect against empty name, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 14/46: Bug simple report : FROM 00.0000 was computed from user preference instead of end period. Improve ergonomy,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 25/46: Cosmetic : appearance h2.info, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 30/46: fix bug, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 34/46: Typo , adapt unit-test, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 38/46: Remove Actif / Passif as card attribute, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 39/46: Acc_ledger : use $currency_rate instead of variable from extract, Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 40/46: Merge branch 'b-orion' into 'master', Dany De Bontridder, 2021/07/13
- [Noalyss-commit] [noalyss] 44/46: Cosmetic : unwanted char in operation detail, Dany De Bontridder, 2021/07/13