示例#1
0
                    } else {
                        array_push($name_list, $key_name);
                    }
                }
            }
        }
    } else {
        // code to-do here
    }
    return $name_list;
}
// ====== Main Logic ============
$inputObjList = $reqObj["inputList"];
$machineInfoList = $reqObj["machine_info"];
$time_start = get_time_str($reqObj["time_start"]);
$time_end = get_time_str($reqObj["time_end"]);
$time_type = $reqObj["time_type"];
$url_list = array();
foreach ($inputObjList as $ilist) {
    list($hostname, $ana_path, $prod, $serv_type, $cubeId) = $ilist;
    save_log($hostname, $ana_path, $prod, $serv_type, $cubeId);
    // copy analyzer.sh to tmp
    if (substr($ana_path, -3) == ".sh") {
        $ana_local_file = scp_file($hostname, $ana_path);
    } else {
        $ana_local_file = scp_file($hostname, $ana_path . "/analyzer.sh");
    }
    // extract analyzer.sh
    list($config, $prod2, $serv_type2, $cubeId2) = parse_analyzer_sh($ana_local_file);
    // check params
    $ret = 0;
示例#2
0
function create_report()
{
    //Получаем глобальные переменные
    global $Month;
    global $Year;
    global $Redactor;
    global $user;
    /*Переменная phpbb*/
    //Определяем переменные
    $html = "";
    //Определяем переменную
    $users = array();
    /*Получаем список пользователей, графиком работы которых мы можем управлять*/
    //IF
    if (check_rights('timetable_show_all')) {
        //IF
        if ($Redactor == 0) {
            $usersRES = db_query("SELECT * FROM `phpbb_users` WHERE `user_type` IN (0,3,9) AND `username`!='root' AND `my_timetable_editor_id`=0 ORDER BY `username` ASC");
            //ELSEIF
        } elseif ($Redactor == -1) {
            $usersRES = db_query("SELECT * FROM `phpbb_users` WHERE `user_type` IN (0,3,9) AND `username`!='root' ORDER BY `username` ASC");
            //ELSE
        } else {
            $usersRES = db_query("SELECT * FROM `phpbb_users` WHERE `user_type` IN (0,3,9) AND `username`!='root' AND `my_timetable_editor_id`={$Redactor} ORDER BY `username` ASC");
        }
        //ELSE
    } else {
        if (db_short_easy("SELECT `timetable_editor` FROM `phpbb_users` WHERE `user_id`={$user->data['user_id']}") == 1) {
            $same_editor_id = $user->data['user_id'];
        } else {
            $same_editorSQL = "SELECT `editor_id` FROM `phpbb_timetable_editors_rights` WHERE `user_id`={$user->data['user_id']}";
            if (db_easy_count($same_editorSQL) > 0) {
                $same_editor_id = db_short_easy($same_editorSQL);
            }
        }
        //Исключение в сортировке для пользователя Нечаев Андрей по его просьбе
        if ($user->data['user_id'] == 46) {
            $special_order = 'timetable_order';
        } else {
            $special_order = 'username';
        }
        //Запрос к базе
        $usersRES = db_query("SELECT * FROM `phpbb_users` WHERE `user_type` IN (0,3,9) AND `my_timetable_editor_id`={$same_editor_id} ORDER BY `{$special_order}` ASC");
    }
    /*Строим шапку таблицы*/
    $html .= "<tr class='vfirst'><td class='gfirst vfirst'>Ф.И.</td>\r\n\t\t\t\t<td class='glast vfirst' style='width:100px;background:#ffe599;'>Отпуска</td>\r\n\t\t\t\t<td class='gnolast vfirst' style='width:100px;background:#b6d7a8;'>Больничные</td>\r\n\t\t\t\t<td class='gnolast vfirst' style='width:100px;background:#E2B1E2;'>За свой счет</td>\r\n\t\t\t\t<td class='gnolast vfirst' style='width:100px;background:#9fc5e8;'>Командировки</td>\r\n\t\t\t\t<td class='gnolast vfirst' style='width:100px;background:#BBBBBB;'>Отработано</td>\r\n\t\t\t\t<td class='glast vfirst' style='width:100px;background:#ECC0C0;'>Выходных</td>\r\n\t\t\t</tr>";
    /*НАЧАЛО: Создаем массив ускоряющий работу (чтобы не делать запрос sql на каждое число*/
    if (@$_GET['report'] == 'year') {
        //Запрос к базе
        $daysRES = db_query("SELECT * FROM `phpbb_timetable` WHERE `year`={$Year}");
        //Определяем переменную
        $timetable = array();
        //WHILE
        while ($day = db_fetch($daysRES)) {
            $timetable[$day['user_id']][$day['month']][$day['day']]['status'] = $day['status'];
            $timetable[$day['user_id']][$day['month']][$day['day']]['hours'] = $day['hours'];
        }
    } else {
        //Запрос к базе
        $daysRES = db_query("SELECT * FROM `phpbb_timetable` WHERE `year`={$Year} AND `month`={$Month}");
        //Определяем переменную
        $timetable = array();
        $day_number = cal_days_in_month(CAL_GREGORIAN, $Month, $Year);
        //WHILE
        while ($day = db_fetch($daysRES)) {
            $timetable[$day['user_id']][$day['day']]['status'] = $day['status'];
            $timetable[$day['user_id']][$day['day']]['hours'] = $day['hours'];
        }
    }
    /*КОНЕЦ: Создаем массив, ускоряющий работу (чтобы не делать запрос sql на каждое число*/
    /*НАЧАЛО: Строим тело таблицы*/
    //IF
    if (db_count($usersRES) > 0) {
        //Определяем переменные
        $total = array();
        //Определяем переменную
        $line = 1;
        //WHILE
        while ($userWHILE = db_fetch($usersRES)) {
            /*Пропускаем тех, у кого notimetable=1*/
            if ($userWHILE['notimetable'] == 1) {
                continue;
            }
            //Определяем переменные
            $total = array();
            $total_str = array();
            $total_holidays = 0;
            $total_in_month = 0;
            for ($status = 1; $status <= 5; $status++) {
                $total[$status] = 0;
            }
            //Define variable
            $day_total = 0;
            if (@$_GET['report'] == 'year') {
                if ($Year == date("Y")) {
                    $monthMAX = date("n");
                } else {
                    $monthMAX = 12;
                }
                for ($monthFOR = 1; $monthFOR <= $monthMAX; $monthFOR++) {
                    //Вычисляем количество дней в месяце
                    if ($Year == date("Y") && $monthFOR == date("n")) {
                        $day_numberFOR = date("j");
                    } else {
                        $day_numberFOR = cal_days_in_month(CAL_GREGORIAN, $monthFOR, $Year);
                    }
                    $day_total += $day_numberFOR;
                    //show($monthFOR);
                    //show($day_total);
                    for ($dayFOR = 1; $dayFOR <= $day_numberFOR; $dayFOR++) {
                        $day_of_weekFOR = date("N", strtotime("{$Year}-{$Month}-{$dayFOR}"));
                        if (isset($timetable[$userWHILE['user_id']][$monthFOR][$dayFOR]['status'])) {
                            $status = $timetable[$userWHILE['user_id']][$monthFOR][$dayFOR]['status'];
                            $total[$status] += $timetable[$userWHILE['user_id']][$monthFOR][$dayFOR]['hours'];
                            if ($status == 6) {
                                $total_holidays++;
                            }
                        } else {
                            if ($day_of_weekFOR == 6 || $day_of_weekFOR == 7) {
                                $total_holidays++;
                            } else {
                                $status = 1;
                                $total[$status] += 8;
                            }
                        }
                    }
                }
                //ELSE
            } else {
                //Вычисляем количество дней в месяце
                if ($Year == date("Y") && $Month == date("n")) {
                    $day_number = date("j");
                } else {
                    $day_number = cal_days_in_month(CAL_GREGORIAN, $Month, $Year);
                }
                $day_total = $day_number;
                //FOR
                for ($dayFOR = 1; $dayFOR <= $day_number; $dayFOR++) {
                    $day_of_weekFOR = date("N", strtotime("{$Year}-{$Month}-{$dayFOR}"));
                    if (isset($timetable[$userWHILE['user_id']][$dayFOR]['status'])) {
                        $status = $timetable[$userWHILE['user_id']][$dayFOR]['status'];
                        $total[$status] += $timetable[$userWHILE['user_id']][$dayFOR]['hours'];
                        if ($status == 6) {
                            $total_holidays++;
                        }
                    } else {
                        if ($day_of_weekFOR == 6 || $day_of_weekFOR == 7) {
                            $total_holidays++;
                        } else {
                            $status = 1;
                            $total[$status] += 8;
                        }
                    }
                }
            }
            //FOR
            for ($status = 1; $status <= 5; $status++) {
                if ($total[$status] > 0) {
                    $total_str[$status] = get_time_str($total[$status]);
                } else {
                    $total_str[$status] = "";
                }
            }
            //IF
            $line == db_count($usersRES) ? $trclass = 'vlast' : ($trclass = 'vnolast');
            //Определяем переменную
            $line++;
            //Определяем переменную
            $html .= "<tr class='{$trclass}'>";
            //Определяем переменную
            $html .= "<td class='gfirst'><a href='/manager.php?action=show_contact&contact={$userWHILE['user_id']}'>{$userWHILE['username']}</a></td>";
            //Определяем переменную
            //$html.="<td class='gnolast'>{$total_str[2]}</td><td class='gnolast'>{$total_str[3]}</td><td class='gnolast'>{$total_str[4]}</td><td class='gnolast'>{$total_str[5]}</td><td class='gnolast'>{$total_str[1]}</td><td class='gnolast'>{$total_holidays}</td><td class='glast'>{$day_total}</td>";
            $html .= "<td class='gnolast'>{$total_str[2]}</td><td class='gnolast'>{$total_str[3]}</td><td class='gnolast'>{$total_str[4]}</td><td class='gnolast'>{$total_str[5]}</td><td class='gnolast'>{$total_str[1]}</td><td class='glast'>{$total_holidays}</td>";
            //Определяем переменную
            $html .= "</tr>";
        }
    } else {
    }
    /*КОНЕЦ: Строим тело таблицы*/
    //Возвращаем значение функции
    return $html;
}