--Order 20013086

---CUSTOMERRESIDENTIALSETTINGS table---
ALTER TABLE CUSTOMERRESIDENTIALSETTINGS ADD (INACTIVECLIENTSERVICEDAYS NUMBER DEFAULT 0 NOT NULL);

ALTER TABLE CUSTOMERRESIDENTIALSETTINGS
  ADD CONSTRAINT INACTIVECLSERVICEDAYS_VALID1_1
  CHECK (INACTIVECLIENTSERVICEDAYS BETWEEN 0 AND 999);


--Order 20014926

---CLIENT table---
ALTER TABLE CLIENT ADD (CLIENTTYPE NUMBER DEFAULT 0 NOT NULL);

COMMENT ON COLUMN CLIENT.CLIENTTYPE
  IS '0 = Normal Client
1 = Unknown Client (client for garments for which it is unknown to who they belong)
2 = Pool Client per Department
3 = Pool Client per Customer
';

ALTER TABLE CLIENT
  ADD CONSTRAINT CLIENTTYPE_VALID1_1
  CHECK (CLIENTTYPE IN (0, 1, 2, 3));


---CUSTOMERRESIDENTIALSETTINGS table---

ALTER TABLE CUSTOMERRESIDENTIALSETTINGS ADD (ALLOWUNKNOWNCLIENTS NUMBER DEFAULT 0 NOT NULL);
ALTER TABLE CUSTOMERRESIDENTIALSETTINGS ADD (ALLOWPOOLCLIENTS NUMBER DEFAULT 0 NOT NULL);
ALTER TABLE CUSTOMERRESIDENTIALSETTINGS ADD (ACCEPTINACTIVECLIENTS NUMBER DEFAULT 0 NOT NULL);

COMMENT ON COLUMN CUSTOMERRESIDENTIALSETTINGS.ALLOWUNKNOWNCLIENTS
  IS '0 = Unknown clients not allowed
1 = Unknown clients are allowed
';
COMMENT ON COLUMN CUSTOMERRESIDENTIALSETTINGS.ALLOWPOOLCLIENTS
  IS '0 = Pool clients not allowed
1 = Pool client per customer allowed
2 = Pool client per department allowed
';
COMMENT ON COLUMN CUSTOMERRESIDENTIALSETTINGS.ACCEPTINACTIVECLIENTS
  IS '0 = Inactive clients are not accepted
1 = Inactive clients are accepted, return to sender
2 = Inactive clients are accepted, move to pool
';

ALTER TABLE CUSTOMERRESIDENTIALSETTINGS
  ADD CONSTRAINT ALLOWUNKNOWNCLIENTS_VALID1_1
  CHECK (ALLOWUNKNOWNCLIENTS IN (0, 1));
ALTER TABLE CUSTOMERRESIDENTIALSETTINGS
  ADD CONSTRAINT ALLOWPOOLCLIENTS_VALID1_1
  CHECK (ALLOWPOOLCLIENTS IN (0, 1, 2));
ALTER TABLE CUSTOMERRESIDENTIALSETTINGS
  ADD CONSTRAINT ACCEPTINACTIVECLIENTS_VALID1_1
  CHECK (ACCEPTINACTIVECLIENTS IN (0, 1, 2));

--Order 20013510

ALTER TABLE PACKINGNOTE ADD (INPROCESSATWORKSTATION_ID NUMBER NULL);
ALTER TABLE PACKINGNOTE ADD (INPROCESSSTARTTIMESTAMP DATE NULL);

COMMENT ON COLUMN PACKINGNOTE.INPROCESSATWORKSTATION_ID
  IS 'Used for locking the delivery note by a workstation.';
 
CREATE INDEX XIF18PACKINGNOTE ON PACKINGNOTE (INPROCESSATWORKSTATION_ID);

ALTER TABLE PACKINGNOTE
  ADD CONSTRAINT PACKINGNOTE_INPROCESSATWS FOREIGN KEY (INPROCESSATWORKSTATION_ID)
  REFERENCES WORKSTATION (WORKSTATION_ID) ON DELETE SET NULL;

--Order 20014864

ALTER TABLE CUSTOMEREDIINFO ADD (EDIGROUP VARCHAR2(12) NULL);