Bug simple report : FROM 00.0000 was computed from user preference
instead of end period. Improve ergonomy Signed-off-by: sparkyx <danydb@noalyss.eu>
This commit is contained in:
parent
5e153bd44d
commit
8ea668ed86
3 changed files with 40 additions and 33 deletions
|
|
@ -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>';
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue