--20011235.90 User acces rights on Customer dialog

CREATE TABLE USERGROUPDIALOGACCESS
(
	USERGROUP_ID         NUMBER NOT NULL ,
	DIALOG_ID            NUMBER NOT NULL ,
	PROFILE              NUMBER DEFAULT  0  NOT NULL  CONSTRAINT  PROFILE_valid CHECK (PROFILE IN (0, 1)),
	BUTTONADD            NUMBER DEFAULT  0  NOT NULL  CONSTRAINT  BUTTONADD_valid CHECK (BUTTONADD IN (0, 1)),
	BUTTONMODIFY         NUMBER DEFAULT  0  NOT NULL  CONSTRAINT  BUTTONMODIFY_valid CHECK (BUTTONMODIFY IN (0, 1)),
	BUTTONDELETE         NUMBER DEFAULT  0  NOT NULL  CONSTRAINT  BUTTONDELETE_valid CHECK (BUTTONDELETE IN (0, 1)),
	SYSTEMUSER_ID        NUMBER NOT NULL ,
	TIMESTAMP            DATE NOT NULL 
);

COMMENT ON COLUMN USERGROUPDIALOGACCESS.PROFILE IS '0 = Full access user
1 = Limited access (delivery)
';

COMMENT ON COLUMN USERGROUPDIALOGACCESS.BUTTONADD IS '0 = Enabled
1 = Disabled
Note : the combination of ButtonAdd = 0 and Profile = 1 is not useful since it is not possible to save when attributes are empty.
';

COMMENT ON COLUMN USERGROUPDIALOGACCESS.BUTTONMODIFY IS '0 = Enabled
1 = Disabled
';

COMMENT ON COLUMN USERGROUPDIALOGACCESS.BUTTONDELETE IS '0 = Enabled
1 = Disabled
';

ALTER TABLE USERGROUPDIALOGACCESS
ADD CONSTRAINT  XPKUSERGROUPDIALOGACCESS PRIMARY KEY (USERGROUP_ID,DIALOG_ID);

CREATE  INDEX XIF1USERGROUPDIALOGACCESS ON USERGROUPDIALOGACCESS
(USERGROUP_ID   ASC);

ALTER TABLE USERGROUPDIALOGACCESS
ADD CONSTRAINT USERGRDIALACCESS_USERGROUP FOREIGN KEY (USERGROUP_ID) REFERENCES USERGROUP (USERGROUP_ID) ON DELETE CASCADE;

CREATE  INDEX XIF2USERGROUPDIALOGACCESS ON USERGROUPDIALOGACCESS
(DIALOG_ID   ASC);

ALTER TABLE USERGROUPDIALOGACCESS
ADD CONSTRAINT USERGRDIALACCESS_DIALOGS FOREIGN KEY (DIALOG_ID) REFERENCES DIALOGS (DIALOG_ID) ON DELETE CASCADE;



