2 if (!isset ($_SESSION)) session_start();
3 header("Cache-Control: no-cache");
4 header("Pragma: no-cache");
5 header("Expires: ".gmdate("D, d M Y H:i:s",time()+(-1*60))." GMT");
6 header('Content-type: text/html; charset=utf-8');
9 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
12 <title>Rico LiveGrid-Example 2 (editable)</title>
14 require "dbConnect.php";
15 require "LoadRicoClient.php";
16 require "../../plugins/php/ricoLiveGridForms.php";
19 <script type='text/javascript'>
20 Rico.loadModule('LiveGridForms','Calendar','Tree');
22 // ricoLiveGridForms will call orders_FormInit right before grid & form initialization.
24 function orders_FormInit() {
25 var cal=new Rico.CalendarControl("Cal");
26 Rico.EditControls.register(cal, Rico.imgDir+'calarrow.png');
28 var CustTree=new Rico.TreeControl("CustomerTree","CustTree.php");
29 Rico.EditControls.register(CustTree, Rico.imgDir+'dotbutton.gif');
33 <link href="../demo.css" type="text/css" rel="stylesheet" />
34 <style type="text/css">
35 div.ricoLG_outerDiv thead .ricoLG_cell, div.ricoLG_outerDiv thead td, div.ricoLG_outerDiv thead th {
46 //************************************************************************************************************
47 // LiveGrid Plus-Edit Example
48 //************************************************************************************************************
50 //************************************************************************************************************
51 if (OpenGridForm("", "orders")) {
52 if ($oForm->action == "table") {
63 function DisplayTable() {
65 echo "<table id='explanation' border='0' cellpadding='0' cellspacing='5' style='clear:both'><tr valign='top'><td>";
66 echo "Base Library: <script type='text/javascript'>document.write(Rico.Lib+' '+Rico.LibVersion);</script>";
67 echo "<hr>The data on this grid can be edited using pop-up forms. ";
68 echo "Just click on a grid cell and then select Edit, Delete, or Add from the pop-up menu. ";
69 echo "The Add and Edit forms are automatically generated by LiveGrid. ";
70 echo "Notice on the Add form how you use the Rico Tree control to select the customer. ";
71 echo "Notice on the Edit form how the Rico Calendar is used to change dates. ";
72 echo "Updates are disabled on the database, so you will get an error message if you try to save.";
74 echo "<script type='text/javascript'><!--\n";
75 echo "google_ad_client = 'pub-7218597156507462';\n";
76 echo "/* 125x125, created 5/11/09 */\n";
77 echo "google_ad_slot = '9298106441';\n";
78 echo "google_ad_width = 125;\n";
79 echo "google_ad_height = 125;\n";
82 echo "<script type='text/javascript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'></script>\n";
83 echo "</td></tr></table>";
84 echo "<p><strong>Orders Table</strong></p>";
86 $oForm->options["panelWidth"]=500;
87 $oForm->options["frozenColumns"]=1;
88 $oForm->options["menuEvent"]='click';
89 $oForm->options["highlightElem"]='cursorRow';
90 //$GLOBALS['oForm']->options["DebugFlag"]=true;
91 //$GLOBALS['oDB']->debug=true;
93 //echo "<p><textarea id='orders_debugmsgs' rows='5' cols='80' style='font-size:smaller;'></textarea>";
96 function DefineFields() {
98 $oForm->options["FilterLocation"]=-1;
100 $oForm->AddPanel("Basic Info");
101 $oForm->AddEntryFieldW("OrderID", "Order ID", "B", "<auto>", 50);
102 $oForm->ConfirmDeleteColumn();
105 $LookupSQL="select CustomerID,CompanyName from customers order by CompanyName";
106 $oForm->AddLookupField("CustomerID",null,"CustID","Customer","CL","",$LookupSQL);
107 $oForm->LookupField["SelectCtl"]="CustomerTree";
108 $oForm->LookupField["InsertOnly"]=true; // do not allow customer to be changed once an order is entered
109 $oForm->CurrentField["width"]=160;
110 $oForm->CurrentField["filterUI"]="t";
112 $LookupSQL="select EmployeeID,".$oDB->concat(array("LastName", "', '", "FirstName"), false)." from employees order by LastName,FirstName";
113 $oForm->AddLookupField("EmployeeID",null,"EmployeeID","Sales Person","SL","",$LookupSQL);
114 $oForm->CurrentField["width"]=140;
115 $oForm->CurrentField["filterUI"]="m";
117 $oForm->AddEntryField("OrderDate", "Order Date", "D", strftime('%Y-%m-%d'));
118 $oForm->CurrentField["SelectCtl"]="Cal";
119 $oForm->CurrentField["width"]=90;
120 $oForm->AddEntryField("RequiredDate", "Required Date", "D", strftime('%Y-%m-%d'));
121 $oForm->CurrentField["SelectCtl"]="Cal";
122 $oForm->CurrentField["width"]=90;
123 $oForm->AddCalculatedField("select sum(UnitPrice*Quantity*(1.0-Discount)) from order_details d where d.OrderID=t.OrderID","Net Sale");
124 $oForm->CurrentField["format"]="DOLLAR";
125 $oForm->CurrentField["width"]=80;
127 $oForm->AddPanel("Ship To");
128 $oForm->AddEntryFieldW("ShipName", "Name", "B", "",140);
129 $oForm->AddEntryFieldW("ShipAddress", "Address", "B", "",140);
130 $oForm->AddEntryFieldW("ShipCity", "City", "B", "",120);
131 $oForm->CurrentField["filterUI"]="s";
132 $oForm->AddEntryFieldW("ShipRegion", "Region", "T", "",60);
133 $oForm->AddEntryFieldW("ShipPostalCode", "Postal Code", "T", "",100);
135 // display ShipCountry with a link to wikipedia
136 $colnum=$oForm->AddEntryFieldW("ShipCountry", "Country", "N", "",100);
137 $oForm->CurrentField["control"]="new Rico.TableColumn.link('http://en.wikipedia.org/wiki/{".$colnum."}','_blank')";
138 $oForm->CurrentField["filterUI"]="s";
140 $oForm->DisplayPage();