7 Star 19 Fork 7

王东祥/HongYuDSC

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
wholesale_purchase.php 6.60 KB
一键复制 编辑 原始数据 按行查看 历史
鸿宇科技 提交于 2018-03-08 22:57 . Initial commit
<?php
//zend by QQ:1527200768 鸿宇科技 禁止倒卖 一经发现停止任何服务
define('IN_ECS', true);
require dirname(__FILE__) . '/includes/init.php';
require ROOT_PATH . '/includes/lib_area.php';
require ROOT_PATH . '/includes/lib_wholesale.php';
$action = (isset($_REQUEST['act']) ? trim($_REQUEST['act']) : 'list');
$smarty->assign('action', $action);
if ($action == 'list')
{
$page_title = '求购单';
$is_finished = (isset($_REQUEST['is_finished']) ? intval($_REQUEST['is_finished']) : -1);
$filter_array = array();
$filter_array['review_status'] = 1;
$query_array = array();
$query_array['act'] = 'list';
if ($is_finished != -1)
{
$query_array['is_finished'] = $is_finished;
$filter_array['is_finished'] = $is_finished;
}
$size = 6;
$page = (isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1);
$purchase_list = get_purchase_list($filter_array, $size, $page);
$pager = get_pager('wholesale_purchase.php', $query_array, $purchase_list['record_count'], $page, $size);
$smarty->assign('pager', $pager);
$smarty->assign('purchase_list', $purchase_list['purchase_list']);
$smarty->assign('is_finished', $is_finished);
$today_start = local_strtotime(local_date('Y-m-d'), gmtime());
$today_end = $today_start + 86400;
$sql = ' SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('wholesale_purchase') . ' WHERE add_time BETWEEN ' . $today_start . ' AND ' . $today_end . ' ';
$today_count = $GLOBALS['db']->getOne($sql);
$smarty->assign('today_count', $today_count);
$sql = ' SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('wholesale_purchase') . ' WHERE 1 AND status = 1 ';
$deal_count = $GLOBALS['db']->getOne($sql);
$smarty->assign('deal_count', $deal_count);
$smarty->assign('buy', $action);
}
else if ($action == 'info')
{
$page_title = '求购单详情';
$purchase_id = (empty($_REQUEST['purchase_id']) ? 0 : intval($_REQUEST['purchase_id']));
if (empty($purchase_id))
{
ecs_header('Location: ./' . "\n");
exit();
}
$purchase_info = get_purchase_info($purchase_id);
$smarty->assign('purchase_info', $purchase_info);
$smarty->assign('is_merchant', check_user_is_merchant($_SESSION['user_id']));
}
else if ($action == 'release')
{
$page_title = '发布求购单';
if (empty($_SESSION['user_id']) || !(check_user_is_merchant($_SESSION['user_id'])))
{
show_message('您不是商家无法发布求购单', '前去入驻', 'merchants.php', 'info');
}
$smarty->assign('country_list', get_regions());
$smarty->assign('province_list', get_regions(1, 1));
}
else if ($action == 'do_release')
{
$data = array();
$data['user_id'] = $_SESSION['user_id'];
$data['subject'] = (empty($_REQUEST['subject']) ? '' : trim($_REQUEST['subject']));
$data['type'] = (empty($_REQUEST['type']) ? 0 : intval($_REQUEST['type']));
$data['contact_name'] = (empty($_REQUEST['contact_name']) ? '' : trim($_REQUEST['contact_name']));
$data['contact_gender'] = (empty($_REQUEST['contact_gender']) ? '' : trim($_REQUEST['contact_gender']));
$data['contact_phone'] = (empty($_REQUEST['contact_phone']) ? '' : trim($_REQUEST['contact_phone']));
$data['contact_email'] = (empty($_REQUEST['contact_email']) ? '' : trim($_REQUEST['contact_email']));
$data['add_time'] = gmtime();
$data['end_time'] = (empty($_REQUEST['end_time']) ? gmtime() : strtotime($_REQUEST['end_time']));
$data['need_invoice'] = (empty($_REQUEST['need_invoice']) ? 0 : intval($_REQUEST['need_invoice']));
$data['invoice_tax_rate'] = (empty($_REQUEST['invoice_tax_rate']) ? '' : trim($_REQUEST['invoice_tax_rate']));
$data['consignee_address'] = (empty($_REQUEST['consignee_address']) ? '' : trim($_REQUEST['consignee_address']));
$data['description'] = (empty($_REQUEST['description']) ? '' : trim($_REQUEST['description']));
$consignee_region = 0;
if (!(empty($_REQUEST['district'])))
{
$consignee_region = intval($_REQUEST['district']);
}
else if (!(empty($_REQUEST['city'])))
{
$consignee_region = intval($_REQUEST['city']);
}
else if (!(empty($_REQUEST['province'])))
{
$consignee_region = intval($_REQUEST['province']);
}
else if (!(empty($_REQUEST['country'])))
{
$consignee_region = intval($_REQUEST['country']);
}
$data['consignee_region'] = $consignee_region;
if ($db->autoExecute($ecs->table('wholesale_purchase'), $data, 'INSERT'))
{
$purchase_id = $db->insert_id();
for ($i = 0; $i < count($_REQUEST['goods_name']);
$i++)
{
$row = array();
$row['purchase_id'] = $purchase_id;
$row['goods_name'] = (empty($_REQUEST['goods_name'][$i]) ? '' : trim($_REQUEST['goods_name'][$i]));
$row['cat_id'] = (empty($_REQUEST['cat_id'][$i]) ? 0 : intval($_REQUEST['cat_id'][$i]));
$row['goods_number'] = (empty($_REQUEST['goods_number'][$i]) ? 0 : intval($_REQUEST['goods_number'][$i]));
$row['goods_price'] = (empty($_REQUEST['goods_price'][$i]) ? 0 : floatval($_REQUEST['goods_price'][$i]));
$row['remarks'] = (empty($_REQUEST['remarks'][$i]) ? '' : trim($_REQUEST['remarks'][$i]));
if (!(empty($_REQUEST['pictures'][$i])))
{
$files = trim($_REQUEST['pictures'][$i]);
$goods_img = move_temporary_files($files, 'data/purchase');
$row['goods_img'] = serialize($goods_img);
}
$db->autoExecute($ecs->table('wholesale_purchase_goods'), $row, 'INSERT');
}
show_message('求购单发布成功', '返回首页', 'wholesale_purchase.php', 'info');
}
else
{
show_message('求购单发布失败', '返回上页', 'javascript:history.go(-1);', 'info');
}
}
else if ($action == 'upload_pic')
{
include_once ROOT_PATH . '/includes/cls_image.php';
$image = new cls_image($_CFG['bgcolor']);
$result = array('error' => 0, 'message' => '', 'id' => '', 'path' => '');
$type = 'purchase';
if (($_FILES['file']['tmp_name'] != '') && ($_FILES['file']['tmp_name'] != 'none'))
{
$dir = 'temporary_files/' . $type;
$path = $image->upload_image($_FILES['file'], $dir);
$data = array();
$data['type'] = $type;
$data['path'] = $path;
$data['add_time'] = gmtime();
$data['identity'] = 0;
$data['user_id'] = $_SESSION['user_id'];
$db->autoExecute($ecs->table('temporary_files'), $data, 'INSERT');
$result['id'] = $db->insert_id();
$result['path'] = $path;
}
else
{
$result['error'] = '1';
$result['message'] = '上传失败,请检查服务器配置';
}
exit(json_encode($result));
}
if (defined('THEME_EXTENSION'))
{
$business_cate = get_business_category_tree();
$smarty->assign('business_cate', $business_cate);
}
assign_template();
$position = assign_ur_here(0, $page_title);
$smarty->assign('page_title', $position['title']);
$smarty->assign('ur_here', $position['ur_here']);
$smarty->assign('categories', get_categories_tree());
$smarty->assign('helps', get_shop_help());
$smarty->display('wholesale_purchase.dwt');
?>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/doney/HongYuDSC.git
git@gitee.com:doney/HongYuDSC.git
doney
HongYuDSC
HongYuDSC
master

搜索帮助