200831PX For payment receipts, added bool to switch on/off sending mails, added member selection from main window (not finished yet)
This commit is contained in:
parent
852322578a
commit
c12e86fbd2
|
@ -27,6 +27,7 @@ namespace dezentrale.core
|
|||
DateTime EndDate { get; set; }
|
||||
string StartDateString { get; }
|
||||
string EndDateString { get; }
|
||||
bool SendEmail { get; set; }
|
||||
}
|
||||
|
||||
//In order to be able to ReplaceReflect, we need to have the SvgData and SvgFileName field separated in a class
|
||||
|
@ -144,22 +145,27 @@ namespace dezentrale.core
|
|||
|
||||
|
||||
LogTarget.StepStarted(++step, "E-Mail the PDFs to the members");
|
||||
FormMail receiptMail = FormMail.GenerateMemberPaymentReceipts().ReplaceReflect(data);
|
||||
foreach (Member m in memberList)
|
||||
if (data.SendEmail)
|
||||
{
|
||||
//gather entries per member
|
||||
List<string> outputs = new List<string>();
|
||||
foreach (KeyValuePair<string, Member> kvp in intermediateFiles)
|
||||
FormMail receiptMail = FormMail.GenerateMemberPaymentReceipts().ReplaceReflect(data);
|
||||
foreach (Member m in memberList)
|
||||
{
|
||||
if (m.Number == kvp.Value.Number) outputs.Add(Path.Combine(data.OutputDirectory, kvp.Key + finalExt));
|
||||
//gather entries per member
|
||||
List<string> outputs = new List<string>();
|
||||
foreach (KeyValuePair<string, Member> kvp in intermediateFiles)
|
||||
{
|
||||
if (m.Number == kvp.Value.Number) outputs.Add(Path.Combine(data.OutputDirectory, kvp.Key + finalExt));
|
||||
}
|
||||
|
||||
//send E-Mail
|
||||
m.StartLogEvent($"Payment receipts E-Mail ({data.StartDateString} ... {data.EndDateString})",LogEvent.eEventType.EMail, Program.config.LocalUser);
|
||||
LogSubEvent lse = receiptMail.Send(m, outputs);
|
||||
m.SaveToFile(true);
|
||||
}
|
||||
|
||||
//send E-Mail
|
||||
m.StartLogEvent($"Payment receipts E-Mail ({data.StartDateString} ... {data.EndDateString})",LogEvent.eEventType.EMail, Program.config.LocalUser);
|
||||
LogSubEvent lse = receiptMail.Send(m, outputs);
|
||||
m.SaveToFile(true);
|
||||
} else
|
||||
{
|
||||
LogTarget.LogLine($"This step is skipped.", LogEvent.ELogLevel.Info, "PaymentReceiptProcess");
|
||||
}
|
||||
|
||||
LogTarget.StepCompleted(4, $"E-Mail the PDFs to the members", true);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -196,6 +196,14 @@ namespace dezentrale.view
|
|||
{
|
||||
if (this.SelectedItems.Count < 1) return null;
|
||||
return (T)this.SelectedItems[0].Tag;
|
||||
}
|
||||
public List<T> GetSelectedItems()
|
||||
{
|
||||
List<T> ret = new List<T>();
|
||||
for(int i = 0; i < this.SelectedItems.Count; i++)
|
||||
ret.Add((T)this.SelectedItems[i].Tag);
|
||||
|
||||
return ret;
|
||||
}
|
||||
public List<T> GetCheckedItems()
|
||||
{
|
||||
|
|
|
@ -250,7 +250,7 @@ namespace dezentrale.view
|
|||
});
|
||||
gui.Controls.Add(new Label()
|
||||
{
|
||||
Text = "Name:",
|
||||
Text = "E-Mail:",
|
||||
Location = new Point(lm, 10 * line + tm + labelOffs),
|
||||
Size = new Size(110, labelHeight),
|
||||
TextAlign = ContentAlignment.BottomRight,
|
||||
|
|
|
@ -242,9 +242,11 @@ namespace dezentrale.view
|
|||
private void mnuMain_Payments_Receipts(object sender, EventArgs e)
|
||||
{
|
||||
int year = DateTime.Now.Year - 1;
|
||||
|
||||
List<Member> sel = lstMembers.GetSelectedItems();
|
||||
frmPaymentReceipts receipts = new frmPaymentReceipts()
|
||||
{
|
||||
MemberList = new List<Member>() { Program.members.Find(4) },
|
||||
MemberList = (sel != null && sel.Count > 0) ? sel : null,
|
||||
DataTemplate = "dezentrale-beitragsquittung-template.svg",
|
||||
DataFormat = IntermediateFormat.SvgInkscape092,
|
||||
StartDate = new DateTime(year, 01, 01),
|
||||
|
|
|
@ -18,23 +18,26 @@ namespace dezentrale.view
|
|||
public string FileNamePattern { get; set; } = "{Number}-{Date}";
|
||||
public DateTime StartDate { get; set; }
|
||||
public DateTime EndDate { get; set; }
|
||||
public bool SendEmail { get; set; } = false;
|
||||
public string StartDateString { get { return StartDate.ToShortDateString(); } }
|
||||
public string EndDateString { get { return EndDate .ToShortDateString(); } }
|
||||
|
||||
|
||||
private TextBox tbTemplate;
|
||||
private ComboBox cbDataFormat;
|
||||
private TextBox tbOutputDirectory;
|
||||
private TextBox tbFileNamePattern;
|
||||
private DateTimePicker dtStartDate;
|
||||
private DateTimePicker dtEndDate;
|
||||
private RadioButton optAllMembers;
|
||||
private RadioButton optSelectedMembers;
|
||||
private CheckBox chkSendEmail;
|
||||
|
||||
public frmPaymentReceipts()
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
this.StartPosition = FormStartPosition.CenterParent;
|
||||
this.Size = new System.Drawing.Size(483, 185);
|
||||
this.MinimumSize = new System.Drawing.Size(455, 185);
|
||||
this.Size = new System.Drawing.Size(483, 245);
|
||||
this.MinimumSize = new System.Drawing.Size(455, 245);
|
||||
this.Text = "Generate payment receipts";
|
||||
this.Controls.Add(new Label()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue