--ABS-8286
-------------  EMAILSETTING  -------------------
ALTER TABLE EMAILSETTING
  DROP CONSTRAINT DOCUMENTTYPEEMAILSETT_VALID;
ALTER TABLE EMAILSETTING
  ADD CONSTRAINT DOCUMENTTYPEEMAILSETT_VALID
  CHECK (DOCUMENTTYPE BETWEEN 1 AND 21);
  
COMMENT ON COLUMN EMAILSETTING.DOCUMENTTYPE
  IS '1 = Invoice 2 = Statement 3 = Purchase order 4 = E-service password reminder 5 = Work order via web 6 = Invoice job checklist 7 = Customer 8 = Log Message 9 = Delivery Note / Consignment Note 10 = Stock Count / Order 11 = Wash List 12 = POD (Proof of delivery) 13 = On site soil scan list 14 = Shipment List 15 = Commission Report 16 = Wearer Web Login Credentials 17 = Recalculation Norm Stock Levels 18 = Recalculation Standard Deliveries 19 = Incidental Inventory 20 = Container Usage Report 21 = (Succesfully) Processed OR Packs';
  
  
-------------  WEBORDER      -------------------
ALTER TABLE WEBORDER
  DROP CONSTRAINT ORIGIN_VALID4;
ALTER TABLE WEBORDER
  ADD CONSTRAINT ORIGIN_VALID4
  CHECK (ORIGIN IN (0, 1, 2));
  
COMMENT ON COLUMN WEBORDER.ORIGIN
  IS '0 = Web application 1 = Laundry order app 2 = Web OR order';

  
-------------  ORDEREDUSEDORPACK  -------------
ALTER TABLE ORDEREDUSEDORPACK ADD ( UNIQUEITEM_ID NUMBER NULL,
								    WEBUSER_ID    NUMBER NULL );
									
CREATE INDEX XIE1ORDEREDUSEDORPACK  ON ORDEREDUSEDORPACK (WEBUSER_ID ASC, PROCESSSTATUS ASC);
 									
CREATE INDEX XIF12ORDEREDUSEDORPACK ON ORDEREDUSEDORPACK (UNIQUEITEM_ID ASC);

CREATE INDEX XIF13ORDEREDUSEDORPACK ON ORDEREDUSEDORPACK (WEBUSER_ID ASC);

ALTER TABLE ORDEREDUSEDORPACK
  ADD CONSTRAINT ORDERUSEORPACK_WEBUSER_ID FOREIGN KEY (WEBUSER_ID)
  REFERENCES WEBUSER (WEBUSER_ID) ON DELETE CASCADE;
  
ALTER TABLE ORDEREDUSEDORPACK
  ADD CONSTRAINT ORDERUSEORPACK_UNIQUEITEM_ID FOREIGN KEY (UNIQUEITEM_ID)
  REFERENCES UNIQUEITEM (UNIQUEITEM_ID) ON DELETE CASCADE;  

  
-------------  ONSITEINVENTORYADJUSTMENT  -----------------
ALTER TABLE ONSITEINVENTORYADJUSTMENT DROP CONSTRAINT ORIGIN_VALID7;
ALTER TABLE ONSITEINVENTORYADJUSTMENT
  ADD CONSTRAINT ORIGIN_VALID7
  CHECK (ORIGIN IN (1,2,3,4,5,6,7,8,9,10,11,12,13));
  
COMMENT ON COLUMN ONSITEINVENTORYADJUSTMENT.ORIGIN
  IS '1 = Manual Correction 2 = Delivery Note 3 = Correction Ticket 4 = Soil Count 5 = Inscan 6 = Straight Even Return 7 = On-site Inventory Check 9 = Conversion 10 = Shortage At Delivery 11 = Rejected At Delivery 12 = Allocation 13 = Used OR pack';
  
