Skip to content

Commit

Permalink
Merge pull request #101 from ufoloko/development
Browse files Browse the repository at this point in the history
Added Option to export csv between dates
  • Loading branch information
valadas authored Jul 5, 2024
2 parents d305f51 + 49d45eb commit 624fe69
Show file tree
Hide file tree
Showing 14 changed files with 468 additions and 53 deletions.
18 changes: 18 additions & 0 deletions App_LocalResources/ExportCSV.ascx.resx
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,22 @@
<data name="plSystemFields.Text" xml:space="preserve">
<value>Include System Fields</value>
</data>
<data name="plFinalDate.Help" xml:space="preserve">
<value>Select final date to export records, if blank all records will be exported</value>
</data>
<data name="plFinalDate.Text" xml:space="preserve">
<value>Final date</value>
</data>
<data name="plInitialDate.Help" xml:space="preserve">
<value>Select initial date to export records, if blank all records will be exported</value>
</data>
<data name="plInitialDate.Text" xml:space="preserve">
<value>Initial date</value>
</data>
<data name="customDateMessage.Text" xml:space="preserve">
<value>You must select both or no dates</value>
</data>
<data name="errorDateMessage.Text" xml:space="preserve">
<value>Initial date must be earlier than final date</value>
</data>
</root>
3 changes: 3 additions & 0 deletions Components/DataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public abstract int AddField(int ModuleID, string FieldTitle, int before, string
public abstract IDataReader GetRow(int UserDefinedRowId, int ModuleId);

public abstract IDataReader GetRows(int ModuleId);

public abstract IDataReader GetRowsWithDates(int ModuleId, DateTime initialDate, DateTime finalDate);

public abstract IDataReader GetFieldSettings(int moduleId);
public abstract void UpdateFieldSetting(int fieldid, string key, string value);

Expand Down
28 changes: 28 additions & 0 deletions Components/UserDefinedTableController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,34 @@ public DataSet GetDataSet(bool withPreRenderedValues)
return ds;
}

/// -----------------------------------------------------------------------------
/// <summary>
/// Gets all Data values of an UDT table (module) from the Database as DataSet
/// </summary>
/// <param name = "withPreRenderedValues">specifies, whether links, dates etc. shall be prerendered for XML output</param>
/// <returns>All field values as DataSet</returns>
/// -----------------------------------------------------------------------------
public DataSet GetDataSetWithDates(bool withPreRenderedValues, DateTime initialDate, DateTime finalDate)
{
var fieldsTable = FieldController.GetFieldsTable(ModuleId, addNewColumn: false, addAuditColumns: false);
DataSet ds;
using (var dr = DataProvider.Instance().GetRowsWithDates(ModuleId,initialDate,finalDate))
{
ds = BuildMainDataSet(fieldsTable, dr, !withPreRenderedValues);
}
var fieldSettingsTable = FieldSettingsController.GetFieldSettingsTable(ModuleId);
ds.Tables.Add(fieldSettingsTable);

SetEditLinksAndVisibilityBasedOnPermissions(ds);

if (withPreRenderedValues)
{
RenderValuesToHtmlInsideDataSet(ds);
}
ds.Namespace = "DotNetNuke/UserDefinedTable";
return ds;
}

public DataSet GetSchemaDataset()
{
var ds = GetRow(-1);
Expand Down
90 changes: 90 additions & 0 deletions DotNetNuke.Modules.UserDefinedTable.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

136 changes: 106 additions & 30 deletions ExportCSV.ascx
Original file line number Diff line number Diff line change
@@ -1,34 +1,110 @@
<%@ Control Language="C#" CodeBehind="ExportCSV.ascx.cs" Inherits="DotNetNuke.Modules.UserDefinedTable.ExportCsv" AutoEventWireup="false" %>
<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %>
<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.Client.ClientResourceManagement" Assembly="DotNetNuke.Web.Client" %>

<dnn:DnnCssInclude runat="server" FilePath="~/Resources/Shared/components/TimePicker/Themes/jquery-ui.css" />
<dnn:DnnCssInclude runat="server" FilePath="~/Resources/Shared/components/TimePicker/Themes/jquery.ui.theme.css" />

<div class="dnnForm">
<div class="dnnFormItem">
<dnn:Label ID="plFolder" runat="server" ControlName="cboFolders" Suffix=":" />
<asp:DropDownList ID="cboFolders" runat="server" CssClass="NormalTextBox" Width="300" />
</div>
<div class="dnnFormItem">
<dnn:Label ID="plFile" runat="server" ControlName="txtFile" Suffix=":" />
<asp:TextBox ID="txtFile" CssClass="NormalTextBox" runat="server" MaxLength="200"
Width="300" />
</div>
<div class="dnnFormItem">
<dnn:label id="plDelimiter" runat="server" controlname="rblDelimiter" suffix=":" />
<asp:RadioButtonList ID="rblDelimiter" runat="server" RepeatDirection="Horizontal"
CssClass="dnnFormRadioButtons ">
<asp:ListItem Selected="True" Value="," resourcekey="comma"></asp:ListItem>
<asp:ListItem Value=";" resourcekey="semicolon"></asp:ListItem>
</asp:RadioButtonList>
</div>
<div class="dnnFormItem">
<dnn:label id="plSystemFields" runat="server" controlname="cbSystemFields" />
<asp:CheckBox ID="cbSystemFields" runat="server"/>
<div class="dnnFormItem">
<dnn:Label ID="plFolder" runat="server" ControlName="cboFolders" Suffix=":" />
<asp:DropDownList ID="cboFolders" runat="server" CssClass="NormalTextBox" Width="300" />
</div>
<div class="dnnFormItem">
<dnn:Label ID="plFile" runat="server" ControlName="txtFile" Suffix=":" />
<asp:TextBox ID="txtFile" CssClass="NormalTextBox" runat="server" MaxLength="200"
Width="300" />
</div>
<div class="dnnFormItem">
<dnn:label id="plDelimiter" runat="server" controlname="rblDelimiter" suffix=":" />
<asp:RadioButtonList ID="rblDelimiter" runat="server" RepeatDirection="Horizontal"
CssClass="dnnFormRadioButtons ">
<asp:ListItem Selected="True" Value="," resourcekey="comma"></asp:ListItem>
<asp:ListItem Value=";" resourcekey="semicolon"></asp:ListItem>
</asp:RadioButtonList>
</div>
<div class="dnnFormItem">
<dnn:label id="plSystemFields" runat="server" controlname="cbSystemFields" />
<asp:CheckBox ID="cbSystemFields" runat="server" />
</div>
<div class="dnnFormItem">
<dnn:label id="plInitialDate" runat="server" controlname="txtInitialDate" />
<asp:TextBox ID="txtInitialDate" CssClass="NormalTextBox" runat="server" MaxLength="200"
Width="300" onchange="TriggerChanges();" />
</div>
<div>

</div>
<div class="dnnFormItem">
<dnn:label id="plFinalDate" runat="server" controlname="txtFinalDate" />
<asp:TextBox ID="txtFinalDate" CssClass="NormalTextBox" runat="server" MaxLength="200"
Width="300" onchange="TriggerChanges();" />
</div>
<div class="dnnFormItem">
<dnn:label id="plDatesValidator" value="" runat="server" controlname="cvtxtStartDate" />
<asp:CompareValidator id="compareValidatorDates" runat="server"
ControlToCompare="txtInitialDate" cultureinvariantvalues="true"
display="Dynamic" enableclientscript="true"
ControlToValidate="txtFinalDate"
type="Date" Operator="GreaterThanEqual"
CssClass="validator-error" resourcekey="errorDateMessage" >
</asp:CompareValidator>
<asp:CustomValidator id="CustomValidatorDates"
ControlToValidate="txtInitialDate"
ClientValidationFunction="ValidateDatesClient"
Display="Dynamic"
runat="server"
resourcekey="customDateMessage" CssClass="validator-error"/>
</div>
<ul class="dnnActions dnnClear">
<li>
<asp:LinkButton ID="cmdExport" resourcekey="cmdExport" runat="server" CssClass="dnnPrimaryAction"
Text="Export" BorderStyle="none"></asp:LinkButton></li>
<li>
<asp:LinkButton ID="cmdCancel" resourcekey="cmdCancel" runat="server" CssClass="dnnSecondaryAction"
Text="Cancel" BorderStyle="none" CausesValidation="False"></asp:LinkButton></li>
</ul>

</div>
<ul class="dnnActions dnnClear">
<li>
<asp:LinkButton ID="cmdExport" resourcekey="cmdExport" runat="server" CssClass="dnnPrimaryAction"
Text="Export" BorderStyle="none"></asp:LinkButton></li>
<li>
<asp:LinkButton ID="cmdCancel" resourcekey="cmdCancel" runat="server" CssClass="dnnSecondaryAction"
Text="Cancel" BorderStyle="none" CausesValidation="False"></asp:LinkButton></li>
</ul>

</div>

<script>
$(function () {
$("#<%= txtInitialDate.ClientID %>").datepicker({
dateFormat: "yy/mm/dd",
showButtonPanel: true,
closeText: 'Clear',
onClose: function () {
var event = arguments.callee.caller.caller.arguments[0];
if ($(event.delegateTarget).hasClass('ui-datepicker-close')) {
$(this).val('');
TriggerChanges();
}
}
});
$("#<%= txtFinalDate.ClientID %>").datepicker({
dateFormat: "yy/mm/dd",
showButtonPanel: true,
closeText: 'Clear',
onClose: function () {
var event = arguments.callee.caller.caller.arguments[0];
if ($(event.delegateTarget).hasClass('ui-datepicker-close')) {
$(this).val('');
TriggerChanges();
}
}
});
});
function TriggerChanges() {
ValidatorValidate(document.getElementById('<%= CustomValidatorDates.ClientID %>'));
}
function ValidateDatesClient(source, arguments) {
if (($("#<%= txtInitialDate.ClientID %>").val().length == 0 && $("#<%= txtFinalDate.ClientID %>").val().length == 0) || ($("#<%= txtInitialDate.ClientID %>").val().length > 0 && $("#<%= txtFinalDate.ClientID %>").val().length > 0)) {
arguments.IsValid = true;
} else {
arguments.IsValid = false;
}
}
</script>
Loading

0 comments on commit 624fe69

Please sign in to comment.