Example #1
0
 function buildControl($value, $mode, $fieldNum = 0, $validate, $additionalCtrlParams, $data)
 {
     if ($this->container->pageType == PAGE_LIST || $this->container->pageType == PAGE_SEARCH) {
         $value = prepare_for_db($this->field, $value, "time");
     }
     parent::buildControl($value, $mode, $fieldNum, $validate, $additionalCtrlParams, $data);
     echo '<input id="' . $this->ctype . '" ' . $this->inputStyle . ' type="hidden" name="' . $this->ctype . '" value="time">';
     $arr_number = parsenumbers((string) $value);
     if (count($arr_number) == 6) {
         $value = mysprintf("%d:%02d:%02d", array($arr_number[3], $arr_number[4], $arr_number[5]));
     }
     $timeAttrs = $this->pageObject->pSetEdit->getFormatTimeAttrs($this->field);
     if (count($timeAttrs)) {
         $input = '<input type="text" ' . $this->inputStyle . ' name="' . $this->cfield . '" ' . (($mode == MODE_INLINE_EDIT || $mode == MODE_INLINE_ADD) && $this->is508 == true ? 'alt="' . $this->strLabel . '" ' : '') . 'id="' . $this->cfield . '" ' . $this->pageObject->pSetEdit->getEditParams($this->field);
         if ($timeAttrs["useTimePicker"]) {
             $convention = $timeAttrs["hours"];
             $loc = getLacaleAmPmForTimePicker($convention, true);
             $tpVal = getValForTimePicker($this->type, $value, $loc['locale']);
             echo $input . ' value="' . htmlspecialchars($tpVal['val']) . '">';
             echo '&nbsp;';
             echo '<img class="runner-imgclock" src="images/clock.gif" alt="Time" border="0" style="margin:4px 0 0 6px; visibility: hidden;" id="trigger-test-' . $this->cfield . '" />';
         } else {
             echo $input . ' value="' . htmlspecialchars($value) . '">';
         }
     }
     $this->buildControlEnd($validate);
 }
Example #2
0
 function buildControl($value, $mode, $fieldNum, $validate, $additionalCtrlParams, $data)
 {
     global $locale_info;
     parent::buildControl($value, $mode, $fieldNum, $validate, $additionalCtrlParams, $data);
     if ($fieldNum) {
         $this->cfield = "value" . $fieldNum . "_" . GoodFieldName($this->field) . '_' . $this->id;
     }
     echo '<input id="' . $this->ctype . '" type="hidden" name="' . $this->ctype . '" value="date' . $this->pageObject->pSetEdit->getDateEditType($this->field) . '">';
     if ($this->pageObject->pageType == PAGE_LIST) {
         $pSet = new ProjectSettings($this->pageObject->tName, PAGE_SEARCH);
     } else {
         $pSet = $this->pageObject->pSetEdit;
     }
     $tvalue = $value;
     $time = db2time($tvalue);
     if (!count($time)) {
         $time = array(0, 0, 0, 0, 0, 0);
     }
     $dp = 0;
     $hasImgCal = true;
     $showTime = $pSet->dateEditShowTime($this->field);
     switch ($pSet->getDateEditType($this->field)) {
         case EDIT_DATE_SIMPLE_INLINE:
             $hasImgCal = false;
         case EDIT_DATE_SIMPLE_DP:
             $ovalue = $value;
             if ($locale_info["LOCALE_IDATE"] == 1) {
                 $fmt = "dd" . $locale_info["LOCALE_SDATE"] . "MM" . $locale_info["LOCALE_SDATE"] . "yyyy";
             } else {
                 if ($locale_info["LOCALE_IDATE"] == 0) {
                     $fmt = "MM" . $locale_info["LOCALE_SDATE"] . "dd" . $locale_info["LOCALE_SDATE"] . "yyyy";
                 } else {
                     $fmt = "yyyy" . $locale_info["LOCALE_SDATE"] . "MM" . $locale_info["LOCALE_SDATE"] . "dd";
                 }
             }
             if ($showTime || $time[3] || $time[4] || $time[5]) {
                 $fmt .= " HH:mm:ss";
             }
             if ($time[0]) {
                 $ovalue = format_datetime_custom($time, $fmt);
             }
             $ovalue1 = $time[2] . "-" . $time[1] . "-" . $time[0];
             if ($showTime || $time[3] || $time[4] || $time[5]) {
                 $ovalue1 .= " " . $time[3] . ":" . $time[4] . ":" . $time[5];
             }
             // need to create date control object to use it with datePicker
             $ret = '<input id="' . $this->cfield . '" ' . $this->inputStyle . ' type="Text" name="' . $this->cfield . '" value="' . $ovalue . '">';
             $ret .= '<input id="ts' . $this->cfield . '" type="Hidden" name="ts' . $this->cfield . '" value="' . $ovalue1 . '">';
             if ($hasImgCal) {
                 $ret .= '&nbsp;<a href="#" id="imgCal_' . $this->cfield . '" data-icon="calendar" title="Click Here to Pick up the date" ></a>';
             }
             echo $ret;
             break;
         case EDIT_DATE_DD_INLINE:
         case EDIT_DATE_DD_DP:
             $dp = 1;
         case EDIT_DATE_DD:
             $controlWidth = $pSet->getControlWidth($this->field);
             if ($controlWidth > 0) {
                 $controlWidth -= 10;
                 $yearWidth = floor($controlWidth * 0.3);
                 $yearStyle = 'style="min-width: ' . $yearWidth . 'px; ';
                 $dayWidth = floor($controlWidth * 0.2);
                 $dayStyle = 'style="min-width: ' . $dayWidth . 'px; margin-right:5px;" ';
                 $mothWidth = $controlWidth - $yearWidth - $dayWidth;
                 $monthStyle = 'style="min-width: ' . $mothWidth . 'px; margin-right:5px;" ';
             } else {
                 $dayStyle = '';
                 $monthStyle = '';
                 $yearStyle = '';
             }
             $alt = ($mode == MODE_INLINE_EDIT || $mode == MODE_INLINE_ADD) && $this->is508 ? 'alt="' . $this->strLabel . '" ' : '';
             $retday = '<select id="day' . $this->cfield . '" ' . $dayStyle . $alt . 'name="day' . $this->cfield . '" ></select>';
             $retmonth = '<select id="month' . $this->cfield . '" ' . $monthStyle . $alt . 'name="month' . $this->cfield . '" ></select>';
             $retyear = '<select id="year' . $this->cfield . '" ' . $yearStyle . $alt . 'name="year' . $this->cfield . '" ></select>';
             $space = $controlWidth > 0 ? '' : "&nbsp;";
             if ($locale_info["LOCALE_ILONGDATE"] == 1) {
                 $ret = $retday . $space . $retmonth . $space . $retyear;
             } else {
                 if ($locale_info["LOCALE_ILONGDATE"] == 0) {
                     $ret = $retmonth . $space . $retday . $space . $retyear;
                 } else {
                     $ret = $retyear . $space . $retmonth . $space . $retday;
                 }
             }
             if ($time[0] && $time[1] && $time[2]) {
                 $ret .= "<input id=\"" . $this->cfield . "\" type=hidden name=\"" . $this->cfield . "\" value=\"" . $time[0] . "-" . $time[1] . "-" . $time[2] . "\">";
             } else {
                 $ret .= "<input id=\"" . $this->cfield . "\" type=hidden name=\"" . $this->cfield . "\" value=\"\">";
             }
             // calendar handling for three DD
             if ($dp) {
                 $ret .= '&nbsp;<a href="#" id="imgCal_' . $this->cfield . '" data-icon="calendar" title="Click Here to Pick up the date"></a>' . '<input id="ts' . $this->cfield . '" type=hidden name="ts' . $this->cfield . '" value="' . $time[2] . '-' . $time[1] . '-' . $time[0] . '">';
             }
             echo $ret;
             break;
         default:
             //	case EDIT_DATE_SIMPLE:
             $ovalue = $value;
             if ($time[0]) {
                 if ($showTime || $time[3] || $time[4] || $time[5]) {
                     $ovalue = str_format_datetime($time);
                 } else {
                     $ovalue = format_shortdate($time);
                 }
             }
             echo '<input id="' . $this->cfield . '" type=text name="' . $this->cfield . '" ' . $this->inputStyle . ' value="' . runner_htmlspecialchars($ovalue) . '">';
     }
     $this->buildControlEnd($validate);
 }