Support mask specific insert functions
[misc/kostenrechnung] / ajax / ricoXMLquery.php
1 <?php\r
2 \r
3 require_once('../init.php');\r
4 \r
5 header("Cache-Control: no-cache");\r
6 header("Pragma: no-cache");\r
7 header("Expires: ".gmdate("D, d M Y H:i:s",time()+(-1*60))." GMT");\r
8 header("Content-type: text/xml");\r
9 echo "<?xml version='1.0' encoding='UTF-8'?".">\n";\r
10 \r
11 require_once('../lib/dbase.php');\r
12 require_once('../lib/dbClass.php');\r
13 require_once('../lib/rico/ricoXmlResponse.php');\r
14 \r
15 $id=isset($_GET["id"]) ? $_GET["id"] : "";\r
16 $offset=isset($_GET["offset"]) ? $_GET["offset"] : "0";\r
17 $size=isset($_GET["page_size"]) ? $_GET["page_size"] : "";\r
18 $total=isset($_GET["get_total"]) ? strtolower($_GET["get_total"]) : "false";\r
19 $distinct=isset($_GET["distinct"]) ? $_GET["distinct"] : "";\r
20 \r
21 echo "\n<ajax-response><response type='object' id='".$id."_updater'>";\r
22 if (empty($id)) {\r
23   ErrorResponse("No ID provided!");\r
24 } elseif ($distinct=="" && !is_numeric($offset)) {\r
25   ErrorResponse("Invalid offset!");\r
26 } elseif ($distinct=="" && !is_numeric($size)) {\r
27   ErrorResponse("Invalid size!");\r
28 } elseif ($distinct!="" && !is_numeric($distinct)) {\r
29   ErrorResponse("Invalid distinct parameter!");\r
30 } elseif (!isset($_SESSION[$id])) {\r
31   ErrorResponse("Your connection with the server was idle for too long and timed out. Please refresh this page and try again.");\r
32 } elseif (!OpenDB()) {\r
33   ErrorResponse(htmlspecialchars($oDB->LastErrorMsg));\r
34 } else {\r
35   $fname = substr($id,5);\r
36   load_mask($fname);\r
37   grid_sql($fname, $mask);\r
38 \r
39   $filters=isset($_SESSION[$id . ".filters"]) ? $_SESSION[$id . ".filters"] : array();\r
40   $oDB->DisplayErrors=false;\r
41   $oDB->ErrMsgFmt="MULTILINE";\r
42   $oXmlResp= new ricoXmlResponse();\r
43   $oXmlResp->sendDebugMsgs=true;\r
44   $oXmlResp->convertCharSet=false;  // Database is already in UTF-8\r
45   if ($distinct=="") {\r
46     $oXmlResp->Query2xml($_SESSION[$id], intval($offset), intval($size), $total!="false", $filters);\r
47   } else {\r
48     $oXmlResp->Query2xmlDistinct($_SESSION[$id], intval($distinct), -1, $filters);\r
49   }\r
50   if (!empty($oDB->LastErrorMsg)) {\r
51     echo "\n<error>";\r
52     echo "\n".htmlspecialchars($oDB->LastErrorMsg);\r
53     echo "\n</error>";\r
54   }\r
55   $oXmlResp=NULL;\r
56   # CloseApp();\r
57 }\r
58 echo "\n</response></ajax-response>";\r
59 \r
60 \r
61 function ErrorResponse($msg) {\r
62   echo "\n<rows update_ui='false' /><error>" . $msg . "</error>";\r
63 }\r
64 \r
65 ?>\r