;+
; NAME
;          EIS_MK_PLAN
;
; PURPOSE
;          This procedure invokes the eis_mk_study GUI
;
; INPUTS
;          NONE
;
; WRITTEN
;          John A Rainnie, RAL, Jan-2006
;
; HISTORY
;          v0.1 JAR 10-Feb-2007
;               Added zdbase input into eis_mk_study_gui. This way
;               I can maintain ZDBASE even when the devious user
;               tries to fool me by resetting it on the fly.
;          v0.2 JAR 26-Feb-2007
;               Also check both ZDBASE_USER and ZDBASE_EIS environment
;               variables have been defined - if not then bail out!
;          v0.3 JAR 27-May-2008
;               Added call to "plot_pointing" method
;          v0.4 JAR 14-Jul-2008
;               Added KEYWORD "rp" - which activates remote planning mode
;          v0.5 JAR 22-Aug-2008
;               Do Remote Planning setup checking here - before invoking PT
;          v0.6 JAR 26-Aug-2008
;               Check that the studies in the timeline database do
;               actually exist in the study database.
;          v0.7 JAR 18-Sep-2008
;               Check EIS_CPT_input/internal directory exists
;          v0.8 JAR 14-Oct-2008
;               Only check tl integrity if in RP mode.
;
;-
;______________________________________________________________________________
PRO eis_mk_plan , rp = rp , response = response

; JAR 26-Aug-2008
valid = 1B

; JAR 22-Aug-2008
IF (KEYWORD_SET(rp) EQ 1) THEN BEGIN
    eis_rp_set_env_vars

    valid = eis_check_tl_integrity()
    IF (valid NE 1) THEN RETURN

    ; Refresh + create $HOME/eis_mk_plan_rp.log file
    rp_log_obj = OBJ_NEW("eis_rp_obj")
    rp_log_obj->Realize
    rp_log_obj->XMANAGER

    rp_log_obj->getProperty , textID = textID
    valid = eis_rp_check_setup(textID , 0.3)

    rp_log_obj->write_file , valid
    rp_log_obj->getProperty , tlbID = tlbID
    WIDGET_CONTROL , tlbID , /DESTROY
    OBJ_DESTROY , rp_log_obj
ENDIF
IF (valid NE 1) THEN RETURN

oMkPlan = OBJ_NEW("eis_mk_plan_gui" , rp = rp , response = response)
oMkPlan->Realize
oMkPlan->XMANAGER
oMkPlan->plot_logo
oMkPlan->plot_pointing; , /NO_POINT
oMkPlan->readPlanFromDatabase
oMkPlan->start_ini_obj
IF (KEYWORD_SET(rp) EQ 1) THEN oMkPlan->rp_setup

END