|
@@ -234,7 +234,11 @@ class Out
|
|
|
|
|
|
$config_type = $config['config_type'];
|
|
|
$config_type = $config_type();
|
|
|
- $out_type = $config_type[$info['out_type']]['name'];
|
|
|
+ if (isset($config_type[$info['out_type']])) {
|
|
|
+ $out_type = $config_type[$info['out_type']]['name'];
|
|
|
+ } else {
|
|
|
+ $out_type = '其他';
|
|
|
+ }
|
|
|
|
|
|
$cdate = date('Y-m-d H:i', $info['cdate']);
|
|
|
|
|
@@ -292,6 +296,13 @@ class Out
|
|
|
'name' => '打印出库单',
|
|
|
);
|
|
|
|
|
|
+ $button[] = array
|
|
|
+ (
|
|
|
+ 'type' => 'link',
|
|
|
+ 'link' => Dever::url('lib/out.excel_one?type='.$info['type'].'&id='.$info['id'], 'mshop'),
|
|
|
+ 'name' => '导出',
|
|
|
+ );
|
|
|
+
|
|
|
$button[] = array
|
|
|
(
|
|
|
'type' => 'alert',
|
|
@@ -307,6 +318,13 @@ class Out
|
|
|
'link' => Dever::url('lib/out.yes?id='.$info['type_id'].'&order_id='.$info['id'], 'mshop'),
|
|
|
'name' => '审核',
|
|
|
);
|
|
|
+
|
|
|
+ $button[] = array
|
|
|
+ (
|
|
|
+ 'type' => 'link',
|
|
|
+ 'link' => Dever::url('lib/out.excel_one?type='.$info['type'].'&id='.$info['id'], 'mshop'),
|
|
|
+ 'name' => '导出',
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
$body = array();
|
|
@@ -390,7 +408,12 @@ class Out
|
|
|
|
|
|
$config_type = $config['config_type'];
|
|
|
$config_type = $config_type();
|
|
|
- $out_type = $config_type[$info['out_type']]['name'];
|
|
|
+ if (isset($config_type[$info['out_type']])) {
|
|
|
+ $out_type = $config_type[$info['out_type']]['name'];
|
|
|
+ } else {
|
|
|
+ $out_type = '其他';
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
$cdate = date('Y-m-d H:i', $info['cdate']);
|
|
|
|
|
@@ -480,13 +503,78 @@ class Out
|
|
|
$pdf->out('库存清单');
|
|
|
}
|
|
|
|
|
|
+ # 导出单个订单
|
|
|
+ public function excel_one_api()
|
|
|
+ {
|
|
|
+ $this->type = Dever::input('type');
|
|
|
+ $id = Dever::input('id');
|
|
|
+ $data = Dever::db('shop/out_order')->select($id);
|
|
|
+ $this->excel($data);
|
|
|
+ }
|
|
|
+
|
|
|
# 导出订单
|
|
|
public function excel($data)
|
|
|
{
|
|
|
- print_r($data);die;
|
|
|
+ if (!$data) {
|
|
|
+ Dever::alert('无导出数据');
|
|
|
+ }
|
|
|
$file = '出库订单';
|
|
|
+ $type = Dever::input('search_option_type', $this->type);
|
|
|
+
|
|
|
+ $header = array('所属仓库', '出库单号', '商品名称', '商品规格属性', '商品采购价格', '商品出库数量', '采购总价格', '出库类型', '出库状态', '出库时间');
|
|
|
+
|
|
|
+ $table = 'store/info';
|
|
|
+ if ($type == 1) {
|
|
|
+ $header[0] = '所属门店';
|
|
|
+ $header[4] = '商品销售价格';
|
|
|
+ $header[6] = '销售总价格';
|
|
|
+ $table = 'shop/info';
|
|
|
+ }
|
|
|
+
|
|
|
+ $body = array();
|
|
|
+ $out_type = Dever::db('shop/out_type')->getAll();
|
|
|
+ $status = Dever::db('shop/out_order')->config['config_status'];
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
+ if (!is_array($v)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $type_info = Dever::db($table)->find($v['type_id']);
|
|
|
+ $goods = Dever::db('shop/out_order_goods')->select(array('order_id' => $v['id']));
|
|
|
+ if (isset($out_type[$v['out_type']]) && $out_type[$v['out_type']]) {
|
|
|
+ $out_type_name = $out_type[$v['out_type']]['name'];
|
|
|
+ } else {
|
|
|
+ $out_type_name = '其他';
|
|
|
+ }
|
|
|
+ $status_name = $status[$v['status']];
|
|
|
+
|
|
|
+ $cdate = strstr($v['cdate'], '-') ? $v['cdate'] : date('Y-m-d H:i', $v['cdate']);
|
|
|
+
|
|
|
+ foreach ($goods as $k1 => $v1) {
|
|
|
+
|
|
|
+ $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']);
|
|
|
+ if (isset($goods_info['sku'])) {
|
|
|
+ $sku = $goods_info['sku']['string'];
|
|
|
+ } else {
|
|
|
+ $sku = '';
|
|
|
+ }
|
|
|
|
|
|
- $header = array();
|
|
|
+ $d = array
|
|
|
+ (
|
|
|
+ $type_info['name'],
|
|
|
+ $v['order_num'],
|
|
|
+ $goods_info['name'],
|
|
|
+ $sku,
|
|
|
+ $v1['price'],
|
|
|
+ $v1['num'],
|
|
|
+ $v1['price']*$v1['num'],
|
|
|
+ $out_type_name,
|
|
|
+ $status_name,
|
|
|
+ $cdate,
|
|
|
+ );
|
|
|
+
|
|
|
+ $body[] = $d;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
Dever::excelExport($body, $header, $file);
|
|
|
}
|