Compare commits
2 Commits
42cbf59372
...
8dbebb5ebd
Author | SHA1 | Date | |
---|---|---|---|
|
8dbebb5ebd | ||
|
210e8756b7 |
@ -266,8 +266,10 @@ namespace OperatorApp.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult PaymentsReport(List<int> payments, string doctype)
|
public IActionResult PaymentsReport(List<int> payments, string doctype, string filename)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(filename)) filename = "report";
|
||||||
|
filename = filename.Replace(".", string.Empty);
|
||||||
List<PaymentBindingModel> paymentBindings = new List<PaymentBindingModel>();
|
List<PaymentBindingModel> paymentBindings = new List<PaymentBindingModel>();
|
||||||
foreach (int paymentId in payments)
|
foreach (int paymentId in payments)
|
||||||
{
|
{
|
||||||
@ -283,13 +285,15 @@ namespace OperatorApp.Controllers
|
|||||||
}
|
}
|
||||||
if (doctype.Equals("word"))
|
if (doctype.Equals("word"))
|
||||||
{
|
{
|
||||||
MemoryStream list = _reportLogic.SavePaymentPurchaseToWord(new ReportBindingModel { FileName = "test" }, paymentBindings);
|
if (!filename.EndsWith(".docx")) filename += ".docx";
|
||||||
return File(list, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "testDoc.docx");
|
MemoryStream list = _reportLogic.SavePaymentPurchaseToWord(new ReportBindingModel { FileName = filename }, paymentBindings);
|
||||||
|
return File(list, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MemoryStream list = _reportLogic.SavePaymentPurchaseToExcel(new ReportBindingModel { FileName = "test" }, paymentBindings);
|
if (!filename.EndsWith(".xlsx")) filename += ".xlsx";
|
||||||
return File(list, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "testExcel.xlsx");
|
MemoryStream list = _reportLogic.SavePaymentPurchaseToExcel(new ReportBindingModel { FileName = filename }, paymentBindings);
|
||||||
|
return File(list, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,44 +308,41 @@ namespace OperatorApp.Controllers
|
|||||||
return View(new ReportBindingModel());
|
return View(new ReportBindingModel());
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void TransfersReport(DateTime dateFrom, DateTime dateTo)
|
public IActionResult TransfersReport(DateTime dateFrom, DateTime dateTo, string reptype, string email, string fileName)
|
||||||
{
|
|
||||||
if (APIClient.Operator == null)
|
|
||||||
{
|
|
||||||
Response.WriteAsync($"<script language=\"javascript\">alert('You need to login!');window.location.replace('/Home/Enter');</script>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MemoryStream report = _reportLogic.SaveTransferPurchaseToPDF(new ReportBindingModel { DateFrom = dateFrom, DateTo = dateTo });
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_mailWorker.MailSendAsync(new MailSendInfoBindingModel
|
|
||||||
{
|
|
||||||
Subject = "Отчёт о закупках",
|
|
||||||
Text = "Для оператора " + APIClient.Operator.LastName + APIClient.Operator.FirstName,
|
|
||||||
MailAddress = "",
|
|
||||||
FileName = "test.pdf",
|
|
||||||
Attachment = report
|
|
||||||
});
|
|
||||||
Response.WriteAsync($"<script language=\"javascript\">alert('Mail sent!');window.location.replace('/');</script>");
|
|
||||||
Redirect("/");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Response.WriteAsync($"<script language=\"javascript\">alert('{ex.Message}');</script>");
|
|
||||||
Response.Redirect("/");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IActionResult ViewReport(DateTime dateFrom, DateTime dateTo)
|
|
||||||
{
|
{
|
||||||
if (APIClient.Operator == null)
|
if (APIClient.Operator == null)
|
||||||
{
|
{
|
||||||
Response.WriteAsync($"<script language=\"javascript\">alert('You need to login!');window.location.replace('/Home/Enter');</script>");
|
Response.WriteAsync($"<script language=\"javascript\">alert('You need to login!');window.location.replace('/Home/Enter');</script>");
|
||||||
return Redirect("/Home/Enter");
|
return Redirect("/Home/Enter");
|
||||||
}
|
}
|
||||||
|
if (reptype.Equals("onForm"))
|
||||||
|
{
|
||||||
ViewBag.DateFrom = dateFrom.ToShortDateString();
|
ViewBag.DateFrom = dateFrom.ToShortDateString();
|
||||||
ViewBag.DateTo = dateTo.ToShortDateString();
|
ViewBag.DateTo = dateTo.ToShortDateString();
|
||||||
return View(_reportLogic.GetTransferPurchase(new ReportBindingModel { DateFrom=dateFrom, DateTo = dateTo }));
|
return View("ViewReport", _reportLogic.GetTransferPurchase(new ReportBindingModel { DateFrom = dateFrom, DateTo = dateTo }));
|
||||||
|
}
|
||||||
|
MemoryStream report = _reportLogic.SaveTransferPurchaseToPDF(new ReportBindingModel { DateFrom = dateFrom, DateTo = dateTo });
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(fileName)) fileName = "report";
|
||||||
|
fileName = fileName.Replace(".", string.Empty);
|
||||||
|
if (!fileName.EndsWith(".pdf")) fileName += ".pdf";
|
||||||
|
_mailWorker.MailSendAsync(new MailSendInfoBindingModel
|
||||||
|
{
|
||||||
|
Subject = "Отчёт о закупках",
|
||||||
|
Text = "Для оператора " + APIClient.Operator.LastName + APIClient.Operator.FirstName,
|
||||||
|
MailAddress = email,
|
||||||
|
FileName = fileName,
|
||||||
|
Attachment = report
|
||||||
|
});
|
||||||
|
Response.WriteAsync($"<script language=\"javascript\">alert('Mail sent!');window.location.replace('/');</script>");
|
||||||
|
return Redirect("/");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Response.WriteAsync($"<script language=\"javascript\">alert('{ex.Message}');</script>");
|
||||||
|
return Redirect("/");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,7 +7,7 @@
|
|||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">ID клиента:</div>
|
<div class="col-4">ID клиента:</div>
|
||||||
<div class="col-8"><input type="text" name="clientid" id="clientid" /></div>
|
<div class="col-8"><input type="text" name="clientid" id="clientid" required/></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-8"></div>
|
<div class="col-8"></div>
|
||||||
|
@ -14,12 +14,15 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Word</div>
|
<div class="col-4">Word</div>
|
||||||
@Html.RadioButton("doctype", "word", true)
|
@Html.RadioButton("doctype", "word", true)
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Excel</div>
|
<div class="col-4">Excel</div>
|
||||||
@Html.RadioButton("doctype", "excel")
|
@Html.RadioButton("doctype", "excel")
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Имя файла (необязательно):</div>
|
||||||
|
<div class="col-8"><input type="text" name="fileName" id="fileName" /></div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-8"></div>
|
<div class="col-8"></div>
|
||||||
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Создание списка</h2>
|
<h2 class="display-4">Создание списка</h2>
|
||||||
</div>
|
</div>
|
||||||
<form asp-action="ViewReport" method="get">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">C:</div>
|
<div class="col-4">C:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
@ -21,13 +21,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h1>Вывести на:</h1>
|
<h1>Вывести на:</h1>
|
||||||
<div class="row">
|
<div class="d-flex flex-row">
|
||||||
<div class="col-4">На почту (.pdf)</div>
|
<div class="col-2">На форму</div>
|
||||||
@Html.RadioButton("reptype", "pdf", true)
|
@Html.RadioButton("reptype", "onForm", true)
|
||||||
|
</div>
|
||||||
|
<div class="d-flex flex-row">
|
||||||
|
<div class="col-2">На почту (.pdf)</div>
|
||||||
|
@Html.RadioButton("reptype", "pdf")
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">На форму</div>
|
<div class="col-4">email:</div>
|
||||||
@Html.RadioButton("reptype", "onForm")
|
<div class="col-8"><input type="text" name="email" id="email" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Имя файла (необязательно):</div>
|
||||||
|
<div class="col-8"><input type="text" name="fileName" id="fileName" /></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-8"></div>
|
<div class="col-8"></div>
|
||||||
|
Loading…
Reference in New Issue
Block a user