use C4::Auth; # get_template_and_user
use C4::Output;
use C4::Acquisition;
-use C4::Dates qw(format_date_in_iso);
+use C4::Dates;
+
+use vars qw($debug);
+
+BEGIN {
+ $debug = $ENV{DEBUG} || 0;
+}
my $input = new CGI;
-my $title = $input->param('title');
+$debug or $debug = $input->param('debug') || 0;
+my $title = $input->param( 'title');
my $author = $input->param('author');
-my $name = $input->param('name');
-my $from_placed_on = $input->param('fromplacedon');
-my $to_placed_on = format_date_in_iso($input->param('toplacedon'));
+my $name = $input->param( 'name' );
+my $from_placed_on = C4::Dates->new($input->param('from'));
+my $to_placed_on = C4::Dates->new($input->param( 'to'));
my $dbh = C4::Context->dbh;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
}
);
+my $from_iso = ($from_placed_on->output('iso') || 0);
+my $to_iso = ( $to_placed_on->output('iso') || 0);
my ( $order_loop, $total_qty, $total_price, $total_qtyreceived ) =
- &GetHistory( $title, $author, $name, $from_placed_on, $to_placed_on );
+ &GetHistory( $title, $author, $name, $from_iso, $to_iso );
$template->param(
suggestions_loop => $order_loop,
title => $title,
author => $author,
name => $name,
- from_placed_on => $from_placed_on,
- to_placed_on => $to_placed_on,
- DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
+ from_placed_on => $from_placed_on->output('syspref'),
+ to_placed_on => $to_placed_on->output('syspref'),
+ DHTMLcalendar_dateformat=> C4::Dates->DHTMLcalendar(),
+ dateformat => C4::Dates->new()->format(),
+ debug => $debug,
);
output_html_with_http_headers $input, $cookie, $template->output;
return 0;
}
}
+
+function get_Calendar_limit (date,did) {
+ // this function could be moved to a static calendar-extras.js file
+ var dvalue = document.getElementById(did).value;
+ if (dvalue == "") { return false; }
+ var limitDate = Date_from_syspref(dvalue);
+ if (debug && debug > 5) {
+ var month = date.getMonth() + 1;
+ var dateString = date.getFullYear() + '-' + month + '-' + date.getDate();
+ alert("Comparing incoming (" + dateString + ") vs "
+ + "'" + did + "' limit\n"
+ + "\n thisdate: " + date
+ + "\nlimitdate: " + limitDate
+ + "\nlimit > thisdate : " + (limitDate > date)
+ + "\nlimit < thisdate : " + (limitDate < date)
+ );
+ }
+ return limitDate;
+}
//]]>
</script>
<!-- TMPL_UNLESS NAME="suggestions_loop" --><form action="/cgi-bin/koha/acqui/histsearch.pl" method="post">
<fieldset class="rows">
<legend>Search Orders</legend>
- <ol>
- <li><label for="title">Title: </label> <input type="text" name="title" id="title" value="<!-- TMPL_VAR name="title"-->" /></li>
- <li><label for="author">Author: </label> <input type="text" name="author" id="author" value="<!-- TMPL_VAR name="author" -->" /></li>
- <li><label for="name">Vendor: </label> <input type="text" name="name" id="name" value="<!-- TMPL_VAR name="name" -->" /></li>
- <li><label for="from">From: </label>
- <input type="text" readonly="readonly" size="10" id="from" name="fromplacedon" value="<!-- TMPL_VAR name="from_placed_on" -->" /> <img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" border="0" id="openCalendarFrom" style="cursor: pointer;" alt="Show Calendar" />
- <script language="JavaScript" type="text/javascript">
- function validate1(date) {
- var day = date.getDate();
- var month = date.getMonth() + 1;
- var year = date.getFullYear();
- var weekDay = date.getDay();
- var dayMonth = month + '-' + day;
- var dateString = year + '-' + month + '-' + day;
- var dateTo = document.getElementById('to').value.split("-");
- var limitDate = new Date(dateTo[0], (dateTo[1] - 1), dateTo[2]);
- if (date > limitDate) {
- return true;
- } else {
- return false;
- }
- }
- Calendar.setup(
- {
- inputField : "from",
- ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
- button : "openCalendarFrom",
- disableFunc : validate1,
- dateStatusFunc : validate1
- }
- );
- </script></li>
- <li><label for="to">To: </label>
- <input readonly="readonly" size="10" id="to" name="toplacedon" value="<!-- TMPL_VAR name="to_placed_on" -->" type="text" /> <img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="openCalendarTo" style="cursor: pointer;" alt="Show Calendar" />
- <script type="text/javascript">
- function validate2(date) {
- var day = date.getDate();
- var month = date.getMonth() + 1;
- var year = date.getFullYear();
- var weekDay = date.getDay();
- var dayMonth = month + '-' + day;
- var dateString = year + '-' + month + '-' + day;
- var dateFrom = document.getElementById('from').value.split("-");
- var limitDate = new Date(dateFrom[0], (dateFrom[1] - 1), dateFrom[2]);
- if (limitDate > date) {
- return true;
- } else {
- return false;
- }
- }
-
- Calendar.setup(
- {
- inputField : "to",
- ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
- button : "openCalendarTo",
- disableFunc : validate2,
- dateStatusFunc : validate2
- }
- );
- </script></li>
- </ol>
- </fieldset>
- <fieldset class="action"><input type="submit" value="Search" /></fieldset>
- </form><!-- /TMPL_UNLESS -->
+ <ol>
+ <li><label for="title">Title: </label> <input type="text" name="title" id="title" value="<!-- TMPL_VAR name="title"-->" /></li>
+ <li><label for="author">Author: </label> <input type="text" name="author" id="author" value="<!-- TMPL_VAR name="author" -->" /></li>
+ <li><label for="name">Vendor: </label> <input type="text" name="name" id="name" value="<!-- TMPL_VAR name="name" -->" /></li>
+ <li><label for="from">From: </label>
+ <input type="text" size="10" id="from" name="from" value="<!-- TMPL_VAR name="from_placed_on" -->" />
+ <img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="openCalendarFrom" style="cursor: pointer;" alt="Show Calendar" />
+ </li>
+ <li><label for="to">To: </label>
+ <input type="text" size="10" id="to" name="to" value="<!-- TMPL_VAR name="to_placed_on" -->" />
+ <img src="<!-- TMPL_VAR Name="themelang" -->/lib/calendar/cal.gif" id="openCalendarTo" style="cursor: pointer;" alt="Show Calendar" />
+ <script type="text/javascript">
+ // return true if the date is blocked.
+ function disable_from(date) {var limit = get_Calendar_limit(date,'to' ); return (limit && limit < date);} // true or false
+ function disable_to (date) {var limit = get_Calendar_limit(date,'from'); return (limit && limit > date);} // true or false
+ Calendar.setup({
+ inputField : "from",
+ ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
+ button : "openCalendarFrom",
+ disableFunc : disable_from,
+ dateStatusFunc : disable_from
+ });
+ Calendar.setup({
+ inputField : "to",
+ ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
+ button : "openCalendarTo",
+ disableFunc : disable_to,
+ dateStatusFunc : disable_to
+ });
+ </script>
+ </li>
+ </ol>
+ </fieldset>
+ <fieldset class="action"><input type="submit" value="Search" /></fieldset>
+ </form><!-- /TMPL_UNLESS -->
<!-- TMPL_IF NAME="suggestions_loop" --><h1>Search Results</h1>
<div id="acqui_histsearch">
<table>
// }
// }
- function get_limit (date,did) {
- var dvalue = document.getElementById(did).value;
- if (dvalue == "") { return false; }
- var limitDate = Date_from_syspref(dvalue);
- if (debug && debug > 5) {
- var month = date.getMonth() + 1;
- var dateString = date.getFullYear() + '-' + month + '-' + date.getDate();
- alert("comparing to " + did + " date:\n"
- + (limitDate > date) + "\n date: " + date
- + "\nincoming:\n" + dateString + "\nlimitdate: " + limitDate
- );
- }
- return limitDate;
- }
+ // return true if the date is blocked.
+ function disable_from(date) {var limit = get_Calendar_limit(date,'to' ); return (limit && limit < date);}
+ function disable_to (date) {var limit = get_Calendar_limit(date,'from'); return (limit && limit > date);}
- function validatefrom(date) {return (get_limit(date,'to' ) < date);} // true or false
- function validateto (date) {return (get_limit(date,'from') > date);} // true or false
-
- Calendar.setup(
- {
+ Calendar.setup({
inputField : "from",
ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
button : "openCalendarFrom",
- disableFunc : validatefrom,
- dateStatusFunc : validatefrom
- }
- );
- Calendar.setup(
- {
+ disableFunc : disable_from,
+ dateStatusFunc : disable_from
+ });
+ Calendar.setup({
inputField : "to",
ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
button : "openCalendarTo",
- disableFunc : validateto,
- dateStatusFunc : validateto
- }
- );
+ disableFunc : disable_to,
+ dateStatusFunc : disable_to
+ });
</script>
</p>