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