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'>
21 // ricoLiveGridForms will call orders_FormInit right before grid & form initialization.
23 function orders_FormInit() {
24 var cal=new Rico.CalendarControl("Cal");
25 Rico.EditControls.register(cal, 'rico-icon rico-calarrow');
27 var CustTree=new Rico.TreeControl("CustomerTree","CustTree.asp");
28 Rico.EditControls.register(CustTree, 'rico-icon rico-dotbutton');
32 <link href="../demo.css" type="text/css" rel="stylesheet" />
33 <style type="text/css">
42 //************************************************************************************************************
43 // LiveGrid Plus-Edit Example
44 //************************************************************************************************************
46 //************************************************************************************************************
47 if (OpenGridForm("", "orders")) {
48 if ($oForm->action == "table") {
59 function DisplayTable() {
61 echo "<table id='explanation' border='0' cellpadding='0' cellspacing='5' style='clear:both'><tr valign='top'><td>";
62 echo "Base Library: <script type='text/javascript'>document.write(Rico.Lib+' '+Rico.LibVersion);</script>";
63 echo "<hr>The data on this grid can be edited using pop-up forms. ";
64 echo "Just click on a grid cell and then select Edit, Delete, or Add from the pop-up menu. ";
65 echo "The Add and Edit forms are automatically generated by LiveGrid. ";
66 echo "Notice on the Add form how you use the Rico Tree control to select the customer. ";
67 echo "Notice on the Edit form how the Rico Calendar is used to change dates. ";
68 echo "Updates are disabled on the database, so you will get an error message if you try to save.";
71 echo "</td></tr></table>";
72 echo "<p><strong>Orders Table</strong></p>";
74 $oForm->options["panelWidth"]=500;
75 $oForm->options["frozenColumns"]=1;
76 $oForm->options["menuEvent"]='click';
77 $oForm->options["highlightElem"]='cursorRow';
78 //$GLOBALS['oForm']->options["DebugFlag"]=true;
79 //$GLOBALS['oDB']->debug=true;
81 //echo "<p><textarea id='orders_debugmsgs' rows='5' cols='80' style='font-size:smaller;'></textarea>";
84 function DefineFields() {
86 $oForm->options["FilterLocation"]=-1;
88 $oForm->AddPanel("Basic Info");
89 $oForm->AddEntryFieldW("OrderID", "Order ID", "B", "<auto>", 50);
90 $oForm->ConfirmDeleteColumn();
93 $LookupSQL="select CustomerID,CompanyName from customers order by CompanyName";
94 $oForm->AddLookupField("CustomerID",null,"CustID","Customer","CL","",$LookupSQL);
95 $oForm->LookupField["SelectCtl"]="CustomerTree";
96 $oForm->LookupField["InsertOnly"]=true; // do not allow customer to be changed once an order is entered
97 $oForm->CurrentField["width"]=160;
98 $oForm->CurrentField["filterUI"]="t";
100 $LookupSQL="select EmployeeID,".$oDB->concat(array("LastName", "', '", "FirstName"), false)." from employees order by LastName,FirstName";
101 $oForm->AddLookupField("EmployeeID",null,"EmployeeID","Sales Person","SL","",$LookupSQL);
102 $oForm->CurrentField["width"]=140;
103 $oForm->CurrentField["filterUI"]="m";
105 $oForm->AddEntryField("OrderDate", "Order Date", "D", @strftime('%Y-%m-%d'));
106 $oForm->CurrentField["SelectCtl"]="Cal";
107 $oForm->CurrentField["width"]=90;
108 $oForm->AddEntryField("RequiredDate", "Required Date", "D", @strftime('%Y-%m-%d'));
109 $oForm->CurrentField["SelectCtl"]="Cal";
110 $oForm->CurrentField["width"]=90;
111 $oForm->AddCalculatedField("select sum(UnitPrice*Quantity*(1.0-Discount)) from order_details d where d.OrderID=t.OrderID","Net Sale");
112 $oForm->CurrentField["format"]="DOLLAR";
113 $oForm->CurrentField["width"]=80;
115 $oForm->AddPanel("Ship To");
116 $oForm->AddEntryFieldW("ShipName", "Name", "B", "",140);
117 $oForm->AddEntryFieldW("ShipAddress", "Address", "B", "",140);
118 $oForm->AddEntryFieldW("ShipCity", "City", "B", "",120);
119 $oForm->CurrentField["filterUI"]="s";
120 $oForm->AddEntryFieldW("ShipRegion", "Region", "T", "",60);
121 $oForm->AddEntryFieldW("ShipPostalCode", "Postal Code", "T", "",100);
123 // display ShipCountry with a link to wikipedia
124 $colnum=$oForm->AddEntryFieldW("ShipCountry", "Country", "N", "",100);
125 $oForm->CurrentField["control"]="new Rico.TableColumn.link('http://en.wikipedia.org/wiki/{".$colnum."}','_blank')";
126 $oForm->CurrentField["filterUI"]="s";
128 $oForm->DisplayPage();