forked from kivitendo/kivitendo-crm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.phtml
243 lines (199 loc) · 7.56 KB
/
example.phtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<?php
require_once("inc/stdLib.php");
$menu = $_SESSION['menu'];
echo $menu['stylesheets'];
echo $menu['javascripts'];
echo $head['JQUERY'];
echo $head['JQUERYUI'];
echo $head['JQTABLE'];
echo $head['THEME'];
echo $head['JUI-DROPDOWN'];
echo $head['TRANSLATION'];
/*****************************************************************************************************************************
Grundsätze: Content wird via Ajax im Json-Format geholt und an die entsprechenden Container verteilt
Daten werden ohne Reload einfach via Ajax gespeichert.
Fürs Holen und Schreiben von Daten befindet sich unter jqhelp eine gleichnamige Datei mit der Extension ".php"
Auf das Benutzen der Variable $_SESSION sollte weitestgehend verzichtet werden.
Statt JS einzusetzen sollte auf die jQuery-Methoden zurückgegriffen werden.
Url-Parameter können mit $.urlParam( 'ParameterName' ) gelesen werden.
Beispiel automatische Übersetzung
******************************************************************************************************************************/
?>
<script type="text/javascript" src="lxcars/jQueryAddOns/date-time-picker.js"></script>
<script type="text/javascript" src="lxcars/jQueryAddOns/german-date-time-picker.js"></script>
<script>
$(document).ready(function() {
var language = kivi.myconfig.countrycode;
$( ".lang" ).each( function(){
var key = $( this ).attr( "data-lang" );
if( $( this ).is( ":input" ) ) $( this ).attr( 'title', typeof( langData[language][key] ) != 'undefined' ? langData[language][key] : 'LNG ERR' );
else $( this ).text( typeof( langData[language][key] ) != 'undefined' ? langData[language][key] : 'LNG ERR' );
});
$("#senddialog").dialog({
autoOpen: false,
width:400,
height:250,
minWidth:300,
minHeight:200,
maxWidth:800,
maxHeight:800,
buttons: [{
text: langData[language]['SAVE'],
id: 'saveButton',
click: function() {
saveData();
getData();
$(this).dialog('close');
}
},
{ text: langData[language]['CLOSE'],
click: function(){
$(this).dialog('close')
}
}]
});
$( "#newbtn" ).button().text(langData[language]['NEW']).click(function() {
$("#senddialog").dialog("open")
.html('<p> <form id="fsend">' +
'<table> <tr> <td><label >'+ langData[language]['BIRTHDAY'] +'</label></td>' +
'<td><input type="text" name="datetime" id="datetime"></td> </tr>' +
'<tr> <td><label>'+ langData[language]['NAME'] +'</label></td> <td><input type="text" name="name" id="name"></td> </tr>' +
'<tr> <td><label>'+ langData[language]['AGE'] +'</label></td> <td><input type="text" name="age" id="age"></td> </tr>' +
'<tr> <td><label>'+ langData[language]['COMMENTS'] +'</label></td> <td><input type="text" name="comments" id="comments"></td>' +
'</tr> </table> </form> </p>');
$("#datetime").datetimepicker({
//dateFormat: 'yy-mm-dd',
stepMinute: 5,
hour: 1,
hourMin: 6,
hourMax: 19,
//timeSuffix: ' Uhr',
timeSuffix: '',
timeText: 'Zeit',
hourText: 'Stunde',
closeText: 'fertig',
currentText: 'jetzt'
});
});
function drawTable(data) {
$("#tbody0").empty();
for (var i = 0; i < data.length; i++) {
drawRow(data[i]);
}
}
function drawRow( rowData ) {
var row = $("<tr>");
$("#tbody0").append(row);
row.append($("<td>" + rowData.id + "</td>"));
row.append($("<td>" + rowData.date_time + "</td>"));
row.append($("<td>" + rowData.c_name + "</td>"));
row.append($("<td>" + rowData.c_age + "</td>"));
row.append($("<td>" + rowData.c_comments + "</td></tr>"));
}
function getData() {
$.ajax({
dataType: 'json',
url: 'ajax/example.php?action=getData',
method: "GET",
success: function( json ) {
$("#tbody0").empty();
drawTable(json);
$("#showtable").trigger("update");
$("#showtable").trigger("appendCache");
},
error: function(){
alert("Holen der Daten fehlgeschlagen!");
}
})
}
function saveData() {
var obj = {};
var array = $('#fsend').serializeArray();
// Ein object aus dem array machen
$.each(array, function(index, item) {
obj[item.name] = item.value;
});
$.ajax({
data: { action: "newEntry", data: JSON.stringify(obj)},
dataType: 'json',
type: 'POST',
url: "ajax/example.php",
success: function(){
alert(langData[language]['SEND_SUCCESS']);
},
error: function(){
alert(langData[language]['SEND_ERROR'] + '. ' + langData[language]['NO_DATA'] + '?');
}
})
}
getData();
$("#showtable").tablesorter().tablesorterPager({
container: $("#pager"),
size: 9999
});
$(window).resize(function (){
$("#gdtable").css({
width: 'auto',
height: 'auto',
position: 'absolute',
marginLeft: 'auto',
marginTop: 'auto',
left: (($(window).width() - $('#showTable').outerWidth())/3),
overflow: 'auto'
});
});
$(window).resize();
// $("#searchButton").button().click(function () {
// $("#searchdialog").html('<table id="searchtable" width="100%" class="tablesorter">' +
// '<thead><tr><th>'+langData[language]["DATE"]+'</th>'+
// '<th width="150px">'+langData[language]["SUBJECT"]+'</th></tr></thead>'+
// '<tbody id="tbody0"><tr><td>14.04.1963 09:45</td><td>was Wichtiges</td></tr>'+
// '<tr><td>15.07.2016 08:00</td><td>nicht ganz unwichtig</td></tr></tbody><tfoot></tfoot></table>')
// .dialog({
// open: function () {
// $('#searchdialog table.tablesorter').tablesorter();
// },
// width: "auto"
// });
// });
});
</script>
<style>
.ui-menu { width: 180px; }
.tablesorter { width:auto; cursor:pointer; widgets: ['zebra']; sortList: [[0,0]];}
</style>
</head>
<body>
<?php
echo $menu['pre_content'];
echo $menu['start_content'];
?>
<?php echo $menu['end_content']; ?>
<p class="ui-state-highlight ui-corner-all tools lang" style="margin-top: 20px; padding: 0.6em;" data-lang="TESTFILE">Testfile</p>
<div id="senddialog" > </div>
<div id="gdtable" class="gdtable">
<table id="showtable" class="tablesorter" >
<thead>
<tr>
<th>ID</th>
<th data-lang='BIRTHDAY' class='lang'>Birthday</th>
<th data-lang='NAME' class='lang'>Name</th>
<th data-lang='AGE' class='lang'>Age</th>
<th data-lang='COMMENTS' class='lang'>Comments</th>
</tr>
</thead>
<tbody id="tbody0"></tbody>
<tfoot></tfoot>
</table>
<div id="pager"> <?php echo $head['JQTABLE-PAGER']; ?> </div>
</div>
<div id='newbtn'></div>
<!--<div id='searchButton'>Search</div>
<div id="searchdialog" title="Search Dialog"></div>
-->
</body>
</html>