-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetJSON.php
More file actions
62 lines (55 loc) · 1.23 KB
/
Copy pathgetJSON.php
File metadata and controls
62 lines (55 loc) · 1.23 KB
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
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET');
class column
{
public $field;
public $title;
public $width;
public $hidden;
function column($id, $caption)
{
$this->field = $id;
$this->title = $caption;
$this->width = "100px";
$this->hidden = false;
}
}
class customer
{
public $Id;
public $name;
public $addr;
public $phone;
}
$type = $_GET["type"];;
$page = isset($_POST['page']) ? intval($_POST['page']) : 0;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$start = $page * $rows + 1;
$last = $start + $rows;
$items = array();
for($i=$start;$i< $last;$i++){
$obj = new customer();
$obj->Id = $i;
$obj->name = "test".$i;
$obj->addr = "address - ".$i;
$obj->phone = "P".$i;
array_push($items, $obj);
}
$result["total"] = 30;
$result["rows"] = $items;
if($type == "init")
{
$columns = array();
$col = new column("Id", "code");
array_push($columns, $col);
$col = new column("name", "name");
array_push($columns, $col);
$col = new column("addr", "address");
array_push($columns, $col);
$col = new column("phone", "phone");
array_push($columns, $col);
$result["columns"] = $columns;
}
echo json_encode($result);
?>