Fixed the dates in aqbudget.pl
authorwolfpac444 <wolfpac444>
Sat, 5 Apr 2003 03:19:33 +0000 (03:19 +0000)
committerwolfpac444 <wolfpac444>
Sat, 5 Apr 2003 03:19:33 +0000 (03:19 +0000)
C4/Date.pm
admin/aqbudget.pl
koha-tmpl/intranet-tmpl/default/en/parameters/aqbudget.tmpl

index c7ddfc4..3b8dcdc 100644 (file)
@@ -56,6 +56,11 @@ sub format_date
        my $olddate = shift;
        my $newdate;
 
+       if ( ! $olddate )
+       {
+               return "";
+       }
+
        my $dateformat = get_date_format();
        
        if ( $dateformat eq "us" )
@@ -86,6 +91,11 @@ sub format_date_in_iso
 {
         my $olddate = shift;
         my $newdate;
+
+        if ( ! $olddate )
+        {
+                return "";
+        }
                 
         my $dateformat = get_date_format();
 
index bc242d6..820b43e 100755 (executable)
@@ -39,6 +39,7 @@
 
 use strict;
 use CGI;
+use C4::Date;
 use C4::Auth;
 use C4::Context;
 use C4::Output;
@@ -46,8 +47,6 @@ use C4::Interface::CGI::Output;
 use C4::Search;
 use HTML::Template;
 
-
-
 sub StringSearch  {
        my ($env,$searchstring,$type)=@_;
        my $dbh = C4::Context->dbh;
@@ -130,8 +129,9 @@ if ($op eq 'add_form') {
        } else {
            $template->param(adding => 1);
        }
-       $template->param(startdate => $dataaqbudget->{'startdate'});
-       $template->param(enddate => $dataaqbudget->{'enddate'});
+       $template->param(dateformat => display_date_format() );
+       $template->param(startdate => format_date($dataaqbudget->{'startdate'}));
+       $template->param(enddate => format_date($dataaqbudget->{'enddate'}));
        $template->param(budgetamount => $dataaqbudget->{'budgetamount'});
                                                                                                        # END $OP eq ADD_FORM
 ################## ADD_VALIDATE ##################################
@@ -140,8 +140,8 @@ if ($op eq 'add_form') {
        my $dbh = C4::Context->dbh;
        my $query = "replace aqbudget (bookfundid,startdate,enddate,budgetamount) values (";
        $query.= $dbh->quote($input->param('bookfundid')).",";
-       $query.= $dbh->quote($input->param('startdate')).",";
-       $query.= $dbh->quote($input->param('enddate')).",";
+       $query.= $dbh->quote(format_date_in_iso($input->param('startdate'))).",";
+       $query.= $dbh->quote(format_date_in_iso($input->param('enddate'))).",";
        $query.= $dbh->quote($input->param('budgetamount')).")";
        my $sth=$dbh->prepare($query);
        $sth->execute;
@@ -160,8 +160,8 @@ if ($op eq 'add_form') {
        my $data=$sth->fetchrow_hashref;
        $sth->finish;
        $template->param(bookfundid => $bookfundid);
-       $template->param(startdate => $data->{'startdate'});
-       $template->param(enddate => $data->{'enddate'});
+       $template->param(startdate => format_date($data->{'startdate'}));
+       $template->param(enddate => format_date($data->{'enddate'}));
        $template->param(budgetamount => $data->{'budgetamount'});
                                                                                                        # END $OP eq DELETE_CONFIRM
 ################## DELETE_CONFIRMED ##################################
@@ -205,8 +205,8 @@ if ($op eq 'add_form') {
                push(@toggle,$toggle);
                push(@bookfundid,$results->[$i]{'bookfundid'});
                push(@bookfundname,$dataaqbookfund->{'bookfundname'});
-               push(@startdate,$results->[$i]{'startdate'});
-               push(@enddate,$results->[$i]{'enddate'});
+               push(@startdate,format_date($results->[$i]{'startdate'}));
+               push(@enddate,format_date($results->[$i]{'enddate'}));
                push(@budgetamount,$results->[$i]{'budgetamount'});
                if ($toggle eq 'white'){
                        $toggle="#ffffcc";
index 634582e..faecc7f 100644 (file)
@@ -91,8 +91,8 @@
 <TMPL_IF name="adding">
 <tr><td>Book fund</td><td><input type=text name=bookfundid size=5 maxlength=5 onBlur=toUC(this)></td></tr>
 </TMPL_IF>
-<tr><td>Start date</td><td><input type=text name=startdate size=40 maxlength=80 value='<TMPL_VAR name="startdate">'>&nbsp;</td></tr>
-<tr><td>End date</td><td><input type=text name=enddate value='<TMPL_VAR name="enddate">'></td></tr>
+<tr><td>Start date (<TMPL_VAR NAME=dateformat>)</td><td><input type=text name=startdate size=40 maxlength=80 value='<TMPL_VAR name="startdate">'>&nbsp;</td></tr>
+<tr><td>End date (<TMPL_VAR NAME=dateformat>)</td><td><input type=text name=enddate value='<TMPL_VAR name="enddate">'></td></tr>
 <tr><td>Budget amount</td><td><input type=text name=budgetamount value='<TMPL_VAR name="budgetamount">'></td></tr>
 <tr><td>&nbsp;</td><td><INPUT type=button value='OK' onClick='Check(this.form)'></td></tr>
 </table>