@@ -37,14 +37,20 @@ public function toHtml()
37
37
$ value = api_format_date ($ value , DATE_TIME_FORMAT_LONG_24H );
38
38
}
39
39
40
- return $ this -> getElementJS () . '
40
+ return '
41
41
<div class="input-group">
42
42
<span class="input-group-addon">
43
43
<input ' . $ this ->_getAttrString ($ this ->_attributes ) . '>
44
44
</span>
45
45
<input class="form-control" type="text" readonly id=" ' . $ id . '_alt" value=" ' . $ value . '">
46
+ <span class="input-group-btn">
47
+ <button class="btn btn-default" type="button">
48
+ <span class="fa fa-times text-danger" aria-hidden="true"></span>
49
+ <span class="sr-only"> ' . get_lang ('Reset ' ) . '</span>
50
+ </button>
51
+ </span>
46
52
</div>
47
- ' ;
53
+ ' . $ this -> getElementJS () ;
48
54
}
49
55
50
56
/**
@@ -71,22 +77,35 @@ private function getElementJS()
71
77
//timeFormat: 'hh:mm'
72
78
$ js .= "<script>
73
79
$(function() {
74
- $('# $ id').hide().datetimepicker({
75
- defaultDate: ' " . $ this ->getValue () . "',
76
- dateFormat: 'yy-mm-dd',
77
- timeFormat: 'HH:mm',
78
- altField: '# {$ id }_alt',
79
- altFormat: \"" . get_lang ('DateFormatLongNoDayJS ' ) . "\",
80
- altTimeFormat: \"" . get_lang ('TimeFormatNoSecJS ' ) . "\",
81
- altSeparator: \" " . get_lang ('AtTime ' ) . " \",
82
- altFieldTimeOnly: false,
83
- showOn: 'both',
84
- buttonImage: ' " . Display::return_icon ('attendance.png ' , null , [], ICON_SIZE_TINY , true , true ) . "',
85
- buttonImageOnly: true,
86
- buttonText: ' " . get_lang ('SelectDate ' ) . "',
87
- changeMonth: true,
88
- changeYear: true
89
- });
80
+ var txtDateTime = $('# $ id'),
81
+ inputGroup = txtDateTime.parents('.input-group');
82
+
83
+ txtDateTime
84
+ .hide()
85
+ .datetimepicker({
86
+ defaultDate: ' " . $ this ->getValue () . "',
87
+ dateFormat: 'yy-mm-dd',
88
+ timeFormat: 'HH:mm',
89
+ altField: '# {$ id }_alt',
90
+ altFormat: \"" . get_lang ('DateFormatLongNoDayJS ' ) . "\",
91
+ altTimeFormat: \"" . get_lang ('TimeFormatNoSecJS ' ) . "\",
92
+ altSeparator: \" " . get_lang ('AtTime ' ) . " \",
93
+ altFieldTimeOnly: false,
94
+ showOn: 'both',
95
+ buttonImage: ' " . Display::return_icon ('attendance.png ' , null , [], ICON_SIZE_TINY , true , true ) . "',
96
+ buttonImageOnly: true,
97
+ buttonText: ' " . get_lang ('SelectDate ' ) . "',
98
+ changeMonth: true,
99
+ changeYear: true
100
+ });
101
+
102
+ inputGroup
103
+ .find('button')
104
+ .on('click', function (e) {
105
+ e.preventDefault();
106
+
107
+ $('# $ id, # {$ id }_alt').val('');
108
+ });
90
109
});
91
110
</script> " ;
92
111
0 commit comments