|
From: <sv...@de...> - 2005-05-19 21:51:01
|
Author: pcamacho
Date: 2005-05-19 17:50:56 -0400 (Thu, 19 May 2005)
New Revision: 1106
Modified:
humano2/trunk/web/builder/site/createreport.aspx.cs
humano2/trunk/web/builder/site/js/createreport.js
humano2/trunk/web/builder/site/js/formreport.js
humano2/trunk/web/builder/site/xsl/createreport.xsl
Log:
ADD: basic interface for creattion of reports: with groupby and selection=
of functions to apply to attributes.=09
Modified: 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-19 21:06:=
59 UTC (rev 1105)
+++ humano2/trunk/web/builder/site/createreport.aspx.cs 2005-05-19 21:50:=
56 UTC (rev 1106)
@@ -41,6 +41,7 @@
private string receivedColumnsStr; =20
private string receivedWhereStr;
private string receivedOrderStr;
+ private string receivedPersoColumnsStr;
=20
private void Page_Load(object sender, System.EventArgs e)
{
@@ -152,30 +153,59 @@
=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 getReportColumnsXml((dt.Rows[0]["groupby"]).ToStrin=
g()); // The columns for a report are in groupby
+ res +=3D getReportPersoColumnsXml((dt.Rows[0]["columns"]).To=
String()); //Here are the functions
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
+ =20
+ private string getReportPersoColumnsXml(string columns)
+ {
+ string [] allColumns =3D columns.Split(new char[] {','});
+ string xmlRes =3D "";
+ =20
+ xmlRes +=3D "<persoColumns>";
+ for(int i=3D0;i<allColumns.Length;i++)
+ {
+ string [] columnValues =3D allColumns[i].Split("|".ToCha=
rArray());
+ string idAtt =3D "";
+ string op =3D "";
+ string [] columnsList =3D getColumnsList();
+ =20
+ if(columnValues.Length >=3D2) //Only take attributes wit=
h functions
+ {
+ op =3D columnValues[1];//No need to move index (+1) =
because the op functions start with num 1 and not 0
+ idAtt =3D Convert.ToString(Convert.ToInt32(getIndexO=
fElement(columnValues[0],columnsList)) + 1); // idem
+ =20
+ xmlRes +=3D"<persoColumn>";
+ xmlRes +=3D "<idAtt>" + idAtt + "</idAtt>";
+ xmlRes +=3D "<op>" + op + "</op>";
+ xmlRes +=3D "</persoColumn>";
+ }
+ }
+ xmlRes +=3D "</persoColumns>";
+ =20
+ return xmlRes;
+ }
+ =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>";
+ =20
+ //Add the column with id attribute 0 to be coherent with the=
interface of showview
+ xmlRes +=3D"<column>";
+ xmlRes +=3D "0";
+ xmlRes +=3D "</column>";
+ =20
for(int i=3D0;i<allColumns.Length;i++)
{
xmlRes +=3D"<column>";
@@ -219,7 +249,6 @@
xmlRes +=3D "</condition>";
}
xmlRes +=3D "</conditions>";
- =20
return xmlRes;
}
=20
@@ -422,11 +451,13 @@
//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
+ dr["groupby"] =3D receivedColumnsStr; //The columns selected=
by user are to put in group by
=20
//Special case for IN filter
dr["where"] =3D parseWhere(receivedWhereStr);
=20
+ dr["columns"] =3D buildColumnsForReport(receivedPersoColumns=
Str,dr["groupby"].ToString()); //
+ =20
dr["order"] =3D parseOrder(receivedOrderStr);
Logger.Log("receivedOrderStr" + receivedOrderStr, LogLevel.T=
race);
Logger.Log("receivedWhereStr" + receivedWhereStr, LogLevel.T=
race);
@@ -437,15 +468,54 @@
}
=20
=20
+ ///<summary>
+ /// The persoCol string comes from the web in this format idAtt0=
|idFunc0;idAtt1|idFunc1; ...
+ /// It has to be converted to:=20
+ /// idAtt0|idFunc0, idAtt1|idFunc1; etc...=20
+ /// So we only have to replace ; for ,
+ ///</summary>
+ private string parsePersoColumns(string persoCol)
+ {
+ if((persoCol!=3D null) && (persoCol.Length >0))
+ {
+ return persoCol.Replace(";",",");
+ }
+ else
+ {
+ return ""; =20
+ }
+ =20
+ }
=20
///<summary>
+ /// The user selects columns to display and columns to group by
+ /// The final list of columns to display are the selected column=
s more the grouby columns
+ ///</summary>
+ private string buildColumnsForReport(string persoColumns, string=
groupByColumns)
+ {
+ string res =3D "";
+ string persoColumnsParsed =3D parsePersoColumns(persoColumns=
);
+ if((persoColumnsParsed.Length > 0) && (groupByColumns.Length=
> 0))
+ {
+ res =3D persoColumnsParsed + "," +groupByColumns;
+ }
+ else //One of the two string at least is empty
+ {
+ res =3D persoColumnsParsed + groupByColumns;
+ }
+ =20
+ Logger.Log("buildColumnsForReport: " + res,LogLevel.Trace);
+ =20
+ return res;
+ }
+ =20
+ ///<summary>
/// A order string is received from the web page in this format:
/// idAtt0 | 0 or 1,idAtt1 | 0 or 1 etc...
/// We have to add the queue to each where condition (1|0 or 0|0=
)
///</summary>
private string parseOrder(string order) =20
{
- =20
if(order=3D=3D"")
{
return ""; =20
@@ -578,11 +648,13 @@
receivedColumnsStr =3D Request["sendColumnsStr"];
receivedOrderStr =3D Request["sendOrderStr"];
receivedWhereStr =3D Request["sendWhereStr"];
+ receivedPersoColumnsStr =3D Request["sendPersoColumnsStr"]; =
=20
=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);
+ Logger.Log("receivedPersoColumnsStr " + receivedPersoColumns=
Str, LogLevel.Trace);
=20
int reportId =3D Convert.ToInt32(Request.QueryString["report=
Id"]);
Logger.Log("reportId: " + reportId, LogLevel.Trace);
Modified: humano2/trunk/web/builder/site/js/createreport.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/createreport.js 2005-05-19 21:06:59=
UTC (rev 1105)
+++ humano2/trunk/web/builder/site/js/createreport.js 2005-05-19 21:50:56=
UTC (rev 1106)
@@ -84,3 +84,20 @@
=20
return optionArray;
}
+
+function PersoColumnsGetSelect1Arr()
+{
+ var optionArray =3D new Array();
+
+ optionArray[0] =3D new Array();
+ optionArray[0]["value"] =3D "-1";
+ optionArray[0]["text"] =3D "--Nothing--";
+ optionArray[1] =3D new Array();
+ optionArray[1]["value"] =3D "1";
+ optionArray[1]["text"] =3D "Count";
+ optionArray[2] =3D new Array();
+ optionArray[2]["value"] =3D "2";
+ optionArray[2]["text"] =3D "Sum";
+ =20
+ return optionArray;
+}
Modified: 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-19 21:06:59 U=
TC (rev 1105)
+++ humano2/trunk/web/builder/site/js/formreport.js 2005-05-19 21:50:56 U=
TC (rev 1106)
@@ -19,7 +19,7 @@
this.columns =3D columns;
this.where =3D where;
this.order =3D order;
-
+ =20
//alert("columns.length: " + columns.length);
=20
//Methods
@@ -86,7 +86,7 @@
this.UpdateAttributes(this.classId);
}
=20
-function FormUpdateSubmitAll(rightColumn,sort,filter)
+function FormUpdateSubmitAll(rightColumn,sort,filter,persoColumns)
{
//Get the ReportName
var reportNameInput =3D GetNodeByTagNameAndAttName("input","reportNa=
meInput")[0];
@@ -115,7 +115,7 @@
columnsStr +=3D sortedList.GetItem(i).GetValue() + ",";
}
//Remove the last coma
- columnsStr =3D "0," + columnsStr; //Don't forget 0!
+ columnsStr =3D columnsStr;=20
columnsStr =3D columnsStr.substring(0,columnsStr.length-1); =
=20
//alert("columnsStr:" + columnsStr);
=20
@@ -128,6 +128,8 @@
//alert("filter SelfRefName:" + filter.GetSelfRefName());
var whereStr =3D filter.ReturnValues();
=20
+ var persoColumnsStr =3D persoColumns.ReturnValues();
+ //alert("persoColumnsStr: " + persoColumnsStr);
//Update the submit all TD
var divSubmitAll =3D GetNodeByTagNameAndAttName("div","SubmitAll")[0=
];
//alert(divSubmitAll);
@@ -138,7 +140,8 @@
+"<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>";
+ +"<input type=3D\"hidden\" name=3D\"sendWhereStr\" value=3D\"" +=
whereStr + "\"></input>"
+ +"<input type=3D\"hidden\" name=3D\"sendPersoColumnsStr\" value=3D=
\"" + persoColumnsStr + "\"></input>";
=20
//alert(divSubmitAll.innerHTML);
return true;
Modified: humano2/trunk/web/builder/site/xsl/createreport.xsl
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=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/xsl/createreport.xsl 2005-05-19 21:06:=
59 UTC (rev 1105)
+++ humano2/trunk/web/builder/site/xsl/createreport.xsl 2005-05-19 21:50:=
56 UTC (rev 1106)
@@ -122,6 +122,34 @@
</xsl:if>
=20
=20
+ //Personalized columns
+ var selectOption0ArrayPersoColumns =3D new Array();
+ var selectOption1ArrayPersoColumns =3D new Array();
+ var i=3D0;
+ <xsl:for-each select=3D"/report/reportDatas/reportParams/per=
soColumns/persoColumn">
+ selectOption0ArrayPersoColumns[i] =3D <xsl:value-of sel=
ect=3D"idAtt" />;
+ selectOption1ArrayPersoColumns[i] =3D <xsl:value-of sel=
ect=3D"op" />;
+ i++;
+ </xsl:for-each>
+ =20
+ <xsl:if test=3D"/report/reportDatas/classId!=3D''">
+ var InputLineParamsPersoColumns =3D
+ {
+ type: 'TWOSELECT', //For the moment
+ select0: AttribsGetSelect0Arr(formArray,<xsl:value-o=
f select=3D"/report/reportDatas/classId" />),
+ select1: PersoColumnsGetSelect1Arr(),
+ lineTitle: 'PersoCol',
+ input0: '',
+ PreselectedInput0: null,
+ PreselectedSelect0: selectOption0ArrayPersoColumns, =
//For the moment
+ PreselectedSelect1: selectOption1ArrayPersoColumns, =
//For the moment
+ refName: 'expandFormPersoColumns'
+ }
+ var InputLinePersoColumns =3D new InputLine(InputLinePar=
amsPersoColumns);
+ </xsl:if>
+ =20
+ =20
+ =20
function recargar()
{
<![CDATA[
@@ -308,19 +336,57 @@
</tr>
<!-- ######################## End filter=
s ######################################## -->
=20
+ <!--######################### Perso Colu=
mns ################################## -->
+ <tr>
+ <td colspan=3D"2">
+ <table width=3D"100%" border=3D"=
0" cellSpacing=3D"0" cellPadding=3D"0">
+ <tr>
+ <td width=3D"100%" colspan=3D=
"2" class=3D"lev1divider">
+ <div class=3D"lev1divide=
r"><IMG height=3D"9" src=3D"clear2x2.gif" width=3D"100%"/></div>
+ </td>
+ </tr>
+ <tr>
+ <td class=3D"lev1head" valig=
n=3D"top"><font size=3D"2">Personalized columns...</font></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <tr>
+ <td class=3D"smallgraytextnolink" co=
lspan=3D"2">
+ <table>
+ <tr>
+ <td>
+ <div id=3D"PersoColu=
mns">
+ </div>
+ </td>
+ </tr>
+ </table>
+ <script language=3D"Javascript">
+ var divPersoColumns =3D GetN=
odeByTagNameAndAttName("div","PersoColumns")[0];
+ var expandFormPersoColumns =3D=
new ExpandForm("expandFormPersoColumns",
+ =
divPersoColumns,
+ =
"Order",
+ =
InputLinePersoColumns);
+ </script>
+ </td>
+ </tr>
+ =20
+ <!--######################### END: Perso=
Columns ################################## -->
+ =20
<!-- ######################## Columns To=
Show ############################## -->
<tr>
<td colspan=3D"2">
- <table width=3D"100%" border=3D"0" cellSpacing=3D"0" cellPadding=
=3D"0">
- <tr>
- <td width=3D"100%" colspan=3D"2">
- <div class=3D"lev1divider"><IMG height=3D"9" src=3D"clear2x2.=
gif" width=3D"100%"/></div>
- </td>
- </tr>
- <tr>
- <td class=3D"lev1head" valign=3D"top"><font size=3D"2">Columns=
...</font></td>
- </tr>
- </table>
+ <table width=3D"100%" border=3D"=
0" cellSpacing=3D"0" cellPadding=3D"0">
+ <tr>
+ <td width=3D"100%" colspan=3D=
"2">
+ <div class=3D"lev1divide=
r"><IMG height=3D"9" src=3D"clear2x2.gif" width=3D"100%"/></div>
+ </td>
+ </tr>
+ <tr>
+ <td class=3D"lev1head" valig=
n=3D"top"><font size=3D"2">Columns...</font></td>
+ </tr>
+ </table>
</td>
</tr>
=20
@@ -397,16 +463,16 @@
<!--######################### Sort #####=
######################################### -->
<tr>
<td colspan=3D"2">
- <table width=3D"100%" border=3D"0" cellSpacing=3D"0" cellPadding=
=3D"0">
- <tr>
- <td width=3D"100%" colspan=3D"2" class=3D"lev1divider">
- <div class=3D"lev1divider"><IMG height=3D"9" src=3D"clear2x2.=
gif" width=3D"100%"/></div>
- </td>
- </tr>
- <tr>
- <td class=3D"lev1head" valign=3D"top"><font size=3D"2">Orden..=
.</font></td>
- </tr>
- </table>
+ <table width=3D"100%" border=3D"=
0" cellSpacing=3D"0" cellPadding=3D"0">
+ <tr>
+ <td width=3D"100%" colspan=3D=
"2" class=3D"lev1divider">
+ <div class=3D"lev1divide=
r"><IMG height=3D"9" src=3D"clear2x2.gif" width=3D"100%"/></div>
+ </td>
+ </tr>
+ <tr>
+ <td class=3D"lev1head" valig=
n=3D"top"><font size=3D"2">Orden...</font></td>
+ </tr>
+ </table>
</td>
</tr>
=20
@@ -426,11 +492,6 @@
=
divSort,
=
"Order",
=
InputLineOrders);
- =
=20
- =
var expandFormFilter =3D new ExpandForm( "expandFormFilter",
- =
divFilter,
- =
"Filter",
- =
InputLineFilters);
</script>
</td>
</tr>
@@ -451,28 +512,31 @@
</tr>
<tr>
<td class=3D"ContentAlt">
- <div id=3D"CrudButtons1">
- <input type=3D"submit">
- <xsl:attribute name=3D=
"value">
- <xsl:value-of se=
lect=3D"/report/reportDatas/saveName" />
- </xsl:attribute>
+ <div id=3D"CrudButtons1">
+ <input type=3D"submit">
+ <xsl:attribute name=3D"v=
alue">
+ <xsl:value-of select=
=3D"/report/reportDatas/saveName" />
+ </xsl:attribute>
+ <xsl:attribute name=3D"o=
nclick">
+ Form.UpdateSubmitAll=
(rightColumn,
+ =
expandFormSort,
+ =
expandFormFilter,
+ =
expandFormPersoColumns); //Don't forget to do the same in Form.UpdateHea=
der
+ </xsl:attribute>
+ </input>
+ </div>
+ </td>
+ <td>
+ <div id=3D"CrudButtons2">
+ <xsl:if test=3D"/report/repo=
rtDatas/displayDeleteButton=3D'true'" >
+ <input type=3D"submit" v=
alue=3D"Delete">
<xsl:attribute name=3D=
"onclick">
- Form.UpdateSubmi=
tAll(rightColumn,expandFormSort,expandFormFilter); //Don't forget to do t=
he same in Form.UpdateHeader
+ Form.DeleteRepor=
t(<xsl:value-of select=3D"/report/id" />);
</xsl:attribute>
</input>
- </div>
+ </xsl:if>
+ </div>
</td>
- <td>
- <div id=3D"CrudButtons2">
- <xsl:if test=3D"/report/=
reportDatas/displayDeleteButton=3D'true'" >
- <input type=3D"submi=
t" value=3D"Delete">
- <xsl:attribute n=
ame=3D"onclick">
- Form.DeleteR=
eport(<xsl:value-of select=3D"/report/id" />);
- </xsl:attribute>
- </input>
- </xsl:if>
- </div>
- </td>
</tr>
<!--######################### End:Button=
s ########################################## -->
</xsl:if>
|