function get_inoutgoods_list() { $result = get_filter(); if ($result === false) { $filter = array(); $filter['sid'] = empty($_REQUEST['sid']) ? '0' : intval($_REQUEST['sid']); $filter['ssid'] = empty($_REQUEST['ssid']) ? '0' : intval($_REQUEST['ssid']); $filter['inout_mode'] = empty($_REQUEST['inout_mode']) ? '0' : intval($_REQUEST['inout_mode']); $filter['inout_type'] = empty($_REQUEST['inout_type']) ? '0' : intval($_REQUEST['inout_type']); $filter['add_time1'] = empty($_REQUEST['add_time1']) ? '' : (strpos($_REQUEST['add_time1'], '-') > 0 ? local_strtotime($_REQUEST['add_time1']) : $_REQUEST['add_time1']); $filter['add_time2'] = empty($_REQUEST['add_time2']) ? '' : (strpos($_REQUEST['add_time2'], '-') > 0 ? local_strtotime($_REQUEST['add_time2']) : $_REQUEST['add_time2']); $filter['brand'] = empty($_REQUEST['brand']) ? '0' : intval($_REQUEST['brand']); $filter['goods_sn'] = empty($_REQUEST['goods_sn']) ? '' : trim($_REQUEST['goods_sn']); $filter['goods_name'] = empty($_REQUEST['goods_name']) ? '' : trim($_REQUEST['goods_name']); $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'b.book_id' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']); $where = ' AND b.supplier_id=' . $_SESSION['supplier_id']; if ($filter['ssid']) { $where .= " AND l.store_id = '" . $filter['ssid'] . "' "; } else { if ($filter['sid']) { $where .= " AND l.store_id in " . get_ssid_list($filter['sid']); } } if ($filter['inout_type']) { $where .= " AND l.inout_type = '" . $filter['inout_type'] . "' "; } if ($filter['add_time1']) { $where .= " AND l.add_time>= '" . $filter['add_time1'] . "' "; } if ($filter['add_time2']) { $where .= " AND l.add_time<= '" . $filter['add_time2'] . "' "; } if ($filter['inout_mode']) { $where .= " AND b.inout_mode = '" . $filter['inout_mode'] . "' "; } if ($filter['goods_sn']) { $where .= " AND g.goods_sn = '" . $filter['goods_sn'] . "' "; } if ($filter['goods_name']) { $where .= " AND g.goods_name like '%" . $filter['goods_name'] . "%' "; } if ($filter['brand']) { $where .= " AND g.brand_id = '" . $filter['brand'] . "' "; } /* 总数 */ $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('store_inout_xushibu') . ' AS b ' . ' left join ' . $GLOBALS['ecs']->table('store_inout_list') . ' AS l on b.inout_rec_id=l.rec_id ' . ' left join ' . $GLOBALS['ecs']->table('goods') . ' AS g on b.goods_id = g.goods_id ' . ' WHERE 1 ' . $where; $filter['record_count'] = $GLOBALS['db']->getOne($sql); $filter = page_and_size($filter); /* 获取入库单数据 */ $sql = 'SELECT b.book_id, b.attr_value, b.inout_mode, b.number_shishou, b.number_stock, g.goods_id, ' . 'g.goods_name, g.goods_sn, g.goods_thumb, l.store_id, l.inout_sn, l.order_sn, l.inout_type, l.takegoods_man, l.add_time ' . 'FROM ' . $GLOBALS['ecs']->table('store_inout_xushibu') . ' AS b ' . ' left join ' . $GLOBALS['ecs']->table('store_inout_list') . ' AS l on b.inout_rec_id=l.rec_id ' . ' left join ' . $GLOBALS['ecs']->table('goods') . ' AS g on b.goods_id=g.goods_id ' . ' WHERE 1 ' . $where . ' ORDER by ' . $filter['sort_by'] . ' ' . $filter['sort_order']; $filter['keyword'] = stripslashes($filter['keyword']); set_filter($filter, $sql); } else { $sql = $result['sql']; $filter = $result['filter']; } $arr = array(); $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']); while ($rows = $GLOBALS['db']->fetchRow($res)) { $rows['store_name'] = get_store_fullname($rows['store_id']); $rows['goods_attr_name'] = get_attr_name($rows['attr_value']); $rows['add_time'] = local_date($GLOBALS['_CFG']['time_format'], $rows['add_time']); $rows['goods_thumb'] = get_image_path($rows['goods_id'], $rows['goods_thumb'], true); $rows['inout_type_name'] = get_inout_type_name($rows['inout_type']); $arr[] = $rows; } return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); }
function get_inoutlist() { $result = get_filter(); if ($result === false) { $filter = array(); $filter['sid'] = empty($_REQUEST['sid']) ? '0' : intval($_REQUEST['sid']); $filter['ssid'] = empty($_REQUEST['ssid']) ? '0' : intval($_REQUEST['ssid']); $filter['inout_status'] = empty($_REQUEST['inout_status']) ? '0' : intval($_REQUEST['inout_status']); $filter['inout_type'] = empty($_REQUEST['inout_type']) ? '0' : intval($_REQUEST['inout_type']); $filter['add_time1'] = empty($_REQUEST['add_time1']) ? '' : (strpos($_REQUEST['add_time1'], '-') > 0 ? local_strtotime($_REQUEST['add_time1']) : $_REQUEST['add_time1']); $filter['add_time2'] = empty($_REQUEST['add_time2']) ? '' : (strpos($_REQUEST['add_time2'], '-') > 0 ? local_strtotime($_REQUEST['add_time2']) : $_REQUEST['add_time2']); $filter['inout_sn'] = empty($_REQUEST['inout_sn']) ? '' : trim($_REQUEST['inout_sn']); $filter['takegoods_man'] = empty($_REQUEST['takegoods_man']) ? '' : trim($_REQUEST['takegoods_man']); $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'rec_id' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']); $where = 'AND store_type_id=0 '; if ($filter['ssid']) { $where .= " AND store_id = '" . $filter['ssid'] . "' "; } else { if ($filter['sid']) { $where .= " AND store_id in " . get_ssid_list($filter['sid']); } } if ($filter['inout_status']) { $where .= " AND inout_status = '" . $filter['inout_status'] . "' "; } if ($filter['inout_type']) { $where .= " AND inout_type = '" . $filter['inout_type'] . "' "; } if ($filter['add_time1']) { $where .= " AND add_time>= '" . $filter['add_time1'] . "' "; } if ($filter['add_time2']) { $where .= " AND add_time<= '" . $filter['add_time2'] . "' "; } if ($filter['inout_sn']) { $where .= " AND inout_sn = '" . $filter['inout_sn'] . "' "; } if ($filter['takegoods_man']) { $where .= " AND takegoods_man like '%" . $filter['takegoods_man'] . "%' "; } //获取当前管理员负责的store_id列表 $storeid_list = ""; $sql1 = "select store_id from " . $GLOBALS['ecs']->table('store_adminer') . " where admin_id = '{$_SESSION['admin_id']}' "; $res1 = $GLOBALS['db']->query($sql1); while ($row1 = $GLOBALS['db']->fetchRow($res1)) { $storeid_list .= $storeid_list ? "," : ""; $storeid_list .= $row1['store_id']; $sql2 = "select store_id from " . $GLOBALS['ecs']->table('store_main') . " where parent_id = '{$row1['store_id']}' "; $res2 = $GLOBALS['db']->query($sql2); while ($row2 = $GLOBALS['db']->fetchRow($res2)) { $storeid_list .= $storeid_list ? "," : ""; $storeid_list .= $row2['store_id']; } } if ($storeid_list) { $where .= " AND store_id in ({$storeid_list}) "; } /* 记录总数 */ $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('store_inout_list') . 'WHERE inout_mode=2 ' . $where; $filter['record_count'] = $GLOBALS['db']->getOne($sql); $filter = page_and_size($filter); /* 获取入库单数据 */ $sql = 'SELECT * ' . 'FROM ' . $GLOBALS['ecs']->table('store_inout_list') . 'WHERE inout_mode=2 ' . $where . ' ORDER by ' . $filter['sort_by'] . ' ' . $filter['sort_order']; $filter['keyword'] = stripslashes($filter['keyword']); set_filter($filter, $sql); } else { $sql = $result['sql']; $filter = $result['filter']; } $arr = array(); $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']); while ($rows = $GLOBALS['db']->fetchRow($res)) { $rows['store_name'] = get_store_fullname($rows['store_id']); $rows['add_time'] = local_date($GLOBALS['_CFG']['time_format'], $rows['add_time']); $rows['inout_status_name'] = $GLOBALS['_LANG']['inout_status'][$rows['inout_status']]; $rows['inout_type_name'] = get_inout_type_name($rows['inout_type']); $rows['admin_name'] = $GLOBALS['db']->getOne("select admin_name from " . $GLOBALS['ecs']->table('store_adminer') . " where store_id='{$rows['store_id']}' "); if ($rows['inout_status'] == 1) { //是否有提交申请的权利 $sql_sh = "select rec_id from " . $GLOBALS['ecs']->table('store_adminer') . " where store_id='{$rows['store_id']}' and admin_id='{$_SESSION['admin_id']}' "; $rec_id_sh = $GLOBALS['db']->getOne($sql_sh); if (!$rec_id_sh) { $rows['tjsq'] = 0; } else { $rows['tjsq'] = 1; } } $arr[] = $rows; } return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); }
function get_stocklist() { $result = get_filter(); if ($result === false) { $filter = array(); $filter['sid'] = empty($_REQUEST['sid']) ? '0' : intval($_REQUEST['sid']); $filter['ssid'] = empty($_REQUEST['ssid']) ? '0' : intval($_REQUEST['ssid']); $filter['goods_sn'] = empty($_REQUEST['goods_sn']) ? '' : trim($_REQUEST['goods_sn']); $filter['goods_name'] = empty($_REQUEST['goods_name']) ? '' : trim($_REQUEST['goods_name']); $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 's.goods_id' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']); $where = ' AND store_type_id=0 '; if (!empty($filter['goods_sn'])) { $sql1 = "select goods_id from " . $GLOBALS['ecs']->table('goods') . " where goods_sn like '%{$filter['goods_sn']}%' "; $goods_id1 = $GLOBALS['db']->getCol($sql1); if (count($goods_id1) > 0) { $where .= " AND goods_id in (" . implode(',', $goods_id1) . ")"; } else { $where .= " AND 1!=1 "; } } elseif (!empty($filter['goods_name'])) { $sql1 = "select goods_id from " . $GLOBALS['ecs']->table('goods') . " where goods_name LIKE '%" . mysql_like_quote($filter['goods_name']) . "%' "; $res_goods = $GLOBALS['db']->query($sql1); $goods_id = "0"; while ($row_goods = $GLOBALS['db']->fetchRow($res_goods)) { $goods_id .= "," . $row_goods['goods_id']; } $where .= " AND goods_id in ({$goods_id})"; } if ($filter['ssid']) { $where .= " AND store_id = '" . $filter['ssid'] . "' "; } else { if ($filter['sid']) { $where .= " AND store_id in " . get_ssid_list($filter['sid']); } } /* 库存总数 */ $sql = 'select count(*) from (select count(*) from ' . $GLOBALS['ecs']->table('store_goods_stock') . ' WHERE 1 ' . $where . " group by goods_id,store_id) AS countTemp "; $filter['record_count'] = $GLOBALS['db']->getOne($sql); $filter = page_and_size($filter); /* 获取库存数据 */ $sql = 'SELECT stock_id, goods_id, store_id ' . 'FROM ' . $GLOBALS['ecs']->table('store_goods_stock') . ' WHERE 1 ' . $where . ' group by goods_id,store_id ORDER BY NULL '; $filter['goods_name'] = stripslashes($filter['goods_name']); set_filter($filter, $sql); } else { $sql = $result['sql']; $filter = $result['filter']; } $arr = array(); $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']); while ($rows = $GLOBALS['db']->fetchRow($res)) { $sql = "select goods_name, goods_sn, goods_thumb from " . $GLOBALS['ecs']->table('goods') . " where goods_id='{$rows['goods_id']}' "; $goods_row = $GLOBALS['db']->getRow($sql); $rows['goods_thumb'] = get_image_path($rows['goods_id'], $goods_row['goods_thumb'], true); $rows['goods_name'] = $goods_row['goods_name']; $rows['goods_sn'] = $goods_row['goods_sn']; $rows['store_name'] = get_store_fullname($rows['store_id']); $rows['attr_stock'] = get_attr_stock($rows['goods_id'], $rows['store_id']); $arr[] = $rows; } return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); }