mirror of
https://gitee.com/ShopeX/OMS
synced 2026-03-22 18:35:35 +08:00
144 lines
4.3 KiB
PHP
144 lines
4.3 KiB
PHP
<?php
|
||
/**
|
||
* Copyright © ShopeX (http://www.shopex.cn). All rights reserved.
|
||
* See LICENSE file for license details.
|
||
*/
|
||
|
||
class console_mdl_dailyinventory_items extends dbeav_model
|
||
{
|
||
public $has_export_cnf = true;
|
||
|
||
/**
|
||
* modifier_stock_date
|
||
* @param mixed $value value
|
||
* @return mixed 返回值
|
||
*/
|
||
public function modifier_stock_date($value)
|
||
{
|
||
return $value;
|
||
}
|
||
|
||
/**
|
||
* modifier_warehouse_code
|
||
* @param mixed $value value
|
||
* @param mixed $list list
|
||
* @return mixed 返回值
|
||
*/
|
||
public function modifier_warehouse_code($value, $list)
|
||
{
|
||
list($s, $b) = explode('_', $value);
|
||
|
||
|
||
return $b ?: $s;
|
||
}
|
||
|
||
/**
|
||
* exportName
|
||
* @param mixed $data 数据
|
||
* @return mixed 返回值
|
||
*/
|
||
public function exportName(&$data)
|
||
{
|
||
$data['name'] = '日盘明细-'.date('Ymd');
|
||
}
|
||
|
||
/**
|
||
* fgetlist_csv
|
||
* @param mixed $data 数据
|
||
* @param mixed $filter filter
|
||
* @param mixed $offset offset
|
||
* @param mixed $exportType exportType
|
||
* @return mixed 返回值
|
||
*/
|
||
public function fgetlist_csv(&$data, $filter, $offset, $exportType = 1)
|
||
{
|
||
$limit = 200;
|
||
$items = $this->getList('*', $filter, $offset * $limit, $limit);
|
||
if (!$items) {
|
||
return false;
|
||
}
|
||
$export_fields = 'column_material_name';
|
||
$finderObj = kernel::single('console_finder_dailyinventory_items');
|
||
foreach ($items as $key=>$aFilter) {
|
||
foreach (explode(',', $export_fields) as $v) {
|
||
if ('column_' == substr($v, 0, 7) && method_exists($finderObj, $v)) {
|
||
$cv = $finderObj->{$v}($aFilter, $items);
|
||
$items[$key][substr($v,7)] = $cv;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (!$data['title']) {
|
||
$title = array();
|
||
foreach ($this->io_title() as $k => $v) {
|
||
$title[] = $v;
|
||
}
|
||
|
||
$data['title']['items'] = mb_convert_encoding('"' . implode('","', $title) . '"', 'GBK', 'UTF-8');
|
||
}
|
||
|
||
foreach ($items as $k => $aFilter) {
|
||
$row['日期'] = $aFilter['stock_date'];
|
||
$row['仓编码'] = $aFilter['warehouse_code'];
|
||
$row['物料编码'] = $aFilter['material_bn'];
|
||
$row['物料名称'] = $aFilter['material_name'];
|
||
$row['库位'] = $aFilter['storage_code'];
|
||
$row['系统库存'] = $aFilter['oms_stock'];
|
||
$row['WMS库存'] = $aFilter['outer_stock'];
|
||
$row['库存差异'] = $aFilter['diff_stock'];
|
||
$row['对比方式'] = $aFilter['diff_type'] == '2' ? '按颗对比':'按条对比';
|
||
$data['content']['items'][] = mb_convert_encoding('"' . implode('","', $row) . '"', 'GBK', 'UTF-8');
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* export_csv
|
||
* @param mixed $data 数据
|
||
* @param mixed $exportType exportType
|
||
* @return mixed 返回值
|
||
*/
|
||
public function export_csv($data, $exportType = 1)
|
||
{
|
||
|
||
$output = array();
|
||
|
||
$output[] = $data['title']['items'] . "\n" . implode("\n", (array) $data['content']['items']);
|
||
|
||
echo implode("\n", $output);
|
||
}
|
||
|
||
/**
|
||
* io_title
|
||
* @param mixed $filter filter
|
||
* @param mixed $ioType ioType
|
||
* @return mixed 返回值
|
||
*/
|
||
public function io_title($filter = null, $ioType = 'csv')
|
||
{
|
||
switch ($ioType) {
|
||
case 'csv':
|
||
default:
|
||
$this->oSchema['csv']['main'] = array(
|
||
'日期' => 'stock_date',
|
||
'仓编码' => 'warehouse_code',
|
||
'物料编码' => 'material_bn',
|
||
'物料名称' => 'material_name',
|
||
'库位' => 'storage_code',
|
||
'系统库存' => 'oms_stock',
|
||
'WMS库存' => 'outer_stock',
|
||
'库存差异' => 'diff_stock',
|
||
'对比方式' => 'diff_type',
|
||
);
|
||
}
|
||
$this->ioTitle[$ioType][$filter] = array_keys($this->oSchema[$ioType]['main']);
|
||
return $this->ioTitle[$ioType][$filter];
|
||
}
|
||
|
||
function modifier_diff_type($cols){
|
||
return $cols == '2' ? '按颗对比':'按条对比';
|
||
}
|
||
|
||
}
|