forked from LibreHealthIO/lh-ehr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransactions.inc
49 lines (45 loc) · 1.52 KB
/
transactions.inc
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
<?php
require_once("{$GLOBALS['srcdir']}/sql.inc");
function getTransById ($id, $cols = "*")
{
$row = sqlQuery("SELECT $cols FROM transactions WHERE id = ?", array($id));
$fres = sqlStatement("SELECT field_id, field_value FROM lbt_data WHERE form_id = ?", array($id));
while ($frow = sqlFetchArray($fres)) {
$row[$frow['field_id']] = $frow['field_value'];
}
return $row;
}
function getTransByPid ($pid, $cols = "*")
{
$res = sqlStatement("select $cols from transactions where pid = ? " .
"order by date DESC", array($pid) );
for ($iter = 0; $row = sqlFetchArray($res); $iter++) {
$fres = sqlStatement("SELECT field_id, field_value FROM lbt_data WHERE form_id = ?",
array($row['id']));
while ($frow = sqlFetchArray($fres)) {
$row[$frow['field_id']] = $frow['field_value'];
}
$all[$iter] = $row;
}
return $all;
}
function newTransaction($pid, $body, $title, $authorized = "0",
$status = "1", $assigned_to = "*")
{
$body = add_escape_custom($body);
$id = sqlInsert("insert into transactions ( " .
"date, title, pid, user, groupname, authorized " .
") values ( " .
"NOW(), '$title', '$pid', '" . $_SESSION['authUser'] .
"', '" . $_SESSION['authProvider'] . "', '$authorized' " .
")");
sqlStatement("INSERT INTO lbt_data (form_id, field_id, field_value) VALUES (?, ?, ?)",
array($id, 'body', $body));
return $id;
}
function authorizeTransaction($id, $authorized = "1")
{
sqlQuery("update transactions set authorized = '$authorized' where " .
"id = '$id'");
}
?>