} if ($_GET['admin_data'] == 'history') { $rs = vcn_report_search($filter, null, true, array_merge(array('bind' => 'OR'), $opts)); } if ($_GET['admin_data'] == 'customer') { $rs = vcn_customers_search($filter, null, true, array_merge(array('bind' => 'OR'), $opts)); } } //final if (!isset($rs)) { if ($_GET['admin_data'] == 'history') { $rs = vcn_report($common_filter, $opts); } //filter reports if ($_GET['admin_data'] == 'customer') { $rs = get_customers($common_filter, $opts); } //get filter customers } //segment $totals = mysql_fetch_array($rs); if (mysql_num_rows($rs)) { mysql_data_seek($rs, 0); } //reset mysql $total_pages = isset($totals['total_results']) ? total_pages($totals['total_results'], $num) : 0; //get total pages push_messages('Tìm thấy <b>' . (isset($totals['total_results']) ? $totals['total_results'] : 0) . '</b> kết quả.'); //result $data['rs'] = $rs; extract($data);
function get_online_customers($cus_type, $supp_id) { $customer_list = get_customers($cus_type, $supp_id); }
<li><a class="active" href="data.php">Upload data</a></li> </div> </ul> </div> <div class="wrapper"> <div class="center"> <?php require 'functions/get_uploaded_transaction_function.php'; require_once 'functions/open_file_function.php'; require 'functions/get_accounts_function.php'; require 'functions/get_customers_function.php'; require 'functions/get_transactions_function.php'; /* --------------------------------------------------------------------------- Getting all the customers, accounts and transactions and puts them in arrays ----------------------------------------------------------------------------*/ $customersArray = get_customers(); $accountsArray = get_accounts(); $transactionsArray = get_transactions(); /* --------------------------------------------------------------------------- Counting the arrays ----------------------------------------------------------------------------*/ $customersArrayLength = count($customersArray); $accountsArrayLength = count($accountsArray); $transactionsArrayLength = count($transactionsArray); $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $FileType = pathinfo($target_file, PATHINFO_EXTENSION); $fileName = basename($_FILES["fileToUpload"]["name"]); // Only account.csv files allowed if ($fileName == "transaction_deposit.csv" or $fileName == "transaction_withdrawal.csv") {
<?php require '../model/database.php'; require '../model/customer_db.php'; $action = filter_input(INPUT_POST, 'action'); if ($action === NULL) { $action = filter_input(INPUT_GET, 'action'); if ($action === NULL) { $action = 'list_customer'; } } //main action slection if ($action == 'list_customer') { $customers = get_customers(); include 'customer_list.php'; } else { if ($action == 'customer_search') { $lastName = filter_input(INPUT_POST, 'lastName'); if ($lastName == NULL || $lastName == FALSE) { $error = "Missing or incorrect customer ID."; include '../errors/error.php'; } else { $customers = get_searchedcustomers($lastName); include 'customer_list.php'; } } else { if ($action == 'customer_update') { $customerID = filter_input(INPUT_POST, 'customerID', FILTER_VALIDATE_INT); if ($customerID == NULL || $customerID == FALSE) { $error = "Missing or incorrect customer ID."; include '../errors/error.php';
$post_tags = $_GET['checkbox_name']; post_products($response, $post_tags, $inventories); } else { $error_msg = "Error: No product available"; echo $error_msg; } if (isset($_GET['post_all_products'])) { if (!empty($inventories)) { get_all_products($inventories); } else { $error_msg = "Error: No product available"; echo $error_msg; } } } elseif (isset($_GET['pull_customers'])) { get_customers(); } elseif (isset($_GET['update_customers'])) { update_get_customers(); } elseif (isset($_GET['pull_invoices'])) { if (!empty($inventories)) { $results = get_invoices($inventories); } else { $error_msg = "Error: No product available"; echo $error_msg; } } elseif (isset($_GET['update_inventory'])) { get_inventory(); } ?> <!DOCTYPE html>
$responseArray['response'] = update_user($values); $responseArray['message'] = 'User updated.'; break; case 'add_customer': include_once __DIR__ . '/customers/add_customer.php'; $responseArray['response'] = add_customer($values); $responseArray['message'] = 'Customer successfully added'; break; case 'update_customer': include_once __DIR__ . '/customers/update_customer.php'; $responseArray['response'] = update_customer($values); $responseArray['message'] = 'Customer updated.'; break; case 'get_customers': include_once __DIR__ . '/customers/get_customers.php'; $responseArray['response'] = get_customers($values); $responseArray['message'] = 'Customers successfully read'; break; case 'verify_user': include_once __DIR__ . '/customers/verify_user.php'; $responseArray['response'] = verify_user($values); $responseArray['message'] = 'User verified'; break; case "verify_admin": include_once __DIR__ . '/customers/verify_admin.php'; $responseArray['response'] = verify_admin($values); $responseArray['message'] = 'Admin verified'; break; default: throw new Exception("Unknown function: {$function}"); }
function action_chat() { $user_id = $_SESSION['user_id']; $smarty = get_smarty(); $ecs = get_ecs(); $db = get_database(); /** * 判断当前用户是为聊天系统的注册用户 */ $exist = check_of_username_exist($user_id); // 获取用户头像 if (!empty($user_id)) { $sql = "select password, headimg from " . $ecs->table('users') . " where user_id = '{$user_id}'"; $row = $db->getRow($sql); $headimg = $row['headimg']; $password = $row['password']; $smarty->assign('headimg', $headimg); } if (!$exist) { // 查询ECShop内用户信息 $sql = 'select a.user_id, a.password, a.email, a.user_name from ' . $ecs->table('users') . ' AS a where a.user_id = "' . $user_id . '"'; $user = $GLOBALS['db']->getRow($sql); if (empty($user)) { // 根据user_id未查找到任何用户信息 } // 用户不存在,创建用户信息 $username = $user_id; $password = $user['password']; $name = $user['user_name']; $email = $user['email']; $type = 10; $shop_id = -1; $result = create_of_user($username, $password, $name, $email, $type, $shop_id); if ($result) { // 创建成功 } else { // 创建失败 } } // 获取前端传来的商品编号、订单编号、店铺编号等 // 商品编号则显示商品信息 // 订单编号则显示订单信息 // 店铺编号则显示店铺信息 $goods_id = null; $supp_id = -1; $order_id = null; $customers = null; // 获取客服信息 $tab_items = array(); // 客服类型 $cus_types = CUSTOMER_SERVICE; // 记录需要发给客服的URL if (!empty($_REQUEST['chat_goods_id'])) { /* 咨询商品信息 */ $goods_id = $_REQUEST['chat_goods_id']; $goods = goods_info($goods_id); $smarty->assign('chat_goods', $goods); $smarty->assign('chat_goods_id', $goods_id); // 获取店铺信息 $supp_id = null; $tab_items[] = array("id" => "chat_goods", "name" => "咨询商品"); // 客服+售前 $cus_types = CUSTOMER_SERVICE . ',' . CUSTOMER_PRE; } if (!empty($_REQUEST['chat_supp_id'])) { /* 店铺信息 */ $supp_id = $_REQUEST['chat_supp_id']; $supp_info = get_dianpu_baseinfo($supp_id); $smarty->assign('supp_info', $supp_info); $smarty->assign('chat_supp_id', $supp_id); $tab_items[] = array("id" => "chat_supp", "name" => "店铺信息"); // 客服+售前 $cus_types = CUSTOMER_SERVICE . ',' . CUSTOMER_PRE; } if (!empty($_REQUEST['chat_order_id'])) { /* 咨询订单信息 */ require 'includes/lib_order.php'; $order_id = $_REQUEST['chat_order_id']; // 获取商品和店铺信息 $goods_id = null; $supp_id = null; $order = order_info($order_id); $order['order_status_text'] = $GLOBALS['_LANG']['os'][$order['order_status']] . ',' . $GLOBALS['_LANG']['ps'][$order['pay_status']] . ',' . $GLOBALS['_LANG']['ss'][$order['shipping_status']]; $order['goods_list'] = order_goods($order_id); $smarty->assign('chat_order', $order); $smarty->assign('chat_order_id', $order_id); $smarty->assign('chat_order_sn', $order['order_sn']); $tab_items[] = array("id" => "chat_order", "name" => "咨询订单"); // 客服+售后 $cus_types = CUSTOMER_SERVICE . ',' . CUSTOMER_AFTER; } if (true) { /* 最近订单列表 */ require 'includes/lib_transaction_1.php'; // 获取用户最近的5条订单列表 $order_list = get_user_orders_1($user_id, 5, 0); // 所有客服忙碌状态,提示web端 $smarty->assign('order_list', $order_list); $smarty->assign('order_count', count($order_list)); $tab_items[] = array("id" => "chat_order_list", "name" => "最近订单"); // 客服 $cus_types = CUSTOMER_SERVICE; } // 获取客服信息 $customers = get_customers($cus_types, $supp_id); // 转换为JSON数据 $smarty->assign('tab_items', json_encode($tab_items)); $to = null; // 客服获取策略:0-顺序、1-随机、2-竞争 if (!empty($customers)) { // 暂时采用随机策略 $poliy = 1; if ($poliy == 0) { foreach ($customers as $customer) { $status = $customer['status']; if ($status == '在线' || $status == '空闲') { $to = $customer; break; // if(isset($customer['cus_status']) && count($customers) > 1) // { // if(time() - $customer['chat_time'] > 5*60) // { // set_customer_status($customer['cus_id'], 0); // $customer['cus_status'] = 0; // } // if($customer['cus_status'] == 0) // { // $to = $customer; // break; // } // } // else // { // $to = $customer; // break; // } } } } else { if ($poliy == 1) { /* 随进策略 */ $onlines = array(); foreach ($customers as $customer) { $status = $customer['status']; if ($status == '在线' || $status == '空闲') { $onlines[] = $customer; } } if (count($onlines) > 0) { $min = 1; $max = count($onlines); $i = mt_rand($min, $max); $to = $onlines[$i - 1]; } } else { } } if (empty($to)) { if ($supp_id == -1) { // 所有客服忙碌状态,提示web端 $smarty->assign('system_notice', '当前客服忙碌,请稍后联系!'); } else { // 所有客服忙碌状态,提示web端 $smarty->assign('system_notice', '当前店铺客服忙碌,请稍后联系!'); } } else { $xmpp_domain = get_xmpp_domain(); $_SESSION['OF_FROM'] = $user_id . '@' . $xmpp_domain; $_SESSION['OF_TO'] = $to['of_username'] . '@' . $xmpp_domain; $smarty->assign('from', $_SESSION['OF_FROM']); $smarty->assign('password', $password); // $smarty->assign('password', "123456"); $smarty->assign('to', '==to=='); $smarty->assign('username', $_SESSION['user_name']); $smarty->assign('customername', $to['cus_name']); // 存储在Session中方便其他地方使用 // 所有客服忙碌状态,提示web端 $smarty->assign('system_notice', '客服<span class="kf_name">' . $to['cus_name'] . '</span>已加入会话!'); } } else { // 所有客服忙碌状态,提示web端 $smarty->assign('system_notice', '当前客服忙碌,请稍后联系!'); } // 打开聊天页面 $smarty->display('chat.dwt'); }