kohabug 1679 & 1680 Fixes date formatting in guided reports wizard

This patch corrects date formatting when defining dictionary definitions in the
guided reports wizard so that dates display according to syspref.

Date formating is also corrected in the report creation section of the guided
reports wizard.

It also corrects a javascript bug which caused some of the calander widgets not
to function properly.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
Chris Nighswonger 2008-08-04 10:15:18 -05:00 committed by Joshua Ferraro
parent 23b8da277b
commit 35b3df2e95
5 changed files with 72 additions and 48 deletions

View File

@ -340,18 +340,23 @@ sub execute_query {
}
my $sth = $dbh->prepare($sql);
$sth->execute();
my $colnames=$sth->{'NAME'};
my @results;
my $row;
my %temphash;
$row = join ('</th><th>',@$colnames);
$row = "<tr><th>$row</th></tr>";
$temphash{'row'} = $row;
push @results, \%temphash;
my $colnames=$sth->{'NAME'};
my @results;
my $row;
my %temphash;
$row = join ('</th><th>',@$colnames);
$row = "<tr><th>$row</th></tr>";
$temphash{'row'} = $row;
push @results, \%temphash;
my $string;
my @xmlarray;
my @xmlarray;
while ( my @data = $sth->fetchrow_array() ) {
# if the field is a date field, it needs formatting
foreach my $data (@data) {
next unless $data =~ C4::Dates->regexp("iso");
my $date = C4::Dates->new($data, "iso");
$data = $date->output();
}
# tabular
my %temphash;
my $row = join( '</td><td>', @data );

View File

@ -204,7 +204,7 @@ Filter by area <select name="areas">
<script type="text/javascript">
Calendar.setup({
inputField : "<!-- TMPL_VAR NAME="name" -->_start_value",
ifFormat : "%Y-%m-%d",
ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
button : "buttonfrom1",
align : "Tl"
});
@ -215,12 +215,12 @@ align : "Tl"
<td>End of date range</td>
<td>
<input type="text" size="10" id="<!-- TMPL_VAR NAME="name" -->_end_value" name="<!-- TMPL_VAR NAME="name" -->_end_value" value="" />
<img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="buttonfrom1" style="cursor: pointer;" />
<img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="buttonfrom2" style="cursor: pointer;" />
<script type="text/javascript">
Calendar.setup({
inputField : "<!-- TMPL_VAR NAME="name" -->_end_value",
ifFormat : "%Y-%m-%d",
button : "buttonfrom1",
ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
button : "buttonfrom2",
align : "Tl"
});
</script>

View File

@ -152,8 +152,7 @@ reports</p>
<input type="submit" name="submit" value="Next &gt;&gt;" /></fieldset>
</form>
</div>
<div class="yui-gb"><div class="yui-u first">Tabular:
<img src="<!-- TMPL_VAR name="themelang" -->/../img/reports-tabular-graphic.gif" alt="" /></div>
<div class="yui-gb"><div class="yui-u first"></div>
<!--- Summary and Matrix reports have not yet been implemented-->
<!--<div class="yui-u">Summary:
@ -230,9 +229,9 @@ NAME="name" -->"><!-- TMPL_VAR NAME="description" --> </label>
/><img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="buttonfrom<!-- TMPL_VAR NAME="name" -->" style="cursor: pointer;" alt="Show Calendar" title="Show Calendar" />
<script type="text/javascript">
Calendar.setup({
inputField : "<!-- TMPL_VAR NAME="name" -->_value",
ifFormat : "%Y-%m-%d",
button : "buttonfrom<!-- TMPL_VAR NAME="name" -->",
inputField : "<!-- TMPL_VAR NAME="name" -->_value",
ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
button : "buttonfrom<!-- TMPL_VAR NAME="name" -->",
align : "Tl"
});
</script>

View File

@ -22,6 +22,7 @@ use C4::Auth;
use CGI;
use C4::Output;
use C4::Reports;
use C4::Dates qw( DHTMLcalendar );
=head1 NAME
@ -127,7 +128,7 @@ elsif ($phase eq 'New Term step 4'){
'definition_description' => $definition_description,
'columns' => \@column_loop,
'columnstring' => $columnstring,
'DHTMLcalendar_dateformat' => C4::Dates->DHTMLcalendar(),
);
}
@ -145,28 +146,39 @@ elsif ($phase eq 'New Term step 5'){
foreach my $crit (@criteria) {
my $value = $input->param( $crit . "_value" );
if ($value) {
$query_criteria .= " AND $crit='$value'";
my %tmp_hash;
$tmp_hash{'name'}=$crit;
$tmp_hash{'value'} = $value;
push @criteria_loop,\%tmp_hash;
my %tmp_hash;
$tmp_hash{'name'}=$crit;
$tmp_hash{'value'} = $value;
push @criteria_loop,\%tmp_hash;
if ($value =~ C4::Dates->regexp(C4::Context->preference('dateformat'))) {
my $date = C4::Dates->new($value);
$value = $date->output("iso");
}
$query_criteria .= " AND $crit='$value'";
}
$value = $input->param( $crit . "_start_value" );
if ($value) {
$query_criteria .= " AND $crit > '$value'";
my %tmp_hash;
$tmp_hash{'name'}="$crit Start";
$tmp_hash{'value'} = $value;
push @criteria_loop,\%tmp_hash;
my %tmp_hash;
$tmp_hash{'name'}="$crit Start";
$tmp_hash{'value'} = $value;
push @criteria_loop,\%tmp_hash;
if ($value =~ C4::Dates->regexp(C4::Context->preference('dateformat'))) {
my $date = C4::Dates->new($value);
$value = $date->output("iso");
}
$query_criteria .= " AND $crit >= '$value'";
}
$value = $input->param( $crit . "_end_value" );
if ($value) {
$query_criteria .= " AND $crit <= '$value'";
my %tmp_hash;
$tmp_hash{'name'}="$crit End";
$tmp_hash{'value'} = $value;
push @criteria_loop,\%tmp_hash;
my %tmp_hash;
$tmp_hash{'name'}="$crit End";
$tmp_hash{'value'} = $value;
push @criteria_loop,\%tmp_hash;
if ($value =~ C4::Dates->regexp(C4::Context->preference('dateformat'))) {
my $date = C4::Dates->new($value);
$value = $date->output("iso");
}
$query_criteria .= " AND $crit <= '$value'";
}
}
$template->param( 'step_5' => 1,
@ -195,7 +207,7 @@ elsif ($phase eq 'Delete Definition'){
$no_html=1;
my $id = $input->param('id');
delete_definition($id);
print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=View%20Dictionary");
print $input->redirect("/cgi-bin/koha/reports/dictionary.pl?phase=View%20Dictionary");
}
$template->param( 'referer' => $referer );

View File

@ -22,6 +22,8 @@ use CGI;
use C4::Reports;
use C4::Auth;
use C4::Output;
use C4::Dates qw( DHTMLcalendar );
=head1 NAME
Script to control the guided report creation
@ -172,6 +174,10 @@ elsif ( $phase eq 'Choose these criteria' ) {
foreach my $crit (@criteria) {
my $value = $input->param( $crit . "_value" );
if ($value) {
if ($value =~ C4::Dates->regexp(C4::Context->preference('dateformat'))) {
my $date = C4::Dates->new($value);
$value = $date->output("iso");
}
$query_criteria .= " AND $crit='$value'";
}
}
@ -181,7 +187,7 @@ elsif ( $phase eq 'Choose these criteria' ) {
'area' => $area,
'type' => $type,
'column' => $column,
'definition' => $definition,
'definition' => $definition,
'criteriastring' => $query_criteria,
);
@ -239,7 +245,7 @@ elsif ( $phase eq 'Choose These Operations' ) {
'column' => $column,
'criteriastring' => $criteria,
'totals' => $totals,
'definition' => $definition,
'definition' => $definition,
);
# get columns
@ -331,7 +337,7 @@ elsif ( $phase eq 'Execute' ) {
my $results = execute_query($sql,$type);
$template->param(
'results' => $results,
'sql' => $sql,
'sql' => $sql,
'execute' => 1
);
}
@ -341,13 +347,13 @@ elsif ($phase eq 'Run this report'){
my $report = $input->param('reports');
my ($sql,$type,$name,$notes) = get_saved_report($report);
my $results = execute_query($sql,$type);
$template->param(
'results' => $results,
'sql' => $sql,
'execute' => 1,
'name' => $name,
'notes' => $notes,
);
$template->param(
'results' => $results,
'sql' => $sql,
'execute' => 1,
'name' => $name,
'notes' => $notes,
);
}
elsif ($phase eq 'Export'){
@ -389,7 +395,9 @@ elsif ($phase eq 'Save Compound'){
}
$template->param( 'referer' => $referer );
$template->param( 'referer' => $referer,
'DHTMLcalendar_dateformat' => C4::Dates->DHTMLcalendar(),
);
if (!$no_html){