//
//  UserDefinedFields.h
//  EAMiPad
//
//  Created by temp on 4/4/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "DBQuery.h"
#import "LOVData.h"
#import "EAMField.h"

@class RecordDataController;
@class RecordData;

typedef enum {
    UDFEntityTypeWorkOrder = 0,
    UDFEntityTypeEquipment,
    UDFEntityTypePosition,
    UDFEntityTypeSystem,
    UDFEntityTypeLocation,
    UDFEntityTypeActivity,
    UDFEntityTypeWorkOrderHospitality,
    UDFEntityTypeMobileNotebook,
    UDFEntityTypeOperatorChecklist,
    UDFEntityTypePermitToWork,
    UDFEntityTypeBookLabor,
    UDFEntityTypePermitToWorkLOTO,
    UDFEntityTypeAccomplishment,
    UDFEntityTypeNonconformity,
    UDFEntityTypeObservation
}  UDFEntityType;

typedef enum {
    UDFTypeText = 0,
    UDFTypeLOV,
    UDFTypeNumber,
    UDFTypeInt,
    UDFTypeDate,
    UDFTypeDateTime,
    UDFTypeCode,
    UDFTypeCodeDesc,
    UDFTypeCheckBox,
    UDFTypeMemo,
} UDFType;

@interface UDF : NSObject

@property (nonatomic, strong) NSString *UDF_RENTITY;
@property (nonatomic, strong) NSString *UDF_FIELD;
@property (nonatomic, strong) NSString *UDF_MIN;
@property (nonatomic, strong) NSString *UDF_MAX;
@property (nonatomic, strong) NSString *UDF_LOOKUPTYPE;
@property (nonatomic, strong) NSString *UDF_LOOKUPRENTITY;
@property (nonatomic, ) int UDF_TYPE;
@property (nonatomic, strong) NSString *UDF_FIELDLABEL;
@property (nonatomic, strong) EAMField *UDF_CONTROL;
@property (nonatomic        ) BOOL      foundInConfig;
@property (nonatomic, strong) NSString *UDF_ORG;
@property (nonatomic, strong) NSString *UDF_UOM;
@property (nonatomic, strong) NSString *UDF_CURR;
@end



@interface UserDefinedFields : NSObject

+ (NSArray *)getUDFDefinationForEntity:(UDFEntityType)entityType;
+ (NSDictionary *)dictionaryFromArray:(NSArray *)array;
+ (NSString *)getGridName:(UDF *)udf;
+ (NSString *)getLOVFields:(UDF *)udf;
+ (NSString *)getLOVKeyField:(UDF *)udf;
+ (NSString *)getLOVFieldsID:(UDF *)udf;
+ (LOVData *)getLOVDataForUDF:(UDF*)udf withDefaultValue:(NSString *)defaultValue;
+ (NSString *)getPickerQuery:(NSString *)field forRentity:(NSString *)rentity;
+ (NSArray *)AddUDFKeys:(NSDictionary *)UDFields to:(NSArray *)keys ;
+ (NSArray *)AddUDFValues:(NSDictionary *)UDFields to:(NSArray *)values withRecordData:(RecordData *)recordData;
+ (void)setReadOnly:(NSDictionary *)UDFields forParent:(RecordDataController *)parent value:(BOOL)value;
+ (NSString *)validateUDFFields:(NSDictionary *)UDFields withRecordData:(RecordData *)recordData;
/* Prompt is on hold 02/25/2013
+ (NSDictionary *)getUDFCollection:(GridData *)data;
+ (EAMField *)createUDFControls:(UDF *)udf; */
+ (void)getModel:(RecordData *)model fields:(NSString **)fields values:(NSString **)values prefix:(NSString *)prefix;
+ (EAMField *)setUDFValues:(EAMField *)pField forUDF:(NSDictionary *)pUdfFields;
+ (void)setReadOnly:(NSDictionary *)UDFields forParent:(RecordDataController *)parent forField:(NSString *)fieldName value:(BOOL)value;
@end
