-
Notifications
You must be signed in to change notification settings - Fork 8
/
get_form_data.php
103 lines (94 loc) · 3.26 KB
/
get_form_data.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
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
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include "chech_restricted.php";
require "settings/database.class.php";
if(isset($_POST['form_id'])){
$form_id = $_POST["form_id"];
$db_mntly = new Database("formbuilder");
$conn = $db_mntly->getConnection();
$sql = "SELECT * FROM form_list WHERE indx=$form_id";
if($result = $conn->query($sql)) {
$count = mysqli_num_rows($result);
if($count > 0){
$params_row = array();
while($row = mysqli_fetch_assoc($result)){
//$params_row['form_nik'] = $row['form_id'] ;
$params_row['frm_name'] = $row['form_name'];
$params_row['frm_title'] = $row["form_title"];
$params_row['restrict_submissions'] = $row["amount_form_submission"];
$params_row['publ_type'] = $row["publish_type"];
$params_row['publ_type_name'] = getPublishTypes($conn,$row["publish_type"]);
$params_row['publ_grps'] = $row["publish_groups"];//getGroupsObj($conn,$form_id,$row["publish_groups"]);
$params_row['publ_deps'] = $row["publish_deps"];//getGroupsObj($conn,$form_id,$row["publish_groups"]);
$params_row['publ_status'] = $row["publish_status"];
$params_row['admin_users'] = $row["admin_users"];
$params_row['frm_note'] = $row["form_note"];
$params_row['frm_style'] = $row["form_genral_style"];
}
$data_obj = new stdClass();
$data_obj->status = 1;
$data_obj->data = $params_row;
echo json_encode($data_obj);
}else{
echo '{
"status": 0,
"data": [
]
}';
}
}else {
echo '{
"status": 0,
"data": [
]
}';
}
}else{
echo '{
"status": 0,
"data": [
]
}';
}
function getGroupsObj($conn,$form_id,$grops){
if($grops != ""){
$gropsAry = explode(",",$grops);
$itemResultsAry = array();
foreach($gropsAry as $gropId){
$sql = "SELECT * FROM users_gropes WHERE indx=$gropId";
if($result = $conn->query($sql)) {
$count = mysqli_num_rows($result);
if($count > 0){
while($row = mysqli_fetch_assoc($result)){
$data_obj = new stdClass();
$data_obj->id = $gropId;
$data_obj->text = $row['group_name'];
$itemResultsAry[] = $data_obj;
}
return json_encode($itemResultsAry);
}else{
return "";
}
}else{
return "";
}
}
}else{
return "";
}
}
function getPublishTypes($conn,$publish_type_id){
$sql = "SELECT name FROM publish_type WHERE id=$publish_type_id";
$typName = "";
if($result = $conn->query($sql)) {
$count = mysqli_num_rows($result);
if($count > 0){
$row = mysqli_fetch_assoc($result);
$typName = $row['name'];
}
}
return $typName;
}
?>