//
//  JSIChecklistDataController.h
//  EAMiPad
//
//  Created by Ram Madichetty on 9/5/13.
//
//

#import <Foundation/Foundation.h>
#import "R5JSICHECKLISTS.h"
#import "LOVData.h"
#import "PickerData.h"
#import "RecordDataController.h"
#import "R5ACTIVITIES.h"
#import "R5JSIACTREJECT.h"
#import "R5OPERATORCHECKLISTS.h"
#import "R5PERMITTOWORKLOTO.h"
#import "R5PERMITTOWORK.h"

@protocol JSIChecklistDataControllerDelegate

- (void)JSIChecklistDataControllerGetSuccess:(NSArray *)items withHeader:(NSDictionary *)header;
- (void)JSIChecklistDataControllerUpdateSuccess:(NSDictionary *)data;
- (void)JSIChecklistDataControllerFailed:(NSString *)fault;
- (void)JSIChecklistDataControllerPerformedSuccess:(NSDictionary *)data;
- (void)ChecklistDataControllerCreateFollowUpSuccess:(NSDictionary *)data;
- (void)JSIChecklistDataControllerUpdateJSIActivitySuccess:(NSDictionary *)data;
- (void)JSIChecklistDataControllerReviewedSuccess:(NSDictionary *)data;
- (void)JSIChecklistDataControllerGetDefaultSuccess:(NSArray *)items withHeader:(NSDictionary *)header;
- (void)JSIChecklistDataControllerGetEquipmentDepartmentSuccess:(NSString *)department;

@end

@interface JSIChecklistDataController : RecordDataController


@property (nonatomic,strong) NSString *workOrder;
@property (nonatomic,strong) NSString *organization;
@property (nonatomic,strong) NSString *activity;
@property (nonatomic) ConnectionMode  connectionMode;
@property (nonatomic,strong) R5JSICHECKLISTS *currentItem;
@property (nonatomic,strong) R5PERMITTOWORKLOTO *lotoRecord;
@property (nonatomic,strong) R5PERMITTOWORK *permitToWorkRecord;
@property (nonatomic, assign)   NSInteger   failedCount;
@property (nonatomic,strong) R5ACTIVITIES *activities;
@property (nonatomic,strong) NSString *hasCehckLists;
@property (nonatomic) BOOL isJSIViewer;
@property (nonatomic) BOOL isJSIReviewer;
@property (nonatomic) BOOL isJSISignals;
@property (nonatomic) BOOL isJSITrack;
@property (nonatomic) BOOL isChecklistCompleted;
@property (nonatomic) BOOL isSignalChecklistCompleted;
@property (nonatomic) BOOL isTrackChecklistCompleted;
@property (nonatomic) BOOL isViewer;
@property (nonatomic) BOOL isReviewer;
@property (nonatomic) BOOL isPERFORMBYRESPONSIBILITY;
@property (nonatomic) BOOL isPERFORMBY2RESPONSIBILITY;
@property (nonatomic) BOOL isNASelectedForCurrentItem;
@property (nonatomic) BOOL isConnected;


typedef enum
{
    Required,
    FilterResponsibility,
    FilterResponsibility2,
    FilterAttention,
    All,
    ParentKeyOccurence
}Filter;


- (id)initWithOpChklistCode:(R5OPERATORCHECKLISTS *)pOperator;
-(id)initWithLotoChecklist:(R5PERMITTOWORKLOTO *)pLotoRecord headerPermitToWork:(R5PERMITTOWORK *) pHeader;
- (id)initWithWorkOrderActivity:(NSString *)workOrder andOrganization:(NSString *)organization  activity:(NSString *)activity;
- (void)getChecklistDefault;
- (void)getChecklist;
- (void)getChecklistItems;
- (void)getChecklistItems:(Filter) pFilter;
- (void)getChecklistWithParameters:(WebQueryParameters *)parameters;
- (void)performChecklistWithUser:(NSString *)user
                    withPassword:(NSString *)password
               withSignatureType:(NSString *)signatureType;
- (void)performChecklistWithUser2:(NSString *)user
                    withPassword:(NSString *)password
               withSignatureType:(NSString *)signatureType;
- (void)reviewChecklistWithUser:(NSString *)user
                   withPassword:(NSString *)password
              withSignatureType:(NSString *)signatureType;
- (LOVData *)getLOVDataSource:(NSString *)lovName forItem:(R5ACTCHECKLISTS *) selectedItem;
- (void)updateFieldValue:(NSString *)fieldName withValues:(NSArray *)fieldValues forItem:(R5JSICHECKLISTS *)checklistItem;
-(void) getComments:(NSString *) pTaskChecklistCode;
- (void)updateChecklistItem:(R5ACTCHECKLISTS *)item;
- (void)getNonConformityTypes:(NSString *)pSearchString item:(R5ACTCHECKLISTS *)item;
- (void)getCommonNotes:(NSString *)pSearchString;
- (void)updateJSIActivity;
- (void) getJSIChecklists:(GridData *)gridData forFilter:(Filter) pFilter withResponsiblity:(NSString *)responsibility withResponsiblity2:(NSString *)responsibility2 forParentKey:(NSString *) parentKey forOccurences:(NSString *)occurence forSearch:(NSString *)searchText;
-(void) updateInsertRepeatingOccurencesRecords:(R5ACTCHECKLISTS *)item inList:(NSMutableArray<R5ACTCHECKLISTS *> *) items;
-(void) getChecklistsFollowUpCount;
- (void)CreateFollowUpWorkOrder;
-(void) getChecklistCondAsFoundGrid;
- (void)CreateDeferredMaintenance;
- (void)getEquipmentDepartment:(NSString *) code withOrg:(NSString *)org withDesc:(NSString *) desc;
- (void)getChecklistForLoto:(R5PERMITTOWORKLOTO *)pLotoRecord;


@end

