Example #1
0
function get_stock_control_log()
{
    $result = get_filter();
    if ($result === false) {
        $filter = array();
        $filter['admin_agency_id'] = empty($_REQUEST['admin_agency_id']) ? '' : trim($_REQUEST['admin_agency_id']);
        $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']);
        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) {
            $filter['keyword'] = json_str_iconv($filter['keyword']);
        }
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'a.id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        $filter['start_date'] = empty($_REQUEST['start_date']) ? local_strtotime('-30 days') : $_REQUEST['start_date'];
        $filter['end_date'] = empty($_REQUEST['end_date']) ? local_strtotime('today') : $_REQUEST['end_date'];
        if (strpos($filter['start_date'], '-') !== false) {
            $filter['start_date'] = local_strtotime($filter['start_date']);
            $filter['end_date'] = local_strtotime($filter['end_date']);
        }
        $where = ' AND stock_status = 1 ';
        $where .= agency_where();
        /*add by ccx for date 2014-11-28 商品入库列表*/
        if (if_agency()) {
            if (!empty($filter['admin_agency_id'])) {
                $where .= " AND (a.admin_agency_id = {$filter['admin_agency_id']} ) ";
            } else {
                $where .= " AND (a.admin_agency_id = 0 ) ";
            }
        }
        if (!empty($filter['keyword'])) {
            $where = $where . " AND (a.goods_name LIKE '%" . mysql_like_quote($filter['keyword']) . "%'  or a.stock_number LIKE '%" . mysql_like_quote($filter['keyword']) . "%' )";
        }
        if ($filter['start_date']) {
            $where = $where . " AND a.log_time >= '{$filter['start_date']}'";
        }
        if ($filter['end_date']) {
            $where = $where . " AND a.log_time <= '" . ($filter['end_date'] + 86400) . "'";
        }
        $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('stock_control_log') . ' AS a ' . 'WHERE 1 ' . $where;
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        $filter = page_and_size($filter);
        /* 获取库存日志管理数据 */
        $sql = 'SELECT a.*  ' . 'FROM ' . $GLOBALS['ecs']->table('stock_control_log') . ' AS a ' . '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['date'] = local_date($GLOBALS['_CFG']['time_format'], $rows['log_time']);
        $arr[] = $rows;
    }
    $GLOBALS['smarty']->assign('start_date', local_date('Y-m-d', $filter['start_date']));
    $GLOBALS['smarty']->assign('end_date', local_date('Y-m-d', $filter['end_date']));
    //显示商品的入库成本入库数量相关信息
    $sql_limit = $sql . " LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",{$filter['page_size']}";
    $overall_order_amount = overall_order_amount($sql);
    //总的计算
    $current_order_amount = current_order_amount($sql_limit);
    // 当前页的计算
    $GLOBALS['smarty']->assign('costing_price_amount', price_format($overall_order_amount['costing_price_amount']));
    $GLOBALS['smarty']->assign('goods_number_amount', $overall_order_amount['goods_number_amount']);
    $GLOBALS['smarty']->assign('current_costing_price_amount', price_format($current_order_amount['current_costing_price_amount']));
    $GLOBALS['smarty']->assign('current_goods_number_amount', $current_order_amount['current_goods_number_amount']);
    $filter['start_date'] = local_date('Y-m-d', $filter['start_date']);
    $filter['end_date'] = local_date('Y-m-d', $filter['end_date']);
    return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
}
Example #2
0
function get_goods_stock_info()
{
    $result = get_filter();
    if ($result === false) {
        $filter = array();
        $filter['admin_agency_id'] = empty($_REQUEST['admin_agency_id']) ? '' : trim($_REQUEST['admin_agency_id']);
        $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']);
        $filter['status'] = strval(trim($_REQUEST['status']));
        //m1
        if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) {
            $filter['keyword'] = json_str_iconv($filter['keyword']);
        }
        $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'a.id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        $where = agency_where();
        /*add by hg for date 2014-04-21 可选商品*/
        if (if_agency()) {
            if (!empty($filter['admin_agency_id'])) {
                $where .= " AND (a.admin_agency_id = {$filter['admin_agency_id']} ) ";
            } else {
                $where .= " AND (a.admin_agency_id = 0 ) ";
            }
        }
        //m1 增加采购订单查询条件
        if (strlen(trim($_REQUEST['status'])) > 0) {
            $where .= " AND (a.stock_status = " . $filter['status'] . " ) ";
        }
        if (!empty($filter['keyword'])) {
            $where .= " AND (a.stock_info_sn LIKE '%" . mysql_like_quote($filter['keyword']) . "%' )";
        }
        $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('stock_info') . ' AS a ' . 'WHERE 1 ' . $where;
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);
        $filter = page_and_size($filter);
        /* 获取采购商品列表管理数据 */
        $sql = 'SELECT a.*  ' . 'FROM ' . $GLOBALS['ecs']->table('stock_info') . ' AS a ' . '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'];
    }
    //echo $sql.'<br/>';
    $arr = array();
    $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']);
    while ($rows = $GLOBALS['db']->fetchRow($res)) {
        $arr[] = $rows;
    }
    //显示采购订单的相关信息:包括库存数量,以及采购总价,当页的采购价格等等
    $sql_limit = $sql . " LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",{$filter['page_size']}";
    $overall_order_amount = overall_order_amount($sql);
    //总的计算
    $current_order_amount = current_order_amount($sql_limit);
    // 当前页的计算
    $GLOBALS['smarty']->assign('costing_price_amount', price_format($overall_order_amount['costing_price_amount']));
    $GLOBALS['smarty']->assign('goods_number_amount', $overall_order_amount['goods_number_amount']);
    $GLOBALS['smarty']->assign('current_costing_price_amount', price_format($current_order_amount['current_costing_price_amount']));
    $GLOBALS['smarty']->assign('current_goods_number_amount', $current_order_amount['current_goods_number_amount']);
    return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
}