//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>
SKU:
<input type="text" name="product_sku" id="product_sku" style="text-align: center">
时间段:
<input type="text" name="start_date" id="start_date" style="text-align: center">
- -
<input type="text" name="end_date" id="end_date" style="text-align: center">
<input class="button search" type="button" value="搜索">
<input class="button" type="button" value="导出指定 SKU 详细报表" onclick="exportPackagingMaterials(0)" style="width: 4cm">
<input class="button" type="button" value="导出包材汇总表" onclick="exportPackagingMaterials(1)" style="width: 3cm">
</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");
}
}
});
}
包材数据明细列表
最新推荐文章于 2020-11-18 20:29:14 发布