Index: /sandbox/workflow/branches/1015/setup/tables_update.inc.php
===================================================================
--- /sandbox/workflow/branches/1015/setup/tables_update.inc.php	(revision 3061)
+++ /sandbox/workflow/branches/1015/setup/tables_update.inc.php	(revision 3110)
@@ -1287,4 +1287,163 @@
 			/* adding primary key without the column removed */
 			$GLOBALS['phpgw']->ADOdb->query('ALTER TABLE egw_wf_interinstance_relations ADD CONSTRAINT egw_wf_interinstance_relations_pkey PRIMARY KEY (wf_parent_instance_id, wf_child_instance_id)');
+			
+			
+			
+			/*
+			 * ATUALIZAÇÃO DO ORGANOGRAMA - TRADUÇÃO DAS TABELAS PARA O INGLÊS
+			 * */
+			
+			/*DROP FOREIGN KEYS*/
+			$workflowDB->query('ALTER TABLE public.area DROP CONSTRAINT "$1";');
+			$workflowDB->query('ALTER TABLE public.area DROP CONSTRAINT "$2";');
+			$workflowDB->query('ALTER TABLE public.area DROP CONSTRAINT "$3";');
+			//$workflowDB->query('ALTER TABLE public.area DROP CONSTRAINT "$4";');
+			$workflowDB->query('ALTER TABLE public.area DROP CONSTRAINT "$5";');
+			$workflowDB->query('ALTER TABLE public.area DROP CONSTRAINT "$6";');
+			$workflowDB->query('ALTER TABLE public.area DROP CONSTRAINT "$7";');
+			$workflowDB->query('ALTER TABLE public.substituicao DROP CONSTRAINT "$1";');
+			$workflowDB->query('ALTER TABLE public.substituicao DROP CONSTRAINT "$2";');
+			$workflowDB->query('ALTER TABLE public.telefone DROP CONSTRAINT "$1";');
+			$workflowDB->query('ALTER TABLE public.funcionario DROP CONSTRAINT "$1";');
+			$workflowDB->query('ALTER TABLE public.funcionario DROP CONSTRAINT "$2";');
+			$workflowDB->query('ALTER TABLE public.funcionario DROP CONSTRAINT "$3";');
+			$workflowDB->query('ALTER TABLE public.funcionario DROP CONSTRAINT "$4";');
+			$workflowDB->query('ALTER TABLE public.funcionario DROP CONSTRAINT "$5";');
+			$workflowDB->query('ALTER TABLE public.funcionario DROP CONSTRAINT "$6";');
+			$workflowDB->query('ALTER TABLE public.funcionario_status DROP CONSTRAINT "$1";');
+			$workflowDB->query('ALTER TABLE public.funcionario_categoria DROP CONSTRAINT "$1";');
+			$workflowDB->query('ALTER TABLE public.centro_custo DROP CONSTRAINT "$1";');
+			$workflowDB->query('ALTER TABLE public.area_status DROP CONSTRAINT "$1";');
+			$workflowDB->query('ALTER TABLE public.cargo DROP CONSTRAINT "$1";');
+			$workflowDB->query('ALTER TABLE public.localidade DROP CONSTRAINT "$1";');
+			$workflowDB->query('ALTER TABLE public.localidade DROP CONSTRAINT "$2";');
+			
+			
+			/*DROP PRIMARY KEYS*/
+			$workflowDB->query('ALTER TABLE public.area DROP CONSTRAINT area_pkey;');
+			$workflowDB->query('ALTER TABLE public.substituicao DROP CONSTRAINT substituicao_pkey;');
+			$workflowDB->query('ALTER TABLE public.telefone DROP CONSTRAINT telefone_pkey;');
+			$workflowDB->query('ALTER TABLE public.organizacao DROP CONSTRAINT organizacao_pkey;');
+			$workflowDB->query('ALTER TABLE public.funcionario DROP CONSTRAINT funcionario_pkey;');
+			$workflowDB->query('ALTER TABLE public.funcionario_status DROP CONSTRAINT funcionario_status_pkey;');
+			$workflowDB->query('ALTER TABLE public.funcionario_categoria DROP CONSTRAINT funcionario_categoria_pkey;');
+			$workflowDB->query('ALTER TABLE public.centro_custo DROP CONSTRAINT centrocusto_pkey;');
+			$workflowDB->query('ALTER TABLE public.area_status DROP CONSTRAINT area_status_pkey;');
+			$workflowDB->query('ALTER TABLE public.cargo DROP CONSTRAINT cargo_pkey;');
+			$workflowDB->query('ALTER TABLE public.localidade DROP CONSTRAINT localidade_pkey;');
+			
+			
+			/* RENAME / ADD AND DROP COLLUMNS */
+			$workflowDB->query('ALTER TABLE public.area RENAME COLUMN superior_area_id TO parent_area_id;');
+			$workflowDB->query('ALTER TABLE public.area RENAME COLUMN auxiliar_funcionario_id TO area_secretary_id;');
+			$workflowDB->query('ALTER TABLE public.area RENAME COLUMN titular_funcionario_id TO area_leader_id;');
+			$workflowDB->query('ALTER TABLE public.area RENAME COLUMN centro_custo_id TO cost_center_id;');
+			$workflowDB->query('ALTER TABLE public.area RENAME COLUMN sigla TO acronym;');
+			$workflowDB->query('ALTER TABLE public.area RENAME COLUMN descricao TO description;');
+			$workflowDB->query('ALTER TABLE public.area RENAME COLUMN ativa TO is_active;');
+			$workflowDB->query('ALTER TABLE public.area DROP COLUMN organizacao_id;');
+			$workflowDB->query('ALTER TABLE public.area ADD COLUMN area_level_id integer;');
+			$workflowDB->query('ALTER TABLE public.substituicao RENAME COLUMN substituicao_id TO leader_substitute_id;');
+			$workflowDB->query('ALTER TABLE public.substituicao RENAME COLUMN funcionario_id TO employee_id;');
+			$workflowDB->query('ALTER TABLE public.substituicao RENAME COLUMN data_inicio TO start_date;');
+			$workflowDB->query('ALTER TABLE public.substituicao RENAME COLUMN data_fim TO end_date;');
+			$workflowDB->query('ALTER TABLE public.telefone RENAME COLUMN telefone_id TO telephone_id;');
+			$workflowDB->query('ALTER TABLE public.telefone RENAME COLUMN organizacao_id TO organization_id;');
+			$workflowDB->query('ALTER TABLE public.telefone RENAME COLUMN descricao TO description;');
+			$workflowDB->query('ALTER TABLE public.telefone RENAME COLUMN numero TO number;');
+			$workflowDB->query('ALTER TABLE public.organizacao RENAME COLUMN organizacao_id TO organization_id;');
+			$workflowDB->query('ALTER TABLE public.organizacao RENAME COLUMN nome TO name;');
+			$workflowDB->query('ALTER TABLE public.organizacao RENAME COLUMN descricao TO description;');
+			$workflowDB->query('ALTER TABLE public.organizacao RENAME COLUMN url_imagem TO url_image;');
+			$workflowDB->query('ALTER TABLE public.organizacao RENAME COLUMN sitio TO website;');
+			$workflowDB->query('ALTER TABLE public.funcionario RENAME COLUMN funcionario_id TO employee_id;');
+			$workflowDB->query('ALTER TABLE public.funcionario RENAME COLUMN funcionario_categoria_id TO employee_category_id;');
+			$workflowDB->query('ALTER TABLE public.funcionario RENAME COLUMN funcionario_status_id TO employee_status_id;');
+			$workflowDB->query('ALTER TABLE public.funcionario RENAME COLUMN cargo_id TO job_title_id;');
+			$workflowDB->query('ALTER TABLE public.funcionario DROP COLUMN centro_custo_id;');
+			$workflowDB->query('ALTER TABLE public.funcionario RENAME COLUMN localidade_id TO location_id;');
+			$workflowDB->query('ALTER TABLE public.funcionario DROP COLUMN organizacao_id;');
+			$workflowDB->query('ALTER TABLE public.funcionario RENAME COLUMN titulo TO title;');
+			$workflowDB->query('ALTER TABLE public.funcionario RENAME COLUMN nivel TO is_supervisor;');
+			$workflowDB->query('ALTER TABLE public.funcionario_status RENAME COLUMN funcionario_status_id TO employee_status_id;');
+			$workflowDB->query('ALTER TABLE public.funcionario_status RENAME COLUMN organizacao_id TO organization_id;');
+			$workflowDB->query('ALTER TABLE public.funcionario_status RENAME COLUMN descricao TO description;');
+			$workflowDB->query('ALTER TABLE public.funcionario_status RENAME COLUMN exibir TO is_active;');
+			$workflowDB->query('ALTER TABLE public.funcionario_categoria RENAME COLUMN funcionario_categoria_id TO employee_category_id;');
+			$workflowDB->query('ALTER TABLE public.funcionario_categoria RENAME COLUMN organizacao_id TO organization_id;');
+			$workflowDB->query('ALTER TABLE public.funcionario_categoria RENAME COLUMN descricao TO description;');
+			$workflowDB->query('ALTER TABLE public.centro_custo RENAME COLUMN centro_custo_id TO cost_center_id;');
+			$workflowDB->query('ALTER TABLE public.centro_custo RENAME COLUMN organizacao_id TO organization_id;');
+			$workflowDB->query('ALTER TABLE public.centro_custo RENAME COLUMN nm_centro_custo TO cost_center_number;');
+			$workflowDB->query('ALTER TABLE public.centro_custo RENAME COLUMN descricao TO description;');
+			$workflowDB->query('ALTER TABLE public.centro_custo RENAME COLUMN grupo TO group_name;');
+			$workflowDB->query('ALTER TABLE public.centro_custo ADD COLUMN is_active SMALLINT default 1;');
+			$workflowDB->query('ALTER TABLE public.area_status RENAME COLUMN area_status_id TO area_level_id;');
+			$workflowDB->query('ALTER TABLE public.area_status RENAME COLUMN organizacao_id TO organization_id;');
+			$workflowDB->query('ALTER TABLE public.area_status RENAME COLUMN nivel TO level;');
+			$workflowDB->query('ALTER TABLE public.area_status RENAME COLUMN descricao TO description;');
+			$workflowDB->query('ALTER TABLE public.cargo RENAME COLUMN cargo_id TO job_title_id;');
+			$workflowDB->query('ALTER TABLE public.cargo RENAME COLUMN organizacao_id TO organization_id;');
+			$workflowDB->query('ALTER TABLE public.cargo RENAME COLUMN descricao TO description;');
+			$workflowDB->query('ALTER TABLE public.localidade RENAME COLUMN localidade_id TO location_id;');
+			$workflowDB->query('ALTER TABLE public.localidade RENAME COLUMN organizacao_id TO organization_id;');
+			$workflowDB->query('ALTER TABLE public.localidade RENAME COLUMN descricao TO description;');
+			$workflowDB->query('ALTER TABLE public.localidade DROP COLUMN centro_custo_id;');
+			$workflowDB->query('ALTER TABLE public.localidade RENAME COLUMN empresa TO company_name;');
+			$workflowDB->query('ALTER TABLE public.localidade RENAME COLUMN endereco TO address;');
+			$workflowDB->query('ALTER TABLE public.localidade RENAME COLUMN complemento TO address_complement;');
+			$workflowDB->query('ALTER TABLE public.localidade RENAME COLUMN cep TO zip_code;');
+			$workflowDB->query('ALTER TABLE public.localidade RENAME COLUMN bairro TO neighborhood;');
+			$workflowDB->query('ALTER TABLE public.localidade RENAME COLUMN cidade TO city_name;');
+			$workflowDB->query('ALTER TABLE public.localidade RENAME COLUMN uf TO state;');
+			
+			
+			/* RENAME TABLES */
+			$workflowDB->query('ALTER TABLE public.area RENAME TO egw_oc_area;');
+			$workflowDB->query('ALTER TABLE public.substituicao RENAME TO egw_oc_leader_substitute;');
+			$workflowDB->query('ALTER TABLE public.telefone RENAME TO egw_oc_telephone;');
+			$workflowDB->query('ALTER TABLE public.organizacao RENAME TO egw_oc_organization;');
+			$workflowDB->query('ALTER TABLE public.funcionario RENAME TO egw_oc_employee;');
+			$workflowDB->query('ALTER TABLE public.funcionario_status RENAME TO egw_oc_employee_status;');
+			$workflowDB->query('ALTER TABLE public.funcionario_categoria RENAME TO egw_oc_employee_category;');
+			$workflowDB->query('ALTER TABLE public.centro_custo RENAME TO egw_oc_cost_center;');
+			$workflowDB->query('ALTER TABLE public.area_status RENAME TO egw_oc_area_level;');
+			$workflowDB->query('ALTER TABLE public.cargo RENAME TO egw_oc_job_title;');
+			$workflowDB->query('ALTER TABLE public.localidade RENAME TO egw_oc_location;');
+			
+			
+			/* CREATING PRIMARY KEYS */
+			$workflowDB->query('ALTER TABLE public.egw_oc_area ADD CONSTRAINT egw_oc_area_pkey PRIMARY KEY (area_id);');
+			$workflowDB->query('ALTER TABLE public.egw_oc_leader_substitute ADD CONSTRAINT egw_oc_leader_substitute_pkey PRIMARY KEY (leader_substitute_id);');
+			$workflowDB->query('ALTER TABLE public.egw_oc_telephone ADD CONSTRAINT egw_oc_telephone_pkey PRIMARY KEY (telephone_id);');
+			$workflowDB->query('ALTER TABLE public.egw_oc_organization ADD CONSTRAINT egw_oc_organization_pkey PRIMARY KEY (organization_id);');
+			$workflowDB->query('ALTER TABLE public.egw_oc_employee ADD CONSTRAINT egw_oc_employee_pkey PRIMARY KEY (employee_id,area_id);');
+			$workflowDB->query('ALTER TABLE public.egw_oc_employee_status ADD CONSTRAINT egw_oc_employee_status_pkey PRIMARY KEY (employee_status_id);');
+			$workflowDB->query('ALTER TABLE public.egw_oc_employee_category ADD CONSTRAINT egw_oc_employee_category_pkey PRIMARY KEY (employee_category_id);');
+			$workflowDB->query('ALTER TABLE public.egw_oc_cost_center ADD CONSTRAINT egw_oc_cost_center_pkey PRIMARY KEY (cost_center_id);');
+			$workflowDB->query('ALTER TABLE public.egw_oc_area_level ADD CONSTRAINT egw_oc_area_level_pkey PRIMARY KEY (area_level_id);');
+			$workflowDB->query('ALTER TABLE public.egw_oc_job_title ADD CONSTRAINT egw_oc_job_title_pkey PRIMARY KEY (job_title_id);');
+			$workflowDB->query('ALTER TABLE public.egw_oc_location ADD CONSTRAINT egw_oc_location_pkey PRIMARY KEY (location_id);');
+			
+			
+			/* CREATING CONSTRAINTS */
+			$workflowDB->query('ALTER TABLE public.egw_oc_area ADD CONSTRAINT "$1" FOREIGN KEY (parent_area_id) REFERENCES egw_oc_area (area_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;');
+			$workflowDB->query('ALTER TABLE public.egw_oc_area ADD CONSTRAINT "$2" FOREIGN KEY (area_level_id) REFERENCES egw_oc_area_level (area_level_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;');
+			$workflowDB->query('ALTER TABLE public.egw_oc_area ADD CONSTRAINT "$3" FOREIGN KEY (cost_center_id) REFERENCES egw_oc_cost_center (cost_center_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;');
+			$workflowDB->query('ALTER TABLE public.egw_oc_leader_substitute ADD CONSTRAINT "$1" FOREIGN KEY (area_id) REFERENCES egw_oc_area (area_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;');
+			$workflowDB->query('ALTER TABLE public.egw_oc_telephone ADD CONSTRAINT "$1" FOREIGN KEY (organization_id) REFERENCES egw_oc_organization (organization_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;');
+			$workflowDB->query('ALTER TABLE public.egw_oc_employee ADD CONSTRAINT "$1" FOREIGN KEY (area_id) REFERENCES egw_oc_area (area_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;');
+			$workflowDB->query('ALTER TABLE public.egw_oc_employee ADD CONSTRAINT "$2" FOREIGN KEY (employee_category_id) REFERENCES egw_oc_employee_category (employee_category_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;');
+			$workflowDB->query('ALTER TABLE public.egw_oc_employee ADD CONSTRAINT "$3" FOREIGN KEY (location_id) REFERENCES egw_oc_location (location_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;');
+			$workflowDB->query('ALTER TABLE public.egw_oc_employee ADD CONSTRAINT "$4" FOREIGN KEY (employee_status_id) REFERENCES egw_oc_employee_status (employee_status_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;');
+			$workflowDB->query('ALTER TABLE public.egw_oc_employee ADD CONSTRAINT "$5" FOREIGN KEY (job_title_id) REFERENCES egw_oc_job_title (job_title_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;');
+			$workflowDB->query('ALTER TABLE public.egw_oc_employee_status ADD CONSTRAINT "$1" FOREIGN KEY (organization_id) REFERENCES egw_oc_organization (organization_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;');
+			$workflowDB->query('ALTER TABLE public.egw_oc_employee_category ADD CONSTRAINT "$1" FOREIGN KEY (organization_id) REFERENCES egw_oc_organization (organization_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;');
+			$workflowDB->query('ALTER TABLE public.egw_oc_cost_center ADD CONSTRAINT "$1" FOREIGN KEY (organization_id) REFERENCES egw_oc_organization (organization_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;');
+			$workflowDB->query('ALTER TABLE public.egw_oc_area_level ADD CONSTRAINT "$1" FOREIGN KEY (organization_id) REFERENCES egw_oc_organization (organization_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;');
+			$workflowDB->query('ALTER TABLE public.egw_oc_job_title ADD CONSTRAINT "$1" FOREIGN KEY (organization_id) REFERENCES egw_oc_organization (organization_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;');
+			$workflowDB->query('ALTER TABLE public.egw_oc_location ADD CONSTRAINT "$1" FOREIGN KEY (organization_id) REFERENCES egw_oc_organization (organization_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION;');
+					
+					
 		}
 
