2 header("Cache-Control: no-cache");
3 header("Pragma: no-cache");
4 header("Expires: ".gmdate("D, d M Y H:i:s",time()+(-1*60))." GMT");
5 header('Content-type: text/html; charset=utf-8');
8 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
11 <title>Rico LiveGrid-Example 2 (editable)</title>
13 require "dbConnect.php";
14 require "../../plugins/php/ricoLiveGridForms.php";
15 require "../../plugins/php/ricoResponse.php";
17 //************************************************************************************************************
18 // LiveGrid Plus-Edit Example
19 //************************************************************************************************************
21 //************************************************************************************************************
22 if (OpenGridForm("", "orders")) {
23 switch ($oForm->action) {
28 $oXmlResp= new ricoXmlResponse();
29 $oXmlResp->sendDebugMsgs=true;
30 $oXmlResp->convertCharSet=true; // MySQL sample database is encoded with ISO-8859-1
31 $oXmlResp->ProcessQuery($oForm->gridID, $oForm->SqlSelectData());
37 $oForm->DisplayPage();
46 require "LoadRicoClient.php";
49 <script type='text/javascript'>
50 Rico.loadModule('LiveGridForms','Calendar','Tree');
52 // ricoLiveGridForms will call orders_FormInit right before grid & form initialization.
54 function orders_FormInit() {
55 var cal=new Rico.CalendarControl("Cal");
56 Rico.EditControls.register(cal, Rico.imgDir+'calarrow.png');
58 var CustTree=new Rico.TreeControl("CustomerTree","CustTree.php");
59 Rico.EditControls.register(CustTree, Rico.imgDir+'dotbutton.gif');
63 <link href="../demo.css" type="text/css" rel="stylesheet" />
64 <style type="text/css">
65 div.ricoLG_outerDiv thead .ricoLG_cell, div.ricoLG_outerDiv thead td, div.ricoLG_outerDiv thead th {
76 <table id='explanation' border='0' cellpadding='0' cellspacing='5' style='clear:both'><tr valign='top'><td>
77 Base Library: <script type='text/javascript'>document.write(Rico.Lib+' '+Rico.LibVersion);</script>
78 <hr>The data on this grid can be edited using pop-up forms.
79 Just click on a grid cell and then select Edit, Delete, or Add from the pop-up menu.
80 The Add and Edit forms are automatically generated by LiveGrid.
81 Notice on the Add form how you use the Rico Tree control to select the customer.
82 Notice on the Edit form how the Rico Calendar is used to change dates.
83 Updates are disabled on the database, so you will get an error message if you try to save.
90 <p><strong>Orders Table</strong></p>
94 $oForm->DisplayPage();
95 //echo "<p><textarea id='orders_debugmsgs' rows='5' cols='80' style='font-size:smaller;'></textarea>";
99 function DefineFields() {
101 $oForm->options["FilterLocation"]=-1;
102 $oForm->options["panelWidth"]=500;
103 $oForm->options["frozenColumns"]=1;
104 $oForm->options["menuEvent"]='click';
105 $oForm->options["highlightElem"]='cursorRow';
106 $oForm->options["XMLprovider"]=$_SERVER['SCRIPT_NAME'];
107 $oForm->sessions=false;
108 //$GLOBALS['oForm']->options["DebugFlag"]=true;
109 //$GLOBALS['oDB']->debug=true;
111 $oForm->AddPanel("Basic Info");
112 $oForm->AddEntryFieldW("OrderID", "Order ID", "B", "<auto>", 50);
113 $oForm->ConfirmDeleteColumn();
116 $LookupSQL="select CustomerID,CompanyName from customers order by CompanyName";
117 $oForm->AddLookupField("CustomerID",null,"CustID","Customer","CL","",$LookupSQL);
118 $oForm->LookupField["SelectCtl"]="CustomerTree";
119 $oForm->LookupField["InsertOnly"]=true; // do not allow customer to be changed once an order is entered
120 $oForm->CurrentField["width"]=160;
121 $oForm->CurrentField["filterUI"]="t";
123 $LookupSQL="select EmployeeID,".$oDB->concat(array("LastName", "', '", "FirstName"), false)." from employees order by LastName,FirstName";
124 $oForm->AddLookupField("EmployeeID",null,"EmployeeID","Sales Person","SL","",$LookupSQL);
125 $oForm->CurrentField["width"]=140;
126 $oForm->CurrentField["filterUI"]="s";
128 $oForm->AddEntryField("OrderDate", "Order Date", "D", strftime('%Y-%m-%d'));
129 $oForm->CurrentField["SelectCtl"]="Cal";
130 $oForm->CurrentField["width"]=90;
131 $oForm->AddEntryField("RequiredDate", "Required Date", "D", strftime('%Y-%m-%d'));
132 $oForm->CurrentField["SelectCtl"]="Cal";
133 $oForm->CurrentField["width"]=90;
134 $oForm->AddCalculatedField("select sum(UnitPrice*Quantity*(1.0-Discount)) from order_details d where d.OrderID=t.OrderID","Net Sale");
135 $oForm->CurrentField["format"]="DOLLAR";
136 $oForm->CurrentField["width"]=80;
138 $oForm->AddPanel("Ship To");
139 $oForm->AddEntryFieldW("ShipName", "Name", "B", "",140);
140 $oForm->AddEntryFieldW("ShipAddress", "Address", "B", "",140);
141 $oForm->AddEntryFieldW("ShipCity", "City", "B", "",120);
142 $oForm->CurrentField["filterUI"]="s";
143 $oForm->AddEntryFieldW("ShipRegion", "Region", "T", "",60);
144 $oForm->AddEntryFieldW("ShipPostalCode", "Postal Code", "T", "",100);
146 // display ShipCountry with a link to wikipedia
147 $colnum=$oForm->AddEntryFieldW("ShipCountry", "Country", "N", "",100);
148 $oForm->CurrentField["control"]="new Rico.TableColumn.link('http://en.wikipedia.org/wiki/{".$colnum."}','_blank')";
149 $oForm->CurrentField["filterUI"]="s";