3 require_once('../config.php');
4 require_once('../lib/general.php');
9 $sql = sprintf('SELECT id,%s FROM %s WHERE id = %d',
10 implode(',', array_keys($mask['edit'])),
11 $mask['table'], $_POST['id']);
13 $sth = pg_query($sql);
16 function details($mask)
18 if (empty($_POST['id']))
19 return array('error' => 'Missing ID');
21 $sql = sprintf('SELECT id,%s FROM %s WHERE id = %d',
22 implode(',', array_keys($mask['details']['list'])),
23 $mask['table'], $_POST['id']);
25 $sth = pg_query($sql);
28 return array('error' => pg_last_error(),
31 $row = pg_fetch_assoc($sth);
33 foreach ($mask['details']['list'] as $field => $info)
34 if (array_key_exists('format', $info))
35 $row[$field] = sprintf($info['format'], $row[$field]);
40 function format_ajax($data)
42 header('Content-type: application/json; charset=UTF-8');
43 echo json_encode($data);
47 if (empty($_POST['func']))
50 if (empty($_POST['mask']))
54 if (load_mask($_POST['mask'], '../') === false) exit;
56 $data = array('error' => 'Unknown function');
58 if ($_POST['func'] == 'fetch') {
60 } elseif ($_POST['func'] == 'details') {
61 $data = details($mask);
62 } elseif ($_POST['func'] == 'save') {