95eddbd1fe69ca160a6be413a9e775ebab995fc0
[infodrom/rico3] / examples / php / ex2xml.php
1 <?php\r
2 if (!isset ($_SESSION)) session_start();\r
3 ?>\r
4 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\r
5 <html>\r
6 <head>\r
7 <title>Rico LiveGrid-Example 2</title>\r
8 \r
9 <?php\r
10 require "dbConnect.php";\r
11 require "LoadRicoClient.php";\r
12 \r
13 session_set_cookie_params(60*60);\r
14 $sqltext="select OrderID,CustomerID,ShipName,ShipCity,ShipCountry,OrderDate,ShippedDate from orders order by OrderID";\r
15 if (isset($_GET["id"])) {\r
16   OpenDB(); // the addQuotes function requires a db connection when using MySQL\r
17   $id=trim($_GET["id"]);\r
18   if (strlen($id) == 5) $sqltext.=" where CustomerID=".$GLOBALS['oDB']->addQuotes($id);\r
19   CloseApp();\r
20 }\r
21 $_SESSION['ex2']=$sqltext;\r
22 ?>\r
23 <link href="../demo.css" type="text/css" rel="stylesheet" />\r
24 \r
25 <script type='text/javascript'>\r
26 var orderGrid,buffer;\r
27 \r
28 Rico.onLoad( function() {\r
29   var opts = {  \r
30     menuEvent     : 'click',\r
31     frozenColumns : 1,\r
32     highlightElem: 'cursorRow',\r
33     columnSpecs   : [,,,,,{type:'date'},{type:'date'}]\r
34   };\r
35   buffer=new Rico.Buffer.AjaxSQL('ricoQuery.php', {TimeOut:<?php print array_shift(session_get_cookie_params())/60 ?>});\r
36   orderGrid=new Rico.LiveGrid ('ex2', buffer, opts);\r
37   orderGrid.menu=new Rico.GridMenu({});\r
38 });\r
39 \r
40 </script>\r
41 \r
42 <style type="text/css">\r
43 div.ricoLG_cell {\r
44   white-space:nowrap;\r
45 }\r
46 </style>\r
47 </head>\r
48 \r
49 <body>\r
50 \r
51 <table id='explanation' border='0' cellpadding='0' cellspacing='5' style='clear:both'><tr valign='top'><td>\r
52 Base Library: \r
53 <script type='text/javascript'>\r
54 document.write(Rico.Lib+' '+Rico.LibVersion);\r
55 </script>\r
56 <hr>\r
57 This example uses AJAX to fetch order data, as required, from the server. \r
58 Notice how the number of visible rows is set automatically based\r
59 on the size of the window. Try the different grid styles that\r
60 are available. \r
61 Click on a cell to see available actions.\r
62 <a href='ricoQuery.php?id=ex2&offset=0&page_size=10&get_total=true'>View the AJAX response (XML)</a>.\r
63 </td>\r
64 <td>\r
65 <?php\r
66 require "info.php";\r
67 ?>\r
68 </td>\r
69 </tr></table>\r
70 \r
71 <p class="ricoBookmark"><span id='ex2_timer' class='ricoSessionTimer'></span><span id="ex2_bookmark">&nbsp;</span></p>\r
72 <table id="ex2" class="ricoLiveGrid" cellspacing="0" cellpadding="0">\r
73 <colgroup>\r
74 <col style='width:40px;' >\r
75 <col style='width:60px;' >\r
76 <col style='width:150px;'>\r
77 <col style='width:80px;' >\r
78 <col style='width:90px;' >\r
79 <col style='width:100px;'>\r
80 <col style='width:100px;'>\r
81 </colgroup>\r
82   <tr>\r
83           <th>Order#</th>\r
84           <th>Customer#</th>\r
85           <th>Ship Name</th>\r
86           <th>Ship City</th>\r
87           <th>Ship Country</th>\r
88           <th>Order Date</th>\r
89           <th>Ship Date</th>\r
90   </tr>\r
91 </table>\r
92 <!--\r
93 <textarea id='ex2_debugmsgs' rows='5' cols='80'></textarea>\r
94 -->\r
95 </body>\r
96 </html>\r
97 \r