Exemple #1
0
        } else {
            $row[$key]['can_remove'] = 0;
        }
    }
    $arr = array('orders' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    return $arr;
}
/**
 *  获取用户信息数组
 *
 * @access  public
 * @param
 *
 * @return array        $user       用户信息数组
 */
function get_user_info($id)
{
    $sql = 'SELECT  user_name' . ' FROM ' . $GLOBALS['ecs']->table('users') . " WHERE user_id = '{$id}'";
    $user = $GLOBALS['db']->getRow($sql);
    return $user['user_name'];
}
/**  by ecmoban Leah
 * 返回某个订单可执行的操作列表,包括权限判断
 * @param   array $order 订单信息 order_status, shipping_status, pay_status
 * @param   bool $is_cod 支付方式是否货到付款
 * @return  array   可执行的操作  confirm, pay, unpay, prepare, ship, unship, receive, cancel, invalid, return, drop
 * 格式 array('confirm' => true, 'pay' => true)
 */
function operable_list($order)
{
    /* 取得订单状态、发货状态、付款状态 */
    $rf = $order['return_status'];
    $rc = $order['is_check'];
    $ff = $order['refund_status'];
    /* 取得订单操作权限 */
    $actions = $_SESSION['action_list'];
    if ($actions == 'all') {
        $priv_list = array('rf' => true, 'rc' => true, 'ff' => true, 'edit' => true);
    } else {
        $actions = ',' . $actions . ',';
        $priv_list = array('rf' => strpos($actions, ',aftermarket_rf_edit,') !== false, 'rc' => strpos($actions, ',aftermarket_rc_edit,') !== false, 'ff' => strpos($actions, ',aftermarket_ff_edit,') !== false, 'edit' => strpos($actions, ',aftermarket_edit,') !== false);
    }
    $service_info = get_service_type($order['service_id']);
    /* 根据状态返回可执行操作 */
    $list = array();
    if (RC_APPLY_FALSE == $rc) {
        //未通过审核
        if ($priv_list['rc']) {
            /* 状态:申请=> 未通过审核 */
            $list['check'] = true;
            // 确认
            if (RF_CANCELED != $rf) {
                $list['canceled'] = true;
            }
        }
    } elseif (RC_APPLY_SUCCESS == $rc) {
        //通过审核
        if ($priv_list['rf']) {
            if ($service_info['service_type'] == ST_RETURN_GOODS) {
                /* 状态 退货退款 */
                if (RF_APPLICATION == $rf) {
                    /* 状态:申请=> 通过审核 */
                    $list['receive_goods'] = true;
                    $list['complete'] = true;
                    $list['canceled'] = true;
                } elseif (RF_SEND_OUT == $rf) {
                    /* 状态 买家商品寄出 */
                    $list['receive_goods'] = true;
                    $list['complete'] = true;
                    $list['canceled'] = true;
                } elseif (RF_RECEIVE == $rf) {
                    /* 状态:收到退回商品 */
                    $list['complete'] = true;
                    $list['canceled'] = true;
                } elseif (RF_COMPLETE == $rf) {
                    $list['canceled'] = true;
                } else {
                    $list['complete'] = true;
                }
                /* 退款状态 */
                if (FF_NOREFUND == $ff) {
                    //未退款
                    $list['refund'] = true;
                } elseif (FF_REFUND == $ff) {
                    //已退款
                }
            } elseif ($service_info['service_type'] == ST_EXCHANGE) {
                if (RF_APPLICATION == $rf) {
                    /* 状态:申请=> 通过审核 */
                    $list['receive_goods'] = true;
                    $list['complete'] = true;
                    $list['canceled'] = true;
                } elseif (RF_SEND_OUT == $rf) {
Exemple #2
0
function query_alerts($status_file_content, $alert_type, $host)
{
    $servicestatus_attributes = array("service_description", "host_name", "current_attempt", "current_state", "plugin_output", "last_hard_state_change", "last_hard_state", "last_time_ok", "last_time_warning", "last_time_unknown", "last_time_critical", "is_flapping", "last_check", "long_plugin_output");
    $num_matches = preg_match_all("/servicestatus \\{([\\S\\s]*?)\\}/", $status_file_content, $matches, PREG_PATTERN_ORDER);
    #echo $matches[0][0] . ", " . $matches[0][1] . "\n";
    #echo $matches[1][0] . ", " . $matches[1][1] . "\n";
    $services_objects = array();
    $i = 0;
    foreach ($matches[1] as $object) {
        $servicestatus = getParameterMap($object, $servicestatus_attributes);
        switch ($alert_type) {
            case "all":
                if (empty($host) || $servicestatus['host_name'] == $host) {
                    $servicestatus['service_type'] = get_service_type($servicestatus['service_description']);
                    $srv_desc = explode("::", $servicestatus['service_description'], 2);
                    $servicestatus['service_description'] = $srv_desc[1];
                }
                break;
            case "nok":
                if (getParameterMapValue($map, "last_hard_state") != ok && (empty($host) || getParameterMapValue($map, "host_name") == $host)) {
                    foreach ($servicestatus_attributes as $attrib) {
                        $servicestatus[$attrib] = htmlentities(getParameterMapValue($map, $attrib), ENT_COMPAT);
                    }
                    $servicestatus['service_type'] = get_service_type($servicestatus['service_description']);
                    $srv_desc = explode("::", $servicestatus['service_description'], 2);
                    $servicestatus['service_description'] = $srv_desc[1];
                }
                break;
            case "ok":
                if (getParameterMapValue($map, "last_hard_state") == ok && (empty($host) || getParameterMapValue($map, "host_name") == $host)) {
                    foreach ($servicestatus_attributes as $attrib) {
                        $servicestatus[$attrib] = htmlentities(getParameterMapValue($map, $attrib), ENT_COMPAT);
                    }
                    $servicestatus['service_type'] = get_service_type($servicestatus['service_description']);
                    $srv_desc = explode("::", $servicestatus['service_description'], 2);
                    $servicestatus['service_description'] = $srv_desc[1];
                }
                break;
            case "warn":
                if (getParameterMapValue($map, "last_hard_state") == warn && (empty($host) || getParameterMapValue($map, "host_name") == $host)) {
                    foreach ($servicestatus_attributes as $attrib) {
                        $servicestatus[$attrib] = htmlentities(getParameterMapValue($map, $attrib), ENT_COMPAT);
                    }
                    $servicestatus['service_type'] = get_service_type($servicestatus['service_description']);
                    $srv_desc = explode("::", $servicestatus['service_description'], 2);
                    $servicestatus['service_description'] = $srv_desc[1];
                }
                break;
            case "critical":
                if (getParameterMapValue($map, "last_hard_state") == critical && (empty($host) || getParameterMapValue($map, "host_name") == $host)) {
                    foreach ($servicestatus_attributes as $attrib) {
                        $servicestatus[$attrib] = htmlentities(getParameterMapValue($map, $attrib), ENT_COMPAT);
                    }
                    $servicestatus['service_type'] = get_service_type($servicestatus['service_description']);
                    $srv_desc = explode("::", $servicestatus['service_description'], 2);
                    $servicestatus['service_description'] = $srv_desc[1];
                }
                break;
        }
        if (!empty($servicestatus)) {
            $services_objects[$i] = $servicestatus;
            $i++;
        }
    }
    // echo "COUNT : " . count ($services_objects) . "\n";
    return $services_objects;
}