format = EDIT_FORMAT_DATE; } function addJSFiles() { global $locale_info; $dateEditType = $this->getDateEditType(); if( $dateEditType == EDIT_DATE_SIMPLE_INLINE || $dateEditType == EDIT_DATE_DD_INLINE ) { $this->pageObject->AddJSFile("include/jquery-ui/jquery-ui.min.js"); } if ( $this->pageObject->getLayoutVersion() == BOOTSTRAP_LAYOUT ) { $this->pageObject->AddJSFile("include/bootstrap/js/moment.js", "include/bootstrap/js/bootstrap.min.js"); $this->pageObject->AddJSFile("include/bootstrap/js/bootstrap-datetimepicker.js", "include/bootstrap/js/moment.js"); } } function addCSSFiles() { $dateEditType = $this->getDateEditType(); if( $dateEditType == EDIT_DATE_SIMPLE_INLINE || $dateEditType == EDIT_DATE_DD_INLINE ) { $this->pageObject->AddCSSFile("include/jquery-ui/smoothness/jquery-ui.min.css"); $this->pageObject->AddCSSFile("include/jquery-ui/smoothness/jquery-ui.theme.min.css"); } if ( $this->pageObject->getLayoutVersion() == BOOTSTRAP_LAYOUT ) { $this->pageObject->AddCSSFile("include/bootstrap/css/bootstrap-datetimepicker.min.css"); } } function getProjectSettings() { if($this->pageObject->pageType == PAGE_LIST) return new ProjectSettings($this->pageObject->tName, PAGE_SEARCH); else return $this->pageObject->pSetEdit; } function getDateEditType( $pSet = null ) { if( !$pSet ) $pSet = $this->getProjectSettings(); $dateEditType = $pSet->getDateEditType($this->field); if( $this->pageObject->getLayoutVersion() == BOOTSTRAP_LAYOUT ) { // search panel control if( ( $this->pageObject->pageType == PAGE_LIST || $this->pageObject->pageType == PAGE_CHART || $this->pageObject->pageType == PAGE_REPORT) || $this->pageObject->pageType == PAGE_SEARCH && $this->pageObject->mode == SEARCH_LOAD_CONTROL) { if( $dateEditType == EDIT_DATE_DD ) return EDIT_DATE_SIMPLE; if( $dateEditType == EDIT_DATE_DD_DP ) return EDIT_DATE_SIMPLE_DP; if( $dateEditType == EDIT_DATE_DD_INLINE ) return EDIT_DATE_SIMPLE_INLINE; } } return $dateEditType; } 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; $pSet = $this->getProjectSettings(); $dateEditType = $this->getDateEditType( $pSet ); //if( $this->pageObject->pageType == PAGE_LIST ) // echo ''; $tvalue = $value; $time = db2time($tvalue); if(!count($time)) $time = array(0, 0, 0, 0, 0, 0); $classString = ''; if( $this->pageObject->getLayoutVersion() == BOOTSTRAP_LAYOUT ) $classString = ' form-control'; $dp = 0; $hasImgCal = true; $showTime = $pSet->dateEditShowTime($this->field); switch( $dateEditType ) { 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]){ $timeAttrs = $this->pageObject->pSetEdit->getFormatTimeAttrs($this->field); $fmt.= " " . $locale_info["LOCALE_STIMEFORMAT"]; } 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]; $ret= 'inputStyle.' class="'.$classString.'" type="Text" name="'.$this->cfield.'" value="'.$ovalue.'">'; $ret.= ''; if( $this->pageObject->getLayoutVersion() == BOOTSTRAP_LAYOUT ) $ret .= ''; elseif ( $hasImgCal ) $ret .= ''; if( $this->pageObject->getLayoutVersion() == BOOTSTRAP_LAYOUT ) { if ( isRTL() ) { $ret .= ""; // for bootstrap calend icon anomaly } $ret = '
' . $ret . '
'; } 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;margin-right:5px;" '; $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 = 'alt="'.$this->strLabel.'" '; // for init normal select width/ After load js, this options will clear $initMonthOpt = ""; if ( $time[1] ) { $months = getMountNames(); $initMonthOpt = ""; } $initMonthOpt .= ""; $initDayOpt = ""; $initYearOpt = ""; $retday=''; $retmonth=''; $retyear=''; $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; $setHiddenElem = 'type=hidden'; if ( $this->pageObject->getLayoutVersion() == BOOTSTRAP_LAYOUT ) { $setHiddenElem = 'class="'. $classString.' hiddenPickerElement"'; } if($time[0] && $time[1] && $time[2]) $ret.="cfield."\" ".$setHiddenElem." name=\"".$this->cfield."\" value=\"".$time[0]."-".$time[1]."-".$time[2]."\">"; else $ret.="cfield."\" ".$setHiddenElem." name=\"".$this->cfield."\" value=\"\">"; // calendar handling for three DD if($dp) { if( $this->pageObject->getLayoutVersion() == BOOTSTRAP_LAYOUT ) $ret .= ''; else { $ret .= ''; $ret .= ''; } } if( $this->pageObject->getLayoutVersion() == BOOTSTRAP_LAYOUT ) $ret = '' . $ret . ''; 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 'inputStyle.' value="'.runner_htmlspecialchars($ovalue).'">'; } $this->buildControlEnd($validate, $mode); } function getFirstElementId() { global $locale_info; $dateEditType = $this->getDateEditType(); if ( !$dateEditType ) { return $this->cfield; } switch( $dateEditType ) { case EDIT_DATE_DD: case EDIT_DATE_DD_INLINE: case EDIT_DATE_DD_DP: if($locale_info["LOCALE_ILONGDATE"] == 1) return "day".$this->cfield; else if($locale_info["LOCALE_ILONGDATE"] == 0) return "month".$this->cfield; else return "year".$this->cfield; break; default: return $this->cfield; break; } } function maxLengthMonth() { $maxLengthMonth = ""; $mounts = getMountNames(); $maxLenght = 0; for ( $i =0; $i < count($mounts); $i++ ) { $curMontn = $mounts[$i]; $curMonthLen = runner_strlen($curMontn); if ( $maxLenght < $curMonthLen ) { $maxLenght = $curMonthLen; $maxLengthMonth = $curMontn; } } return $maxLengthMonth; } } ?>