function get_user_group($name=""){ if($name=="") $name=$_SESSION['user']; $group=''; $user=db_easy("SELECT `group` FROM `users` WHERE `name`='$name'"); $group=$user['group']; return $group; }
function show_branch() { switch (@$_GET['message']) { case "branchjustadded": $message_html = template_get("message", array('message' => "Город успешно добавлен")); break; default: $message_html = template_get("nomessage"); } $branch_id = $_GET['branch']; $branch = db_easy("SELECT * FROM `phpbb_branches` WHERE `id`={$branch_id}"); $pointsRES = db_query("SELECT * FROM `phpbb_points` WHERE `branch_id`={$branch_id}"); if (db_count($pointsRES) > 0) { while ($point = db_fetch($pointsRES)) { $points_html .= "<div style='padding-bottom:5px;'><a href='/manager.php?action=show_point&point={$point['id']}'>{$point['name']}</a></div>"; } } else { $points_html = "-"; } if (check_rights('add_branch')) { $edit_branch_html = "<a href='/manager.php?action=edit_branch&branch={$branch_id}' style='font-size:8pt;'>Редактировать</a>"; } $html .= template_get("branches/show_branch", array('name' => $branch['name'], 'editbranch' => $edit_branch_html, 'message' => $message_html, 'points' => $points_html)); return $html; }
function page_message() { $message_id = $_GET['message']; $message = db_easy("SELECT * FROM `intr_message` WHERE `id`={$message_id}"); $q_comm = db_query("SELECT * FROM `intr_comments` WHERE `message_id`={$message_id} ORDER BY `date` DESC"); $user = db_easy("SELECT * FROM `users` WHERE `id`=" . $message['user_id']); $edit_del_comment_html = ""; if (check_group("writer") || $user['name'] == get_user()) { $edit_del_message_html .= "<br/><a href='" . uri_make_v1(array("UriScript" => 'intranet.php', 'page' => 'message', 'message' => $message_id, 'edit_message' => 'yes', 'message' => $message['id'])) . "' style='font-size:8pt;'>Редактировать</a>"; $edit_del_message_html .= "<a href='" . uri_make_v1(array("UriScript" => 'intranet.php', 'page' => 'message', 'message' => $message_id, 'delete_message' => 'yes', 'message' => $message['id'])) . "' style='padding-left:10px;font-size:8pt;' onClick=\"if(!confirm('Удалить?')) return false;\">Удалить</a>"; } $comments_html = ""; while ($comment = db_fetch($q_comm)) { $user = db_easy("SELECT * FROM `users` WHERE `id`={$comment['user_id']}"); $comments_html .= "<div style='margin:15px 0 0 0;padding:0 0 0 10px;border-left:2px solid #AAA;'>"; $comments_html .= "<span style='font-size:8pt;font-style:italic;'><b>" . $user['name_rus'] . ",</b> " . date("d.m.Y H:i", strtotime($comment['date'])) . "</span><br/>" . $comment['text'] . "</div>"; if (check_group("writer") || $user['name'] == get_user()) { $comments_html .= "<a href='" . uri_make_v1(array("UriScript" => 'intranet.php', 'page' => 'message', 'message' => $message_id, 'edit_comment' => 'yes', 'comment' => $comment['id'])) . "' style='font-size:8pt;'>Редактировать</a>"; $comments_html .= "<a href='" . uri_make_v1(array("UriScript" => 'intranet.php', 'page' => 'message', 'message' => $message_id, 'delete_comment' => 'yes', 'comment' => $comment['id'])) . "' style='padding-left:10px;font-size:8pt;' onClick=\"if(!confirm('Удалить?')) return false;\">Удалить</a>"; } } $html .= template_get('message/message', array("user" => $user['name_rus'], "date" => date("d.m.Y", strtotime($message['date'])), "title" => $message['title'], "edit_del_message" => $edit_del_message_html, "text" => $message['text'], "uri_back" => uri_make_v1(array("UriScript" => "intranet.php")), "uri_comment" => uri_make_v1(array("UriScript" => "intranet.php", "page" => "message", "message" => $message_id, "add_comment" => "yes")), "comments" => $comments_html)); //Подключаем подвал $html .= template_get('footer'); return $html; }
function page_contact() { $user_name = $_GET['name']; $user = db_easy("SELECT * FROM `users` WHERE `name`='" . $user_name . "'"); $edit_del_comment_html = ""; if (check_group("writer") || $user['name'] == get_user()) { } $html .= template_get('contacts/contact', array("name_rus" => $user['name_rus'], "position" => $user['position'], "mobile_phone" => $user['mobile_phone'])); //Подключаем подвал $html .= template_get('footer'); return $html; }
function delete_point() { if (!check_rights('delete_point')) { //Возвращаем значение функции return "У вас нет соответствующих прав"; } /*Получаем данные от пользователя*/ $point_id = $_GET['point']; //Запрос к базе $point = db_easy("SELECT * FROM `phpbb_points` WHERE `id`={$point_id}"); //Запрос к базе db_query("DELETE FROM `phpbb_points` WHERE `id`={$point_id}"); //Отправляем HTTP заголовок header("location: /manager.php?action=list_points&message=pointdeleted&name={$point['name']}"); //Возвращаем значение функции return $html; }
function getOrAdd_model($name) { $name = trim($name); if ($name != "") { $qstr = "SELECT * FROM `models` WHERE `name`='" . $name . "'"; $q = db_query($qstr); if (db_count($q) > 0) { $model_id = db_easy($qstr)['id']; } else { db_query("INSERT INTO `models` SET `name`='" . $name . "'"); $model_id = db_easy("SELECT * FROM `models` WHERE `name`='" . $name . "'")['id']; } return $model_id; } else { return 0; } }
function edit_branch() { if (!check_rights('edit_branch')) { //Возвращаем значение функции return "У вас нет соответствующих прав"; } $branch_id = $_GET['branch']; if (!isset($_POST['name'])) { switch (@$_GET['message']) { case "branchsaved": $message_html = template_get("message", array('message' => "Изменения сохранены")); break; case "emptybranchname": $message_html = template_get("errormessage", array('message' => "Название подразделения не может быть пустым")); break; case "samebranchexists": $message_html = template_get("errormessage", array('message' => "Подразделение с таким именем уже имеется")); break; default: $message_html = template_get("nomessage"); } $branch = db_easy("SELECT * FROM `phpbb_branches` WHERE `id`={$branch_id}"); $show_branch_html = "<a href='/manager.php?action=show_branch&branch={$branch_id}' style='font-size:8pt;'>Просмотреть</a>"; $html .= template_get("branches/edit_branch", array('action' => "/manager.php?action=edit_branch&branch={$branch_id}", 'name' => $branch['name'], 'showbranch' => $show_branch_html, 'message' => $message_html)); } else { $branch['name'] = trim($_POST['name']); $do = true; //Проверка на пустое название города $branch['name'] = trim($_POST['name']); if (!preg_match("/^.{1,70}\$/", $branch['name'])) { header("location: /manager.php?action=edit_branch&branch={$branch_id}&message=emptybranchname"); $do = false; } //Проверка на наличие города с таким же именем if (db_easy_count("SELECT * FROM `phpbb_branches` WHERE `name`='{$branch['name']}'") > 0) { header("location: /manager.php?action=edit_branch&branch={$branch_id}&message=samebranchexists"); $do = false; } if ($do) { db_query("UPDATE `phpbb_branches`\r\n\t\t\t\t\tSET `name`='{$branch['name']}'\r\n\t\t\t\t\tWHERE `id`={$branch_id}"); header("location: /manager.php?action=edit_branch&branch={$branch_id}&message=branchsaved"); } } return $html; }
function show_point() { switch (@$_GET['message']) { case "pointjustadded": $message_html = template_get("message", array('message' => "Офис/склад успешно добавлен")); break; default: $message_html = template_get("nomessage"); } $point_id = $_GET['point']; $point = db_easy("SELECT * FROM `phpbb_points` WHERE `id`={$point_id}"); $branch = db_easy("SELECT * FROM `phpbb_branches` WHERE `id`={$point['branch_id']}"); if (check_rights('edit_point')) { $edit_point_html = "<a href='/manager.php?action=edit_point&point={$point_id}' style='font-size:8pt;'>Редактировать</a>"; } $contactsRES = db_query("SELECT * FROM `phpbb_users`\r\n\t\t\t\t\t\t\t\t\tWHERE (`user_type`=0 OR `user_type`=3) AND `username`!='root' AND `user_email`!='*****@*****.**'\r\n\t\t\t\t\t\t\t\t\t\t\tAND `point_id`={$point_id}\r\n\t\t\t\t\t\t\t\t\tORDER BY `username` ASC\r\n\t\t\t\t\t\t\t\t\t"); $contacts_html = ""; while ($contact = db_fetch($contactsRES)) { $contacts_html .= "<a href='/manager.php?action=show_contact&contact={$contact['user_id']}'>" . $contact['username'] . "</a><br/>"; } $html .= template_get("points/show_point", array('name' => $point['name'], 'address' => $point['address'], 'phone' => $point['phone'], 'editpoint' => $edit_point_html, 'message' => $message_html, 'branch' => $branch['name'], 'contacts' => $contacts_html)); return $html; }
function edit_contact() { //Глобальная переменная global $Dbh; /*Проверка прав на выполнение действия*/ if (!check_rights('edit_contact')) { //Возвращаем значение функции return "У вас нет соответствующих прав"; } /*Получаем id, предварительно проверив*/ $user_id = (int) $_GET['contact']; $contactRES = db_query("SELECT * FROM `phpbb_users` WHERE `user_id`={$user_id} AND `user_type` IN (0,3,9)"); if (db_count($contactRES) > 0) { $contact = db_fetch($contactRES); } else { $errors[] = "Критическая ошибка входных данных (user_id)"; } //IF if (!isset($_POST['name'])) { /*Загружаем фото пользователя*/ if (isset($_FILES['file'])) { $photomessage = upload_user_photo($user_id); } /*Обновляем информацию о контакте после подгрузки аватара*/ $contact = db_easy("SELECT * FROM `phpbb_users` WHERE `user_id`={$user_id} AND `user_type` IN (0,3,9)"); /*Обрабатываем входящее сообщение*/ switch (@$_GET['message']) { case "user_added_successfully": $message_html = template_get("message", array('message' => "Сотрудник успешно добавлен")); break; case "contactsaved": $message_html = template_get("message", array('message' => "Изменения сохранены")); break; default: $message_html = template_get("nomessage"); } /*Возвращает HTML код формы*/ $html .= show_form_edit_contact($contact, $messages, $photomessage); } else { //Проверка 'name' if (preg_match(REGEXP_USERNAME, $_POST['name'])) { if (db_easy_count("SELECT `user_id` FROM `phpbb_users` WHERE `username`='" . $_POST['name'] . "' AND `user_id`!={$user_id}") > 0) { $errors[] = ERROR_USERNAME_EXISTS; } else { $name = $_POST['name']; } } else { $errors[] = ERROR_USERNAME_REQUIREMENT; } //REGEXP_EASY_STRING $strings_sql = ""; $strings_params = array('user_occ', 'user_skype', 'user_email', 'user_extphone', 'user_privatemobilephone', 'user_workmobilephone', 'hrmanager_alias'); foreach ($strings_params as $nameFOR) { $strings_sql .= "`" . $nameFOR . "`= :" . $nameFOR . " , "; } //Числовые поля $point_id = (int) $_POST['point']; $hire_month = (int) $_POST['hire_month']; $hire_year = (int) $_POST['hire_year']; $mychief_id = (int) $_POST['mychief']; $my_timetable_editor_id = (int) $_POST['my_timetable_editor']; //Checkbox-ы $checkboxes_sql = ""; foreach (array('chief', 'notimetable', 'timetable_editor', 'engineer', 'engineer_chief', 'spec_prod_staff') as $nameFOR) { if ($_POST[$nameFOR] == "on") { $checkboxes_sql .= "`{$nameFOR}`=1, "; } else { $checkboxes_sql .= "`{$nameFOR}`=0, "; } } //user_type $_POST['nocontact'] == "on" ? $user_type = 9 : ($user_type = 0); //Проверяем наличие ошибок во входных данных if (count($errors) == 0) { //Формируем SQL запрос $sql = "\tUPDATE\r\n\t\t\t\t\t\t`phpbb_users` \r\n\t\t\t\t\tSET \r\n\t\t\t\t\t\t" . $strings_sql . "\r\n\t\t\t\t\t\t" . $checkboxes_sql . "\r\n\t\t\t\t\t\t`user_type`= {$user_type},\r\n\t\t\t\t\t\t`point_id`={$point_id},\r\n\t\t\t\t\t\t`mychief_id`={$mychief_id},\r\n\t\t\t\t\t\t`my_timetable_editor_id`={$my_timetable_editor_id},\r\n\t\t\t\t\t\t`hire`='{$hire_year}-{$hire_month}-1'\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t`user_id`={$user_id}"; //show($sql); //Готовим выражение $sth = $Dbh->prepare($sql); //Привязываем параметры foreach ($strings_params as $nameFOR) { $sth->bindParam(":" . $nameFOR, $_POST[$nameFOR], PDO::PARAM_STR); } //Выполняем запрос if (!$sth->execute()) { show($sth->errorInfo()); } /*Обновляем пароль*/ if (trim($_POST['password']) != "") { $sth = $Dbh->prepare("UPDATE `phpbb_users` SET `user_password`= ? WHERE `user_id`=" . $user_id); if (!$sth->execute(array(phpbb_hash($_POST['password'])))) { show($sth->errorInfo()); } } /*Обновляем статус*/ $sth = $Dbh->prepare("UPDATE `phpbb_profile_fields_data` SET `pf_status`= ? WHERE `user_id`=" . $user_id); if (!$sth->execute(array($_POST['status']))) { show($sth->errorInfo()); } //Получаем только что записанные данные из БД $contact = db_easy("SELECT * FROM `phpbb_users` WHERE `user_id`={$user_id} AND `user_type` IN (0,3,9)"); //Возвращаем значение функции return show_form_edit_contact($contact, $errors); } else { //Возвращаем значение функции return show_form_edit_contact($contact, $errors); } } //Возвращаем HTML-код return $html; }
function edit_point() { if (!check_rights('edit_point')) { //Возвращаем значение функции return "У вас нет соответствующих прав"; } $point_id = $_GET['point']; if (!isset($_POST['name'])) { switch (@$_GET['message']) { case "pointsaved": $message_html = template_get("message", array('message' => "Изменения сохранены")); break; case "emptypointname": $message_html = template_get("errormessage", array('message' => "Название не может быть пустым")); break; case "samepointexists": $message_html = template_get("errormessage", array('message' => "Офис/склад с таким именем уже имеется")); break; default: $message_html = template_get("nomessage"); } $point = db_easy("SELECT * FROM `phpbb_points` WHERE `id`={$point_id}"); $show_point_html = "<a href='/manager.php?action=show_point&point={$point_id}&' style='font-size:8pt;'>Просмотреть</a>"; /*Строим список SELECT*/ $branches_html = ""; $selected_html = ""; $branchesRES = db_query("SELECT * FROM `phpbb_branches` ORDER BY `name` ASC"); while ($branch = db_fetch($branchesRES)) { if ($point['branch_id'] == $branch['id']) { $selected_html = "selected"; } else { $selected_html = ""; } $branches_html .= "<option value='{$branch['id']}' {$selected_html}>{$branch['name']}</option>"; } $html .= template_get("points/edit_point", array('action' => "/manager.php?action=edit_point&point={$point_id}", 'name' => $point['name'], 'address' => $point['address'], 'phone' => $point['phone'], 'branches' => $branches_html, 'showpoint' => $show_point_html, 'message' => $message_html)); } else { $point['name'] = trim($_POST['name']); $point['address'] = trim($_POST['address']); $point['phone'] = trim($_POST['phone']); $point['branch_id'] = trim($_POST['branch']); $do = true; //Проверка на пустое название города $point['name'] = trim($_POST['name']); if (!preg_match("/^.{1,70}\$/", $point['name'])) { header("location: /manager.php?action=edit_point&point={$point_id}&message=emptypointname"); $do = false; } //Проверка на наличие города с таким же именем $other_pointRES = db_query("SELECT * FROM `phpbb_points` WHERE `name`='{$point['name']}'"); $other_point = db_fetch($other_pointRES); if (db_count($other_pointRES) > 0) { if ($other_point['id'] != $point_id) { header("location: /manager.php?action=edit_point&point={$point_id}&message=samepointexists"); $do = false; } } if ($do) { db_query("UPDATE `phpbb_points`\r\n\t\t\t\t\tSET `name`='{$point['name']}',\r\n\t\t\t\t\t\t`branch_id`={$point['branch_id']},\r\n\t\t\t\t\t\t`address`='{$point['address']}',\r\n\t\t\t\t\t\t`phone`='{$point['phone']}'\r\n\t\t\t\t\tWHERE `id`={$point_id}"); header("location: /manager.php?action=edit_point&point={$point_id}&message=pointsaved"); } } return $html; }
function create_timetable() { //Получаем глобальные переменные global $Month; global $Year; global $Redactor; global $user; /*Переменная phpbb*/ global $MonthsShort; //Определяем переменные $html = ""; //Определяем переменную $users = array(); /*Вычисляем количество дней в месяце*/ $day_number = cal_days_in_month(CAL_GREGORIAN, $Month, $Year); /*Получаем список пользователей, графиком работы которых мы можем управлять*/ //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']; } elseif (is_engineer_chief_employee()) { $same_editor_id = $user->data['mychief_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 rowspan='2' class='gfirst vfirst'>Ф.И.</td><td rowspan='2' colspan='2' class='gnolast vfirst'>Устроен</td><td class='vfirst glast' colspan='{$day_number}'>Дата</td></tr>"; $html .= "<tr class='vfirst'>"; for ($dayFOR = 1; $dayFOR <= $day_number; $dayFOR++) { //IF $dayFOR == $day_number ? $tdclass = 'glast' : ($tdclass = 'gnolast'); //Определяем переменную $html .= "<td class='{$tdclass}'>{$dayFOR}</td>"; } $html .= "</tr>"; /*НАЧАЛО: Создаем массив ускоряющий работу (чтобы не делать запрос sql на каждое число*/ //Запрос к базе $daysRES = db_query("SELECT * FROM `phpbb_timetable` WHERE `year`={$Year} AND `month`={$Month}"); //Определяем переменную $timetable = array(); //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 на каждое число*/ /*НАЧАЛО: Строим тело таблицы*/ //Определяем переменную $line = 1; $engineer = 0; $spec_prod_staff = 0; //Определяем, является ли редактор шефом инженеров if ($Redactor != -1 && $Redactor != 0) { $redactor_engineers_chief = db_short_easy("SELECT `engineer_chief` FROM `phpbb_users` WHERE `user_id`=" . $Redactor); } else { $redactor_engineers_chief = 0; } //IF if (db_count($usersRES) > 0) { //WHILE while ($userWHILE = db_fetch($usersRES)) { /*Пропускаем тех, у кого notimetable=1*/ if ($userWHILE['notimetable'] == 1) { continue; } //Получаем "шефа" правильным образом if ($userWHILE['mychief_id'] != 0) { $chiefQUERY = db_query("SELECT * FROM `phpbb_users` WHERE `user_id`=" . $userWHILE['mychief_id']); if (db_count($chiefQUERY) > 0) { $chief = db_fetch($chiefQUERY); } else { $chief = false; } } else { $chief = false; } //Флаг инженера $engineer = $userWHILE['engineer']; //Флаг специального сотрудника производства $spec_prod_staff = $userWHILE['spec_prod_staff']; //Проверяем, имеет ли сотрудник при //IF if ($redactor_engineers_chief != 1) { $line == db_count($usersRES) ? $trclass = 'vlast' : ($trclass = 'vnolast'); } else { $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>"; $userWHILE['hire'] != "0000-00-00" ? $hire_monthWHILE = $MonthsShort[(int) date("m", strtotime($userWHILE['hire']))] : ($hire_monthWHILE = ""); $userWHILE['hire'] != "0000-00-00" ? $hire_yearWHILE = date("Y", strtotime($userWHILE['hire'])) : ($hire_yearWHILE = ""); $html .= "<td class='gnolast'>" . $hire_monthWHILE . "</td>"; $html .= "<td class='gnolast'>" . $hire_yearWHILE . "</td>"; //FOR for ($dayFOR = 1; $dayFOR <= $day_number; $dayFOR++) { //IF $dayFOR == $day_number ? $tdclass = 'glast' : ($tdclass = 'gnolast'); //IF isset($timetable[$userWHILE['user_id']][$dayFOR]['status']) ? $status = $timetable[$userWHILE['user_id']][$dayFOR]['status'] : ($status = 0); //IF if ($timetable[$userWHILE['user_id']][$dayFOR]['hours'] >= 1 && $timetable[$userWHILE['user_id']][$dayFOR]['hours'] <= 7) { $addtext = '(' . $timetable[$userWHILE['user_id']][$dayFOR]['hours'] . ')'; } else { $addtext = ''; } //SWITCH switch ($status) { case 0: $status_html = ''; $color = '#fff'; break; case 1: $status_html = ''; $color = '#fff'; break; case 2: $status_html = 'от' . $addtext; $color = '#ffe599'; break; case 3: $status_html = 'Б' . $addtext; $color = '#b6d7a8'; break; case 4: $status_html = 'до' . $addtext; $color = '#E2B1E2'; break; case 5: $status_html = 'к' . $addtext; $color = '#9fc5e8'; break; case 6: $status_html = ""; $color = "#FFF;"; break; case 51: $status_html = '/-' . $addtext; $color = '#fff'; break; case 52: $status_html = '-/' . $addtext; $color = '#fff'; break; case 53: $status_html = '-' . $addtext; $color = '#fff'; break; case 54: $status_html = '1' . $addtext; $color = '#fff'; break; case 55: $status_html = '0.5' . $addtext; $color = '#fff'; break; case 56: $status_html = "<span style='font-size:7pt;'>0.5+<span style='color:red;'>0.5</span></span>" . $addtext; $color = '#fff'; break; case 57: $status_html = "<span style='color:red;'>1</span>" . $addtext; break; case 58: $status_html = "<span style='color:red;'>0.5</span>" . $addtext; break; case 9: $status_html = 'зф' . $addtext; $color = '#CF596E'; break; } $day_of_week = date("N", strtotime("{$Year}-{$Month}-{$dayFOR}")); if (($day_of_week == 6 || $day_of_week == 7) && $status == 0 || $status == 6) { if ($status_html == '') { $backgroundimage = "url(/images/krestik.png)"; } else { $backgroundimage = ""; } } else { $backgroundimage = ""; } $onDoubleClick = "popup_menu(this.id);"; //Определяем переменную $html .= "<td id='{$userWHILE['user_id']}-{$Year}-{$Month}-{$dayFOR}-{$engineer}-{$spec_prod_staff}' class='{$tdclass}' onDblClick=\"{$onDoubleClick}\" unselectable='on' onselectstart='return false;' style='background:{$color};background-repeat:no-repeat;background-image:{$backgroundimage};'>{$status_html}</td>"; } //Определяем переменную $html .= "</tr>"; } //Добавляем комментарии к столбцам для инженеров if ($redactor_engineers_chief == 1 || is_engineer_chief_employee()) { $comments_number = 1; for ($comment_number = 1; $comment_number <= $comments_number; $comment_number++) { //$comment_number==$comments_number ? $tr_class='vlast' : $tr_class='vnolast'; $html .= "<tr>"; $html .= "<td></td><td></td><td class='comment2'></td>"; for ($dayFOR = 1; $dayFOR <= $day_number; $dayFOR++) { $commentFOR = db_easy("SELECT * FROM `phpbb_timetable_comments` WHERE `year`={$Year} AND `month`={$Month} AND `day`={$dayFOR}"); if ($commentFOR['comment1'] != '' || $commentFOR['comment2'] != '' || $commentFOR['comment3'] != '') { $styleFOR = "background:url('/images/cross.png') center center no-repeat"; } else { $styleFOR = ""; } $dayFOR == $day_number ? $td_g_class = 'glast' : ($td_g_class = 'gnolast'); $html .= "<td id='comment-{$comment_number}-{$Year}-{$Month}-{$dayFOR}' class='comment1' style=\"{$styleFOR}\" onDblClick=\"if(popup_id_check!=this.id) {popup_comment(this.id);}\" align='center'></td>"; } $html .= "</tr>"; } } } /*КОНЕЦ: Строим тело таблицы*/ //Возвращаем значение функции return $html; }
function show_contact() { $user = $GLOBALS['user']; $user_id = (int) $_GET['contact']; //НАЧАЛО: Обновление статуса if (isset($_POST['status'])) { $post_status = $_POST['status']; db_query("UPDATE `phpbb_profile_fields_data` SET `pf_status`='{$post_status}' WHERE `user_id`={$user_id}"); $status_update_message = template_get('message', array('message' => "Статус успешно обновлен")); } else { $status_update_message = ""; } //КОНЕЦ: Обновление статуса $posts_number = db_easy_count("SELECT * FROM `phpbb_posts` WHERE `poster_id`={$user_id}"); $topics_number = db_easy_count("SELECT * FROM `phpbb_topics` WHERE `topic_poster`={$user_id}"); $contact = db_easy("SELECT * FROM `phpbb_users` WHERE `user_id`={$user_id}"); $status = db_easy("SELECT * FROM `phpbb_profile_fields_data` WHERE `user_id`={$user_id}"); $point = db_easy("SELECT * FROM `phpbb_points` WHERE `id`={$contact['point_id']}"); $mobilephones_html = ""; if ($contact['user_workmobilephone'] != "") { $mobilephones_html .= "<tr><td>Мобильный телефон (рабочий)</td><td>{$contact['user_workmobilephone']}</td>"; } if ($contact['user_privatemobilephone'] != "") { $mobilephones_html .= "<tr><td>Мобильный телефон (личный)</td><td>{$contact['user_privatemobilephone']}</td>"; } // if (check_rights('show_hidden_contacts')) { $contact['user_type'] == 9 ? $sql_hidden_contacts = "OR `user_type`=9" : ($sql_hidden_contacts = ""); } //Мой руководитель if ($contact['mychief_id'] != 0) { $mychief = db_easy("SELECT * FROM `phpbb_users` WHERE `user_id`={$contact['mychief_id']}"); $mychief_html = "<tr><td>Руководитель:</td><td><a href='/manager.php?action=show_contact&contact={$contact['mychief_id']}'>{$mychief['username']}</a></td></tr>"; } else { $mychief_html = ""; } //Мои подчиненные $employeesRES = db_query("SELECT * FROM `phpbb_users` WHERE `mychief_id`={$user_id} AND `user_type` IN (0,3) ORDER BY `username` ASC"); if (db_count($employeesRES) > 0 && $contact['chief'] == 1) { $employees_html = "<tr><td valign='top'>Подчиненные:</td><td>"; while ($employee = db_fetch($employeesRES)) { $employees_html .= "<a href='/manager.php?action=show_contact&contact=" . $employee['user_id'] . "'>" . $employee['username'] . "</a><br/>"; } $employees_html .= "</td></tr>"; } else { $employees_html = ""; } if ($point['name'] == "" || $point['name'] == "--не определено--") { $point_html = "не определено"; } else { $point_html = "<a href='/manager.php?action=show_point&point={$point['id']}'>{$point['name']}</a>"; } if (check_rights('edit_contact')) { $edit_contact_html = "<a href='/manager.php?action=edit_contact&contact={$user_id}' style='font-size:8pt;'>Редактировать</a>"; } if ($user->data['user_id'] == $user_id && !check_rights('edit_contact')) { $status_html = "<form action='/manager.php?action=show_contact&contact={$user_id}' method='post'>\r\n\t\t\t\t\t\t\t\t<input type='text' name='status' value='{$status['pf_status']}' style='width:350px;' /><br/>\r\n\t\t\t\t\t\t\t\t{$status_update_message}\r\n\t\t\t\t\t\t\t\t<input type='submit' value='Обновить' style='margin:6px 0 0 0; width:80px;' />\r\n\t\t\t\t\t\t</form>"; } else { $status_html = $status['pf_status']; } //НАЧАЛО: Переключатели "Следующий" и "Предыдущий" $previous_html = ""; $next_html = ""; $all_contactsRES = db_query("SELECT * FROM `phpbb_users`\r\n\t\t\t\t\t\t\t\tWHERE (`user_type`=0 OR `user_type`=3 {$sql_hidden_contacts}) AND `username`!='root'\r\n\t\t\t\t\t\t\t\t\tORDER BY `username`\r\n\t\t\t\t\t\t\t\t\t\t"); $count_contacts = db_count($all_contactsRES); $i = 0; $all_contacts = array(); while ($a_contact = db_fetch($all_contactsRES)) { $all_contacts[$i] = $a_contact['user_id']; if ($a_contact['user_id'] == $user_id) { $current = $i; } $i++; } $previous = $current; $next = $current; $previous_id = $user_id; $next_id = $user_id; if ($current > 0) { $previous = $current - 1; $previous_id = $all_contacts[$previous]; } if ($current < $count_contacts - 1) { $next = $current + 1; $next_id = $all_contacts[$next]; } //КОНЕЦ: Переключатели "Следующий" и "Предыдущий" /*НАЧАЛО: Учет рабочего времени*/ if (($user->data['user_id'] == $user_id || $user->data['timetable_editor'] == 1 && $contact['my_timetable_editor_id'] == $user->data['user_id'] || check_rights('hr_manager')) && $contact['notimetable'] != 1) { /*Отпуск*/ $vocations = get_days_str($user_id, date("Y"), 2); /*Больничный*/ $bolnichny = get_days_str($user_id, date("Y"), 3); /*За свой счет*/ $zasvoischet = get_days_str($user_id, date("Y"), 4); /*Командировка*/ $travel = get_days_str($user_id, date("Y"), 5); $uchet_rabochego_vremeni = template_get("contacts/uchet_rabochego_vremeni", array('vocations_num' => $vocations['used'], 'vocations_rest' => get_rest($vocations['used_hours'], 20 * 8), 'vocations_str' => $vocations['when'], 'bolnichny_num' => $bolnichny['used'], 'bolnichny_rest' => get_rest($bolnichny['used_hours'], 5 * 8), 'bolnichny_str' => $bolnichny['when'], 'zasvoischet_num' => $zasvoischet['used'], 'zasvoischet_str' => $zasvoischet['when'], 'travel_num' => $travel['used'], 'travel_str' => $travel['when'])); } else { $uchet_rabochego_vremeni = ''; } /*КОНЕЦ: Учет рабочего времени*/ $html .= template_get("contacts/show_contact", array('name' => $contact['username'], 'occupation' => $contact['user_occ'], 'email' => $contact['user_email'], 'skype' => $contact['user_skype'], 'officephone' => $point['phone'], 'extphone' => $contact['user_extphone'], 'mobilephones' => $mobilephones_html, 'status' => $status_html, 'point' => $point_html, 'editcontact' => $edit_contact_html, 'mychief' => $mychief_html, 'employees' => $employees_html, 'photo' => get_user_avatar($contact['user_avatar'], $contact['user_avatar_type'], $contact['user_avatar_width'], $contact['user_avatar_height']), 'posts_number' => $posts_number, 'previous' => "/manager.php?action=show_contact&contact={$previous_id}", 'next' => "/manager.php?action=show_contact&contact={$next_id}", 'current' => $current + 1 . " из " . $count_contacts, 'uchet_rabochego_vremeni' => $uchet_rabochego_vremeni)); return $html; }