self.buscarReporteDetalle = function () { var url = pathApi + "apisublaborrealizada/obtenerreporteDetalle"; self.listaReporte.removeAll(); if ($("#frmReporte").valid()) { disableBottonForm("frmReporte", "btnBuscar", "lmReporte"); //$('.tableDT').DataTable().clear().destroy(); $.post(url, $("#frmReporte").serialize(), function (data) {
if (data["estatus"]) { $.each(data["resultado"], function (key, item) { var estatus = (item.Estatus == "A") ? "Aprobada" : ((item.Estatus == "P") ? pendiente : ((item.Estatus == "I") ? inactivo : ((item.Estatus == "PO") ? "Posteada" : inactivo))); item.Estatus = { icono: estatus, valor: item.Estatus }; item.Fecha = toShortDateString(item.Fecha); item.Precio = item.Precio.formatMoney(2, '.', ','); item.Monto = (item.Precio * item.Cantidad); item.Monto = item.Monto.formatMoney(2, '.', ',');
// monto Total
item.MontoTotal += (item.Precio * item.Cantidad); item.CantidadTotal += item.Cantidad; //item.FechaRegistrada = toShortDateString(item.FechaRegistrada); self.listaReporte.push(item); });
if (self.listaReporte().length > 0) { self.Fecha($('#FechaInicio').val() + " - " + $('#FechaFin').val()); } else { mostrarToastr("No se han encontrado resultados", "W"); }
} else { mostrarToastr(data["mensaje"], "E"); } enableBottonForm("frmReporte", "btnBuscar", "lmReporte"); }, "json") .fail(function (d) { enableBottonForm("frmReporte", "btnBuscar", "lmReporte"); mostrarToastr(d.responseText, "E"); }); } else { enableBottonForm("frmReporte", "btnBuscar", "lmReporte"); } }
<table class="table table-hover"> <thead> <tr bgcolor="#f5f5f5"> @*<th>@Idioma.Fecha</th>*@ @*<th>@Idioma.Numero</th>*@ <th>@Idioma.Empleado</th> <th>@Idioma.Campo</th> <th>@Idioma.SubLabor</th> <th>@Idioma.Precio</th> <th>@Idioma.Cantidad</th> <th>@Idioma.Monto</th> <th>@Idioma.Estatus</th> </tr> </thead> <tbody data-bind="foreach:listaReporte"> <tr> @*<td data-bind="html: Fecha"></td>*@ @*<td data-bind="html: Numero"></td>*@ <td data-bind="html: Empleado"></td> <td data-bind="html: Campo"></td> <td data-bind="html: SubLabor"></td> <td data-bind="html: Precio"></td> <td data-bind="html: Cantidad"></td> <td data-bind="html: Monto"></td> <td data-bind="html: Estatus.icono"></td> </tr> </tbody> <tfoot> <tr> <td colspan="5"><b>Total:</b></td> <td data-bind="html:CantidadTotal"></td> <td data-bind="html: MontoTotal"></td> </tr> </tfoot> </table>