gift

Table info.

Title Gift
Description Gift

Fields

Name Type Required Index Hidden On form Title Pick list Description
GiftID int(11) PRI
TimestampCreated datetime Created The timestamp the record was created
TimestampModified datetime Last edited The timestamp the record was last edited
Version int(11) Version version
DateReceived date Acknowledged The date the exchange, donation or shipping material was received, as indicated on the yellow form
GiftDate date MUL Gift date The date the exchange, donation or shipping material was sent
GiftNumber varchar(50) MUL Gift number Gift number
IsFinancialResponsibility bit(1) Is Financial Responsibility isFinancialResponsibility
Number1 float(20,10) Quantity The number of specimens in the exchange, donation or shipping material
Number2 float(20,10) Number2 se
PurposeOfGift varchar(64) Purpose of donation Why the material is being donated
ReceivedComments varchar(255) Received comments Comments about the receipt of outgoing donations, exchange or shipping material, as indicated on the yellow form
Remarks text Description A description of the exchange, donation or shipping material
SpecialConditions text Special conditions Any special conditions about the donation
SrcGeography varchar(500) Category GiftType
  • Exchange
  • Donation
  • Shipping material
  • Special donation
Whether the gift is exchange, donation or shipping material
SrcTaxonomy varchar(500) File name The name of the exchange file
Text1 text Migration comments Details of discrepancies between L&E database, exchange scanning-in thing, and other bewildering things
Text2 text Text2 User definable.
YesNo1 bit(1) Yes No1 yesNo1
YesNo2 bit(1) Yes No2 yesNo2
DivisionID int(11) MUL
ModifiedByAgentID int(11) MUL
DisciplineID int(11) MUL
CreatedByAgentID int(11) MUL
AddressOfRecordID int(11) MUL
Contents text Contents contents
Integer1 int(11) Integer1 integer1
Integer2 int(11) Integer2 integer2
Integer3 int(11) Integer3 integer3

Indexes

Name Fields Unique Nullable
FK3069304CE675DE DisciplineID
FK3069305327F942 ModifiedByAgentID
FK3069307699B003 CreatedByAgentID
FK30693097C961D8 DivisionID
FK306930DC8B4810 AddressOfRecordID
GiftDateIDX GiftDate
GiftNumberIDX GiftNumber
PRIMARY GiftID

One-to-many relationships

Name Field Related table Related field
FK221917D59890879E GiftID giftagent GiftID
FK18B1F679890879E GiftID giftpreparation GiftID
FKE139719A9890879E GiftID shipment GiftID

Many-to-one relationships

Name Field Related table Related field
FK3069304CE675DE DisciplineID discipline UserGroupScopeId
FK3069305327F942 ModifiedByAgentID agent AgentID
FK3069307699B003 CreatedByAgentID agent AgentID
FK30693097C961D8 DivisionID division UserGroupScopeId
FK306930DC8B4810 AddressOfRecordID addressofrecord AddressOfRecordID

gift_before_insert

EventINSERT
TimingBEFORE
Statement:
DROP TRIGGER IF EXISTS gift_before_insert;
 
DELIMITER $$
 
CREATE TRIGGER gift_before_insert BEFORE INSERT ON gift
FOR EACH ROW
  BEGIN
    DECLARE var_gift_number INTEGER(11);
        DECLARE var_exchangein_number INTEGER(11);
 
        IF isnull(@DISABLE_TRIGGER) THEN
            SELECT MAX(GiftNumber)
            INTO var_gift_number
            FROM gift;
 
            SELECT MAX(Text1)
            INTO var_exchangein_number
            FROM exchangein;
 
            IF var_gift_number>=var_exchangein_number THEN
                SET NEW.GiftNumber=LPAD(var_gift_number+1, 4, '0');
            ELSE
                SET NEW.GiftNumber=LPAD(var_exchangein_number+1, 4, '0');
            END IF;
        END IF;
  END
 
DELIMITER ;