Commit 17d21d15 authored by Frank Bergmann's avatar Frank Bergmann

P/O HR initial import

parents
<?xml version="1.0"?>
<!-- Generated by the OpenACS Package Manager -->
<package key="intranet-hr" url="http://openacs.org/repository/apm/packages/intranet-hr" type="apm_application">
<package-name>Project/Open HR</package-name>
<pretty-plural>Project/Open HR</pretty-plural>
<initial-install-p>f</initial-install-p>
<singleton-p>t</singleton-p>
<auto-mount>intranet-hr</auto-mount>
<version name="0.0.1d" url="http://openacs.org/repository/download/apm/intranet-hr-0.0.1d.apm">
<owner url="mailto:fraber@fraber.de">Frank Bergmann</owner>
<summary>Employees, Salaries, OrgChart</summary>
<vendor url="http://www.project-open.com/">Project/Open</vendor>
<description format="text/plain">Human Resources module consisting mainly of the &quot;employee&quot; business object. Employee information include payroll, corporate hierarchy (who manages whom) and demographics.</description>
<!-- No dependency information -->
<callbacks>
</callbacks>
<parameters>
<!-- No version parameters -->
</parameters>
</version>
</package>
-- /packages/intranet/sql/intranet.sql
--
-- Project/Open Core Module, fraber@fraber.de, 030828
-- A complete revision of June 1999 by dvr@arsdigita.com
--
-- Copyright (C) 1999-2004 ArsDigita, Frank Bergmann and others
--
-- This program is free software. You can redistribute it
-- and/or modify it under the terms of the GNU General
-- Public License as published by the Free Software Foundation;
-- either version 2 of the License, or (at your option)
-- any later version. This program is distributed in the
-- hope that it will be useful, but WITHOUT ANY WARRANTY;
-- without even the implied warranty of MERCHANTABILITY or
-- FITNESS FOR A PARTICULAR PURPOSE.
-- See the GNU General Public License for more details.
----------------------------------------------------
-- Employees
--
-- Employees is a subclass of Users
-- So according to the AC conventions, there is an
-- additional table *_info which contains the additional
-- fields.
--
create table im_employees (
user_id integer
primary key
references users,
job_title varchar(200),
job_description varchar(4000),
-- is this person an official team leader?
team_leader_p char(1)
constraint im_employee_team_lead_con
check (team_leader_p in ('t','f')),
-- can this person lead projects?
project_lead_p char(1)
constraint im_employee_project_lead_con check
(project_lead_p in ('t','f')),
-- percent of a full time person this person works
percentage integer,
supervisor_id integer
references users,
-- add a constraint to prevent a user from being her own supervisor
group_manages varchar(100),
current_information varchar(4000),
--- send email if their information is too old
last_modified date default sysdate not null,
ss_number varchar(20),
salary number(9,2),
salary_period varchar(12) default 'month'
constraint im_employee_salary_period_con
check (salary_period in ('hour','day','week','month','year')),
--- W2 information
dependant_p char(1)
constraint im_employee_dependant_p_con
check (dependant_p in ('t','f')),
only_job_p char(1)
constraint im_employee_only_job_p_con
check (only_job_p in ('t','f')),
married_p char(1)
constraint im_employee_married_p_con
check (married_p in ('t','f')),
dependants integer default 0,
head_of_household_p char(1)
constraint im_employee_head_of_house_con
check (head_of_household_p in ('t','f')),
birthdate date,
skills varchar(2000),
first_experience date,
years_experience number(5,2),
educational_history varchar(4000),
last_degree_completed varchar(100),
resume clob,
resume_html_p char(1)
constraint im_employee_resume_html_p_con
check (resume_html_p in ('t','f')),
start_date date,
-- when did the employee leave the company
termination_date date,
received_offer_letter_p char(1)
constraint im_employee_recv_offer_con
check(received_offer_letter_p in ('t','f')),
returned_offer_letter_p char(1)
constraint im_employee_return_offer_con
check(returned_offer_letter_p in ('t','f')),
-- did s/he sign the confidentiality agreement?
signed_confidentiality_p char(1)
constraint im_employee_conf_p_con
check(signed_confidentiality_p in ('t','f')),
most_recent_review date,
most_recent_review_in_folder_p char(1)
constraint im_employee_recent_review_con
check(most_recent_review_in_folder_p in ('t','f')),
featured_employee_approved_p char(1)
constraint featured_employee_p_con
check(featured_employee_approved_p in ('t','f')),
featured_employee_approved_by integer
references users,
featured_employee_blurb clob,
featured_employee_blurb_html_p char(1) default 'f'
constraint featured_emp_blurb_html_p_con
check (featured_employee_blurb_html_p in ('t','f')),
referred_by references users,
referred_by_recording_user integer
references users,
experience_id integer
references categories,
source_id integer
references categories,
original_job_id integer
references categories,
current_job_id integer
references categories,
qualification_id integer
references categories,
department_id integer
references categories,
termination_reason varchar(4000),
voluntary_termination_p char(1) default 'f'
constraint iei_voluntary_termination_p_ck
check (voluntary_termination_p in ('t','f')),
recruiting_blurb clob,
recruiting_blurb_html_p char(1) default 'f'
constraint recruiting_blurb_html_p_con
check (recruiting_blurb_html_p in ('t','f'))
);
create index im_employees_referred_idx on im_employees(referred_by);
-- stuff we need for the Org Chart
-- Oracle will pop a cap in our bitch ass if do CONNECT BY queries
-- on im_us<ers without these indices
create index im_employees_idx1 on im_employees(user_id, supervisor_id);
create index im_employees_idx2 on im_employees(supervisor_id, user_id);
-- you can't do a JOIN with a CONNECT BY so we need a PL/SQL proc to
-- pull out user's name from user_id
create or replace function im_supervises_p(
v_supervisor_id IN integer,
v_user_id IN integer)
return varchar
is
v_exists_p char;
BEGIN
select decode(count(1),0,'f','t') into v_exists_p
from im_employees
where user_id = v_user_id
and level > 1
start with user_id = v_supervisor_id
connect by supervisor_id = PRIOR user_id;
return v_exists_p;
END im_supervises_p;
/
show errors
-- at given stages in the employee cycle, certain checkpoints
-- must be competed. For example, the employee should receive
-- an offer letter and it should be put in the employee folder
create sequence im_employee_checkpoint_id_seq;
create table im_employee_checkpoints (
checkpoint_id integer
primary key,
stage varchar(100) not null,
checkpoint varchar(500) not null
);
create table im_emp_checkpoint_checkoffs (
checkpoint_id integer
references im_employee_checkpoints,
checkee integer not null
references users,
checker integer not null
references users,
check_date date,
check_note varchar(1000),
primary key (checkee, checkpoint_id)
);
-- We need to keep track of in influx of employees.
-- For example, what employees have received offer letters?
create table im_employee_pipeline (
user_id integer
primary key
references users,
state_id integer not null
references categories,
office_id integer
references groups,
team_id integer
references groups,
prior_experience_id integer
references categories,
experience_id integer
references categories,
source_id integer
references categories,
job_id integer
references categories,
projected_start_date date,
-- the person at the company in charge of reeling them in.
recruiter_user_id integer
references users,
referred_by integer
references users,
note varchar(4000),
probability_to_start integer
);
-- keep track of the last_modified on im_employees
create or replace trigger im_employees_last_modif_tr
before update on im_employees
for each row
DECLARE
BEGIN
:new.last_modified := sysdate;
END;
/
show errors;
# /www/intranet/employees/org-chart.tcl
ad_page_contract {
by philg@mit.edu on July 6, 1999
uses CONNECT BY on the supervisor column in im_employees to query
out the org chart for a company
than one person without a supervisor. We figure the Big Kahuna
is the person with no supervisor AND no subordinates
Changed display style from indented list to nested table.
May 11, 2000
@param starting_user_id if exists: starting user of org chart
@author Mark Dettinger <dettinger@arsdigita.com>
@creation-date
@cvs-id org-chart.tcl,v 3.15.2.8 2000/09/22 01:38:30 kevin Exp
} {
{ starting_user_id:integer "" }
}
set user_id [ad_maybe_redirect_for_registration]
set context_bar [ad_context_bar [list /intranet/users/ "Users"] "Org Chart"]
set page_title "Users"
set page_focus "im_header_form.keywords"
set user_admin_p [im_is_user_site_wide_or_intranet_admin $user_id]
set return_url [im_url_with_query]
if {![im_permission $user_id view_users]} {
set err_msg "You don't have permissions to view users"
ad_returnredirect "/error?error=$err_msg"
return
}
# Need to find the true big kahuna
# Note that the following query requires! that employees also exist in the
# im_employees - basically, until you say This user is supervised by nobody
# or by her, that user won't show up in the query
set big_kahuna_list [db_list kahuna_find \
"select info.user_id
from im_employees_active info
where supervisor_id is null
and exists (select 1
from im_employees_active info2
where info2.supervisor_id = info.user_id)"]
if { [llength $big_kahuna_list] == 0 || [llength $big_kahuna_list] > 1 } {
ad_return_error "No Big Kahuna" "<blockquote>For the org chart page to work, you need to have set up the \"who supervises whom\" relationships so that there is only one person (the CEO) who has no supervisor and no subordinates.</blockquote>"
return
}
if { ![exists_and_not_null starting_user_id] } {
set starting_user_id [lindex $big_kahuna_list 0]
}
set page_body "<blockquote>\n"
# this is kind of inefficient in that we do a subquery to make
# sure the employee hasn't left the company, but you can't do a
# JOIN with a CONNECT BY
#
# there's a weird case when a manager has left the company.
# we can't just leave him blank because
# it screws the chart up, therefore put in a placeholder "vacant"
#
set last_level 0 ;#level of last employee
set vacant_position ""
set nodes_sql "
select
user_id,
im_name_from_user_id(user_id) as employee_name,
ad_group_member_p(user_id, [im_employee_group_id]) as currently_employed_p
from
im_employees
start with
user_id = :starting_user_id
connect by
supervisor_id = PRIOR user_id"
set bind_vars [ns_set create]
ns_set put $bind_vars starting_user_id $starting_user_id
# generate the org chart
append page_body [tree_to_horizontal_table [im_prune_org_chart [db_tree nodes_display $nodes_sql -bind $bind_vars]] im_print_employee]
# Now pull out the people who don't get included because they
# aren't starting_user_id and they don't have supervisors
set employee_listing_sql "
select u.user_id, u.first_names || ' ' || u.last_name as employee_name
from im_employees_active u
where u.user_id <> :starting_user_id
and u.supervisor_id is null
order by lower(employee_name)"
set homeless_employees ""
db_foreach employee_listing $employee_listing_sql {
append homeless_employees " <li> <a href=../users/view?[export_url_vars user_id]>$employee_name</a>"
if { $user_admin_p } {
append homeless_employees " (<a href=admin/update-supervisor?[export_url_vars user_id return_url]>add supervisor</a>)"
}
append homeless_employees "\n"
}
if { ![empty_string_p $homeless_employees] } {
append page_body "<p><h3>Employees without supervisors</h3>
<ul>
$homeless_employees
</ul>
"
}
append page_body "</blockquote>\n"
set page_body "
<BR>
[im_user_navbar "none" "/intranet/users/index" "" "" [list starting_user_id]]
$page_body
"
db_release_unused_handles
doc_return 200 text/html [im_return_template]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment