Author: pcamacho
Date: 2005-05-18 15:48:18 -0400 (Wed, 18 May 2005)
New Revision: 1090
Added:
humano2/trunk/web/builder/site/createreport.aspx
humano2/trunk/web/builder/site/createreport.aspx.cs
humano2/trunk/web/builder/site/js/formreport.js
humano2/trunk/web/builder/site/js/formview.js
humano2/trunk/web/builder/site/js/grafcomponents/expandformreport.js
humano2/trunk/web/builder/site/xsl/createreport.xsl
Removed:
humano2/trunk/web/builder/site/js/form.js
Modified:
humano2/trunk/components/webTools/Adapter.cs
humano2/trunk/core/db/absComplex.cs
humano2/trunk/core/db/consts.cs
humano2/trunk/core/db/mssql/mssqlComplex.cs
humano2/trunk/core/db/pgsql/pgsqlComplex.cs
humano2/trunk/web/builder/site/functionoperationbar.aspx
humano2/trunk/web/builder/site/js/grafcomponents/expandform.js
humano2/trunk/web/builder/site/xsl/createview.xsl
humano2/trunk/web/portal/site/readXslt.aspx
Log:
ADD: First step for creation of reports. The interface is for now the sam=
e as views but the datas are saved in the=20
table report.
Modified: humano2/trunk/components/webTools/Adapter.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/components/webTools/Adapter.cs 2005-05-18 19:23:33 UTC =
(rev 1089)
+++ humano2/trunk/components/webTools/Adapter.cs 2005-05-18 19:48:18 UTC =
(rev 1090)
@@ -1310,6 +1310,7 @@
=20
return crud.Create(classId, formTable);=09
}
+ =20
=09
///<summary>Updates values for a class instance</summary>
///<remarks>better to do this seperately so we can better control what=
get's changed.</remarks>
@@ -1376,6 +1377,16 @@
=09
return cId;
}
+ =20
+ public int CreateReport(DataTable reportTable, SessionCredencial=
cred)
+ {
+ crud.Domain =3D cred.DomainIds[cred.CurrentDomainIndex];
+ Logger.Log("******** CreateReport ***********",LogLevel.Trace);
+ int cId =3D crud.Create((int) ReportConsts.ReportClass, reportTable);
+ =09
+ return cId;
+ }
+ =20
=20
///<summary>Marks an instance as deleted.</summary>
public void DeleteInstance(int instanceId, SessionCredencial cred)
@@ -1663,6 +1674,11 @@
{
return complex.GetViewData(viewId);
}
+ =20
+ public DataTable GetReportData(int reportId)=20
+ {
+ return complex.GetReportData(reportId);
+ }
=09
private DataTable genTableFromAttributesAndData(NameValueCollection at=
tributeDict, NameValueCollection data)
{
Modified: humano2/trunk/core/db/absComplex.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/core/db/absComplex.cs 2005-05-18 19:23:33 UTC (rev 1089=
)
+++ humano2/trunk/core/db/absComplex.cs 2005-05-18 19:48:18 UTC (rev 1090=
)
@@ -192,6 +192,12 @@
///<returns>a datatable with the information about the view.</returns>
abstract public DataTable GetViewData(int viewId);
=20
+ ///<summary>Get the structure of a report.</summary>
+ ///<param name=3D"viewId">The id of the report.</param>
+ ///<returns>a datatable with the information about the report.</return=
s>
+ abstract public DataTable GetReportData(int reportId);
+ =09
+ =20
///<summary>gets all the formulas that are related to attribtes of =
a class</summary>
///<param name=3D"classId">The Id of fthe class</param>
///<returns>A dataTable with the ideas of the formulas.</returns>
Modified: humano2/trunk/core/db/consts.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/core/db/consts.cs 2005-05-18 19:23:33 UTC (rev 1089)
+++ humano2/trunk/core/db/consts.cs 2005-05-18 19:48:18 UTC (rev 1090)
@@ -54,6 +54,18 @@
Name =3D 1018,
}
=20
+ public enum ReportConsts: int
+ {
+ ReportClass =3D 1300,
+ Columns =3D 1301,
+ Where =3D 1302,
+ GroupBy =3D 1303,
+ Having =3D 1304,
+ Order =3D 1305,
+ Class =3D 1306,
+ Name =3D 1307,
+ }
+ =20
public enum FormulaConsts : int {
FormulaClass =3D 1001,
Formula =3D 1002,
Modified: humano2/trunk/core/db/mssql/mssqlComplex.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/core/db/mssql/mssqlComplex.cs 2005-05-18 19:23:33 UTC (=
rev 1089)
+++ humano2/trunk/core/db/mssql/mssqlComplex.cs 2005-05-18 19:48:18 UTC (=
rev 1090)
@@ -84,6 +84,14 @@
=20
return res; =09
}
+ =20
+ ///<summary>Get the structure of a report.</summary>
+ ///<param name=3D"viewId">The id of the report.</param>
+ ///<returns>a datatable with the information about the report.</return=
s>
+ public override DataTable GetReportData(int reportId)=20
+ {
+ return null;
+ }
=09
///<summary>gets all the formulas that are related to attribtes of =
a class</summary>
///<param name=3D"classId">The Id of fthe class</param>
Modified: humano2/trunk/core/db/pgsql/pgsqlComplex.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/core/db/pgsql/pgsqlComplex.cs 2005-05-18 19:23:33 UTC (=
rev 1089)
+++ humano2/trunk/core/db/pgsql/pgsqlComplex.cs 2005-05-18 19:48:18 UTC (=
rev 1090)
@@ -82,6 +82,17 @@
return res; =09
}
=09
+ ///<summary>Get the structure of a report.</summary>
+ ///<param name=3D"viewId">The id of the report.</param>
+ ///<returns>a datatable with the information about the report.</return=
s>
+ public override DataTable GetReportData(int reportId)=20
+ {
+ string query =3D "select id_entity, \"columns\", \"where\", \"groupby=
\", \"having\", \"order\", \"idClassReport\", \"reportName\" "+=20
+ "from \"report\" where id_entity =3D " + reportId;
+ DataTable res =3D this.doSelect(query);
+ return res; =09
+ }
+ =20
///<summary>gets all the formulas that are related to attribtes of =
a class</summary>
///<param name=3D"classId">The Id of fthe class</param>
///<returns>A dataTable with the ideas of the formulas.</returns>
Added: humano2/trunk/web/builder/site/createreport.aspx
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/web/builder/site/createreport.aspx 2005-05-18 19:23:33 =
UTC (rev 1089)
+++ humano2/trunk/web/builder/site/createreport.aspx 2005-05-18 19:48:18 =
UTC (rev 1090)
@@ -0,0 +1,6 @@
+<%@ Page language=3D"c#" Codebehind=3D"createreport.aspx.cs" AutoEventWi=
reup=3D"false" Inherits=3D"Builder.site.CreateReport" %>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
+<% getContent("xsl/createreport.xsl"); %>
+<% //Response.Write(createXml());%>
+
+
Added: humano2/trunk/web/builder/site/createreport.aspx.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/web/builder/site/createreport.aspx.cs 2005-05-18 19:23:=
33 UTC (rev 1089)
+++ humano2/trunk/web/builder/site/createreport.aspx.cs 2005-05-18 19:48:=
18 UTC (rev 1090)
@@ -0,0 +1,720 @@
+//
+// The Humano2 Business solution.
+// Copyright (C) 2004,5 Humano2 Chile S.A. (http://www.humano2.com)
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version. =20
+//
+//
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Web;
+using System.Web.SessionState;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Web.UI.HtmlControls;
+
+using Humano2.Core;
+using Humano2.Core.Db;
+using Humano2.Components.WebTools;
+
+namespace Builder.site
+{
+ public class CreateReport : basePage
+ {=09
+ =20
+ private string reportName;
+ private int reportId;
+ private string delete;
+ =20
+ private string receivedCreateUpdate;
+ =20
+ //Update this variables when create=3Dtrue is passed in paramete=
r of page
+ private string receivedReportName;
+ private string receivedClassId;
+ private string receivedColumnsStr; =20
+ private string receivedWhereStr;
+ private string receivedOrderStr;
+ =20
+ private void Page_Load(object sender, System.EventArgs e)
+ {
+ reportId =3D Convert.ToInt32(Request["reportId"]);
+ delete =3D Request["delete"];
+ receivedCreateUpdate =3D Request["sendCreateUpdate"];
+ =20
+ Logger.Log("delete: " + delete, LogLevel.Trace);
+ Logger.Log("reportId: " + reportId, LogLevel.Trace);
+ Logger.Log("receivedCreateUpdate: " + receivedCreateUpdate, =
LogLevel.Trace);
+ =20
+ if (delete=3D=3D"true")
+ {
+ deleteReport();
+ return;
+ }
+ =20
+ if(receivedCreateUpdate =3D=3D "true")
+ {
+ ProcessCreationUpdate();
+ return;
+ } =20
+ }
+ =20
+ override protected string createXml()
+ {
+ =20
+ DataTable currReport =3D null;
+ Logger.Log("ReportMain: reportId =3D " + Convert.ToString(re=
portId),LogLevel.Trace);
+ if(reportId !=3D 0)
+ {
+ currReport =3D userCred.CoreAdapter.GetReportData(report=
Id);
+ reportName =3D Convert.ToString(currReport.Rows[0]["repo=
rtName"]);
+ }
+ else
+ {
+ reportName =3D ""; =20
+ }
+ =20
+ string strXml =3D "";
+ strXml +=3D "<report>";
+ strXml +=3D "<reportDatas>";
+ strXml +=3D "<id>";
+ strXml +=3D Convert.ToString(reportId);
+ strXml +=3D "</id>";
+ strXml +=3D String.Format("<name>{0}</name>",repor=
tName);
+ =20
+ //Put the classId if necessary
+ string classId;
+ string classidaux =3D Request["classList"];
+ =20
+ if(currReport !=3D null)
+ {
+ reportName =3D Convert.ToString(currReport.Rows[0]["reportName"]);
+ classId =3D Convert.ToString(Convert.ToInt32(currReport.Rows[0]["idC=
lassReport"]));
+ }
+ else if(classidaux!=3D"")
+ {
+ classId =3D Request["classList"];
+ }
+ else
+ {
+ classId =3D "0";
+ }
+ =20
+ if(reportId =3D=3D 0) //To create a report
+ {
+ strXml +=3D String.Format("<saveName>{0}</save=
Name>","Create");
+ strXml +=3D "<displayDeleteButton>false</displ=
ayDeleteButton>";
+ }
+ else //To update a report
+ {
+ strXml +=3D String.Format("<saveName>{0}</save=
Name>","Update");
+ strXml +=3D "<displayDeleteButton>true</displa=
yDeleteButton>";
+ strXml +=3D "<classReportName>" + userCred.Cor=
eAdapter.GetClassNameById(Convert.ToInt32(classId)) +"</classReportName>"=
;
+ strXml +=3D getReportContent();
+ Logger.Log("getReportContent(): " + getReportContent(),L=
ogLevel.Trace);
+ }=20
+ =20
+ strXml +=3D "<classId>" + classId + "</classId>";
+ strXml +=3D "</reportDatas>";
+ strXml +=3D "<classes>";
+ //Se necesita traer las clases, pero en vez de traerlas toda=
s, solo traeremos las
+ //relacionadas...
+ if(Convert.ToInt32(classId) > 0)
+ {
+ strXml +=3D formAttribList(Convert.ToInt32(classId));
+ }
+ strXml +=3D getClassList();
+ strXml +=3D "</classes>";
+ strXml +=3D "</report>";
+ =20
+ Logger.Log("ReportMain: createXml(): " + strXml, LogLevel.Tr=
ace);
+ =20
+ return strXml;
+ }
+ =20
+ override protected void OnInit(EventArgs e)
+ {
+ =20
+ InitializeComponent();
+ base.OnInit(e);
+ }
+ =20
+ private void InitializeComponent()
+ { =20
+ this.Load +=3D new System.EventHandler(this.Page_Load);
+ }
+ =20
+ private string getReportContent()
+ {
+ =20
+ DataTable dt =3D userCred.CoreAdapter.GetReportData(reportId=
);
+ =09
+ string res =3D"";
+ =20
+ res +=3D "<reportParams>";
+ res +=3D getReportColumnsXml((dt.Rows[0]["columns"]).ToStrin=
g()); // The columns
+ res +=3D getReportWhereXml((dt.Rows[0]["where"]).ToString())=
; //Where=20
+ res +=3D getReportOrderXml((dt.Rows[0]["order"]).ToString())=
; //Order
+ res +=3D "</reportParams>";
+
+ return res;
+ }
+ =20
+ private string getReportColumnsXml(string columns)
+ {
+ string [] allColumns =3D columns.Split(new char [] {','}); =
=20
+ string xmlRes =3D "";
+ =20
+ if(allColumns.Length <=3D 1)
+ {
+ return "";
+ }
+ xmlRes +=3D "<columns>";
+ for(int i=3D0;i<allColumns.Length;i++)
+ {
+ xmlRes +=3D"<column>";
+ xmlRes +=3D allColumns[i];
+ xmlRes +=3D "</column>";
+ }
+ xmlRes +=3D "</columns>";
+ return xmlRes;
+ }
+
+ private string getReportWhereXml(string where)
+ {
+ string [] tabWhere =3D where.Split(new char [] {'|',';'}); =
=20
+ string xmlRes =3D "";
+ =20
+ if(tabWhere.Length <=3D 1)
+ {
+ return "";
+ }
+ =20
+ xmlRes +=3D "<conditions>";
+ string [] columnsList =3D getColumnsList();
+ =20
+ for(int i=3D0;i<tabWhere.Length;i+=3D5) //The string is |att=
Id|numCond|'valor'|0 or 1|
+ {
+ string operatorValue =3D Convert.ToString(Convert.ToInt3=
2(tabWhere[i+1]) +1); //Because the first item in the list is -----
+ string attributeValue =3D Convert.ToString(Convert.ToInt=
32(getIndexOfElement(tabWhere[i+0],columnsList)) + 1);
+ xmlRes +=3D"<condition>";
+ xmlRes +=3D"<idAtt>" + attributeValue + "</idAtt>";
+ xmlRes +=3D"<operator>" + operatorValue + "</operator>";
+ xmlRes +=3D"<value>";
+ if(operatorValue =3D=3D "9") //In special case (don't fo=
rget the operator value has been incremented (9=3D8+1)...)
+ {
+ xmlRes +=3D convertInCaseFromReportToInterface(tabWh=
ere[i+2]);
+ }
+ else
+ { =20
+ xmlRes +=3D tabWhere[i+2];
+ }
+ xmlRes +=3D "</value>";
+ xmlRes +=3D "</condition>";
+ }
+ xmlRes +=3D "</conditions>";
+ =20
+ return xmlRes;
+ }
+
+
+ ///<summary>
+ /// Basically this function takes a string of form: "[(item1,ite=
m2,item3)]" and returns "item1 item2 item3"
+ ///</summary>
+ private string convertInCaseFromReportToInterface(string strInCa=
se)
+ {
+ string convertedStr =3D "";
+ convertedStr +=3D "'";
+ string [] strInCaseArr =3D strInCase.Split(new char [] {','=
,'[','(',']',')','\''});
+ for(int i=3D0; i<strInCaseArr.Length;i++)
+ {
+ if(strInCaseArr[i] !=3D "") //Remove unuseful strings
+ {
+ convertedStr +=3D strInCaseArr[i] + " ";=20
+ Logger.Log("convertedStr[" + Convert.ToString(i) +"]=
:" + convertedStr,LogLevel.Trace);
+ }
+ }
+ convertedStr =3D convertedStr.Substring(0,convertedStr.Lengt=
h-1); //remove last space
+ convertedStr +=3D "'";
+ Logger.Log("convertedStr: " + convertedStr,LogLevel.Trace);
+ return convertedStr;
+ }
+ =20
+ ///<summary>
+ ///The result of this function allow to use getIndexOfElement
+ ///</summary>
+ private string [] getColumnsList()
+ {
+ string [] list;
+ //Get class id
+ DataTable currReport =3D null;
+ currReport =3D userCred.CoreAdapter.GetReportData(reportId);
+ int classId =3D Convert.ToInt32(currReport.Rows[0]["idClassR=
eport"]);
+ DataTable res =3D userCred.CoreAdapter.GetAttributesFromClas=
s(classId);
+
+ string listAtt =3D "";
+ =20
+ string separator=3D"|";
+ foreach(DataRow row in res.Rows)
+ {
+ int idAtt =3D Convert.ToInt32(row["id_entity"]);
+ if(row["attType"].ToString()!=3D"pertinence")
+ {
+ listAtt+=3D Convert.ToString(idAtt) + separator;
+ }
+ else
+ {
+ DataTable dtpert =3D userCred.CoreAdapter.GetClassesFromPertinence(=
Convert.ToInt32(row["id_entity"]));
+ DataRow dr2 =3D dtpert.Rows[0];
+ int idClassRel =3D Convert.ToInt32(dr2["to"].ToString());
+ =09
+ //For each attribute of pertinence put the id with t=
ogo
+ int attLogin =3D 0;
+ int [] listAttId =3D getAttributeIdListForClass(idCl=
assRel);
+ int size =3D listAttId.Length;
+ for(int k=3D0;k<size;k++)
+ {
+ attLogin =3D listAttId[k];
+ listAtt +=3D idAtt + "^" + attLogin + separator;
+ }
+ }
+ }
+ //Remove last separator
+ listAtt =3D listAtt.Substring(0,listAtt.Length-1);
+ =20
+ //Now split the string create the list
+ string [] listAttArr =3D listAtt.Split(new char [] {'|'});
+ for(int i=3D0;i<listAttArr.Length;i++)
+ {
+ Logger.Log("listAttArr[" +Convert.ToString(i) + "]=3D " =
+ listAttArr[i],LogLevel.Trace);
+ }
+ return listAttArr;
+ }
+ =20
+ ///<summary>
+ ///This functions is used because of the javascript interface th=
at needs to know which element of
+ /// the combo box list is selected
+ ///</summary>
+ private string getIndexOfElement(string element, string [] tabEl=
ements)
+ {
+ int index =3D 0;
+ for(int i=3D0;i<tabElements.Length;i++)
+ {
+ if(element =3D=3D tabElements[i])
+ {
+ index=3Di;
+ break;
+ }
+ }
+ return Convert.ToString(index);
+ }
+ =20
+ private string getReportOrderXml(string order)
+ {
+ string [] tabOrder =3D order.Split(new char [] {',','|'}); =
=20
+ string xmlRes =3D "";
+ string [] columnsList =3D getColumnsList();
+ =20
+ if(tabOrder.Length <=3D 1)
+ {
+ return "";
+ }
+ =20
+ xmlRes +=3D "<orders>";
+ for(int i=3D0;i<tabOrder.Length;i+=3D2) //The string is attI=
d|0 or 1
+ {
+ string orderAtt =3D Convert.ToString(Convert.ToInt32(get=
IndexOfElement(tabOrder[i+0],columnsList))+1);
+ string orderAscOrDesc =3D Convert.ToString(Convert.ToInt=
32(tabOrder[i+1])+1);
+ xmlRes +=3D"<order>";
+ xmlRes +=3D"<idAtt>" + orderAtt + "</idAtt>";
+ xmlRes +=3D"<ascOrDesc>" + orderAscOrDesc + "</ascOrDesc=
>";
+ xmlRes +=3D "</order>";
+ }
+ xmlRes +=3D "</orders>";
+ =20
+ return xmlRes;
+ }
+ =20
+ ///<summary>
+ /// Returns an xml string as this:
+ /// <class>
+ /// <id> </id>
+ /// <name> </name>
+ /// </class>
+ ///</summary>
+ private string getClassList()=20
+ {
+ string xmlString =3D "";
+
+ DataTable res =3D userCred.CoreAdapter.GetAllClassesOfDomain=
(userCred);
+ DataRow startRow =3D res.NewRow();
+ startRow["id_entity"] =3D 0;
+ startRow["name"] =3D "-- Classes --";
+ res.Rows.InsertAt(startRow, 0);
+ =20
+ //Parse the table and build the xml string
+ =20
+ foreach(DataRow row in res.Rows)
+ {
+ int classId =3D Convert.ToInt32(row["id_entity"]);
+ =20
+ xmlString +=3D "<class>";
+ xmlString +=3D "<id>";
+ xmlString +=3D row["id_entity"];
+ xmlString +=3D "</id>"; =20
+ xmlString +=3D "<name>"; =20
+ xmlString +=3D row["name"];
+ xmlString +=3D "</name>";=20
+ xmlString +=3D "</class>";
+ }
+ //Logger.Log("ReportMain getClassList: " + xmlString, LogLev=
el.Trace);
+ return xmlString;
+ }
+ =20
+ private void deleteReport()
+ {
+ Logger.Log("deleteReport called", LogLevel.Trace);
+ userCred.CoreAdapter.DeleteInstance(reportId, userCred);
+ sendMessageToUser(UserMessage.DELETEVIEWOK);
+ this.MyRedirect();
+ return;
+ }
+ =20
+ private DataTable createReportTable()
+ {
+ // Report's Name
+ if(receivedReportName =3D=3D "")
+ {
+ Logger.Log("No name for report", LogLevel.Trace);
+ return null;
+ }
+ =20
+ // Class that the report belongs to.
+ int classId =3D Convert.ToInt32(receivedClassId);
+ if(classId =3D=3D 0)=20
+ { // There was no class chosen, don't do anything.
+ Logger.Log("ClassId =3D=3D 0", LogLevel.Trace);
+ return null;
+ }
+ =20
+ // List of attributes to show.
+ string columnsStr =3D "0,";
+ =20
+ if(receivedColumnsStr =3D=3D "0") //No columns =3D> No Updat=
e/Create
+ {
+ Logger.Log("No columns for report",LogLevel.Trace);
+ return null; =20
+ }
+ =20
+ DataTable dt =3D createReportDataTable();
+ DataRow dr =3D dt.NewRow();
+ dr["idClassReport"] =3D receivedClassId;
+ dr["reportName"] =3D receivedReportName;
+ =20
+ //Logger.Log("reportmain: checkForPertinence: " + userCred.C=
oreAdapter.CheckForPertinence(receivedColumnsStr),LogLevel.Trace);
+ =20
+ //dr["columns"] =3D userCred.CoreAdapter.CheckForPertinence(=
receivedColumnsStr); //If a column is a pertinence, change it
+ dr["columns"] =3D receivedColumnsStr; //If a column is a per=
tinence, change it
+ =20
+ //Special case for IN filter
+ dr["where"] =3D treatInSpecialCase(receivedWhereStr);=20
+ =20
+ dr["order"] =3D receivedOrderStr;
+ Logger.Log("receivedOrderStr" + receivedOrderStr, LogLevel.T=
race);
+ Logger.Log("receivedWhereStr" + receivedWhereStr, LogLevel.T=
race);
+ =09
+ dt.Rows.Add(dr);
+ =20
+ return dt;
+ }
+ =20
+ ///<summary>
+ /// The IN filter must be treated in a special maner. If the val=
ue to compare to is "20 30", then=20
+ /// this value must be changed to ['20','30']; (ReportToolsDoc)
+ ///</summary> =20
+ private string treatInSpecialCase(string where)
+ {
+ if(where =3D=3D "")
+ {
+ return ""; =20
+ }
+ string [] whereArr =3D where.Split(new char [] {'|',';'});
+ =20
+ for(int i=3D0;i<whereArr.Length;i++)
+ {
+ Logger.Log("whereArr" +"[" + Convert.ToString(i) + "]=3D=
" + whereArr[i],LogLevel.Trace);
+ }
+ =20
+ string newWhere=3D"";=20
+ for(int i=3D0;i<whereArr.Length;i+=3D5)
+ { =20
+ if(whereArr[i+1] =3D=3D "8") //In case
+ {
+ string [] inStrArr =3D whereArr[i+2].Split(new char =
[] {' ','\''});
+ //rebuild the where str
+ string whereValueStr =3D "";
+ whereValueStr +=3D "[(";
+ for(int j=3D0;j<inStrArr.Length;j++)=20
+ {
+ if(inStrArr[j] !=3D "") //Remove empty strings a=
fter split
+ whereValueStr +=3D "'" + inStrArr[j] + "'" +=
","; =20
+ }
+ whereValueStr =3D whereValueStr.Substring(0,whereVal=
ueStr.Length-1); //Remove last coma
+ whereValueStr +=3D")]";
+ =20
+ newWhere +=3D whereArr[0+i] + "|" + whereArr[1+i] + =
"|" + whereValueStr + "|" +whereArr[3+i] + "|" +whereArr[4+i] + ";";
+ }
+ else
+ {
+ newWhere +=3D whereArr[0+i] + "|" + whereArr[1+i] + =
"|" + whereArr[2+i] + "|" +whereArr[3+i] + "|" +whereArr[4+i] + ";";
+ }
+ }
+ newWhere =3D newWhere.Substring(0,newWhere.Length-1); //remo=
ve last ';'
+ Logger.Log("reportmain: treatInSpecialCase return=3D " + new=
Where, LogLevel.Trace);
+ return newWhere;
+ } =20
+ =20
+ private void ProcessCreationUpdate()
+ {
+ =20
+ Logger.Log("ReportMain: ProcessCreationUpdate", LogLevel.Tra=
ce);
+ =20
+ receivedClassId =3D Request["sendClassId"];
+ receivedReportName =3D Request["sendReportName"];
+ receivedColumnsStr =3D Request["sendColumnsStr"];
+ receivedOrderStr =3D Request["sendOrderStr"];
+ receivedWhereStr =3D Request["sendWhereStr"];
+ =20
+ Logger.Log("receivedClassId: " + receivedClassId, LogLevel.T=
race);
+ Logger.Log("receivedReportName: " + receivedReportName, LogL=
evel.Trace);
+ Logger.Log("receivedColumnsStr: " + receivedColumnsStr, LogL=
evel.Trace);
+ Logger.Log("receivedWhereStr: " + receivedWhereStr, LogLevel=
.Trace);
+
+ int reportId =3D Convert.ToInt32(Request.QueryString["report=
Id"]);
+ Logger.Log("reportId: " + reportId, LogLevel.Trace);
+ =20
+ //Creates the table now
+ DataTable reportTable =3D createReportTable();
+ if(reportTable !=3D null)=20
+ {=20
+ if(reportId =3D=3D 0)
+ {
+ //Response.Write("Create");
+ Logger.Log("Creation of report",LogLevel.Trace);
+ userCred.CoreAdapter.CreateReport(reportTable, userC=
red);
+ sendMessageToUser(UserMessage.CREATEVIEWOK); //Chang=
e
+ }
+ else=20
+ {
+ //Response.Write("Update");
+ Logger.Log("Update of report",LogLevel.Trace);
+ userCred.CoreAdapter.UpdateInstance(reportId, report=
Table, userCred);
+ sendMessageToUser(UserMessage.UPDATEVIEWOK); //Chang=
e
+ }
+ }=09
+ this.MyRedirect();
+ }
+
+ public void MyRedirect()
+ {
+ Response.Write("<script language=3D\"Javascript\">\n");
+ Response.Write("top.frames[1].mainframe.location =3D \"" + Html.genAb=
soluteUrl("/builder/site/functionindex.aspx") + "\";");
+ Response.Write("</script>\n");
+ }
+
+ // Funcion agregada por negro que solo traera la informacion necesaria=
...
+ private string formAttribList(int classId)=20
+ {
+ string salida=3D"";
+ int attlogin =3D 0;
+ int idatt =3D 0;
+ DataTable dtpert;
+ DataTable dtrel;
+ int idClassRel =3D 0;
+ string className =3D "";
+
+ DataTable dt =3D userCred.CoreAdapter.GetAttributesFromClass(classId)=
;
+
+ adapter dbAdapter =3D new adapter();
+ className =3D dbAdapter.GetClassNameById(classId);
+ //className =3D dt.Rows[0]["name"].ToString();
+
+ salida +=3D "<class>";
+ salida +=3D "<id>" + classId + "</id>";
+ salida +=3D "<name>" + className + "</name>";
+ salida +=3D "<attributes>";
+ =09
+ foreach(DataRow row in dt.Rows)=20
+ {
+ string attName =3D Convert.ToString(row["attName"]);
+ string attType =3D Convert.ToString(row["attType"]);
+ if(attType=3D=3D"pertinence")
+ {
+ idatt =3D Convert.ToInt32(row["id_entity"]);
+ dtpert =3D userCred.CoreAdapter.GetClassesFromPertinence(idatt);
+ DataRow dr2 =3D dtpert.Rows[0];
+ idClassRel =3D Convert.ToInt32(dr2["to"].ToString());
+ =09
+ //For each attribute of pertinence put the id with t=
ogo and=20
+ // the pertname.attname
+ int [] listAttId =3D getAttributeIdListForClass(idCl=
assRel);
+ string [] listAttName =3D getAttributeNameListForCla=
ss(idClassRel);
+ int size =3D listAttId.Length;
+ for(int i=3D0;i<size;i++)
+ {
+ attlogin =3D listAttId[i];
+ salida +=3D "<attribute>";
+ salida +=3D "<id>" + idatt + "^" + attlogin + "<=
/id>";
+ salida +=3D "<name>" + attName + "." + listAttN=
ame[i]+ "</name>";
+ salida +=3D "</attribute>";
+ }
+ }
+ else
+ {
+ salida +=3D "<attribute>";
+ salida +=3D "<id>" + row["id_entity"].ToString() + "</id>";
+ salida +=3D "<name>" + attName + "</name>";
+ salida +=3D "</attribute>";
+ }
+ }
+ salida +=3D "</attributes>";
+ salida +=3D "</class>";
+
+ foreach(DataRow row in dt.Select("attType=3D'pertinence'"))=20
+ {
+ idatt =3D Convert.ToInt32(row["id_entity"]);
+ dtpert =3D userCred.CoreAdapter.GetClassesFromPertinence(idatt);
+ =20
+
+ foreach(DataRow dr in dtpert.Rows)
+ {
+ idClassRel =3D Convert.ToInt32(dr["to"].ToString());
+ dtrel =3D userCred.CoreAdapter.GetAttributesFromClass(idClassRel);
+ className =3D dbAdapter.GetClassNameById(idClassRel);
+
+ salida +=3D "<class>";
+ salida +=3D "<id>" + idClassRel + "</id>";
+ salida +=3D "<name>" + className + "</name>";
+ salida +=3D "<attributes>";
+
+ foreach(DataRow row2 in dtrel.Rows)=20
+ {
+ string attName =3D Convert.ToString(row2["attName"]);
+ className =3D Convert.ToString(dr["name"]);
+ //res.Append("<option>"+className+":"+attName+"</option>");
+ salida +=3D "<attribute>";
+ salida +=3D "<id>" + idatt + "^" + row2["id_entity"].ToString() + =
"</id>";
+ salida +=3D "<name>" + className + "." + attName + "</name>";
+ salida +=3D "</attribute>";
+
+ }
+ salida +=3D "</attributes>";
+ salida +=3D "</class>";
+ }
+
+ }
+ =09
+ return salida;
+ }
+ =20
+ public int GetAttributePrimary(int idClass)
+ {
+ int iniClass;
+ DataTable dt1;
+ adapter dbAdapter =3D userCred.CoreAdapter;
+
+ //DataTable dtParam =3D myform.makeDataTableInReportTools();
+ DataTable dtParam =3D this.makeDataTableInViewTools();
+ DataRow dr =3D dtParam.NewRow();
+
+ //clase de los atributos.
+ iniClass =3D 5;
+
+ dr["columna"] =3D "0";
+
+
+ //Explicacion de los filtros...
+ //atributo 67|4|'true' =3D> isPrimary=3D'true'
+ //atributo 40|4|idClass =3D> classId=3DidClass
+ dr["filtros"] =3D "67|4|'true'|1|0;40|4|'"+idClass+"'|0|0";
+
+ dtParam.Rows.Add(dr);
+
+ dt1 =3D dbAdapter.GetDataTableView(dtParam, iniClass);
+ if(dt1.Rows.Count=3D=3D1)
+ {
+ return Convert.ToInt32(dt1.Rows[0][0].ToString());
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ =20
+ private DataTable makeDataTableInViewTools()
+ {
+ DataTable dt1 =3D new DataTable();
+ DataColumn dc1;
+ dc1 =3D new DataColumn("columna",typeof(string));
+ dt1.Columns.Add(dc1);
+ dc1 =3D new DataColumn("filtros",typeof(string));
+ dt1.Columns.Add(dc1);
+ dc1 =3D new DataColumn("group",typeof(string));
+ dt1.Columns.Add(dc1);
+ dc1 =3D new DataColumn("having",typeof(string));
+ dt1.Columns.Add(dc1);
+ dc1 =3D new DataColumn("order",typeof(string));
+ dt1.Columns.Add(dc1);
+ dc1 =3D new DataColumn("claves",typeof(string));
+ dt1.Columns.Add(dc1);
+ return dt1;
+ }
+
+ private DataTable createReportDataTable()
+ {
+ DataTable dt =3D new DataTable();
+ dt.Columns.Add("columns");
+ dt.Columns.Add("where");
+ dt.Columns.Add("groupby");
+ dt.Columns.Add("having");
+ dt.Columns.Add("order");
+ dt.Columns.Add("idClassReport");
+ dt.Columns.Add("reportName");
+ return dt;
+ }
+ =20
+ =20
+ ///<summary> The list of all attributes id for a class</summary>
+ private int[] getAttributeIdListForClass(int classId)
+ {
+ DataTable res =3D userCred.CoreAdapter.GetAttributesFromClas=
s(classId);
+ int [] idArr =3D new int[res.Rows.Count];
+ int i=3D0;
+ foreach(DataRow row in res.Rows)
+ {
+ idArr[i++] =3D Convert.ToInt32(row["id_entity"]);
+ }
+ =20
+ return idArr;
+ }
+ =20
+ ///<summary> The list of all attributes name for a class </summa=
ry>
+ private string[] getAttributeNameListForClass(int classId)
+ {
+ DataTable res =3D userCred.CoreAdapter.GetAttributesFromClas=
s(classId);
+ string [] nameArr =3D new string[res.Rows.Count];
+ int i=3D0;
+ foreach(DataRow row in res.Rows)
+ {
+ nameArr[i++] =3D Convert.ToString(row["attName"]);
+ }
+ return nameArr;
+ }
+ }
+}
Modified: humano2/trunk/web/builder/site/functionoperationbar.aspx
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/web/builder/site/functionoperationbar.aspx 2005-05-18 1=
9:23:33 UTC (rev 1089)
+++ humano2/trunk/web/builder/site/functionoperationbar.aspx 2005-05-18 1=
9:48:18 UTC (rev 1090)
@@ -32,6 +32,12 @@
var mainFrame =3D parent.frames["maindata"];
mainFrame.location.href =3D "foldermanagement.aspx";
}
+ =20
+ function CreateReport()
+ {
+ var mainFrame =3D parent.frames["maindata"];
+ mainFrame.location.href =3D "createreport.aspx";
+ }
=20
</script>
</HEAD>
@@ -42,6 +48,7 @@
<!--div id=3D"CreateRule"><a href=3D"#" onClick=3D"CreateRule()">Crea=
te Rule</a></div-->
<div id=3D"CreateForm"><a href=3D"#" onClick=3D"CreateForm()">Create =
Form</a></div>
<div id=3D"CreateFolder"><a href=3D"#" onClick=3D"CreateFolder()">Cre=
ate Folder</a></div>
+ <div id=3D"CreateReport"><a href=3D"#" onClick=3D"CreateRepo=
rt()">Create Report</a></div>
</div>
<form id=3D"Form1" method=3D"post" runat=3D"server">
<input id=3D"classId2" name=3D"classId2" type=3D"hidden">=20
Deleted: humano2/trunk/web/builder/site/js/form.js
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/web/builder/site/js/form.js 2005-05-18 19:23:33 UTC (re=
v 1089)
+++ humano2/trunk/web/builder/site/js/form.js 2005-05-18 19:48:18 UTC (re=
v 1090)
@@ -1,442 +0,0 @@
-/*
-//
-// The Humano2 Business solution.
-// Copyright (C) 2004,5 Humano2 Chile S.A. (http://www.humano2.com)
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version. =20
-//
-//
-*/
-
-
-/**
- * When you choose a class you have to update the buttons Crud
- */
-function UpdateHeader()
-{
- //Update crudbuttons =20
- var crudTag1 =3D GetNodeByTagNameAndAttName("div","CrudButtons1")[0]=
;
- =20
- crudTag1.innerHTML=3D
- "<input type=3D\"submit\" value=3D\"Create\" onclick=3D=
\"Form.UpdateSubmitAll(rightColumn,expandFormSort,expandFormFilter);\">"
- + "</input>";
- =20
- var crudTag2 =3D GetNodeByTagNameAndAttName("div","CrudButtons2")[0]=
;
- //alert("crudTag2: " + crudTag2);
- crudTag2.innerHTML =3D ""; //No delete button
- =20
- =20
- //update input viewname =20
- var viewNameDiv =3D GetNodeByTagNameAndAttName("div","ViewName")[0];
- viewNameDiv.innerHTML =3D=20
- "<input type=3D\"text\" id=3D \"viewNameInput\" name=3D\"vie=
wNameInput\">"
- +"</input>";
-}
-
-
-//////////////////////////////////////////////ViewParams Class /////////=
//////////////////////////////////////////////
-function ViewParams(columns,where,order)
-{
- =20
- //Fields
- this.columns =3D columns;
- this.where =3D where;
- this.order =3D order;
-
- //alert("columns.length: " + columns.length);
- =20
- //Methods
- this.GetColumns =3D ViewParamsGetColumns;
- this.GetWhere =3D ViewParamsGetWhere;
- this.GetOrder =3D ViewParamsGetOrder;
- this.Empty =3D ViewParamsEmpty;
-=20
-}
-
-function ViewParamsEmpty()
-{
- var res =3D ((this.GetColumns().length =3D=3D 0) && (this.where =3D=3D=
null) && (this.order =3D=3D null));
- //alert("ViewParamsEmpty: " + res);
- return res;
-}
-
-function ViewParamsGetColumns()
-{
- //Jump the first unuseful element (0,10035,10025) for example
- var res =3D new Array()
- for(i=3D1;i<this.columns.length;i++)
- {
- res[i-1] =3D this.columns[i]; =20
- }
- //alert("ViewParamsGetColumns: length=3D " + res.length);
- return res;
-}
-
-function ViewParamsGetWhere()
-{
- return this.where; =20
-}
-
-function ViewParamsGetOrder()
-{
- return this.order; =20
-}
-
-
-////////////////////////////////////////////// Form Class //////////////=
///////////////////////////////////////////////
-function Form(formArray, classId, ViewParams)
-{
- //Fields
- this.attributeLeftArray =3D new Array();
- this.attributeRightArray =3D new Array();
- this.formArray =3D formArray;
- this.classId =3D classId;
- this.ViewParams =3D ViewParams;
- =20
- =20
- //Methods
- this.UpdateAttributes =3D FormUpdateAttributes;
- this.GetRightAtt =3D FormGetRightAtt;
- this.GetLeftAtt =3D FormGetLeftAtt;
- this.UpdateList =3D FormUpdateList;
- this.UpdateLists =3D FormUpdateLists;
- this.SetToDefault =3D FormSetToDefault;
- this.UpdateSubmitAll =3D FormUpdateSubmitAll;
- this.DeleteView =3D FormDeleteView;
- this.GetSortArray =3D FormGetSortArray;
- this.GetFilterArray =3D FormGetFilterArray;
- this.UpdateSort =3D FormUpdateSort;
- this.UpdateFilter =3D FormUpdateFilter;
- this.GetNameOfAttribute =3D FormGetNameOfAttribute;
- =20
- //Update the attributes
- this.UpdateAttributes(this.classId);
-}
-
-function FormUpdateSubmitAll(rightColumn,sort,filter)
-{
- //Get the viewName
- var viewNameInput =3D GetNodeByTagNameAndAttName("input","viewNameIn=
put")[0];
- var viewName =3D viewNameInput.value;
- =20
- if(viewName =3D=3D "")
- {
- alert("You must enter the name of view."); =20
- return false;
- }
- =20
- //alert("viewName:" + viewName);
- =20
- //Get the classId
- var classId =3D this.classId;
- //alert("classId:" + classId);
- =20
- //Build the columnstr string
- //alert(rightColumn);
- var i;
- var sortedList =3D rightColumn.fSortedList;
- //alert(sortedList.Length());
- var columnsStr =3D "";
- for(i=3D0;i<sortedList.Length();i++)
- {
- columnsStr +=3D sortedList.GetItem(i).GetValue() + ",";
- }
- //Remove the last coma
- columnsStr =3D "0," + columnsStr; //Don't forget 0!
- columnsStr =3D columnsStr.substring(0,columnsStr.length-1); =
=20
- //alert("columnsStr:" + columnsStr);
- =20
- //Now the sort
- //alert("sort SelfRefName:" + sort.GetSelfRefName());
- =20
- //TODO: order is unavailable yet due to a problem in ViewTools
- var orderStr =3D sort.ReturnValues();=20
- //var orderStr=3D"";
- =20
- //The filter
- //alert("filter SelfRefName:" + filter.GetSelfRefName());
- var whereStr =3D filter.ReturnValues();
- =20
- //Update the submit all TD
- var divSubmitAll =3D GetNodeByTagNameAndAttName("div","SubmitAll")[0=
];
- //alert(divSubmitAll);
- divSubmitAll.innerHTML +=3D=20
- =20
- "<input type=3D\"hidden\" name=3D\"sendCreateUpdate\" value=3D\"=
true\"></input>"
- +"<input type=3D\"hidden\" name=3D\"sendClassId\" value=3D\""+ c=
lassId +"\"></input>"
- +"<input type=3D\"hidden\" name=3D\"sendViewName\" value=3D\"" +=
viewName + "\"></input>"
- +"<input type=3D\"hidden\" name=3D\"sendColumnsStr\" value=3D\""=
+ columnsStr + "\"></input>"
- +"<input type=3D\"hidden\" name=3D\"sendOrderStr\" value=3D\"" +=
orderStr + "\"></input>"
- +"<input type=3D\"hidden\" name=3D\"sendWhereStr\" value=3D\"" +=
whereStr + "\"></input>";
- =20
- //alert(divSubmitAll.innerHTML);
- return true;
-}
-
-function FormDeleteView(viewId)
-{
- if (confirm("Are you sure you want to delete the view?"))
- {
- var divSubmitAll =3D GetNodeByTagNameAndAttName("div","SubmitAll=
")[0];
- //alert(divSubmitAll);
- divSubmitAll.innerHTML +=3D "<input type=3D\"hidden\" name=3D=
\"delete\" value=3D\"true\"></input>";
- divSubmitAll.innerHTML +=3D "<input type=3D\"hidden\" name=3D=
\"viewId\" value=3D\"" + viewId + "\"></input>";
- return true; =20
- }
- else
- {
- return false; =20
- }
-}
-
-function FormGetRightAtt()
-{
- return this.attributeRightArray;
-}
-
-function FormGetLeftAtt()
-{
- return this.attributeLeftArray;
-}
-
-function FormUpdateList(list,classId,leftOrRight)
-{
- =20
- this.classId =3D classId; //stores classId
- this.UpdateAttributes(classId);
- =20
- var updateArray;
- if(leftOrRight =3D=3D "left")
- {
- updateArray =3D this.attributeLeftArray;
- }
- else
- {
- updateArray =3D this.attributeRightArray; =20
- }
- =20
- list.Set(updateArray);
-}
-
-function FormUpdateLists(left,right,classId)
-{
- this.UpdateList(left,classId,"left");
- this.UpdateList(right,classId,"right");
-}
-
-function FormSetToDefault(left,right)
-{
- this.UpdateLists(left,right,this.classId); =20
-}
-
-function FormGetSortArray(number)
-{
- var optionArray =3D new Array();
- =20
- if(number =3D=3D 1) // The attributes
- {
- var lengthArray =3D this.formArray[this.classId].length;
- //alert("lengthArray: " + lengthArray);
- =20
- optionArray[0] =3D new Array(); //Begin to second element
- optionArray[0]["value"] =3D "-1";
- optionArray[0]["text"] =3D "--Nothing--";
- =20
- for (var i =3D 0; i < lengthArray ;i++)
- {
- optionArray[i+1] =3D new Array(); //Begin to second element
- optionArray[i+1]["value"] =3D this.formArray[this.classId][i=
]["value"];
- optionArray[i+1]["text"] =3D this.formArray[this.classId][i=
]["name"];
- }
- }
- else // Asc Desc etc...
- {
- optionArray[0] =3D new Array();
- optionArray[0]["value"] =3D "-1";
- optionArray[0]["text"] =3D "--Nothing--";
- optionArray[1] =3D new Array();
- optionArray[1]["value"] =3D "0";
- optionArray[1]["text"] =3D "Ascendent";
- optionArray[2] =3D new Array();
- optionArray[2]["value"] =3D "1";
- optionArray[2]["text"] =3D "Descendent";
- }
- return optionArray;
-}
-
-
-function FormGetFilterArray(number)
-{
- var optionArray =3D new Array();
- =20
- if(number =3D=3D 1) // The attributes (as for sort)
- {
- var lengthArray =3D this.formArray[this.classId].length;
- //alert("lengthArray: " + lengthArray);
- =20
- optionArray[0] =3D new Array();
- optionArray[0]["value"] =3D "-1";
- optionArray[0]["text"] =3D "--Nothing--"
- for (var i =3D 0; i < lengthArray ;i++)=20
- {
- optionArray[i+1] =3D new Array(); //Begin to second element
- optionArray[i+1]["value"] =3D this.formArray[this.classId][i=
]["value"];
- optionArray[i+1]["text"] =3D this.formArray[this.classId][i=
]["name"];
- }
- }
- else // Asc Desc etc...
- {
- optionArray[0] =3D new Array();
- optionArray[0]["value"] =3D "-1";
- optionArray[0]["text"] =3D "--Nothing--";
- optionArray[1] =3D new Array();
- optionArray[1]["value"] =3D "0";
- optionArray[1]["text"] =3D "GreaterOrEqualThan";
- optionArray[2] =3D new Array();
- optionArray[2]["value"] =3D "1";
- optionArray[2]["text"] =3D "LessEqualThan";
- optionArray[3] =3D new Array();
- optionArray[3]["value"] =3D "2";
- optionArray[3]["text"] =3D "GreaterThan";
- optionArray[4] =3D new Array();
- optionArray[4]["value"] =3D "3";
- optionArray[4]["text"] =3D "LessThan";
- optionArray[5] =3D new Array();
- optionArray[5]["value"] =3D "4";
- optionArray[5]["text"] =3D "EqualTo";
- optionArray[6] =3D new Array();
- optionArray[6]["value"] =3D "5";
- optionArray[6]["text"] =3D "DistinctTo";
- optionArray[7] =3D new Array();
- optionArray[7]["value"] =3D "6";
- optionArray[7]["text"] =3D "BeginWith";
- optionArray[8] =3D new Array();
- optionArray[8]["value"] =3D "7";
- optionArray[8]["text"] =3D "ContainsTo";
- optionArray[9] =3D new Array();
- optionArray[9]["value"] =3D "8";
- optionArray[9]["text"] =3D "In";
- =20
- }
- =20
- return optionArray;
-}
-
-function FormUpdateSort(sort,classId)
-{
- this.classId =3D classId;
- sort.Update(this.GetSortArray(1),this.GetSortArray(2)); //TODO: sort=
doesn't work yet
-}
-
-function FormUpdateFilter(filter,classId)
-{
- this.classId =3D classId;
- filter.Update(this.GetFilterArray(1),this.GetFilterArray(2)); =20
-}
-
-function FormUpdateAttributes(classId)
-{
- //alert(classId);
- this.classId =3D classId; //stores classId
- this.attributeLeftArray =3D new Array();
- this.attributeRightArray =3D new Array();
- =20
- if(this.ViewParams.Empty() =3D=3D true) //In the case of creation of=
a class
- {
- =20
- //For the columns
- var maxAttNumber =3D this.formArray[classId].length;
- if(maxAttNumber < 3)
- {
- maxAttNumber =3D 0; =20
- }
- else
- {
- maxAttNumber =3D 3;
- }
- =20
- for (var i =3D 0; i < maxAttNumber ;i++)
- {
- var element =3D new ListElement( this.formArray[classId][i]=
["name"],
- this.formArray[classId][i]["=
value"],
- false);
- this.attributeRightArray[i] =3D element; =
=20
- }
- =20
- for (var i =3D 0; i < this.formArray[classId].length ;i++)
- {
- if(i<maxAttNumber)
- {
- var element =3D new ListElement( this.formArray[classId=
][i]["name"],
- this.formArray[classId][=
i]["value"],
- true);
- =20
- }
- else
- {
- var element =3D new ListElement( this.formArray[classId=
][i]["name"],
- this.formArray[classId][=
i]["value"],
- false);
- }
- this.attributeLeftArray[i] =3D element; =
=20
- }
- =20
- }
- else //In the case of update of a class
- {
- var j=3D0; //the counter for rightArray
- for(var i=3D0; i<this.formArray[classId].length;i++)
- {
- var idAttForm =3D this.formArray[classId][i]["value"];
- if(IsInArray(idAttForm,this.ViewParams.GetColumns()) =3D=3D =
true) //If the attribute is in the view
- {
- =20
- =20
- //The left array
- var element =3D new ListElement( this.formArray[classId=
][i]["name"],
- this.formArray[classId][=
i]["value"],
- true);
- this.attributeLeftArray[i] =3D element; =20
- //The right array: the element
- var element =3D new ListElement( this.formArray[classId=
][i]["name"],
- this.formArray[classId][=
i]["value"],
- false);
- this.attributeRightArray[j++] =3D element; =
=20
- =20
- }
- else
- {
- var element =3D new ListElement( this.formArray[classId=
][i]["name"],
- this.formArray[classId][=
i]["value"],
- false);
- //The left array
- this.attributeLeftArray[i] =3D element; =20
- =20
- //The right array: nothing
- =20
- }
- }
- }
-}
-
-
-/**
- * Returns the name of attribute give its id
- */
-function FormGetNameOfAttribute(idAtt)
-{
- for(i=3D0;i<this.formArray[classId].length;i++)
- {
- var elTab =3D this.formArray[classId][i];
- if(idAtt =3D=3D elTab["value"])
- {
- return elTab["name"];
- }
- }
- return "";
-}
-
-////////////////////////////////////////////// END: Form Class /////////=
////////////////////////////////////////////////
Added: humano2/trunk/web/builder/site/js/formreport.js
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/web/builder/site/js/formreport.js 2005-05-18 19:23:33 U=
TC (rev 1089)
+++ humano2/trunk/web/builder/site/js/formreport.js 2005-05-18 19:48:18 U=
TC (rev 1090)
@@ -0,0 +1,442 @@
+/*
+//
+// The Humano2 Business solution.
+// Copyright (C) 2004,5 Humano2 Chile S.A. (http://www.humano2.com)
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version. =20
+//
+//
+*/
+
+
+/**
+ * When you choose a class you have to update the buttons Crud
+ */
+function UpdateHeader()
+{
+ //Update crudbuttons =20
+ var crudTag1 =3D GetNodeByTagNameAndAttName("div","CrudButtons1")[0]=
;
+ =20
+ crudTag1.innerHTML=3D
+ "<input type=3D\"submit\" value=3D\"Create\" onclick=3D=
\"Form.UpdateSubmitAll(rightColumn,expandFormSort,expandFormFilter);\">"
+ + "</input>";
+ =20
+ var crudTag2 =3D GetNodeByTagNameAndAttName("div","CrudButtons2")[0]=
;
+ //alert("crudTag2: " + crudTag2);
+ crudTag2.innerHTML =3D ""; //No delete button
+ =20
+ =20
+ //update input reportname =20
+ var reportNameDiv =3D GetNodeByTagNameAndAttName("div","ReportName")=
[0];
+ reportNameDiv.innerHTML =3D=20
+ "<input type=3D\"text\" id=3D \"reportNameInput\" name=3D\"r=
eportNameInput\">"
+ +"</input>";
+}
+
+
+//////////////////////////////////////////////ReportParams Class ///////=
////////////////////////////////////////////////
+function ReportParams(columns,where,order)
+{
+ =20
+ //Fields
+ this.columns =3D columns;
+ this.where =3D where;
+ this.order =3D order;
+
+ //alert("columns.length: " + columns.length);
+ =20
+ //Methods
+ this.GetColumns =3D ReportParamsGetColumns;
+ this.GetWhere =3D ReportParamsGetWhere;
+ this.GetOrder =3D ReportParamsGetOrder;
+ this.Empty =3D ReportParamsEmpty;
+=20
+}
+
+function ReportParamsEmpty()
+{
+ var res =3D ((this.GetColumns().length =3D=3D 0) && (this.where =3D=3D=
null) && (this.order =3D=3D null));
+ //alert("ReportParamsEmpty: " + res);
+ return res;
+}
+
+function ReportParamsGetColumns()
+{
+ //Jump the first unuseful element (0,10035,10025) for example
+ var res =3D new Array()
+ for(i=3D1;i<this.columns.length;i++)
+ {
+ res[i-1] =3D this.columns[i]; =20
+ }
+ //alert("ReportParamsGetColumns: length=3D " + res.length);
+ return res;
+}
+
+function ReportParamsGetWhere()
+{
+ return this.where; =20
+}
+
+function ReportParamsGetOrder()
+{
+ return this.order; =20
+}
+
+
+////////////////////////////////////////////// Form Class //////////////=
///////////////////////////////////////////////
+function Form(formArray, classId, ReportParams)
+{
+ //Fields
+ this.attributeLeftArray =3D new Array();
+ this.attributeRightArray =3D new Array();
+ this.formArray =3D formArray;
+ this.classId =3D classId;
+ this.ReportParams =3D ReportParams;
+ =20
+ =20
+ //Methods
+ this.UpdateAttributes =3D FormUpdateAttributes;
+ this.GetRightAtt =3D FormGetRightAtt;
+ this.GetLeftAtt =3D FormGetLeftAtt;
+ this.UpdateList =3D FormUpdateList;
+ this.UpdateLists =3D FormUpdateLists;
+ this.SetToDefault =3D FormSetToDefault;
+ this.UpdateSubmitAll =3D FormUpdateSubmitAll;
+ this.DeleteReport =3D FormDeleteReport;
+ this.GetSortArray =3D FormGetSortArray;
+ this.GetFilterArray =3D FormGetFilterArray;
+ this.UpdateSort =3D FormUpdateSort;
+ this.UpdateFilter =3D FormUpdateFilter;
+ this.GetNameOfAttribute =3D FormGetNameOfAttribute;
+ =20
+ //Update the attributes
+ this.UpdateAttributes(this.classId);
+}
+
+function FormUpdateSubmitAll(rightColumn,sort,filter)
+{
+ //Get the ReportName
+ var reportNameInput =3D GetNodeByTagNameAndAttName("input","reportNa=
meInput")[0];
+ var reportName =3D reportNameInput.value;
+ =20
+ if(reportName =3D=3D "")
+ {
+ alert("You must enter the name of report."); =20
+ return false;
+ }
+ =20
+ //alert("reportName:" + reportName);
+ =20
+ //Get the classId
+ var classId =3D this.classId;
+ //alert("classId:" + classId);
+ =20
+ //Build the columnstr string
+ //alert(rightColumn);
+ var i;
+ var sortedList =3D rightColumn.fSortedList;
+ //alert(sortedList.Length());
+ var columnsStr =3D "";
+ for(i=3D0;i<sortedList.Length();i++)
+ {
+ columnsStr +=3D sortedList.GetItem(i).GetValue() + ",";
+ }
+ //Remove the last coma
+ columnsStr =3D "0," + columnsStr; //Don't forget 0!
+ columnsStr =3D columnsStr.substring(0,columnsStr.length-1); =
=20
+ //alert("columnsStr:" + columnsStr);
+ =20
+ //Now the sort
+ //alert("sort SelfRefName:" + sort.GetSelfRefName());
+ =20
+ =20
+ var orderStr =3D sort.ReturnValues();=20
+ =20
+ =20
+ //The filter
+ //alert("filter SelfRefName:" + filter.GetSelfRefName());
+ var whereStr =3D filter.ReturnValues();
+ =20
+ //Update the submit all TD
+ var divSubmitAll =3D GetNodeByTagNameAndAttName("div","SubmitAll")[0=
];
+ //alert(divSubmitAll);
+ divSubmitAll.innerHTML +=3D=20
+ =20
+ "<input type=3D\"hidden\" name=3D\"sendCreateUpdate\" value=3D\"=
true\"></input>"
+ +"<input type=3D\"hidden\" name=3D\"sendClassId\" value=3D\""+ c=
lassId +"\"></input>"
+ +"<input type=3D\"hidden\" name=3D\"sendReportName\" value=3D\""=
+ reportName + "\"></input>"
+ +"<input type=3D\"hidden\" name=3D\"sendColumnsStr\" value=3D\""=
+ columnsStr + "\"></input>"
+ +"<input type=3D\"hidden\" name=3D\"sendOrderStr\" value=3D\"" +=
orderStr + "\"></input>"
+ +"<input type=3D\"hidden\" name=3D\"sendWhereStr\" value=3D\"" +=
whereStr + "\"></input>";
+ =20
+ //alert(divSubmitAll.innerHTML);
+ return true;
+}
+
+function FormDeleteReport(reportId)
+{
+ if (confirm("Are you sure you want to delete the report?"))
+ {
+ var divSubmitAll =3D GetNodeByTagNameAndAttName("div","SubmitAll=
")[0];
+ //alert(divSubmitAll);
+ divSubmitAll.innerHTML +=3D "<input type=3D\"hidden\" name=3D=
\"delete\" value=3D\"true\"></input>";
+ divSubmitAll.innerHTML +=3D "<input type=3D\"hidden\" name=3D=
\"reportId\" value=3D\"" + reportId + "\"></input>";
+ return true; =20
+ }
+ else
+ {
+ return false; =20
+ }
+}
+
+function FormGetRightAtt()
+{
+ return this.attributeRightArray;
+}
+
+function FormGetLeftAtt()
+{
+ return this.attributeLeftArray;
+}
+
+function FormUpdateList(list,classId,leftOrRight)
+{
+ =20
+ this.classId =3D classId; //stores classId
+ this.UpdateAttributes(classId);
+ =20
+ var updateArray;
+ if(leftOrRight =3D=3D "left")
+ {
+ updateArray =3D this.attributeLeftArray;
+ }
+ else
+ {
+ updateArray =3D this.attributeRightArray; =20
+ }
+ =20
+ list.Set(updateArray);
+}
+
+function FormUpdateLists(left,right,classId)
+{
+ this.UpdateList(left,classId,"left");
+ this.UpdateList(right,classId,"right");
+}
+
+function FormSetToDefault(left,right)
+{
+ this.UpdateLists(left,right,this.classId); =20
+}
+
+function FormGetSortArray(number)
+{
+ var optionArray =3D new Array();
+ =20
+ if(number =3D=3D 1) // The attributes
+ {
+ var lengthArray =3D this.formArray[this.classId].length;
+ //alert("lengthArray: " + lengthArray);
+ =20
+ optionArray[0] =3D new Array(); //Begin to second element
+ optionArray[0]["value"] =3D "-1";
+ optionArray[0]["text"] =3D "--Nothing--";
+ =20
+ for (var i =3D 0; i < lengthArray ;i++)
+ {
+ optionArray[i+1] =3D new Array(); //Begin to second element
+ optionArray[i+1]["value"] =3D this.formArray[this.classId][i=
]["value"];
+ optionArray[i+1]["text"] =3D this.formArray[this.classId][i=
]["name"];
+ }
+ }
+ else // Asc Desc etc...
+ {
+ optionArray[0] =3D new Array();
+ optionArray[0]["value"] =3D "-1";
+ optionArray[0]["text"] =3D "--Nothing--";
+ optionArray[1] =3D new Array();
+ optionArray[1]["value"] =3D "0";
+ optionArray[1][...
[truncated message content] |