-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdefaults.phtml
147 lines (131 loc) · 8.49 KB
/
defaults.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<?php
require_once( __DIR__.'/inc/stdLib.php' );
$menu = $_SESSION['menu'];
echo $menu['stylesheets'];
echo $menu['javascripts'];
echo $head['THEME'];
echo $head['T8'];
?>
<script>
$( document ).ready( function(){
const data = [ //If you would like to add a new setting or heading, just create a new line.
{ "name": "externDatabase","label": "Extern Database", "type": "headline" }, //headline
{ "name": "GEODB", "label": "Geo Database:", "type": "checkbox", "tooltip": "depracted" }, //checkbox
{ "name": "BLZDB", "label": "BLZ Database:", "type": "checkbox", "tooltip": "depracted"},
{ "name": "contacthread", "label": "Contac thread", "type": "headline" },
{ "name": "CallEdit", "label": "Call edit:", "type": "checkbox", "tooltip": "Tooltip" },
{ "name": "email", "label": "Email", "type": "headline" },
{ "name": "MailFlag", "label": "Mail Flag:", "type": "select", "data":["flagged", "Answered", "Seen", "Deleted", "Draft"], "tooltip":"depracted"}, //selectbox
{ "name": "Expunge", "label": "Expunge:", "type": "checkbox", "tooltip": "Tooltip" },
{ "name": "logmail", "label": "Log mail:", "type": "checkbox", "tooltip": "Tooltip" },
{ "name": "Maps", "label": "Maps", "type": "headline" },
{ "name": "streetview_man", "label": "Streetview:", "type": "input", "size": "100", "tooltip": "Tooltip" }, //input
{ "name": "planspace_man", "label": "Planspace:", "type": "input", "size": "1", "tooltip": "Tooltip" },
{ "name": "user-friendly links", "label": "User-friendly links", "type": "headline" },
{ "name": "dir_group", "label": "Group:", "type": "input", "size": "6", "tooltip": "Tooltip" },
{ "name": "dir_mode", "label": "Mode:", "type": "input", "size": "6", "tooltip": "Tooltip" },
{ "name": "misc", "label": "Misc", "type": "headline" },
{ "name": "listLimit", "label": "Listlimit:", "type": "input", "size": "1", "tooltip":"Maximum number of displayed items in a list" },
{ "name": "phoneintegration", "label": "Phoneintegration with Asterisk", "type": "headline" },
{ "name": "external_contexts", "label": "External Contexts:", "type": "input", "size": "60", "tooltip": "External Contexts, seperated by semicolon, read '/etc/asterisk/extensions.ael'" },
{ "name": "internal_phones", "label": "Internal Phones:", "type": "input", "size": "60", "tooltip": "Internal Phones, seperated by semicolon, read '/etc/asterisk/extensions.ael'" },
{ "name": "crmti_mobile_number", "label": "Handynummer:", "type": "input", "size": "60", "tooltip": "Der Name des contexes muss entweder Handy oder Mobile enthalten." },
{ "name": "ip_asterisk", "label": "IP adress Asterisk Server:", "type": "input", "size": "60", "tooltip": "mostly 127.0.0.1" },
{ "name": "asterisk_passwd", "label": "Asterisk Password:", "type": "password", "size": "60", "tooltip": "Passwd for ClicktoCall, read '/etc/asterisk/manager.conf'" },
{ "name": "payment", "label": "Payment with EC terminal", "type": "headline" },
{ "name": "ec_terminal_ip-adress", "label": "IP address:", "type": "input", "size": "13", "tooltip": "IP address of the ec terminal" },
{ "name": "ec_terminal_port", "label": "Port:", "type": "input", "size": "13", "tooltip": "Port of the ec terminal, e.g. 22000" },
{ "name": "ec_terminal_passwd", "label": "Terminal Password:", "type": "password", "size": "13", "tooltip": "Password of the ec terminal, Cashier password six digits, e.g. 012345" },
{ "name": "eletter", "label": "eLetter", "type": "headline" },
{ "name": "eletter_hostname", "label": "Ftp Hostname:", "type": "input", "size": "13", "tooltip": "hostname for ftp" },
{ "name": "eletter_username", "label": "Ftp Username:", "type": "input", "size": "13", "tooltip": "Username for Ftp" },
{ "name": "eletter_folder", "label": "Ftp Folder:", "type": "input", "size": "13", "tooltip": "Folder for eletter" },
{ "name": "eletter_passwd", "label": "Ftp Password:", "type": "password", "size": "13", "tooltip": "Password for Ftp" },
{ "name": "lxcars", "label": "Fahrzeugschein-Scanner", "type": "headline" },
{ "name": "lxcarsapi", "label": "FS-Scanner", "type": "input", "size": "60", "tooltip": "API Key für Fahrzeugschein-Scanner" },
{ "name": "aag-online", "label": "AAG-Online", "type": "headline" },
{ "name": "aag-online_user", "label": "AAG-Online User", "type": "input", "size": "60", "tooltip": "Benutzer für AAG-Online" },
{ "name": "aag-online_passwd", "label": "AAG-Online Password:", "type": "password", "size": "13", "tooltip": "Password for AAG-Online" },
];
var tabledata = '';
$.each( data, function( i, item ){
if( item.type == 'headline' ) tabledata += '<tr><td colspan="2"><b>' + kivi.t8( item.label ) + '</b></td></tr>';
if( item.type == 'checkbox' ) tabledata += '<tr><td>' + kivi.t8( item.label ) + '</td><td><input type="checkbox" id="' + item.name + '" name="'+ item.name + '" value="true" title="' + kivi.t8( item.tooltip ) + '"></input></td></tr>';
if( item.type == 'input' ) tabledata += '<tr><td>' + kivi.t8( item.label ) + '</td><td><input type="text" id="' + item.name + '" name="'+ item.name + '" size="' + item.size + '" title="' + kivi.t8( item.tooltip ) + '"></input></td></tr>';
if( item.type == 'password' ) tabledata += '<tr><td>' + kivi.t8( item.label ) + '</td><td><input type="password" id="' + item.name + '" name="'+ item.name + '" size="' + item.size + '" title="' + kivi.t8( item.tooltip ) + '"></input></td></tr>';
if( item.type == 'select' ){
tabledata += '<tr><td>' + kivi.t8( item.label ) + '</td><td><select type="select" id="' + item.name + '" name="'+ item.name + '" title="' + kivi.t8( item.tooltip ) + '">';
$.each( item.data, function( i, item ){ tabledata += '<option value="' + item + '">' + kivi.t8( item ) + '</option>'; } );
tabledata += '</select></input></td></tr>';
}
})
$( "#sitetable > tbody" ).append( tabledata );
$.ajax({
url: 'ajax/defaults.php',
type: 'POST',
data: { action: 'getDefaults' },
success: function ( data ){
//console.log( data );
$.each( data, function( i, item ){
console.log( item );
if( $( '#' + item.key ).attr('type') == 'checkbox' ) $( '#' + item.key ).prop('checked', item.val == 'true' || item.val == 't' ? true : false );
if( $( '#' + item.key ).attr('type') == 'text' ) $( '#' + item.key ).val( item.val );
if( $( '#' + item.key ).attr('type') == 'password' ) $( '#' + item.key ).val( item.val );
if( $( '#' + item.key ).attr('type') == 'select' ) $( '#' + item.key + ' option[value=' + item.val + ']').attr( 'selected', true );
})
},
error: function () {
alert( 'Error: getDefaults()!' )
}
});//ajax
$( '#head' ).text( kivi.t8( 'Default Configuration' ) );
$( "#save" ).button({
label: kivi.t8( 'save' )
}).css({
'margin':'5px'
}).click( function(){
var formdata = $( "#sitetable input,select" ).serializeArray();
$( '#sitetable input[type="checkbox"]:not(:checked)' ).each( function( i, e ){
formdata.push( { name: e.getAttribute( "name" ), value: false } ); //put unchecked boxes in array
});
const newArrayFormdata = formdata.map( ( { name: key, value: val, ...rest } ) => ( { key, val, ...rest } ) ); //name -> key, value -> val (colunmname in database)
$.ajax({
url: 'ajax/defaults.php',
type: 'POST',
data: { action: 'saveDefaults', data: newArrayFormdata },
success: function ( data ) {
//if( data ) alert( );
},
error: function () {
alert( 'Error: saveDefaults()!' );
}
})
}).attr( 'title', kivi.t8( "to save, press 'CTRL + s'" ) );//save button
// press STRG+S for save
$( window ).bind( 'keydown', function( event ){
if ( ( event.ctrlKey || event.metaKey ) && String.fromCharCode(event.which).toLowerCase() == 's' ){
$( "#save" ).click();
return false;
}
});
$( document ).tooltip( { position: { my: "center bottom-10", at: "center top" } } );
});
</script>
</head>
<body>
<?php
echo $menu['pre_content'];
echo $menu['start_content'];
?>
<p id="head" class="ui-state-highlight ui-corner-all tools" style="margin-top: 20px; padding: 0.6em;"></p>
<table id="sitetable">
<thead></thead>
<tbody></tbody>
</table>
<button id="save"></button>
<?php echo $menu['end_content']; ?>
</html>