--THIS FILE IS NEEDED ONLY FOR THE ONLINE UPDATE OR WHEN UPGRADING FROM VERSION 8.9.0.5!!!

CREATE OR REPLACE procedure V8_UPD_ADDHSKRIGHTS is
begin
  for hsk in (select distinct wusr_wegr_id from wusr where wusr_wegr_id is not null and wusr_name like 'Housekeeping%') loop
    insert into wusr (WUSR_ID, WUSR_VALUE, WUSR_NAME, WUSR_XCMS_ID, WUSR_WEGR_ID) values 
       (seq_wusr.nextval, 1, 'HousekeepingHousekeeping Status', null, hsk.wusr_wegr_id); 
  end loop;
end V8_UPD_ADDHSKRIGHTS;
/

CREATE OR REPLACE procedure V8_UPD_FIXARTRANSACTIONRIGHTS is
  cursor OOO is
    select distinct wusr_wegr_id from wusr where wusr_wegr_id is not null;
  cooo OOO%rowtype;

begin
  for cooo in ooo loop
    insert into wusr values (seq_wusr.nextval, null, cooo.wusr_wegr_id, 'Accounts ReceivableTransactionsCompression of Account Transaction Postings', 1); 
    insert into wusr values (seq_wusr.nextval, null, cooo.wusr_wegr_id, 'Accounts ReceivableTransactionsCompression of CC Transaction Postings', 1); 
  end loop;

  exception
    when no_data_found then
      raise; --null;
    when others then
      raise; --null;  
end V8_UPD_FIXARTRANSACTIONRIGHTS;
/

CREATE OR REPLACE procedure V8_UPD_FIXMOVEPOSTINGRIGHTS is
begin

  for mp in (select * from wusr where wusr_name='CashieringMove Postings') loop
  
    insert into wusr (WUSR_ID, WUSR_VALUE, WUSR_NAME, WUSR_XCMS_ID, WUSR_WEGR_ID) values 
       (seq_wusr.nextval, mp.wusr_value, 'CashieringMove PostingsMove Postings To Another Folio', mp.wusr_xcms_id, mp.wusr_wegr_id); 
    insert into wusr (WUSR_ID, WUSR_VALUE, WUSR_NAME, WUSR_XCMS_ID, WUSR_WEGR_ID) values 
       (seq_wusr.nextval, mp.wusr_value, 'CashieringMove PostingsMove Postings On Same Folio', mp.wusr_xcms_id, mp.wusr_wegr_id);
 
  end loop;

  exception
    when no_data_found then
      raise; --null;
    when others then
      raise; --null;  
end V8_UPD_FIXMOVEPOSTINGRIGHTS;
/

CREATE OR REPLACE procedure V8_UPD_FIXXCMSEDITBYTYPE is
begin
  for mp in (select * from wusr where wusr_name='Customer ProfilesProfile DetailsEdit') loop
    insert into wusr (WUSR_ID, WUSR_VALUE, WUSR_NAME, WUSR_XCMS_ID, WUSR_WEGR_ID) values 
       (seq_wusr.nextval, mp.wusr_value, 'Customer ProfilesProfile DetailsEditCompany', mp.wusr_xcms_id, mp.wusr_wegr_id);
    insert into wusr (WUSR_ID, WUSR_VALUE, WUSR_NAME, WUSR_XCMS_ID, WUSR_WEGR_ID) values 
       (seq_wusr.nextval, mp.wusr_value, 'Customer ProfilesProfile DetailsEditTravel Agent', mp.wusr_xcms_id, mp.wusr_wegr_id);
    insert into wusr (WUSR_ID, WUSR_VALUE, WUSR_NAME, WUSR_XCMS_ID, WUSR_WEGR_ID) values 
       (seq_wusr.nextval, mp.wusr_value, 'Customer ProfilesProfile DetailsEditSource', mp.wusr_xcms_id, mp.wusr_wegr_id);
                insert into wusr (WUSR_ID, WUSR_VALUE, WUSR_NAME, WUSR_XCMS_ID, WUSR_WEGR_ID) values 
       (seq_wusr.nextval, mp.wusr_value, 'Customer ProfilesProfile DetailsEditIndividual', mp.wusr_xcms_id, mp.wusr_wegr_id); 
    insert into wusr (WUSR_ID, WUSR_VALUE, WUSR_NAME, WUSR_XCMS_ID, WUSR_WEGR_ID) values 
       (seq_wusr.nextval, mp.wusr_value, 'Customer ProfilesProfile DetailsEditVendors', mp.wusr_xcms_id, mp.wusr_wegr_id);
                   insert into wusr (WUSR_ID, WUSR_VALUE, WUSR_NAME, WUSR_XCMS_ID, WUSR_WEGR_ID) values 
       (seq_wusr.nextval, mp.wusr_value, 'Customer ProfilesProfile DetailsEditMeeting Planner', mp.wusr_xcms_id, mp.wusr_wegr_id);   
  end loop;
  exception
    when no_data_found then
      raise; --null;
    when others then
      raise; --null;  
end V8_UPD_FIXXCMSEDITBYTYPE;
/

CREATE OR REPLACE procedure V8_UPD_FIXXCMSINSERTBYTYPE is
begin
  for mp in (select * from wusr where wusr_name='Customer ProfilesProfile DetailsInsert') loop  
    insert into wusr (WUSR_ID, WUSR_VALUE, WUSR_NAME, WUSR_XCMS_ID, WUSR_WEGR_ID) values 
       (seq_wusr.nextval, mp.wusr_value, 'Customer ProfilesProfile DetailsInsertCompany', mp.wusr_xcms_id, mp.wusr_wegr_id);
    insert into wusr (WUSR_ID, WUSR_VALUE, WUSR_NAME, WUSR_XCMS_ID, WUSR_WEGR_ID) values 
       (seq_wusr.nextval, mp.wusr_value, 'Customer ProfilesProfile DetailsInsertTravel Agent', mp.wusr_xcms_id, mp.wusr_wegr_id);
                insert into wusr (WUSR_ID, WUSR_VALUE, WUSR_NAME, WUSR_XCMS_ID, WUSR_WEGR_ID) values 
       (seq_wusr.nextval, mp.wusr_value, 'Customer ProfilesProfile DetailsInsertSource', mp.wusr_xcms_id, mp.wusr_wegr_id);
                insert into wusr (WUSR_ID, WUSR_VALUE, WUSR_NAME, WUSR_XCMS_ID, WUSR_WEGR_ID) values 
       (seq_wusr.nextval, mp.wusr_value, 'Customer ProfilesProfile DetailsInsertIndividual', mp.wusr_xcms_id, mp.wusr_wegr_id);  
                insert into wusr (WUSR_ID, WUSR_VALUE, WUSR_NAME, WUSR_XCMS_ID, WUSR_WEGR_ID) values 
       (seq_wusr.nextval, mp.wusr_value, 'Customer ProfilesProfile DetailsInsertVendors', mp.wusr_xcms_id, mp.wusr_wegr_id);
                insert into wusr (WUSR_ID, WUSR_VALUE, WUSR_NAME, WUSR_XCMS_ID, WUSR_WEGR_ID) values 
       (seq_wusr.nextval, mp.wusr_value, 'Customer ProfilesProfile DetailsInsertMeeting Planner', mp.wusr_xcms_id, mp.wusr_wegr_id); 
  end loop;
  exception
    when no_data_found then
      raise; --null;
    when others then
      raise; --null;  
end V8_UPD_FIXXCMSINSERTBYTYPE;
/
