|
@@ -55,13 +55,120 @@ class DateTimePicker extends HTML_QuickForm_text
|
|
|
//timeFormat: 'hh:mm'
|
|
|
$js .= "<script>
|
|
|
$(function() {
|
|
|
- $('#$id').datetimepicker({
|
|
|
+ $('#$id').hide().datetimepicker({
|
|
|
+ defaultDate: '" . $this->getValue() . "',
|
|
|
dateFormat: 'yy-mm-dd',
|
|
|
- timeFormat: 'HH:mm'
|
|
|
+ timeFormat: 'HH:mm',
|
|
|
+ altField: '#{$id}_alt',
|
|
|
+ altFormat: \"" . get_lang('DateFormatLongNoDayJS') . "\",
|
|
|
+ altTimeFormat: \"" . get_lang('TimeFormatNoSecJS') . "\",
|
|
|
+ altSeparator: \" " . get_lang('AtTime') . " \",
|
|
|
+ altFieldTimeOnly: false,
|
|
|
+ showOn: 'both',
|
|
|
+ buttonImage: '" . Display::return_icon('attendance.png', null, [], ICON_SIZE_TINY, true, true) . "',
|
|
|
+ buttonImageOnly: true,
|
|
|
+ buttonText: '" . get_lang('SelectDate') . "'
|
|
|
});
|
|
|
});
|
|
|
</script>";
|
|
|
|
|
|
return $js;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param string $layout
|
|
|
+ *
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public function getTemplate($layout)
|
|
|
+ {
|
|
|
+ $size = $this->getColumnsSize();
|
|
|
+ $id = $this->getAttribute('id');
|
|
|
+ $value = $this->getValue();
|
|
|
+
|
|
|
+ if (empty($size)) {
|
|
|
+ $sizeTemp = $this->getInputSize();
|
|
|
+ if (empty($size)) {
|
|
|
+ $sizeTemp = 8;
|
|
|
+ }
|
|
|
+ $size = array(2, $sizeTemp, 2);
|
|
|
+ } else {
|
|
|
+ if (is_array($size)) {
|
|
|
+ if (count($size) != 3) {
|
|
|
+ $sizeTemp = $this->getInputSize();
|
|
|
+ if (empty($size)) {
|
|
|
+ $sizeTemp = 8;
|
|
|
+ }
|
|
|
+ $size = array(2, $sizeTemp, 2);
|
|
|
+ }
|
|
|
+ // else just keep the $size array as received
|
|
|
+ } else {
|
|
|
+ $size = array(2, intval($size), 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($value)) {
|
|
|
+ $value = api_format_date($value, DATE_TIME_FORMAT_LONG_24H);
|
|
|
+ }
|
|
|
+
|
|
|
+ switch ($layout) {
|
|
|
+ case FormValidator::LAYOUT_INLINE:
|
|
|
+ return '
|
|
|
+ <div class="form-group {error_class}">
|
|
|
+ <label {label-for} >
|
|
|
+ <!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
|
|
|
+ {label}
|
|
|
+ </label>
|
|
|
+
|
|
|
+ <div class="input-group">
|
|
|
+ <span class="input-group-addon">
|
|
|
+ {element}
|
|
|
+ </span>
|
|
|
+ <input class="form-control" type="text" readonly id="' . $id . '_alt" value="' . $value . '">
|
|
|
+ </div>
|
|
|
+ </div>';
|
|
|
+ break;
|
|
|
+ case FormValidator::LAYOUT_HORIZONTAL:
|
|
|
+ return '
|
|
|
+ <div class="form-group {error_class}">
|
|
|
+ <label {label-for} class="col-sm-'.$size[0].' control-label" >
|
|
|
+ <!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
|
|
|
+ {label}
|
|
|
+ </label>
|
|
|
+ <div class="col-sm-'.$size[1].'">
|
|
|
+ {icon}
|
|
|
+
|
|
|
+ <div class="input-group">
|
|
|
+ <span class="input-group-addon">
|
|
|
+ {element}
|
|
|
+ </span>
|
|
|
+ <input class="form-control" type="text" readonly id="' . $id . '_alt" value="' . $value . '">
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- BEGIN label_2 -->
|
|
|
+ <p class="help-block">{label_2}</p>
|
|
|
+ <!-- END label_2 -->
|
|
|
+
|
|
|
+ <!-- BEGIN error -->
|
|
|
+ <span class="help-inline">{error}</span>
|
|
|
+ <!-- END error -->
|
|
|
+ </div>
|
|
|
+ <div class="col-sm-'.$size[2].'">
|
|
|
+ <!-- BEGIN label_3 -->
|
|
|
+ {label_3}
|
|
|
+ <!-- END label_3 -->
|
|
|
+ </div>
|
|
|
+ </div>';
|
|
|
+ break;
|
|
|
+ case FormValidator::LAYOUT_BOX_NO_LABEL:
|
|
|
+ return '
|
|
|
+ <div class="input-group">
|
|
|
+ {icon}
|
|
|
+ {element}
|
|
|
+ <input class="form-control" type="text" readonly id="' . $id . '_alt" value="' . $value . '">
|
|
|
+ </div>';
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|