Пример #1
0
function get_nature_stats()
{
    $admin_id = $_SESSION['admin_id'];
    $group_id = $_SESSION['group_id'];
    $role_id = $_SESSION['role_id'];
    $ranklist_date = get_ranklist_date();
    extract($ranklist_date);
    $statistics = sales_stats($date_start, $date_end);
    $statistics['service_ranklist'] = stats_service($date_start, $date_end);
    //权限判断
    $pwd_info = authority_judge();
    //当前员工的各指标排行
    if (!admin_priv('service_all_mgr', '', false)) {
        if ($pwd_info['ordinary_employee'] == true) {
            $my_ranking = array('own_ranking' => 0, 'final_amount' => 0, 'order_num' => 0, 'own_group_ranking' => 0, 'num_service' => 0);
        }
        $person_ranklist_total = count($statistics['person_ranklist']);
        for ($i = 0; $i < $person_ranklist_total; $i++) {
            if ($admin_id == $statistics['person_ranklist'][$i]['admin_id']) {
                $my_ranking['own_ranking'] = $i + 1;
                $my_ranking['final_amount'] = $statistics['person_ranklist'][$i]['final_amount'];
                $my_ranking['order_num'] = $statistics['person_ranklist'][$i]['num'];
                break;
            }
        }
        $group_ranklist_total = count($statistics['group_ranklist']);
        for ($i = 0; $i < $group_ranklist_total; $i++) {
            if ($group_id == $statistics['group_ranklist'][$i]['group_id']) {
                $my_ranking['own_group_ranking'] = $i + 1;
                break;
            }
        }
        $role_ranklist_total = count($statistics['role_ranklist']);
        for ($i = 0; $i < $role_ranklist_total; $i++) {
            if ($role_id == $statistics['role_ranklist'][$i]['platform']) {
                $my_ranking['own_role_ranking'] = $i + 1;
                break;
            }
        }
        $service_ranklist_total = count($statistics['service_ranklist']);
        for ($i = 0; $i < $service_ranklist_total; $i++) {
            if ($admin_id == $statistics['service_ranklist'][$i]['admin_id']) {
                $my_ranking['num_service'] = $statistics['service_ranklist'][$i]['num_service'];
                break;
            }
        }
        foreach ($my_ranking as $key => &$val) {
            if ($val == '') {
                $my_ranking[$key] = 0;
            }
        }
        $cn_key = array('个人销量排行', '订单总金额', '订单数', '团队排行', '服务记录');
        $my_ranking = array_combine($cn_key, $my_ranking);
        $stats_info['my_ranking'] = $my_ranking;
    }
    $stats_info['statistics'] = $statistics;
    $stats_info['pwd_info'] = $pwd_info;
    $stats_info['date_status'] = $_REQUEST['date_status'];
    return $stats_info;
}
Пример #2
0
         $result = get_ranklist($sql_sub, 'finish_order_ranklist', $date_start, $date_end);
         if ($_REQUEST['company_mgr']) {
             $key = 'role_name';
         } else {
             $key = 'admin_name';
         }
         $value = 'num';
         break;
     case 'hide_person_ranklist':
         $sql_sub = tidysql('sql_person_ranklist');
         $result = get_ranklist($sql_sub, 'personal_ranklist', $date_start, $date_end);
         $key = 'admin_name';
         $value = 'final_amount';
         break;
     case 'hide_service_ranklist':
         $result = stats_service($date_start, $date_end);
         $key = 'user_name';
         $value = 'num_service';
         break;
 }
 $table = array();
 $rank_count = ceil(count($result) / 10);
 $off_width = $rank_count >= 3 ? 282 * 3 : 282 * $rank_count;
 for ($j = 0; $j < $rank_count; $j++) {
     $table[$j] = '<table style="float:left;margin-right:12px;" width="264px">';
     for ($i = $j * 10; $i < $j * 10 + 10; $i++) {
         $table[$j] .= '<tr><td><em>' . ($i + 1) . '</em></td><td>' . $result[$i][$key] . '</td><td style="text-align:left;color:#9E2F33;border-right:1px solid #A8A5A5">' . $result[$i][$value] . '</td></tr>';
     }
     $table[$j] .= '</table>';
 }
 foreach ($table as $val) {