-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.php
executable file
·78 lines (74 loc) · 2.45 KB
/
options.php
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
<?php
include "classes/db.php";
$table = filter_input(INPUT_GET, 'table');
$fields = filter_input(INPUT_GET, 'fields');
$orderby= filter_input(INPUT_GET, 'orderby');
$Folder = filter_input(INPUT_GET, 'Folder');
$Folder = (isset($Folder)) ? $Folder : 0;
if(empty($fields)){
$fields = "Id, Name";
}
if(empty($orderby)){
$orderby = "Name";
}
try
{
if(empty($table)){
$jTableResult = array();
$jTableResult['Result'] = "ERROR";
$jTableResult['Message'] = "Options: Не указана таблица для получения данных!";
print json_encode($jTableResult);
} else {
//Open database connection
$db = new db();
$where = '';
if($table == "ZzItem"){
$row[] = array(
"DisplayText" => "<<Значение не выбрано>>",
"Value" => 0
);
$where = "ISNULL(Folder,0) = $Folder AND Name<>'РезервныйШтрихкод'";
}
$q = $db->select($fields, $table, $where, "ORDER BY $orderby");
$rows = $q->all();
// //Open database connection
// $db = new db();
//
// //Get records from database "'".$value[Name]."'"
// $q = $db->select($fields, $table, "ISNULL(Folder,0) = $Folder", "ORDER BY $orderby");
// $rows = $q->all();
// if($table == "ZzItem"){
// $row[] = array(
// "DisplayText" => "<<Значение не выбрано>>",
// "Value" => 0
// );
// }
foreach ($rows as $key => $value) {
if($table == "SyPerson"){
$fio = $value[LastName]." ".$value[FirstName]." ".$value[MiddleName];
$DisplayText = $fio;
$Value = $value[PersonId];
} else {
$DisplayText = $value[Name];
$Value = $value[Id];
}
$row[] = array(
"DisplayText" => $DisplayText,
"Value" => $Value
);
}
$jTableResult = array();
$jTableResult['Result'] = "OK";
$jTableResult['Options'] = $row;
print json_encode($jTableResult);
}
}
catch(Exception $ex)
{
//Return error message
$jTableResult = array();
$jTableResult['Result'] = "ERROR";
$jTableResult['Message'] = $ex->getMessage();
print json_encode($jTableResult);
}
?>