PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php function department() { require_once(config('system_dir').'system/department_globals.php'); require_once(config('system_dir').'scripts/department_bender.php'); $DEPARTMENT['header'] = draw_header(); $DEPARTMENT['title'] = draw_title('Подразделения', [$GLOBALS['home']]); if ($department_id = (int)$_GET['id']) { $path_list = []; $path_list[] = $GLOBALS['home']; $path_list[] = '<a href="?department" class="dark_a color-white">Подразделения</a>'; $department = get_department_by_id($department_id); if ($report_id = (int)$_GET['report']) { $report = get_report_by_id($report_id); $title = 'Отчет "'.$report['reports_title'].'"'; $path_list[] = '<a href="?department&id='.$department_id.'" class="dark_a color-white">'.htmlspecialchars($department['departments_name']).'</a>'; $content = draw_report($report); } /*----------------------------------------------------------------------------------------------------*/ elseif ((isset($_GET['add_report']) or isset($_GET['edit_report'])) and get_user_id()) { if (isset($_GET['add_report']) and (is_root() or get_person_access_ldap('oo_admin') or $department_id == $_SESSION['department_id'])) { $title = 'Добавление отчета'; $content = draw_make_report(); } /*----------------------------------------------------------------------------------------------------*/ elseif ($report_id = (int)$_GET['edit_report'] and (is_root() or get_person_access_ldap('oo_admin') or $department_id == $_SESSION['department_id'])) { $title = 'Изменение отчета'; if ($report = get_report_by_id($report_id)) $content = draw_make_report($report); } $path_list[] = '<a href="?department&id='.$department_id.'" class="dark_a color-white">'.htmlspecialchars($department['departments_name']).'</a>'; $head = '<script src="'.config('system_src').'system/ckeditor-4.16.2/ckeditor.js"></script>'. '<script type="text/javascript">'. 'function make_report(report_id)'. '{'. 'for (instance in CKEDITOR.instances){CKEDITOR.instances[instance].updateElement();}'. '$("#make_report").ajaxSubmit'. '({'. 'type:"post",'. 'dataType:"json",'. 'data:{q:"make_report"},'. 'beforeSubmit:function(){$(".make_report").replaceWith("<span class=\"make_report\">'.addslashes(get_fa_icon('spinner')).'</span>");},'. 'success:function(data)'. '{'. 'if (data)'. '{'. 'if (data["code_error"]==0)'. '{'. /*'if (data["count_uploaded_files"]) alert(data["count_uploaded_files"]);'.*/ 'if (data["url"]) window.location.href=data["url"];'. '}'. 'else if (data["code_error"]==1) alert("НЕвозможно создать/изменить отчет");'. 'else if (data["errors"]) alert("Вы не ввели: "+data["errors"]);'. '}'. '},'. 'error:function(object)'. '{'. 'alert("ERROR: НЕвозможно создать/изменить отчет");'. 'console.log(object.responseText);'. '},'. 'complete:function()'. '{'. 'if (report_id) var name="Сохранить";'. 'else var name="Создать";'. '$(".make_report").replaceWith("<input type=\"submit\" value=\""+name+"\" class=\"button-dark make_report\">");'. '}'. '});'. '}'. '</script>'; } /*----------------------------------------------------------------------------------------------------*/ elseif ((isset($_GET['add_calendar_plan']) or isset($_GET['edit_calendar_plan'])) and get_user_id() and get_access_by_department_id($department_id)) { if (isset($_GET['add_calendar_plan']) and (is_root() or get_person_access_ldap('oo_admin') or $department_id == $_SESSION['department_id'])) { $title = 'Добавление календарного планирования'; $content = draw_make_calendar_plan(); } /*----------------------------------------------------------------------------------------------------*/ elseif ($calendar_plan_id = (int)$_GET['edit_calendar_plan'] and (is_root() or get_person_access_ldap('oo_admin') or $department_id == $_SESSION['department_id'])) { $title = 'Изменение календарного планирования'; if ($calendar_plan = get_calendar_plans_by_id($calendar_plan_id)) $content = draw_make_calendar_plan($calendar_plan); } $path_list[] = '<a href="?department&id='.$department_id.'" class="dark_a color-white">'.htmlspecialchars($department['departments_name']).'</a>'; $head = '<script type="text/javascript">'. 'function make_calendar_plans(calendar_plan_id)'. '{'. '$("#make_calendar_plans").ajaxSubmit'. '({'. 'type:"post",'. 'dataType:"json",'. 'data:{q:"make_calendar_plans"},'. 'beforeSubmit:function(){$(".make_calendar_plans").replaceWith("<span class=\"make_calendar_plans\">'.addslashes(get_fa_icon('spinner')).'</span>");},'. 'success:function(data)'. '{'. 'if (data)'. '{'. 'if (data["code_error"]==0)'. '{'. 'if (data["url"]) window.location.href=data["url"];'. '}'. 'else if (data["code_error"]==1) alert("НЕвозможно добавить/изменить календарное планирование");'. '}'. '},'. 'error:function(object)'. '{'. 'alert("ERROR: НЕвозможно добавить/изменить календарное планирование");'. 'console.log(object.responseText);'. '},'. 'complete:function()'. '{'. 'if (calendar_plan_id) var name="Сохранить";'. 'else var name="Добавить";'. '$(".make_calendar_plans").replaceWith("<input type=\"submit\" value=\""+name+"\" class=\"button-dark make_calendar_plans\">");'. '}'. '});'. '}'. '</script>'; } /*----------------------------------------------------------------------------------------------------*/ elseif (isset($_GET['calendar_plans']) and get_user_id()) { $title = 'Календарное планирование'; $path_list[] = '<a href="?department&id='.$department_id.'" class="dark_a color-white">'.htmlspecialchars($department['departments_name']).'</a>'; $years = get_calendar_plans_years_by_department_id(); foreach ($years as $year) { if ($year == (int)$_GET['year'] or $year == date('Y') and !isset($_GET['year'])) $year_item = '<span class="font-bold">'.$year.' г.</span>'; else $year_item = '<a href="?department&id='.(int)$_GET['id'].'&calendar_plans&year='.$year.'">'.$year.' г.</a>'; $years_list[] = '<div class="field inline">'.$year_item.'</div>'; } if ($calendar_plans = get_calendar_plans_by_department_id_and_year()) $content = draw_calendar_plans($calendar_plans); else $content = '<div class="align-center-x label">Информация отсутствует</div>'; $content = '<div>'.join('&emsp;', $years_list).'</div>'.$content; } /*----------------------------------------------------------------------------------------------------*/ elseif (isset($_GET['dashboards'])) { $title = 'Диаграммы'; $path_list[] = '<a href="?department&id='.$department_id.'" class="dark_a color-white">'.htmlspecialchars($department['departments_name']).'</a>'; if ((int)$_GET['id'] == 39) $draw_dashboards = draw_dashboard_operators_work(); else $draw_dashboards = '<span class="label">Информация отсутствует</span>'; $head = '<script type="text/javascript">'. 'function operators_work()'. '{'. 'var date_from=$("#date_from_operators_work").val();'. 'var date_to=$("#date_to_operators_work").val();'. 'if (!date_from && !date_to)'. '{'. 'var current_date=new Date();'. 'var month_begin=current_date.getFullYear()+"-"+("0"+(current_date.getMonth()+1)).slice(-2)+"-01";'. 'var today=current_date.getFullYear()+"-"+("0"+(current_date.getMonth()+1)).slice(-2)+"-"+("0"+(current_date.getDate())).slice(-2);'. '$("#date_from_operators_work").val(month_begin);'. '$("#date_to_operators_work").val(today);'. 'var date_from=$("#date_from_operators_work").val();'. 'var date_to=$("#date_to_operators_work").val();'. '}'. 'ajax_'. '({'. 'data:'. '{'. 'q:"operators_work",'. 'date_from:date_from,'. 'date_to:date_to,'. '},'. 'done:function()'. '{'. 'var data=this;'. 'if (data)'. '{'. 'if (data["code_error"]==1) alert("Дата начала не должна превышать дату окончания");'. 'else if (data["code_error"]==2) alert("НЕвозможно получить данные");'. '}'. '}'. '});'. '}'. '</script>'; $content = '<div class="align-center-x">'.$draw_dashboards.'</div>'; } /*----------------------------------------------------------------------------------------------------*/ else { $title = htmlspecialchars($department['departments_name']); if ($posts = get_posts()) foreach ($posts as $post) $posts_list[$post['posts_id']] = $post['posts_name']; if (get_user_id()) { if (is_root() or get_person_access_ldap('oo_admin')) { $make_work = '<div onclick="show_form_make_work()" class="a inline">Изменить</div>'; $draw_form_make_work = draw_form_make_work($department['departments_work']); } if (is_root() or get_person_access_ldap('oo_admin') or $department_id == $_SESSION['department_id']) $make_report = '<a href="?department&id='.$department_id.'&add_report">Добавить</a>'; if (is_root() or $department_id == $_SESSION['department_id']) $make_vacancy = '<div class="inline relative">'. '<div onclick="show_popup(\'make_vacancy_0\')" class="a">Добавить</div>'.draw_form_make_vacancy($posts_list). '</div>'; if ((is_root() or get_person_access_ldap('oo_admin') or $department_id == $_SESSION['department_id']) and get_access_by_department_id($department_id)) $make_calendar_plans = '<a href="?department&id='.$department_id.'&add_calendar_plan">Добавить</a>'; $head = '<script src="'.config('system_src').'system/ckeditor-4.16.2/ckeditor.js"></script>'. '<script type="text/javascript">'. 'function show_form_make_work()'. '{'. '$("#work").addClass("hidden");'. '$("#make_work").removeClass("hidden");'. '}'. /*----------------------------------------------------------------------------------------------------*/ 'function hide_form_make_work()'. '{'. '$("#work").removeClass("hidden");'. '$("#make_work").addClass("hidden");'. '}'. /*----------------------------------------------------------------------------------------------------*/ 'function make_work()'. '{'. 'for (instance in CKEDITOR.instances){CKEDITOR.instances[instance].updateElement();}'. '$("#make_work").ajaxSubmit'. '({'. 'type:"post",'. 'dataType:"json",'. 'data:{q:"make_work"},'. 'beforeSubmit:function(){$(".make_work").replaceWith("<span class=\"make_work\">'.addslashes(get_fa_icon('spinner')).'</span>");},'. 'success:function(data)'. '{'. 'if (data)'. '{'. 'if (data["code_error"]==0)'. '{'. '$("#work").removeClass("hidden");'. '$("#work").html(data["work"]);'. '$("#make_work").addClass("hidden");'. '}'. 'else if (data["code_error"]==1) alert("Деятельность успешно изменена, но НЕвозможно отобразить изменения. В крайнем случае обновите, пожалуйста, страницу (F5 или Ctrl+F5)");'. 'else if (data["code_error"]==2) alert("НЕвозможно изменить деятельность");'. '}'. '},'. 'error:function(object)'. '{'. 'alert("ERROR: НЕвозможно изменить деятельность");'. 'console.log(object.responseText);'. '},'. 'complete:function()'. '{'. '$(".make_work").replaceWith("<input type=\"submit\" value=\"Сохранить\" class=\"button-dark make_work\">");'. '}'. '});'. '}'. /*----------------------------------------------------------------------------------------------------*/ 'function make_vacancy(vacancy_id)'. '{'. '$("#make_vacancy_"+vacancy_id).ajaxSubmit'. '({'. 'type:"post",'. 'dataType:"json",'. 'data:'. '{'. 'q:"make_vacancy",'. 'vacancy_id:vacancy_id,'. '},'. 'beforeSubmit:function(){$(".make_vacancy").replaceWith("<span class=\"make_vacancy\">'.addslashes(get_fa_icon('spinner')).'</span>");},'. 'success:function(data)'. '{'. 'if (data)'. '{'. 'if (data["code_error"]==0)'. '{'. '$(".popup").addClass("hidden");'. 'if (data["vacancy"]) $(data["vacancy"]).insertAfter($("#new_vacancy"));'. 'else if (data["vacancy_"+vacancy_id]) $("#vacancy_"+vacancy_id).html(data["vacancy_"+vacancy_id]);'. '}'. 'else if (data["code_error"]==1) alert("Вакансия успешно добавлена/изменена, но НЕвозможно отобразить изменения. В крайнем случае обновите, пожалуйста, страницу (F5 или Ctrl+F5)");'. 'else if (data["code_error"]==2) alert("НЕвозможно добавить/изменить вакансию");'. 'else if (data["code_error"]==3) alert("Введите должность");'. '}'. '},'. 'error:function(object)'. '{'. 'alert("ERROR: НЕвозможно добавить/изменить вакансию");'. 'console.log(object.responseText);'. '},'. 'complete:function()'. '{'. '$(".make_vacancy").replaceWith("<input type=\"submit\" value=\"Сохранить\" class=\"button-dark make_vacancy\">");'. '}'. '});'. '}'. /*----------------------------------------------------------------------------------------------------*/ 'function change_status_vacancy(vacancy_id,status)'. '{'. 'ajax_'. '({'. 'data:'. '{'. 'q:"change_status_vacancy",'. 'vacancy_id:vacancy_id,'. 'status:status,'. '},'. 'done:function()'. '{'. 'var data=this;'. 'if (data)'. '{'. 'if (data["code_error"]==1) alert("Вакансии успешно восстановлена, но НЕвозможно отобразить изменения. В крайнем случае обновите, пожалуйста, страницу (F5 или Ctrl+F5)");'. 'else if (data["code_error"]==2) alert("НЕвозможно получить вакансию");'. 'else if (data["code_error"]==1) alert("НЕвозможно изменить статус вакансии");'. '}'. '}'. '});'. '}'. '</script>'; } else { $make_work = '<span class="label">Чтобы изменить деятельность, необходимо <a href="?account">авторизоваться</a></span>'; $make_report = '<span class="label">Чтобы добавить отчет, необходимо <a href="?account">авторизоваться</a></span>'; $make_vacancy = '<span class="label">Чтобы добавить вакансию, необходимо <a href="?account">авторизоваться</a></span>'; $make_calendar_plans = '<span class="label">Чтобы изменить календарное планирование, необходимо <a href="?account">авторизоваться</a></span>'; } $head .= '<script type="text/javascript">'. 'function show_data_vacancy(vacancy_id)'. '{'. '$(".popup").addClass("hidden");'. '$("#data_vacancy_"+vacancy_id).removeClass("hidden");'. '}'. '</script>'; if (!$work = $department['departments_work']) $work = '<span class="label">Информация отсутствует</span>'; if ($reports = get_reports_by_department_id()) $reports = draw_reports($reports); else $reports = '<span class="label">Информация отсутствует</span>'; if ($vacancies = get_vacancies_by_department_id()) { $count_vacancies = ' ('.count($vacancies).')'; $vacancies_list = draw_vacancies($posts_list, $vacancies); } else { $count_vacancies = ''; $vacancies_list = '<span class="label">Информация отсутствует</span>'; } if (get_calendar_plans_years_by_department_id()) $calendar_plans = '<a href="?department&id='.$department_id.'&calendar_plans">Посмотреть</a>'; else $calendar_plans = '<span class="label">Информация отсутствует</span>'; if ($employees = get_employees(['department' => $department_id])) { $count_employees = ' ('.count($employees).')'; $draw_employees = draw_employees($employees); } else { $count_employees = ''; $draw_employees = '<div class="label">Информация отсутствует</div>'; } $content = '<h2 class="h inline">Деятельность:</h2>&emsp;'.$make_work.'<div id="work">'.$work.'</div>'.$draw_form_make_work. '<h2 class="inline">Отчет о проделанной работе:</h2>&emsp;'.$make_report.'<div class="reports">'.$reports.'</div>'. '<h2 class="inline">Вакансии'.$count_vacancies.':</h2>&emsp;'.$make_vacancy.'<div class="vacancies"><div id="new_vacancy"></div>'.$vacancies_list.'</div>'. '<h2 class="inline">Календарное планирование:</h2>&emsp;'.$make_calendar_plans.'<div class="calendar_plans">'.$calendar_plans.'</div>'. '<h2 class="inline">Диаграммы:</h2>&emsp;<div class="dashboards"><a href="?department&id='.$department_id.'&dashboards">Посмотреть</a></div>'. '<h2>Сотрудники'.$count_employees.':</h2>'.$draw_employees; } $DEPARTMENT['title'] = draw_title($title, $path_list); } /*----------------------------------------------------------------------------------------------------*/ else $content = draw_departments(); $DEPARTMENT['head'] .= '<link href="versions/'.SITE_VERSION.'/css/department.css" type="text/css" rel="stylesheet">'.$head; $DEPARTMENT['content'] = '<div class="departments">'.$content.'</div>'; return $DEPARTMENT; } ?>
Show:  
Copy Clear