Added Date control, and to Create Invoice
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Web;
|
||||
using System.Web.Services;
|
||||
using System.Web.UI;
|
||||
@@ -40,6 +41,7 @@ namespace Swarmops.Frontend.Automation
|
||||
return input.ToString("N2");
|
||||
}
|
||||
|
||||
|
||||
[WebMethod]
|
||||
public static AjaxInputCallResult FormatCurrencyString(string input)
|
||||
{
|
||||
@@ -57,5 +59,33 @@ namespace Swarmops.Frontend.Automation
|
||||
|
||||
return new AjaxInputCallResult {Success = true, NewValue = (cents / 100.0).ToString("N2")};
|
||||
}
|
||||
|
||||
|
||||
public class AjaxDateValidationResult: AjaxInputCallResult
|
||||
{
|
||||
public string InterpretedDate { get; set; }
|
||||
public string PresentedDate { get; set; }
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public static AjaxDateValidationResult InterpretDateString(string input)
|
||||
{
|
||||
GetAuthenticationDataAndCulture();
|
||||
|
||||
DateTime interpretedDate = DateTime.MinValue;
|
||||
bool success = DateTime.TryParse(input, out interpretedDate);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
return new AjaxDateValidationResult() {Success = false};
|
||||
}
|
||||
|
||||
return new AjaxDateValidationResult()
|
||||
{
|
||||
Success = true,
|
||||
InterpretedDate = interpretedDate.ToString(CultureInfo.InvariantCulture),
|
||||
PresentedDate = interpretedDate.ToString("yyyy MMM dd")
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<%@ Control Language="C#" AutoEventWireup="true" Inherits="Swarmops.Frontend.Controls.Base.DateTextBox" Codebehind="DateTextBox.ascx.cs" %>
|
||||
<%@ Import Namespace="Swarmops.Common.Enums" %>
|
||||
|
||||
<!-- TODO: Add nice autocomplete stuff -->
|
||||
|
||||
<% if (this.Layout == LayoutDirection.Vertical) { %><div class="stacked-input-control"><% } %>
|
||||
<asp:TextBox ID="TextInput" runat="server" CssClass="" /><asp:HiddenField ID="InterpretedDate" runat="server"/>
|
||||
<% if (this.Layout == LayoutDirection.Vertical) { %></div><% } %>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function <%=this.ClientID%>_focus() {
|
||||
$('#<%=this.TextInput.ClientID%>').focus();
|
||||
}
|
||||
|
||||
function <%=this.ClientID%>_setValue(newValue) {
|
||||
$('#<%=this.TextInput.ClientID%>').val(newValue);
|
||||
}
|
||||
|
||||
function <%=this.ClientID%>_val() {
|
||||
return $('#<%=this.TextInput.ClientID%>').val();
|
||||
}
|
||||
|
||||
function <%=this.ClientID%>_initialize(initValue) {
|
||||
_initVal_<%=this.TextInput.ClientID%> = initValue;
|
||||
<%=this.ClientID%>_setValue(initValue);
|
||||
// <%=this.ClientID%>_enable();
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$('#<%=this.ClientID%>_TextInput').blur(function () {
|
||||
|
||||
var dateText = $('#<%=this.ClientID%>_TextInput').val();
|
||||
|
||||
var jsonData = {};
|
||||
jsonData.input = dataText;
|
||||
|
||||
if (currencyText.trim().indexOf(' ') >= 0) {
|
||||
SwarmopsJS.ajaxCall('/Automation/Formatting.aspx/InterpretDateString',
|
||||
jsonData,
|
||||
function(data) {
|
||||
if (data.Success) {
|
||||
$('#<%=this.ClientID%>_TextInput').val(data.PresentedValue);
|
||||
$('#<%=this.ClientID%>_InterpretedDate').val(data.InterpretedValue);
|
||||
} else {
|
||||
$('#<%=this.ClientID%>_TextInput').val('');
|
||||
$('#<%=this.ClientID%>_InterpretedDate').val('');
|
||||
$('#<%=this.TextInput.ClientID%>').focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Swarmops.Common.Enums;
|
||||
using System.Web.UI;
|
||||
using Swarmops.Logic.Financial;
|
||||
using Swarmops.Logic.Support;
|
||||
|
||||
namespace Swarmops.Frontend.Controls.Base
|
||||
{
|
||||
/// <summary>
|
||||
/// This is an ordinary textbox, except it does culture-sensitive and
|
||||
/// asynchronous validation of currency input.
|
||||
/// </summary>
|
||||
public partial class DateTextBox : ControlV5Base
|
||||
{
|
||||
protected void Page_Load (object sender, EventArgs e)
|
||||
{
|
||||
this.TextInput.Attributes["role"] = "note"; // disable Lastpass trying to autofill
|
||||
|
||||
if (this.Layout == LayoutDirection.Unknown)
|
||||
{
|
||||
this.Layout = LayoutDirection.Vertical;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime Value
|
||||
{
|
||||
get { return DateTime.Parse(this.InterpretedDate.Value, CultureInfo.InvariantCulture); }
|
||||
set
|
||||
{
|
||||
this.InterpretedDate.Value = Value.ToString(CultureInfo.InvariantCulture);
|
||||
this.TextInput.Text = Value.ToString("YYYY MMM dd");
|
||||
}
|
||||
}
|
||||
|
||||
public LayoutDirection Layout { get; set; }
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Swarmops.Frontend.Controls.Base {
|
||||
|
||||
|
||||
public partial class DateTextBox {
|
||||
|
||||
/// <summary>
|
||||
/// TextInput control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox TextInput;
|
||||
|
||||
/// <summary>
|
||||
/// InterpretedDate control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.HiddenField InterpretedDate;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
<%@ Register src="~/Controls/v5/Base/FileUpload.ascx" tagname="FileUpload" tagprefix="Swarmops5" %>
|
||||
<%@ Register TagPrefix="Swarmops5" TagName="ComboBudgets" Src="~/Controls/v5/Financial/ComboBudgets.ascx" %>
|
||||
<%@ Register TagPrefix="Swarmops5" TagName="CurrencyAmount" Src="~/Controls/v5/Financial/CurrencyTextBox.ascx" %>
|
||||
<%@ Register TagPrefix="Swarmops5" TagName="DateTextBox" Src="~/Controls/v5/Financial/DateTextBox.ascx" %>
|
||||
|
||||
<asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
|
||||
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
|
||||
@@ -145,12 +146,13 @@
|
||||
<h2><asp:Label ID="BoxTitle" runat="server"/></h2>
|
||||
<asp:HiddenField ID="HiddenTagSetIdentifiers" runat="server"/>
|
||||
<div class="data-entry-fields">
|
||||
<Swarmops5:DateTextBox runat="server" ID="DateInvoiceIssued"/>
|
||||
<div class="stacked-input-control"><asp:TextBox runat="server" ID="TextInvoiceDate"/></div>
|
||||
<div class="stacked-input-control"><asp:TextBox runat="server" ID="TextSupplier" /></div>
|
||||
<Swarmops5:CurrencyAmount runat="server" ID="CurrencyAmount" />
|
||||
<span class="vatEnabled"><Swarmops5:CurrencyAmount runat="server" ID="CurrencyVat" /></span>
|
||||
<Swarmops5:DateTextBox runat="server" ID="DateInvoiceDue"/>
|
||||
<div class="stacked-input-control"><asp:TextBox runat="server" ID="TextPurpose" /></div>
|
||||
<div class="stacked-input-control"><asp:TextBox runat="server" ID="TextDueDate" /></div>
|
||||
<Swarmops5:ComboBudgets ID="ComboBudgets" runat="server" ListType="InvoiceableIn" />
|
||||
<asp:Repeater ID="RepeaterTagDrop" runat="server"><ItemTemplate><span id="SpanDropTags<%# Eval("TagSetId") %>"><select class="easyui-combotree" url="/Automation/Json-TransactionTagsTree.aspx?TagSetId=<%# Eval("TagSetId") %>" name="DropTags<%# Eval("TagSetId") %>" id="DropTags<%# Eval("TagSetId") %>" animate="true" style="width:300px"></select></span> <br/></ItemTemplate></asp:Repeater>
|
||||
|
||||
@@ -172,8 +174,8 @@
|
||||
<asp:Label runat="server" ID="LabelSupplier" /><br/>
|
||||
<asp:Label runat="server" ID="LabelAmount" /><br/>
|
||||
<span class="vatEnabled"><asp:Label runat="server" ID="LabelVat" /><br/></span>
|
||||
<asp:Label runat="server" ID="LabelPurpose" /><br/>
|
||||
<asp:Label runat="server" ID="LabelDueDate" /><br/>
|
||||
<asp:Label runat="server" ID="LabelPurpose" /><br/>
|
||||
<asp:Label runat="server" ID="LabelBudget" /><br/>
|
||||
<asp:Repeater ID="RepeaterTagLabels" runat="server"><ItemTemplate><%# Eval("TagSetLocalizedName") %><br/></ItemTemplate></asp:Repeater>
|
||||
<h2><asp:Label runat="server" ID="LabelHeaderImageFiles" /></h2>
|
||||
|
||||
@@ -103,8 +103,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
this.CurrencyAmount.Cents = 0;
|
||||
this.CurrencyVat.Cents = 0;
|
||||
this.TextSupplier.Focus();
|
||||
this.TextDueDate.Text = DateTime.Today.AddDays (30).ToShortDateString(); // Use current culture
|
||||
this.TextInvoiceDate.Text = DateTime.Today.ToShortDateString();
|
||||
this.DateInvoiceIssued.Value = DateTime.Today;
|
||||
this.DateInvoiceDue.Value = DateTime.Today.AddDays(30);
|
||||
|
||||
Localize();
|
||||
}
|
||||
|
||||
+27
-18
@@ -48,6 +48,15 @@ namespace Swarmops.Frontend.Pages.v5.Financial {
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.HiddenField HiddenTagSetIdentifiers;
|
||||
|
||||
/// <summary>
|
||||
/// DateInvoiceIssued control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.UserControl DateInvoiceIssued;
|
||||
|
||||
/// <summary>
|
||||
/// TextInvoiceDate control.
|
||||
/// </summary>
|
||||
@@ -84,6 +93,15 @@ namespace Swarmops.Frontend.Pages.v5.Financial {
|
||||
/// </remarks>
|
||||
protected global::Swarmops.Frontend.Controls.Financial.CurrencyTextBox CurrencyVat;
|
||||
|
||||
/// <summary>
|
||||
/// DateInvoiceDue control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.UserControl DateInvoiceDue;
|
||||
|
||||
/// <summary>
|
||||
/// TextPurpose control.
|
||||
/// </summary>
|
||||
@@ -93,15 +111,6 @@ namespace Swarmops.Frontend.Pages.v5.Financial {
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox TextPurpose;
|
||||
|
||||
/// <summary>
|
||||
/// TextDueDate control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox TextDueDate;
|
||||
|
||||
/// <summary>
|
||||
/// ComboBudgets control.
|
||||
/// </summary>
|
||||
@@ -192,15 +201,6 @@ namespace Swarmops.Frontend.Pages.v5.Financial {
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label LabelVat;
|
||||
|
||||
/// <summary>
|
||||
/// LabelPurpose control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label LabelPurpose;
|
||||
|
||||
/// <summary>
|
||||
/// LabelDueDate control.
|
||||
/// </summary>
|
||||
@@ -210,6 +210,15 @@ namespace Swarmops.Frontend.Pages.v5.Financial {
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label LabelDueDate;
|
||||
|
||||
/// <summary>
|
||||
/// LabelPurpose control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label LabelPurpose;
|
||||
|
||||
/// <summary>
|
||||
/// LabelBudget control.
|
||||
/// </summary>
|
||||
|
||||
@@ -152,6 +152,13 @@
|
||||
<Compile Include="Controls\v5\Base\AjaxDropDown.ascx.designer.cs">
|
||||
<DependentUpon>AjaxDropDown.ascx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\v5\Base\DateTextBox.ascx.cs">
|
||||
<DependentUpon>DateTextBox.ascx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\v5\Base\DateTextBox.ascx.designer.cs">
|
||||
<DependentUpon>DateTextBox.ascx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\v5\Base\DocumentDownloader.ascx.cs">
|
||||
<DependentUpon>DocumentDownloader.ascx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -864,6 +871,7 @@
|
||||
<Content Include="Controls\v5\Base\AjaxToggleSlider.ascx" />
|
||||
<Content Include="Controls\v5\Base\ComboGeographies.ascx" />
|
||||
<Content Include="Controls\v5\Base\AjaxDropDown.ascx" />
|
||||
<Content Include="Controls\v5\Base\DateTextBox.ascx" />
|
||||
<Content Include="Controls\v5\Base\DocumentDownloader.ascx" />
|
||||
<Content Include="Controls\v5\Base\DropDown.ascx" />
|
||||
<Content Include="Controls\v5\Base\FileUpload.ascx" />
|
||||
|
||||
Reference in New Issue
Block a user