【问题标题】:how to print total in footer in table using codeigniter如何使用codeigniter在表格的页脚中打印总计
【发布时间】:2015-06-17 08:16:28
【问题描述】:

我正在使用 codeigniter 框架。如何在页脚的采购订单列中获取总计。

$return_array[] = array(
    'brand_name'=>$row->brand_name,
    'product_type'=>$row->product_type,
    'product_flavour'=>$row->product_flavour,
    'dealer_price'=>$dealer_price,
    'price'=>$price ,
    'openStock'=>$openStock,
    'total_purchase'=>$toatal_purchase,
    'free_issuese_in'=>$free_issuese_in,   
    'stock_tra_in'=>$stock_tra_in,
    'tot'=> number_format(count($openStock) > 0 ? $openStock[0]->openStock:0,2)+($toatal_purchase[0]->totalPurchase)+($free_issuese_in[0]->freeIssueseIn)+($stock_tra_in[0]->stocktrain),//total
    'totalsales'=>$totalSales,
    'stockTraOut'=>$stockTraOut,
    'freeIssuesOut'=>$freeIssuesOut,
    'clossing_blnc'=>  number_format(count($stockTraOut)> 0 ? $stockTraOut[0]->stockTraOut :0,2)+( $freeIssuesOut[0]->freeIssuesOut)+($totalSales[0]->totalsales)-(number_format(count($openStock) > 0 ? $openStock[0]->openStock:0,2)+($toatal_purchase[0]->totalPurchase)+($free_issuese_in[0]->freeIssueseIn)+($stock_tra_in[0]->stocktrain))//closing balance
);

我传递给 body 的那些数据......这里 7 列是总购买列。我想为页脚另一个 id 获取该列数据的总和。我使用 json 解析传递这些数据。

for( var x=0; x<order.length;x++) {
    order_detail.push(
        '<tr>'
         +'<td>'+ order[x].brand_name + '</td>'
         +'<td>'+ order[x].product_type + '</td>'
         +'<td>'+ order[x].product_flavour +'</td>'
         +'<td id="mm">' + order[x].dealer_price[0].dealer_price +'</td>'
         +'<td id="yy"  style="display:none;">' + order[x].price[0].price+'</td>'
         +'<td>' + order[x].openStock[0].openStock +'</td>'
         +'<td>' + order[x].total_purchase[0].totalPurchase+'</td>'
         +'<td>'+ order[x].free_issuese_in[0].freeIssueseIn + '</td>'
         +'<td>'+ order[x].stock_tra_in[0].stocktrain + '</td>'
         +'<td>' + order[x].tot+'</td>'
         +'<td>' + order[x].totalsales[0].totalsales+'</td>' 
         +'<td>'+ order[x].stockTraOut[0].stockTraOut + '</td>'
         +'<td>'+ order[x].freeIssuesOut[0].freeIssuesOut + '</td>'
         +'<td>'+ order[x].clossing_blnc + '</td>'
         +'</tr>'
   );

}
sweetAlert("Good job!", "monthly stock Succsessfully filter !", "success");
//  $j('#lbl_rescount').text('0');
//  $j('#sl_amount').text(order['totals_td'][0].tot_purchase);

// $j('#sl_amount').html(tot1);
$j('#order_body').html(order_detail);

【问题讨论】:

  • 你的问题不清楚
  • 我想在采购订单列中获取总数.....在表页脚中......如何编码......在数组函数内的模型文件中我无法计算总购买量....

标签: php json codeigniter


【解决方案1】:

首先,您的原始帖子令人困惑。您首先展示 PHP,然后是 JS,让我们假设很多事情。

我的假设是您首先在控制器中创建$return_array,然后将其传递给您的视图。然后在您看来,您以某种方式将其传递给 JS。你在使用 AJAX 吗?您只是将此信息直接传递给 PHP 视图吗?

如果您使用 AJAX,然后使用 JSON.parse()$return_array[] 转换为 order 那么为什么不直接执行以下操作?

var total = 0;
for( var x=0; x<order.length;x++) {
    total+= order[x].total_purchase[0].totalPurchase;
    order_detail.push(
        //your table code
   );

}
$("footer").html(total);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-30
    • 1970-01-01
    • 1970-01-01
    • 2012-12-29
    • 1970-01-01
    • 2020-01-13
    相关资源
    最近更新 更多