/**
  * A method that echos the HTML for this field.
  */
 function display()
 {
     $oStartDate = $this->getStartDate();
     $startDateStr = is_null($oStartDate) ? '' : $oStartDate->format('%Y-%m-%d');
     $oEndDate = $this->getEndDate();
     $endDateStr = is_null($oEndDate) ? '' : $oEndDate->format('%Y-%m-%d');
     echo "\n        <select name='{$this->_name}_preset' id='{$this->_name}_preset' onchange='{$this->_name}FormChange(" . ($this->_autoSubmit ? 1 : 0) . ")' tabindex='" . $this->_tabIndex++ . "'>";
     foreach ($this->_fieldSelectionNames as $v => $n) {
         $selected = $v == $this->_fieldSelectionValue ? " selected='selected'" : '';
         echo "\n            <option value='{$v}'{$selected}>{$n}</option>";
     }
     echo "\n        </select>\n        <label for='{$this->_name}_start' style='margin-left: 1em'> " . $this->oTrans->translate('From') . "</label>\n        <input class='date' name='{$this->_name}_start' id='{$this->_name}_start' type='text' value='{$startDateStr}' tabindex='" . $this->_tabIndex++ . "' />\n        <input type='image' src='" . OX::assetPath() . "/images/icon-calendar.gif' id='{$this->_name}_start_button' align='absmiddle' border='0' tabindex='" . $this->_tabIndex++ . "' />\n        <label for='{$this->_name}_end' style='margin-left: 1em'> " . $this->oTrans->translate('To') . "</label>\n        <input class='date' name='{$this->_name}_end' id='{$this->_name}_end' type='text' value='{$endDateStr}' tabindex='" . $this->_tabIndex++ . "' />\n        <input type='image' src='" . OX::assetPath() . "/images/icon-calendar.gif' id='{$this->_name}_end_button' align='absmiddle' border='0' tabindex='" . $this->_tabIndex++ . "' />\n        <script type='text/javascript'>\n        <!--\n        Calendar.setup({\n            inputField : '{$this->_name}_start',\n            ifFormat   : '%Y-%m-%d',\n            button     : '{$this->_name}_start_button',\n            align      : 'Bl',\n            weekNumbers: false,\n            firstDay   : " . ($GLOBALS['pref']['ui_week_start_day'] ? 1 : 0) . ",\n            electric   : false\n        })\n        Calendar.setup({\n            inputField : '{$this->_name}_end',\n            ifFormat   : '%Y-%m-%d',\n            button     : '{$this->_name}_end_button',\n            align      : 'Bl',\n            weekNumbers: false,\n            firstDay   : " . ($GLOBALS['pref']['ui_week_start_day'] ? 1 : 0) . ",\n            electric   : false\n        })\n        // Tabindex handling\n        {$this->_name}TabIndex = " . ($this->_tabIndex - 4) . ";\n        // Functions\n        function {$this->_name}Reset()\n        {\n            document.getElementById('{$this->_name}_start').value = '{$startDateStr}';\n            document.getElementById('{$this->_name}_start').value = '{$endDateStr}';\n            document.getElementById('{$this->_name}_preset').value = '{$this->_fieldSelectionValue}';\n        }\n        function {$this->_name}FormSubmit() {\n            submitForm();\n            return false;\n        }\n        function {$this->_name}FormChange(bAutoSubmit)\n        {\n            var o = document.getElementById('{$this->_name}_preset');\n            var {$this->_name}SelectName = o.options[o.selectedIndex].value;\n            var specific = {$this->_name}SelectName == 'specific';";
     $oTmpDaySpan = new OA_Admin_DaySpan();
     foreach ($this->_fieldSelectionNames as $v => $n) {
         if ($v != 'specific') {
             if ($v != 'all_events') {
                 $oTmpDaySpan->setSpanPresetValue($v);
                 $oTmpStartDate = $oTmpDaySpan->getStartDate();
                 $sTmpStartDate = $oTmpStartDate->format('%Y-%m-%d');
                 $oTmpEndDate = $oTmpDaySpan->getEndDate();
                 $sTmpEndDate = $oTmpEndDate->format('%Y-%m-%d');
             } else {
                 $sTmpStartDate = '';
                 $sTmpEndDate = '';
             }
             echo "\n            if ({$this->_name}SelectName == '{$v}') {\n                document.getElementById('{$this->_name}_start').value = '{$sTmpStartDate}';\n                document.getElementById('{$this->_name}_end').value = '{$sTmpEndDate}';\n            }\n                ";
         }
     }
     echo "\n\n            document.getElementById('{$this->_name}_start').readOnly = !specific;\n            document.getElementById('{$this->_name}_end').readOnly = !specific;\n\n            if (!specific) {\n                document.getElementById('{$this->_name}_start').style.backgroundColor = '#CCCCCC';\n                document.getElementById('{$this->_name}_end').style.backgroundColor = '#CCCCCC';\n                document.getElementById('{$this->_name}_start').tabIndex = null;\n                document.getElementById('{$this->_name}_start_button').tabIndex = null;\n                document.getElementById('{$this->_name}_end').tabIndex = null;\n                document.getElementById('{$this->_name}_end_button').tabIndex = null;\n            } else {\n                document.getElementById('{$this->_name}_start').style.backgroundColor = '#FFFFFF';\n                document.getElementById('{$this->_name}_end').style.backgroundColor = '#FFFFFF';\n                document.getElementById('{$this->_name}_start').tabIndex = {$this->_name}TabIndex;\n                document.getElementById('{$this->_name}_start_button').tabIndex = {$this->_name}TabIndex + 1;\n                document.getElementById('{$this->_name}_end').tabIndex = {$this->_name}TabIndex + 2;\n                document.getElementById('{$this->_name}_end_button').tabIndex = {$this->_name}TabIndex + 3;\n            }\n\n            document.getElementById('{$this->_name}_start_button').readOnly = !specific;\n            document.getElementById('{$this->_name}_end_button').readOnly = !specific;\n            document.getElementById('{$this->_name}_start_button').src = specific ? '" . OX::assetPath() . "/images/icon-calendar.gif' : '" . OX::assetPath() . "/images/icon-calendar-d.gif';\n            document.getElementById('{$this->_name}_end_button').src = specific ? '" . OX::assetPath() . "/images/icon-calendar.gif' : '" . OX::assetPath() . "/images/icon-calendar-d.gif';\n            document.getElementById('{$this->_name}_start_button').style.cursor = specific ? 'auto' : 'default';\n            document.getElementById('{$this->_name}_end_button').style.cursor = specific ? 'auto' : 'default';\n\n            if (!specific && bAutoSubmit) {\n                submitForm();\n            }\n        }\n        {$this->_name}FormChange(0);\n        //-->\n        </script>";
 }
 /**
  * A method to test the setSpanPresetValue() method.
  */
 function testSetSpanPresetValue()
 {
     $oDaySpan = new OA_Admin_DaySpan();
     $oDaySpan->oNowDate = new Date('2007-05-09');
     $oDaySpan->setSpanPresetValue('today');
     $this->assertEqual($oDaySpan->getStartDateString(), '2007-05-09');
     $this->assertEqual($oDaySpan->getEndDateString(), '2007-05-09');
     $oDaySpan->oNowDate = new Date('2007-05-10');
     $oDaySpan->setSpanPresetValue('today');
     $this->assertEqual($oDaySpan->getStartDateString(), '2007-05-10');
     $this->assertEqual($oDaySpan->getEndDateString(), '2007-05-10');
 }