包材数据明细列表

//Controller
class Product_PackageController extends Zend_Controller_Action {
    //包材数据明细列表
    public function packagingMaterialsListAction() {
        if ($this->_request->isPost()) {
            $warehouseId = $this->_request->getParam('userWarehouse', '');
            $productSku = $this->_request->getParam('product_sku', '');
            $startDate = $this->_request->getParam('start_date', '');
            $endDate = $this->_request->getParam('end_date', '');
            $return = array(
                'ask' => 0,
                'msg' => '',
                'data' => '',
                'count' => '',
            );
            if ($startDate && $endDate) {
                if ($warehouseId || $productSku) {
                    $combination = array(
                        'warehouse_id' => $warehouseId,
                        'product_sku' => $productSku,
                        'start_date' => $startDate . ' 00:00:00',
                        'end_date' => $endDate . ' 23:59:59',
                    );
                } else {
                    $return['msg'] = '请选择仓库或者输入耗材 ID';
                    die(Zend_Json::encode($return));
                }
            } else {
                $return['msg'] = '请选择时间段';
                die(Zend_Json::encode($return));
            }

            $pmIds = Product_Service_PackagingMaterials::getCombination($combination, '*');
            if ($pmIds) {
                $row = array();
                $data = array();
                foreach ($pmIds as $key => $value) {
                    $key = date('n月', strtotime($value['pm_create_date']));
                    $product_sku = $value['product_sku'];
                    if (!isset($row[$key][$product_sku])) {
                        $row[$key][$product_sku]['pm_beginning_quantity'] = $value['pm_beginning_quantity'];
                        $row[$key][$product_sku]['pm_beginning_gold'] = $value['pm_beginning_gold'];
                        $row[$key][$product_sku]['start_date'] = $value['pm_create_date'];
                    }
                    $data[$key][$product_sku]['beginning_inventory_quantity'] = $row[$key][$product_sku]['pm_beginning_quantity'] < 0 ? 0 : $row[$key][$product_sku]['pm_beginning_quantity'];
                    $data[$key][$product_sku]['beginning_inventory_gold'] = $row[$key][$product_sku]['pm_beginning_gold'] < 0 ? 0 : $row[$key][$product_sku]['pm_beginning_gold'];
                    if (!isset($data[$key][$product_sku]['into_quantity_count'])) {
                        $data[$key][$product_sku]['into_quantity_count'] = '';
                        $data[$key][$product_sku]['into_gold_count'] = '';
                    }
                    if (!isset($data[$key][$product_sku]['outbound_quantity_count'])) {
                        $data[$key][$product_sku]['outbound_quantity_count'] = '';
                        $data[$key][$product_sku]['outbound_gold_count'] = '';
                    }
                    if ($value['pm_type'] == 0 || $value['pm_type'] == 2) {
                        $data[$key][$product_sku]['into_quantity_count'] += $value['pm_quantity'];
                        $data[$key][$product_sku]['into_gold_count'] += $value['pm_gold'];
                    } else {
                        $data[$key][$product_sku]['outbound_quantity_count'] += $value['pm_quantity'];
                        $data[$key][$product_sku]['outbound_gold_count'] += $value['pm_gold'];
                    }
                    $data[$key][$product_sku]['end_semester_inventory_quantity'] = $value['pm_end_semester_quantity'];
                    $data[$key][$product_sku]['end_semester_inventory_gold'] = $value['pm_end_semester_gold'];
                    $data[$key][$product_sku]['start_date'] = date('Y-m-d', strtotime($row[$key][$product_sku]['start_date']));
                    $data[$key][$product_sku]['end_date'] = date('Y-m-d', strtotime($value['pm_create_date']));
                }
                ksort($data);
                $return['ask'] = 1;
                $return['data'] = $data;
                $return['count'] = count($data);
            } else {
                $return['msg'] = '未查询到对应数据';
            }
            die(Zend_Json::encode($return));
        }
        echo Cff::renderTpl($this->tplDirectory . 'packaging-materials-list.tpl', 'layout');
    }
    }


//Html
<!DOCTYPE html>
<html>
    <head>
        <title>包材数据明细列表</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="/css/order/transport.css" rel="stylesheet" type="text/css"/>
        <script src="/js/product/package/packaging-materials-list.js"></script>
    </head>
    <body>
        <div class="search_div">
            <form id="sForm" name="sForm" onsubmit='return false;'>
                <div>
                    <label><{include file=$userWarehouseTpl}></label>
                    &nbsp;&nbsp;
                    SKU:
                    <input type="text"  name="product_sku" id="product_sku" style="text-align: center">
                    &nbsp;&nbsp;
                    时间段:
                    <input type="text"  name="start_date" id="start_date" style="text-align: center">
                    &nbsp;&nbsp;- -&nbsp;&nbsp;
                    <input type="text"  name="end_date" id="end_date" style="text-align: center">
                    &nbsp;&nbsp;
                    <input class="button search" type="button" value="搜索">
                    &nbsp;&nbsp;
                    <input class="button" type="button" value="导出指定 SKU 详细报表" onclick="exportPackagingMaterials(0)" style="width: 4cm">
                    &nbsp;&nbsp;
                    <input class="button" type="button" value="导出包材汇总表" onclick="exportPackagingMaterials(1)" style="width: 3cm">
                    &nbsp;&nbsp;
                </div>
            </form>
        </div>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="myTab">
            <tbody>
                <tr class="even-tr">
                    <th>月份</th>
                    <th>产品 SKU</th>
                    <th>期初库存数量</th>
                    <th>期初库存金额</th>
                    <th>入库数量汇总</th>
                    <th>入库金额汇总</th>
                    <th>出库数量汇总</th>
                    <th>出库金额汇总</th>
                    <th>期末库存数量</th>
                    <th>期末库存金额</th>
                </tr>
            </tbody>
            <tbody id="loadData" style="text-align: center"></tbody>
        </table>
    </body>
</html>


js
//初始化
$(function () {
    //日期
    var dayNamesMin = ["日", "一", "二", "三", "四", "五", "六"];
    var monthNamesShort = ["01月", "02月", "03月", "04月", "05月", "06月", "07月", "08月", "09月", "10月", "11月", "12月"];
    $("#start_date").datepicker({
        dayNamesMin: dayNamesMin,
        monthNamesShort: monthNamesShort,
        changeMonth: true,
        changeYear: true,
        dateFormat: "yy-mm-dd"
    });
    $("#end_date").datepicker({
        dayNamesMin: dayNamesMin,
        monthNamesShort: monthNamesShort,
        changeMonth: true,
        changeYear: true,
        dateFormat: "yy-mm-dd"
    });

    //搜索
    $(".search").click(function () {
        initData(0);
    });
});

//包材数据明细列表
function loadData() {
    loading();
    $.ajax({
        url: "/product/package/packaging-materials-list",
        async: false,
        dataType: "json",
        type: "post",
        data: $("#sForm").serializeArray(),
        success: function (json) {
            var Html = "";
            if (json.ask) {
                $.each(json.data, function (key, value) {
                    $.each(value, function (ke, valu) {
                        Html += "<tr>";
                        Html += "<td>" + key + "</td>";
                        Html += "<td onclick='packagingMaterialsDetailList(\"" + ke + "\", \"" + valu.start_date + "\", \"" + valu.end_date + "\")' style='cursor: pointer'>" + ke + "</td>";
                        Html += "<td>" + valu.beginning_inventory_quantity + "</td>";
                        Html += "<td>" + valu.beginning_inventory_gold + "</td>";
                        Html += "<td>" + valu.into_quantity_count + "</td>";
                        Html += "<td>" + valu.into_gold_count + "</td>";
                        Html += "<td>" + valu.outbound_quantity_count + "</td>";
                        Html += "<td>" + valu.outbound_gold_count + "</td>";
                        Html += "<td>" + valu.end_semester_inventory_quantity + "</td>";
                        Html += "<td>" + valu.end_semester_inventory_gold + "</td>";
                        Html += "</tr>";
                    });
                });
            } else {
                alertTip(json.msg);
                Html += "<tr><td colspan='100%'>" + json.msg + "</td></tr>";
            }
            $("#loadData").html(Html);
        }
    });
    closeLoading();
}

//提示
function alertTip(tip) {
    $("<div title='提示'><p align='center'>" + tip + "</p></div>").dialog({
        modal: true,
        buttons: {
            '确定': function () {
                $(this).dialog("close");
            }
        }
    });
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值