@{ ViewData["Title"] = "Index"; Layout = "~/Views/Shared/_Layout.cshtml"; } @using SuperCms.Controllers; @using SuperCms.Models; @using System.Globalization; @{ int pageNow = 1; if (Model.page != null) { pageNow = int.Parse(Model.page); } } @model ReportViewModel
@*

Message configuration

*@

Toolbars

@* *@
@*
*@
@{ List services = Model.services.data.FindAll(x => x.companyID == Model.companyID); if (Model.typeGet == UtilsController.Constant.MONEY_GET) { @**@ } else { @**@ } @{ // get the newest data folowing by each service for (int j = 0; j < services.Count; j++) { ConnConfig service = services[j]; // get all data in the last month // calculator double newSub = 0, newSubBefore = 0, newSubS = 0, newSubP = 0, newSubN = 0; double revenue = 0, revenueBefore = 0; double expense = 0, expenseBefore = 0; double totalSub = 0, totalSubBefore = 0, totalSubS = 0, totalSubP = 0, totalSubN = 0; double deactive = 0, deactiveBefore = 0, deactiveS = 0, deactiveP = 0, deactiveN = 0; //double active = 0, activeBefore = 0, activeS = 0, activeP = 0, activeN = 0; double benefit = 0, benefitBefore = 0; double benefitP = 0, revenueP = 0, expenseP = 0; double benefitD = 0, revenueD = 0, expenseD = 0; double benefitN = 0, revenueN = 0, expenseN = 0; ConnDatas dataDateNowLastMonth = new ConnDatas(); dataDateNowLastMonth.data = new List(); ConnDatas dataDateNowMonthNow = new ConnDatas(); dataDateNowMonthNow.data = new List(); DistributedDataByService distributedDataByService = Model.distributedDataByServices.Find(x => x.service.id == service.id); distributedDataByService.dataLastMonth.data.Sort(delegate (ConnData x, ConnData y) { if (x.dateGet == null && y.dateGet == null) return 0; else if (x.dateGet == null) return -1; else if (y.dateGet == null) return 1; else return DateTime.Compare( DateTime.ParseExact(y.dateGet + " 23:59:59", "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture), DateTime.ParseExact(x.dateGet + " 23:59:59", "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture)); }); if (int.Parse(Model.date) <= distributedDataByService.dataLastMonth.data.Count) { for (int q = 0; q < int.Parse(Model.date); q++) { dataDateNowLastMonth.data.Add(distributedDataByService.dataLastMonth.data[distributedDataByService.dataLastMonth.data.Count - 1 - q]); } totalSubBefore = double.Parse(dataDateNowLastMonth.data[0].totalSub); dataDateNowLastMonth.data.ForEach(x => { if (x.registerNew != null) { newSubBefore += int.Parse(x.registerNew); } }); dataDateNowLastMonth.data.ForEach(x => { if (x.deactive != null) { deactiveBefore += int.Parse(x.deactive); } }); dataDateNowLastMonth.data.ForEach(x => { if (x.revenue != null) { revenueBefore += int.Parse(x.revenue); } }); dataDateNowLastMonth.data.ForEach(x => { if (x.expense != null) { expenseBefore += int.Parse(x.expense); } }); } //distributedDataByService.dataLastMonth.data.ForEach(x => newSubBefore += int.Parse(x.registerNew)); //distributedDataByService.dataLastMonth.data.ForEach(x => deactiveBefore += int.Parse(x.deactive)); //distributedDataByService.dataLastMonth.data.ForEach(x => revenueBefore += int.Parse(x.revenue)); //distributedDataByService.dataLastMonth.data.ForEach(x => expenseBefore += int.Parse(x.expense)); // get max day of the last month //if (distributedDataByService.dataLastMonth.data.Count > 0) //{ // totalSubBefore = double.Parse(distributedDataByService.dataLastMonth.data[0].totalSub); //} benefitBefore = revenueBefore - Math.Abs(expenseBefore); distributedDataByService.dataNow.data.Sort(delegate (ConnData x, ConnData y) { if (x.dateGet == null && y.dateGet == null) return 0; else if (x.dateGet == null) return -1; else if (y.dateGet == null) return 1; else return DateTime.Compare( DateTime.ParseExact(y.dateGet + " 23:59:59", "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture), DateTime.ParseExact(x.dateGet + " 23:59:59", "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture)); }); if (int.Parse(Model.date) <= distributedDataByService.dataNow.data.Count) { for (int q = 0; q < int.Parse(Model.date); q++) { dataDateNowMonthNow.data.Add(distributedDataByService.dataNow.data[distributedDataByService.dataNow.data.Count - 1 - q]); } totalSub = double.Parse(dataDateNowMonthNow.data[0].totalSub); dataDateNowMonthNow.data.ForEach(x => { if (x.registerNew != null) { newSub += int.Parse(x.registerNew); } }); dataDateNowMonthNow.data.ForEach(x => { if (x.deactive != null) { deactive += int.Parse(x.deactive); } }); dataDateNowMonthNow.data.ForEach(x => { if (x.revenue != null) { revenue += int.Parse(x.revenue); } }); dataDateNowMonthNow.data.ForEach(x => { if (x.expense != null) { expense += int.Parse(x.expense); } }); if (dataDateNowMonthNow.data[int.Parse(Model.date) - 1].revenue != null) { revenueN = double.Parse(dataDateNowMonthNow.data[int.Parse(Model.date) - 1].revenue); } if (dataDateNowMonthNow.data[int.Parse(Model.date) - 1].expense != null) { expenseN = double.Parse(dataDateNowMonthNow.data[int.Parse(Model.date) - 1].expense); } benefitN = revenueN + expenseN; if (dataDateNowMonthNow.data[int.Parse(Model.date) - 1].totalSub != null) { totalSubN = double.Parse(dataDateNowMonthNow.data[int.Parse(Model.date) - 1].totalSub); } } //distributedDataByService.dataNow.data.ForEach(x => newSub += int.Parse(x.registerNew)); //distributedDataByService.dataNow.data.ForEach(x => deactive += int.Parse(x.deactive)); //distributedDataByService.dataNow.data.ForEach(x => revenue += int.Parse(x.revenue)); //distributedDataByService.dataNow.data.ForEach(x => expense += int.Parse(x.expense)); //if (distributedDataByService.dataNow.data.Count > 0) //{ // totalSub = double.Parse(distributedDataByService.dataNow.data[0].totalSub); //} benefit = revenue - Math.Abs(expense); revenueD = revenue - revenueBefore; expenseD = Math.Abs(expense) - Math.Abs(expenseBefore); benefitD = benefit - benefitBefore; revenueP = revenueBefore != 0 ? Math.Round(revenueD * 100 / revenueBefore, 2) : 100; expenseP = expenseBefore != 0 ? Math.Round(expenseD * 100 / expenseBefore, 2) : 100; benefitP = benefitBefore != 0 ? Math.Round(benefitD * 100 / benefitBefore, 2) : 100; //if (distributedDataByService.distributedByTimes.Count > 0) //{ // revenueN = double.Parse(distributedDataByService.distributedByTimes[0].connDatas.data[0].revenue); // expenseN = double.Parse(distributedDataByService.distributedByTimes[0].connDatas.data[0].expense); // benefitN = revenueN + expenseN; // totalSubN = double.Parse(distributedDataByService.distributedByTimes[0].connDatas.data[0].totalSub); //} totalSubS = totalSub - totalSubBefore; totalSubP = totalSubBefore != 0 ? Math.Round(totalSubS * 100 / totalSubBefore, 2) : 100; deactiveS = deactive - deactiveBefore; deactiveP = deactiveBefore != 0 ? Math.Round(deactiveS * 100 / deactiveBefore, 2) : 100; newSubS = newSub - newSubBefore; newSubP = newSubBefore != 0 ? Math.Round(newSubS * 100 / newSubBefore, 2) : 100; if (Model.typeGet == UtilsController.Constant.MONEY_GET) { @if (service.state == UtilsController.Constant.ALL_REVEUNUE) { } else { } if (service.state == UtilsController.Constant.ALL_REVEUNUE) { } } else { } } } }
NO VAS CODE Acc last month Acc now +/- %@Model.listDate[1].ToString("dd/MM")@Model.date@Model.listDate[0].ToString("/MM")
NO VAS CODE SUB SUB last month +/- %@Model.listDate[1].ToString("dd/MM")@Model.date@Model.listDate[1].ToString("/MM")
@(j + 1) @service.serviceName@(j + 1) @service.serviceNameRevenue @(string.Format("{0:#,0}", revenueBefore)) @(string.Format("{0:#,0}", revenue)) @(string.Format("{0:#,0}", Math.Abs(revenueD))) @{ if (revenueD < 0) {
@Math.Abs(revenueP)%
0%
} else {
0%
@Math.Abs(revenueP)%
} }
@(string.Format("{0:#,0}", revenueN))
Expense @(string.Format("{0:#,0}", expenseBefore >= 0 ? expenseBefore : -expenseBefore)) @(string.Format("{0:#,0}", expense >= 0 ? expense : -expense)) @(string.Format("{0:#,0}", Math.Abs(expenseD))) @{ if (expenseD < 0) {
@Math.Abs(expenseP)%
0%
} else {
0%
@Math.Abs(expenseP)%
} }
@(string.Format("{0:#,0}", expenseN >= 0 ? expenseN : -expenseN))
Benefit @(string.Format("{0:#,0}", benefitBefore)) @(string.Format("{0:#,0}", benefit)) @(string.Format("{0:#,0}", Math.Abs(benefitD))) @{ if (benefitD < 0) {
@Math.Abs(benefitP)%
0%
} else {
0%
@Math.Abs(benefitP)%
} }
@(string.Format("{0:#,0}", benefitN))
@(j + 1) @service.serviceName Total Sub @(string.Format("{0:#,0}", totalSub)) @(string.Format("{0:#,0}", totalSubBefore)) @(string.Format("{0:#,0}", Math.Abs(totalSubS))) @{ if (totalSubS < 0) {
@Math.Abs(totalSubP)%
0%
} else {
0%
@Math.Abs(totalSubP)%
} }
@(string.Format("{0:#,0}", totalSubN))
Deactive @(string.Format("{0:#,0}", deactive)) @(string.Format("{0:#,0}", deactiveBefore)) @(string.Format("{0:#,0}", Math.Abs(deactiveS))) @{ if (deactiveS < 0) {
@Math.Abs(deactiveP)%
0%
} else {
0%
@Math.Abs(deactiveP)%
} }
@(string.Format("{0:#,0}", deactiveN))
Active @(string.Format("{0:#,0}", newSub)) @(string.Format("{0:#,0}", newSubBefore)) @(string.Format("{0:#,0}", Math.Abs(newSubS))) @{ if (newSubS < 0) {
@Math.Abs(newSubP)%
0%
} else {
0%
@Math.Abs(newSubP)%
} }
@(string.Format("{0:#,0}", newSubN))
@{ @{ for (int d = 1; d < Model.listDate.Count; d++) { } } @{ // get the newest data folowing by each service for (int j = 0; j < services.Count; j++) { ConnConfig service = services[j]; // get all data in the last month // calculator double benefitN = 0, revenueN = 0, expenseN = 0; DistributedDataByService distributedDataByService = Model.distributedDataByServices.Find(x => x.service.id == service.id); if (Model.typeGet == UtilsController.Constant.MONEY_GET) { @{ if (distributedDataByService.distributedByTimes.Count > 0) { for (int c = 0; c < distributedDataByService.distributedByTimes.Count; c++) { if (distributedDataByService.distributedByTimes[c].connDatas.data.Count > 0) { if (distributedDataByService.distributedByTimes[c].connDatas.data[0].revenue != null) { revenueN = double.Parse(distributedDataByService.distributedByTimes[c].connDatas.data[0].revenue); } if (distributedDataByService.distributedByTimes[c].connDatas.data[0].expense != null) { expenseN = double.Parse(distributedDataByService.distributedByTimes[c].connDatas.data[0].expense); } benefitN = revenueN + expenseN; } } } else { for (int d = 1; d < Model.listDate.Count; d++) { } } } if (service.state == UtilsController.Constant.ALL_REVEUNUE) { @{ if (distributedDataByService.distributedByTimes.Count > 0) { for (int c = 0; c < distributedDataByService.distributedByTimes.Count; c++) { if (distributedDataByService.distributedByTimes[c].connDatas.data.Count > 0) { if (distributedDataByService.distributedByTimes[c].connDatas.data[0].revenue != null) { revenueN = double.Parse(distributedDataByService.distributedByTimes[c].connDatas.data[0].revenue); } if (distributedDataByService.distributedByTimes[c].connDatas.data[0].expense != null) { expenseN = double.Parse(distributedDataByService.distributedByTimes[c].connDatas.data[0].expense); } benefitN = revenueN + expenseN; } } } else { for (int d = 1; d < Model.listDate.Count; d++) { } } } @{ if (distributedDataByService.distributedByTimes.Count > 0) { for (int c = 0; c < distributedDataByService.distributedByTimes.Count; c++) { if (distributedDataByService.distributedByTimes[c].connDatas.data.Count > 0) { if (distributedDataByService.distributedByTimes[c].connDatas.data[0].revenue != null) { revenueN = double.Parse(distributedDataByService.distributedByTimes[c].connDatas.data[0].revenue); } if (distributedDataByService.distributedByTimes[c].connDatas.data[0].expense != null) { expenseN = double.Parse(distributedDataByService.distributedByTimes[c].connDatas.data[0].expense); } benefitN = revenueN + expenseN; } } } else { for (int d = 1; d < Model.listDate.Count; d++) { } } } } } else { @{ if(distributedDataByService.distributedByTimes.Count > 0){ double totalSub = 0; for (int c = 0; c < distributedDataByService.distributedByTimes.Count; c++) { if (distributedDataByService.distributedByTimes[c].connDatas.data.Count > 0) { if (distributedDataByService.distributedByTimes[c].connDatas.data[0].totalSub != null) { totalSub = double.Parse(distributedDataByService.distributedByTimes[c].connDatas.data[0].totalSub); } } } }else { for (int d = 1; d < Model.listDate.Count; d++) { } } } @{ if(distributedDataByService.distributedByTimes.Count > 0){ double deactive = 0; for (int c = 0; c < distributedDataByService.distributedByTimes.Count; c++) { if (distributedDataByService.distributedByTimes[c].connDatas.data.Count > 0) { if (distributedDataByService.distributedByTimes[c].connDatas.data[0].deactive != null) { deactive = double.Parse(distributedDataByService.distributedByTimes[c].connDatas.data[0].deactive); } } } }else { for (int d = 1; d < Model.listDate.Count; d++) { } } } @{ if(distributedDataByService.distributedByTimes.Count > 0){ double newSub = 0; for (int c = 0; c < distributedDataByService.distributedByTimes.Count; c++) { if (distributedDataByService.distributedByTimes[c].connDatas.data.Count > 0) { if (distributedDataByService.distributedByTimes[c].connDatas.data[0].registerNew != null) { newSub = double.Parse(distributedDataByService.distributedByTimes[c].connDatas.data[0].registerNew); } } } }else { for (int d = 1; d < Model.listDate.Count; d++) { } } } } } } }
@Model.listDate[d].ToString("dd/MM")
@(string.Format("{0:#,0}", revenueN))0
@(string.Format("{0:#,0}", expenseN >= 0 ? expenseN : -expenseN))0
@(string.Format("{0:#,0}", benefitN))0
@(string.Format("{0:#,0}", totalSub))0
@(string.Format("{0:#,0}", deactive))0
@(string.Format("{0:#,0}", newSub))0
@{ int totalPage = Model.totalPage != null ? int.Parse(Model.totalPage) : 1;
@{
  • ‹‹
  • @{ if (totalPage <= 4) { for (int k = 1; k <= totalPage; k++) {
  • @k
  • } } else if (pageNow <= totalPage - 4) { for (int k = pageNow; (k <= pageNow + 4 && k <= totalPage); k++) {
  • @k
  • } } else { for (int k = totalPage - 4; k <= totalPage; k++) {
  • @k
  • } } }
  • ››
}
}
@*@section scripts{ }*@