function show_stat_only_user() { //Определяем переменные $user_id = $_GET['user']; $stat_html = ""; //Запрос к базе $username = db_short_easy("SELECT `username` FROM `phpbb_users` WHERE `user_id`={$user_id} LIMIT 1"); //Определяем переменные $stat_html .= "<span style='font-weight:bold;text-decoration:underline;'>Тип</span>: по сотруднику<br/>"; $stat_html .= "<span style='font-weight:bold;text-decoration:underline;'>Имя сотрудника</span>: {$username}<br/><br/>"; //Определяем переменные $date_stats = array(); //Запрос к базе $statsRES = db_query("SELECT * FROM `phpbb_stat` WHERE `user_id`={$user_id} ORDER BY `date` DESC"); //Определяем переменные $number = db_count($statsRES); //Цикл while ($statWHILE = db_fetch($statsRES)) { $date_stats[date("d/m/Y", strtotime($statWHILE['date']))][] = array('uri' => $statWHILE['uri'], 'time' => date("H:i", strtotime($statWHILE['date']))); } //Определяем переменные //$stat_html.="Итого: $number<br/><br/>"; //Цикл foreach ($date_stats as $date => $statFOR) { $stat_html .= "<a href='/manager.php?action=show_stat&date={$date}'>" . $date . "</a>: " . "<a href='/manager.php?action=show_stat&user={$user_id}&date={$date}'>" . count($statFOR) . " страниц</a><br/>"; } //Возвращаем значение функции return $html .= template_get("stat/show_stat", array('username' => $username, 'userStats' => $stat_html)); }
function get_ComputerId() { //Подключаем глобальную переменную global $ComputerId; //Получаем данные от пользователя $ComputerId = (int) @$_GET['computer']; //IF if ($ComputerId == 0) { $ComputerId = db_short_easy("SELECT *\n\t\t\t\t\t\t\t\t\t\tFROM `computers`\n\t\t\t\t\t\t\t\t\t\t\tORDER BY `date` DESC"); } }
function show_form_edit_contact($contact = array(), $messages = array(), $photomessage = '') { //Подключаем глобальные переменные global $MonthsShort; //Определяем значение переменной $message_html = show_messages($messages); //Определяем переменную $show_contact_html = "<a href='/manager.php?action=show_contact&contact={$contact['user_id']}' style='font-size:8pt;'>Просмотреть</a>"; /*Получаем статус*/ $statusRES = db_query("SELECT * FROM `phpbb_profile_fields_data` WHERE `user_id`={$contact['user_id']}"); db_count($statusRES) > 0 ? $status = db_fetch($statusRES)['pf_status'] : ($status = ''); //Переключатель "Есть подчиненные" if ($contact['chief'] == 1) { $chief = "checked"; } else { $chief = ""; } //Переключатель "Я могу редактировать графики работ" if ($contact['timetable_editor'] == 1) { $timetable_editor = "checked"; } else { $timetable_editor = ""; } //Переключатель "Не показывать в контактах" if ($contact['user_type'] == 9) { $nocontact = "checked"; } else { $nocontact = ""; } //Переключатель "Есть подчиненные" if ($contact['notimetable'] == 1) { $notimetable = "checked"; } else { $notimetable = ""; } //Переключатель "Инженер" if ($contact['engineer'] == 1) { $engineer = "checked"; } else { $engineer = ""; } //Переключатель "Руководитель инженеров" if ($contact['engineer_chief'] == 1) { $engineer_chief = "checked"; } else { $engineer_chief = ""; } //Переключатель "Специальный сотрудник производства" if ($contact['spec_prod_staff'] == 1) { $spec_prod_staff = "checked"; } else { $spec_prod_staff = ""; } /*Получаем список складов/офисов*/ $points_html = get_points_options($contact); /*Получаем список руководителей*/ $mychiefs_html = get_chiefs_options($contact); /*Получаем список редакторов для графика работ*/ $timetable_editors_html = get_timetable_editors_options($contact); /*Переключатели "Следующий" и "Предыдущий"*/ $switch = switch_next_previous($contact['user_id']); //НАЧАЛО: Установка алиаса для HR-manager-а if ($contact['timetable_editor'] == 1) { $hrmanager_alias_html = template_get("contacts/hrmanager_alias", array('hrmanager_alias' => $contact['hrmanager_alias'])); } else { $hrmanager_alias_html = ""; } //КОНЕЦ: Установка алиаса для HR-manager-а //Запрос к БД $contact_hire_date = db_short_easy("SELECT `hire` FROM `phpbb_users` WHERE `user_id`=" . $contact['user_id']); //Получаем список месяцев $hire_months_options = get_hire_months_options($contact); //НАЧАЛО: Получаем список годов strtotime($contact_hire_date) ? $contact_hire_year = (int) date("Y", strtotime($contact_hire_date)) : ($contact_hire_year = (int) date("Y")); $hire_years_options = ""; for ($yearFOR = (int) date("Y"); $yearFOR >= 1995; $yearFOR--) { if ($contact_hire_year == $yearFOR) { $selectedFOR = "selected"; } else { $selectedFOR = ""; } $hire_years_options .= "<option value='" . $yearFOR . "' " . $selectedFOR . ">" . $yearFOR . "</option>"; } //КОНЕЦ: Получаем список годов /*Подключаем шаблон*/ return template_get("contacts/edit_contact", array('action' => "/manager.php?action=edit_contact&contact=" . $contact['user_id'], 'name' => $contact['username'], 'occupation' => $contact['user_occ'], 'email' => $contact['user_email'], 'skype' => $contact['user_skype'], 'officephone' => $contact['user_officephone'], 'extphone' => $contact['user_extphone'], 'workmobilephone' => $contact['user_workmobilephone'], 'privatemobilephone' => $contact['user_privatemobilephone'], 'location' => $contact['user_from'], 'status' => $status, 'message' => $message_html, 'points' => $points_html, 'showcontact' => $show_contact_html, 'previous' => "/manager.php?action=edit_contact&contact={$switch['previous_id']}", 'next' => "/manager.php?action=edit_contact&contact={$switch['next_id']}", 'current' => $switch['current'] + 1 . " из " . $switch['contacts_num'], 'chief' => $chief, 'mychiefs' => $mychiefs_html, 'nocontact' => $nocontact, 'notimetable' => $notimetable, 'engineer' => $engineer, 'engineer_chief' => $engineer_chief, 'spec_prod_staff' => $spec_prod_staff, 'timetable_editor' => $timetable_editor, 'timetable_editors' => $timetable_editors_html, 'photo' => get_user_avatar($contact['user_avatar'], $contact['user_avatar_type'], $contact['user_avatar_width'], $contact['user_avatar_height']), 'photomessage' => $photomessage, 'hrmanager_alias' => $hrmanager_alias_html, 'hire_months_options' => $hire_months_options, 'hire_years_options' => $hire_years_options)); }
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; }