//Controller
class Product_ReceivingController extends Zend_Controller_Action {
//質檢組收貨及積壓預警清單
public function qcGroupReceivingAndBacklogReportAction() {
set_time_limit(0);
$catearray = Product_Service_Receiving::$productCategory;
if ($this->_request->isPost()) {
$warehouseId = $this->_request->getParam("userWarehouse", "");
$startTime = $this->_request->getParam("start_time", "");
$endTime = $this->_request->getParam("end_time", "");
$return = array(
"ask" => 0,
"msg" => "",
"data" => "",
"count" => "",
);
if (!$warehouseId) {
$return['msg'] = "請選擇倉庫";
die(Zend_Json::encode($return));
}
if (!$startTime || !$endTime) {
$return['msg'] = "請選擇時間";
die(Zend_Json::encode($return));
}
$data = array();
$week = array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
$date = date("Y-m-d");
if (strtotime($endTime) >= strtotime($date)) {
$data[] = Product_Service_QualityReceivingBacklog::generateQualityReceivingBacklog($date, $warehouseId);
$combination = array(
"warehouse_id" => $warehouseId,
"start_date" => $startTime,
"end_date" => $endTime,
);
$qrbIds = Product_Service_QualityReceivingBacklog::getCombination($combination, "*", "qrb_date desc");
if ($qrbIds) {
foreach ($qrbIds as $value) {
$data[] = $value;
}
}
} else {
$combination = array(
"warehouse_id" => $warehouseId,
"start_date" => $startTime,
"end_date" => $endTime,
);
$qrbIds = Product_Service_QualityReceivingBacklog::getCombination($combination, "*", "qrb_date desc");
if ($qrbIds) {
foreach ($qrbIds as $value) {
$data[] = $value;
}
}
}
if (!$data) {
$return['msg'] = "未擷取到對應資料";
die(json_encode($return));
}
$list = array();
foreach ($data as $key => $valu) {
$list[$key]['qrb_date'] = $valu['qrb_date'];
$list[$key]['week'] = $week[date("w", strtotime($valu['qrb_date']))];
$list[$key]['qrb_peceiving_votes'] = !isset($valu['qrb_peceiving_votes']) ? "" : $valu['qrb_peceiving_votes'];
$list[$key]['qrb_po'] = !isset($valu['qrb_po']) ? "" : $valu['qrb_po'];
$list[$key]['qrb_csp'] = !isset($valu['qrb_csp']) ? "" : $valu['qrb_csp'];
$list[$key]['qrb_csp_proportion'] = !isset($valu['qrb_csp_proportion']) ? "" : $valu['qrb_csp_proportion'];
$list[$key]['qrb_manual_asn'] = !isset($valu['qrb_manual_asn']) ? "" : $valu['qrb_manual_asn'];
$list[$key]['qrb_manual_asn_proportion'] = !isset($valu['qrb_manual_asn_proportion']) ? "" : $valu['qrb_manual_asn_proportion'];
$list[$key]['qrb_procurement_asn'] = !isset($valu['qrb_procurement_asn']) ? "" : $valu['qrb_procurement_asn'];
$list[$key]['qrb_procurement_asn_proportion'] = !isset($valu['qrb_procurement_asn_proportion']) ? "" : $valu['qrb_procurement_asn_proportion'];
$list[$key]['qrb_processing'] = !isset($valu['qrb_processing']) ? "" : $valu['qrb_processing'];
$list[$key]['qrb_week_processing'] = !isset($valu['qrb_week_processing']) ? "" : $valu['qrb_week_processing'];
$list[$key]['qrb_backlog'] = !isset($valu['qrb_backlog']) ? "" : $valu['qrb_backlog'];
$list[$key]['qrb_backlog_proportion'] = !isset($valu['qrb_backlog_proportion']) ? "" : $valu['qrb_backlog_proportion'];
$list[$key]['qrb_warning_level'] = !isset($valu['qrb_warning_level']) ? "" : $valu['qrb_warning_level'];
$list[$key]['qrb_no_po'] = !isset($valu['qrb_no_po']) ? "" : $valu['qrb_no_po'];
$list[$key]['qrb_no_csp'] = !isset($valu['qrb_no_csp']) ? "" : $valu['qrb_no_csp'];
$list[$key]['qrb_is_csp'] = !isset($valu['qrb_is_csp']) ? "" : $valu['qrb_is_csp'];
$list[$key]['qrb_category'] = !isset($valu['qrb_category']) ? "" : unserialize($valu['qrb_category']);
}
$return['ask'] = 1;
$return['data'] = $list;
$return['count'] = count($list);
$return['count_category'] = count($catearray);
die(Zend_Json::encode($return));
}
$this->view->category = $catearray;
echo Cff::renderTpl($this->tplDirectory . "receiving-and-backlog-reports.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" target="_blank" rel="external nofollow" rel="stylesheet" type="text/css"/>
<script src="/js/product/receiving/receiving-and-backlog-reports.js"></script>
</head>
<body>
<div class="search_div">
<form id="sForm" name="sForm" onsubmit='return false;'>
<div>
<label>
<{include file=$userWarehouseTpl}>
</label>
<input type="text" name="start_time" id="start_time" style="text-align: center">
- -
<input type="text" name="end_time" id="end_time" style="text-align: center">
<input class="button search" type="button" value="搜尋">
<input class="button" type="button" value="收件人" onclick="addressee()">
<input class="button" type="button" value="預警名額設定" onclick="warningIndicatorSetting()" style="color: red; width: 90px">
</div>
</form>
</div>
<table width="100%" cellspacing="0" cellpadding="0" class="myTab">
<tbody>
<tr class="even-tr">
<th colspan="2">時間</th>
<th colspan="4">收貨資料</th>
<th colspan="4">PO 單綁定資料</th>
<th colspan="5">積壓預警</th>
<th colspan="100%">積壓資料</th>
</tr>
<tr class="even-tr">
<th>日期</th>
<th>星期</th>
<th>收貨票數</th>
<th>PO 收貨量</th>
<th>CSP 收貨量</th>
<th>CSP 占比</th>
<th>有 ASN 單的票數</th>
<th>占比</th>
<th>無 ASN 單的票數</th>
<th>占比</th>
<th>當天處理票數</th>
<th>上周日均處理票數</th>
<th>積壓票數</th>
<th>積壓 / 日均處理票數 %</th>
<th>預警等級</th>
<th>未綁定 PO 票數</th>
<th>非 CSP</th>
<th>CSP</th>
<{foreach from=$category key="key" item="value"}>
<th value="<{$key}>"><{$value}></th>
<{/foreach}>
</tr>
</tbody>
<tbody id="loadData" style="text-align: center"></tbody>
</table>
<div id="addresseeDialog" title="收件人" style="display: none; text-align: center"></div>
<div id="warningIndicatorSettingDialog" title="預警名額設定" style="display: none"></div>
</body>
</html>
js
//清單
function loadData() {
loading();
$.ajax({
url: "/product/receiving/qc-group-receiving-and-backlog-report",
async: false,
dataType: "json",
type: "post",
data: $("#sForm").serializeArray(),
success: function (json) {
var Html = "";
if (!json.ask) {
alertTip(json.msg);
Html += "<tr><td colspan='100%'>" + json.msg + "</td></tr>";
} else {
$.each(json.data, function (key, value) {
if (key % 2 == 0) {
Html += "<tr>";
} else {
Html += "<tr class='even-tr'>";
}
Html += "<td>" + value.qrb_date + "</td>";
Html += "<td>" + value.week + "</td>";
Html += "<td>" + value.qrb_peceiving_votes + "</td>";
Html += "<td>" + value.qrb_po + "</td>";
Html += "<td>" + value.qrb_csp + "</td>";
if (value.qrb_csp_proportion) {
Html += "<td>" + value.qrb_csp_proportion + "%</td>";
} else {
Html += "<td></td>";
}
Html += "<td>" + value.qrb_manual_asn + "</td>";
if (value.qrb_manual_asn_proportion) {
Html += "<td>" + value.qrb_manual_asn_proportion + "%</td>";
} else {
Html += "<td></td>";
}
Html += "<td>" + value.qrb_procurement_asn + "</td>";
if (value.qrb_procurement_asn_proportion) {
Html += "<td>" + value.qrb_procurement_asn_proportion + "%</td>";
} else {
Html += "<td></td>";
}
Html += "<td>" + value.qrb_processing + "</td>";
Html += "<td>" + value.qrb_week_processing + "</td>";
Html += "<td>" + value.qrb_backlog + "</td>";
if (value.qrb_backlog_proportion) {
Html += "<td>" + value.qrb_backlog_proportion + "%</td>";
} else {
Html += "<td></td>";
}
Html += "<td style='background-color: " + value.qrb_warning_level + "' ></td>";
Html += "<td>" + value.qrb_no_po + "</td>";
Html += "<td>" + value.qrb_no_csp + "</td>";
Html += "<td>" + value.qrb_is_csp + "</td>";
if (value.qrb_category) {
$.each(value.qrb_category, function (k, val) {
if (val != 0) {
Html += "<td value=" + k + ">" + val + "</td>";
} else {
Html += "<td value=" + k + "></td>";
}
})
} else {
for (var i = 0; i < json.count_category; i++) {
Html += "<td></td>";
}
}
Html += "</tr>";
});
}
$("#loadData").html(Html);
}
});
closeLoading();
}