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