Commit 356113af63d89e6998f955ee22dbf0ca95339cce

Authored by bshuttle
1 parent 36242472

date range widget (criteria) now works.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4578 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/browse/Criteria.inc
... ... @@ -272,12 +272,24 @@ class DateCreatedCriterion extends BrowseCriterion {
272 272 }
273 273 function searchWidget ($aRequest) {
274 274 global $default;
  275 +
  276 + // this is not ideal, but we don't actually have access to the
  277 + // dispatcher's oPage object.
  278 +
  279 + // even worse, we may _not_ have the items we want.
  280 +
  281 + global $main;
  282 +
275 283 $sStartWidget = $this->getWidgetBase() . "_start";
276 284 $sEndWidget = $this->getWidgetBase() . "_end";
  285 + /* // legacy code.
277 286 $sToRender = "After date: <input type=\"text\" size=\"10\" name=\"" . $sStartWidget . "\" />";
278 287 $sToRender .= "&nbsp;&nbsp;<a href=\"javascript:show_calendar('MainForm." . $sStartWidget . "',null,null,'YYYY-MM-DD', false);\" onmouseover=\"window.status='Date Picker';return true;\" onmouseout=\"window.status='';return true;\"><img src=\"$default->graphicsUrl/calendar/calendar.gif\" name=\"imgCalendar\" width=\"34\" height=\"21\" border=\"0\" alt=\"\"></a>";
279 288 $sToRender .= " &nbsp; Before date: <input type=\"text\" size=\"10\" name=\"" . $sEndWidget . "\" />";
280 289 $sToRender .= "&nbsp;&nbsp;<a href=\"javascript:show_calendar('MainForm." . $sEndWidget . "',null,null,'YYYY-MM-DD', false);\" onmouseover=\"window.status='Date Picker';return true;\" onmouseout=\"window.status='';return true;\"><img src=\"$default->graphicsUrl/calendar/calendar.gif\" name=\"imgCalendar\" width=\"34\" height=\"21\" border=\"0\" alt=\"\"></a>";
  290 + */
  291 + $sToRender = 'After Date: <span class="kt_calendar_holder"><strong class="kt_calendar_datetext">No Date Selected</strong><input type="hidden" name="' . $sStartWidget . '" class="kt_calendar_value" /> <input type="button" onclick="init_kt_calendar(this);" value="select"></span> &mdash; ';
  292 + $sToRender .= 'Before Date: <span class="kt_calendar_holder"><strong class="kt_calendar_datetext">No Date Selected</strong><input type="hidden" name="' . $sEndWidget . '" class="kt_calendar_value" /> <input type="button" onclick="init_kt_calendar(this);" value="select"></span><br />';
281 293 return $sToRender;
282 294 }
283 295 function searchSQL ($aRequest) {
... ...
resources/js/kt3calendar.js 0 → 100644
  1 +/*
  2 + * KT3 Calendar wrapper.
  3 + *
  4 + * use this with the following example code:
  5 +
  6 +<span class="kt_calendar_holder">
  7 + <strong class="kt_calendar_datetext">No Date Selected</strong>
  8 + <input type="hidden" name="my_var_name" class="kt_calendar_value" />
  9 + <input type="button" onclick="init_kt_calendar(this);">
  10 +</span>
  11 +
  12 + */
  13 +
  14 +function breadcrumbFind(elem, tagName) {
  15 + var stopTag = 'BODY';
  16 + var currentTag = elem.tagName;
  17 + var currentElem = elem;
  18 + while ((currentTag != stopTag) && (currentTag != tagName)) {
  19 + currentElem = currentElem.parentNode;
  20 + currentTag = currentElem.tagName;
  21 + }
  22 +
  23 + if (currentTag == tagName) {
  24 + return currentElem;
  25 + } else {
  26 + return null;
  27 + }
  28 +}
  29 +
  30 +function resolve_calendar_date(display, store, calendar, date) {
  31 + store.value = date;
  32 + display.innerHTML = date;
  33 + calendar.hide();
  34 +}
  35 +
  36 +function close_calendar_ev(calendar) { calendar.hide(); }
  37 +
  38 +function init_kt_calendar(source) {
  39 + var match = breadcrumbFind(source, 'SPAN');
  40 + if (match == null) {
  41 + alert('invalid target for calendar.');
  42 + }
  43 +
  44 + // if we have done this already:
  45 + if (typeof(match._kt3cal) != 'undefined') {
  46 + match._kt3cal.show();
  47 + } else {
  48 + // create the partial'd functions.
  49 + var dwL = getElementsByTagAndClassName(null, 'kt_calendar_datetext', match);
  50 + var sL = getElementsByTagAndClassName(null, 'kt_calendar_value', match);
  51 +
  52 + if ((dwL.length == 0) || (sL.length == 0)) {
  53 + return null; // fail out.
  54 + }
  55 +
  56 + var resolve = partial(resolve_calendar_date, dwL[0], sL[0]);
  57 +
  58 + var c = new Calendar(0, null, resolve, close_calendar_ev);
  59 + c.showsTime = true;
  60 + c.setDateFormat('%Y/%m/%d %H:%M');
  61 +
  62 + c.create();
  63 + c.showAtElement(source,'Bc'); // the button
  64 + c.show();
  65 + match._kt3cal = c;
  66 + }
  67 +}
  68 +
... ...
templates/ktcore/boolean_search.smarty
... ... @@ -6,6 +6,12 @@
6 6 {$context->oPage->requireJSResource("resources/js/taillog.js")}
7 7 {$context->oPage->requireJSResource("resources/js/constructed_search.js")}
8 8  
  9 +{$context->oPage->requireJSResource("resources/js/kt3calendar.js")}
  10 +{$context->oPage->requireJSResource("thirdpartyjs/jscalendar-1.0/calendar.js")}
  11 +{$context->oPage->requireJSResource("thirdpartyjs/jscalendar-1.0/lang/calendar-en.js")}
  12 +{$context->oPage->requireJSResource("thirdpartyjs/jscalendar-1.0/calendar-setup.js")}
  13 +{$context->oPage->requireCSSResource("thirdpartyjs/jscalendar-1.0/calendar-system.css")}
  14 +
9 15 {capture assign=sJS}
10 16 {literal}
11 17 function testStartup() {
... ...