function GetGroupDisplay($field, $value) { global $locale_info, $rpt_array, $tbl, $fields_type; for ($i = 0; $i < count($rpt_array['group_fields']) - 1; $i++){ $arr = $rpt_array['group_fields'][$i]; foreach ($rpt_array['totals'] as $fld){ if ($arr['name'] == fldname($fld)) { if (!is_wr_custom()) $ftype = WRGetFieldType($fld['table'] . "." . $fld['name']); else $ftype = $fields_type[$fld['name']]; if ($field == $arr['name']) { if ($arr['int_type'] == 0) { $prefix = ""; if (!is_wr_db()) $prefix = $rpt_array["tables"][0] . "_"; else $field = GoodFieldName($field); if ($rpt_array['totals'][$prefix . $field]['curr'] == "true") return str_format_currency($value); else return $value; } elseif (IsNumberType($ftype)) { $start = $value - ($value % $arr['int_type']); $end = $start + $arr['int_type']; $prefix = ""; if (!is_wr_db()) $prefix = $rpt_array["tables"][0] . "_"; else $field = GoodFieldName($field); if ($rpt_array['totals'][$prefix . $field]['curr'] == "true") return str_format_currency($start) . " - " . str_format_currency($end); else return $start . " - " . $end; } elseif (IsCharType($ftype)) { return substr($value, 0, $arr['int_type']); } elseif (IsDateFieldType($ftype)) { $tm = db2time($value); if (!count($tm)) return ""; if ($arr['int_type'] == 1) { // DATE_INTERVAL_YEAR return $tm[0]; } elseif ($arr['int_type'] == 2) { // DATE_INTERVAL_QUARTER return $tm[0] . "/Q" . floor(($tm[1] - 1) / 4 + 1); } elseif ($arr['int_type'] == 3) { // DATE_INTERVAL_MONTH return @$locale_info["LOCALE_SABBREVMONTHNAME" . $tm[1]] . " " . $tm[0]; } elseif ($arr['int_type'] == 4) { // DATE_INTERVAL_WEEK $start = getweekstart($tm); $end = adddays($start, 6); return format_shortdate($start) . " - " . format_shortdate($end); } elseif ($arr['int_type'] == 5) { // DATE_INTERVAL_DAY return format_shortdate($tm); } elseif ($arr['int_type'] == 6) { // DATE_INTERVAL_HOUR $tm[4] = 0; $tm[5] = 0; return str_format_datetime($tm); } elseif ($arr['int_type'] == 7) { // DATE_INTERVAL_MINUTE $tm[5] = 0; return str_format_datetime($tm); } else { return str_format_datetime($tm); } } } } } } }
public function showDBValue(&$data, $keylink) { return format_shortdate(db2time($data[$this->field])); }
function getFieldName($fieldValue, $data) { global $locale_info; $value = $data[$this->_recordBasedRequest ? $this->_name : $this->_sqlname]; if ($value == null || !$value || strcasecmp($value, 'null') == 0) { return 'NULL'; } if ($this->_interval == 0) { if ($this->_viewFormat) { global $pageObject; return $pageObject->viewControls->showDBValue($this->_name, $data); } else { $date = db2time($value); return str_format_datetime($date); } } switch ($this->_interval) { case 1: $date = cached_db2time($value); return $date[0]; case 2: $date = cached_db2time($value); return $date[0] . '/Q' . intval($date[1] / 3); case 3: $date = cached_db2time($value); return @$locale_info["LOCALE_SABBREVMONTHNAME" . $date[1]] . " " . $date[0]; case 4: return cached_formatweekstart($value); case 5: $date = cached_db2time($value); return format_shortdate($date); case 6: $date = db2time($value); $date[4] = 0; $date[5] = 0; return str_format_datetime($date); case 7: $date = db2time($value); $date[5] = 0; return str_format_datetime($date); } }
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 .= ' <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 ? '' : " "; 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 .= ' <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); }
/** * Get axes displyed values * @param Number index * @param String value * @return String */ protected function getAxisDisplayValue($index, $value) { global $locale_info; if ($value == "" || is_null($value)) { return ""; } $groupFieldsData = $this->xml_array["group_fields"]; $field = $groupFieldsData[$index]["name"]; $int_type = $groupFieldsData[$index]["int_type"]; if ($this->fromWizard) { $control = $this->viewControls->getControl($field); } if ($int_type == 0) { // The 'Normal' interval is set if ($this->fromWizard) { $data = array($field => $value); return $control->showDBValue($data, ""); } if ($this->table_type != "db") { $fieldIdentifier = $this->xml_array["tables"][0] . "_" . $field; } else { $fieldIdentifier = $this->CrossGoodFieldName($field); } if ($this->xml_array['totals'][$fieldIdentifier]['curr'] == true) { return str_format_currency($value); } return xmlencode($value); } $ftype = $this->getFieldType($field); if (IsNumberType($ftype)) { $start = $value - $value % $int_type; $end = $start + $int_type; if ($this->fromWizard) { $dataStart = array($field => $start); $dataEnd = array($field => $end); return $control->showDBValue($dataStart, "") . " - " . $control->showDBValue($dataEnd, ""); } if ($this->table_type != "db") { $fieldIdentifier = $this->xml_array["tables"][0] . "_" . $field; } else { $fieldIdentifier = $this->CrossGoodFieldName($field); } if ($this->xml_array['totals'][$fieldIdentifier]['curr'] == true) { return str_format_currency($start) . " - " . str_format_currency($end); } return $start . " - " . $end; } if (IsCharType($ftype)) { return xmlencode(substr($value, 0, $int_type)); } if (IsDateFieldType($ftype)) { $dvalue = substr($value, 0, 4) . '-' . substr($value, 4, 2) . '-' . substr($value, 6, 2); if (strlen($value) == 10) { $dvalue .= " " . substr($value, 8, 2) . "00:00"; } elseif (strlen($value) == 12) { $dvalue .= " " . substr($value, 8, 2) . ":" . substr($value, 10, 2) . ":00"; } $tm = db2time($dvalue); if (!count($tm)) { return ""; } switch ($int_type) { case 1: // DATE_INTERVAL_YEAR return $tm[0]; case 2: // DATE_INTERVAL_QUARTER return $tm[0] . "/Q" . $tm[1]; case 3: // DATE_INTERVAL_MONTH return @$locale_info["LOCALE_SABBREVMONTHNAME" . $tm[1]] . " " . $tm[0]; case 4: // DATE_INTERVAL_WEEK $dates = $this->getDatesByWeek($tm[1] + 1, $tm[0]); return format_shortdate(db2time($dates[0])) . ' - ' . format_shortdate(db2time($dates[1])); case 5: // DATE_INTERVAL_DAY return format_shortdate($tm); case 6: // DATE_INTERVAL_HOUR $tm[4] = 0; $tm[5] = 0; return str_format_datetime($tm); case 7: // DATE_INTERVAL_MINUTE $tm[5] = 0; return str_format_datetime($tm); default: return str_format_datetime($tm); } } return ""; }
function getDisplayValue($index, $value) { global $locale_info; $field = $this->xml_array["group_fields"][$index]["name"]; if ($value == "" || is_null($value)) { return ""; } $ftype = $this->getFieldType($field); $arr = array(); $arr = $this->xml_array["group_fields"]; for ($i = 0; $i < count($arr) - 1; $i++) { if ($field == $arr[$i]["name"] && $index == $i) { $int_type = $arr[$i]["int_type"]; break; } } if ($int_type == 0) { $prefix = ""; if ($this->table_type != "db") { if (!$this->fromWizard) { $prefix = $this->xml_array["tables"][0] . "_"; } } else { $field = $this->CrossGoodFieldName($field); } if ($this->xml_array['totals'][$prefix . $field]['curr'] == true) { return str_format_currency($value); } else { return $value; } } elseif (IsNumberType($ftype)) { $start = $value - $value % $int_type; $end = $start + $int_type; $prefix = ""; if ($this->table_type != "db") { if (!$this->fromWizard) { $prefix = $this->xml_array["tables"][0] . "_"; } } else { $field = $this->CrossGoodFieldName($field); } if ($this->xml_array['totals'][$prefix . $field]['curr'] == true) { return str_format_currency($start) . " - " . str_format_currency($end); } else { return $start . " - " . $end; } } elseif (IsCharType($ftype)) { return substr($value, 0, $int_type); } elseif (IsDateFieldType($ftype)) { $dvalue = substr($value, 0, 4) . '-' . substr($value, 4, 2) . '-' . substr($value, 6, 2); if (strlen($value) == 10) { $dvalue .= " " . substr($value, 8, 2) . "00:00"; } elseif (strlen($value) == 12) { $dvalue .= " " . substr($value, 8, 2) . ":" . substr($value, 10, 2) . ":00"; } $tm = db2time($dvalue); if (!count($tm)) { return ""; } if ($int_type == 1) { // DATE_INTERVAL_YEAR return $tm[0]; } elseif ($int_type == 2) { // DATE_INTERVAL_QUARTER return $tm[0] . "/Q" . $tm[1]; } elseif ($int_type == 3) { // DATE_INTERVAL_MONTH return @$locale_info["LOCALE_SABBREVMONTHNAME" . $tm[1]] . " " . $tm[0]; } elseif ($int_type == 4) { // DATE_INTERVAL_WEEK $dates = $this->getDatesByWeek($tm[1] + 1, $tm[0]); return format_shortdate(db2time($dates[0])) . ' - ' . format_shortdate(db2time($dates[1])); } elseif ($int_type == 5) { // DATE_INTERVAL_DAY return format_shortdate($tm); } elseif ($int_type == 6) { // DATE_INTERVAL_HOUR $tm[4] = 0; $tm[5] = 0; return str_format_datetime($tm); } elseif ($int_type == 7) { // DATE_INTERVAL_MINUTE $tm[5] = 0; return str_format_datetime($tm); } else { return str_format_datetime($tm); } } }
/** * Get the step-rounded date/date-time formatted string * @param String value * @param Boolean isLower * @return String */ protected function getRoundedDate($value, $isLower, $isKnob = false) { //array(year,month,day,hour,minute,second) $dateArray = $this->getDateTimeArray($value); switch ($this->stepType) { case FSST_SECONDS: if ($isKnob) { return $this->getDateTimeString($dateArray); } $prepDateArray = $this->minDateArray; $diffSec = $this->getDifferenceInSecWithMin($value, $isLower); $prepDateArray = addSeconds($prepDateArray, $diffSec); return $this->getDateTimeString($prepDateArray); case FSST_MINUTES: if ($isKnob) { return $this->getDateTimeString($dateArray); } $prepDateArray = $this->minDateArray; $diffSec = $this->getDifferenceInSecWithMin($value, $isLower); $minutes = floor($diffSec / 60); $prepDateArray = addMinutes($prepDateArray, $minutes); return $this->getDateTimeString($prepDateArray); case FSST_HOURS: $hours = $this->getAdjustedHoursValue($dateArray[3], $dateArray[4], $isLower); $dateArray[3] = $dateArray[4] = $dateArray[5] = 0; $dateArray = addHours($dateArray, $hours); return $this->getDateTimeString($dateArray); case FSST_DAYS: return format_shortdate($dateArray); case FSST_MONTHS: if ($isKnob) { return format_shortdate($dateArray); } $dateArray[1] = $this->getAdjustedMonthNumber($dateArray[1], $isLower); $dateArray[2] = $isLower ? 1 : getLastMonthDayNumber($dateArray[0], $dateArray[1]); $dateArray[3] = $dateArray[4] = $dateArray[5] = 0; return format_shortdate($dateArray); case FSST_YEARS: $dateArray[3] = $dateArray[4] = $dateArray[5] = 0; $dateArray[1] = $isLower ? 1 : 12; $dateArray[2] = $isLower ? 1 : 31; return format_shortdate($dateArray); default: return $value; } }
function GetDateEdit($field, $value, $type, $fieldNum = 0, $search = MODE_EDIT, $record_id = "", &$pageObj) { global $cYearRadius, $locale_info, $jscode, $strTableName; $is508 = isEnableSection508(); $strLabel = Label($field); $cfieldname = GoodFieldName($field); $cfield = "value_" . GoodFieldName($field) . '_' . $record_id; if ($fieldNum) { $cfield = "value" . $fieldNum . "_" . GoodFieldName($field) . '_' . $record_id; } $tvalue = $value; $time = db2time($tvalue); if (!count($time)) { $time = array(0, 0, 0, 0, 0, 0); } $dp = 0; switch ($type) { 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"; $sundayfirst = "false"; } else { if ($locale_info["LOCALE_IDATE"] == 0) { $fmt = "MM" . $locale_info["LOCALE_SDATE"] . "dd" . $locale_info["LOCALE_SDATE"] . "yyyy"; $sundayfirst = "true"; } else { $fmt = "yyyy" . $locale_info["LOCALE_SDATE"] . "MM" . $locale_info["LOCALE_SDATE"] . "dd"; $sundayfirst = "false"; } } if ($time[5]) { $fmt .= " HH:mm:ss"; } else { if ($time[3] || $time[4]) { $fmt .= " HH:mm"; } } if ($time[0]) { $ovalue = format_datetime_custom($time, $fmt); } $ovalue1 = $time[2] . "-" . $time[1] . "-" . $time[0]; $showtime = "false"; if (DateEditShowTime($field)) { $showtime = "true"; $ovalue1 .= " " . $time[3] . ":" . $time[4] . ":" . $time[5]; } // need to create date control object to use it with datePicker $ret = '<input id="' . $cfield . '" type="Text" name="' . $cfield . '" size="20" value="' . $ovalue . '">'; $ret .= '<input id="ts' . $cfield . '" type="Hidden" name="ts' . $cfield . '" value="' . $ovalue1 . '"> '; //$ret.=' <img src="images/cal.gif" width=16 height=16 border=0 alt="'."Click Here to Pick up the date".'">'; $ret .= ' <a href="#" id="imgCal_' . $cfield . '">' . '<img src="images/cal.gif" width=16 height=16 border=0 alt="' . "Click Here to Pick up the date" . '"></a>'; echo $ret; return; case EDIT_DATE_DD_DP: $dp = 1; case EDIT_DATE_DD: $retday = '<select id="day' . $cfield . '" ' . (($search == MODE_INLINE_EDIT || $search == MODE_INLINE_ADD) && $is508 == true ? 'alt="' . $strLabel . '" ' : '') . 'name="day' . $cfield . '" ></select>'; $retmonth = '<select id="month' . $cfield . '" ' . (($search == MODE_INLINE_EDIT || $search == MODE_INLINE_ADD) && $is508 == true ? 'alt="' . $strLabel . '" ' : '') . 'name="month' . $cfield . '" ></select>'; $retyear = '<select id="year' . $cfield . '" ' . (($search == MODE_INLINE_EDIT || $search == MODE_INLINE_ADD) && $is508 == true ? 'alt="' . $strLabel . '" ' : '') . 'name="year' . $cfield . '" ></select>'; $sundayfirst = "false"; if ($locale_info["LOCALE_ILONGDATE"] == 1) { $ret = $retday . " " . $retmonth . " " . $retyear; } else { if ($locale_info["LOCALE_ILONGDATE"] == 0) { $ret = $retmonth . " " . $retday . " " . $retyear; $sundayfirst = "true"; } else { $ret = $retyear . " " . $retmonth . " " . $retday; } } if ($time[0] && $time[1] && $time[2]) { $ret .= "<input id=\"" . $cfield . "\" type=hidden name=\"" . $cfield . "\" value=\"" . $time[0] . "-" . $time[1] . "-" . $time[2] . "\">"; } else { $ret .= "<input id=\"" . $cfield . "\" type=hidden name=\"" . $cfield . "\" value=\"\">"; } // calendar handling for three DD if ($dp) { $ret .= ' <a href="#" id="imgCal_' . $cfield . '">' . '<img src="images/cal.gif" width=16 height=16 border=0 alt="Click Here to Pick up the date"></a>' . '<input id="ts' . $cfield . '" type=hidden name="ts' . $cfield . '" value="' . $time[2] . '-' . $time[1] . '-' . $time[0] . '">'; //$ret.=' <img src="images/cal.gif" width=16 height=16 border=0 alt="Click Here to Pick up the date"><input id="ts'.$cfield.'" type=hidden name="ts'.$cfield.'" value="'.$time[2].'-'.$time[1].'-'.$time[0].'">'; } echo $ret; return; // case EDIT_DATE_SIMPLE: // case EDIT_DATE_SIMPLE: default: $ovalue = $value; if ($time[0]) { if ($time[3] || $time[4] || $time[5]) { $ovalue = str_format_datetime($time); } else { $ovalue = format_shortdate($time); } } echo '<input id="' . $cfield . '" type=text name="' . $cfield . '" size="20" value="' . htmlspecialchars($ovalue) . '">'; return; } }
/** * @param &Array data * @return String */ public function getTextValue(&$data) { return format_shortdate(db2time($data[$this->field])); }