|
|
@@ -7258,8 +7258,8 @@ class Whlabel extends Start_Controller
|
|
|
$this->excelxh->get_fz2($data, $titlename, $filename, $tail);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- public function _whlabelexcelzh()
|
|
|
+ //梦体发现 用数字粘贴 会出现遗产给的数据
|
|
|
+ public function _whlabelexcelzh_ztsh()
|
|
|
{
|
|
|
if (isset($_GET['excel'])) {
|
|
|
$where = "sku != 'Preset'";
|
|
|
@@ -7394,7 +7394,159 @@ class Whlabel extends Start_Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function _fc()
|
|
|
+ //用XML(SpreadsheetML)格式导出excel,逻辑与_whlabelexcelzh一致,仅输出格式不同
|
|
|
+ public function _whlabelexcelzh()
|
|
|
+ {
|
|
|
+ $excelxml = function ($info_list, $headers, $numkeys, $filename) {
|
|
|
+ $str = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
|
|
+ $str .= '<?mso-application progid="Excel.Sheet"?>' . "\n";
|
|
|
+ $str .= '<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">' . "\n";
|
|
|
+ $str .= '<Worksheet ss:Name="Sheet1">' . "\n";
|
|
|
+ $str .= '<Table>' . "\n";
|
|
|
+ $str .= '<Row>' . "\n";
|
|
|
+ foreach ($headers as $h) {
|
|
|
+ $str .= '<Cell><Data ss:Type="String">' . htmlspecialchars($h, ENT_QUOTES, 'UTF-8') . '</Data></Cell>' . "\n";
|
|
|
+ }
|
|
|
+ $str .= '</Row>' . "\n";
|
|
|
+ foreach ($info_list as $row) {
|
|
|
+ $str .= '<Row>' . "\n";
|
|
|
+ foreach ($row as $ke => $va) {
|
|
|
+ $va = (string)$va;
|
|
|
+ $va = str_replace('<br>', "\n", $va);
|
|
|
+ if ($va === '') {
|
|
|
+ $str .= '<Cell><Data ss:Type="String"></Data></Cell>' . "\n";
|
|
|
+ } else if (in_array($ke, $numkeys) && is_numeric($va)) {
|
|
|
+ $str .= '<Cell><Data ss:Type="Number">' . $va . '</Data></Cell>' . "\n";
|
|
|
+ } else {
|
|
|
+ $str .= '<Cell><Data ss:Type="String">' . htmlspecialchars($va, ENT_QUOTES, 'UTF-8') . '</Data></Cell>' . "\n";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $str .= '</Row>' . "\n";
|
|
|
+ }
|
|
|
+ $str .= '</Table>' . "\n";
|
|
|
+ $str .= '</Worksheet>' . "\n";
|
|
|
+ $str .= '</Workbook>' . "\n";
|
|
|
+ while (ob_get_level()) {
|
|
|
+ ob_end_clean();
|
|
|
+ }
|
|
|
+ header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
|
|
|
+ header("Content-Disposition: attachment; filename=" . $filename);
|
|
|
+ header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
|
|
+ header("Pragma: no-cache");
|
|
|
+ header("Expires: 0");
|
|
|
+ echo $str;
|
|
|
+ exit();
|
|
|
+ };
|
|
|
+
|
|
|
+ if (isset($_GET['excel'])) {
|
|
|
+ $where = "sku != 'Preset'";
|
|
|
+ //数据排序
|
|
|
+ $order_str = "id desc";
|
|
|
+ if (empty($page)) {
|
|
|
+ $start = 0;
|
|
|
+ $perpage = 1;
|
|
|
+ } else {
|
|
|
+ $start = ($page - 1) * $perpage;
|
|
|
+ }
|
|
|
+ $category = $this->input->get('category', true);
|
|
|
+ $warehouse = $this->input->get('warehouse', true);
|
|
|
+ $excelid = $this->input->get('sid', true);
|
|
|
+ if ($category) {
|
|
|
+ $where .= " and features like '%-$category-%'";
|
|
|
+ }
|
|
|
+ if ($warehouse) {
|
|
|
+ $where .= " and warehouse = '$warehouse'";
|
|
|
+ }
|
|
|
+ $xzid = '';
|
|
|
+ if ($excelid) {
|
|
|
+ $excelid = explode(',', trim($excelid, ','));
|
|
|
+ foreach ($excelid as $key => $value) {
|
|
|
+ $xzid .= " id = " . $value . " or";
|
|
|
+ }
|
|
|
+ $xzid = " and (" . rtrim($xzid, 'or') . ");";
|
|
|
+ }
|
|
|
+ $list = array();
|
|
|
+ $rows = $this->whlabel->find_pc($where, 'sku,title,features,warehouse', 'warehouse,sku,title,number,features');
|
|
|
+ foreach ($rows as $key => $value) {
|
|
|
+ $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
|
|
|
+ $zh = '';
|
|
|
+ $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
|
|
|
+ foreach ($zt as $v) {
|
|
|
+ $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
|
|
|
+ }
|
|
|
+ $zt = array_sum(array_column($zt, 'num'));
|
|
|
+ $number = $value['number'];
|
|
|
+ $ftime = time() - 15 * 24 * 3600;
|
|
|
+ $warehouse = $this->warehouse->read($value['warehouse']);
|
|
|
+ //按表头顺序输出:仓库 | SKU | 产品 | 库存数量 | 在途数量及预达日期 | 在途+库存数量
|
|
|
+ $rows[$key] = array(
|
|
|
+ 'warehouse' => ($warehouse !== false && isset($warehouse['title'])) ? $warehouse['title'] : $value['warehouse'],
|
|
|
+ 'sku' => $value['sku'],
|
|
|
+ 'title' => isset($value['title']) ? $value['title'] : '',
|
|
|
+ 'number' => $c,
|
|
|
+ 'features' => $zh,
|
|
|
+ 'hb' => $c + $zt,
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
|
|
|
+ $filename = $title . ".xls";
|
|
|
+ $headers = array('仓库', 'SKU', '产品', '库存数量', '在途数量及预达日期', '在途+库存数量');
|
|
|
+ $numkeys = array('number', 'hb');
|
|
|
+ $excelxml($rows, $headers, $numkeys, $filename);
|
|
|
+ }
|
|
|
+ if (isset($_GET['excel'])) {
|
|
|
+ $warehouse = $this->input->get('warehouse', true);
|
|
|
+ $sku = $this->input->get('sku', true);
|
|
|
+ $cz = $this->input->get('cz', true);
|
|
|
+ $text = $this->input->post('text', true);
|
|
|
+ $xztime = $this->input->get('xztime', true);
|
|
|
+ $timetk = $this->input->get('timetk', true);
|
|
|
+ $timetj = $this->input->get('timetj', true);
|
|
|
+ $timetk = strtotime($timetk);
|
|
|
+ $timetj = strtotime($timetj);
|
|
|
+ $where = "time = '0' ";
|
|
|
+ if ($warehouse) {
|
|
|
+ $where .= " and warehouse = '$warehouse'";
|
|
|
+ }
|
|
|
+ if ($sku) {
|
|
|
+ $where .= " and sku = '$sku'";
|
|
|
+ }
|
|
|
+ if ($text) {
|
|
|
+ $where .= " and text like '%$text%'";
|
|
|
+ }
|
|
|
+ if ($cz != '') {
|
|
|
+ $where .= " and cz = '$cz'";
|
|
|
+ }
|
|
|
+ if ($timetk && $timetj) {
|
|
|
+ $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
|
|
|
+ }
|
|
|
+ //数据排序
|
|
|
+ $order_str = $xztime . " desc";
|
|
|
+ //取得信息列表
|
|
|
+ $zh = array();
|
|
|
+ $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
|
|
|
+ foreach ($info_list as $v) {
|
|
|
+ $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
|
|
|
+ $warehouse = $this->warehouse->read($v['warehouse']);
|
|
|
+ $v['warehouse'] = ($warehouse !== false && isset($warehouse['title'])) ? $warehouse['title'] : $v['warehouse'];
|
|
|
+ $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
|
|
|
+ $v['stime'] = date('Y-m-d', $v['stime']);
|
|
|
+ if (isset($zh[$v['features']])) {
|
|
|
+ $zh[$v['features']]['num'] += $v['num'];
|
|
|
+ } else {
|
|
|
+ $zh[$v['features']] = $v;
|
|
|
+ }
|
|
|
+ $zh[$v['features']]['features'] = $c;
|
|
|
+ }
|
|
|
+ $title = "在途数据" . date('Y-m-d', time());
|
|
|
+ $filename = $title . ".xls";
|
|
|
+ $headers = array('仓库', 'SKU', '名称', '在途数量', '库存数量', '添加在途日期', '预达日期', '备注');
|
|
|
+ $numkeys = array('num', 'features');
|
|
|
+ $excelxml($zh, $headers, $numkeys, $filename);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+public function _fc()
|
|
|
{
|
|
|
$vip = 0;
|
|
|
if (isset($_SESSION['api'])) {
|