View | Details | Raw Unified | Return to bug 21200
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc (-6 / +18 lines)
Lines 56-74 function validate_date (dateText, inst) { Link Here
56
    }
56
    }
57
}
57
}
58
58
59
function Date_from_syspref(dstring) {
59
function Date_from_syspref(dstring, tmpdformat) {
60
        var dateX = dstring.split(/[-/.]/);
60
        var dateX = dstring.split(/[-/.]/);
61
        if (typeof tmpdformat === 'undefined') {
62
           tmpdformat = dformat;
63
        }
61
        if (debug > 1 && sentmsg < 1) {sentmsg++; alert("Date_from_syspref(" + dstring + ") splits to:\n" + dateX.join("\n"));}
64
        if (debug > 1 && sentmsg < 1) {sentmsg++; alert("Date_from_syspref(" + dstring + ") splits to:\n" + dateX.join("\n"));}
62
        if (dformat === "iso") {
65
        if (tmpdformat === "iso") {
63
                return new Date(dateX[0], (dateX[1] - 1), dateX[2]);  // YYYY-MM-DD to (YYYY,m(0-11),d)
66
                return new Date(dateX[0], (dateX[1] - 1), dateX[2]);  // YYYY-MM-DD to (YYYY,m(0-11),d)
64
        } else if (dformat === "us") {
67
        } else if (tmpdformat === "us") {
65
                return new Date(dateX[2], (dateX[0] - 1), dateX[1]);  // MM/DD/YYYY to (YYYY,m(0-11),d)
68
                return new Date(dateX[2], (dateX[0] - 1), dateX[1]);  // MM/DD/YYYY to (YYYY,m(0-11),d)
66
        } else if (dformat === "metric") {
69
        } else if (tmpdformat === "metric") {
67
                return new Date(dateX[2], (dateX[1] - 1), dateX[0]);  // DD/MM/YYYY to (YYYY,m(0-11),d)
70
                return new Date(dateX[2], (dateX[1] - 1), dateX[0]);  // DD/MM/YYYY to (YYYY,m(0-11),d)
68
        } else if (dformat === "dmydot") {
71
        } else if (tmpdformat === "dmydot") {
69
                return new Date(dateX[2], (dateX[1] - 1), dateX[0]);  // DD.MM.YYYY to (YYYY,m(0-11),d)
72
                return new Date(dateX[2], (dateX[1] - 1), dateX[0]);  // DD.MM.YYYY to (YYYY,m(0-11),d)
70
        } else {
73
        } else {
71
                if (debug > 0) {alert("KOHA ERROR - Unrecognized date format: " +dformat);}
74
                if (debug > 0) {alert("KOHA ERROR - Unrecognized date format: " +tmpdformat);}
72
                return 0;
75
                return 0;
73
        }
76
        }
74
}
77
}
Lines 150-155 $("#dateofbirth").datepicker({ Link Here
150
    }).on("change", function(e, value) {
153
    }).on("change", function(e, value) {
151
        if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
154
        if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");}
152
    });
155
    });
156
157
    $( ".datepicker" ).each(function () {
158
        var defval = $(this).data("defvalue");
159
        if (defval !== "") {
160
           var tmpd = Date_from_syspref(defval, "iso");
161
           $(this).datepicker('setDate', tmpd);
162
        }
163
    });
164
153
    // http://jqueryui.com/demos/datepicker/#date-range
165
    // http://jqueryui.com/demos/datepicker/#date-range
154
    var dates = $( ".datepickerfrom, .datepickerto" ).datepicker({
166
    var dates = $( ".datepickerfrom, .datepickerto" ).datepicker({
155
        changeMonth: true,
167
        changeMonth: true,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-1 / +1 lines)
Lines 672-678 canned reports and writing custom SQL reports.</p> Link Here
672
                <input name="param_name" value="[% sql_param.name %]" type="hidden" />
672
                <input name="param_name" value="[% sql_param.name %]" type="hidden" />
673
                [% IF sql_param.input == 'date' %]
673
                [% IF sql_param.input == 'date' %]
674
                    <li>
674
                    <li>
675
                    <label for="date_[% sql_param_entry %][% loop.count %]">[% sql_param.entry %]:</label> <input id="date_[% sql_param_entry %][% loop.count %]" type="text" value="" size="10" name="sql_params" class="datepicker" />
675
                    <label for="date_[% sql_param_entry %][% loop.count %]">[% sql_param.entry %]:</label> <input id="date_[% sql_param_entry %][% loop.count %]" type="text" value="" data-defvalue="[% sql_param.inputvalue %]" size="10" name="sql_params" class="datepicker" />
676
                    </li>
676
                    </li>
677
                [% ELSIF ( sql_param.input == 'text' ) %]
677
                [% ELSIF ( sql_param.input == 'text' ) %]
678
                    <li><label for="sql_params[% loop.count %]">[% sql_param.entry %]: </label><input id="sql_params[% loop.count %]" type="text" name="sql_params" /></li>
678
                    <li><label for="sql_params[% loop.count %]">[% sql_param.entry %]: </label><input id="sql_params[% loop.count %]" type="text" name="sql_params" /></li>
(-)a/reports/guided_reports.pl (-3 / +11 lines)
Lines 701-719 elsif ($phase eq 'Run this report'){ Link Here
701
            my @authval_errors;
701
            my @authval_errors;
702
            my %uniq_params;
702
            my %uniq_params;
703
            for(my $i=0;$i<($#split/2);$i++) {
703
            for(my $i=0;$i<($#split/2);$i++) {
704
                my ($text,$authorised_value) = split /\|/,$split[$i*2+1];
704
                my ($text,$authorised_value,$def_value) = split /\|/,$split[$i*2+1];
705
                my $sep = $authorised_value ? "|" : "";
705
                my $sep = $authorised_value ? "|" : "";
706
                if( defined $uniq_params{$text.$sep.$authorised_value} ){
706
                if( defined $uniq_params{$text.$sep.$authorised_value} ){
707
                    next;
707
                    next;
708
                } else { $uniq_params{$text.$sep.$authorised_value} = "$i"; }
708
                } else { $uniq_params{$text.$sep.$authorised_value} = "$i"; }
709
                my $input;
709
                my $input;
710
                my $labelid;
710
                my $labelid;
711
                my $inputvalue;
711
                if ( not defined $authorised_value ) {
712
                if ( not defined $authorised_value ) {
712
                    # no authorised value input, provide a text box
713
                    # no authorised value input, provide a text box
713
                    $input = "text";
714
                    $input = "text";
714
                } elsif ( $authorised_value eq "date" ) {
715
                } elsif ( $authorised_value eq "date" ) {
715
                    # require a date, provide a date picker
716
                    # require a date, provide a date picker
716
                    $input = 'date';
717
                    $input = 'date';
718
                    if ( defined $def_value && ($def_value eq "now" || $def_value =~ /^([+-]?\d+) +(hour|day|week|month|year)$/) ) { # careful with the regex, we are doing explicit sql query
719
                        my ($ivalue, $interval) = ($1, $2);
720
                        ($ivalue, $interval) = (0, "hour") if ($def_value eq "now");
721
                        my $dbh=C4::Context->dbh;
722
                        my $sth = $dbh->prepare("SELECT DATE(DATE_ADD(NOW(), INTERVAL ? ".$interval." ))");
723
                        $sth->execute( $ivalue );
724
                        $inputvalue = $sth->fetchrow_array();
725
                    }
717
                } else {
726
                } else {
718
                    # defined $authorised_value, and not 'date'
727
                    # defined $authorised_value, and not 'date'
719
                    my $dbh=C4::Context->dbh;
728
                    my $dbh=C4::Context->dbh;
Lines 797-803 elsif ($phase eq 'Run this report'){ Link Here
797
                    };
806
                    };
798
                }
807
                }
799
808
800
                push @tmpl_parameters, {'entry' => $text, 'input' => $input, 'labelid' => $labelid, 'name' => $text.$sep.$authorised_value };
809
                push @tmpl_parameters, {'entry' => $text, 'input' => $input, 'inputvalue' => $inputvalue, 'labelid' => $labelid, 'name' => $text.$sep.$authorised_value };
801
            }
810
            }
802
            $template->param('sql'         => $sql,
811
            $template->param('sql'         => $sql,
803
                            'name'         => $name,
812
                            'name'         => $name,
804
- 

Return to bug 21200