From: Joey Schulze Date: Sat, 12 Dec 2009 14:50:35 +0000 (+0100) Subject: Add call edit functionality X-Git-Url: https://git.infodrom.org/?p=infodrom%2Fphone;a=commitdiff_plain;h=05d1bb257d5716fffeffe42b9c6edf3bdcbad40c;ds=sidebyside Add call edit functionality --- diff --git a/index.php b/index.php index 1e4362b..d37f4e6 100644 --- a/index.php +++ b/index.php @@ -13,6 +13,10 @@ if (!empty($_POST['func'])) { delete_call($_POST['dir'],$_POST['call']); } elseif ($_POST['func'] == 'callinfo') { $data = callinfo($_POST['dir'],$_POST['call']); + $data['dir'] = $_POST['dir']; + $data['call'] = $_POST['call']; + } elseif ($_POST['func'] == 'save') { + save_call(); } header('Content-type: application/json; charset=UTF-8'); echo json_encode($data); @@ -63,5 +67,20 @@ if (!empty($_POST['func'])) {

+
+

Edit message

+
+
+ 
+ + +Name

+Note

+ + +
+
+
+ diff --git a/phone.css b/phone.css index abbe1bd..4add06b 100644 --- a/phone.css +++ b/phone.css @@ -36,6 +36,15 @@ div.phonelist { margin-bottom: 3px; } +input { + border: 1px solid #aaaaaa; + background-color: #f6f6f6; + font-size: 10px; +} +input.button:hover { + background-color: #e0e0e0; +} + p.title { margin-top: 0px; border-bottom: 1px solid #bfbfbf; @@ -68,7 +77,7 @@ div.phonecall { border: 1px solid #bfbfbf; width: 200px; position: absolute; - left: 500px; + left: 600px; top: 5px; } div.phonecall p { @@ -81,3 +90,19 @@ iframe.phonecall { margin-left: 10px; border: 0; } + +div.editcall { + border: 1px solid #bfbfbf; + width: 210px; + position: absolute; + left: 350px; + top: 5px; +} +div.editcall p { + margin: 0; + padding-left: 3px; +} + +span#edit_status { + padding-left: 5px; +} diff --git a/phone.js b/phone.js index 9b5d51d..58e5371 100644 --- a/phone.js +++ b/phone.js @@ -1,6 +1,7 @@ var menu_list = { 'title': 'Calls', 'items': [{'name': 'Archive', 'callback': menu_list_archive}, + {'name': 'Edit', 'callback': menu_list_edit}, {'name': 'Delete', 'callback': menu_list_delete}, {'name': 'Cancel', 'type': 'hide'}] }; @@ -113,6 +114,24 @@ function play_message(event) event.originalTarget.className = ''; } +function save_callback(data) +{ + field = document.getElementById('edit_status'); + field.innerHTML = 'Call saved'; +} + +function save() +{ + var dir = document.getElementById('edit_dir'); + var call = document.getElementById('edit_call'); + var name = document.getElementById('edit_name'); + var note = document.getElementById('edit_note'); + var params = 'dir=' + dir.value + '&call=' + call.value; + params += '&name=' + name.value + '¬e=' + note.value; + + ajax_request('save', params, save_callback); +} + function list_context(e) { var menu = document.getElementById('menu_list'); @@ -135,6 +154,28 @@ function menu_list_archive_callback(data) fetch_archive(); } +function menu_list_edit_callback(data) +{ + var fields = ['name','note','dir','call']; + var field; + + for (var i=0; i < fields.length; i++) { + field = document.getElementById('edit_' + fields[i]); + field.value = data[fields[i]]; + } + + fields = ['name','note']; + for (var i=0; i < fields.length; i++) { + field = document.getElementById('edit_' + fields[i]); + field.innerHTML = data[fields[i]]; + } + + field = document.getElementById('edit_date'); + field.innerHTML = data.date + ', ' + data.length; + field = document.getElementById('edit_status'); + field.innerHTML = ''; +} + function menu_list_archive(e) { if (e.target.parentNode.payload['dir'] == 'incoming') @@ -143,6 +184,14 @@ function menu_list_archive(e) e.target.parentNode.style.display = 'none'; } +function menu_list_edit(e) +{ + var params = 'dir='+e.target.parentNode.payload['dir']+'&call='+e.target.parentNode.payload['call']; + ajax_request('callinfo', params, menu_list_edit_callback); + + e.target.parentNode.style.display = 'none'; +} + function menu_list_delete(e) { var params = 'dir='+e.target.parentNode.payload['dir']+'&call='+e.target.parentNode.payload['call']; diff --git a/phone.php b/phone.php index b2dbd6d..5f77ba9 100644 --- a/phone.php +++ b/phone.php @@ -4,7 +4,9 @@ define('SPOOL_DIR', '/var/spool/vbox/ttyI6'); function read_info($dir, $call) { $info = array(); - if (($f = fopen(SPOOL_DIR . '/' . $dir . '/' . $call . '.info', 'r')) !== false) { + $fname = SPOOL_DIR . '/' . $dir . '/' . $call . '.info'; + + if (is_file($fname) && ($f = fopen($fname, 'r')) !== false) { $line = fgets($f, 1024); fclose($f); $info = unserialize($line); @@ -141,4 +143,13 @@ function delete_call($dir, $call) unlink($basename . '.info'); } +function save_call() +{ + $info = read_info($_POST['dir'], $_POST['call']); + $info['name'] = $_POST['name']; + $info['note'] = $_POST['note']; + + error_log(var_export($info,true)); +} + ?>