采购项目最终总计如何计算

时间:2018-10-10 09:40:31

标签: php jquery ajax

我已经创建了库存控制系统的采购报告。如果我们要检查购买,请从日期和日期中选择要购买的物品的方式。所有记录将成功显示在dataTable上,但我的问题是,列{“ sTitle”:“ total”,“ mData”:“ total”}在这里,我需要计算每天的最终购买金额。它将显示在数据表。 购买总金额。

function get_all() {
                    var from_date = $('#from_date').val();
                    var to_date = $('#to_date').val();
                    $('#tbl-projects').dataTable().fnDestroy();

                    $.ajax({
                        url:"all_purchase.php",
                        type: "POST",
                        dataType: 'JSON',
                        data:{from_date:from_date, to_date:to_date},
                        async:false,
                        success: function (data) {
                            console.log(data);

                            $('#tbl-projects').dataTable({
                                dom: 'Bfrtip',
                                buttons: [
                                    , 'excel', 'pdf', 'print'
                                ],

                                "aaData": data
                                ,
                                "scrollX": true,
                                "aoColumns": [
                                    {"sTitle": "Invoice No", "mData": "Invoice_id"},
                                    {"sTitle": "VendorName", "mData": "vendor_id"},
                                    {"sTitle": "date", "mData": "date"},
                                    {"sTitle": "total", "mData": "total"},
                                    {"sTitle": "pay", "mData": "pay"},
                                    {"sTitle": "due", "mData": "due"},
                                    {"sTitle": "payment_type", "mData": "payment_type"},
                                    {
                                        "sTitle": "Payment Status","mData": "due", "render": function (mData, type, row, meta) {
                                        if (mData != 0) {
                                            return '<span class="label label-info">Pending</span>';
                                        }
                                        else  {
                                            return '<span class="label label-warning">Complete</span>';
                                        }
                                    }
                                    },
                                  ]
                            });
                        },
                        error: function (xhr) {
                            console.log('Request Status: ' + xhr.status  );
                            console.log('Status Text: ' + xhr.statusText );
                            console.log(xhr.responseText);
                            var text = $($.parseHTML(xhr.responseText)).filter('.trace-message').text();
                            console.log(text)
                        }
                    });
                }

0 个答案:

没有答案