Commit 7c2c8f8b authored by Malte Sussdorff's avatar Malte Sussdorff

Initial Import

parents
Pipeline #560 failed with stages
<?xml version="1.0"?>
<!-- Generated by the OpenACS Package Manager -->
<package key="organizations" url="http://openacs.org/repository/apm/packages/organizations" type="apm_application">
<package-name>Organization</package-name>
<pretty-plural>Organizations</pretty-plural>
<initial-install-p>f</initial-install-p>
<singleton-p>f</singleton-p>
<version name="0.6d3" url="http://openacs.org/repository/download/apm/organizations-0.6d3.apm">
<owner url="mailto:jon@mayuli.com">Jon Griffin</owner>
<owner url="mailto:jader@bread.com">Jade Rubick</owner>
<summary>Implementation of HR-XML organizations datamodel.</summary>
<release-date>2004-06-25</release-date>
<vendor url="http://www.mayuli.com">Mayuli Enterprises, LLC</vendor>
<description format="text/plain">Provides the datamodel for an
implementation of the HR-XML organizations spec, but no API for
manipulating the data. Also note that the Oracle code is out of sync
with the Postgres code. The source code has comments in it indicating
what needs to be updated to make things work correctly [Jade Rubick].
</description>
<provides url="organizations" version="0.6d3"/>
<requires url="acs-kernel" version="5.0d13"/>
<callbacks>
</callbacks>
<parameters>
<!-- No version parameters -->
</parameters>
</version>
</package>
-- @cvs-id $Id$
create table organization_types (
organization_type_id integer
constraint company_types_pk
primary key,
type varchar2 (40)
constraint company_type_name_uq
unique
constraint company_type_name_nn
not null
);
comment on table organization_types is '
This is a lookup table displaying organization types.
';
comment on column organization_types.organization_type_id is '
Primary key.
';
comment on column organization_types.type is '
Pretty name.
';
-- add some data
insert into organization_types values (acs_object_id_seq.nextval,'Vendor');
insert into organization_types values (acs_object_id_seq.nextval,'Customer');
insert into organization_types values (acs_object_id_seq.nextval,'Prospect');
insert into organization_types values (acs_object_id_seq.nextval,'Misc.');
-- organization
-- this will be a party
create table organizations (
organization_id integer
constraint organization_id_pk
primary key
constraint organization_id_fk
references parties(party_id),
name varchar2(200)
constraint organization_name_nn
not null
constraint organization_name_uq
unique,
-- usually the same as name
legal_name varchar2(200),
-- this can be ein/ssn/vat
reg_number varchar2(100),
notes varchar2(4000)
);
-- create an index? Postgres version does
-- create index organization_name_ix on organizations(name);
-- this is untested, copied from Postgres. Needs to be tested to work for
-- Oracle.
create table organization_type_map (
organization_id integer
constraint org_type_map_org_id_fk
references organizations(organization_id),
organization_type_id integer
constraint org_type_map_type_fk
references organization_types(organization_type_id)
);
@ 'organizations-plsql-create.sql'
-- Yes, this is also missing a drop script!
-- packages/organization/sql/oracle/organization-plsql.sql
--
-- @author Jon Griffin
-- @creation-date 13 March 2003
-- @cvs-id $Id$
begin
acs_object_type.create_type (
object_type => 'organization',
pretty_name => 'Organization',
pretty_plural => 'Organizations',
supertype => 'party',
table_name => 'organizations',
id_column => 'organization_id'
);
end;
/
show errors
create or replace package organization
as
function new (
p_organization_id in organizations.organization_id%TYPE default null,
p_legal_name in organizations.legal_name%TYPE,
p_name in organizations.name%TYPE,
p_notes in organizations.notes%TYPE default null,
p_reg_number in organizations.reg_number%TYPE default null,
p_email in parties.email%TYPE default null,
p_url in parties.url%TYPE default null,
p_object_type in acs_objects.object_type%TYPE default 'organization',
p_creation_date in acs_objects.creation_date%TYPE default sysdate,
p_creation_user in acs_objects.creation_user%TYPE default null,
p_creation_ip in acs_objects.creation_ip%TYPE default null,
p_context_id in acs_objects.context_id%TYPE default null
) return organizations.organization_id%TYPE;
procedure del (
p_organization_id in organizations.organization_id%TYPE
);
end organization;
/
show errors
-- behavior is different between oracle and postgres. Postgres
-- version adds in the first organization_type to the organization_type_map
-- table, to specify which type this organization is.
create or replace package body organization
as
function new (
p_organization_id in organizations.organization_id%TYPE default null,
p_legal_name in organizations.legal_name%TYPE,
p_name in organizations.name%TYPE,
p_notes in organizations.notes%TYPE default null,
p_reg_number in organizations.reg_number%TYPE default null,
p_email in parties.email%TYPE default null,
p_url in parties.url%TYPE default null,
p_object_type in acs_objects.object_type%TYPE default 'organization',
p_creation_date in acs_objects.creation_date%TYPE default sysdate,
p_creation_user in acs_objects.creation_user%TYPE default null,
p_creation_ip in acs_objects.creation_ip%TYPE default null,
p_context_id in acs_objects.context_id%TYPE default null
) return organizations.organization_id%TYPE
is
v_organization_id organizations.organization_id%TYPE;
begin
v_organization_id := party.new (
party_id => null,
object_type => p_object_type,
creation_user => p_creation_user,
creation_ip => p_creation_ip,
email => p_email,
url => p_url,
context_id => p_context_id
);
insert into organizations (
legal_name,
name,
notes,
organization_id,
reg_number
)
values (
p_legal_name,
p_name,
p_notes,
v_organization_id,
p_reg_number
);
acs_permission.grant_permission (
object_id => v_organization_id,
grantee_id => p_creation_user,
privilege => 'admin'
);
return v_organization_id;
end new;
--
--
procedure del (
p_organization_id in organizations.organization_id%TYPE
)
is
begin
-- these delete statements should not be necessary
delete from acs_permissions
where object_id = organization.del.p_organization_id;
-- need to remove items from organization_type_map, like postgres
delete from organizations
where organization_id = organization.del.p_organization_id;
party.del(organization.del.p_organization_id);
end del;
end organization;
/
show errors
-- name function is missing in Oracle version!! Need to port from Postgres
-- packages/organization/sql/oracle/organization-plsql.sql
--
-- @author Jon Griffin
-- @creation-date 13 March 2003
-- @cvs-id $Id$
create or replace package organization
as
function new (
p_organization_id in organizations.organization_id%TYPE default null,
p_legal_name in organizations.legal_name%TYPE,
p_name in organizations.name%TYPE,
p_notes in organizations.notes%TYPE default null,
p_reg_number in organizations.reg_number%TYPE default null,
p_email in parties.email%TYPE default null,
p_url in parties.url%TYPE default null,
p_object_type in acs_objects.object_type%TYPE default 'organization',
p_creation_date in acs_objects.creation_date%TYPE default sysdate,
p_creation_user in acs_objects.creation_user%TYPE default null,
p_creation_ip in acs_objects.creation_ip%TYPE default null,
p_context_id in acs_objects.context_id%TYPE default null
) return organizations.organization_id%TYPE;
procedure del (
p_organization_id in organizations.organization_id%TYPE
);
end organization;
/
show errors
create or replace package body organization
as
function new (
p_organization_id in organizations.organization_id%TYPE default null,
p_legal_name in organizations.legal_name%TYPE,
p_name in organizations.name%TYPE,
p_notes in organizations.notes%TYPE default null,
p_reg_number in organizations.reg_number%TYPE default null,
p_email in parties.email%TYPE default null,
p_url in parties.url%TYPE default null,
p_object_type in acs_objects.object_type%TYPE default 'organization',
p_creation_date in acs_objects.creation_date%TYPE default sysdate,
p_creation_user in acs_objects.creation_user%TYPE default null,
p_creation_ip in acs_objects.creation_ip%TYPE default null,
p_context_id in acs_objects.context_id%TYPE default null
) return organizations.organization_id%TYPE
is
v_organization_id organizations.organization_id%TYPE;
begin
v_organization_id := party.new (
party_id => null,
object_type => p_object_type,
creation_user => p_creation_user,
creation_ip => p_creation_ip,
email => p_email,
url => p_url,
context_id => p_context_id
);
insert into organizations (
legal_name,
name,
notes,
organization_id,
reg_number
)
values (
p_legal_name,
p_name,
p_notes,
v_organization_id,
p_reg_number
);
acs_permission.grant_permission (
object_id => v_organization_id,
grantee_id => p_creation_user,
privilege => 'admin'
);
return v_organization_id;
end new;
--
--
procedure del (
p_organization_id in organizations.organization_id%TYPE
)
is
begin
delete from acs_permissions
where object_id = organization.del.p_organization_id;
delete from organizations
where organization_id = organization.del.p_organization_id;
party.del(organization.del.p_organization_id);
end del;
end organization;
/
show errors
-- @cvs-id $Id$
create table organization_types (
organization_type_id serial
constraint company_types_pk
primary key,
type varchar (40)
constraint company_type_name_uq
unique
constraint company_type_name_nn
not null
);
comment on table organization_types is '
This is a lookup table displaying organization types.
';
comment on column organization_types.organization_type_id is '
Primary key.
';
comment on column organization_types.type is '
Pretty name.
';
-- add some data
insert into organization_types (type) values ('Vendor');
insert into organization_types (type) values ('Customer');
insert into organization_types (type) values ('Prospect');
insert into organization_types (type) values ('Other');
-- organization
-- this will be a party
-- probably should be it's own package
create table organizations (
organization_id integer
constraint organization_id_pk
primary key
constraint organization_id_fk
references parties(party_id),
name varchar(200),
-- usually the same as name
legal_name varchar(200),
-- this can be ein/ssn/vat
reg_number varchar(100),
-- The internal client_id. You should have your own sequence for that.
client_id varchar(100) constraint orga_client_id_un unique,
notes text
);
create index organization_name_ix on organizations(name);
create index organization_cliend_idx on organizations(client_id);
create table organization_type_map (
organization_id integer
constraint org_type_map_org_id_fk
references organizations(organization_id),
organization_type_id integer
constraint org_type_map_type_fk
references organization_types(organization_type_id)
);
\i organizations-plsql-create.sql
-- @cvs-id $Id$
select drop_package('organization');
-- drop permissions
delete from acs_permissions where object_id in (select organization_id from organizations);
-- drop objects
create function inline_0()
returns integer as '
declare
object_rec record;
begin
for object_rec in select object_id from acs_objects where object_type=''organization''
loop
perform acs_object__delete( object_rec.object_id );
end loop;
return 0;
end;' language 'plpgsql';
select inline_0();
drop function inline_0();
--drop table
drop table organization_type_map;
drop table organizations cascade;
--drop type
select acs_object_type__drop_type(
'organization',
't'
);
drop table organization_types;
-- packages/organization/sql/postgresql/organization-plsql.sql
--
-- @author Jon Griffin
-- @creation-date 24 February 2003
-- @cvs-id $Id$
-- What no comments?
create function inline_0 ()
returns integer as '
begin
PERFORM acs_object_type__create_type (
''organization'', -- object_type
''Organization'', -- pretty_name
''Organization'', -- pretty_plural
''party'', -- supertype
''organizations'', -- table_name
''organization_id'', -- id_column
''organization'', -- package_name
''f'', -- abstract_p
null, -- type_extension_table
''organization__name'' -- name_method
);
return 0;
end;' language 'plpgsql';
select inline_0 ();
drop function inline_0 ();
------ start of oacs new proc
select define_function_args('organization__new','legal_name,name,notes,organization_id,organization_type_id,reg_number,email,url,creation_user,creation_ip,context_id');
create or replace function organization__new (
varchar, -- legal_name
varchar, -- name
text, -- notes
integer, -- organization_id
integer, -- organization_type_id
varchar, -- reg_number
varchar, -- email
varchar, -- url
integer, -- creation_user
varchar, -- creation_ip
integer -- context_id
) returns integer as '
declare
p_legal_name alias for $1; -- comment
p_name alias for $2; -- comment
p_notes alias for $3; -- comment
p_organization_id alias for $4; -- comment
p_organization_type_id alias for $5; -- comment
p_reg_number alias for $6; -- comment
p_email alias for $7; -- email
p_url alias for $8;
p_creation_user alias for $9; -- comment
p_creation_ip alias for $10;
p_context_id alias for $11; -- comment
-- local vars
v_organization_id organizations.organization_id%TYPE;
begin
v_organization_id := party__new (
p_organization_id, -- party_id
''organization'',
now(),
p_creation_user,
p_creation_ip,
p_email,
p_url,
p_context_id
);
update acs_objects
set title = p_name
where object_id = v_organization_id;
insert into organizations (
legal_name,
name,
notes,
organization_id,
reg_number
)
values (
p_legal_name,
p_name,
p_notes,
v_organization_id,
p_reg_number
);
insert into organization_type_map (
organization_id,
organization_type_id
) values (
v_organization_id,
p_organization_type_id
);
PERFORM acs_permission__grant_permission (
v_organization_id,
p_creation_user,
''admin''
);
raise NOTICE ''Adding organization - %'',p_name;
return v_organization_id;
end;' language 'plpgsql';
------ end new proc
------ start of oacs del proc
select define_function_args('organization__del','organization_id');
create or replace function organization__del (integer)
returns integer as '
declare
p_organization_id alias for $1;
v_return integer := 0;
begin
-- these should not be necessary
delete from acs_permissions
where object_id = p_organization_id;
delete from organization_type_map
where organization_id = p_organization_id;
delete from organizations
where organization_id = p_organization_id;
raise NOTICE ''Deleting organization - %'',p_organization_id;
PERFORM party__delete(p_organization_id);
return v_return;
end;' language 'plpgsql';
------ end del proc
------ start of oacs set proc
select define_function_args('organization__set','legal_name,name,notes,organization_id,reg_number');
create or replace function organization__set (varchar,varchar,text,integer,varchar)
returns integer as '
declare
p_legal_name alias for $1; -- comment
p_name alias for $2; -- comment
p_notes alias for $3; -- comment
p_organization_id alias for $4; -- comment
p_reg_number alias for $5; -- comment
v_return integer := 0;
begin
update organizations
set
legal_name = p_legal_name,
name = p_name,
notes = p_notes,
organization_id = p_organization_id,
reg_number = p_reg_number
where organization_id = p_organization_id;
raise NOTICE ''Updating - organization - %'',p_organization_id;
return v_return;
end;' language 'plpgsql';
------ end set proc
------ start of oacs name proc
select define_function_args('organization___name','organization_id');
create or replace function organization__name (integer)
returns varchar as '
declare
p_organization_id alias for $1;
v_organization_name organizations.name%TYPE;
begin
select name || ''_'' || organization_id into v_organization_name
from organizations
where organization_id = p_organization_id;
return v_organization_name;
end;
' language 'plpgsql';
------ end name proc
-- create functions for organization_rels
select define_function_args('organization_rel__new','rel_id,rel_type;organization_rel,object_id_one,object_id_two,creation_user,creation_ip');
create or replace function organization_rel__new (integer,varchar,integer,integer,integer,varchar)
returns integer as '
declare
new__rel_id alias for $1; -- default null
rel_type alias for $2; -- default ''organization_rel''
object_id_one alias for $3;
object_id_two alias for $4;
creation_user alias for $5; -- default null
creation_ip alias for $6; -- default null
v_rel_id integer;
begin
v_rel_id := acs_rel__new (
new__rel_id,
rel_type,
object_id_one,
object_id_two,
object_id_one,
creation_user,
creation_ip
);
return v_rel_id;
end;' language 'plpgsql';
-- function new
create or replace function organization_rel__new (integer,integer)
returns integer as '
declare
object_id_one alias for $1;
object_id_two alias for $2;
begin
return organization_rel__new(null,
''organization_rel'',
object_id_one,
object_id_two,
null,
null);
end;' language 'plpgsql';
-- procedure delete
create or replace function organization_rel__delete (integer)
returns integer as '
declare
rel_id alias for $1;
begin
PERFORM acs_rel__delete(rel_id);
return 0;
end;' language 'plpgsql';
--
--
--
-- @author Jade Rubick (jader@bread.com)
-- @creation-date 2004-06-25
-- @arch-tag: 07f8a128-3ba4-411b-af7a-4ced0c68278b
-- @cvs-id $Id$
--
create or replace function organization__name (integer)
returns varchar as '
declare
p_organization_id alias for $1;
v_organization_name organizations.name%TYPE;
begin
select name || ''_'' || organization_id into v_organization_name
from organizations
where organization_id = p_organization_id;
return v_organization_name;
end;
' language 'plpgsql';
------ end name proc
-- raise statement said organization rather than p_organization
create or replace function organization__set (varchar,varchar,text,integer,varchar)
returns integer as '
declare
p_legal_name alias for $1; -- comment
p_name alias for $2; -- comment
p_notes alias for $3; -- comment
p_organization_id alias for $4; -- comment
p_reg_number alias for $5; -- comment
v_return integer := 0;
begin
update organizations
set
legal_name = p_legal_name,
name = p_name,
notes = p_notes,
organization_id = p_organization_id,
reg_number = p_reg_number
where organization_id = p_organization_id;
raise NOTICE ''Updating - organization - %'',p_organization_id;
return v_return;
end;' language 'plpgsql';
alter table organizations drop constraint organization_name_uq;
alter table organizations add index organizations_client_id_idx on organizations(client_id);
\ No newline at end of file
alter table organizations add column client_id varchar(100);
create index organization_cliend_idx on organizations(client_id);
alter table organizations add constraint orga_client_id_un unique(client_id);
\ No newline at end of file
11/24/03 Jade Rubick
Note that the Oracle code is out of sync with the Postgres code. The
source code has comments in it indicating what needs to be updated to
make things work correctly.
The Postgres code is the reference version at this point.
In general, getting things in sync will not be that difficult. The
/sql/oracle files will need to be updated, and that's about it.
#
ad_library {
Procs for organizations
@author Jade Rubick (jader@bread.com)
@creation-date 2004-05-24
@arch-tag: 1d9b7e33-1d9f-43e5-a85e-47dc870fedb9
@cvs-id $Id$
}
namespace eval organization {}
namespace eval organizations {}
ad_proc -public organizations::name {
{-organization_id:required}
} {
Returns the organization name when given the organization_id
@author Jade Rubick (jader@bread.com)
@creation-date 2004-05-24
@param organization_id
@return organization name
@error returns an empty string
} {
return [db_string get_name {
SELECT
name
FROM
organizations
WHERE
organization_id = :organization_id
} -default ""]
}
ad_proc -public organization::get_by_name {
{-name:required}
} {
Return the organization_id of the organization with the given name. Uses
a lowercase comparison so we do not allow organizations to differ only
in case. Returns empty string if no organization found.
@author Matthew Geddert (openacs@geddert.com)
@creation-date 2005-07-06
@return organization_id
} {
return [db_string get_by_name { select organization_id from organizations where lower(name) = lower(:name) } -default {}]
}
ad_proc -public organization::new {
{-organization_id ""}
{-legal_name ""}
{-name:required}
{-notes ""}
{-organization_type_id ""}
{-reg_number ""}
{-email ""}
{-url ""}
{-user_id ""}
{-peeraddr ""}
{-package_id ""}
} {
Creates a new organization
@author Matthew Geddert (openacs@geddert.com)
@creation-date 2004-06-14
@return organization_id
@error returns an empty string
} {
if { ![exists_and_not_null user_id] } {
set user_id [ad_conn user_id]
}
if { ![exists_and_not_null peeraddr] } {
set peeraddr [ad_conn peeraddr]
}
if { ![exists_and_not_null package_id] } {
set package_id [ad_conn package_id]
}
set organization_id [db_exec_plsql create_organization {
select organization__new (
:legal_name,
:name,
:notes,
:organization_id,
:organization_type_id,
:reg_number,
:email,
:url,
:user_id,
:peeraddr,
:package_id
)
}]
return $organization_id
}
ad_proc -public organizations::id {
{-name:required}
} {
Returns the organization id for a given name
@author Christian Langmann (C_Langmann@gmx.de)
@creation-date 2005-06-14
@param name the name to look for
@return organization id
@error returns an empty string
} {
return [db_string get_id {
SELECT
organization_id
FROM
organizations
WHERE
name = :name
} -default ""]
}
ad_proc -public organization::name_p {
{-name:required}
} {
this returns whether the organization with the given name exists
} {
if {[db_0or1row contact_org_exists_p {select '1' from organizations where name = :name}]} {
return 1
} else {
return 0
}
}
ad_proc -public organization::organization_p {
{-party_id:required}
} {
is this party an organization? Cached
} {
return [util_memoize [list ::organization::organization_p_not_cached -party_id $party_id]]
}
ad_proc -public organization::organization_p_not_cached {
{-party_id:required}
} {
is this party and organization?
} {
if {[person::person_p -party_id $party_id]} {
return 0
} else {
if {[db_0or1row contact_org_exists_p {select '1' from organizations where organization_id = :party_id}]} {
return 1
} else {
return 0
}
}
}
<master>
<property name="title">@title@</property>
<property name="context_bar">@context_bar;noquote@</property>
<formtemplate id="org"></formtemplate>
ad_page_contract {
Simple add/edit form for organizations
} {
organization_id:integer,optional
organization_type_id:integer,multiple,optional
} -properties {
context_bar:onevalue
title:onevalue
}
# The unique identifier for this package.
set package_id [ad_conn package_id]
# The id of the person logged in and browsing this page
set user_id [auth::require_login]
# address of person logged in
set peeraddr [ad_conn peeraddr]
# An HTML block for the breadcrumb trail
set title "Add an organization"
if {[exists_and_not_null organization_id]} {
set title "Edit an organization"
set context_bar [ad_context_bar "Edit"]
permission::require_permission \
-object_id $package_id \
-privilege write
set org_types_used [db_list select_org_types_used { }]
} else {
set context_bar [ad_context_bar "New"]
permission::require_permission \
-object_id $package_id \
-privilege create
set org_types_used {}
}
ad_form -name org -form {
organization_id:key
{name:text
{label "Name"}
}
{legal_name:text
{label "Legal name"}
}
{email:text,optional
{label "Organization email address"}
}
{url:text,optional
{label "Organization URL"}
}
{notes:text(textarea),optional
{label "Notes"}
}
{organization_type_id:text(checkbox),multiple
{label "Organization type"}
{ options {[db_list_of_lists get_org_types { }]}}
{ values {$org_types_used}}
}
{reg_number:text,optional
{label "Registration number (ein/ssn/vat/etc)"}
}
} -select_query_name org_query -new_data {
set org_type_id [lindex $organization_type_id 0]
set organization_id [db_exec_plsql do_insert_org { *SQL* }]
db_transaction {
set i 0
foreach oti $organization_type_id {
if {$i > 0} {
db_dml do_insert_types { }
}
incr i
}
}
} -edit_data {
db_transaction {
db_dml delete_org_types_used { }
db_dml do_update_org { *SQL* }
db_dml do_update_parties { *SQL* }
foreach oti $organization_type_id {
db_dml do_insert_types { }
}
}
} -after_submit {
ad_returnredirect "one?[export_url_vars organization_id]"
}
<?xml version="1.0"?>
<queryset>
<fullquery name="do_insert_org">
<querytext>
select organization__new (
:legal_name,
:name,
:notes,
null,
:org_type_id,
:reg_number,
:email,
:url,
:user_id,
:peeraddr,
:package_id
);
</querytext>
</fullquery>
<fullquery name="do_insert_types">
<querytext>
insert into organization_type_map
(organization_id, organization_type_id) values
(:organization_id, :oti)
</querytext>
</fullquery>
<fullquery name="do_update_org">
<querytext>
UPDATE
organizations
SET
name = :name,
legal_name = :legal_name,
notes = :notes,
reg_number = :reg_number
WHERE
organization_id = :organization_id
</querytext>
</fullquery>
<fullquery name="do_update_parties">
<querytext>
UPDATE
parties
SET
email = :email,
url = :url
WHERE
party_id = :organization_id
</querytext>
</fullquery>
<fullquery name="org_query">
<querytext>
SELECT
o.name,
o.legal_name,
p.email,
p.url,
o.notes,
o.reg_number
FROM
organizations o,
parties p
WHERE
p.party_id = o.organization_id and
o.organization_id = :organization_id
</querytext>
</fullquery>
<fullquery name="get_org_types">
<querytext>
select type,
organization_type_id
from organization_types
order by type
</querytext>
</fullquery>
<fullquery name="select_org_types_used">
<querytext>
SELECT
organization_type_id as oti
FROM
organization_type_map
WHERE
organization_id = :organization_id
</querytext>
</fullquery>
<fullquery name="delete_org_types_used">
<querytext>
DELETE FROM organization_type_map
WHERE
organization_id = :organization_id
</querytext>
</fullquery>
</queryset>
ad_page_contract {
Delete an organization
@author Jade Rubick (jade@rubick.com)
@creation-date 2003-05-29
@cvs-id $Id$
} {
organization_id:integer
}
permission::require_permission -object_id $organization_id -privilege delete
db_exec_plsql organization_delete { }
ad_returnredirect .
<?xml version="1.0"?>
<queryset>
<fullquery name="organization_delete">
<querytext>
select organization__del(:organization_id)
</querytext>
</fullquery>
</queryset>
\ No newline at end of file
<master>
<property name="title">@title@</property>
<property name="context_bar">@context_bar;noquote@</property>
<table cellpadding="3" cellspacing="3">
<tr>
<td class="list-filter-pane" valign="top" width="200">
<listfilters name="orgs"></listfilters>
</td>
<td class="list-list-pane" valign="top">
<listtemplate name="orgs"></listtemplate>
</td>
</tr>
</table>
ad_page_contract {
Displays all organizations associated with this instance.
@author jade@bread.com
@creation-date 2003-05-23
@cvs-id $Id$
@param organization_type_id limits view to a particular organization_type
@return context_bar passed to the master template to show the context bar
@return create_p does the user have create permissions?
@return admin_p does the user have admin permissions?
@return write_p does the user have write permissions?
@return title passed to the master template for title display
@return orgs datasource for organization information
} {
organization_type_id:integer,optional
} -properties {
title:onevalue
context_bar:onevalue
create_p:onevalue
delete_p:onevalue
admin_p:onevalue
write_p:onevalue
orgs:multirow
}
# The unique identifier for this package.
set package_id [ad_conn package_id]
# The id of the person logged in and browsing this page
set user_id [auth::require_login]
# An HTML block for the breadcrumb trail
set context_bar [ad_context_bar]
set title "Organizations"
# Permissions
permission::require_permission \
-object_id $package_id \
-privilege read
set create_p [permission::permission_p -object_id $package_id -privilege create]
set write_p [permission::permission_p -object_id $package_id -privilege write]
set delete_p [permission::permission_p -object_id $package_id -privilege delete]
set admin_p [permission::permission_p -object_id $package_id -privilege admin]
# list builder
template::list::create \
-name orgs \
-multirow orgs \
-key organization_id \
-class "list" \
-main_class "list" \
-sub_class "narrow" \
-elements {
edit {
label {}
display_template {
<if @orgs.write@>
<a href="add-edit?organization_id=@orgs.organization_id@" title="Edit this organization">
<img src="/shared/images/Edit16.gif" height="16" width="16"
alt="Edit" border="0"></a>
</if>
<else>
@orgs.write@
</else>
}
}
name {
label "Name"
link_url_eval {one?[export_vars {organization_id}]}
}
notes {
label "Notes"
hide_p 1
}
organization_type_id {
label "Type"
display_col organization_type
}
} \
-filters {
organization_type_id {
label "Organization type"
values {[db_list_of_lists select_org_types {}]}
where_clause {
ot.organization_type_id = :organization_type_id
}
add_url_eval {[export_vars -base "index" { {organization_type_id $__filter_value } variable_id}]}
}
} \
-actions {
"Add" "add-edit" "Add a new organization"
} \
-orderby {
default_value name,asc
name {
label "Name"
orderby_desc "upper(o.name), desc"
orderby_asc "upper(o.name)"
default_direction asc
}
notes {
label "Notes"
orderby_desc "o.notes, desc"
orderby_asc "o.notes"
default_direction asc
}
}
db_multirow -extend { item_url write } orgs orgs_query {
} {
set item_url [export_vars -base "one" {organization_id}]
set write $write_p
}
<?xml version="1.0"?>
<queryset>
<fullquery name="orgs_query">
<querytext>
SELECT
o.organization_id,
o.name,
o.legal_name,
o.reg_number,
o.notes,
ot.type as organization_type
FROM
organizations o,
organization_types ot,
organization_type_map tm
WHERE
o.organization_id = tm.organization_id and
tm.organization_type_id = ot.organization_type_id
[template::list::filter_where_clauses -and -name "orgs"]
[template::list::orderby_clause -orderby -name orgs]
</querytext>
</fullquery>
<fullquery name="select_org_types">
<querytext>
SELECT
type as org_type,
organization_type_id
FROM
organization_types
ORDER BY
org_type
</querytext>
</fullquery>
</queryset>
<master>
<property name="title">@title@</property>
<property name="context_bar">@context_bar;noquote@</property>
<table>
<tr>
<th>Name:</th>
<td>@name@</td>
</tr>
<tr>
<th>Legal name:</th>
<td>@legal_name@</td>
</tr>
<tr>
<th>Email:</th>
<td><a href="mailto:@email@">@email@</a></td>
</tr>
<tr>
<th>Website:</th>
<td><a href="@url@">@url@</a></td>
</tr>
<tr>
<th>Registration number:</th>
<td>@reg_number@</td>
</tr>
<tr>
<th>Notes:</th>
<td>@notes@</td>
</tr>
</table>
<ul>
<li><a href="add-edit?organization_id=@organization_id@">edit organization</a>
<if @delete_p@>
<li><a href="delete?organization_id=@organization_id@">delete organization</a>
</if>
</ul>
ad_page_contract {
Displays all organizations associated with this instance.
@author jade@bread.com
@creation-date 2003-05-23
@cvs-id $Id$
@return context_bar passed to the master template to show the context bar
@return create_p does the user have create permissions?
@return admin_p does the user have admin permissions?
@return write_p does the user have write permissions?
@return title passed to the master template for title display
@return name organization name
@return legal_name organization's legal name
@return reg_number EIN/SSN/etc number
@return notes notes about the organization
} {
organization_id:integer
} -properties {
title:onevalue
context_bar:onevalue
create_p:onevalue
admin_p:onevalue
delete_p:onevalue
write_p:onevalue
name:onevalue
legal_name:onevalue
reg_number:onevalue
notes:onevalue
}
# The unique identifier for this package.
set package_id [ad_conn package_id]
# The id of the person logged in and browsing this page
set user_id [auth::require_login]
# An HTML block for the breadcrumb trail
set context_bar [ad_context_bar "One"]
set title "Organizations"
# Permissions
permission::require_permission \
-object_id $package_id \
-privilege read
set create_p [permission::permission_p -object_id $package_id -privilege create]
set write_p [permission::permission_p -object_id $package_id -privilege write]
set delete_p [permission::permission_p -object_id $package_id -privilege delete]
set admin_p [permission::permission_p -object_id $package_id -privilege admin]
db_1row org_query { }
<?xml version="1.0"?>
<queryset>
<fullquery name="org_query">
<querytext>
SELECT
o.name,
o.legal_name,
p.email,
p.url,
o.notes,
o.reg_number
FROM
organizations o,
parties p
WHERE
p.party_id = o.organization_id and
o.organization_id = :organization_id
</querytext>
</fullquery>
</queryset>
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