-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson_protot.php
More file actions
56 lines (52 loc) · 1.61 KB
/
json_protot.php
File metadata and controls
56 lines (52 loc) · 1.61 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
<?php
/**
* Javascript-palvelu protojen listaamiseen
*
* @package SLS-Prototracker
* @license http://opensource.org/licenses/GPL-2.0
* @author Mauri "mos" Sahlberg
* @uses globals.php
* @uses database.php
* @uses protot.php
* @uses minrights.php
* */
require_once("globals.php");
require_once("$basepath/helpers/common.php");
require_once("$basepath/helpers/database.php");
require_once("$basepath/classes/protot.php");
require_once("$basepath/helpers/minrights.php");
$draw = isset($_REQUEST["draw"]) ? $_REQUEST["draw"] : false;
$start = isset($_REQUEST["start"]) ? $_REQUEST["start"] : 0;
$length = isset($_REQUEST["length"]) ? $_REQUEST["length"] : 10;
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : false;
$order = isset($_REQUEST["order"]) ? $_REQUEST["order"] : false;
$columns = isset($_REQUEST["columns"]) ? $_REQUEST["columns"] : false;
$a = array("id", "nimi", "omistaja", "luotu", "muokattu", "status" );
$p = new PROTOT($db);
$od=false;
if($order) {
$od="";
$first=true;
foreach($order as $o) {
if(isset($a[$o["column"]])) {
$od.=$first ? "" : ", ";
$od.=$a[$o["column"]]." ".$o["dir"];
$first=false;
}
}
}
$protot=$p->tableFetch($start, $length, $od, $search, $_SESSION["user"]["tunniste"]);
$jason = array("draw"=>$draw, "recordsTotal"=>$protot["lkm"], "recordsFiltered"=>$protot["filtered"]);
$data = array();
$i=0;
foreach($protot["protot"] as $rivi) {
$j=0;
foreach($a as $k=>$v) {
$data[$i][$j++]=$rivi[$v];
}
$i++;
}
$jason["data"]=$data;
header("Content-type: application/json");
echo json_encode($jason);
?>